.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-html / node_modules / typescript / lib / tsc.js
1 /*! *****************************************************************************
2 Copyright (c) Microsoft Corporation. All rights reserved.
3 Licensed under the Apache License, Version 2.0 (the "License"); you may not use
4 this file except in compliance with the License. You may obtain a copy of the
5 License at http://www.apache.org/licenses/LICENSE-2.0
6
7 THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
8 KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
9 WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
10 MERCHANTABLITY OR NON-INFRINGEMENT.
11
12 See the Apache Version 2.0 License for specific language governing permissions
13 and limitations under the License.
14 ***************************************************************************** */
15
16
17 "use strict";
18 var __spreadArray = (this && this.__spreadArray) || function (to, from) {
19     for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
20         to[j] = from[i];
21     return to;
22 };
23 var __assign = (this && this.__assign) || function () {
24     __assign = Object.assign || function(t) {
25         for (var s, i = 1, n = arguments.length; i < n; i++) {
26             s = arguments[i];
27             for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
28                 t[p] = s[p];
29         }
30         return t;
31     };
32     return __assign.apply(this, arguments);
33 };
34 var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
35     if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
36     return cooked;
37 };
38 var __generator = (this && this.__generator) || function (thisArg, body) {
39     var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
40     return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
41     function verb(n) { return function (v) { return step([n, v]); }; }
42     function step(op) {
43         if (f) throw new TypeError("Generator is already executing.");
44         while (_) try {
45             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;
46             if (y = 0, t) op = [op[0] & 2, t.value];
47             switch (op[0]) {
48                 case 0: case 1: t = op; break;
49                 case 4: _.label++; return { value: op[1], done: false };
50                 case 5: _.label++; y = op[1]; op = [0]; continue;
51                 case 7: op = _.ops.pop(); _.trys.pop(); continue;
52                 default:
53                     if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
54                     if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
55                     if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
56                     if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
57                     if (t[2]) _.ops.pop();
58                     _.trys.pop(); continue;
59             }
60             op = body.call(thisArg, _);
61         } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
62         if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
63     }
64 };
65 var ts;
66 (function (ts) {
67     ts.versionMajorMinor = "4.2";
68     ts.version = "4.2.3";
69     var NativeCollections;
70     (function (NativeCollections) {
71         function tryGetNativeMap() {
72             return typeof Map !== "undefined" && "entries" in Map.prototype && new Map([[0, 0]]).size === 1 ? Map : undefined;
73         }
74         NativeCollections.tryGetNativeMap = tryGetNativeMap;
75         function tryGetNativeSet() {
76             return typeof Set !== "undefined" && "entries" in Set.prototype && new Set([0]).size === 1 ? Set : undefined;
77         }
78         NativeCollections.tryGetNativeSet = tryGetNativeSet;
79     })(NativeCollections = ts.NativeCollections || (ts.NativeCollections = {}));
80 })(ts || (ts = {}));
81 var ts;
82 (function (ts) {
83     function getCollectionImplementation(name, nativeFactory, shimFactory) {
84         var _a;
85         var constructor = (_a = ts.NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](getIterator);
86         if (constructor)
87             return constructor;
88         throw new Error("TypeScript requires an environment that provides a compatible native " + name + " implementation.");
89     }
90     ts.Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim");
91     ts.Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim");
92     function getIterator(iterable) {
93         if (iterable) {
94             if (isArray(iterable))
95                 return arrayIterator(iterable);
96             if (iterable instanceof ts.Map)
97                 return iterable.entries();
98             if (iterable instanceof ts.Set)
99                 return iterable.values();
100             throw new Error("Iteration not supported.");
101         }
102     }
103     ts.getIterator = getIterator;
104     ts.emptyArray = [];
105     ts.emptyMap = new ts.Map();
106     ts.emptySet = new ts.Set();
107     function createMap() {
108         return new ts.Map();
109     }
110     ts.createMap = createMap;
111     function createMapFromTemplate(template) {
112         var map = new ts.Map();
113         for (var key in template) {
114             if (hasOwnProperty.call(template, key)) {
115                 map.set(key, template[key]);
116             }
117         }
118         return map;
119     }
120     ts.createMapFromTemplate = createMapFromTemplate;
121     function length(array) {
122         return array ? array.length : 0;
123     }
124     ts.length = length;
125     function forEach(array, callback) {
126         if (array) {
127             for (var i = 0; i < array.length; i++) {
128                 var result = callback(array[i], i);
129                 if (result) {
130                     return result;
131                 }
132             }
133         }
134         return undefined;
135     }
136     ts.forEach = forEach;
137     function forEachRight(array, callback) {
138         if (array) {
139             for (var i = array.length - 1; i >= 0; i--) {
140                 var result = callback(array[i], i);
141                 if (result) {
142                     return result;
143                 }
144             }
145         }
146         return undefined;
147     }
148     ts.forEachRight = forEachRight;
149     function firstDefined(array, callback) {
150         if (array === undefined) {
151             return undefined;
152         }
153         for (var i = 0; i < array.length; i++) {
154             var result = callback(array[i], i);
155             if (result !== undefined) {
156                 return result;
157             }
158         }
159         return undefined;
160     }
161     ts.firstDefined = firstDefined;
162     function firstDefinedIterator(iter, callback) {
163         while (true) {
164             var iterResult = iter.next();
165             if (iterResult.done) {
166                 return undefined;
167             }
168             var result = callback(iterResult.value);
169             if (result !== undefined) {
170                 return result;
171             }
172         }
173     }
174     ts.firstDefinedIterator = firstDefinedIterator;
175     function reduceLeftIterator(iterator, f, initial) {
176         var result = initial;
177         if (iterator) {
178             for (var step = iterator.next(), pos = 0; !step.done; step = iterator.next(), pos++) {
179                 result = f(result, step.value, pos);
180             }
181         }
182         return result;
183     }
184     ts.reduceLeftIterator = reduceLeftIterator;
185     function zipWith(arrayA, arrayB, callback) {
186         var result = [];
187         ts.Debug.assertEqual(arrayA.length, arrayB.length);
188         for (var i = 0; i < arrayA.length; i++) {
189             result.push(callback(arrayA[i], arrayB[i], i));
190         }
191         return result;
192     }
193     ts.zipWith = zipWith;
194     function zipToIterator(arrayA, arrayB) {
195         ts.Debug.assertEqual(arrayA.length, arrayB.length);
196         var i = 0;
197         return {
198             next: function () {
199                 if (i === arrayA.length) {
200                     return { value: undefined, done: true };
201                 }
202                 i++;
203                 return { value: [arrayA[i - 1], arrayB[i - 1]], done: false };
204             }
205         };
206     }
207     ts.zipToIterator = zipToIterator;
208     function zipToMap(keys, values) {
209         ts.Debug.assert(keys.length === values.length);
210         var map = new ts.Map();
211         for (var i = 0; i < keys.length; ++i) {
212             map.set(keys[i], values[i]);
213         }
214         return map;
215     }
216     ts.zipToMap = zipToMap;
217     function intersperse(input, element) {
218         if (input.length <= 1) {
219             return input;
220         }
221         var result = [];
222         for (var i = 0, n = input.length; i < n; i++) {
223             if (i)
224                 result.push(element);
225             result.push(input[i]);
226         }
227         return result;
228     }
229     ts.intersperse = intersperse;
230     function every(array, callback) {
231         if (array) {
232             for (var i = 0; i < array.length; i++) {
233                 if (!callback(array[i], i)) {
234                     return false;
235                 }
236             }
237         }
238         return true;
239     }
240     ts.every = every;
241     function find(array, predicate) {
242         for (var i = 0; i < array.length; i++) {
243             var value = array[i];
244             if (predicate(value, i)) {
245                 return value;
246             }
247         }
248         return undefined;
249     }
250     ts.find = find;
251     function findLast(array, predicate) {
252         for (var i = array.length - 1; i >= 0; i--) {
253             var value = array[i];
254             if (predicate(value, i)) {
255                 return value;
256             }
257         }
258         return undefined;
259     }
260     ts.findLast = findLast;
261     function findIndex(array, predicate, startIndex) {
262         for (var i = startIndex || 0; i < array.length; i++) {
263             if (predicate(array[i], i)) {
264                 return i;
265             }
266         }
267         return -1;
268     }
269     ts.findIndex = findIndex;
270     function findLastIndex(array, predicate, startIndex) {
271         for (var i = startIndex === undefined ? array.length - 1 : startIndex; i >= 0; i--) {
272             if (predicate(array[i], i)) {
273                 return i;
274             }
275         }
276         return -1;
277     }
278     ts.findLastIndex = findLastIndex;
279     function findMap(array, callback) {
280         for (var i = 0; i < array.length; i++) {
281             var result = callback(array[i], i);
282             if (result) {
283                 return result;
284             }
285         }
286         return ts.Debug.fail();
287     }
288     ts.findMap = findMap;
289     function contains(array, value, equalityComparer) {
290         if (equalityComparer === void 0) { equalityComparer = equateValues; }
291         if (array) {
292             for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
293                 var v = array_1[_i];
294                 if (equalityComparer(v, value)) {
295                     return true;
296                 }
297             }
298         }
299         return false;
300     }
301     ts.contains = contains;
302     function arraysEqual(a, b, equalityComparer) {
303         if (equalityComparer === void 0) { equalityComparer = equateValues; }
304         return a.length === b.length && a.every(function (x, i) { return equalityComparer(x, b[i]); });
305     }
306     ts.arraysEqual = arraysEqual;
307     function indexOfAnyCharCode(text, charCodes, start) {
308         for (var i = start || 0; i < text.length; i++) {
309             if (contains(charCodes, text.charCodeAt(i))) {
310                 return i;
311             }
312         }
313         return -1;
314     }
315     ts.indexOfAnyCharCode = indexOfAnyCharCode;
316     function countWhere(array, predicate) {
317         var count = 0;
318         if (array) {
319             for (var i = 0; i < array.length; i++) {
320                 var v = array[i];
321                 if (predicate(v, i)) {
322                     count++;
323                 }
324             }
325         }
326         return count;
327     }
328     ts.countWhere = countWhere;
329     function filter(array, f) {
330         if (array) {
331             var len = array.length;
332             var i = 0;
333             while (i < len && f(array[i]))
334                 i++;
335             if (i < len) {
336                 var result = array.slice(0, i);
337                 i++;
338                 while (i < len) {
339                     var item = array[i];
340                     if (f(item)) {
341                         result.push(item);
342                     }
343                     i++;
344                 }
345                 return result;
346             }
347         }
348         return array;
349     }
350     ts.filter = filter;
351     function filterMutate(array, f) {
352         var outIndex = 0;
353         for (var i = 0; i < array.length; i++) {
354             if (f(array[i], i, array)) {
355                 array[outIndex] = array[i];
356                 outIndex++;
357             }
358         }
359         array.length = outIndex;
360     }
361     ts.filterMutate = filterMutate;
362     function clear(array) {
363         array.length = 0;
364     }
365     ts.clear = clear;
366     function map(array, f) {
367         var result;
368         if (array) {
369             result = [];
370             for (var i = 0; i < array.length; i++) {
371                 result.push(f(array[i], i));
372             }
373         }
374         return result;
375     }
376     ts.map = map;
377     function mapIterator(iter, mapFn) {
378         return {
379             next: function () {
380                 var iterRes = iter.next();
381                 return iterRes.done ? iterRes : { value: mapFn(iterRes.value), done: false };
382             }
383         };
384     }
385     ts.mapIterator = mapIterator;
386     function sameMap(array, f) {
387         if (array) {
388             for (var i = 0; i < array.length; i++) {
389                 var item = array[i];
390                 var mapped = f(item, i);
391                 if (item !== mapped) {
392                     var result = array.slice(0, i);
393                     result.push(mapped);
394                     for (i++; i < array.length; i++) {
395                         result.push(f(array[i], i));
396                     }
397                     return result;
398                 }
399             }
400         }
401         return array;
402     }
403     ts.sameMap = sameMap;
404     function flatten(array) {
405         var result = [];
406         for (var _i = 0, array_2 = array; _i < array_2.length; _i++) {
407             var v = array_2[_i];
408             if (v) {
409                 if (isArray(v)) {
410                     addRange(result, v);
411                 }
412                 else {
413                     result.push(v);
414                 }
415             }
416         }
417         return result;
418     }
419     ts.flatten = flatten;
420     function flatMap(array, mapfn) {
421         var result;
422         if (array) {
423             for (var i = 0; i < array.length; i++) {
424                 var v = mapfn(array[i], i);
425                 if (v) {
426                     if (isArray(v)) {
427                         result = addRange(result, v);
428                     }
429                     else {
430                         result = append(result, v);
431                     }
432                 }
433             }
434         }
435         return result || ts.emptyArray;
436     }
437     ts.flatMap = flatMap;
438     function flatMapToMutable(array, mapfn) {
439         var result = [];
440         if (array) {
441             for (var i = 0; i < array.length; i++) {
442                 var v = mapfn(array[i], i);
443                 if (v) {
444                     if (isArray(v)) {
445                         addRange(result, v);
446                     }
447                     else {
448                         result.push(v);
449                     }
450                 }
451             }
452         }
453         return result;
454     }
455     ts.flatMapToMutable = flatMapToMutable;
456     function flatMapIterator(iter, mapfn) {
457         var first = iter.next();
458         if (first.done) {
459             return ts.emptyIterator;
460         }
461         var currentIter = getIterator(first.value);
462         return {
463             next: function () {
464                 while (true) {
465                     var currentRes = currentIter.next();
466                     if (!currentRes.done) {
467                         return currentRes;
468                     }
469                     var iterRes = iter.next();
470                     if (iterRes.done) {
471                         return iterRes;
472                     }
473                     currentIter = getIterator(iterRes.value);
474                 }
475             },
476         };
477         function getIterator(x) {
478             var res = mapfn(x);
479             return res === undefined ? ts.emptyIterator : isArray(res) ? arrayIterator(res) : res;
480         }
481     }
482     ts.flatMapIterator = flatMapIterator;
483     function sameFlatMap(array, mapfn) {
484         var result;
485         if (array) {
486             for (var i = 0; i < array.length; i++) {
487                 var item = array[i];
488                 var mapped = mapfn(item, i);
489                 if (result || item !== mapped || isArray(mapped)) {
490                     if (!result) {
491                         result = array.slice(0, i);
492                     }
493                     if (isArray(mapped)) {
494                         addRange(result, mapped);
495                     }
496                     else {
497                         result.push(mapped);
498                     }
499                 }
500             }
501         }
502         return result || array;
503     }
504     ts.sameFlatMap = sameFlatMap;
505     function mapAllOrFail(array, mapFn) {
506         var result = [];
507         for (var i = 0; i < array.length; i++) {
508             var mapped = mapFn(array[i], i);
509             if (mapped === undefined) {
510                 return undefined;
511             }
512             result.push(mapped);
513         }
514         return result;
515     }
516     ts.mapAllOrFail = mapAllOrFail;
517     function mapDefined(array, mapFn) {
518         var result = [];
519         if (array) {
520             for (var i = 0; i < array.length; i++) {
521                 var mapped = mapFn(array[i], i);
522                 if (mapped !== undefined) {
523                     result.push(mapped);
524                 }
525             }
526         }
527         return result;
528     }
529     ts.mapDefined = mapDefined;
530     function mapDefinedIterator(iter, mapFn) {
531         return {
532             next: function () {
533                 while (true) {
534                     var res = iter.next();
535                     if (res.done) {
536                         return res;
537                     }
538                     var value = mapFn(res.value);
539                     if (value !== undefined) {
540                         return { value: value, done: false };
541                     }
542                 }
543             }
544         };
545     }
546     ts.mapDefinedIterator = mapDefinedIterator;
547     function mapDefinedEntries(map, f) {
548         if (!map) {
549             return undefined;
550         }
551         var result = new ts.Map();
552         map.forEach(function (value, key) {
553             var entry = f(key, value);
554             if (entry !== undefined) {
555                 var newKey = entry[0], newValue = entry[1];
556                 if (newKey !== undefined && newValue !== undefined) {
557                     result.set(newKey, newValue);
558                 }
559             }
560         });
561         return result;
562     }
563     ts.mapDefinedEntries = mapDefinedEntries;
564     function mapDefinedValues(set, f) {
565         if (set) {
566             var result_1 = new ts.Set();
567             set.forEach(function (value) {
568                 var newValue = f(value);
569                 if (newValue !== undefined) {
570                     result_1.add(newValue);
571                 }
572             });
573             return result_1;
574         }
575     }
576     ts.mapDefinedValues = mapDefinedValues;
577     function getOrUpdate(map, key, callback) {
578         if (map.has(key)) {
579             return map.get(key);
580         }
581         var value = callback();
582         map.set(key, value);
583         return value;
584     }
585     ts.getOrUpdate = getOrUpdate;
586     function tryAddToSet(set, value) {
587         if (!set.has(value)) {
588             set.add(value);
589             return true;
590         }
591         return false;
592     }
593     ts.tryAddToSet = tryAddToSet;
594     ts.emptyIterator = { next: function () { return ({ value: undefined, done: true }); } };
595     function singleIterator(value) {
596         var done = false;
597         return {
598             next: function () {
599                 var wasDone = done;
600                 done = true;
601                 return wasDone ? { value: undefined, done: true } : { value: value, done: false };
602             }
603         };
604     }
605     ts.singleIterator = singleIterator;
606     function spanMap(array, keyfn, mapfn) {
607         var result;
608         if (array) {
609             result = [];
610             var len = array.length;
611             var previousKey = void 0;
612             var key = void 0;
613             var start = 0;
614             var pos = 0;
615             while (start < len) {
616                 while (pos < len) {
617                     var value = array[pos];
618                     key = keyfn(value, pos);
619                     if (pos === 0) {
620                         previousKey = key;
621                     }
622                     else if (key !== previousKey) {
623                         break;
624                     }
625                     pos++;
626                 }
627                 if (start < pos) {
628                     var v = mapfn(array.slice(start, pos), previousKey, start, pos);
629                     if (v) {
630                         result.push(v);
631                     }
632                     start = pos;
633                 }
634                 previousKey = key;
635                 pos++;
636             }
637         }
638         return result;
639     }
640     ts.spanMap = spanMap;
641     function mapEntries(map, f) {
642         if (!map) {
643             return undefined;
644         }
645         var result = new ts.Map();
646         map.forEach(function (value, key) {
647             var _a = f(key, value), newKey = _a[0], newValue = _a[1];
648             result.set(newKey, newValue);
649         });
650         return result;
651     }
652     ts.mapEntries = mapEntries;
653     function some(array, predicate) {
654         if (array) {
655             if (predicate) {
656                 for (var _i = 0, array_3 = array; _i < array_3.length; _i++) {
657                     var v = array_3[_i];
658                     if (predicate(v)) {
659                         return true;
660                     }
661                 }
662             }
663             else {
664                 return array.length > 0;
665             }
666         }
667         return false;
668     }
669     ts.some = some;
670     function getRangesWhere(arr, pred, cb) {
671         var start;
672         for (var i = 0; i < arr.length; i++) {
673             if (pred(arr[i])) {
674                 start = start === undefined ? i : start;
675             }
676             else {
677                 if (start !== undefined) {
678                     cb(start, i);
679                     start = undefined;
680                 }
681             }
682         }
683         if (start !== undefined)
684             cb(start, arr.length);
685     }
686     ts.getRangesWhere = getRangesWhere;
687     function concatenate(array1, array2) {
688         if (!some(array2))
689             return array1;
690         if (!some(array1))
691             return array2;
692         return __spreadArray(__spreadArray([], array1), array2);
693     }
694     ts.concatenate = concatenate;
695     function selectIndex(_, i) {
696         return i;
697     }
698     function indicesOf(array) {
699         return array.map(selectIndex);
700     }
701     ts.indicesOf = indicesOf;
702     function deduplicateRelational(array, equalityComparer, comparer) {
703         var indices = indicesOf(array);
704         stableSortIndices(array, indices, comparer);
705         var last = array[indices[0]];
706         var deduplicated = [indices[0]];
707         for (var i = 1; i < indices.length; i++) {
708             var index = indices[i];
709             var item = array[index];
710             if (!equalityComparer(last, item)) {
711                 deduplicated.push(index);
712                 last = item;
713             }
714         }
715         deduplicated.sort();
716         return deduplicated.map(function (i) { return array[i]; });
717     }
718     function deduplicateEquality(array, equalityComparer) {
719         var result = [];
720         for (var _i = 0, array_4 = array; _i < array_4.length; _i++) {
721             var item = array_4[_i];
722             pushIfUnique(result, item, equalityComparer);
723         }
724         return result;
725     }
726     function deduplicate(array, equalityComparer, comparer) {
727         return array.length === 0 ? [] :
728             array.length === 1 ? array.slice() :
729                 comparer ? deduplicateRelational(array, equalityComparer, comparer) :
730                     deduplicateEquality(array, equalityComparer);
731     }
732     ts.deduplicate = deduplicate;
733     function deduplicateSorted(array, comparer) {
734         if (array.length === 0)
735             return ts.emptyArray;
736         var last = array[0];
737         var deduplicated = [last];
738         for (var i = 1; i < array.length; i++) {
739             var next = array[i];
740             switch (comparer(next, last)) {
741                 case true:
742                 case 0:
743                     continue;
744                 case -1:
745                     return ts.Debug.fail("Array is unsorted.");
746             }
747             deduplicated.push(last = next);
748         }
749         return deduplicated;
750     }
751     function insertSorted(array, insert, compare) {
752         if (array.length === 0) {
753             array.push(insert);
754             return;
755         }
756         var insertIndex = binarySearch(array, insert, identity, compare);
757         if (insertIndex < 0) {
758             array.splice(~insertIndex, 0, insert);
759         }
760     }
761     ts.insertSorted = insertSorted;
762     function sortAndDeduplicate(array, comparer, equalityComparer) {
763         return deduplicateSorted(sort(array, comparer), equalityComparer || comparer || compareStringsCaseSensitive);
764     }
765     ts.sortAndDeduplicate = sortAndDeduplicate;
766     function arrayIsSorted(array, comparer) {
767         if (array.length < 2)
768             return true;
769         var prevElement = array[0];
770         for (var _i = 0, _a = array.slice(1); _i < _a.length; _i++) {
771             var element = _a[_i];
772             if (comparer(prevElement, element) === 1) {
773                 return false;
774             }
775             prevElement = element;
776         }
777         return true;
778     }
779     ts.arrayIsSorted = arrayIsSorted;
780     function arrayIsEqualTo(array1, array2, equalityComparer) {
781         if (equalityComparer === void 0) { equalityComparer = equateValues; }
782         if (!array1 || !array2) {
783             return array1 === array2;
784         }
785         if (array1.length !== array2.length) {
786             return false;
787         }
788         for (var i = 0; i < array1.length; i++) {
789             if (!equalityComparer(array1[i], array2[i], i)) {
790                 return false;
791             }
792         }
793         return true;
794     }
795     ts.arrayIsEqualTo = arrayIsEqualTo;
796     function compact(array) {
797         var result;
798         if (array) {
799             for (var i = 0; i < array.length; i++) {
800                 var v = array[i];
801                 if (result || !v) {
802                     if (!result) {
803                         result = array.slice(0, i);
804                     }
805                     if (v) {
806                         result.push(v);
807                     }
808                 }
809             }
810         }
811         return result || array;
812     }
813     ts.compact = compact;
814     function relativeComplement(arrayA, arrayB, comparer) {
815         if (!arrayB || !arrayA || arrayB.length === 0 || arrayA.length === 0)
816             return arrayB;
817         var result = [];
818         loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) {
819             if (offsetB > 0) {
820                 ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0);
821             }
822             loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) {
823                 if (offsetA > startA) {
824                     ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0);
825                 }
826                 switch (comparer(arrayB[offsetB], arrayA[offsetA])) {
827                     case -1:
828                         result.push(arrayB[offsetB]);
829                         continue loopB;
830                     case 0:
831                         continue loopB;
832                     case 1:
833                         continue loopA;
834                 }
835             }
836         }
837         return result;
838     }
839     ts.relativeComplement = relativeComplement;
840     function sum(array, prop) {
841         var result = 0;
842         for (var _i = 0, array_5 = array; _i < array_5.length; _i++) {
843             var v = array_5[_i];
844             result += v[prop];
845         }
846         return result;
847     }
848     ts.sum = sum;
849     function append(to, value) {
850         if (value === undefined)
851             return to;
852         if (to === undefined)
853             return [value];
854         to.push(value);
855         return to;
856     }
857     ts.append = append;
858     function combine(xs, ys) {
859         if (xs === undefined)
860             return ys;
861         if (ys === undefined)
862             return xs;
863         if (isArray(xs))
864             return isArray(ys) ? concatenate(xs, ys) : append(xs, ys);
865         if (isArray(ys))
866             return append(ys, xs);
867         return [xs, ys];
868     }
869     ts.combine = combine;
870     function toOffset(array, offset) {
871         return offset < 0 ? array.length + offset : offset;
872     }
873     function addRange(to, from, start, end) {
874         if (from === undefined || from.length === 0)
875             return to;
876         if (to === undefined)
877             return from.slice(start, end);
878         start = start === undefined ? 0 : toOffset(from, start);
879         end = end === undefined ? from.length : toOffset(from, end);
880         for (var i = start; i < end && i < from.length; i++) {
881             if (from[i] !== undefined) {
882                 to.push(from[i]);
883             }
884         }
885         return to;
886     }
887     ts.addRange = addRange;
888     function pushIfUnique(array, toAdd, equalityComparer) {
889         if (contains(array, toAdd, equalityComparer)) {
890             return false;
891         }
892         else {
893             array.push(toAdd);
894             return true;
895         }
896     }
897     ts.pushIfUnique = pushIfUnique;
898     function appendIfUnique(array, toAdd, equalityComparer) {
899         if (array) {
900             pushIfUnique(array, toAdd, equalityComparer);
901             return array;
902         }
903         else {
904             return [toAdd];
905         }
906     }
907     ts.appendIfUnique = appendIfUnique;
908     function stableSortIndices(array, indices, comparer) {
909         indices.sort(function (x, y) { return comparer(array[x], array[y]) || compareValues(x, y); });
910     }
911     function sort(array, comparer) {
912         return (array.length === 0 ? array : array.slice().sort(comparer));
913     }
914     ts.sort = sort;
915     function arrayIterator(array) {
916         var i = 0;
917         return { next: function () {
918                 if (i === array.length) {
919                     return { value: undefined, done: true };
920                 }
921                 else {
922                     i++;
923                     return { value: array[i - 1], done: false };
924                 }
925             } };
926     }
927     ts.arrayIterator = arrayIterator;
928     function arrayReverseIterator(array) {
929         var i = array.length;
930         return {
931             next: function () {
932                 if (i === 0) {
933                     return { value: undefined, done: true };
934                 }
935                 else {
936                     i--;
937                     return { value: array[i], done: false };
938                 }
939             }
940         };
941     }
942     ts.arrayReverseIterator = arrayReverseIterator;
943     function stableSort(array, comparer) {
944         var indices = indicesOf(array);
945         stableSortIndices(array, indices, comparer);
946         return indices.map(function (i) { return array[i]; });
947     }
948     ts.stableSort = stableSort;
949     function rangeEquals(array1, array2, pos, end) {
950         while (pos < end) {
951             if (array1[pos] !== array2[pos]) {
952                 return false;
953             }
954             pos++;
955         }
956         return true;
957     }
958     ts.rangeEquals = rangeEquals;
959     function elementAt(array, offset) {
960         if (array) {
961             offset = toOffset(array, offset);
962             if (offset < array.length) {
963                 return array[offset];
964             }
965         }
966         return undefined;
967     }
968     ts.elementAt = elementAt;
969     function firstOrUndefined(array) {
970         return array.length === 0 ? undefined : array[0];
971     }
972     ts.firstOrUndefined = firstOrUndefined;
973     function first(array) {
974         ts.Debug.assert(array.length !== 0);
975         return array[0];
976     }
977     ts.first = first;
978     function lastOrUndefined(array) {
979         return array.length === 0 ? undefined : array[array.length - 1];
980     }
981     ts.lastOrUndefined = lastOrUndefined;
982     function last(array) {
983         ts.Debug.assert(array.length !== 0);
984         return array[array.length - 1];
985     }
986     ts.last = last;
987     function singleOrUndefined(array) {
988         return array && array.length === 1
989             ? array[0]
990             : undefined;
991     }
992     ts.singleOrUndefined = singleOrUndefined;
993     function singleOrMany(array) {
994         return array && array.length === 1
995             ? array[0]
996             : array;
997     }
998     ts.singleOrMany = singleOrMany;
999     function replaceElement(array, index, value) {
1000         var result = array.slice(0);
1001         result[index] = value;
1002         return result;
1003     }
1004     ts.replaceElement = replaceElement;
1005     function binarySearch(array, value, keySelector, keyComparer, offset) {
1006         return binarySearchKey(array, keySelector(value), keySelector, keyComparer, offset);
1007     }
1008     ts.binarySearch = binarySearch;
1009     function binarySearchKey(array, key, keySelector, keyComparer, offset) {
1010         if (!some(array)) {
1011             return -1;
1012         }
1013         var low = offset || 0;
1014         var high = array.length - 1;
1015         while (low <= high) {
1016             var middle = low + ((high - low) >> 1);
1017             var midKey = keySelector(array[middle], middle);
1018             switch (keyComparer(midKey, key)) {
1019                 case -1:
1020                     low = middle + 1;
1021                     break;
1022                 case 0:
1023                     return middle;
1024                 case 1:
1025                     high = middle - 1;
1026                     break;
1027             }
1028         }
1029         return ~low;
1030     }
1031     ts.binarySearchKey = binarySearchKey;
1032     function reduceLeft(array, f, initial, start, count) {
1033         if (array && array.length > 0) {
1034             var size = array.length;
1035             if (size > 0) {
1036                 var pos = start === undefined || start < 0 ? 0 : start;
1037                 var end = count === undefined || pos + count > size - 1 ? size - 1 : pos + count;
1038                 var result = void 0;
1039                 if (arguments.length <= 2) {
1040                     result = array[pos];
1041                     pos++;
1042                 }
1043                 else {
1044                     result = initial;
1045                 }
1046                 while (pos <= end) {
1047                     result = f(result, array[pos], pos);
1048                     pos++;
1049                 }
1050                 return result;
1051             }
1052         }
1053         return initial;
1054     }
1055     ts.reduceLeft = reduceLeft;
1056     var hasOwnProperty = Object.prototype.hasOwnProperty;
1057     function hasProperty(map, key) {
1058         return hasOwnProperty.call(map, key);
1059     }
1060     ts.hasProperty = hasProperty;
1061     function getProperty(map, key) {
1062         return hasOwnProperty.call(map, key) ? map[key] : undefined;
1063     }
1064     ts.getProperty = getProperty;
1065     function getOwnKeys(map) {
1066         var keys = [];
1067         for (var key in map) {
1068             if (hasOwnProperty.call(map, key)) {
1069                 keys.push(key);
1070             }
1071         }
1072         return keys;
1073     }
1074     ts.getOwnKeys = getOwnKeys;
1075     function getAllKeys(obj) {
1076         var result = [];
1077         do {
1078             var names = Object.getOwnPropertyNames(obj);
1079             for (var _i = 0, names_1 = names; _i < names_1.length; _i++) {
1080                 var name = names_1[_i];
1081                 pushIfUnique(result, name);
1082             }
1083         } while (obj = Object.getPrototypeOf(obj));
1084         return result;
1085     }
1086     ts.getAllKeys = getAllKeys;
1087     function getOwnValues(sparseArray) {
1088         var values = [];
1089         for (var key in sparseArray) {
1090             if (hasOwnProperty.call(sparseArray, key)) {
1091                 values.push(sparseArray[key]);
1092             }
1093         }
1094         return values;
1095     }
1096     ts.getOwnValues = getOwnValues;
1097     var _entries = Object.entries || (function (obj) {
1098         var keys = getOwnKeys(obj);
1099         var result = Array(keys.length);
1100         for (var i = 0; i < keys.length; i++) {
1101             result[i] = [keys[i], obj[keys[i]]];
1102         }
1103         return result;
1104     });
1105     function getEntries(obj) {
1106         return obj ? _entries(obj) : [];
1107     }
1108     ts.getEntries = getEntries;
1109     function arrayOf(count, f) {
1110         var result = new Array(count);
1111         for (var i = 0; i < count; i++) {
1112             result[i] = f(i);
1113         }
1114         return result;
1115     }
1116     ts.arrayOf = arrayOf;
1117     function arrayFrom(iterator, map) {
1118         var result = [];
1119         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
1120             result.push(map ? map(iterResult.value) : iterResult.value);
1121         }
1122         return result;
1123     }
1124     ts.arrayFrom = arrayFrom;
1125     function assign(t) {
1126         var args = [];
1127         for (var _i = 1; _i < arguments.length; _i++) {
1128             args[_i - 1] = arguments[_i];
1129         }
1130         for (var _a = 0, args_1 = args; _a < args_1.length; _a++) {
1131             var arg = args_1[_a];
1132             if (arg === undefined)
1133                 continue;
1134             for (var p in arg) {
1135                 if (hasProperty(arg, p)) {
1136                     t[p] = arg[p];
1137                 }
1138             }
1139         }
1140         return t;
1141     }
1142     ts.assign = assign;
1143     function equalOwnProperties(left, right, equalityComparer) {
1144         if (equalityComparer === void 0) { equalityComparer = equateValues; }
1145         if (left === right)
1146             return true;
1147         if (!left || !right)
1148             return false;
1149         for (var key in left) {
1150             if (hasOwnProperty.call(left, key)) {
1151                 if (!hasOwnProperty.call(right, key))
1152                     return false;
1153                 if (!equalityComparer(left[key], right[key]))
1154                     return false;
1155             }
1156         }
1157         for (var key in right) {
1158             if (hasOwnProperty.call(right, key)) {
1159                 if (!hasOwnProperty.call(left, key))
1160                     return false;
1161             }
1162         }
1163         return true;
1164     }
1165     ts.equalOwnProperties = equalOwnProperties;
1166     function arrayToMap(array, makeKey, makeValue) {
1167         if (makeValue === void 0) { makeValue = identity; }
1168         var result = new ts.Map();
1169         for (var _i = 0, array_6 = array; _i < array_6.length; _i++) {
1170             var value = array_6[_i];
1171             var key = makeKey(value);
1172             if (key !== undefined)
1173                 result.set(key, makeValue(value));
1174         }
1175         return result;
1176     }
1177     ts.arrayToMap = arrayToMap;
1178     function arrayToNumericMap(array, makeKey, makeValue) {
1179         if (makeValue === void 0) { makeValue = identity; }
1180         var result = [];
1181         for (var _i = 0, array_7 = array; _i < array_7.length; _i++) {
1182             var value = array_7[_i];
1183             result[makeKey(value)] = makeValue(value);
1184         }
1185         return result;
1186     }
1187     ts.arrayToNumericMap = arrayToNumericMap;
1188     function arrayToMultiMap(values, makeKey, makeValue) {
1189         if (makeValue === void 0) { makeValue = identity; }
1190         var result = createMultiMap();
1191         for (var _i = 0, values_1 = values; _i < values_1.length; _i++) {
1192             var value = values_1[_i];
1193             result.add(makeKey(value), makeValue(value));
1194         }
1195         return result;
1196     }
1197     ts.arrayToMultiMap = arrayToMultiMap;
1198     function group(values, getGroupId, resultSelector) {
1199         if (resultSelector === void 0) { resultSelector = identity; }
1200         return arrayFrom(arrayToMultiMap(values, getGroupId).values(), resultSelector);
1201     }
1202     ts.group = group;
1203     function clone(object) {
1204         var result = {};
1205         for (var id in object) {
1206             if (hasOwnProperty.call(object, id)) {
1207                 result[id] = object[id];
1208             }
1209         }
1210         return result;
1211     }
1212     ts.clone = clone;
1213     function extend(first, second) {
1214         var result = {};
1215         for (var id in second) {
1216             if (hasOwnProperty.call(second, id)) {
1217                 result[id] = second[id];
1218             }
1219         }
1220         for (var id in first) {
1221             if (hasOwnProperty.call(first, id)) {
1222                 result[id] = first[id];
1223             }
1224         }
1225         return result;
1226     }
1227     ts.extend = extend;
1228     function copyProperties(first, second) {
1229         for (var id in second) {
1230             if (hasOwnProperty.call(second, id)) {
1231                 first[id] = second[id];
1232             }
1233         }
1234     }
1235     ts.copyProperties = copyProperties;
1236     function maybeBind(obj, fn) {
1237         return fn ? fn.bind(obj) : undefined;
1238     }
1239     ts.maybeBind = maybeBind;
1240     function createMultiMap() {
1241         var map = new ts.Map();
1242         map.add = multiMapAdd;
1243         map.remove = multiMapRemove;
1244         return map;
1245     }
1246     ts.createMultiMap = createMultiMap;
1247     function multiMapAdd(key, value) {
1248         var values = this.get(key);
1249         if (values) {
1250             values.push(value);
1251         }
1252         else {
1253             this.set(key, values = [value]);
1254         }
1255         return values;
1256     }
1257     function multiMapRemove(key, value) {
1258         var values = this.get(key);
1259         if (values) {
1260             unorderedRemoveItem(values, value);
1261             if (!values.length) {
1262                 this.delete(key);
1263             }
1264         }
1265     }
1266     function createUnderscoreEscapedMultiMap() {
1267         return createMultiMap();
1268     }
1269     ts.createUnderscoreEscapedMultiMap = createUnderscoreEscapedMultiMap;
1270     function isArray(value) {
1271         return Array.isArray ? Array.isArray(value) : value instanceof Array;
1272     }
1273     ts.isArray = isArray;
1274     function toArray(value) {
1275         return isArray(value) ? value : [value];
1276     }
1277     ts.toArray = toArray;
1278     function isString(text) {
1279         return typeof text === "string";
1280     }
1281     ts.isString = isString;
1282     function isNumber(x) {
1283         return typeof x === "number";
1284     }
1285     ts.isNumber = isNumber;
1286     function tryCast(value, test) {
1287         return value !== undefined && test(value) ? value : undefined;
1288     }
1289     ts.tryCast = tryCast;
1290     function cast(value, test) {
1291         if (value !== undefined && test(value))
1292             return value;
1293         return ts.Debug.fail("Invalid cast. The supplied value " + value + " did not pass the test '" + ts.Debug.getFunctionName(test) + "'.");
1294     }
1295     ts.cast = cast;
1296     function noop(_) { }
1297     ts.noop = noop;
1298     function returnFalse() { return false; }
1299     ts.returnFalse = returnFalse;
1300     function returnTrue() { return true; }
1301     ts.returnTrue = returnTrue;
1302     function returnUndefined() { return undefined; }
1303     ts.returnUndefined = returnUndefined;
1304     function identity(x) { return x; }
1305     ts.identity = identity;
1306     function toLowerCase(x) { return x.toLowerCase(); }
1307     ts.toLowerCase = toLowerCase;
1308     var fileNameLowerCaseRegExp = /[^\u0130\u0131\u00DFa-z0-9\\/:\-_\. ]+/g;
1309     function toFileNameLowerCase(x) {
1310         return fileNameLowerCaseRegExp.test(x) ?
1311             x.replace(fileNameLowerCaseRegExp, toLowerCase) :
1312             x;
1313     }
1314     ts.toFileNameLowerCase = toFileNameLowerCase;
1315     function notImplemented() {
1316         throw new Error("Not implemented");
1317     }
1318     ts.notImplemented = notImplemented;
1319     function memoize(callback) {
1320         var value;
1321         return function () {
1322             if (callback) {
1323                 value = callback();
1324                 callback = undefined;
1325             }
1326             return value;
1327         };
1328     }
1329     ts.memoize = memoize;
1330     function memoizeOne(callback) {
1331         var map = new ts.Map();
1332         return function (arg) {
1333             var key = typeof arg + ":" + arg;
1334             var value = map.get(key);
1335             if (value === undefined && !map.has(key)) {
1336                 value = callback(arg);
1337                 map.set(key, value);
1338             }
1339             return value;
1340         };
1341     }
1342     ts.memoizeOne = memoizeOne;
1343     function compose(a, b, c, d, e) {
1344         if (!!e) {
1345             var args_2 = [];
1346             for (var i = 0; i < arguments.length; i++) {
1347                 args_2[i] = arguments[i];
1348             }
1349             return function (t) { return reduceLeft(args_2, function (u, f) { return f(u); }, t); };
1350         }
1351         else if (d) {
1352             return function (t) { return d(c(b(a(t)))); };
1353         }
1354         else if (c) {
1355             return function (t) { return c(b(a(t))); };
1356         }
1357         else if (b) {
1358             return function (t) { return b(a(t)); };
1359         }
1360         else if (a) {
1361             return function (t) { return a(t); };
1362         }
1363         else {
1364             return function (t) { return t; };
1365         }
1366     }
1367     ts.compose = compose;
1368     function equateValues(a, b) {
1369         return a === b;
1370     }
1371     ts.equateValues = equateValues;
1372     function equateStringsCaseInsensitive(a, b) {
1373         return a === b
1374             || a !== undefined
1375                 && b !== undefined
1376                 && a.toUpperCase() === b.toUpperCase();
1377     }
1378     ts.equateStringsCaseInsensitive = equateStringsCaseInsensitive;
1379     function equateStringsCaseSensitive(a, b) {
1380         return equateValues(a, b);
1381     }
1382     ts.equateStringsCaseSensitive = equateStringsCaseSensitive;
1383     function compareComparableValues(a, b) {
1384         return a === b ? 0 :
1385             a === undefined ? -1 :
1386                 b === undefined ? 1 :
1387                     a < b ? -1 :
1388                         1;
1389     }
1390     function compareValues(a, b) {
1391         return compareComparableValues(a, b);
1392     }
1393     ts.compareValues = compareValues;
1394     function compareTextSpans(a, b) {
1395         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);
1396     }
1397     ts.compareTextSpans = compareTextSpans;
1398     function min(a, b, compare) {
1399         return compare(a, b) === -1 ? a : b;
1400     }
1401     ts.min = min;
1402     function compareStringsCaseInsensitive(a, b) {
1403         if (a === b)
1404             return 0;
1405         if (a === undefined)
1406             return -1;
1407         if (b === undefined)
1408             return 1;
1409         a = a.toUpperCase();
1410         b = b.toUpperCase();
1411         return a < b ? -1 : a > b ? 1 : 0;
1412     }
1413     ts.compareStringsCaseInsensitive = compareStringsCaseInsensitive;
1414     function compareStringsCaseSensitive(a, b) {
1415         return compareComparableValues(a, b);
1416     }
1417     ts.compareStringsCaseSensitive = compareStringsCaseSensitive;
1418     function getStringComparer(ignoreCase) {
1419         return ignoreCase ? compareStringsCaseInsensitive : compareStringsCaseSensitive;
1420     }
1421     ts.getStringComparer = getStringComparer;
1422     var createUIStringComparer = (function () {
1423         var defaultComparer;
1424         var enUSComparer;
1425         var stringComparerFactory = getStringComparerFactory();
1426         return createStringComparer;
1427         function compareWithCallback(a, b, comparer) {
1428             if (a === b)
1429                 return 0;
1430             if (a === undefined)
1431                 return -1;
1432             if (b === undefined)
1433                 return 1;
1434             var value = comparer(a, b);
1435             return value < 0 ? -1 : value > 0 ? 1 : 0;
1436         }
1437         function createIntlCollatorStringComparer(locale) {
1438             var comparer = new Intl.Collator(locale, { usage: "sort", sensitivity: "variant" }).compare;
1439             return function (a, b) { return compareWithCallback(a, b, comparer); };
1440         }
1441         function createLocaleCompareStringComparer(locale) {
1442             if (locale !== undefined)
1443                 return createFallbackStringComparer();
1444             return function (a, b) { return compareWithCallback(a, b, compareStrings); };
1445             function compareStrings(a, b) {
1446                 return a.localeCompare(b);
1447             }
1448         }
1449         function createFallbackStringComparer() {
1450             return function (a, b) { return compareWithCallback(a, b, compareDictionaryOrder); };
1451             function compareDictionaryOrder(a, b) {
1452                 return compareStrings(a.toUpperCase(), b.toUpperCase()) || compareStrings(a, b);
1453             }
1454             function compareStrings(a, b) {
1455                 return a < b ? -1 : a > b ? 1 : 0;
1456             }
1457         }
1458         function getStringComparerFactory() {
1459             if (typeof Intl === "object" && typeof Intl.Collator === "function") {
1460                 return createIntlCollatorStringComparer;
1461             }
1462             if (typeof String.prototype.localeCompare === "function" &&
1463                 typeof String.prototype.toLocaleUpperCase === "function" &&
1464                 "a".localeCompare("B") < 0) {
1465                 return createLocaleCompareStringComparer;
1466             }
1467             return createFallbackStringComparer;
1468         }
1469         function createStringComparer(locale) {
1470             if (locale === undefined) {
1471                 return defaultComparer || (defaultComparer = stringComparerFactory(locale));
1472             }
1473             else if (locale === "en-US") {
1474                 return enUSComparer || (enUSComparer = stringComparerFactory(locale));
1475             }
1476             else {
1477                 return stringComparerFactory(locale);
1478             }
1479         }
1480     })();
1481     var uiComparerCaseSensitive;
1482     var uiLocale;
1483     function getUILocale() {
1484         return uiLocale;
1485     }
1486     ts.getUILocale = getUILocale;
1487     function setUILocale(value) {
1488         if (uiLocale !== value) {
1489             uiLocale = value;
1490             uiComparerCaseSensitive = undefined;
1491         }
1492     }
1493     ts.setUILocale = setUILocale;
1494     function compareStringsCaseSensitiveUI(a, b) {
1495         var comparer = uiComparerCaseSensitive || (uiComparerCaseSensitive = createUIStringComparer(uiLocale));
1496         return comparer(a, b);
1497     }
1498     ts.compareStringsCaseSensitiveUI = compareStringsCaseSensitiveUI;
1499     function compareProperties(a, b, key, comparer) {
1500         return a === b ? 0 :
1501             a === undefined ? -1 :
1502                 b === undefined ? 1 :
1503                     comparer(a[key], b[key]);
1504     }
1505     ts.compareProperties = compareProperties;
1506     function compareBooleans(a, b) {
1507         return compareValues(a ? 1 : 0, b ? 1 : 0);
1508     }
1509     ts.compareBooleans = compareBooleans;
1510     function getSpellingSuggestion(name, candidates, getName) {
1511         var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34));
1512         var bestDistance = Math.floor(name.length * 0.4) + 1;
1513         var bestCandidate;
1514         for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
1515             var candidate = candidates_1[_i];
1516             var candidateName = getName(candidate);
1517             if (candidateName !== undefined && Math.abs(candidateName.length - name.length) <= maximumLengthDifference) {
1518                 if (candidateName === name) {
1519                     continue;
1520                 }
1521                 if (candidateName.length < 3 && candidateName.toLowerCase() !== name.toLowerCase()) {
1522                     continue;
1523                 }
1524                 var distance = levenshteinWithMax(name, candidateName, bestDistance - 0.1);
1525                 if (distance === undefined) {
1526                     continue;
1527                 }
1528                 ts.Debug.assert(distance < bestDistance);
1529                 bestDistance = distance;
1530                 bestCandidate = candidate;
1531             }
1532         }
1533         return bestCandidate;
1534     }
1535     ts.getSpellingSuggestion = getSpellingSuggestion;
1536     function levenshteinWithMax(s1, s2, max) {
1537         var previous = new Array(s2.length + 1);
1538         var current = new Array(s2.length + 1);
1539         var big = max + 0.01;
1540         for (var i = 0; i <= s2.length; i++) {
1541             previous[i] = i;
1542         }
1543         for (var i = 1; i <= s1.length; i++) {
1544             var c1 = s1.charCodeAt(i - 1);
1545             var minJ = Math.ceil(i > max ? i - max : 1);
1546             var maxJ = Math.floor(s2.length > max + i ? max + i : s2.length);
1547             current[0] = i;
1548             var colMin = i;
1549             for (var j = 1; j < minJ; j++) {
1550                 current[j] = big;
1551             }
1552             for (var j = minJ; j <= maxJ; j++) {
1553                 var substitutionDistance = s1[i - 1].toLowerCase() === s2[j - 1].toLowerCase()
1554                     ? (previous[j - 1] + 0.1)
1555                     : (previous[j - 1] + 2);
1556                 var dist = c1 === s2.charCodeAt(j - 1)
1557                     ? previous[j - 1]
1558                     : Math.min(previous[j] + 1, current[j - 1] + 1, substitutionDistance);
1559                 current[j] = dist;
1560                 colMin = Math.min(colMin, dist);
1561             }
1562             for (var j = maxJ + 1; j <= s2.length; j++) {
1563                 current[j] = big;
1564             }
1565             if (colMin > max) {
1566                 return undefined;
1567             }
1568             var temp = previous;
1569             previous = current;
1570             current = temp;
1571         }
1572         var res = previous[s2.length];
1573         return res > max ? undefined : res;
1574     }
1575     function endsWith(str, suffix) {
1576         var expectedPos = str.length - suffix.length;
1577         return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos;
1578     }
1579     ts.endsWith = endsWith;
1580     function removeSuffix(str, suffix) {
1581         return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : str;
1582     }
1583     ts.removeSuffix = removeSuffix;
1584     function tryRemoveSuffix(str, suffix) {
1585         return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : undefined;
1586     }
1587     ts.tryRemoveSuffix = tryRemoveSuffix;
1588     function stringContains(str, substring) {
1589         return str.indexOf(substring) !== -1;
1590     }
1591     ts.stringContains = stringContains;
1592     function removeMinAndVersionNumbers(fileName) {
1593         var trailingMinOrVersion = /[.-]((min)|(\d+(\.\d+)*))$/;
1594         return fileName.replace(trailingMinOrVersion, "").replace(trailingMinOrVersion, "");
1595     }
1596     ts.removeMinAndVersionNumbers = removeMinAndVersionNumbers;
1597     function orderedRemoveItem(array, item) {
1598         for (var i = 0; i < array.length; i++) {
1599             if (array[i] === item) {
1600                 orderedRemoveItemAt(array, i);
1601                 return true;
1602             }
1603         }
1604         return false;
1605     }
1606     ts.orderedRemoveItem = orderedRemoveItem;
1607     function orderedRemoveItemAt(array, index) {
1608         for (var i = index; i < array.length - 1; i++) {
1609             array[i] = array[i + 1];
1610         }
1611         array.pop();
1612     }
1613     ts.orderedRemoveItemAt = orderedRemoveItemAt;
1614     function unorderedRemoveItemAt(array, index) {
1615         array[index] = array[array.length - 1];
1616         array.pop();
1617     }
1618     ts.unorderedRemoveItemAt = unorderedRemoveItemAt;
1619     function unorderedRemoveItem(array, item) {
1620         return unorderedRemoveFirstItemWhere(array, function (element) { return element === item; });
1621     }
1622     ts.unorderedRemoveItem = unorderedRemoveItem;
1623     function unorderedRemoveFirstItemWhere(array, predicate) {
1624         for (var i = 0; i < array.length; i++) {
1625             if (predicate(array[i])) {
1626                 unorderedRemoveItemAt(array, i);
1627                 return true;
1628             }
1629         }
1630         return false;
1631     }
1632     function createGetCanonicalFileName(useCaseSensitiveFileNames) {
1633         return useCaseSensitiveFileNames ? identity : toFileNameLowerCase;
1634     }
1635     ts.createGetCanonicalFileName = createGetCanonicalFileName;
1636     function patternText(_a) {
1637         var prefix = _a.prefix, suffix = _a.suffix;
1638         return prefix + "*" + suffix;
1639     }
1640     ts.patternText = patternText;
1641     function matchedText(pattern, candidate) {
1642         ts.Debug.assert(isPatternMatch(pattern, candidate));
1643         return candidate.substring(pattern.prefix.length, candidate.length - pattern.suffix.length);
1644     }
1645     ts.matchedText = matchedText;
1646     function findBestPatternMatch(values, getPattern, candidate) {
1647         var matchedValue;
1648         var longestMatchPrefixLength = -1;
1649         for (var _i = 0, values_2 = values; _i < values_2.length; _i++) {
1650             var v = values_2[_i];
1651             var pattern = getPattern(v);
1652             if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) {
1653                 longestMatchPrefixLength = pattern.prefix.length;
1654                 matchedValue = v;
1655             }
1656         }
1657         return matchedValue;
1658     }
1659     ts.findBestPatternMatch = findBestPatternMatch;
1660     function startsWith(str, prefix) {
1661         return str.lastIndexOf(prefix, 0) === 0;
1662     }
1663     ts.startsWith = startsWith;
1664     function removePrefix(str, prefix) {
1665         return startsWith(str, prefix) ? str.substr(prefix.length) : str;
1666     }
1667     ts.removePrefix = removePrefix;
1668     function tryRemovePrefix(str, prefix, getCanonicalFileName) {
1669         if (getCanonicalFileName === void 0) { getCanonicalFileName = identity; }
1670         return startsWith(getCanonicalFileName(str), getCanonicalFileName(prefix)) ? str.substring(prefix.length) : undefined;
1671     }
1672     ts.tryRemovePrefix = tryRemovePrefix;
1673     function isPatternMatch(_a, candidate) {
1674         var prefix = _a.prefix, suffix = _a.suffix;
1675         return candidate.length >= prefix.length + suffix.length &&
1676             startsWith(candidate, prefix) &&
1677             endsWith(candidate, suffix);
1678     }
1679     function and(f, g) {
1680         return function (arg) { return f(arg) && g(arg); };
1681     }
1682     ts.and = and;
1683     function or() {
1684         var fs = [];
1685         for (var _i = 0; _i < arguments.length; _i++) {
1686             fs[_i] = arguments[_i];
1687         }
1688         return function () {
1689             var args = [];
1690             for (var _i = 0; _i < arguments.length; _i++) {
1691                 args[_i] = arguments[_i];
1692             }
1693             for (var _a = 0, fs_1 = fs; _a < fs_1.length; _a++) {
1694                 var f = fs_1[_a];
1695                 if (f.apply(void 0, args)) {
1696                     return true;
1697                 }
1698             }
1699             return false;
1700         };
1701     }
1702     ts.or = or;
1703     function not(fn) {
1704         return function () {
1705             var args = [];
1706             for (var _i = 0; _i < arguments.length; _i++) {
1707                 args[_i] = arguments[_i];
1708             }
1709             return !fn.apply(void 0, args);
1710         };
1711     }
1712     ts.not = not;
1713     function assertType(_) { }
1714     ts.assertType = assertType;
1715     function singleElementArray(t) {
1716         return t === undefined ? undefined : [t];
1717     }
1718     ts.singleElementArray = singleElementArray;
1719     function enumerateInsertsAndDeletes(newItems, oldItems, comparer, inserted, deleted, unchanged) {
1720         unchanged = unchanged || noop;
1721         var newIndex = 0;
1722         var oldIndex = 0;
1723         var newLen = newItems.length;
1724         var oldLen = oldItems.length;
1725         var hasChanges = false;
1726         while (newIndex < newLen && oldIndex < oldLen) {
1727             var newItem = newItems[newIndex];
1728             var oldItem = oldItems[oldIndex];
1729             var compareResult = comparer(newItem, oldItem);
1730             if (compareResult === -1) {
1731                 inserted(newItem);
1732                 newIndex++;
1733                 hasChanges = true;
1734             }
1735             else if (compareResult === 1) {
1736                 deleted(oldItem);
1737                 oldIndex++;
1738                 hasChanges = true;
1739             }
1740             else {
1741                 unchanged(oldItem, newItem);
1742                 newIndex++;
1743                 oldIndex++;
1744             }
1745         }
1746         while (newIndex < newLen) {
1747             inserted(newItems[newIndex++]);
1748             hasChanges = true;
1749         }
1750         while (oldIndex < oldLen) {
1751             deleted(oldItems[oldIndex++]);
1752             hasChanges = true;
1753         }
1754         return hasChanges;
1755     }
1756     ts.enumerateInsertsAndDeletes = enumerateInsertsAndDeletes;
1757     function fill(length, cb) {
1758         var result = Array(length);
1759         for (var i = 0; i < length; i++) {
1760             result[i] = cb(i);
1761         }
1762         return result;
1763     }
1764     ts.fill = fill;
1765     function cartesianProduct(arrays) {
1766         var result = [];
1767         cartesianProductWorker(arrays, result, undefined, 0);
1768         return result;
1769     }
1770     ts.cartesianProduct = cartesianProduct;
1771     function cartesianProductWorker(arrays, result, outer, index) {
1772         for (var _i = 0, _a = arrays[index]; _i < _a.length; _i++) {
1773             var element = _a[_i];
1774             var inner = void 0;
1775             if (outer) {
1776                 inner = outer.slice();
1777                 inner.push(element);
1778             }
1779             else {
1780                 inner = [element];
1781             }
1782             if (index === arrays.length - 1) {
1783                 result.push(inner);
1784             }
1785             else {
1786                 cartesianProductWorker(arrays, result, inner, index + 1);
1787             }
1788         }
1789     }
1790     function padLeft(s, length, padString) {
1791         if (padString === void 0) { padString = " "; }
1792         return length <= s.length ? s : padString.repeat(length - s.length) + s;
1793     }
1794     ts.padLeft = padLeft;
1795     function padRight(s, length, padString) {
1796         if (padString === void 0) { padString = " "; }
1797         return length <= s.length ? s : s + padString.repeat(length - s.length);
1798     }
1799     ts.padRight = padRight;
1800     function takeWhile(array, predicate) {
1801         var len = array.length;
1802         var index = 0;
1803         while (index < len && predicate(array[index])) {
1804             index++;
1805         }
1806         return array.slice(0, index);
1807     }
1808     ts.takeWhile = takeWhile;
1809 })(ts || (ts = {}));
1810 var ts;
1811 (function (ts) {
1812     var LogLevel;
1813     (function (LogLevel) {
1814         LogLevel[LogLevel["Off"] = 0] = "Off";
1815         LogLevel[LogLevel["Error"] = 1] = "Error";
1816         LogLevel[LogLevel["Warning"] = 2] = "Warning";
1817         LogLevel[LogLevel["Info"] = 3] = "Info";
1818         LogLevel[LogLevel["Verbose"] = 4] = "Verbose";
1819     })(LogLevel = ts.LogLevel || (ts.LogLevel = {}));
1820     var Debug;
1821     (function (Debug) {
1822         var typeScriptVersion;
1823         var currentAssertionLevel = 0;
1824         Debug.currentLogLevel = LogLevel.Warning;
1825         Debug.isDebugging = false;
1826         function getTypeScriptVersion() {
1827             return typeScriptVersion !== null && typeScriptVersion !== void 0 ? typeScriptVersion : (typeScriptVersion = new ts.Version(ts.version));
1828         }
1829         Debug.getTypeScriptVersion = getTypeScriptVersion;
1830         function shouldLog(level) {
1831             return Debug.currentLogLevel <= level;
1832         }
1833         Debug.shouldLog = shouldLog;
1834         function logMessage(level, s) {
1835             if (Debug.loggingHost && shouldLog(level)) {
1836                 Debug.loggingHost.log(level, s);
1837             }
1838         }
1839         function log(s) {
1840             logMessage(LogLevel.Info, s);
1841         }
1842         Debug.log = log;
1843         (function (log_1) {
1844             function error(s) {
1845                 logMessage(LogLevel.Error, s);
1846             }
1847             log_1.error = error;
1848             function warn(s) {
1849                 logMessage(LogLevel.Warning, s);
1850             }
1851             log_1.warn = warn;
1852             function log(s) {
1853                 logMessage(LogLevel.Info, s);
1854             }
1855             log_1.log = log;
1856             function trace(s) {
1857                 logMessage(LogLevel.Verbose, s);
1858             }
1859             log_1.trace = trace;
1860         })(log = Debug.log || (Debug.log = {}));
1861         var assertionCache = {};
1862         function getAssertionLevel() {
1863             return currentAssertionLevel;
1864         }
1865         Debug.getAssertionLevel = getAssertionLevel;
1866         function setAssertionLevel(level) {
1867             var prevAssertionLevel = currentAssertionLevel;
1868             currentAssertionLevel = level;
1869             if (level > prevAssertionLevel) {
1870                 for (var _i = 0, _a = ts.getOwnKeys(assertionCache); _i < _a.length; _i++) {
1871                     var key = _a[_i];
1872                     var cachedFunc = assertionCache[key];
1873                     if (cachedFunc !== undefined && Debug[key] !== cachedFunc.assertion && level >= cachedFunc.level) {
1874                         Debug[key] = cachedFunc;
1875                         assertionCache[key] = undefined;
1876                     }
1877                 }
1878             }
1879         }
1880         Debug.setAssertionLevel = setAssertionLevel;
1881         function shouldAssert(level) {
1882             return currentAssertionLevel >= level;
1883         }
1884         Debug.shouldAssert = shouldAssert;
1885         function shouldAssertFunction(level, name) {
1886             if (!shouldAssert(level)) {
1887                 assertionCache[name] = { level: level, assertion: Debug[name] };
1888                 Debug[name] = ts.noop;
1889                 return false;
1890             }
1891             return true;
1892         }
1893         function fail(message, stackCrawlMark) {
1894             debugger;
1895             var e = new Error(message ? "Debug Failure. " + message : "Debug Failure.");
1896             if (Error.captureStackTrace) {
1897                 Error.captureStackTrace(e, stackCrawlMark || fail);
1898             }
1899             throw e;
1900         }
1901         Debug.fail = fail;
1902         function failBadSyntaxKind(node, message, stackCrawlMark) {
1903             return fail((message || "Unexpected node.") + "\r\nNode " + formatSyntaxKind(node.kind) + " was unexpected.", stackCrawlMark || failBadSyntaxKind);
1904         }
1905         Debug.failBadSyntaxKind = failBadSyntaxKind;
1906         function assert(expression, message, verboseDebugInfo, stackCrawlMark) {
1907             if (!expression) {
1908                 message = message ? "False expression: " + message : "False expression.";
1909                 if (verboseDebugInfo) {
1910                     message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo());
1911                 }
1912                 fail(message, stackCrawlMark || assert);
1913             }
1914         }
1915         Debug.assert = assert;
1916         function assertEqual(a, b, msg, msg2, stackCrawlMark) {
1917             if (a !== b) {
1918                 var message = msg ? msg2 ? msg + " " + msg2 : msg : "";
1919                 fail("Expected " + a + " === " + b + ". " + message, stackCrawlMark || assertEqual);
1920             }
1921         }
1922         Debug.assertEqual = assertEqual;
1923         function assertLessThan(a, b, msg, stackCrawlMark) {
1924             if (a >= b) {
1925                 fail("Expected " + a + " < " + b + ". " + (msg || ""), stackCrawlMark || assertLessThan);
1926             }
1927         }
1928         Debug.assertLessThan = assertLessThan;
1929         function assertLessThanOrEqual(a, b, stackCrawlMark) {
1930             if (a > b) {
1931                 fail("Expected " + a + " <= " + b, stackCrawlMark || assertLessThanOrEqual);
1932             }
1933         }
1934         Debug.assertLessThanOrEqual = assertLessThanOrEqual;
1935         function assertGreaterThanOrEqual(a, b, stackCrawlMark) {
1936             if (a < b) {
1937                 fail("Expected " + a + " >= " + b, stackCrawlMark || assertGreaterThanOrEqual);
1938             }
1939         }
1940         Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual;
1941         function assertIsDefined(value, message, stackCrawlMark) {
1942             if (value === undefined || value === null) {
1943                 fail(message, stackCrawlMark || assertIsDefined);
1944             }
1945         }
1946         Debug.assertIsDefined = assertIsDefined;
1947         function checkDefined(value, message, stackCrawlMark) {
1948             assertIsDefined(value, message, stackCrawlMark || checkDefined);
1949             return value;
1950         }
1951         Debug.checkDefined = checkDefined;
1952         Debug.assertDefined = checkDefined;
1953         function assertEachIsDefined(value, message, stackCrawlMark) {
1954             for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
1955                 var v = value_1[_i];
1956                 assertIsDefined(v, message, stackCrawlMark || assertEachIsDefined);
1957             }
1958         }
1959         Debug.assertEachIsDefined = assertEachIsDefined;
1960         function checkEachDefined(value, message, stackCrawlMark) {
1961             assertEachIsDefined(value, message, stackCrawlMark || checkEachDefined);
1962             return value;
1963         }
1964         Debug.checkEachDefined = checkEachDefined;
1965         Debug.assertEachDefined = checkEachDefined;
1966         function assertNever(member, message, stackCrawlMark) {
1967             if (message === void 0) { message = "Illegal value:"; }
1968             var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") && formatSyntaxKind ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
1969             return fail(message + " " + detail, stackCrawlMark || assertNever);
1970         }
1971         Debug.assertNever = assertNever;
1972         function assertEachNode(nodes, test, message, stackCrawlMark) {
1973             if (shouldAssertFunction(1, "assertEachNode")) {
1974                 assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertEachNode);
1975             }
1976         }
1977         Debug.assertEachNode = assertEachNode;
1978         function assertNode(node, test, message, stackCrawlMark) {
1979             if (shouldAssertFunction(1, "assertNode")) {
1980                 assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertNode);
1981             }
1982         }
1983         Debug.assertNode = assertNode;
1984         function assertNotNode(node, test, message, stackCrawlMark) {
1985             if (shouldAssertFunction(1, "assertNotNode")) {
1986                 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);
1987             }
1988         }
1989         Debug.assertNotNode = assertNotNode;
1990         function assertOptionalNode(node, test, message, stackCrawlMark) {
1991             if (shouldAssertFunction(1, "assertOptionalNode")) {
1992                 assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " did not pass test '" + getFunctionName(test) + "'."; }, stackCrawlMark || assertOptionalNode);
1993             }
1994         }
1995         Debug.assertOptionalNode = assertOptionalNode;
1996         function assertOptionalToken(node, kind, message, stackCrawlMark) {
1997             if (shouldAssertFunction(1, "assertOptionalToken")) {
1998                 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);
1999             }
2000         }
2001         Debug.assertOptionalToken = assertOptionalToken;
2002         function assertMissingNode(node, message, stackCrawlMark) {
2003             if (shouldAssertFunction(1, "assertMissingNode")) {
2004                 assert(node === undefined, message || "Unexpected node.", function () { return "Node " + formatSyntaxKind(node.kind) + " was unexpected'."; }, stackCrawlMark || assertMissingNode);
2005             }
2006         }
2007         Debug.assertMissingNode = assertMissingNode;
2008         function getFunctionName(func) {
2009             if (typeof func !== "function") {
2010                 return "";
2011             }
2012             else if (func.hasOwnProperty("name")) {
2013                 return func.name;
2014             }
2015             else {
2016                 var text = Function.prototype.toString.call(func);
2017                 var match = /^function\s+([\w\$]+)\s*\(/.exec(text);
2018                 return match ? match[1] : "";
2019             }
2020         }
2021         Debug.getFunctionName = getFunctionName;
2022         function formatSymbol(symbol) {
2023             return "{ name: " + ts.unescapeLeadingUnderscores(symbol.escapedName) + "; flags: " + formatSymbolFlags(symbol.flags) + "; declarations: " + ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }) + " }";
2024         }
2025         Debug.formatSymbol = formatSymbol;
2026         function formatEnum(value, enumObject, isFlags) {
2027             if (value === void 0) { value = 0; }
2028             var members = getEnumMembers(enumObject);
2029             if (value === 0) {
2030                 return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
2031             }
2032             if (isFlags) {
2033                 var result = "";
2034                 var remainingFlags = value;
2035                 for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
2036                     var _a = members_1[_i], enumValue = _a[0], enumName = _a[1];
2037                     if (enumValue > value) {
2038                         break;
2039                     }
2040                     if (enumValue !== 0 && enumValue & value) {
2041                         result = "" + result + (result ? "|" : "") + enumName;
2042                         remainingFlags &= ~enumValue;
2043                     }
2044                 }
2045                 if (remainingFlags === 0) {
2046                     return result;
2047                 }
2048             }
2049             else {
2050                 for (var _b = 0, members_2 = members; _b < members_2.length; _b++) {
2051                     var _c = members_2[_b], enumValue = _c[0], enumName = _c[1];
2052                     if (enumValue === value) {
2053                         return enumName;
2054                     }
2055                 }
2056             }
2057             return value.toString();
2058         }
2059         Debug.formatEnum = formatEnum;
2060         function getEnumMembers(enumObject) {
2061             var result = [];
2062             for (var name in enumObject) {
2063                 var value = enumObject[name];
2064                 if (typeof value === "number") {
2065                     result.push([value, name]);
2066                 }
2067             }
2068             return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
2069         }
2070         function formatSyntaxKind(kind) {
2071             return formatEnum(kind, ts.SyntaxKind, false);
2072         }
2073         Debug.formatSyntaxKind = formatSyntaxKind;
2074         function formatNodeFlags(flags) {
2075             return formatEnum(flags, ts.NodeFlags, true);
2076         }
2077         Debug.formatNodeFlags = formatNodeFlags;
2078         function formatModifierFlags(flags) {
2079             return formatEnum(flags, ts.ModifierFlags, true);
2080         }
2081         Debug.formatModifierFlags = formatModifierFlags;
2082         function formatTransformFlags(flags) {
2083             return formatEnum(flags, ts.TransformFlags, true);
2084         }
2085         Debug.formatTransformFlags = formatTransformFlags;
2086         function formatEmitFlags(flags) {
2087             return formatEnum(flags, ts.EmitFlags, true);
2088         }
2089         Debug.formatEmitFlags = formatEmitFlags;
2090         function formatSymbolFlags(flags) {
2091             return formatEnum(flags, ts.SymbolFlags, true);
2092         }
2093         Debug.formatSymbolFlags = formatSymbolFlags;
2094         function formatTypeFlags(flags) {
2095             return formatEnum(flags, ts.TypeFlags, true);
2096         }
2097         Debug.formatTypeFlags = formatTypeFlags;
2098         function formatSignatureFlags(flags) {
2099             return formatEnum(flags, ts.SignatureFlags, true);
2100         }
2101         Debug.formatSignatureFlags = formatSignatureFlags;
2102         function formatObjectFlags(flags) {
2103             return formatEnum(flags, ts.ObjectFlags, true);
2104         }
2105         Debug.formatObjectFlags = formatObjectFlags;
2106         function formatFlowFlags(flags) {
2107             return formatEnum(flags, ts.FlowFlags, true);
2108         }
2109         Debug.formatFlowFlags = formatFlowFlags;
2110         var isDebugInfoEnabled = false;
2111         var extendedDebugModule;
2112         function extendedDebug() {
2113             enableDebugInfo();
2114             if (!extendedDebugModule) {
2115                 throw new Error("Debugging helpers could not be loaded.");
2116             }
2117             return extendedDebugModule;
2118         }
2119         function printControlFlowGraph(flowNode) {
2120             return console.log(formatControlFlowGraph(flowNode));
2121         }
2122         Debug.printControlFlowGraph = printControlFlowGraph;
2123         function formatControlFlowGraph(flowNode) {
2124             return extendedDebug().formatControlFlowGraph(flowNode);
2125         }
2126         Debug.formatControlFlowGraph = formatControlFlowGraph;
2127         var flowNodeProto;
2128         function attachFlowNodeDebugInfoWorker(flowNode) {
2129             if (!("__debugFlowFlags" in flowNode)) {
2130                 Object.defineProperties(flowNode, {
2131                     __tsDebuggerDisplay: {
2132                         value: function () {
2133                             var flowHeader = this.flags & 2 ? "FlowStart" :
2134                                 this.flags & 4 ? "FlowBranchLabel" :
2135                                     this.flags & 8 ? "FlowLoopLabel" :
2136                                         this.flags & 16 ? "FlowAssignment" :
2137                                             this.flags & 32 ? "FlowTrueCondition" :
2138                                                 this.flags & 64 ? "FlowFalseCondition" :
2139                                                     this.flags & 128 ? "FlowSwitchClause" :
2140                                                         this.flags & 256 ? "FlowArrayMutation" :
2141                                                             this.flags & 512 ? "FlowCall" :
2142                                                                 this.flags & 1024 ? "FlowReduceLabel" :
2143                                                                     this.flags & 1 ? "FlowUnreachable" :
2144                                                                         "UnknownFlow";
2145                             var remainingFlags = this.flags & ~(2048 - 1);
2146                             return "" + flowHeader + (remainingFlags ? " (" + formatFlowFlags(remainingFlags) + ")" : "");
2147                         }
2148                     },
2149                     __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, true); } },
2150                     __debugToString: { value: function () { return formatControlFlowGraph(this); } }
2151                 });
2152             }
2153         }
2154         function attachFlowNodeDebugInfo(flowNode) {
2155             if (isDebugInfoEnabled) {
2156                 if (typeof Object.setPrototypeOf === "function") {
2157                     if (!flowNodeProto) {
2158                         flowNodeProto = Object.create(Object.prototype);
2159                         attachFlowNodeDebugInfoWorker(flowNodeProto);
2160                     }
2161                     Object.setPrototypeOf(flowNode, flowNodeProto);
2162                 }
2163                 else {
2164                     attachFlowNodeDebugInfoWorker(flowNode);
2165                 }
2166             }
2167         }
2168         Debug.attachFlowNodeDebugInfo = attachFlowNodeDebugInfo;
2169         var nodeArrayProto;
2170         function attachNodeArrayDebugInfoWorker(array) {
2171             if (!("__tsDebuggerDisplay" in array)) {
2172                 Object.defineProperties(array, {
2173                     __tsDebuggerDisplay: {
2174                         value: function (defaultValue) {
2175                             defaultValue = String(defaultValue).replace(/(?:,[\s\w\d_]+:[^,]+)+\]$/, "]");
2176                             return "NodeArray " + defaultValue;
2177                         }
2178                     }
2179                 });
2180             }
2181         }
2182         function attachNodeArrayDebugInfo(array) {
2183             if (isDebugInfoEnabled) {
2184                 if (typeof Object.setPrototypeOf === "function") {
2185                     if (!nodeArrayProto) {
2186                         nodeArrayProto = Object.create(Array.prototype);
2187                         attachNodeArrayDebugInfoWorker(nodeArrayProto);
2188                     }
2189                     Object.setPrototypeOf(array, nodeArrayProto);
2190                 }
2191                 else {
2192                     attachNodeArrayDebugInfoWorker(array);
2193                 }
2194             }
2195         }
2196         Debug.attachNodeArrayDebugInfo = attachNodeArrayDebugInfo;
2197         function enableDebugInfo() {
2198             if (isDebugInfoEnabled)
2199                 return;
2200             var weakTypeTextMap;
2201             var weakNodeTextMap;
2202             function getWeakTypeTextMap() {
2203                 if (weakTypeTextMap === undefined) {
2204                     if (typeof WeakMap === "function")
2205                         weakTypeTextMap = new WeakMap();
2206                 }
2207                 return weakTypeTextMap;
2208             }
2209             function getWeakNodeTextMap() {
2210                 if (weakNodeTextMap === undefined) {
2211                     if (typeof WeakMap === "function")
2212                         weakNodeTextMap = new WeakMap();
2213                 }
2214                 return weakNodeTextMap;
2215             }
2216             Object.defineProperties(ts.objectAllocator.getSymbolConstructor().prototype, {
2217                 __tsDebuggerDisplay: {
2218                     value: function () {
2219                         var symbolHeader = this.flags & 33554432 ? "TransientSymbol" :
2220                             "Symbol";
2221                         var remainingSymbolFlags = this.flags & ~33554432;
2222                         return symbolHeader + " '" + ts.symbolName(this) + "'" + (remainingSymbolFlags ? " (" + formatSymbolFlags(remainingSymbolFlags) + ")" : "");
2223                     }
2224                 },
2225                 __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } }
2226             });
2227             Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, {
2228                 __tsDebuggerDisplay: {
2229                     value: function () {
2230                         var typeHeader = this.flags & 98304 ? "NullableType" :
2231                             this.flags & 384 ? "LiteralType " + JSON.stringify(this.value) :
2232                                 this.flags & 2048 ? "LiteralType " + (this.value.negative ? "-" : "") + this.value.base10Value + "n" :
2233                                     this.flags & 8192 ? "UniqueESSymbolType" :
2234                                         this.flags & 32 ? "EnumType" :
2235                                             this.flags & 67359327 ? "IntrinsicType " + this.intrinsicName :
2236                                                 this.flags & 1048576 ? "UnionType" :
2237                                                     this.flags & 2097152 ? "IntersectionType" :
2238                                                         this.flags & 4194304 ? "IndexType" :
2239                                                             this.flags & 8388608 ? "IndexedAccessType" :
2240                                                                 this.flags & 16777216 ? "ConditionalType" :
2241                                                                     this.flags & 33554432 ? "SubstitutionType" :
2242                                                                         this.flags & 262144 ? "TypeParameter" :
2243                                                                             this.flags & 524288 ?
2244                                                                                 this.objectFlags & 3 ? "InterfaceType" :
2245                                                                                     this.objectFlags & 4 ? "TypeReference" :
2246                                                                                         this.objectFlags & 8 ? "TupleType" :
2247                                                                                             this.objectFlags & 16 ? "AnonymousType" :
2248                                                                                                 this.objectFlags & 32 ? "MappedType" :
2249                                                                                                     this.objectFlags & 2048 ? "ReverseMappedType" :
2250                                                                                                         this.objectFlags & 256 ? "EvolvingArrayType" :
2251                                                                                                             "ObjectType" :
2252                                                                                 "Type";
2253                         var remainingObjectFlags = this.flags & 524288 ? this.objectFlags & ~2367 : 0;
2254                         return "" + typeHeader + (this.symbol ? " '" + ts.symbolName(this.symbol) + "'" : "") + (remainingObjectFlags ? " (" + formatObjectFlags(remainingObjectFlags) + ")" : "");
2255                     }
2256                 },
2257                 __debugFlags: { get: function () { return formatTypeFlags(this.flags); } },
2258                 __debugObjectFlags: { get: function () { return this.flags & 524288 ? formatObjectFlags(this.objectFlags) : ""; } },
2259                 __debugTypeToString: {
2260                     value: function () {
2261                         var map = getWeakTypeTextMap();
2262                         var text = map === null || map === void 0 ? void 0 : map.get(this);
2263                         if (text === undefined) {
2264                             text = this.checker.typeToString(this);
2265                             map === null || map === void 0 ? void 0 : map.set(this, text);
2266                         }
2267                         return text;
2268                     }
2269                 },
2270             });
2271             Object.defineProperties(ts.objectAllocator.getSignatureConstructor().prototype, {
2272                 __debugFlags: { get: function () { return formatSignatureFlags(this.flags); } },
2273                 __debugSignatureToString: { value: function () { var _a; return (_a = this.checker) === null || _a === void 0 ? void 0 : _a.signatureToString(this); } }
2274             });
2275             var nodeConstructors = [
2276                 ts.objectAllocator.getNodeConstructor(),
2277                 ts.objectAllocator.getIdentifierConstructor(),
2278                 ts.objectAllocator.getTokenConstructor(),
2279                 ts.objectAllocator.getSourceFileConstructor()
2280             ];
2281             for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) {
2282                 var ctor = nodeConstructors_1[_i];
2283                 if (!ctor.prototype.hasOwnProperty("__debugKind")) {
2284                     Object.defineProperties(ctor.prototype, {
2285                         __tsDebuggerDisplay: {
2286                             value: function () {
2287                                 var nodeHeader = ts.isGeneratedIdentifier(this) ? "GeneratedIdentifier" :
2288                                     ts.isIdentifier(this) ? "Identifier '" + ts.idText(this) + "'" :
2289                                         ts.isPrivateIdentifier(this) ? "PrivateIdentifier '" + ts.idText(this) + "'" :
2290                                             ts.isStringLiteral(this) ? "StringLiteral " + JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...") :
2291                                                 ts.isNumericLiteral(this) ? "NumericLiteral " + this.text :
2292                                                     ts.isBigIntLiteral(this) ? "BigIntLiteral " + this.text + "n" :
2293                                                         ts.isTypeParameterDeclaration(this) ? "TypeParameterDeclaration" :
2294                                                             ts.isParameter(this) ? "ParameterDeclaration" :
2295                                                                 ts.isConstructorDeclaration(this) ? "ConstructorDeclaration" :
2296                                                                     ts.isGetAccessorDeclaration(this) ? "GetAccessorDeclaration" :
2297                                                                         ts.isSetAccessorDeclaration(this) ? "SetAccessorDeclaration" :
2298                                                                             ts.isCallSignatureDeclaration(this) ? "CallSignatureDeclaration" :
2299                                                                                 ts.isConstructSignatureDeclaration(this) ? "ConstructSignatureDeclaration" :
2300                                                                                     ts.isIndexSignatureDeclaration(this) ? "IndexSignatureDeclaration" :
2301                                                                                         ts.isTypePredicateNode(this) ? "TypePredicateNode" :
2302                                                                                             ts.isTypeReferenceNode(this) ? "TypeReferenceNode" :
2303                                                                                                 ts.isFunctionTypeNode(this) ? "FunctionTypeNode" :
2304                                                                                                     ts.isConstructorTypeNode(this) ? "ConstructorTypeNode" :
2305                                                                                                         ts.isTypeQueryNode(this) ? "TypeQueryNode" :
2306                                                                                                             ts.isTypeLiteralNode(this) ? "TypeLiteralNode" :
2307                                                                                                                 ts.isArrayTypeNode(this) ? "ArrayTypeNode" :
2308                                                                                                                     ts.isTupleTypeNode(this) ? "TupleTypeNode" :
2309                                                                                                                         ts.isOptionalTypeNode(this) ? "OptionalTypeNode" :
2310                                                                                                                             ts.isRestTypeNode(this) ? "RestTypeNode" :
2311                                                                                                                                 ts.isUnionTypeNode(this) ? "UnionTypeNode" :
2312                                                                                                                                     ts.isIntersectionTypeNode(this) ? "IntersectionTypeNode" :
2313                                                                                                                                         ts.isConditionalTypeNode(this) ? "ConditionalTypeNode" :
2314                                                                                                                                             ts.isInferTypeNode(this) ? "InferTypeNode" :
2315                                                                                                                                                 ts.isParenthesizedTypeNode(this) ? "ParenthesizedTypeNode" :
2316                                                                                                                                                     ts.isThisTypeNode(this) ? "ThisTypeNode" :
2317                                                                                                                                                         ts.isTypeOperatorNode(this) ? "TypeOperatorNode" :
2318                                                                                                                                                             ts.isIndexedAccessTypeNode(this) ? "IndexedAccessTypeNode" :
2319                                                                                                                                                                 ts.isMappedTypeNode(this) ? "MappedTypeNode" :
2320                                                                                                                                                                     ts.isLiteralTypeNode(this) ? "LiteralTypeNode" :
2321                                                                                                                                                                         ts.isNamedTupleMember(this) ? "NamedTupleMember" :
2322                                                                                                                                                                             ts.isImportTypeNode(this) ? "ImportTypeNode" :
2323                                                                                                                                                                                 formatSyntaxKind(this.kind);
2324                                 return "" + nodeHeader + (this.flags ? " (" + formatNodeFlags(this.flags) + ")" : "");
2325                             }
2326                         },
2327                         __debugKind: { get: function () { return formatSyntaxKind(this.kind); } },
2328                         __debugNodeFlags: { get: function () { return formatNodeFlags(this.flags); } },
2329                         __debugModifierFlags: { get: function () { return formatModifierFlags(ts.getEffectiveModifierFlagsNoCache(this)); } },
2330                         __debugTransformFlags: { get: function () { return formatTransformFlags(this.transformFlags); } },
2331                         __debugIsParseTreeNode: { get: function () { return ts.isParseTreeNode(this); } },
2332                         __debugEmitFlags: { get: function () { return formatEmitFlags(ts.getEmitFlags(this)); } },
2333                         __debugGetText: {
2334                             value: function (includeTrivia) {
2335                                 if (ts.nodeIsSynthesized(this))
2336                                     return "";
2337                                 var map = getWeakNodeTextMap();
2338                                 var text = map === null || map === void 0 ? void 0 : map.get(this);
2339                                 if (text === undefined) {
2340                                     var parseNode = ts.getParseTreeNode(this);
2341                                     var sourceFile = parseNode && ts.getSourceFileOfNode(parseNode);
2342                                     text = sourceFile ? ts.getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : "";
2343                                     map === null || map === void 0 ? void 0 : map.set(this, text);
2344                                 }
2345                                 return text;
2346                             }
2347                         }
2348                     });
2349                 }
2350             }
2351             try {
2352                 if (ts.sys && ts.sys.require) {
2353                     var basePath = ts.getDirectoryPath(ts.resolvePath(ts.sys.getExecutingFilePath()));
2354                     var result = ts.sys.require(basePath, "./compiler-debug");
2355                     if (!result.error) {
2356                         result.module.init(ts);
2357                         extendedDebugModule = result.module;
2358                     }
2359                 }
2360             }
2361             catch (_a) {
2362             }
2363             isDebugInfoEnabled = true;
2364         }
2365         Debug.enableDebugInfo = enableDebugInfo;
2366         function formatDeprecationMessage(name, error, errorAfter, since, message) {
2367             var deprecationMessage = error ? "DeprecationError: " : "DeprecationWarning: ";
2368             deprecationMessage += "'" + name + "' ";
2369             deprecationMessage += since ? "has been deprecated since v" + since : "is deprecated";
2370             deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v" + errorAfter + "." : ".";
2371             deprecationMessage += message ? " " + ts.formatStringFromArgs(message, [name], 0) : "";
2372             return deprecationMessage;
2373         }
2374         function createErrorDeprecation(name, errorAfter, since, message) {
2375             var deprecationMessage = formatDeprecationMessage(name, true, errorAfter, since, message);
2376             return function () {
2377                 throw new TypeError(deprecationMessage);
2378             };
2379         }
2380         function createWarningDeprecation(name, errorAfter, since, message) {
2381             var hasWrittenDeprecation = false;
2382             return function () {
2383                 if (!hasWrittenDeprecation) {
2384                     log.warn(formatDeprecationMessage(name, false, errorAfter, since, message));
2385                     hasWrittenDeprecation = true;
2386                 }
2387             };
2388         }
2389         function createDeprecation(name, options) {
2390             var _a, _b;
2391             if (options === void 0) { options = {}; }
2392             var version = typeof options.typeScriptVersion === "string" ? new ts.Version(options.typeScriptVersion) : (_a = options.typeScriptVersion) !== null && _a !== void 0 ? _a : getTypeScriptVersion();
2393             var errorAfter = typeof options.errorAfter === "string" ? new ts.Version(options.errorAfter) : options.errorAfter;
2394             var warnAfter = typeof options.warnAfter === "string" ? new ts.Version(options.warnAfter) : options.warnAfter;
2395             var since = typeof options.since === "string" ? new ts.Version(options.since) : (_b = options.since) !== null && _b !== void 0 ? _b : warnAfter;
2396             var error = options.error || errorAfter && version.compareTo(errorAfter) <= 0;
2397             var warn = !warnAfter || version.compareTo(warnAfter) >= 0;
2398             return error ? createErrorDeprecation(name, errorAfter, since, options.message) :
2399                 warn ? createWarningDeprecation(name, errorAfter, since, options.message) :
2400                     ts.noop;
2401         }
2402         function wrapFunction(deprecation, func) {
2403             return function () {
2404                 deprecation();
2405                 return func.apply(this, arguments);
2406             };
2407         }
2408         function deprecate(func, options) {
2409             var deprecation = createDeprecation(getFunctionName(func), options);
2410             return wrapFunction(deprecation, func);
2411         }
2412         Debug.deprecate = deprecate;
2413     })(Debug = ts.Debug || (ts.Debug = {}));
2414 })(ts || (ts = {}));
2415 var ts;
2416 (function (ts) {
2417     var versionRegExp = /^(0|[1-9]\d*)(?:\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*)(?:\-([a-z0-9-.]+))?(?:\+([a-z0-9-.]+))?)?)?$/i;
2418     var prereleaseRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)(?:\.(?:0|[1-9]\d*|[a-z-][a-z0-9-]*))*$/i;
2419     var buildRegExp = /^[a-z0-9-]+(?:\.[a-z0-9-]+)*$/i;
2420     var numericIdentifierRegExp = /^(0|[1-9]\d*)$/;
2421     var Version = (function () {
2422         function Version(major, minor, patch, prerelease, build) {
2423             if (minor === void 0) { minor = 0; }
2424             if (patch === void 0) { patch = 0; }
2425             if (prerelease === void 0) { prerelease = ""; }
2426             if (build === void 0) { build = ""; }
2427             if (typeof major === "string") {
2428                 var result = ts.Debug.checkDefined(tryParseComponents(major), "Invalid version");
2429                 (major = result.major, minor = result.minor, patch = result.patch, prerelease = result.prerelease, build = result.build);
2430             }
2431             ts.Debug.assert(major >= 0, "Invalid argument: major");
2432             ts.Debug.assert(minor >= 0, "Invalid argument: minor");
2433             ts.Debug.assert(patch >= 0, "Invalid argument: patch");
2434             ts.Debug.assert(!prerelease || prereleaseRegExp.test(prerelease), "Invalid argument: prerelease");
2435             ts.Debug.assert(!build || buildRegExp.test(build), "Invalid argument: build");
2436             this.major = major;
2437             this.minor = minor;
2438             this.patch = patch;
2439             this.prerelease = prerelease ? prerelease.split(".") : ts.emptyArray;
2440             this.build = build ? build.split(".") : ts.emptyArray;
2441         }
2442         Version.tryParse = function (text) {
2443             var result = tryParseComponents(text);
2444             if (!result)
2445                 return undefined;
2446             var major = result.major, minor = result.minor, patch = result.patch, prerelease = result.prerelease, build = result.build;
2447             return new Version(major, minor, patch, prerelease, build);
2448         };
2449         Version.prototype.compareTo = function (other) {
2450             if (this === other)
2451                 return 0;
2452             if (other === undefined)
2453                 return 1;
2454             return ts.compareValues(this.major, other.major)
2455                 || ts.compareValues(this.minor, other.minor)
2456                 || ts.compareValues(this.patch, other.patch)
2457                 || comparePrereleaseIdentifiers(this.prerelease, other.prerelease);
2458         };
2459         Version.prototype.increment = function (field) {
2460             switch (field) {
2461                 case "major": return new Version(this.major + 1, 0, 0);
2462                 case "minor": return new Version(this.major, this.minor + 1, 0);
2463                 case "patch": return new Version(this.major, this.minor, this.patch + 1);
2464                 default: return ts.Debug.assertNever(field);
2465             }
2466         };
2467         Version.prototype.toString = function () {
2468             var result = this.major + "." + this.minor + "." + this.patch;
2469             if (ts.some(this.prerelease))
2470                 result += "-" + this.prerelease.join(".");
2471             if (ts.some(this.build))
2472                 result += "+" + this.build.join(".");
2473             return result;
2474         };
2475         Version.zero = new Version(0, 0, 0);
2476         return Version;
2477     }());
2478     ts.Version = Version;
2479     function tryParseComponents(text) {
2480         var match = versionRegExp.exec(text);
2481         if (!match)
2482             return undefined;
2483         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;
2484         if (prerelease && !prereleaseRegExp.test(prerelease))
2485             return undefined;
2486         if (build && !buildRegExp.test(build))
2487             return undefined;
2488         return {
2489             major: parseInt(major, 10),
2490             minor: parseInt(minor, 10),
2491             patch: parseInt(patch, 10),
2492             prerelease: prerelease,
2493             build: build
2494         };
2495     }
2496     function comparePrereleaseIdentifiers(left, right) {
2497         if (left === right)
2498             return 0;
2499         if (left.length === 0)
2500             return right.length === 0 ? 0 : 1;
2501         if (right.length === 0)
2502             return -1;
2503         var length = Math.min(left.length, right.length);
2504         for (var i = 0; i < length; i++) {
2505             var leftIdentifier = left[i];
2506             var rightIdentifier = right[i];
2507             if (leftIdentifier === rightIdentifier)
2508                 continue;
2509             var leftIsNumeric = numericIdentifierRegExp.test(leftIdentifier);
2510             var rightIsNumeric = numericIdentifierRegExp.test(rightIdentifier);
2511             if (leftIsNumeric || rightIsNumeric) {
2512                 if (leftIsNumeric !== rightIsNumeric)
2513                     return leftIsNumeric ? -1 : 1;
2514                 var result = ts.compareValues(+leftIdentifier, +rightIdentifier);
2515                 if (result)
2516                     return result;
2517             }
2518             else {
2519                 var result = ts.compareStringsCaseSensitive(leftIdentifier, rightIdentifier);
2520                 if (result)
2521                     return result;
2522             }
2523         }
2524         return ts.compareValues(left.length, right.length);
2525     }
2526     var VersionRange = (function () {
2527         function VersionRange(spec) {
2528             this._alternatives = spec ? ts.Debug.checkDefined(parseRange(spec), "Invalid range spec.") : ts.emptyArray;
2529         }
2530         VersionRange.tryParse = function (text) {
2531             var sets = parseRange(text);
2532             if (sets) {
2533                 var range = new VersionRange("");
2534                 range._alternatives = sets;
2535                 return range;
2536             }
2537             return undefined;
2538         };
2539         VersionRange.prototype.test = function (version) {
2540             if (typeof version === "string")
2541                 version = new Version(version);
2542             return testDisjunction(version, this._alternatives);
2543         };
2544         VersionRange.prototype.toString = function () {
2545             return formatDisjunction(this._alternatives);
2546         };
2547         return VersionRange;
2548     }());
2549     ts.VersionRange = VersionRange;
2550     var logicalOrRegExp = /\s*\|\|\s*/g;
2551     var whitespaceRegExp = /\s+/g;
2552     var partialRegExp = /^([xX*0]|[1-9]\d*)(?:\.([xX*0]|[1-9]\d*)(?:\.([xX*0]|[1-9]\d*)(?:-([a-z0-9-.]+))?(?:\+([a-z0-9-.]+))?)?)?$/i;
2553     var hyphenRegExp = /^\s*([a-z0-9-+.*]+)\s+-\s+([a-z0-9-+.*]+)\s*$/i;
2554     var rangeRegExp = /^\s*(~|\^|<|<=|>|>=|=)?\s*([a-z0-9-+.*]+)$/i;
2555     function parseRange(text) {
2556         var alternatives = [];
2557         for (var _i = 0, _a = text.trim().split(logicalOrRegExp); _i < _a.length; _i++) {
2558             var range = _a[_i];
2559             if (!range)
2560                 continue;
2561             var comparators = [];
2562             var match = hyphenRegExp.exec(range);
2563             if (match) {
2564                 if (!parseHyphen(match[1], match[2], comparators))
2565                     return undefined;
2566             }
2567             else {
2568                 for (var _b = 0, _c = range.split(whitespaceRegExp); _b < _c.length; _b++) {
2569                     var simple = _c[_b];
2570                     var match_1 = rangeRegExp.exec(simple);
2571                     if (!match_1 || !parseComparator(match_1[1], match_1[2], comparators))
2572                         return undefined;
2573                 }
2574             }
2575             alternatives.push(comparators);
2576         }
2577         return alternatives;
2578     }
2579     function parsePartial(text) {
2580         var match = partialRegExp.exec(text);
2581         if (!match)
2582             return undefined;
2583         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];
2584         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);
2585         return { version: version, major: major, minor: minor, patch: patch };
2586     }
2587     function parseHyphen(left, right, comparators) {
2588         var leftResult = parsePartial(left);
2589         if (!leftResult)
2590             return false;
2591         var rightResult = parsePartial(right);
2592         if (!rightResult)
2593             return false;
2594         if (!isWildcard(leftResult.major)) {
2595             comparators.push(createComparator(">=", leftResult.version));
2596         }
2597         if (!isWildcard(rightResult.major)) {
2598             comparators.push(isWildcard(rightResult.minor) ? createComparator("<", rightResult.version.increment("major")) :
2599                 isWildcard(rightResult.patch) ? createComparator("<", rightResult.version.increment("minor")) :
2600                     createComparator("<=", rightResult.version));
2601         }
2602         return true;
2603     }
2604     function parseComparator(operator, text, comparators) {
2605         var result = parsePartial(text);
2606         if (!result)
2607             return false;
2608         var version = result.version, major = result.major, minor = result.minor, patch = result.patch;
2609         if (!isWildcard(major)) {
2610             switch (operator) {
2611                 case "~":
2612                     comparators.push(createComparator(">=", version));
2613                     comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" :
2614                         "minor")));
2615                     break;
2616                 case "^":
2617                     comparators.push(createComparator(">=", version));
2618                     comparators.push(createComparator("<", version.increment(version.major > 0 || isWildcard(minor) ? "major" :
2619                         version.minor > 0 || isWildcard(patch) ? "minor" :
2620                             "patch")));
2621                     break;
2622                 case "<":
2623                 case ">=":
2624                     comparators.push(createComparator(operator, version));
2625                     break;
2626                 case "<=":
2627                 case ">":
2628                     comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major")) :
2629                         isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor")) :
2630                             createComparator(operator, version));
2631                     break;
2632                 case "=":
2633                 case undefined:
2634                     if (isWildcard(minor) || isWildcard(patch)) {
2635                         comparators.push(createComparator(">=", version));
2636                         comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor")));
2637                     }
2638                     else {
2639                         comparators.push(createComparator("=", version));
2640                     }
2641                     break;
2642                 default:
2643                     return false;
2644             }
2645         }
2646         else if (operator === "<" || operator === ">") {
2647             comparators.push(createComparator("<", Version.zero));
2648         }
2649         return true;
2650     }
2651     function isWildcard(part) {
2652         return part === "*" || part === "x" || part === "X";
2653     }
2654     function createComparator(operator, operand) {
2655         return { operator: operator, operand: operand };
2656     }
2657     function testDisjunction(version, alternatives) {
2658         if (alternatives.length === 0)
2659             return true;
2660         for (var _i = 0, alternatives_1 = alternatives; _i < alternatives_1.length; _i++) {
2661             var alternative = alternatives_1[_i];
2662             if (testAlternative(version, alternative))
2663                 return true;
2664         }
2665         return false;
2666     }
2667     function testAlternative(version, comparators) {
2668         for (var _i = 0, comparators_1 = comparators; _i < comparators_1.length; _i++) {
2669             var comparator = comparators_1[_i];
2670             if (!testComparator(version, comparator.operator, comparator.operand))
2671                 return false;
2672         }
2673         return true;
2674     }
2675     function testComparator(version, operator, operand) {
2676         var cmp = version.compareTo(operand);
2677         switch (operator) {
2678             case "<": return cmp < 0;
2679             case "<=": return cmp <= 0;
2680             case ">": return cmp > 0;
2681             case ">=": return cmp >= 0;
2682             case "=": return cmp === 0;
2683             default: return ts.Debug.assertNever(operator);
2684         }
2685     }
2686     function formatDisjunction(alternatives) {
2687         return ts.map(alternatives, formatAlternative).join(" || ") || "*";
2688     }
2689     function formatAlternative(comparators) {
2690         return ts.map(comparators, formatComparator).join(" ");
2691     }
2692     function formatComparator(comparator) {
2693         return "" + comparator.operator + comparator.operand;
2694     }
2695 })(ts || (ts = {}));
2696 var ts;
2697 (function (ts) {
2698     function hasRequiredAPI(performance, PerformanceObserver) {
2699         return typeof performance === "object" &&
2700             typeof performance.timeOrigin === "number" &&
2701             typeof performance.mark === "function" &&
2702             typeof performance.measure === "function" &&
2703             typeof performance.now === "function" &&
2704             typeof PerformanceObserver === "function";
2705     }
2706     function tryGetWebPerformanceHooks() {
2707         if (typeof performance === "object" &&
2708             typeof PerformanceObserver === "function" &&
2709             hasRequiredAPI(performance, PerformanceObserver)) {
2710             return {
2711                 shouldWriteNativeEvents: true,
2712                 performance: performance,
2713                 PerformanceObserver: PerformanceObserver
2714             };
2715         }
2716     }
2717     function tryGetNodePerformanceHooks() {
2718         if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof module === "object" && typeof require === "function") {
2719             try {
2720                 var performance_1;
2721                 var _a = require("perf_hooks"), nodePerformance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver;
2722                 if (hasRequiredAPI(nodePerformance_1, PerformanceObserver_1)) {
2723                     performance_1 = nodePerformance_1;
2724                     var version_1 = new ts.Version(process.versions.node);
2725                     var range = new ts.VersionRange("<12.16.3 || 13 <13.13");
2726                     if (range.test(version_1)) {
2727                         performance_1 = {
2728                             get timeOrigin() { return nodePerformance_1.timeOrigin; },
2729                             now: function () { return nodePerformance_1.now(); },
2730                             mark: function (name) { return nodePerformance_1.mark(name); },
2731                             measure: function (name, start, end) {
2732                                 if (start === void 0) { start = "nodeStart"; }
2733                                 if (end === undefined) {
2734                                     end = "__performance.measure-fix__";
2735                                     nodePerformance_1.mark(end);
2736                                 }
2737                                 nodePerformance_1.measure(name, start, end);
2738                                 if (end === "__performance.measure-fix__") {
2739                                     nodePerformance_1.clearMarks("__performance.measure-fix__");
2740                                 }
2741                             }
2742                         };
2743                     }
2744                     return {
2745                         shouldWriteNativeEvents: false,
2746                         performance: performance_1,
2747                         PerformanceObserver: PerformanceObserver_1
2748                     };
2749                 }
2750             }
2751             catch (_b) {
2752             }
2753         }
2754     }
2755     var nativePerformanceHooks = tryGetWebPerformanceHooks() || tryGetNodePerformanceHooks();
2756     var nativePerformance = nativePerformanceHooks === null || nativePerformanceHooks === void 0 ? void 0 : nativePerformanceHooks.performance;
2757     function tryGetNativePerformanceHooks() {
2758         return nativePerformanceHooks;
2759     }
2760     ts.tryGetNativePerformanceHooks = tryGetNativePerformanceHooks;
2761     ts.timestamp = nativePerformance ? function () { return nativePerformance.now(); } :
2762         Date.now ? Date.now :
2763             function () { return +(new Date()); };
2764 })(ts || (ts = {}));
2765 var ts;
2766 (function (ts) {
2767     var performance;
2768     (function (performance) {
2769         var perfHooks;
2770         var performanceImpl;
2771         function createTimerIf(condition, measureName, startMarkName, endMarkName) {
2772             return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer;
2773         }
2774         performance.createTimerIf = createTimerIf;
2775         function createTimer(measureName, startMarkName, endMarkName) {
2776             var enterCount = 0;
2777             return {
2778                 enter: enter,
2779                 exit: exit
2780             };
2781             function enter() {
2782                 if (++enterCount === 1) {
2783                     mark(startMarkName);
2784                 }
2785             }
2786             function exit() {
2787                 if (--enterCount === 0) {
2788                     mark(endMarkName);
2789                     measure(measureName, startMarkName, endMarkName);
2790                 }
2791                 else if (enterCount < 0) {
2792                     ts.Debug.fail("enter/exit count does not match.");
2793                 }
2794             }
2795         }
2796         performance.createTimer = createTimer;
2797         performance.nullTimer = { enter: ts.noop, exit: ts.noop };
2798         var enabled = false;
2799         var timeorigin = ts.timestamp();
2800         var marks = new ts.Map();
2801         var counts = new ts.Map();
2802         var durations = new ts.Map();
2803         function mark(markName) {
2804             var _a;
2805             if (enabled) {
2806                 var count = (_a = counts.get(markName)) !== null && _a !== void 0 ? _a : 0;
2807                 counts.set(markName, count + 1);
2808                 marks.set(markName, ts.timestamp());
2809                 performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName);
2810             }
2811         }
2812         performance.mark = mark;
2813         function measure(measureName, startMarkName, endMarkName) {
2814             var _a, _b;
2815             if (enabled) {
2816                 var end = (_a = (endMarkName !== undefined ? marks.get(endMarkName) : undefined)) !== null && _a !== void 0 ? _a : ts.timestamp();
2817                 var start = (_b = (startMarkName !== undefined ? marks.get(startMarkName) : undefined)) !== null && _b !== void 0 ? _b : timeorigin;
2818                 var previousDuration = durations.get(measureName) || 0;
2819                 durations.set(measureName, previousDuration + (end - start));
2820                 performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName);
2821             }
2822         }
2823         performance.measure = measure;
2824         function getCount(markName) {
2825             return counts.get(markName) || 0;
2826         }
2827         performance.getCount = getCount;
2828         function getDuration(measureName) {
2829             return durations.get(measureName) || 0;
2830         }
2831         performance.getDuration = getDuration;
2832         function forEachMeasure(cb) {
2833             durations.forEach(function (duration, measureName) { return cb(measureName, duration); });
2834         }
2835         performance.forEachMeasure = forEachMeasure;
2836         function isEnabled() {
2837             return enabled;
2838         }
2839         performance.isEnabled = isEnabled;
2840         function enable(system) {
2841             var _a;
2842             if (system === void 0) { system = ts.sys; }
2843             if (!enabled) {
2844                 enabled = true;
2845                 perfHooks || (perfHooks = ts.tryGetNativePerformanceHooks());
2846                 if (perfHooks) {
2847                     timeorigin = perfHooks.performance.timeOrigin;
2848                     if (perfHooks.shouldWriteNativeEvents || ((_a = system === null || system === void 0 ? void 0 : system.cpuProfilingEnabled) === null || _a === void 0 ? void 0 : _a.call(system)) || (system === null || system === void 0 ? void 0 : system.debugMode)) {
2849                         performanceImpl = perfHooks.performance;
2850                     }
2851                 }
2852             }
2853             return true;
2854         }
2855         performance.enable = enable;
2856         function disable() {
2857             if (enabled) {
2858                 marks.clear();
2859                 counts.clear();
2860                 durations.clear();
2861                 performanceImpl = undefined;
2862                 enabled = false;
2863             }
2864         }
2865         performance.disable = disable;
2866     })(performance = ts.performance || (ts.performance = {}));
2867 })(ts || (ts = {}));
2868 var ts;
2869 (function (ts) {
2870     var _a;
2871     var nullLogger = {
2872         logEvent: ts.noop,
2873         logErrEvent: ts.noop,
2874         logPerfEvent: ts.noop,
2875         logInfoEvent: ts.noop,
2876         logStartCommand: ts.noop,
2877         logStopCommand: ts.noop,
2878         logStartUpdateProgram: ts.noop,
2879         logStopUpdateProgram: ts.noop,
2880         logStartUpdateGraph: ts.noop,
2881         logStopUpdateGraph: ts.noop,
2882         logStartResolveModule: ts.noop,
2883         logStopResolveModule: ts.noop,
2884         logStartParseSourceFile: ts.noop,
2885         logStopParseSourceFile: ts.noop,
2886         logStartReadFile: ts.noop,
2887         logStopReadFile: ts.noop,
2888         logStartBindFile: ts.noop,
2889         logStopBindFile: ts.noop,
2890         logStartScheduledOperation: ts.noop,
2891         logStopScheduledOperation: ts.noop,
2892     };
2893     var etwModule;
2894     try {
2895         var etwModulePath = (_a = process.env.TS_ETW_MODULE_PATH) !== null && _a !== void 0 ? _a : "./node_modules/@microsoft/typescript-etw";
2896         etwModule = require(etwModulePath);
2897     }
2898     catch (e) {
2899         etwModule = undefined;
2900     }
2901     ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger;
2902 })(ts || (ts = {}));
2903 var ts;
2904 (function (ts) {
2905 })(ts || (ts = {}));
2906 (function (ts) {
2907     var tracingEnabled;
2908     (function (tracingEnabled) {
2909         var fs;
2910         var traceCount = 0;
2911         var traceFd = 0;
2912         var mode;
2913         var legendPath;
2914         var legend = [];
2915         ;
2916         function startTracing(tracingMode, traceDir, configFilePath) {
2917             ts.Debug.assert(!ts.tracing, "Tracing already started");
2918             if (fs === undefined) {
2919                 try {
2920                     fs = require("fs");
2921                 }
2922                 catch (e) {
2923                     throw new Error("tracing requires having fs\n(original error: " + (e.message || e) + ")");
2924                 }
2925             }
2926             mode = tracingMode;
2927             if (legendPath === undefined) {
2928                 legendPath = ts.combinePaths(traceDir, "legend.json");
2929             }
2930             if (!fs.existsSync(traceDir)) {
2931                 fs.mkdirSync(traceDir, { recursive: true });
2932             }
2933             var countPart = mode === 1 ? "." + process.pid + "-" + ++traceCount
2934                 : mode === 2 ? "." + process.pid
2935                     : "";
2936             var tracePath = ts.combinePaths(traceDir, "trace" + countPart + ".json");
2937             var typesPath = ts.combinePaths(traceDir, "types" + countPart + ".json");
2938             legend.push({
2939                 configFilePath: configFilePath,
2940                 tracePath: tracePath,
2941                 typesPath: typesPath,
2942             });
2943             traceFd = fs.openSync(tracePath, "w");
2944             ts.tracing = tracingEnabled;
2945             var meta = { cat: "__metadata", ph: "M", ts: 1000 * ts.timestamp(), pid: 1, tid: 1 };
2946             fs.writeSync(traceFd, "[\n"
2947                 + [__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" })]
2948                     .map(function (v) { return JSON.stringify(v); }).join(",\n"));
2949         }
2950         tracingEnabled.startTracing = startTracing;
2951         function stopTracing(typeCatalog) {
2952             ts.Debug.assert(ts.tracing, "Tracing is not in progress");
2953             ts.Debug.assert(!!typeCatalog === (mode !== 2));
2954             fs.writeSync(traceFd, "\n]\n");
2955             fs.closeSync(traceFd);
2956             ts.tracing = undefined;
2957             if (typeCatalog) {
2958                 dumpTypes(typeCatalog);
2959             }
2960             else {
2961                 legend[legend.length - 1].typesPath = undefined;
2962             }
2963         }
2964         tracingEnabled.stopTracing = stopTracing;
2965         function instant(phase, name, args) {
2966             writeEvent("I", phase, name, args, "\"s\":\"g\"");
2967         }
2968         tracingEnabled.instant = instant;
2969         var eventStack = [];
2970         function push(phase, name, args, separateBeginAndEnd) {
2971             if (separateBeginAndEnd === void 0) { separateBeginAndEnd = false; }
2972             if (separateBeginAndEnd) {
2973                 writeEvent("B", phase, name, args);
2974             }
2975             eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd });
2976         }
2977         tracingEnabled.push = push;
2978         function pop() {
2979             ts.Debug.assert(eventStack.length > 0);
2980             writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp());
2981             eventStack.length--;
2982         }
2983         tracingEnabled.pop = pop;
2984         function popAll() {
2985             var endTime = 1000 * ts.timestamp();
2986             for (var i = eventStack.length - 1; i >= 0; i--) {
2987                 writeStackEvent(i, endTime);
2988             }
2989             eventStack.length = 0;
2990         }
2991         tracingEnabled.popAll = popAll;
2992         var sampleInterval = 1000 * 10;
2993         function writeStackEvent(index, endTime) {
2994             var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd;
2995             if (separateBeginAndEnd) {
2996                 writeEvent("E", phase, name, args, undefined, endTime);
2997             }
2998             else if (sampleInterval - (time % sampleInterval) <= endTime - time) {
2999                 writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time);
3000             }
3001         }
3002         function writeEvent(eventType, phase, name, args, extras, time) {
3003             if (time === void 0) { time = 1000 * ts.timestamp(); }
3004             if (mode === 2 && phase === "checkTypes")
3005                 return;
3006             ts.performance.mark("beginTracing");
3007             fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"" + eventType + "\",\"cat\":\"" + phase + "\",\"ts\":" + time + ",\"name\":\"" + name + "\"");
3008             if (extras)
3009                 fs.writeSync(traceFd, "," + extras);
3010             if (args)
3011                 fs.writeSync(traceFd, ",\"args\":" + JSON.stringify(args));
3012             fs.writeSync(traceFd, "}");
3013             ts.performance.mark("endTracing");
3014             ts.performance.measure("Tracing", "beginTracing", "endTracing");
3015         }
3016         function indexFromOne(lc) {
3017             return {
3018                 line: lc.line + 1,
3019                 character: lc.character + 1,
3020             };
3021         }
3022         function dumpTypes(types) {
3023             var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
3024             ts.performance.mark("beginDumpTypes");
3025             var typesPath = legend[legend.length - 1].typesPath;
3026             var typesFd = fs.openSync(typesPath, "w");
3027             var recursionIdentityMap = new ts.Map();
3028             fs.writeSync(typesFd, "[");
3029             var numTypes = types.length;
3030             for (var i = 0; i < numTypes; i++) {
3031                 var type = types[i];
3032                 var objectFlags = type.objectFlags;
3033                 var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol;
3034                 var firstDeclaration = (_b = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _b === void 0 ? void 0 : _b[0];
3035                 var firstFile = firstDeclaration && ts.getSourceFileOfNode(firstDeclaration);
3036                 var display = void 0;
3037                 if ((objectFlags & 16) | (type.flags & 2944)) {
3038                     try {
3039                         display = (_c = type.checker) === null || _c === void 0 ? void 0 : _c.typeToString(type);
3040                     }
3041                     catch (_s) {
3042                         display = undefined;
3043                     }
3044                 }
3045                 var indexedAccessProperties = {};
3046                 if (type.flags & 8388608) {
3047                     var indexedAccessType = type;
3048                     indexedAccessProperties = {
3049                         indexedAccessObjectType: (_d = indexedAccessType.objectType) === null || _d === void 0 ? void 0 : _d.id,
3050                         indexedAccessIndexType: (_e = indexedAccessType.indexType) === null || _e === void 0 ? void 0 : _e.id,
3051                     };
3052                 }
3053                 var referenceProperties = {};
3054                 if (objectFlags & 4) {
3055                     var referenceType = type;
3056                     referenceProperties = {
3057                         instantiatedType: (_f = referenceType.target) === null || _f === void 0 ? void 0 : _f.id,
3058                         typeArguments: (_g = referenceType.resolvedTypeArguments) === null || _g === void 0 ? void 0 : _g.map(function (t) { return t.id; }),
3059                     };
3060                 }
3061                 var conditionalProperties = {};
3062                 if (type.flags & 16777216) {
3063                     var conditionalType = type;
3064                     conditionalProperties = {
3065                         conditionalCheckType: (_h = conditionalType.checkType) === null || _h === void 0 ? void 0 : _h.id,
3066                         conditionalExtendsType: (_j = conditionalType.extendsType) === null || _j === void 0 ? void 0 : _j.id,
3067                         conditionalTrueType: (_l = (_k = conditionalType.resolvedTrueType) === null || _k === void 0 ? void 0 : _k.id) !== null && _l !== void 0 ? _l : -1,
3068                         conditionalFalseType: (_o = (_m = conditionalType.resolvedFalseType) === null || _m === void 0 ? void 0 : _m.id) !== null && _o !== void 0 ? _o : -1,
3069                     };
3070                 }
3071                 var recursionToken = void 0;
3072                 var recursionIdentity = type.checker.getRecursionIdentity(type);
3073                 if (recursionIdentity) {
3074                     recursionToken = recursionIdentityMap.get(recursionIdentity);
3075                     if (!recursionToken) {
3076                         recursionToken = recursionIdentityMap.size;
3077                         recursionIdentityMap.set(recursionIdentity, recursionToken);
3078                     }
3079                 }
3080                 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 && {
3081                         path: firstFile.path,
3082                         start: indexFromOne(ts.getLineAndCharacterOfPosition(firstFile, firstDeclaration.pos)),
3083                         end: indexFromOne(ts.getLineAndCharacterOfPosition(ts.getSourceFileOfNode(firstDeclaration), firstDeclaration.end)),
3084                     }, flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display });
3085                 fs.writeSync(typesFd, JSON.stringify(descriptor));
3086                 if (i < numTypes - 1) {
3087                     fs.writeSync(typesFd, ",\n");
3088                 }
3089             }
3090             fs.writeSync(typesFd, "]\n");
3091             fs.closeSync(typesFd);
3092             ts.performance.mark("endDumpTypes");
3093             ts.performance.measure("Dump types", "beginDumpTypes", "endDumpTypes");
3094         }
3095         function dumpLegend() {
3096             if (!legendPath) {
3097                 return;
3098             }
3099             fs.writeFileSync(legendPath, JSON.stringify(legend));
3100         }
3101         tracingEnabled.dumpLegend = dumpLegend;
3102     })(tracingEnabled = ts.tracingEnabled || (ts.tracingEnabled = {}));
3103 })(ts || (ts = {}));
3104 (function (ts) {
3105     ts.startTracing = ts.tracingEnabled.startTracing;
3106 })(ts || (ts = {}));
3107 var ts;
3108 (function (ts) {
3109     var OperationCanceledException = (function () {
3110         function OperationCanceledException() {
3111         }
3112         return OperationCanceledException;
3113     }());
3114     ts.OperationCanceledException = OperationCanceledException;
3115     var FileIncludeKind;
3116     (function (FileIncludeKind) {
3117         FileIncludeKind[FileIncludeKind["RootFile"] = 0] = "RootFile";
3118         FileIncludeKind[FileIncludeKind["SourceFromProjectReference"] = 1] = "SourceFromProjectReference";
3119         FileIncludeKind[FileIncludeKind["OutputFromProjectReference"] = 2] = "OutputFromProjectReference";
3120         FileIncludeKind[FileIncludeKind["Import"] = 3] = "Import";
3121         FileIncludeKind[FileIncludeKind["ReferenceFile"] = 4] = "ReferenceFile";
3122         FileIncludeKind[FileIncludeKind["TypeReferenceDirective"] = 5] = "TypeReferenceDirective";
3123         FileIncludeKind[FileIncludeKind["LibFile"] = 6] = "LibFile";
3124         FileIncludeKind[FileIncludeKind["LibReferenceDirective"] = 7] = "LibReferenceDirective";
3125         FileIncludeKind[FileIncludeKind["AutomaticTypeDirectiveFile"] = 8] = "AutomaticTypeDirectiveFile";
3126     })(FileIncludeKind = ts.FileIncludeKind || (ts.FileIncludeKind = {}));
3127     var ExitStatus;
3128     (function (ExitStatus) {
3129         ExitStatus[ExitStatus["Success"] = 0] = "Success";
3130         ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped";
3131         ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated";
3132         ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped";
3133         ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkipped"] = 4] = "ProjectReferenceCycle_OutputsSkipped";
3134         ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped";
3135     })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {}));
3136     var TypeReferenceSerializationKind;
3137     (function (TypeReferenceSerializationKind) {
3138         TypeReferenceSerializationKind[TypeReferenceSerializationKind["Unknown"] = 0] = "Unknown";
3139         TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithConstructSignatureAndValue"] = 1] = "TypeWithConstructSignatureAndValue";
3140         TypeReferenceSerializationKind[TypeReferenceSerializationKind["VoidNullableOrNeverType"] = 2] = "VoidNullableOrNeverType";
3141         TypeReferenceSerializationKind[TypeReferenceSerializationKind["NumberLikeType"] = 3] = "NumberLikeType";
3142         TypeReferenceSerializationKind[TypeReferenceSerializationKind["BigIntLikeType"] = 4] = "BigIntLikeType";
3143         TypeReferenceSerializationKind[TypeReferenceSerializationKind["StringLikeType"] = 5] = "StringLikeType";
3144         TypeReferenceSerializationKind[TypeReferenceSerializationKind["BooleanType"] = 6] = "BooleanType";
3145         TypeReferenceSerializationKind[TypeReferenceSerializationKind["ArrayLikeType"] = 7] = "ArrayLikeType";
3146         TypeReferenceSerializationKind[TypeReferenceSerializationKind["ESSymbolType"] = 8] = "ESSymbolType";
3147         TypeReferenceSerializationKind[TypeReferenceSerializationKind["Promise"] = 9] = "Promise";
3148         TypeReferenceSerializationKind[TypeReferenceSerializationKind["TypeWithCallSignature"] = 10] = "TypeWithCallSignature";
3149         TypeReferenceSerializationKind[TypeReferenceSerializationKind["ObjectType"] = 11] = "ObjectType";
3150     })(TypeReferenceSerializationKind = ts.TypeReferenceSerializationKind || (ts.TypeReferenceSerializationKind = {}));
3151     var DiagnosticCategory;
3152     (function (DiagnosticCategory) {
3153         DiagnosticCategory[DiagnosticCategory["Warning"] = 0] = "Warning";
3154         DiagnosticCategory[DiagnosticCategory["Error"] = 1] = "Error";
3155         DiagnosticCategory[DiagnosticCategory["Suggestion"] = 2] = "Suggestion";
3156         DiagnosticCategory[DiagnosticCategory["Message"] = 3] = "Message";
3157     })(DiagnosticCategory = ts.DiagnosticCategory || (ts.DiagnosticCategory = {}));
3158     function diagnosticCategoryName(d, lowerCase) {
3159         if (lowerCase === void 0) { lowerCase = true; }
3160         var name = DiagnosticCategory[d.category];
3161         return lowerCase ? name.toLowerCase() : name;
3162     }
3163     ts.diagnosticCategoryName = diagnosticCategoryName;
3164     var ModuleResolutionKind;
3165     (function (ModuleResolutionKind) {
3166         ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic";
3167         ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs";
3168     })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {}));
3169     var WatchFileKind;
3170     (function (WatchFileKind) {
3171         WatchFileKind[WatchFileKind["FixedPollingInterval"] = 0] = "FixedPollingInterval";
3172         WatchFileKind[WatchFileKind["PriorityPollingInterval"] = 1] = "PriorityPollingInterval";
3173         WatchFileKind[WatchFileKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling";
3174         WatchFileKind[WatchFileKind["UseFsEvents"] = 3] = "UseFsEvents";
3175         WatchFileKind[WatchFileKind["UseFsEventsOnParentDirectory"] = 4] = "UseFsEventsOnParentDirectory";
3176     })(WatchFileKind = ts.WatchFileKind || (ts.WatchFileKind = {}));
3177     var WatchDirectoryKind;
3178     (function (WatchDirectoryKind) {
3179         WatchDirectoryKind[WatchDirectoryKind["UseFsEvents"] = 0] = "UseFsEvents";
3180         WatchDirectoryKind[WatchDirectoryKind["FixedPollingInterval"] = 1] = "FixedPollingInterval";
3181         WatchDirectoryKind[WatchDirectoryKind["DynamicPriorityPolling"] = 2] = "DynamicPriorityPolling";
3182     })(WatchDirectoryKind = ts.WatchDirectoryKind || (ts.WatchDirectoryKind = {}));
3183     var PollingWatchKind;
3184     (function (PollingWatchKind) {
3185         PollingWatchKind[PollingWatchKind["FixedInterval"] = 0] = "FixedInterval";
3186         PollingWatchKind[PollingWatchKind["PriorityInterval"] = 1] = "PriorityInterval";
3187         PollingWatchKind[PollingWatchKind["DynamicPriority"] = 2] = "DynamicPriority";
3188     })(PollingWatchKind = ts.PollingWatchKind || (ts.PollingWatchKind = {}));
3189     var ModuleKind;
3190     (function (ModuleKind) {
3191         ModuleKind[ModuleKind["None"] = 0] = "None";
3192         ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS";
3193         ModuleKind[ModuleKind["AMD"] = 2] = "AMD";
3194         ModuleKind[ModuleKind["UMD"] = 3] = "UMD";
3195         ModuleKind[ModuleKind["System"] = 4] = "System";
3196         ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015";
3197         ModuleKind[ModuleKind["ES2020"] = 6] = "ES2020";
3198         ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext";
3199     })(ModuleKind = ts.ModuleKind || (ts.ModuleKind = {}));
3200     ts.commentPragmas = {
3201         "reference": {
3202             args: [
3203                 { name: "types", optional: true, captureSpan: true },
3204                 { name: "lib", optional: true, captureSpan: true },
3205                 { name: "path", optional: true, captureSpan: true },
3206                 { name: "no-default-lib", optional: true }
3207             ],
3208             kind: 1
3209         },
3210         "amd-dependency": {
3211             args: [{ name: "path" }, { name: "name", optional: true }],
3212             kind: 1
3213         },
3214         "amd-module": {
3215             args: [{ name: "name" }],
3216             kind: 1
3217         },
3218         "ts-check": {
3219             kind: 2
3220         },
3221         "ts-nocheck": {
3222             kind: 2
3223         },
3224         "jsx": {
3225             args: [{ name: "factory" }],
3226             kind: 4
3227         },
3228         "jsxfrag": {
3229             args: [{ name: "factory" }],
3230             kind: 4
3231         },
3232         "jsximportsource": {
3233             args: [{ name: "factory" }],
3234             kind: 4
3235         },
3236         "jsxruntime": {
3237             args: [{ name: "factory" }],
3238             kind: 4
3239         },
3240     };
3241 })(ts || (ts = {}));
3242 var ts;
3243 (function (ts) {
3244     ts.directorySeparator = "/";
3245     ts.altDirectorySeparator = "\\";
3246     var urlSchemeSeparator = "://";
3247     var backslashRegExp = /\\/g;
3248     function isAnyDirectorySeparator(charCode) {
3249         return charCode === 47 || charCode === 92;
3250     }
3251     ts.isAnyDirectorySeparator = isAnyDirectorySeparator;
3252     function isUrl(path) {
3253         return getEncodedRootLength(path) < 0;
3254     }
3255     ts.isUrl = isUrl;
3256     function isRootedDiskPath(path) {
3257         return getEncodedRootLength(path) > 0;
3258     }
3259     ts.isRootedDiskPath = isRootedDiskPath;
3260     function isDiskPathRoot(path) {
3261         var rootLength = getEncodedRootLength(path);
3262         return rootLength > 0 && rootLength === path.length;
3263     }
3264     ts.isDiskPathRoot = isDiskPathRoot;
3265     function pathIsAbsolute(path) {
3266         return getEncodedRootLength(path) !== 0;
3267     }
3268     ts.pathIsAbsolute = pathIsAbsolute;
3269     function pathIsRelative(path) {
3270         return /^\.\.?($|[\\/])/.test(path);
3271     }
3272     ts.pathIsRelative = pathIsRelative;
3273     function pathIsBareSpecifier(path) {
3274         return !pathIsAbsolute(path) && !pathIsRelative(path);
3275     }
3276     ts.pathIsBareSpecifier = pathIsBareSpecifier;
3277     function hasExtension(fileName) {
3278         return ts.stringContains(getBaseFileName(fileName), ".");
3279     }
3280     ts.hasExtension = hasExtension;
3281     function fileExtensionIs(path, extension) {
3282         return path.length > extension.length && ts.endsWith(path, extension);
3283     }
3284     ts.fileExtensionIs = fileExtensionIs;
3285     function fileExtensionIsOneOf(path, extensions) {
3286         for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
3287             var extension = extensions_1[_i];
3288             if (fileExtensionIs(path, extension)) {
3289                 return true;
3290             }
3291         }
3292         return false;
3293     }
3294     ts.fileExtensionIsOneOf = fileExtensionIsOneOf;
3295     function hasTrailingDirectorySeparator(path) {
3296         return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1));
3297     }
3298     ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator;
3299     function isVolumeCharacter(charCode) {
3300         return (charCode >= 97 && charCode <= 122) ||
3301             (charCode >= 65 && charCode <= 90);
3302     }
3303     function getFileUrlVolumeSeparatorEnd(url, start) {
3304         var ch0 = url.charCodeAt(start);
3305         if (ch0 === 58)
3306             return start + 1;
3307         if (ch0 === 37 && url.charCodeAt(start + 1) === 51) {
3308             var ch2 = url.charCodeAt(start + 2);
3309             if (ch2 === 97 || ch2 === 65)
3310                 return start + 3;
3311         }
3312         return -1;
3313     }
3314     function getEncodedRootLength(path) {
3315         if (!path)
3316             return 0;
3317         var ch0 = path.charCodeAt(0);
3318         if (ch0 === 47 || ch0 === 92) {
3319             if (path.charCodeAt(1) !== ch0)
3320                 return 1;
3321             var p1 = path.indexOf(ch0 === 47 ? ts.directorySeparator : ts.altDirectorySeparator, 2);
3322             if (p1 < 0)
3323                 return path.length;
3324             return p1 + 1;
3325         }
3326         if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58) {
3327             var ch2 = path.charCodeAt(2);
3328             if (ch2 === 47 || ch2 === 92)
3329                 return 3;
3330             if (path.length === 2)
3331                 return 2;
3332         }
3333         var schemeEnd = path.indexOf(urlSchemeSeparator);
3334         if (schemeEnd !== -1) {
3335             var authorityStart = schemeEnd + urlSchemeSeparator.length;
3336             var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart);
3337             if (authorityEnd !== -1) {
3338                 var scheme = path.slice(0, schemeEnd);
3339                 var authority = path.slice(authorityStart, authorityEnd);
3340                 if (scheme === "file" && (authority === "" || authority === "localhost") &&
3341                     isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
3342                     var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
3343                     if (volumeSeparatorEnd !== -1) {
3344                         if (path.charCodeAt(volumeSeparatorEnd) === 47) {
3345                             return ~(volumeSeparatorEnd + 1);
3346                         }
3347                         if (volumeSeparatorEnd === path.length) {
3348                             return ~volumeSeparatorEnd;
3349                         }
3350                     }
3351                 }
3352                 return ~(authorityEnd + 1);
3353             }
3354             return ~path.length;
3355         }
3356         return 0;
3357     }
3358     function getRootLength(path) {
3359         var rootLength = getEncodedRootLength(path);
3360         return rootLength < 0 ? ~rootLength : rootLength;
3361     }
3362     ts.getRootLength = getRootLength;
3363     function getDirectoryPath(path) {
3364         path = normalizeSlashes(path);
3365         var rootLength = getRootLength(path);
3366         if (rootLength === path.length)
3367             return path;
3368         path = removeTrailingDirectorySeparator(path);
3369         return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator)));
3370     }
3371     ts.getDirectoryPath = getDirectoryPath;
3372     function getBaseFileName(path, extensions, ignoreCase) {
3373         path = normalizeSlashes(path);
3374         var rootLength = getRootLength(path);
3375         if (rootLength === path.length)
3376             return "";
3377         path = removeTrailingDirectorySeparator(path);
3378         var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1));
3379         var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined;
3380         return extension ? name.slice(0, name.length - extension.length) : name;
3381     }
3382     ts.getBaseFileName = getBaseFileName;
3383     function tryGetExtensionFromPath(path, extension, stringEqualityComparer) {
3384         if (!ts.startsWith(extension, "."))
3385             extension = "." + extension;
3386         if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46) {
3387             var pathExtension = path.slice(path.length - extension.length);
3388             if (stringEqualityComparer(pathExtension, extension)) {
3389                 return pathExtension;
3390             }
3391         }
3392     }
3393     function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) {
3394         if (typeof extensions === "string") {
3395             return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || "";
3396         }
3397         for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) {
3398             var extension = extensions_2[_i];
3399             var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer);
3400             if (result)
3401                 return result;
3402         }
3403         return "";
3404     }
3405     function getAnyExtensionFromPath(path, extensions, ignoreCase) {
3406         if (extensions) {
3407             return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive);
3408         }
3409         var baseFileName = getBaseFileName(path);
3410         var extensionIndex = baseFileName.lastIndexOf(".");
3411         if (extensionIndex >= 0) {
3412             return baseFileName.substring(extensionIndex);
3413         }
3414         return "";
3415     }
3416     ts.getAnyExtensionFromPath = getAnyExtensionFromPath;
3417     function pathComponents(path, rootLength) {
3418         var root = path.substring(0, rootLength);
3419         var rest = path.substring(rootLength).split(ts.directorySeparator);
3420         if (rest.length && !ts.lastOrUndefined(rest))
3421             rest.pop();
3422         return __spreadArray([root], rest);
3423     }
3424     function getPathComponents(path, currentDirectory) {
3425         if (currentDirectory === void 0) { currentDirectory = ""; }
3426         path = combinePaths(currentDirectory, path);
3427         return pathComponents(path, getRootLength(path));
3428     }
3429     ts.getPathComponents = getPathComponents;
3430     function getPathFromPathComponents(pathComponents) {
3431         if (pathComponents.length === 0)
3432             return "";
3433         var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
3434         return root + pathComponents.slice(1).join(ts.directorySeparator);
3435     }
3436     ts.getPathFromPathComponents = getPathFromPathComponents;
3437     function normalizeSlashes(path) {
3438         return path.replace(backslashRegExp, ts.directorySeparator);
3439     }
3440     ts.normalizeSlashes = normalizeSlashes;
3441     function reducePathComponents(components) {
3442         if (!ts.some(components))
3443             return [];
3444         var reduced = [components[0]];
3445         for (var i = 1; i < components.length; i++) {
3446             var component = components[i];
3447             if (!component)
3448                 continue;
3449             if (component === ".")
3450                 continue;
3451             if (component === "..") {
3452                 if (reduced.length > 1) {
3453                     if (reduced[reduced.length - 1] !== "..") {
3454                         reduced.pop();
3455                         continue;
3456                     }
3457                 }
3458                 else if (reduced[0])
3459                     continue;
3460             }
3461             reduced.push(component);
3462         }
3463         return reduced;
3464     }
3465     ts.reducePathComponents = reducePathComponents;
3466     function combinePaths(path) {
3467         var paths = [];
3468         for (var _i = 1; _i < arguments.length; _i++) {
3469             paths[_i - 1] = arguments[_i];
3470         }
3471         if (path)
3472             path = normalizeSlashes(path);
3473         for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
3474             var relativePath = paths_1[_a];
3475             if (!relativePath)
3476                 continue;
3477             relativePath = normalizeSlashes(relativePath);
3478             if (!path || getRootLength(relativePath) !== 0) {
3479                 path = relativePath;
3480             }
3481             else {
3482                 path = ensureTrailingDirectorySeparator(path) + relativePath;
3483             }
3484         }
3485         return path;
3486     }
3487     ts.combinePaths = combinePaths;
3488     function resolvePath(path) {
3489         var paths = [];
3490         for (var _i = 1; _i < arguments.length; _i++) {
3491             paths[_i - 1] = arguments[_i];
3492         }
3493         return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArray([path], paths)) : normalizeSlashes(path));
3494     }
3495     ts.resolvePath = resolvePath;
3496     function getNormalizedPathComponents(path, currentDirectory) {
3497         return reducePathComponents(getPathComponents(path, currentDirectory));
3498     }
3499     ts.getNormalizedPathComponents = getNormalizedPathComponents;
3500     function getNormalizedAbsolutePath(fileName, currentDirectory) {
3501         return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
3502     }
3503     ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
3504     function normalizePath(path) {
3505         path = normalizeSlashes(path);
3506         var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
3507         return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
3508     }
3509     ts.normalizePath = normalizePath;
3510     function getPathWithoutRoot(pathComponents) {
3511         if (pathComponents.length === 0)
3512             return "";
3513         return pathComponents.slice(1).join(ts.directorySeparator);
3514     }
3515     function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
3516         return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
3517     }
3518     ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
3519     function toPath(fileName, basePath, getCanonicalFileName) {
3520         var nonCanonicalizedPath = isRootedDiskPath(fileName)
3521             ? normalizePath(fileName)
3522             : getNormalizedAbsolutePath(fileName, basePath);
3523         return getCanonicalFileName(nonCanonicalizedPath);
3524     }
3525     ts.toPath = toPath;
3526     function normalizePathAndParts(path) {
3527         path = normalizeSlashes(path);
3528         var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
3529         if (parts.length) {
3530             var joinedParts = root + parts.join(ts.directorySeparator);
3531             return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
3532         }
3533         else {
3534             return { path: root, parts: parts };
3535         }
3536     }
3537     ts.normalizePathAndParts = normalizePathAndParts;
3538     function removeTrailingDirectorySeparator(path) {
3539         if (hasTrailingDirectorySeparator(path)) {
3540             return path.substr(0, path.length - 1);
3541         }
3542         return path;
3543     }
3544     ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
3545     function ensureTrailingDirectorySeparator(path) {
3546         if (!hasTrailingDirectorySeparator(path)) {
3547             return path + ts.directorySeparator;
3548         }
3549         return path;
3550     }
3551     ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator;
3552     function ensurePathIsNonModuleName(path) {
3553         return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path;
3554     }
3555     ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName;
3556     function changeAnyExtension(path, ext, extensions, ignoreCase) {
3557         var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path);
3558         return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
3559     }
3560     ts.changeAnyExtension = changeAnyExtension;
3561     var relativePathSegmentRegExp = /(^|\/)\.{0,2}($|\/)/;
3562     function comparePathsWorker(a, b, componentComparer) {
3563         if (a === b)
3564             return 0;
3565         if (a === undefined)
3566             return -1;
3567         if (b === undefined)
3568             return 1;
3569         var aRoot = a.substring(0, getRootLength(a));
3570         var bRoot = b.substring(0, getRootLength(b));
3571         var result = ts.compareStringsCaseInsensitive(aRoot, bRoot);
3572         if (result !== 0) {
3573             return result;
3574         }
3575         var aRest = a.substring(aRoot.length);
3576         var bRest = b.substring(bRoot.length);
3577         if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) {
3578             return componentComparer(aRest, bRest);
3579         }
3580         var aComponents = reducePathComponents(getPathComponents(a));
3581         var bComponents = reducePathComponents(getPathComponents(b));
3582         var sharedLength = Math.min(aComponents.length, bComponents.length);
3583         for (var i = 1; i < sharedLength; i++) {
3584             var result_2 = componentComparer(aComponents[i], bComponents[i]);
3585             if (result_2 !== 0) {
3586                 return result_2;
3587             }
3588         }
3589         return ts.compareValues(aComponents.length, bComponents.length);
3590     }
3591     function comparePathsCaseSensitive(a, b) {
3592         return comparePathsWorker(a, b, ts.compareStringsCaseSensitive);
3593     }
3594     ts.comparePathsCaseSensitive = comparePathsCaseSensitive;
3595     function comparePathsCaseInsensitive(a, b) {
3596         return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive);
3597     }
3598     ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive;
3599     function comparePaths(a, b, currentDirectory, ignoreCase) {
3600         if (typeof currentDirectory === "string") {
3601             a = combinePaths(currentDirectory, a);
3602             b = combinePaths(currentDirectory, b);
3603         }
3604         else if (typeof currentDirectory === "boolean") {
3605             ignoreCase = currentDirectory;
3606         }
3607         return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase));
3608     }
3609     ts.comparePaths = comparePaths;
3610     function containsPath(parent, child, currentDirectory, ignoreCase) {
3611         if (typeof currentDirectory === "string") {
3612             parent = combinePaths(currentDirectory, parent);
3613             child = combinePaths(currentDirectory, child);
3614         }
3615         else if (typeof currentDirectory === "boolean") {
3616             ignoreCase = currentDirectory;
3617         }
3618         if (parent === undefined || child === undefined)
3619             return false;
3620         if (parent === child)
3621             return true;
3622         var parentComponents = reducePathComponents(getPathComponents(parent));
3623         var childComponents = reducePathComponents(getPathComponents(child));
3624         if (childComponents.length < parentComponents.length) {
3625             return false;
3626         }
3627         var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive;
3628         for (var i = 0; i < parentComponents.length; i++) {
3629             var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer;
3630             if (!equalityComparer(parentComponents[i], childComponents[i])) {
3631                 return false;
3632             }
3633         }
3634         return true;
3635     }
3636     ts.containsPath = containsPath;
3637     function startsWithDirectory(fileName, directoryName, getCanonicalFileName) {
3638         var canonicalFileName = getCanonicalFileName(fileName);
3639         var canonicalDirectoryName = getCanonicalFileName(directoryName);
3640         return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\");
3641     }
3642     ts.startsWithDirectory = startsWithDirectory;
3643     function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) {
3644         var fromComponents = reducePathComponents(getPathComponents(from));
3645         var toComponents = reducePathComponents(getPathComponents(to));
3646         var start;
3647         for (start = 0; start < fromComponents.length && start < toComponents.length; start++) {
3648             var fromComponent = getCanonicalFileName(fromComponents[start]);
3649             var toComponent = getCanonicalFileName(toComponents[start]);
3650             var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer;
3651             if (!comparer(fromComponent, toComponent))
3652                 break;
3653         }
3654         if (start === 0) {
3655             return toComponents;
3656         }
3657         var components = toComponents.slice(start);
3658         var relative = [];
3659         for (; start < fromComponents.length; start++) {
3660             relative.push("..");
3661         }
3662         return __spreadArray(__spreadArray([""], relative), components);
3663     }
3664     ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo;
3665     function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
3666         ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
3667         var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
3668         var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
3669         var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
3670         return getPathFromPathComponents(pathComponents);
3671     }
3672     ts.getRelativePathFromDirectory = getRelativePathFromDirectory;
3673     function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
3674         return !isRootedDiskPath(absoluteOrRelativePath)
3675             ? absoluteOrRelativePath
3676             : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, false);
3677     }
3678     ts.convertToRelativePath = convertToRelativePath;
3679     function getRelativePathFromFile(from, to, getCanonicalFileName) {
3680         return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName));
3681     }
3682     ts.getRelativePathFromFile = getRelativePathFromFile;
3683     function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
3684         var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName);
3685         var firstComponent = pathComponents[0];
3686         if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) {
3687             var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///";
3688             pathComponents[0] = prefix + firstComponent;
3689         }
3690         return getPathFromPathComponents(pathComponents);
3691     }
3692     ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl;
3693     function forEachAncestorDirectory(directory, callback) {
3694         while (true) {
3695             var result = callback(directory);
3696             if (result !== undefined) {
3697                 return result;
3698             }
3699             var parentPath = getDirectoryPath(directory);
3700             if (parentPath === directory) {
3701                 return undefined;
3702             }
3703             directory = parentPath;
3704         }
3705     }
3706     ts.forEachAncestorDirectory = forEachAncestorDirectory;
3707     function isNodeModulesDirectory(dirPath) {
3708         return ts.endsWith(dirPath, "/node_modules");
3709     }
3710     ts.isNodeModulesDirectory = isNodeModulesDirectory;
3711 })(ts || (ts = {}));
3712 var ts;
3713 (function (ts) {
3714     function generateDjb2Hash(data) {
3715         var acc = 5381;
3716         for (var i = 0; i < data.length; i++) {
3717             acc = ((acc << 5) + acc) + data.charCodeAt(i);
3718         }
3719         return acc.toString();
3720     }
3721     ts.generateDjb2Hash = generateDjb2Hash;
3722     function setStackTraceLimit() {
3723         if (Error.stackTraceLimit < 100) {
3724             Error.stackTraceLimit = 100;
3725         }
3726     }
3727     ts.setStackTraceLimit = setStackTraceLimit;
3728     var FileWatcherEventKind;
3729     (function (FileWatcherEventKind) {
3730         FileWatcherEventKind[FileWatcherEventKind["Created"] = 0] = "Created";
3731         FileWatcherEventKind[FileWatcherEventKind["Changed"] = 1] = "Changed";
3732         FileWatcherEventKind[FileWatcherEventKind["Deleted"] = 2] = "Deleted";
3733     })(FileWatcherEventKind = ts.FileWatcherEventKind || (ts.FileWatcherEventKind = {}));
3734     var PollingInterval;
3735     (function (PollingInterval) {
3736         PollingInterval[PollingInterval["High"] = 2000] = "High";
3737         PollingInterval[PollingInterval["Medium"] = 500] = "Medium";
3738         PollingInterval[PollingInterval["Low"] = 250] = "Low";
3739     })(PollingInterval = ts.PollingInterval || (ts.PollingInterval = {}));
3740     ts.missingFileModifiedTime = new Date(0);
3741     function createPollingIntervalBasedLevels(levels) {
3742         var _a;
3743         return _a = {},
3744             _a[PollingInterval.Low] = levels.Low,
3745             _a[PollingInterval.Medium] = levels.Medium,
3746             _a[PollingInterval.High] = levels.High,
3747             _a;
3748     }
3749     var defaultChunkLevels = { Low: 32, Medium: 64, High: 256 };
3750     var pollingChunkSize = createPollingIntervalBasedLevels(defaultChunkLevels);
3751     ts.unchangedPollThresholds = createPollingIntervalBasedLevels(defaultChunkLevels);
3752     function setCustomPollingValues(system) {
3753         if (!system.getEnvironmentVariable) {
3754             return;
3755         }
3756         var pollingIntervalChanged = setCustomLevels("TSC_WATCH_POLLINGINTERVAL", PollingInterval);
3757         pollingChunkSize = getCustomPollingBasedLevels("TSC_WATCH_POLLINGCHUNKSIZE", defaultChunkLevels) || pollingChunkSize;
3758         ts.unchangedPollThresholds = getCustomPollingBasedLevels("TSC_WATCH_UNCHANGEDPOLLTHRESHOLDS", defaultChunkLevels) || ts.unchangedPollThresholds;
3759         function getLevel(envVar, level) {
3760             return system.getEnvironmentVariable(envVar + "_" + level.toUpperCase());
3761         }
3762         function getCustomLevels(baseVariable) {
3763             var customLevels;
3764             setCustomLevel("Low");
3765             setCustomLevel("Medium");
3766             setCustomLevel("High");
3767             return customLevels;
3768             function setCustomLevel(level) {
3769                 var customLevel = getLevel(baseVariable, level);
3770                 if (customLevel) {
3771                     (customLevels || (customLevels = {}))[level] = Number(customLevel);
3772                 }
3773             }
3774         }
3775         function setCustomLevels(baseVariable, levels) {
3776             var customLevels = getCustomLevels(baseVariable);
3777             if (customLevels) {
3778                 setLevel("Low");
3779                 setLevel("Medium");
3780                 setLevel("High");
3781                 return true;
3782             }
3783             return false;
3784             function setLevel(level) {
3785                 levels[level] = customLevels[level] || levels[level];
3786             }
3787         }
3788         function getCustomPollingBasedLevels(baseVariable, defaultLevels) {
3789             var customLevels = getCustomLevels(baseVariable);
3790             return (pollingIntervalChanged || customLevels) &&
3791                 createPollingIntervalBasedLevels(customLevels ? __assign(__assign({}, defaultLevels), customLevels) : defaultLevels);
3792         }
3793     }
3794     ts.setCustomPollingValues = setCustomPollingValues;
3795     function createDynamicPriorityPollingWatchFile(host) {
3796         var watchedFiles = [];
3797         var changedFilesInLastPoll = [];
3798         var lowPollingIntervalQueue = createPollingIntervalQueue(PollingInterval.Low);
3799         var mediumPollingIntervalQueue = createPollingIntervalQueue(PollingInterval.Medium);
3800         var highPollingIntervalQueue = createPollingIntervalQueue(PollingInterval.High);
3801         return watchFile;
3802         function watchFile(fileName, callback, defaultPollingInterval) {
3803             var file = {
3804                 fileName: fileName,
3805                 callback: callback,
3806                 unchangedPolls: 0,
3807                 mtime: getModifiedTime(fileName)
3808             };
3809             watchedFiles.push(file);
3810             addToPollingIntervalQueue(file, defaultPollingInterval);
3811             return {
3812                 close: function () {
3813                     file.isClosed = true;
3814                     ts.unorderedRemoveItem(watchedFiles, file);
3815                 }
3816             };
3817         }
3818         function createPollingIntervalQueue(pollingInterval) {
3819             var queue = [];
3820             queue.pollingInterval = pollingInterval;
3821             queue.pollIndex = 0;
3822             queue.pollScheduled = false;
3823             return queue;
3824         }
3825         function pollPollingIntervalQueue(queue) {
3826             queue.pollIndex = pollQueue(queue, queue.pollingInterval, queue.pollIndex, pollingChunkSize[queue.pollingInterval]);
3827             if (queue.length) {
3828                 scheduleNextPoll(queue.pollingInterval);
3829             }
3830             else {
3831                 ts.Debug.assert(queue.pollIndex === 0);
3832                 queue.pollScheduled = false;
3833             }
3834         }
3835         function pollLowPollingIntervalQueue(queue) {
3836             pollQueue(changedFilesInLastPoll, PollingInterval.Low, 0, changedFilesInLastPoll.length);
3837             pollPollingIntervalQueue(queue);
3838             if (!queue.pollScheduled && changedFilesInLastPoll.length) {
3839                 scheduleNextPoll(PollingInterval.Low);
3840             }
3841         }
3842         function pollQueue(queue, pollingInterval, pollIndex, chunkSize) {
3843             var needsVisit = queue.length;
3844             var definedValueCopyToIndex = pollIndex;
3845             for (var polled = 0; polled < chunkSize && needsVisit > 0; nextPollIndex(), needsVisit--) {
3846                 var watchedFile = queue[pollIndex];
3847                 if (!watchedFile) {
3848                     continue;
3849                 }
3850                 else if (watchedFile.isClosed) {
3851                     queue[pollIndex] = undefined;
3852                     continue;
3853                 }
3854                 polled++;
3855                 var fileChanged = onWatchedFileStat(watchedFile, getModifiedTime(watchedFile.fileName));
3856                 if (watchedFile.isClosed) {
3857                     queue[pollIndex] = undefined;
3858                 }
3859                 else if (fileChanged) {
3860                     watchedFile.unchangedPolls = 0;
3861                     if (queue !== changedFilesInLastPoll) {
3862                         queue[pollIndex] = undefined;
3863                         addChangedFileToLowPollingIntervalQueue(watchedFile);
3864                     }
3865                 }
3866                 else if (watchedFile.unchangedPolls !== ts.unchangedPollThresholds[pollingInterval]) {
3867                     watchedFile.unchangedPolls++;
3868                 }
3869                 else if (queue === changedFilesInLastPoll) {
3870                     watchedFile.unchangedPolls = 1;
3871                     queue[pollIndex] = undefined;
3872                     addToPollingIntervalQueue(watchedFile, PollingInterval.Low);
3873                 }
3874                 else if (pollingInterval !== PollingInterval.High) {
3875                     watchedFile.unchangedPolls++;
3876                     queue[pollIndex] = undefined;
3877                     addToPollingIntervalQueue(watchedFile, pollingInterval === PollingInterval.Low ? PollingInterval.Medium : PollingInterval.High);
3878                 }
3879                 if (queue[pollIndex]) {
3880                     if (definedValueCopyToIndex < pollIndex) {
3881                         queue[definedValueCopyToIndex] = watchedFile;
3882                         queue[pollIndex] = undefined;
3883                     }
3884                     definedValueCopyToIndex++;
3885                 }
3886             }
3887             return pollIndex;
3888             function nextPollIndex() {
3889                 pollIndex++;
3890                 if (pollIndex === queue.length) {
3891                     if (definedValueCopyToIndex < pollIndex) {
3892                         queue.length = definedValueCopyToIndex;
3893                     }
3894                     pollIndex = 0;
3895                     definedValueCopyToIndex = 0;
3896                 }
3897             }
3898         }
3899         function pollingIntervalQueue(pollingInterval) {
3900             switch (pollingInterval) {
3901                 case PollingInterval.Low:
3902                     return lowPollingIntervalQueue;
3903                 case PollingInterval.Medium:
3904                     return mediumPollingIntervalQueue;
3905                 case PollingInterval.High:
3906                     return highPollingIntervalQueue;
3907             }
3908         }
3909         function addToPollingIntervalQueue(file, pollingInterval) {
3910             pollingIntervalQueue(pollingInterval).push(file);
3911             scheduleNextPollIfNotAlreadyScheduled(pollingInterval);
3912         }
3913         function addChangedFileToLowPollingIntervalQueue(file) {
3914             changedFilesInLastPoll.push(file);
3915             scheduleNextPollIfNotAlreadyScheduled(PollingInterval.Low);
3916         }
3917         function scheduleNextPollIfNotAlreadyScheduled(pollingInterval) {
3918             if (!pollingIntervalQueue(pollingInterval).pollScheduled) {
3919                 scheduleNextPoll(pollingInterval);
3920             }
3921         }
3922         function scheduleNextPoll(pollingInterval) {
3923             pollingIntervalQueue(pollingInterval).pollScheduled = host.setTimeout(pollingInterval === PollingInterval.Low ? pollLowPollingIntervalQueue : pollPollingIntervalQueue, pollingInterval, pollingIntervalQueue(pollingInterval));
3924         }
3925         function getModifiedTime(fileName) {
3926             return host.getModifiedTime(fileName) || ts.missingFileModifiedTime;
3927         }
3928     }
3929     ts.createDynamicPriorityPollingWatchFile = createDynamicPriorityPollingWatchFile;
3930     function createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames) {
3931         var fileWatcherCallbacks = ts.createMultiMap();
3932         var dirWatchers = new ts.Map();
3933         var toCanonicalName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
3934         return nonPollingWatchFile;
3935         function nonPollingWatchFile(fileName, callback, _pollingInterval, fallbackOptions) {
3936             var filePath = toCanonicalName(fileName);
3937             fileWatcherCallbacks.add(filePath, callback);
3938             var dirPath = ts.getDirectoryPath(filePath) || ".";
3939             var watcher = dirWatchers.get(dirPath) ||
3940                 createDirectoryWatcher(ts.getDirectoryPath(fileName) || ".", dirPath, fallbackOptions);
3941             watcher.referenceCount++;
3942             return {
3943                 close: function () {
3944                     if (watcher.referenceCount === 1) {
3945                         watcher.close();
3946                         dirWatchers.delete(dirPath);
3947                     }
3948                     else {
3949                         watcher.referenceCount--;
3950                     }
3951                     fileWatcherCallbacks.remove(filePath, callback);
3952                 }
3953             };
3954         }
3955         function createDirectoryWatcher(dirName, dirPath, fallbackOptions) {
3956             var watcher = fsWatch(dirName, 1, function (_eventName, relativeFileName) {
3957                 if (!ts.isString(relativeFileName)) {
3958                     return;
3959                 }
3960                 var fileName = ts.getNormalizedAbsolutePath(relativeFileName, dirName);
3961                 var callbacks = fileName && fileWatcherCallbacks.get(toCanonicalName(fileName));
3962                 if (callbacks) {
3963                     for (var _i = 0, callbacks_1 = callbacks; _i < callbacks_1.length; _i++) {
3964                         var fileCallback = callbacks_1[_i];
3965                         fileCallback(fileName, FileWatcherEventKind.Changed);
3966                     }
3967                 }
3968             }, false, PollingInterval.Medium, fallbackOptions);
3969             watcher.referenceCount = 0;
3970             dirWatchers.set(dirPath, watcher);
3971             return watcher;
3972         }
3973     }
3974     function createSingleFileWatcherPerName(watchFile, useCaseSensitiveFileNames) {
3975         var cache = new ts.Map();
3976         var callbacksCache = ts.createMultiMap();
3977         var toCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
3978         return function (fileName, callback, pollingInterval, options) {
3979             var path = toCanonicalFileName(fileName);
3980             var existing = cache.get(path);
3981             if (existing) {
3982                 existing.refCount++;
3983             }
3984             else {
3985                 cache.set(path, {
3986                     watcher: watchFile(fileName, function (fileName, eventKind) { return ts.forEach(callbacksCache.get(path), function (cb) { return cb(fileName, eventKind); }); }, pollingInterval, options),
3987                     refCount: 1
3988                 });
3989             }
3990             callbacksCache.add(path, callback);
3991             return {
3992                 close: function () {
3993                     var watcher = ts.Debug.checkDefined(cache.get(path));
3994                     callbacksCache.remove(path, callback);
3995                     watcher.refCount--;
3996                     if (watcher.refCount)
3997                         return;
3998                     cache.delete(path);
3999                     ts.closeFileWatcherOf(watcher);
4000                 }
4001             };
4002         };
4003     }
4004     ts.createSingleFileWatcherPerName = createSingleFileWatcherPerName;
4005     function onWatchedFileStat(watchedFile, modifiedTime) {
4006         var oldTime = watchedFile.mtime.getTime();
4007         var newTime = modifiedTime.getTime();
4008         if (oldTime !== newTime) {
4009             watchedFile.mtime = modifiedTime;
4010             watchedFile.callback(watchedFile.fileName, getFileWatcherEventKind(oldTime, newTime));
4011             return true;
4012         }
4013         return false;
4014     }
4015     ts.onWatchedFileStat = onWatchedFileStat;
4016     function getFileWatcherEventKind(oldTime, newTime) {
4017         return oldTime === 0
4018             ? FileWatcherEventKind.Created
4019             : newTime === 0
4020                 ? FileWatcherEventKind.Deleted
4021                 : FileWatcherEventKind.Changed;
4022     }
4023     ts.getFileWatcherEventKind = getFileWatcherEventKind;
4024     ts.ignoredPaths = ["/node_modules/.", "/.git", "/.#"];
4025     ts.sysLog = ts.noop;
4026     function setSysLog(logger) {
4027         ts.sysLog = logger;
4028     }
4029     ts.setSysLog = setSysLog;
4030     function createDirectoryWatcherSupportingRecursive(_a) {
4031         var watchDirectory = _a.watchDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, directoryExists = _a.directoryExists, realpath = _a.realpath, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout;
4032         var cache = new ts.Map();
4033         var callbackCache = ts.createMultiMap();
4034         var cacheToUpdateChildWatches = new ts.Map();
4035         var timerToUpdateChildWatches;
4036         var filePathComparer = ts.getStringComparer(!useCaseSensitiveFileNames);
4037         var toCanonicalFilePath = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
4038         return function (dirName, callback, recursive, options) { return recursive ?
4039             createDirectoryWatcher(dirName, options, callback) :
4040             watchDirectory(dirName, callback, recursive, options); };
4041         function createDirectoryWatcher(dirName, options, callback) {
4042             var dirPath = toCanonicalFilePath(dirName);
4043             var directoryWatcher = cache.get(dirPath);
4044             if (directoryWatcher) {
4045                 directoryWatcher.refCount++;
4046             }
4047             else {
4048                 directoryWatcher = {
4049                     watcher: watchDirectory(dirName, function (fileName) {
4050                         if (isIgnoredPath(fileName, options))
4051                             return;
4052                         if (options === null || options === void 0 ? void 0 : options.synchronousWatchDirectory) {
4053                             invokeCallbacks(dirPath, fileName);
4054                             updateChildWatches(dirName, dirPath, options);
4055                         }
4056                         else {
4057                             nonSyncUpdateChildWatches(dirName, dirPath, fileName, options);
4058                         }
4059                     }, false, options),
4060                     refCount: 1,
4061                     childWatches: ts.emptyArray
4062                 };
4063                 cache.set(dirPath, directoryWatcher);
4064                 updateChildWatches(dirName, dirPath, options);
4065             }
4066             var callbackToAdd = callback && { dirName: dirName, callback: callback };
4067             if (callbackToAdd) {
4068                 callbackCache.add(dirPath, callbackToAdd);
4069             }
4070             return {
4071                 dirName: dirName,
4072                 close: function () {
4073                     var directoryWatcher = ts.Debug.checkDefined(cache.get(dirPath));
4074                     if (callbackToAdd)
4075                         callbackCache.remove(dirPath, callbackToAdd);
4076                     directoryWatcher.refCount--;
4077                     if (directoryWatcher.refCount)
4078                         return;
4079                     cache.delete(dirPath);
4080                     ts.closeFileWatcherOf(directoryWatcher);
4081                     directoryWatcher.childWatches.forEach(ts.closeFileWatcher);
4082                 }
4083             };
4084         }
4085         function invokeCallbacks(dirPath, fileNameOrInvokeMap, fileNames) {
4086             var fileName;
4087             var invokeMap;
4088             if (ts.isString(fileNameOrInvokeMap)) {
4089                 fileName = fileNameOrInvokeMap;
4090             }
4091             else {
4092                 invokeMap = fileNameOrInvokeMap;
4093             }
4094             callbackCache.forEach(function (callbacks, rootDirName) {
4095                 var _a;
4096                 if (invokeMap && invokeMap.get(rootDirName) === true)
4097                     return;
4098                 if (rootDirName === dirPath || (ts.startsWith(dirPath, rootDirName) && dirPath[rootDirName.length] === ts.directorySeparator)) {
4099                     if (invokeMap) {
4100                         if (fileNames) {
4101                             var existing = invokeMap.get(rootDirName);
4102                             if (existing) {
4103                                 (_a = existing).push.apply(_a, fileNames);
4104                             }
4105                             else {
4106                                 invokeMap.set(rootDirName, fileNames.slice());
4107                             }
4108                         }
4109                         else {
4110                             invokeMap.set(rootDirName, true);
4111                         }
4112                     }
4113                     else {
4114                         callbacks.forEach(function (_a) {
4115                             var callback = _a.callback;
4116                             return callback(fileName);
4117                         });
4118                     }
4119                 }
4120             });
4121         }
4122         function nonSyncUpdateChildWatches(dirName, dirPath, fileName, options) {
4123             var parentWatcher = cache.get(dirPath);
4124             if (parentWatcher && directoryExists(dirName)) {
4125                 scheduleUpdateChildWatches(dirName, dirPath, fileName, options);
4126                 return;
4127             }
4128             invokeCallbacks(dirPath, fileName);
4129             removeChildWatches(parentWatcher);
4130         }
4131         function scheduleUpdateChildWatches(dirName, dirPath, fileName, options) {
4132             var existing = cacheToUpdateChildWatches.get(dirPath);
4133             if (existing) {
4134                 existing.fileNames.push(fileName);
4135             }
4136             else {
4137                 cacheToUpdateChildWatches.set(dirPath, { dirName: dirName, options: options, fileNames: [fileName] });
4138             }
4139             if (timerToUpdateChildWatches) {
4140                 clearTimeout(timerToUpdateChildWatches);
4141                 timerToUpdateChildWatches = undefined;
4142             }
4143             timerToUpdateChildWatches = setTimeout(onTimerToUpdateChildWatches, 1000);
4144         }
4145         function onTimerToUpdateChildWatches() {
4146             timerToUpdateChildWatches = undefined;
4147             ts.sysLog("sysLog:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size);
4148             var start = ts.timestamp();
4149             var invokeMap = new ts.Map();
4150             while (!timerToUpdateChildWatches && cacheToUpdateChildWatches.size) {
4151                 var result = cacheToUpdateChildWatches.entries().next();
4152                 ts.Debug.assert(!result.done);
4153                 var _a = result.value, dirPath = _a[0], _b = _a[1], dirName = _b.dirName, options = _b.options, fileNames = _b.fileNames;
4154                 cacheToUpdateChildWatches.delete(dirPath);
4155                 var hasChanges = updateChildWatches(dirName, dirPath, options);
4156                 invokeCallbacks(dirPath, invokeMap, hasChanges ? undefined : fileNames);
4157             }
4158             ts.sysLog("sysLog:: invokingWatchers:: Elapsed:: " + (ts.timestamp() - start) + "ms:: " + cacheToUpdateChildWatches.size);
4159             callbackCache.forEach(function (callbacks, rootDirName) {
4160                 var existing = invokeMap.get(rootDirName);
4161                 if (existing) {
4162                     callbacks.forEach(function (_a) {
4163                         var callback = _a.callback, dirName = _a.dirName;
4164                         if (ts.isArray(existing)) {
4165                             existing.forEach(callback);
4166                         }
4167                         else {
4168                             callback(dirName);
4169                         }
4170                     });
4171                 }
4172             });
4173             var elapsed = ts.timestamp() - start;
4174             ts.sysLog("sysLog:: Elapsed:: " + elapsed + "ms:: onTimerToUpdateChildWatches:: " + cacheToUpdateChildWatches.size + " " + timerToUpdateChildWatches);
4175         }
4176         function removeChildWatches(parentWatcher) {
4177             if (!parentWatcher)
4178                 return;
4179             var existingChildWatches = parentWatcher.childWatches;
4180             parentWatcher.childWatches = ts.emptyArray;
4181             for (var _i = 0, existingChildWatches_1 = existingChildWatches; _i < existingChildWatches_1.length; _i++) {
4182                 var childWatcher = existingChildWatches_1[_i];
4183                 childWatcher.close();
4184                 removeChildWatches(cache.get(toCanonicalFilePath(childWatcher.dirName)));
4185             }
4186         }
4187         function updateChildWatches(parentDir, parentDirPath, options) {
4188             var parentWatcher = cache.get(parentDirPath);
4189             if (!parentWatcher)
4190                 return false;
4191             var newChildWatches;
4192             var hasChanges = ts.enumerateInsertsAndDeletes(directoryExists(parentDir) ? ts.mapDefined(getAccessibleSortedChildDirectories(parentDir), function (child) {
4193                 var childFullName = ts.getNormalizedAbsolutePath(child, parentDir);
4194                 return !isIgnoredPath(childFullName, options) && filePathComparer(childFullName, ts.normalizePath(realpath(childFullName))) === 0 ? childFullName : undefined;
4195             }) : ts.emptyArray, parentWatcher.childWatches, function (child, childWatcher) { return filePathComparer(child, childWatcher.dirName); }, createAndAddChildDirectoryWatcher, ts.closeFileWatcher, addChildDirectoryWatcher);
4196             parentWatcher.childWatches = newChildWatches || ts.emptyArray;
4197             return hasChanges;
4198             function createAndAddChildDirectoryWatcher(childName) {
4199                 var result = createDirectoryWatcher(childName, options);
4200                 addChildDirectoryWatcher(result);
4201             }
4202             function addChildDirectoryWatcher(childWatcher) {
4203                 (newChildWatches || (newChildWatches = [])).push(childWatcher);
4204             }
4205         }
4206         function isIgnoredPath(path, options) {
4207             return ts.some(ts.ignoredPaths, function (searchPath) { return isInPath(path, searchPath); }) ||
4208                 isIgnoredByWatchOptions(path, options, useCaseSensitiveFileNames, getCurrentDirectory);
4209         }
4210         function isInPath(path, searchPath) {
4211             if (ts.stringContains(path, searchPath))
4212                 return true;
4213             if (useCaseSensitiveFileNames)
4214                 return false;
4215             return ts.stringContains(toCanonicalFilePath(path), searchPath);
4216         }
4217     }
4218     ts.createDirectoryWatcherSupportingRecursive = createDirectoryWatcherSupportingRecursive;
4219     function createFileWatcherCallback(callback) {
4220         return function (_fileName, eventKind) { return callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", ""); };
4221     }
4222     ts.createFileWatcherCallback = createFileWatcherCallback;
4223     function createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists) {
4224         return function (eventName) {
4225             if (eventName === "rename") {
4226                 callback(fileName, fileExists(fileName) ? FileWatcherEventKind.Created : FileWatcherEventKind.Deleted);
4227             }
4228             else {
4229                 callback(fileName, FileWatcherEventKind.Changed);
4230             }
4231         };
4232     }
4233     function isIgnoredByWatchOptions(pathToCheck, options, useCaseSensitiveFileNames, getCurrentDirectory) {
4234         return ((options === null || options === void 0 ? void 0 : options.excludeDirectories) || (options === null || options === void 0 ? void 0 : options.excludeFiles)) && (ts.matchesExclude(pathToCheck, options === null || options === void 0 ? void 0 : options.excludeFiles, useCaseSensitiveFileNames, getCurrentDirectory()) ||
4235             ts.matchesExclude(pathToCheck, options === null || options === void 0 ? void 0 : options.excludeDirectories, useCaseSensitiveFileNames, getCurrentDirectory()));
4236     }
4237     function createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory) {
4238         return function (eventName, relativeFileName) {
4239             if (eventName === "rename") {
4240                 var fileName = !relativeFileName ? directoryName : ts.normalizePath(ts.combinePaths(directoryName, relativeFileName));
4241                 if (!relativeFileName || !isIgnoredByWatchOptions(fileName, options, useCaseSensitiveFileNames, getCurrentDirectory)) {
4242                     callback(fileName);
4243                 }
4244             }
4245         };
4246     }
4247     function createSystemWatchFunctions(_a) {
4248         var pollingWatchFile = _a.pollingWatchFile, getModifiedTime = _a.getModifiedTime, setTimeout = _a.setTimeout, clearTimeout = _a.clearTimeout, fsWatch = _a.fsWatch, fileExists = _a.fileExists, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, getCurrentDirectory = _a.getCurrentDirectory, fsSupportsRecursiveFsWatch = _a.fsSupportsRecursiveFsWatch, directoryExists = _a.directoryExists, getAccessibleSortedChildDirectories = _a.getAccessibleSortedChildDirectories, realpath = _a.realpath, tscWatchFile = _a.tscWatchFile, useNonPollingWatchers = _a.useNonPollingWatchers, tscWatchDirectory = _a.tscWatchDirectory;
4249         var dynamicPollingWatchFile;
4250         var nonPollingWatchFile;
4251         var hostRecursiveDirectoryWatcher;
4252         return {
4253             watchFile: watchFile,
4254             watchDirectory: watchDirectory
4255         };
4256         function watchFile(fileName, callback, pollingInterval, options) {
4257             options = updateOptionsForWatchFile(options, useNonPollingWatchers);
4258             var watchFileKind = ts.Debug.checkDefined(options.watchFile);
4259             switch (watchFileKind) {
4260                 case ts.WatchFileKind.FixedPollingInterval:
4261                     return pollingWatchFile(fileName, callback, PollingInterval.Low, undefined);
4262                 case ts.WatchFileKind.PriorityPollingInterval:
4263                     return pollingWatchFile(fileName, callback, pollingInterval, undefined);
4264                 case ts.WatchFileKind.DynamicPriorityPolling:
4265                     return ensureDynamicPollingWatchFile()(fileName, callback, pollingInterval, undefined);
4266                 case ts.WatchFileKind.UseFsEvents:
4267                     return fsWatch(fileName, 0, createFsWatchCallbackForFileWatcherCallback(fileName, callback, fileExists), false, pollingInterval, ts.getFallbackOptions(options));
4268                 case ts.WatchFileKind.UseFsEventsOnParentDirectory:
4269                     if (!nonPollingWatchFile) {
4270                         nonPollingWatchFile = createUseFsEventsOnParentDirectoryWatchFile(fsWatch, useCaseSensitiveFileNames);
4271                     }
4272                     return nonPollingWatchFile(fileName, callback, pollingInterval, ts.getFallbackOptions(options));
4273                 default:
4274                     ts.Debug.assertNever(watchFileKind);
4275             }
4276         }
4277         function ensureDynamicPollingWatchFile() {
4278             return dynamicPollingWatchFile ||
4279                 (dynamicPollingWatchFile = createDynamicPriorityPollingWatchFile({ getModifiedTime: getModifiedTime, setTimeout: setTimeout }));
4280         }
4281         function updateOptionsForWatchFile(options, useNonPollingWatchers) {
4282             if (options && options.watchFile !== undefined)
4283                 return options;
4284             switch (tscWatchFile) {
4285                 case "PriorityPollingInterval":
4286                     return { watchFile: ts.WatchFileKind.PriorityPollingInterval };
4287                 case "DynamicPriorityPolling":
4288                     return { watchFile: ts.WatchFileKind.DynamicPriorityPolling };
4289                 case "UseFsEvents":
4290                     return generateWatchFileOptions(ts.WatchFileKind.UseFsEvents, ts.PollingWatchKind.PriorityInterval, options);
4291                 case "UseFsEventsWithFallbackDynamicPolling":
4292                     return generateWatchFileOptions(ts.WatchFileKind.UseFsEvents, ts.PollingWatchKind.DynamicPriority, options);
4293                 case "UseFsEventsOnParentDirectory":
4294                     useNonPollingWatchers = true;
4295                 default:
4296                     return useNonPollingWatchers ?
4297                         generateWatchFileOptions(ts.WatchFileKind.UseFsEventsOnParentDirectory, ts.PollingWatchKind.PriorityInterval, options) :
4298                         { watchFile: ts.WatchFileKind.FixedPollingInterval };
4299             }
4300         }
4301         function generateWatchFileOptions(watchFile, fallbackPolling, options) {
4302             var defaultFallbackPolling = options === null || options === void 0 ? void 0 : options.fallbackPolling;
4303             return {
4304                 watchFile: watchFile,
4305                 fallbackPolling: defaultFallbackPolling === undefined ?
4306                     fallbackPolling :
4307                     defaultFallbackPolling
4308             };
4309         }
4310         function watchDirectory(directoryName, callback, recursive, options) {
4311             if (fsSupportsRecursiveFsWatch) {
4312                 return fsWatch(directoryName, 1, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(options));
4313             }
4314             if (!hostRecursiveDirectoryWatcher) {
4315                 hostRecursiveDirectoryWatcher = createDirectoryWatcherSupportingRecursive({
4316                     useCaseSensitiveFileNames: useCaseSensitiveFileNames,
4317                     getCurrentDirectory: getCurrentDirectory,
4318                     directoryExists: directoryExists,
4319                     getAccessibleSortedChildDirectories: getAccessibleSortedChildDirectories,
4320                     watchDirectory: nonRecursiveWatchDirectory,
4321                     realpath: realpath,
4322                     setTimeout: setTimeout,
4323                     clearTimeout: clearTimeout
4324                 });
4325             }
4326             return hostRecursiveDirectoryWatcher(directoryName, callback, recursive, options);
4327         }
4328         function nonRecursiveWatchDirectory(directoryName, callback, recursive, options) {
4329             ts.Debug.assert(!recursive);
4330             var watchDirectoryOptions = updateOptionsForWatchDirectory(options);
4331             var watchDirectoryKind = ts.Debug.checkDefined(watchDirectoryOptions.watchDirectory);
4332             switch (watchDirectoryKind) {
4333                 case ts.WatchDirectoryKind.FixedPollingInterval:
4334                     return pollingWatchFile(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium, undefined);
4335                 case ts.WatchDirectoryKind.DynamicPriorityPolling:
4336                     return ensureDynamicPollingWatchFile()(directoryName, function () { return callback(directoryName); }, PollingInterval.Medium, undefined);
4337                 case ts.WatchDirectoryKind.UseFsEvents:
4338                     return fsWatch(directoryName, 1, createFsWatchCallbackForDirectoryWatcherCallback(directoryName, callback, options, useCaseSensitiveFileNames, getCurrentDirectory), recursive, PollingInterval.Medium, ts.getFallbackOptions(watchDirectoryOptions));
4339                 default:
4340                     ts.Debug.assertNever(watchDirectoryKind);
4341             }
4342         }
4343         function updateOptionsForWatchDirectory(options) {
4344             if (options && options.watchDirectory !== undefined)
4345                 return options;
4346             switch (tscWatchDirectory) {
4347                 case "RecursiveDirectoryUsingFsWatchFile":
4348                     return { watchDirectory: ts.WatchDirectoryKind.FixedPollingInterval };
4349                 case "RecursiveDirectoryUsingDynamicPriorityPolling":
4350                     return { watchDirectory: ts.WatchDirectoryKind.DynamicPriorityPolling };
4351                 default:
4352                     var defaultFallbackPolling = options === null || options === void 0 ? void 0 : options.fallbackPolling;
4353                     return {
4354                         watchDirectory: ts.WatchDirectoryKind.UseFsEvents,
4355                         fallbackPolling: defaultFallbackPolling !== undefined ?
4356                             defaultFallbackPolling :
4357                             undefined
4358                     };
4359             }
4360         }
4361     }
4362     ts.createSystemWatchFunctions = createSystemWatchFunctions;
4363     function patchWriteFileEnsuringDirectory(sys) {
4364         var originalWriteFile = sys.writeFile;
4365         sys.writeFile = function (path, data, writeBom) {
4366             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); });
4367         };
4368     }
4369     ts.patchWriteFileEnsuringDirectory = patchWriteFileEnsuringDirectory;
4370     function getNodeMajorVersion() {
4371         if (typeof process === "undefined") {
4372             return undefined;
4373         }
4374         var version = process.version;
4375         if (!version) {
4376             return undefined;
4377         }
4378         var dot = version.indexOf(".");
4379         if (dot === -1) {
4380             return undefined;
4381         }
4382         return parseInt(version.substring(1, dot));
4383     }
4384     ts.getNodeMajorVersion = getNodeMajorVersion;
4385     ts.sys = (function () {
4386         var byteOrderMarkIndicator = "\uFEFF";
4387         function getNodeSystem() {
4388             var _a;
4389             var nativePattern = /^native |^\([^)]+\)$|^(internal[\\/]|[a-zA-Z0-9_\s]+(\.js)?$)/;
4390             var _fs = require("fs");
4391             var _path = require("path");
4392             var _os = require("os");
4393             var _crypto;
4394             try {
4395                 _crypto = require("crypto");
4396             }
4397             catch (_b) {
4398                 _crypto = undefined;
4399             }
4400             var activeSession;
4401             var profilePath = "./profile.cpuprofile";
4402             var realpathSync = (_a = _fs.realpathSync.native) !== null && _a !== void 0 ? _a : _fs.realpathSync;
4403             var Buffer = require("buffer").Buffer;
4404             var nodeVersion = getNodeMajorVersion();
4405             var isNode4OrLater = nodeVersion >= 4;
4406             var isLinuxOrMacOs = process.platform === "linux" || process.platform === "darwin";
4407             var platform = _os.platform();
4408             var useCaseSensitiveFileNames = isFileSystemCaseSensitive();
4409             var fsSupportsRecursiveFsWatch = isNode4OrLater && (process.platform === "win32" || process.platform === "darwin");
4410             var getCurrentDirectory = ts.memoize(function () { return process.cwd(); });
4411             var _c = createSystemWatchFunctions({
4412                 pollingWatchFile: createSingleFileWatcherPerName(fsWatchFileWorker, useCaseSensitiveFileNames),
4413                 getModifiedTime: getModifiedTime,
4414                 setTimeout: setTimeout,
4415                 clearTimeout: clearTimeout,
4416                 fsWatch: fsWatch,
4417                 useCaseSensitiveFileNames: useCaseSensitiveFileNames,
4418                 getCurrentDirectory: getCurrentDirectory,
4419                 fileExists: fileExists,
4420                 fsSupportsRecursiveFsWatch: fsSupportsRecursiveFsWatch,
4421                 directoryExists: directoryExists,
4422                 getAccessibleSortedChildDirectories: function (path) { return getAccessibleFileSystemEntries(path).directories; },
4423                 realpath: realpath,
4424                 tscWatchFile: process.env.TSC_WATCHFILE,
4425                 useNonPollingWatchers: process.env.TSC_NONPOLLING_WATCHER,
4426                 tscWatchDirectory: process.env.TSC_WATCHDIRECTORY,
4427             }), watchFile = _c.watchFile, watchDirectory = _c.watchDirectory;
4428             var nodeSystem = {
4429                 args: process.argv.slice(2),
4430                 newLine: _os.EOL,
4431                 useCaseSensitiveFileNames: useCaseSensitiveFileNames,
4432                 write: function (s) {
4433                     process.stdout.write(s);
4434                 },
4435                 writeOutputIsTTY: function () {
4436                     return process.stdout.isTTY;
4437                 },
4438                 readFile: readFile,
4439                 writeFile: writeFile,
4440                 watchFile: watchFile,
4441                 watchDirectory: watchDirectory,
4442                 resolvePath: function (path) { return _path.resolve(path); },
4443                 fileExists: fileExists,
4444                 directoryExists: directoryExists,
4445                 createDirectory: function (directoryName) {
4446                     if (!nodeSystem.directoryExists(directoryName)) {
4447                         try {
4448                             _fs.mkdirSync(directoryName);
4449                         }
4450                         catch (e) {
4451                             if (e.code !== "EEXIST") {
4452                                 throw e;
4453                             }
4454                         }
4455                     }
4456                 },
4457                 getExecutingFilePath: function () {
4458                     return __filename;
4459                 },
4460                 getCurrentDirectory: getCurrentDirectory,
4461                 getDirectories: getDirectories,
4462                 getEnvironmentVariable: function (name) {
4463                     return process.env[name] || "";
4464                 },
4465                 readDirectory: readDirectory,
4466                 getModifiedTime: getModifiedTime,
4467                 setModifiedTime: setModifiedTime,
4468                 deleteFile: deleteFile,
4469                 createHash: _crypto ? createSHA256Hash : generateDjb2Hash,
4470                 createSHA256Hash: _crypto ? createSHA256Hash : undefined,
4471                 getMemoryUsage: function () {
4472                     if (global.gc) {
4473                         global.gc();
4474                     }
4475                     return process.memoryUsage().heapUsed;
4476                 },
4477                 getFileSize: function (path) {
4478                     try {
4479                         var stat = statSync(path);
4480                         if (stat === null || stat === void 0 ? void 0 : stat.isFile()) {
4481                             return stat.size;
4482                         }
4483                     }
4484                     catch (_a) { }
4485                     return 0;
4486                 },
4487                 exit: function (exitCode) {
4488                     disableCPUProfiler(function () { return process.exit(exitCode); });
4489                 },
4490                 enableCPUProfiler: enableCPUProfiler,
4491                 disableCPUProfiler: disableCPUProfiler,
4492                 cpuProfilingEnabled: function () { return !!activeSession || ts.contains(process.execArgv, "--cpu-prof") || ts.contains(process.execArgv, "--prof"); },
4493                 realpath: realpath,
4494                 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); }),
4495                 tryEnableSourceMapsForHost: function () {
4496                     try {
4497                         require("source-map-support").install();
4498                     }
4499                     catch (_a) {
4500                     }
4501                 },
4502                 setTimeout: setTimeout,
4503                 clearTimeout: clearTimeout,
4504                 clearScreen: function () {
4505                     process.stdout.write("\x1Bc");
4506                 },
4507                 setBlocking: function () {
4508                     if (process.stdout && process.stdout._handle && process.stdout._handle.setBlocking) {
4509                         process.stdout._handle.setBlocking(true);
4510                     }
4511                 },
4512                 bufferFrom: bufferFrom,
4513                 base64decode: function (input) { return bufferFrom(input, "base64").toString("utf8"); },
4514                 base64encode: function (input) { return bufferFrom(input).toString("base64"); },
4515                 require: function (baseDir, moduleName) {
4516                     try {
4517                         var modulePath = ts.resolveJSModule(moduleName, baseDir, nodeSystem);
4518                         return { module: require(modulePath), modulePath: modulePath, error: undefined };
4519                     }
4520                     catch (error) {
4521                         return { module: undefined, modulePath: undefined, error: error };
4522                     }
4523                 }
4524             };
4525             return nodeSystem;
4526             function statSync(path) {
4527                 return _fs.statSync(path, { throwIfNoEntry: false });
4528             }
4529             function enableCPUProfiler(path, cb) {
4530                 if (activeSession) {
4531                     cb();
4532                     return false;
4533                 }
4534                 var inspector = require("inspector");
4535                 if (!inspector || !inspector.Session) {
4536                     cb();
4537                     return false;
4538                 }
4539                 var session = new inspector.Session();
4540                 session.connect();
4541                 session.post("Profiler.enable", function () {
4542                     session.post("Profiler.start", function () {
4543                         activeSession = session;
4544                         profilePath = path;
4545                         cb();
4546                     });
4547                 });
4548                 return true;
4549             }
4550             function cleanupPaths(profile) {
4551                 var externalFileCounter = 0;
4552                 var remappedPaths = new ts.Map();
4553                 var normalizedDir = ts.normalizeSlashes(__dirname);
4554                 var fileUrlRoot = "file://" + (ts.getRootLength(normalizedDir) === 1 ? "" : "/") + normalizedDir;
4555                 for (var _i = 0, _a = profile.nodes; _i < _a.length; _i++) {
4556                     var node = _a[_i];
4557                     if (node.callFrame.url) {
4558                         var url = ts.normalizeSlashes(node.callFrame.url);
4559                         if (ts.containsPath(fileUrlRoot, url, useCaseSensitiveFileNames)) {
4560                             node.callFrame.url = ts.getRelativePathToDirectoryOrUrl(fileUrlRoot, url, fileUrlRoot, ts.createGetCanonicalFileName(useCaseSensitiveFileNames), true);
4561                         }
4562                         else if (!nativePattern.test(url)) {
4563                             node.callFrame.url = (remappedPaths.has(url) ? remappedPaths : remappedPaths.set(url, "external" + externalFileCounter + ".js")).get(url);
4564                             externalFileCounter++;
4565                         }
4566                     }
4567                 }
4568                 return profile;
4569             }
4570             function disableCPUProfiler(cb) {
4571                 if (activeSession && activeSession !== "stopping") {
4572                     var s_1 = activeSession;
4573                     activeSession.post("Profiler.stop", function (err, _a) {
4574                         var _b;
4575                         var profile = _a.profile;
4576                         if (!err) {
4577                             try {
4578                                 if ((_b = statSync(profilePath)) === null || _b === void 0 ? void 0 : _b.isDirectory()) {
4579                                     profilePath = _path.join(profilePath, (new Date()).toISOString().replace(/:/g, "-") + "+P" + process.pid + ".cpuprofile");
4580                                 }
4581                             }
4582                             catch (_c) {
4583                             }
4584                             try {
4585                                 _fs.mkdirSync(_path.dirname(profilePath), { recursive: true });
4586                             }
4587                             catch (_d) {
4588                             }
4589                             _fs.writeFileSync(profilePath, JSON.stringify(cleanupPaths(profile)));
4590                         }
4591                         activeSession = undefined;
4592                         s_1.disconnect();
4593                         cb();
4594                     });
4595                     activeSession = "stopping";
4596                     return true;
4597                 }
4598                 else {
4599                     cb();
4600                     return false;
4601                 }
4602             }
4603             function bufferFrom(input, encoding) {
4604                 return Buffer.from && Buffer.from !== Int8Array.from
4605                     ? Buffer.from(input, encoding)
4606                     : new Buffer(input, encoding);
4607             }
4608             function isFileSystemCaseSensitive() {
4609                 if (platform === "win32" || platform === "win64") {
4610                     return false;
4611                 }
4612                 return !fileExists(swapCase(__filename));
4613             }
4614             function swapCase(s) {
4615                 return s.replace(/\w/g, function (ch) {
4616                     var up = ch.toUpperCase();
4617                     return ch === up ? ch.toLowerCase() : up;
4618                 });
4619             }
4620             function fsWatchFileWorker(fileName, callback, pollingInterval) {
4621                 _fs.watchFile(fileName, { persistent: true, interval: pollingInterval }, fileChanged);
4622                 var eventKind;
4623                 return {
4624                     close: function () { return _fs.unwatchFile(fileName, fileChanged); }
4625                 };
4626                 function fileChanged(curr, prev) {
4627                     var isPreviouslyDeleted = +prev.mtime === 0 || eventKind === FileWatcherEventKind.Deleted;
4628                     if (+curr.mtime === 0) {
4629                         if (isPreviouslyDeleted) {
4630                             return;
4631                         }
4632                         eventKind = FileWatcherEventKind.Deleted;
4633                     }
4634                     else if (isPreviouslyDeleted) {
4635                         eventKind = FileWatcherEventKind.Created;
4636                     }
4637                     else if (+curr.mtime === +prev.mtime) {
4638                         return;
4639                     }
4640                     else {
4641                         eventKind = FileWatcherEventKind.Changed;
4642                     }
4643                     callback(fileName, eventKind);
4644                 }
4645             }
4646             function fsWatch(fileOrDirectory, entryKind, callback, recursive, fallbackPollingInterval, fallbackOptions) {
4647                 var options;
4648                 var lastDirectoryPartWithDirectorySeparator;
4649                 var lastDirectoryPart;
4650                 if (isLinuxOrMacOs) {
4651                     lastDirectoryPartWithDirectorySeparator = fileOrDirectory.substr(fileOrDirectory.lastIndexOf(ts.directorySeparator));
4652                     lastDirectoryPart = lastDirectoryPartWithDirectorySeparator.slice(ts.directorySeparator.length);
4653                 }
4654                 var watcher = !fileSystemEntryExists(fileOrDirectory, entryKind) ?
4655                     watchMissingFileSystemEntry() :
4656                     watchPresentFileSystemEntry();
4657                 return {
4658                     close: function () {
4659                         watcher.close();
4660                         watcher = undefined;
4661                     }
4662                 };
4663                 function invokeCallbackAndUpdateWatcher(createWatcher) {
4664                     ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing watcher to " + (createWatcher === watchPresentFileSystemEntry ? "Present" : "Missing") + "FileSystemEntryWatcher");
4665                     callback("rename", "");
4666                     if (watcher) {
4667                         watcher.close();
4668                         watcher = createWatcher();
4669                     }
4670                 }
4671                 function watchPresentFileSystemEntry() {
4672                     if (options === undefined) {
4673                         if (fsSupportsRecursiveFsWatch) {
4674                             options = { persistent: true, recursive: !!recursive };
4675                         }
4676                         else {
4677                             options = { persistent: true };
4678                         }
4679                     }
4680                     try {
4681                         var presentWatcher = _fs.watch(fileOrDirectory, options, isLinuxOrMacOs ?
4682                             callbackChangingToMissingFileSystemEntry :
4683                             callback);
4684                         presentWatcher.on("error", function () { return invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry); });
4685                         return presentWatcher;
4686                     }
4687                     catch (e) {
4688                         return watchPresentFileSystemEntryWithFsWatchFile();
4689                     }
4690                 }
4691                 function callbackChangingToMissingFileSystemEntry(event, relativeName) {
4692                     return event === "rename" &&
4693                         (!relativeName ||
4694                             relativeName === lastDirectoryPart ||
4695                             (relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) !== -1 && relativeName.lastIndexOf(lastDirectoryPartWithDirectorySeparator) === relativeName.length - lastDirectoryPartWithDirectorySeparator.length)) &&
4696                         !fileSystemEntryExists(fileOrDirectory, entryKind) ?
4697                         invokeCallbackAndUpdateWatcher(watchMissingFileSystemEntry) :
4698                         callback(event, relativeName);
4699                 }
4700                 function watchPresentFileSystemEntryWithFsWatchFile() {
4701                     ts.sysLog("sysLog:: " + fileOrDirectory + ":: Changing to fsWatchFile");
4702                     return watchFile(fileOrDirectory, createFileWatcherCallback(callback), fallbackPollingInterval, fallbackOptions);
4703                 }
4704                 function watchMissingFileSystemEntry() {
4705                     return watchFile(fileOrDirectory, function (_fileName, eventKind) {
4706                         if (eventKind === FileWatcherEventKind.Created && fileSystemEntryExists(fileOrDirectory, entryKind)) {
4707                             invokeCallbackAndUpdateWatcher(watchPresentFileSystemEntry);
4708                         }
4709                     }, fallbackPollingInterval, fallbackOptions);
4710                 }
4711             }
4712             function readFileWorker(fileName, _encoding) {
4713                 var buffer;
4714                 try {
4715                     buffer = _fs.readFileSync(fileName);
4716                 }
4717                 catch (e) {
4718                     return undefined;
4719                 }
4720                 var len = buffer.length;
4721                 if (len >= 2 && buffer[0] === 0xFE && buffer[1] === 0xFF) {
4722                     len &= ~1;
4723                     for (var i = 0; i < len; i += 2) {
4724                         var temp = buffer[i];
4725                         buffer[i] = buffer[i + 1];
4726                         buffer[i + 1] = temp;
4727                     }
4728                     return buffer.toString("utf16le", 2);
4729                 }
4730                 if (len >= 2 && buffer[0] === 0xFF && buffer[1] === 0xFE) {
4731                     return buffer.toString("utf16le", 2);
4732                 }
4733                 if (len >= 3 && buffer[0] === 0xEF && buffer[1] === 0xBB && buffer[2] === 0xBF) {
4734                     return buffer.toString("utf8", 3);
4735                 }
4736                 return buffer.toString("utf8");
4737             }
4738             function readFile(fileName, _encoding) {
4739                 ts.perfLogger.logStartReadFile(fileName);
4740                 var file = readFileWorker(fileName, _encoding);
4741                 ts.perfLogger.logStopReadFile();
4742                 return file;
4743             }
4744             function writeFile(fileName, data, writeByteOrderMark) {
4745                 ts.perfLogger.logEvent("WriteFile: " + fileName);
4746                 if (writeByteOrderMark) {
4747                     data = byteOrderMarkIndicator + data;
4748                 }
4749                 var fd;
4750                 try {
4751                     fd = _fs.openSync(fileName, "w");
4752                     _fs.writeSync(fd, data, undefined, "utf8");
4753                 }
4754                 finally {
4755                     if (fd !== undefined) {
4756                         _fs.closeSync(fd);
4757                     }
4758                 }
4759             }
4760             function getAccessibleFileSystemEntries(path) {
4761                 ts.perfLogger.logEvent("ReadDir: " + (path || "."));
4762                 try {
4763                     var entries = _fs.readdirSync(path || ".", { withFileTypes: true });
4764                     var files = [];
4765                     var directories = [];
4766                     for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
4767                         var dirent = entries_1[_i];
4768                         var entry = typeof dirent === "string" ? dirent : dirent.name;
4769                         if (entry === "." || entry === "..") {
4770                             continue;
4771                         }
4772                         var stat = void 0;
4773                         if (typeof dirent === "string" || dirent.isSymbolicLink()) {
4774                             var name = ts.combinePaths(path, entry);
4775                             try {
4776                                 stat = statSync(name);
4777                                 if (!stat) {
4778                                     continue;
4779                                 }
4780                             }
4781                             catch (e) {
4782                                 continue;
4783                             }
4784                         }
4785                         else {
4786                             stat = dirent;
4787                         }
4788                         if (stat.isFile()) {
4789                             files.push(entry);
4790                         }
4791                         else if (stat.isDirectory()) {
4792                             directories.push(entry);
4793                         }
4794                     }
4795                     files.sort();
4796                     directories.sort();
4797                     return { files: files, directories: directories };
4798                 }
4799                 catch (e) {
4800                     return ts.emptyFileSystemEntries;
4801                 }
4802             }
4803             function readDirectory(path, extensions, excludes, includes, depth) {
4804                 return ts.matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, process.cwd(), depth, getAccessibleFileSystemEntries, realpath);
4805             }
4806             function fileSystemEntryExists(path, entryKind) {
4807                 var originalStackTraceLimit = Error.stackTraceLimit;
4808                 Error.stackTraceLimit = 0;
4809                 try {
4810                     var stat = statSync(path);
4811                     if (!stat) {
4812                         return false;
4813                     }
4814                     switch (entryKind) {
4815                         case 0: return stat.isFile();
4816                         case 1: return stat.isDirectory();
4817                         default: return false;
4818                     }
4819                 }
4820                 catch (e) {
4821                     return false;
4822                 }
4823                 finally {
4824                     Error.stackTraceLimit = originalStackTraceLimit;
4825                 }
4826             }
4827             function fileExists(path) {
4828                 return fileSystemEntryExists(path, 0);
4829             }
4830             function directoryExists(path) {
4831                 return fileSystemEntryExists(path, 1);
4832             }
4833             function getDirectories(path) {
4834                 return getAccessibleFileSystemEntries(path).directories.slice();
4835             }
4836             function realpath(path) {
4837                 try {
4838                     return realpathSync(path);
4839                 }
4840                 catch (_a) {
4841                     return path;
4842                 }
4843             }
4844             function getModifiedTime(path) {
4845                 var _a;
4846                 try {
4847                     return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime;
4848                 }
4849                 catch (e) {
4850                     return undefined;
4851                 }
4852             }
4853             function setModifiedTime(path, time) {
4854                 try {
4855                     _fs.utimesSync(path, time, time);
4856                 }
4857                 catch (e) {
4858                     return;
4859                 }
4860             }
4861             function deleteFile(path) {
4862                 try {
4863                     return _fs.unlinkSync(path);
4864                 }
4865                 catch (e) {
4866                     return;
4867                 }
4868             }
4869             function createSHA256Hash(data) {
4870                 var hash = _crypto.createHash("sha256");
4871                 hash.update(data);
4872                 return hash.digest("hex");
4873             }
4874         }
4875         var sys;
4876         if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") {
4877             sys = getNodeSystem();
4878         }
4879         if (sys) {
4880             patchWriteFileEnsuringDirectory(sys);
4881         }
4882         return sys;
4883     })();
4884     if (ts.sys && ts.sys.getEnvironmentVariable) {
4885         setCustomPollingValues(ts.sys);
4886         ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))
4887             ? 1
4888             : 0);
4889     }
4890     if (ts.sys && ts.sys.debugMode) {
4891         ts.Debug.isDebugging = true;
4892     }
4893 })(ts || (ts = {}));
4894 var ts;
4895 (function (ts) {
4896     function diag(code, category, key, message, reportsUnnecessary, elidedInCompatabilityPyramid, reportsDeprecated) {
4897         return { code: code, category: category, key: key, message: message, reportsUnnecessary: reportsUnnecessary, elidedInCompatabilityPyramid: elidedInCompatabilityPyramid, reportsDeprecated: reportsDeprecated };
4898     }
4899     ts.Diagnostics = {
4900         Unterminated_string_literal: diag(1002, ts.DiagnosticCategory.Error, "Unterminated_string_literal_1002", "Unterminated string literal."),
4901         Identifier_expected: diag(1003, ts.DiagnosticCategory.Error, "Identifier_expected_1003", "Identifier expected."),
4902         _0_expected: diag(1005, ts.DiagnosticCategory.Error, "_0_expected_1005", "'{0}' expected."),
4903         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."),
4904         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."),
4905         Trailing_comma_not_allowed: diag(1009, ts.DiagnosticCategory.Error, "Trailing_comma_not_allowed_1009", "Trailing comma not allowed."),
4906         Asterisk_Slash_expected: diag(1010, ts.DiagnosticCategory.Error, "Asterisk_Slash_expected_1010", "'*/' expected."),
4907         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."),
4908         Unexpected_token: diag(1012, ts.DiagnosticCategory.Error, "Unexpected_token_1012", "Unexpected token."),
4909         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."),
4910         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."),
4911         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."),
4912         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."),
4913         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."),
4914         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."),
4915         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."),
4916         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."),
4917         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."),
4918         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."),
4919         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'."),
4920         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."),
4921         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."),
4922         Accessibility_modifier_already_seen: diag(1028, ts.DiagnosticCategory.Error, "Accessibility_modifier_already_seen_1028", "Accessibility modifier already seen."),
4923         _0_modifier_must_precede_1_modifier: diag(1029, ts.DiagnosticCategory.Error, "_0_modifier_must_precede_1_modifier_1029", "'{0}' modifier must precede '{1}' modifier."),
4924         _0_modifier_already_seen: diag(1030, ts.DiagnosticCategory.Error, "_0_modifier_already_seen_1030", "'{0}' modifier already seen."),
4925         _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."),
4926         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."),
4927         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."),
4928         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."),
4929         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."),
4930         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."),
4931         _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."),
4932         _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."),
4933         _0_modifier_cannot_be_used_here: diag(1042, ts.DiagnosticCategory.Error, "_0_modifier_cannot_be_used_here_1042", "'{0}' modifier cannot be used here."),
4934         _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."),
4935         _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."),
4936         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."),
4937         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."),
4938         A_rest_parameter_cannot_be_optional: diag(1047, ts.DiagnosticCategory.Error, "A_rest_parameter_cannot_be_optional_1047", "A rest parameter cannot be optional."),
4939         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."),
4940         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."),
4941         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."),
4942         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."),
4943         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."),
4944         A_get_accessor_cannot_have_parameters: diag(1054, ts.DiagnosticCategory.Error, "A_get_accessor_cannot_have_parameters_1054", "A 'get' accessor cannot have parameters."),
4945         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."),
4946         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."),
4947         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."),
4948         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."),
4949         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."),
4950         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."),
4951         Enum_member_must_have_initializer: diag(1061, ts.DiagnosticCategory.Error, "Enum_member_must_have_initializer_1061", "Enum member must have initializer."),
4952         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."),
4953         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."),
4954         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}>'?"),
4955         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."),
4956         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."),
4957         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."),
4958         _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."),
4959         _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."),
4960         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."),
4961         Invalid_reference_directive_syntax: diag(1084, ts.DiagnosticCategory.Error, "Invalid_reference_directive_syntax_1084", "Invalid 'reference' directive syntax."),
4962         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}'."),
4963         _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."),
4964         _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."),
4965         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."),
4966         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."),
4967         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."),
4968         An_accessor_cannot_have_type_parameters: diag(1094, ts.DiagnosticCategory.Error, "An_accessor_cannot_have_type_parameters_1094", "An accessor cannot have type parameters."),
4969         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."),
4970         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."),
4971         _0_list_cannot_be_empty: diag(1097, ts.DiagnosticCategory.Error, "_0_list_cannot_be_empty_1097", "'{0}' list cannot be empty."),
4972         Type_parameter_list_cannot_be_empty: diag(1098, ts.DiagnosticCategory.Error, "Type_parameter_list_cannot_be_empty_1098", "Type parameter list cannot be empty."),
4973         Type_argument_list_cannot_be_empty: diag(1099, ts.DiagnosticCategory.Error, "Type_argument_list_cannot_be_empty_1099", "Type argument list cannot be empty."),
4974         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."),
4975         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."),
4976         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."),
4977         for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules: diag(1103, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules_1103", "'for await' loops are only allowed within async functions and at the top levels of modules."),
4978         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."),
4979         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."),
4980         Jump_target_cannot_cross_function_boundary: diag(1107, ts.DiagnosticCategory.Error, "Jump_target_cannot_cross_function_boundary_1107", "Jump target cannot cross function boundary."),
4981         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."),
4982         Expression_expected: diag(1109, ts.DiagnosticCategory.Error, "Expression_expected_1109", "Expression expected."),
4983         Type_expected: diag(1110, ts.DiagnosticCategory.Error, "Type_expected_1110", "Type expected."),
4984         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."),
4985         Duplicate_label_0: diag(1114, ts.DiagnosticCategory.Error, "Duplicate_label_0_1114", "Duplicate label '{0}'."),
4986         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."),
4987         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."),
4988         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."),
4989         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."),
4990         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."),
4991         An_export_assignment_cannot_have_modifiers: diag(1120, ts.DiagnosticCategory.Error, "An_export_assignment_cannot_have_modifiers_1120", "An export assignment cannot have modifiers."),
4992         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."),
4993         Variable_declaration_list_cannot_be_empty: diag(1123, ts.DiagnosticCategory.Error, "Variable_declaration_list_cannot_be_empty_1123", "Variable declaration list cannot be empty."),
4994         Digit_expected: diag(1124, ts.DiagnosticCategory.Error, "Digit_expected_1124", "Digit expected."),
4995         Hexadecimal_digit_expected: diag(1125, ts.DiagnosticCategory.Error, "Hexadecimal_digit_expected_1125", "Hexadecimal digit expected."),
4996         Unexpected_end_of_text: diag(1126, ts.DiagnosticCategory.Error, "Unexpected_end_of_text_1126", "Unexpected end of text."),
4997         Invalid_character: diag(1127, ts.DiagnosticCategory.Error, "Invalid_character_1127", "Invalid character."),
4998         Declaration_or_statement_expected: diag(1128, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_1128", "Declaration or statement expected."),
4999         Statement_expected: diag(1129, ts.DiagnosticCategory.Error, "Statement_expected_1129", "Statement expected."),
5000         case_or_default_expected: diag(1130, ts.DiagnosticCategory.Error, "case_or_default_expected_1130", "'case' or 'default' expected."),
5001         Property_or_signature_expected: diag(1131, ts.DiagnosticCategory.Error, "Property_or_signature_expected_1131", "Property or signature expected."),
5002         Enum_member_expected: diag(1132, ts.DiagnosticCategory.Error, "Enum_member_expected_1132", "Enum member expected."),
5003         Variable_declaration_expected: diag(1134, ts.DiagnosticCategory.Error, "Variable_declaration_expected_1134", "Variable declaration expected."),
5004         Argument_expression_expected: diag(1135, ts.DiagnosticCategory.Error, "Argument_expression_expected_1135", "Argument expression expected."),
5005         Property_assignment_expected: diag(1136, ts.DiagnosticCategory.Error, "Property_assignment_expected_1136", "Property assignment expected."),
5006         Expression_or_comma_expected: diag(1137, ts.DiagnosticCategory.Error, "Expression_or_comma_expected_1137", "Expression or comma expected."),
5007         Parameter_declaration_expected: diag(1138, ts.DiagnosticCategory.Error, "Parameter_declaration_expected_1138", "Parameter declaration expected."),
5008         Type_parameter_declaration_expected: diag(1139, ts.DiagnosticCategory.Error, "Type_parameter_declaration_expected_1139", "Type parameter declaration expected."),
5009         Type_argument_expected: diag(1140, ts.DiagnosticCategory.Error, "Type_argument_expected_1140", "Type argument expected."),
5010         String_literal_expected: diag(1141, ts.DiagnosticCategory.Error, "String_literal_expected_1141", "String literal expected."),
5011         Line_break_not_permitted_here: diag(1142, ts.DiagnosticCategory.Error, "Line_break_not_permitted_here_1142", "Line break not permitted here."),
5012         or_expected: diag(1144, ts.DiagnosticCategory.Error, "or_expected_1144", "'{' or ';' expected."),
5013         Declaration_expected: diag(1146, ts.DiagnosticCategory.Error, "Declaration_expected_1146", "Declaration expected."),
5014         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."),
5015         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'."),
5016         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."),
5017         const_declarations_must_be_initialized: diag(1155, ts.DiagnosticCategory.Error, "const_declarations_must_be_initialized_1155", "'const' declarations must be initialized."),
5018         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."),
5019         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."),
5020         Unterminated_template_literal: diag(1160, ts.DiagnosticCategory.Error, "Unterminated_template_literal_1160", "Unterminated template literal."),
5021         Unterminated_regular_expression_literal: diag(1161, ts.DiagnosticCategory.Error, "Unterminated_regular_expression_literal_1161", "Unterminated regular expression literal."),
5022         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."),
5023         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."),
5024         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."),
5025         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."),
5026         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."),
5027         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."),
5028         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."),
5029         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."),
5030         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."),
5031         extends_clause_already_seen: diag(1172, ts.DiagnosticCategory.Error, "extends_clause_already_seen_1172", "'extends' clause already seen."),
5032         extends_clause_must_precede_implements_clause: diag(1173, ts.DiagnosticCategory.Error, "extends_clause_must_precede_implements_clause_1173", "'extends' clause must precede 'implements' clause."),
5033         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."),
5034         implements_clause_already_seen: diag(1175, ts.DiagnosticCategory.Error, "implements_clause_already_seen_1175", "'implements' clause already seen."),
5035         Interface_declaration_cannot_have_implements_clause: diag(1176, ts.DiagnosticCategory.Error, "Interface_declaration_cannot_have_implements_clause_1176", "Interface declaration cannot have 'implements' clause."),
5036         Binary_digit_expected: diag(1177, ts.DiagnosticCategory.Error, "Binary_digit_expected_1177", "Binary digit expected."),
5037         Octal_digit_expected: diag(1178, ts.DiagnosticCategory.Error, "Octal_digit_expected_1178", "Octal digit expected."),
5038         Unexpected_token_expected: diag(1179, ts.DiagnosticCategory.Error, "Unexpected_token_expected_1179", "Unexpected token. '{' expected."),
5039         Property_destructuring_pattern_expected: diag(1180, ts.DiagnosticCategory.Error, "Property_destructuring_pattern_expected_1180", "Property destructuring pattern expected."),
5040         Array_element_destructuring_pattern_expected: diag(1181, ts.DiagnosticCategory.Error, "Array_element_destructuring_pattern_expected_1181", "Array element destructuring pattern expected."),
5041         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."),
5042         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."),
5043         Modifiers_cannot_appear_here: diag(1184, ts.DiagnosticCategory.Error, "Modifiers_cannot_appear_here_1184", "Modifiers cannot appear here."),
5044         Merge_conflict_marker_encountered: diag(1185, ts.DiagnosticCategory.Error, "Merge_conflict_marker_encountered_1185", "Merge conflict marker encountered."),
5045         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."),
5046         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."),
5047         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."),
5048         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."),
5049         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."),
5050         An_import_declaration_cannot_have_modifiers: diag(1191, ts.DiagnosticCategory.Error, "An_import_declaration_cannot_have_modifiers_1191", "An import declaration cannot have modifiers."),
5051         Module_0_has_no_default_export: diag(1192, ts.DiagnosticCategory.Error, "Module_0_has_no_default_export_1192", "Module '{0}' has no default export."),
5052         An_export_declaration_cannot_have_modifiers: diag(1193, ts.DiagnosticCategory.Error, "An_export_declaration_cannot_have_modifiers_1193", "An export declaration cannot have modifiers."),
5053         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."),
5054         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."),
5055         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."),
5056         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."),
5057         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."),
5058         Unterminated_Unicode_escape_sequence: diag(1199, ts.DiagnosticCategory.Error, "Unterminated_Unicode_escape_sequence_1199", "Unterminated Unicode escape sequence."),
5059         Line_terminator_not_permitted_before_arrow: diag(1200, ts.DiagnosticCategory.Error, "Line_terminator_not_permitted_before_arrow_1200", "Line terminator not permitted before arrow."),
5060         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."),
5061         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."),
5062         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'."),
5063         Decorators_are_not_valid_here: diag(1206, ts.DiagnosticCategory.Error, "Decorators_are_not_valid_here_1206", "Decorators are not valid here."),
5064         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."),
5065         _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."),
5066         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."),
5067         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."),
5068         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."),
5069         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."),
5070         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."),
5071         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."),
5072         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."),
5073         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'."),
5074         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."),
5075         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."),
5076         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."),
5077         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."),
5078         _0_tag_already_specified: diag(1223, ts.DiagnosticCategory.Error, "_0_tag_already_specified_1223", "'{0}' tag already specified."),
5079         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."),
5080         Cannot_find_parameter_0: diag(1225, ts.DiagnosticCategory.Error, "Cannot_find_parameter_0_1225", "Cannot find parameter '{0}'."),
5081         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}'."),
5082         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}'."),
5083         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."),
5084         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."),
5085         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."),
5086         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."),
5087         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."),
5088         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."),
5089         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."),
5090         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."),
5091         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'."),
5092         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'."),
5093         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."),
5094         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."),
5095         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."),
5096         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."),
5097         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."),
5098         _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."),
5099         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."),
5100         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."),
5101         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."),
5102         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."),
5103         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."),
5104         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."),
5105         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'."),
5106         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."),
5107         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."),
5108         _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."),
5109         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."),
5110         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."),
5111         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."),
5112         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"),
5113         Keywords_cannot_contain_escape_characters: diag(1260, ts.DiagnosticCategory.Error, "Keywords_cannot_contain_escape_characters_1260", "Keywords cannot contain escape characters."),
5114         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."),
5115         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."),
5116         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."),
5117         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."),
5118         A_rest_element_cannot_follow_another_rest_element: diag(1265, ts.DiagnosticCategory.Error, "A_rest_element_cannot_follow_another_rest_element_1265", "A rest element cannot follow another rest element."),
5119         An_optional_element_cannot_follow_a_rest_element: diag(1266, ts.DiagnosticCategory.Error, "An_optional_element_cannot_follow_a_rest_element_1266", "An optional element cannot follow a rest element."),
5120         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."),
5121         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."),
5122         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."),
5123         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."),
5124         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."),
5125         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."),
5126         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."),
5127         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."),
5128         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."),
5129         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."),
5130         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."),
5131         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."),
5132         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."),
5133         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'."),
5134         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."),
5135         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."),
5136         Dynamic_import_cannot_have_type_arguments: diag(1326, ts.DiagnosticCategory.Error, "Dynamic_import_cannot_have_type_arguments_1326", "Dynamic import cannot have type arguments."),
5137         String_literal_with_double_quotes_expected: diag(1327, ts.DiagnosticCategory.Error, "String_literal_with_double_quotes_expected_1327", "String literal with double quotes expected."),
5138         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."),
5139         _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}()'?"),
5140         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'."),
5141         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'."),
5142         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'."),
5143         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."),
5144         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."),
5145         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."),
5146         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."),
5147         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."),
5148         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."),
5149         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."),
5150         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}')'?"),
5151         Type_arguments_cannot_be_used_here: diag(1342, ts.DiagnosticCategory.Error, "Type_arguments_cannot_be_used_here_1342", "Type arguments cannot be used here."),
5152         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'."),
5153         A_label_is_not_allowed_here: diag(1344, ts.DiagnosticCategory.Error, "A_label_is_not_allowed_here_1344", "'A label is not allowed here."),
5154         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."),
5155         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."),
5156         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."),
5157         Non_simple_parameter_declared_here: diag(1348, ts.DiagnosticCategory.Error, "Non_simple_parameter_declared_here_1348", "Non-simple parameter declared here."),
5158         use_strict_directive_used_here: diag(1349, ts.DiagnosticCategory.Error, "use_strict_directive_used_here_1349", "'use strict' directive used here."),
5159         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."),
5160         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."),
5161         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."),
5162         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."),
5163         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."),
5164         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."),
5165         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'?"),
5166         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 '}'."),
5167         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."),
5168         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."),
5169         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?"),
5170         _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'."),
5171         _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'."),
5172         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."),
5173         Convert_to_type_only_export: diag(1364, ts.DiagnosticCategory.Message, "Convert_to_type_only_export_1364", "Convert to type-only export"),
5174         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"),
5175         Split_into_two_separate_import_declarations: diag(1366, ts.DiagnosticCategory.Message, "Split_into_two_separate_import_declarations_1366", "Split into two separate import declarations"),
5176         Split_all_invalid_type_only_imports: diag(1367, ts.DiagnosticCategory.Message, "Split_all_invalid_type_only_imports_1367", "Split all invalid type-only imports"),
5177         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"),
5178         Did_you_mean_0: diag(1369, ts.DiagnosticCategory.Message, "Did_you_mean_0_1369", "Did you mean '{0}'?"),
5179         This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set_to_error: diag(1371, ts.DiagnosticCategory.Error, "This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set__1371", "This import is never used as a value and must use 'import type' because 'importsNotUsedAsValues' is set to 'error'."),
5180         Convert_to_type_only_import: diag(1373, ts.DiagnosticCategory.Message, "Convert_to_type_only_import_1373", "Convert to type-only import"),
5181         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"),
5182         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."),
5183         _0_was_imported_here: diag(1376, ts.DiagnosticCategory.Message, "_0_was_imported_here_1376", "'{0}' was imported here."),
5184         _0_was_exported_here: diag(1377, ts.DiagnosticCategory.Message, "_0_was_exported_here_1377", "'{0}' was exported here."),
5185         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."),
5186         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'."),
5187         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'."),
5188         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;`?"),
5189         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;`?"),
5190         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'."),
5191         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."),
5192         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."),
5193         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."),
5194         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."),
5195         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."),
5196         _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."),
5197         Provides_a_root_package_name_when_using_outFile_with_declarations: diag(1390, ts.DiagnosticCategory.Message, "Provides_a_root_package_name_when_using_outFile_with_declarations_1390", "Provides a root package name when using outFile with declarations."),
5198         The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_declaration_emit: diag(1391, ts.DiagnosticCategory.Error, "The_bundledPackageName_option_must_be_provided_when_using_outFile_and_node_module_resolution_with_de_1391", "The `bundledPackageName` option must be provided when using outFile and node module resolution with declaration emit."),
5199         An_import_alias_cannot_use_import_type: diag(1392, ts.DiagnosticCategory.Error, "An_import_alias_cannot_use_import_type_1392", "An import alias cannot use 'import type'"),
5200         Imported_via_0_from_file_1: diag(1393, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_1393", "Imported via {0} from file '{1}'"),
5201         Imported_via_0_from_file_1_with_packageId_2: diag(1394, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_with_packageId_2_1394", "Imported via {0} from file '{1}' with packageId '{2}'"),
5202         Imported_via_0_from_file_1_to_import_importHelpers_as_specified_in_compilerOptions: diag(1395, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_to_import_importHelpers_as_specified_in_compilerOptions_1395", "Imported via {0} from file '{1}' to import 'importHelpers' as specified in compilerOptions"),
5203         Imported_via_0_from_file_1_with_packageId_2_to_import_importHelpers_as_specified_in_compilerOptions: diag(1396, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_with_packageId_2_to_import_importHelpers_as_specified_in_compilerOptions_1396", "Imported via {0} from file '{1}' with packageId '{2}' to import 'importHelpers' as specified in compilerOptions"),
5204         Imported_via_0_from_file_1_to_import_jsx_and_jsxs_factory_functions: diag(1397, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_to_import_jsx_and_jsxs_factory_functions_1397", "Imported via {0} from file '{1}' to import 'jsx' and 'jsxs' factory functions"),
5205         Imported_via_0_from_file_1_with_packageId_2_to_import_jsx_and_jsxs_factory_functions: diag(1398, ts.DiagnosticCategory.Message, "Imported_via_0_from_file_1_with_packageId_2_to_import_jsx_and_jsxs_factory_functions_1398", "Imported via {0} from file '{1}' with packageId '{2}' to import 'jsx' and 'jsxs' factory functions"),
5206         File_is_included_via_import_here: diag(1399, ts.DiagnosticCategory.Message, "File_is_included_via_import_here_1399", "File is included via import here."),
5207         Referenced_via_0_from_file_1: diag(1400, ts.DiagnosticCategory.Message, "Referenced_via_0_from_file_1_1400", "Referenced via '{0}' from file '{1}'"),
5208         File_is_included_via_reference_here: diag(1401, ts.DiagnosticCategory.Message, "File_is_included_via_reference_here_1401", "File is included via reference here."),
5209         Type_library_referenced_via_0_from_file_1: diag(1402, ts.DiagnosticCategory.Message, "Type_library_referenced_via_0_from_file_1_1402", "Type library referenced via '{0}' from file '{1}'"),
5210         Type_library_referenced_via_0_from_file_1_with_packageId_2: diag(1403, ts.DiagnosticCategory.Message, "Type_library_referenced_via_0_from_file_1_with_packageId_2_1403", "Type library referenced via '{0}' from file '{1}' with packageId '{2}'"),
5211         File_is_included_via_type_library_reference_here: diag(1404, ts.DiagnosticCategory.Message, "File_is_included_via_type_library_reference_here_1404", "File is included via type library reference here."),
5212         Library_referenced_via_0_from_file_1: diag(1405, ts.DiagnosticCategory.Message, "Library_referenced_via_0_from_file_1_1405", "Library referenced via '{0}' from file '{1}'"),
5213         File_is_included_via_library_reference_here: diag(1406, ts.DiagnosticCategory.Message, "File_is_included_via_library_reference_here_1406", "File is included via library reference here."),
5214         Matched_by_include_pattern_0_in_1: diag(1407, ts.DiagnosticCategory.Message, "Matched_by_include_pattern_0_in_1_1407", "Matched by include pattern '{0}' in '{1}'"),
5215         File_is_matched_by_include_pattern_specified_here: diag(1408, ts.DiagnosticCategory.Message, "File_is_matched_by_include_pattern_specified_here_1408", "File is matched by include pattern specified here."),
5216         Part_of_files_list_in_tsconfig_json: diag(1409, ts.DiagnosticCategory.Message, "Part_of_files_list_in_tsconfig_json_1409", "Part of 'files' list in tsconfig.json"),
5217         File_is_matched_by_files_list_specified_here: diag(1410, ts.DiagnosticCategory.Message, "File_is_matched_by_files_list_specified_here_1410", "File is matched by 'files' list specified here."),
5218         Output_from_referenced_project_0_included_because_1_specified: diag(1411, ts.DiagnosticCategory.Message, "Output_from_referenced_project_0_included_because_1_specified_1411", "Output from referenced project '{0}' included because '{1}' specified"),
5219         Output_from_referenced_project_0_included_because_module_is_specified_as_none: diag(1412, ts.DiagnosticCategory.Message, "Output_from_referenced_project_0_included_because_module_is_specified_as_none_1412", "Output from referenced project '{0}' included because '--module' is specified as 'none'"),
5220         File_is_output_from_referenced_project_specified_here: diag(1413, ts.DiagnosticCategory.Message, "File_is_output_from_referenced_project_specified_here_1413", "File is output from referenced project specified here."),
5221         Source_from_referenced_project_0_included_because_1_specified: diag(1414, ts.DiagnosticCategory.Message, "Source_from_referenced_project_0_included_because_1_specified_1414", "Source from referenced project '{0}' included because '{1}' specified"),
5222         Source_from_referenced_project_0_included_because_module_is_specified_as_none: diag(1415, ts.DiagnosticCategory.Message, "Source_from_referenced_project_0_included_because_module_is_specified_as_none_1415", "Source from referenced project '{0}' included because '--module' is specified as 'none'"),
5223         File_is_source_from_referenced_project_specified_here: diag(1416, ts.DiagnosticCategory.Message, "File_is_source_from_referenced_project_specified_here_1416", "File is source from referenced project specified here."),
5224         Entry_point_of_type_library_0_specified_in_compilerOptions: diag(1417, ts.DiagnosticCategory.Message, "Entry_point_of_type_library_0_specified_in_compilerOptions_1417", "Entry point of type library '{0}' specified in compilerOptions"),
5225         Entry_point_of_type_library_0_specified_in_compilerOptions_with_packageId_1: diag(1418, ts.DiagnosticCategory.Message, "Entry_point_of_type_library_0_specified_in_compilerOptions_with_packageId_1_1418", "Entry point of type library '{0}' specified in compilerOptions with packageId '{1}'"),
5226         File_is_entry_point_of_type_library_specified_here: diag(1419, ts.DiagnosticCategory.Message, "File_is_entry_point_of_type_library_specified_here_1419", "File is entry point of type library specified here."),
5227         Entry_point_for_implicit_type_library_0: diag(1420, ts.DiagnosticCategory.Message, "Entry_point_for_implicit_type_library_0_1420", "Entry point for implicit type library '{0}'"),
5228         Entry_point_for_implicit_type_library_0_with_packageId_1: diag(1421, ts.DiagnosticCategory.Message, "Entry_point_for_implicit_type_library_0_with_packageId_1_1421", "Entry point for implicit type library '{0}' with packageId '{1}'"),
5229         Library_0_specified_in_compilerOptions: diag(1422, ts.DiagnosticCategory.Message, "Library_0_specified_in_compilerOptions_1422", "Library '{0}' specified in compilerOptions"),
5230         File_is_library_specified_here: diag(1423, ts.DiagnosticCategory.Message, "File_is_library_specified_here_1423", "File is library specified here."),
5231         Default_library: diag(1424, ts.DiagnosticCategory.Message, "Default_library_1424", "Default library"),
5232         Default_library_for_target_0: diag(1425, ts.DiagnosticCategory.Message, "Default_library_for_target_0_1425", "Default library for target '{0}'"),
5233         File_is_default_library_for_target_specified_here: diag(1426, ts.DiagnosticCategory.Message, "File_is_default_library_for_target_specified_here_1426", "File is default library for target specified here."),
5234         Root_file_specified_for_compilation: diag(1427, ts.DiagnosticCategory.Message, "Root_file_specified_for_compilation_1427", "Root file specified for compilation"),
5235         File_is_output_of_project_reference_source_0: diag(1428, ts.DiagnosticCategory.Message, "File_is_output_of_project_reference_source_0_1428", "File is output of project reference source '{0}'"),
5236         File_redirects_to_file_0: diag(1429, ts.DiagnosticCategory.Message, "File_redirects_to_file_0_1429", "File redirects to file '{0}'"),
5237         The_file_is_in_the_program_because_Colon: diag(1430, ts.DiagnosticCategory.Message, "The_file_is_in_the_program_because_Colon_1430", "The file is in the program because:"),
5238         for_await_loops_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(1431, ts.DiagnosticCategory.Error, "for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_1431", "'for await' loops 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."),
5239         Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher: diag(1432, ts.DiagnosticCategory.Error, "Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_1432", "Top-level 'for await' loops are only allowed when the 'module' option is set to 'esnext' or 'system', and the 'target' option is set to 'es2017' or higher."),
5240         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."),
5241         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."),
5242         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),
5243         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),
5244         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),
5245         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),
5246         Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
5247         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."),
5248         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."),
5249         Circular_definition_of_import_alias_0: diag(2303, ts.DiagnosticCategory.Error, "Circular_definition_of_import_alias_0_2303", "Circular definition of import alias '{0}'."),
5250         Cannot_find_name_0: diag(2304, ts.DiagnosticCategory.Error, "Cannot_find_name_0_2304", "Cannot find name '{0}'."),
5251         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}'."),
5252         File_0_is_not_a_module: diag(2306, ts.DiagnosticCategory.Error, "File_0_is_not_a_module_2306", "File '{0}' is not a module."),
5253         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."),
5254         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."),
5255         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."),
5256         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."),
5257         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."),
5258         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."),
5259         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."),
5260         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)."),
5261         Type_0_is_not_generic: diag(2315, ts.DiagnosticCategory.Error, "Type_0_is_not_generic_2315", "Type '{0}' is not generic."),
5262         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."),
5263         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)."),
5264         Cannot_find_global_type_0: diag(2318, ts.DiagnosticCategory.Error, "Cannot_find_global_type_0_2318", "Cannot find global type '{0}'."),
5265         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."),
5266         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}'."),
5267         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}'."),
5268         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}'."),
5269         Cannot_redeclare_exported_variable_0: diag(2323, ts.DiagnosticCategory.Error, "Cannot_redeclare_exported_variable_0_2323", "Cannot redeclare exported variable '{0}'."),
5270         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}'."),
5271         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}'."),
5272         Types_of_property_0_are_incompatible: diag(2326, ts.DiagnosticCategory.Error, "Types_of_property_0_are_incompatible_2326", "Types of property '{0}' are incompatible."),
5273         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}'."),
5274         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."),
5275         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}'."),
5276         Index_signatures_are_incompatible: diag(2330, ts.DiagnosticCategory.Error, "Index_signatures_are_incompatible_2330", "Index signatures are incompatible."),
5277         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."),
5278         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."),
5279         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."),
5280         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."),
5281         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."),
5282         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."),
5283         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."),
5284         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."),
5285         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}'."),
5286         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."),
5287         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}'."),
5288         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'."),
5289         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}'."),
5290         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}'."),
5291         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}'."),
5292         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."),
5293         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."),
5294         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'?"),
5295         This_expression_is_not_callable: diag(2349, ts.DiagnosticCategory.Error, "This_expression_is_not_callable_2349", "This expression is not callable."),
5296         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."),
5297         This_expression_is_not_constructable: diag(2351, ts.DiagnosticCategory.Error, "This_expression_is_not_constructable_2351", "This expression is not constructable."),
5298         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."),
5299         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}'."),
5300         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."),
5301         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."),
5302         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."),
5303         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."),
5304         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."),
5305         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."),
5306         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'."),
5307         The_right_hand_side_of_an_in_expression_must_not_be_a_primitive: diag(2361, ts.DiagnosticCategory.Error, "The_right_hand_side_of_an_in_expression_must_not_be_a_primitive_2361", "The right-hand side of an 'in' expression must not be a primitive."),
5308         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."),
5309         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."),
5310         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."),
5311         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}'."),
5312         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'."),
5313         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."),
5314         Type_parameter_name_cannot_be_0: diag(2368, ts.DiagnosticCategory.Error, "Type_parameter_name_cannot_be_0_2368", "Type parameter name cannot be '{0}'."),
5315         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."),
5316         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."),
5317         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."),
5318         Parameter_0_cannot_reference_itself: diag(2372, ts.DiagnosticCategory.Error, "Parameter_0_cannot_reference_itself_2372", "Parameter '{0}' cannot reference itself."),
5319         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."),
5320         Duplicate_string_index_signature: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_string_index_signature_2374", "Duplicate string index signature."),
5321         Duplicate_number_index_signature: diag(2375, ts.DiagnosticCategory.Error, "Duplicate_number_index_signature_2375", "Duplicate number index signature."),
5322         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."),
5323         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."),
5324         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."),
5325         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."),
5326         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."),
5327         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."),
5328         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."),
5329         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."),
5330         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."),
5331         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."),
5332         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."),
5333         Function_overload_must_be_static: diag(2387, ts.DiagnosticCategory.Error, "Function_overload_must_be_static_2387", "Function overload must be static."),
5334         Function_overload_must_not_be_static: diag(2388, ts.DiagnosticCategory.Error, "Function_overload_must_not_be_static_2388", "Function overload must not be static."),
5335         Function_implementation_name_must_be_0: diag(2389, ts.DiagnosticCategory.Error, "Function_implementation_name_must_be_0_2389", "Function implementation name must be '{0}'."),
5336         Constructor_implementation_is_missing: diag(2390, ts.DiagnosticCategory.Error, "Constructor_implementation_is_missing_2390", "Constructor implementation is missing."),
5337         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."),
5338         Multiple_constructor_implementations_are_not_allowed: diag(2392, ts.DiagnosticCategory.Error, "Multiple_constructor_implementations_are_not_allowed_2392", "Multiple constructor implementations are not allowed."),
5339         Duplicate_function_implementation: diag(2393, ts.DiagnosticCategory.Error, "Duplicate_function_implementation_2393", "Duplicate function implementation."),
5340         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."),
5341         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."),
5342         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."),
5343         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}'."),
5344         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."),
5345         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."),
5346         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."),
5347         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."),
5348         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."),
5349         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}'."),
5350         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."),
5351         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'."),
5352         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."),
5353         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}'."),
5354         Setters_cannot_return_a_value: diag(2408, ts.DiagnosticCategory.Error, "Setters_cannot_return_a_value_2408", "Setters cannot return a value."),
5355         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."),
5356         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'."),
5357         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}'."),
5358         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}'."),
5359         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}'."),
5360         Class_name_cannot_be_0: diag(2414, ts.DiagnosticCategory.Error, "Class_name_cannot_be_0_2414", "Class name cannot be '{0}'."),
5361         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}'."),
5362         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}'."),
5363         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}'."),
5364         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}'."),
5365         Types_of_construct_signatures_are_incompatible: diag(2419, ts.DiagnosticCategory.Error, "Types_of_construct_signatures_are_incompatible_2419", "Types of construct signatures are incompatible."),
5366         Class_0_incorrectly_implements_interface_1: diag(2420, ts.DiagnosticCategory.Error, "Class_0_incorrectly_implements_interface_1_2420", "Class '{0}' incorrectly implements interface '{1}'."),
5367         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."),
5368         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."),
5369         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."),
5370         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."),
5371         Interface_name_cannot_be_0: diag(2427, ts.DiagnosticCategory.Error, "Interface_name_cannot_be_0_2427", "Interface name cannot be '{0}'."),
5372         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."),
5373         Interface_0_incorrectly_extends_interface_1: diag(2430, ts.DiagnosticCategory.Error, "Interface_0_incorrectly_extends_interface_1_2430", "Interface '{0}' incorrectly extends interface '{1}'."),
5374         Enum_name_cannot_be_0: diag(2431, ts.DiagnosticCategory.Error, "Enum_name_cannot_be_0_2431", "Enum name cannot be '{0}'."),
5375         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."),
5376         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."),
5377         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."),
5378         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."),
5379         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."),
5380         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."),
5381         Import_name_cannot_be_0: diag(2438, ts.DiagnosticCategory.Error, "Import_name_cannot_be_0_2438", "Import name cannot be '{0}'."),
5382         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."),
5383         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}'."),
5384         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."),
5385         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}'."),
5386         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}'."),
5387         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}'."),
5388         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."),
5389         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}'."),
5390         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."),
5391         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."),
5392         Class_0_used_before_its_declaration: diag(2449, ts.DiagnosticCategory.Error, "Class_0_used_before_its_declaration_2449", "Class '{0}' used before its declaration."),
5393         Enum_0_used_before_its_declaration: diag(2450, ts.DiagnosticCategory.Error, "Enum_0_used_before_its_declaration_2450", "Enum '{0}' used before its declaration."),
5394         Cannot_redeclare_block_scoped_variable_0: diag(2451, ts.DiagnosticCategory.Error, "Cannot_redeclare_block_scoped_variable_0_2451", "Cannot redeclare block-scoped variable '{0}'."),
5395         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."),
5396         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."),
5397         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."),
5398         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}'."),
5399         Type_alias_0_circularly_references_itself: diag(2456, ts.DiagnosticCategory.Error, "Type_alias_0_circularly_references_itself_2456", "Type alias '{0}' circularly references itself."),
5400         Type_alias_name_cannot_be_0: diag(2457, ts.DiagnosticCategory.Error, "Type_alias_name_cannot_be_0_2457", "Type alias name cannot be '{0}'."),
5401         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."),
5402         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."),
5403         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}'."),
5404         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."),
5405         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."),
5406         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."),
5407         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'."),
5408         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."),
5409         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."),
5410         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."),
5411         Cannot_find_global_value_0: diag(2468, ts.DiagnosticCategory.Error, "Cannot_find_global_value_0_2468", "Cannot find global value '{0}'."),
5412         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'."),
5413         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."),
5414         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'."),
5415         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."),
5416         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."),
5417         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."),
5418         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."),
5419         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."),
5420         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."),
5421         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'."),
5422         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}'."),
5423         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."),
5424         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}'."),
5425         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."),
5426         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}'."),
5427         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."),
5428         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."),
5429         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."),
5430         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."),
5431         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."),
5432         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."),
5433         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}'."),
5434         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."),
5435         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."),
5436         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."),
5437         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."),
5438         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 *'."),
5439         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."),
5440         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."),
5441         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."),
5442         _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."),
5443         Cannot_find_namespace_0: diag(2503, ts.DiagnosticCategory.Error, "Cannot_find_namespace_0_2503", "Cannot find namespace '{0}'."),
5444         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."),
5445         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."),
5446         _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."),
5447         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."),
5448         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."),
5449         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."),
5450         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."),
5451         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."),
5452         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."),
5453         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."),
5454         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."),
5455         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}'."),
5456         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."),
5457         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."),
5458         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."),
5459         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."),
5460         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."),
5461         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."),
5462         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."),
5463         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."),
5464         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."),
5465         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."),
5466         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."),
5467         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."),
5468         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."),
5469         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."),
5470         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."),
5471         Object_is_possibly_null: diag(2531, ts.DiagnosticCategory.Error, "Object_is_possibly_null_2531", "Object is possibly 'null'."),
5472         Object_is_possibly_undefined: diag(2532, ts.DiagnosticCategory.Error, "Object_is_possibly_undefined_2532", "Object is possibly 'undefined'."),
5473         Object_is_possibly_null_or_undefined: diag(2533, ts.DiagnosticCategory.Error, "Object_is_possibly_null_or_undefined_2533", "Object is possibly 'null' or 'undefined'."),
5474         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."),
5475         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."),
5476         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}'."),
5477         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}'."),
5478         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."),
5479         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."),
5480         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."),
5481         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."),
5482         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."),
5483         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."),
5484         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."),
5485         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[]'."),
5486         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."),
5487         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."),
5488         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."),
5489         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."),
5490         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}'?"),
5491         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}'?"),
5492         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."),
5493         Expected_0_arguments_but_got_1: diag(2554, ts.DiagnosticCategory.Error, "Expected_0_arguments_but_got_1_2554", "Expected {0} arguments, but got {1}."),
5494         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}."),
5495         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."),
5496         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."),
5497         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}."),
5498         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}'."),
5499         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?"),
5500         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}'?"),
5501         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."),
5502         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."),
5503         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."),
5504         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."),
5505         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."),
5506         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."),
5507         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."),
5508         Object_is_of_type_unknown: diag(2571, ts.DiagnosticCategory.Error, "Object_is_of_type_unknown_2571", "Object is of type 'unknown'."),
5509         Rest_signatures_are_incompatible: diag(2572, ts.DiagnosticCategory.Error, "Rest_signatures_are_incompatible_2572", "Rest signatures are incompatible."),
5510         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."),
5511         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."),
5512         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."),
5513         Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead: diag(2576, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead_2576", "Property '{0}' does not exist on type '{1}'. Did you mean to access the static member '{2}' instead?"),
5514         Return_type_annotation_circularly_references_itself: diag(2577, ts.DiagnosticCategory.Error, "Return_type_annotation_circularly_references_itself_2577", "Return type annotation circularly references itself."),
5515         Unused_ts_expect_error_directive: diag(2578, ts.DiagnosticCategory.Error, "Unused_ts_expect_error_directive_2578", "Unused '@ts-expect-error' directive."),
5516         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`."),
5517         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`."),
5518         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`."),
5519         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."),
5520         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'."),
5521         _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."),
5522         Enum_type_0_circularly_references_itself: diag(2586, ts.DiagnosticCategory.Error, "Enum_type_0_circularly_references_itself_2586", "Enum type '{0}' circularly references itself."),
5523         JSDoc_type_0_circularly_references_itself: diag(2587, ts.DiagnosticCategory.Error, "JSDoc_type_0_circularly_references_itself_2587", "JSDoc type '{0}' circularly references itself."),
5524         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."),
5525         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."),
5526         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."),
5527         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."),
5528         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."),
5529         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."),
5530         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."),
5531         _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."),
5532         _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."),
5533         _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."),
5534         _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."),
5535         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."),
5536         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."),
5537         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."),
5538         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}'."),
5539         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."),
5540         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."),
5541         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."),
5542         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."),
5543         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."),
5544         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."),
5545         _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."),
5546         _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."),
5547         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."),
5548         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?"),
5549         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?"),
5550         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}'."),
5551         _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."),
5552         _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."),
5553         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}."),
5554         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}."),
5555         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."),
5556         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."),
5557         Source_provides_no_match_for_required_element_at_position_0_in_target: diag(2623, ts.DiagnosticCategory.Error, "Source_provides_no_match_for_required_element_at_position_0_in_target_2623", "Source provides no match for required element at position {0} in target."),
5558         Source_provides_no_match_for_variadic_element_at_position_0_in_target: diag(2624, ts.DiagnosticCategory.Error, "Source_provides_no_match_for_variadic_element_at_position_0_in_target_2624", "Source provides no match for variadic element at position {0} in target."),
5559         Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target: diag(2625, ts.DiagnosticCategory.Error, "Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target_2625", "Variadic element at position {0} in source does not match element at position {1} in target."),
5560         Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target: diag(2626, ts.DiagnosticCategory.Error, "Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target_2626", "Type at position {0} in source is not compatible with type at position {1} in target."),
5561         Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target: diag(2627, ts.DiagnosticCategory.Error, "Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target_2627", "Type at positions {0} through {1} in source is not compatible with type at position {2} in target."),
5562         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."),
5563         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."),
5564         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."),
5565         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}'."),
5566         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."),
5567         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."),
5568         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."),
5569         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}'."),
5570         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."),
5571         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."),
5572         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."),
5573         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}'?"),
5574         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}'?"),
5575         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."),
5576         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."),
5577         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."),
5578         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."),
5579         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."),
5580         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."),
5581         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."),
5582         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."),
5583         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."),
5584         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."),
5585         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."),
5586         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."),
5587         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."),
5588         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."),
5589         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}'."),
5590         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'."),
5591         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."),
5592         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."),
5593         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."),
5594         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."),
5595         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}'."),
5596         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."),
5597         _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."),
5598         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."),
5599         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}'."),
5600         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'?"),
5601         _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}'?"),
5602         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."),
5603         _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."),
5604         _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."),
5605         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}'."),
5606         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),
5607         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?"),
5608         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."),
5609         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."),
5610         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}'."),
5611         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."),
5612         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."),
5613         _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."),
5614         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."),
5615         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."),
5616         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."),
5617         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."),
5618         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."),
5619         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."),
5620         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."),
5621         _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."),
5622         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."),
5623         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."),
5624         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}\"]'?"),
5625         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."),
5626         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."),
5627         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."),
5628         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}'."),
5629         Duplicate_property_0: diag(2718, ts.DiagnosticCategory.Error, "Duplicate_property_0_2718", "Duplicate property '{0}'."),
5630         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."),
5631         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?"),
5632         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'."),
5633         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'."),
5634         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'."),
5635         _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}'?"),
5636         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}."),
5637         Cannot_find_lib_definition_for_0: diag(2726, ts.DiagnosticCategory.Error, "Cannot_find_lib_definition_for_0_2726", "Cannot find lib definition for '{0}'."),
5638         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}'?"),
5639         _0_is_declared_here: diag(2728, ts.DiagnosticCategory.Message, "_0_is_declared_here_2728", "'{0}' is declared here."),
5640         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."),
5641         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."),
5642         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(...)'."),
5643         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."),
5644         Property_0_was_also_declared_here: diag(2733, ts.DiagnosticCategory.Error, "Property_0_was_also_declared_here_2733", "Property '{0}' was also declared here."),
5645         Are_you_missing_a_semicolon: diag(2734, ts.DiagnosticCategory.Error, "Are_you_missing_a_semicolon_2734", "Are you missing a semicolon?"),
5646         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}'?"),
5647         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}'."),
5648         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."),
5649         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."),
5650         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}"),
5651         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."),
5652         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}'."),
5653         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."),
5654         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."),
5655         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."),
5656         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."),
5657         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."),
5658         _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}'."),
5659         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."),
5660         _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}'?"),
5661         The_implementation_signature_is_declared_here: diag(2750, ts.DiagnosticCategory.Error, "The_implementation_signature_is_declared_here_2750", "The implementation signature is declared here."),
5662         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."),
5663         The_first_export_default_is_here: diag(2752, ts.DiagnosticCategory.Error, "The_first_export_default_is_here_2752", "The first export default is here."),
5664         Another_export_default_is_here: diag(2753, ts.DiagnosticCategory.Error, "Another_export_default_is_here_2753", "Another export default is here."),
5665         super_may_not_use_type_arguments: diag(2754, ts.DiagnosticCategory.Error, "super_may_not_use_type_arguments_2754", "'super' may not use type arguments."),
5666         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."),
5667         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."),
5668         Type_0_has_no_call_signatures: diag(2757, ts.DiagnosticCategory.Error, "Type_0_has_no_call_signatures_2757", "Type '{0}' has no call signatures."),
5669         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."),
5670         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."),
5671         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."),
5672         Type_0_has_no_construct_signatures: diag(2761, ts.DiagnosticCategory.Error, "Type_0_has_no_construct_signatures_2761", "Type '{0}' has no construct signatures."),
5673         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."),
5674         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}'."),
5675         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}'."),
5676         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}'."),
5677         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}'."),
5678         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."),
5679         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."),
5680         No_overload_matches_this_call: diag(2769, ts.DiagnosticCategory.Error, "No_overload_matches_this_call_2769", "No overload matches this call."),
5681         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."),
5682         The_last_overload_is_declared_here: diag(2771, ts.DiagnosticCategory.Error, "The_last_overload_is_declared_here_2771", "The last overload is declared here."),
5683         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."),
5684         Did_you_forget_to_use_await: diag(2773, ts.DiagnosticCategory.Error, "Did_you_forget_to_use_await_2773", "Did you forget to use 'await'?"),
5685         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?"),
5686         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."),
5687         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."),
5688         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."),
5689         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."),
5690         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."),
5691         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."),
5692         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."),
5693         _0_needs_an_explicit_type_annotation: diag(2782, ts.DiagnosticCategory.Message, "_0_needs_an_explicit_type_annotation_2782", "'{0}' needs an explicit type annotation."),
5694         _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."),
5695         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."),
5696         This_spread_always_overwrites_this_property: diag(2785, ts.DiagnosticCategory.Error, "This_spread_always_overwrites_this_property_2785", "This spread always overwrites this property."),
5697         _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."),
5698         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."),
5699         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."),
5700         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."),
5701         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."),
5702         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."),
5703         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?"),
5704         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."),
5705         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'?"),
5706         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."),
5707         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."),
5708         A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract: diag(2797, ts.DiagnosticCategory.Error, "A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_2797", "A mixin class that extends from a type variable containing an abstract construct signature must also be declared 'abstract'."),
5709         The_declaration_was_marked_as_deprecated_here: diag(2798, ts.DiagnosticCategory.Error, "The_declaration_was_marked_as_deprecated_here_2798", "The declaration was marked as deprecated here."),
5710         Type_produces_a_tuple_type_that_is_too_large_to_represent: diag(2799, ts.DiagnosticCategory.Error, "Type_produces_a_tuple_type_that_is_too_large_to_represent_2799", "Type produces a tuple type that is too large to represent."),
5711         Expression_produces_a_tuple_type_that_is_too_large_to_represent: diag(2800, ts.DiagnosticCategory.Error, "Expression_produces_a_tuple_type_that_is_too_large_to_represent_2800", "Expression produces a tuple type that is too large to represent."),
5712         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}'."),
5713         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}'."),
5714         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}'."),
5715         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}'."),
5716         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}'."),
5717         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}'."),
5718         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}'."),
5719         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}'."),
5720         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}'."),
5721         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}'."),
5722         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}'."),
5723         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}'."),
5724         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}'."),
5725         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."),
5726         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}'."),
5727         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}'."),
5728         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."),
5729         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}'."),
5730         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}'."),
5731         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."),
5732         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}'."),
5733         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}'."),
5734         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}'."),
5735         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}'."),
5736         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}'."),
5737         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}'."),
5738         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}'."),
5739         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}'."),
5740         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."),
5741         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}'."),
5742         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}'."),
5743         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."),
5744         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}'."),
5745         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}'."),
5746         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}'."),
5747         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}'."),
5748         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}'."),
5749         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}'."),
5750         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}'."),
5751         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}'."),
5752         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."),
5753         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}'."),
5754         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}'."),
5755         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."),
5756         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}'."),
5757         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}'."),
5758         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}'."),
5759         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}'."),
5760         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."),
5761         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}'."),
5762         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}'."),
5763         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."),
5764         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}'."),
5765         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}'."),
5766         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}'."),
5767         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}'."),
5768         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}'."),
5769         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}'."),
5770         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."),
5771         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}'."),
5772         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}'."),
5773         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."),
5774         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}'."),
5775         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}'."),
5776         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}'."),
5777         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}'."),
5778         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."),
5779         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}'."),
5780         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}'."),
5781         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}'."),
5782         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}'."),
5783         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}'."),
5784         Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2: diag(4084, ts.DiagnosticCategory.Error, "Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2_4084", "Exported type alias '{0}' has or is using private name '{1}' from module {2}."),
5785         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."),
5786         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}'."),
5787         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}'."),
5788         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."),
5789         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."),
5790         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}'."),
5791         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}'."),
5792         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."),
5793         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}'."),
5794         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}'."),
5795         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}'."),
5796         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}'."),
5797         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}'."),
5798         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}'."),
5799         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."),
5800         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}'."),
5801         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}'."),
5802         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."),
5803         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."),
5804         Tuple_type_arguments_circularly_reference_themselves: diag(4110, ts.DiagnosticCategory.Error, "Tuple_type_arguments_circularly_reference_themselves_4110", "Tuple type arguments circularly reference themselves."),
5805         Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0: diag(4111, ts.DiagnosticCategory.Error, "Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0_4111", "Property '{0}' comes from an index signature, so it must be accessed with ['{0}']."),
5806         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."),
5807         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."),
5808         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}'."),
5809         Cannot_read_file_0_Colon_1: diag(5012, ts.DiagnosticCategory.Error, "Cannot_read_file_0_Colon_1_5012", "Cannot read file '{0}': {1}."),
5810         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}."),
5811         Unknown_compiler_option_0: diag(5023, ts.DiagnosticCategory.Error, "Unknown_compiler_option_0_5023", "Unknown compiler option '{0}'."),
5812         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}."),
5813         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}'?"),
5814         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}."),
5815         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."),
5816         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."),
5817         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'."),
5818         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."),
5819         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}'."),
5820         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}'."),
5821         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}'."),
5822         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."),
5823         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."),
5824         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}'."),
5825         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}'."),
5826         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."),
5827         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."),
5828         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."),
5829         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."),
5830         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}'."),
5831         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}'."),
5832         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."),
5833         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."),
5834         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."),
5835         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}'."),
5836         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."),
5837         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'."),
5838         Unknown_build_option_0: diag(5072, ts.DiagnosticCategory.Error, "Unknown_build_option_0_5072", "Unknown build option '{0}'."),
5839         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}."),
5840         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."),
5841         _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}'."),
5842         _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."),
5843         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}'?"),
5844         Unknown_watch_option_0: diag(5078, ts.DiagnosticCategory.Error, "Unknown_watch_option_0_5078", "Unknown watch option '{0}'."),
5845         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}'?"),
5846         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}."),
5847         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}."),
5848         _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}'."),
5849         Cannot_read_file_0: diag(5083, ts.DiagnosticCategory.Error, "Cannot_read_file_0_5083", "Cannot read file '{0}'."),
5850         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."),
5851         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."),
5852         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."),
5853         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."),
5854         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."),
5855         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}'."),
5856         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 './'?"),
5857         Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled: diag(5091, ts.DiagnosticCategory.Error, "Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled_5091", "Option 'preserveConstEnums' cannot be disabled when 'isolatedModules' is enabled."),
5858         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."),
5859         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."),
5860         Generates_corresponding_d_ts_file: diag(6002, ts.DiagnosticCategory.Message, "Generates_corresponding_d_ts_file_6002", "Generates corresponding '.d.ts' file."),
5861         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."),
5862         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."),
5863         Watch_input_files: diag(6005, ts.DiagnosticCategory.Message, "Watch_input_files_6005", "Watch input files."),
5864         Redirect_output_structure_to_the_directory: diag(6006, ts.DiagnosticCategory.Message, "Redirect_output_structure_to_the_directory_6006", "Redirect output structure to the directory."),
5865         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."),
5866         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."),
5867         Do_not_emit_comments_to_output: diag(6009, ts.DiagnosticCategory.Message, "Do_not_emit_comments_to_output_6009", "Do not emit comments to output."),
5868         Do_not_emit_outputs: diag(6010, ts.DiagnosticCategory.Message, "Do_not_emit_outputs_6010", "Do not emit outputs."),
5869         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."),
5870         Skip_type_checking_of_declaration_files: diag(6012, ts.DiagnosticCategory.Message, "Skip_type_checking_of_declaration_files_6012", "Skip type checking of declaration files."),
5871         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."),
5872         Only_emit_d_ts_declaration_files: diag(6014, ts.DiagnosticCategory.Message, "Only_emit_d_ts_declaration_files_6014", "Only emit '.d.ts' declaration files."),
5873         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'."),
5874         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'."),
5875         Print_this_message: diag(6017, ts.DiagnosticCategory.Message, "Print_this_message_6017", "Print this message."),
5876         Print_the_compiler_s_version: diag(6019, ts.DiagnosticCategory.Message, "Print_the_compiler_s_version_6019", "Print the compiler's version."),
5877         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'."),
5878         Syntax_Colon_0: diag(6023, ts.DiagnosticCategory.Message, "Syntax_Colon_0_6023", "Syntax: {0}"),
5879         options: diag(6024, ts.DiagnosticCategory.Message, "options_6024", "options"),
5880         file: diag(6025, ts.DiagnosticCategory.Message, "file_6025", "file"),
5881         Examples_Colon_0: diag(6026, ts.DiagnosticCategory.Message, "Examples_Colon_0_6026", "Examples: {0}"),
5882         Options_Colon: diag(6027, ts.DiagnosticCategory.Message, "Options_Colon_6027", "Options:"),
5883         Version_0: diag(6029, ts.DiagnosticCategory.Message, "Version_0_6029", "Version {0}"),
5884         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."),
5885         Starting_compilation_in_watch_mode: diag(6031, ts.DiagnosticCategory.Message, "Starting_compilation_in_watch_mode_6031", "Starting compilation in watch mode..."),
5886         File_change_detected_Starting_incremental_compilation: diag(6032, ts.DiagnosticCategory.Message, "File_change_detected_Starting_incremental_compilation_6032", "File change detected. Starting incremental compilation..."),
5887         KIND: diag(6034, ts.DiagnosticCategory.Message, "KIND_6034", "KIND"),
5888         FILE: diag(6035, ts.DiagnosticCategory.Message, "FILE_6035", "FILE"),
5889         VERSION: diag(6036, ts.DiagnosticCategory.Message, "VERSION_6036", "VERSION"),
5890         LOCATION: diag(6037, ts.DiagnosticCategory.Message, "LOCATION_6037", "LOCATION"),
5891         DIRECTORY: diag(6038, ts.DiagnosticCategory.Message, "DIRECTORY_6038", "DIRECTORY"),
5892         STRATEGY: diag(6039, ts.DiagnosticCategory.Message, "STRATEGY_6039", "STRATEGY"),
5893         FILE_OR_DIRECTORY: diag(6040, ts.DiagnosticCategory.Message, "FILE_OR_DIRECTORY_6040", "FILE OR DIRECTORY"),
5894         Generates_corresponding_map_file: diag(6043, ts.DiagnosticCategory.Message, "Generates_corresponding_map_file_6043", "Generates corresponding '.map' file."),
5895         Compiler_option_0_expects_an_argument: diag(6044, ts.DiagnosticCategory.Error, "Compiler_option_0_expects_an_argument_6044", "Compiler option '{0}' expects an argument."),
5896         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}'."),
5897         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}."),
5898         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}'."),
5899         Unsupported_locale_0: diag(6049, ts.DiagnosticCategory.Error, "Unsupported_locale_0_6049", "Unsupported locale '{0}'."),
5900         Unable_to_open_file_0: diag(6050, ts.DiagnosticCategory.Error, "Unable_to_open_file_0_6050", "Unable to open file '{0}'."),
5901         Corrupted_locale_file_0: diag(6051, ts.DiagnosticCategory.Error, "Corrupted_locale_file_0_6051", "Corrupted locale file {0}."),
5902         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."),
5903         File_0_not_found: diag(6053, ts.DiagnosticCategory.Error, "File_0_not_found_6053", "File '{0}' not found."),
5904         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}."),
5905         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."),
5906         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."),
5907         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."),
5908         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."),
5909         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)."),
5910         NEWLINE: diag(6061, ts.DiagnosticCategory.Message, "NEWLINE_6061", "NEWLINE"),
5911         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."),
5912         Enables_experimental_support_for_ES7_decorators: diag(6065, ts.DiagnosticCategory.Message, "Enables_experimental_support_for_ES7_decorators_6065", "Enables experimental support for ES7 decorators."),
5913         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."),
5914         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."),
5915         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)."),
5916         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."),
5917         Successfully_created_a_tsconfig_json_file: diag(6071, ts.DiagnosticCategory.Message, "Successfully_created_a_tsconfig_json_file_6071", "Successfully created a tsconfig.json file."),
5918         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."),
5919         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)."),
5920         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."),
5921         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."),
5922         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."),
5923         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."),
5924         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."),
5925         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."),
5926         Specify_JSX_code_generation_Colon_preserve_react_native_react_react_jsx_or_react_jsxdev: diag(6080, ts.DiagnosticCategory.Message, "Specify_JSX_code_generation_Colon_preserve_react_native_react_react_jsx_or_react_jsxdev_6080", "Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'."),
5927         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."),
5928         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}."),
5929         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."),
5930         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"),
5931         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."),
5932         Resolving_module_0_from_1: diag(6086, ts.DiagnosticCategory.Message, "Resolving_module_0_from_1_6086", "======== Resolving module '{0}' from '{1}'. ========"),
5933         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}'."),
5934         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}'."),
5935         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}'. ========"),
5936         Module_name_0_was_not_resolved: diag(6090, ts.DiagnosticCategory.Message, "Module_name_0_was_not_resolved_6090", "======== Module name '{0}' was not resolved. ========"),
5937         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}'."),
5938         Module_name_0_matched_pattern_1: diag(6092, ts.DiagnosticCategory.Message, "Module_name_0_matched_pattern_1_6092", "Module name '{0}', matched pattern '{1}'."),
5939         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}'."),
5940         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}'."),
5941         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}'."),
5942         File_0_does_not_exist: diag(6096, ts.DiagnosticCategory.Message, "File_0_does_not_exist_6096", "File '{0}' does not exist."),
5943         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."),
5944         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}'."),
5945         Found_package_json_at_0: diag(6099, ts.DiagnosticCategory.Message, "Found_package_json_at_0_6099", "Found 'package.json' at '{0}'."),
5946         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."),
5947         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}'."),
5948         Allow_javascript_files_to_be_compiled: diag(6102, ts.DiagnosticCategory.Message, "Allow_javascript_files_to_be_compiled_6102", "Allow javascript files to be compiled."),
5949         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."),
5950         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}'."),
5951         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}'."),
5952         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}'."),
5953         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}'."),
5954         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}'."),
5955         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}'."),
5956         Trying_other_entries_in_rootDirs: diag(6110, ts.DiagnosticCategory.Message, "Trying_other_entries_in_rootDirs_6110", "Trying other entries in 'rootDirs'."),
5957         Module_resolution_using_rootDirs_has_failed: diag(6111, ts.DiagnosticCategory.Message, "Module_resolution_using_rootDirs_has_failed_6111", "Module resolution using 'rootDirs' has failed."),
5958         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."),
5959         Enable_strict_null_checks: diag(6113, ts.DiagnosticCategory.Message, "Enable_strict_null_checks_6113", "Enable strict null checks."),
5960         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'?"),
5961         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."),
5962         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}'. ========"),
5963         Resolving_using_primary_search_paths: diag(6117, ts.DiagnosticCategory.Message, "Resolving_using_primary_search_paths_6117", "Resolving using primary search paths..."),
5964         Resolving_from_node_modules_folder: diag(6118, ts.DiagnosticCategory.Message, "Resolving_from_node_modules_folder_6118", "Resolving from node_modules folder..."),
5965         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}. ========"),
5966         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. ========"),
5967         Resolving_with_primary_search_path_0: diag(6121, ts.DiagnosticCategory.Message, "Resolving_with_primary_search_path_0_6121", "Resolving with primary search path '{0}'."),
5968         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."),
5969         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. ========"),
5970         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."),
5971         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}'."),
5972         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."),
5973         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}'. ========"),
5974         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. ========"),
5975         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}'."),
5976         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'."),
5977         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."),
5978         _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),
5979         Report_errors_on_unused_locals: diag(6134, ts.DiagnosticCategory.Message, "Report_errors_on_unused_locals_6134", "Report errors on unused locals."),
5980         Report_errors_on_unused_parameters: diag(6135, ts.DiagnosticCategory.Message, "Report_errors_on_unused_parameters_6135", "Report errors on unused parameters."),
5981         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."),
5982         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}'."),
5983         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),
5984         Import_emit_helpers_from_tslib: diag(6139, ts.DiagnosticCategory.Message, "Import_emit_helpers_from_tslib_6139", "Import emit helpers from 'tslib'."),
5985         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}'."),
5986         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."),
5987         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."),
5988         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}'."),
5989         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."),
5990         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'."),
5991         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}'."),
5992         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."),
5993         Show_diagnostic_information: diag(6149, ts.DiagnosticCategory.Message, "Show_diagnostic_information_6149", "Show diagnostic information."),
5994         Show_verbose_diagnostic_information: diag(6150, ts.DiagnosticCategory.Message, "Show_verbose_diagnostic_information_6150", "Show verbose diagnostic information."),
5995         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."),
5996         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."),
5997         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')."),
5998         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."),
5999         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."),
6000         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')"),
6001         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."),
6002         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)."),
6003         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."),
6004         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."),
6005         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."),
6006         Disable_size_limitations_on_JavaScript_projects: diag(6162, ts.DiagnosticCategory.Message, "Disable_size_limitations_on_JavaScript_projects_6162", "Disable size limitations on JavaScript projects."),
6007         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."),
6008         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."),
6009         Do_not_truncate_error_messages: diag(6165, ts.DiagnosticCategory.Message, "Do_not_truncate_error_messages_6165", "Do not truncate error messages."),
6010         Output_directory_for_generated_declaration_files: diag(6166, ts.DiagnosticCategory.Message, "Output_directory_for_generated_declaration_files_6166", "Output directory for generated declaration files."),
6011         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'."),
6012         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."),
6013         Show_all_compiler_options: diag(6169, ts.DiagnosticCategory.Message, "Show_all_compiler_options_6169", "Show all compiler options."),
6014         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"),
6015         Command_line_Options: diag(6171, ts.DiagnosticCategory.Message, "Command_line_Options_6171", "Command-line Options"),
6016         Basic_Options: diag(6172, ts.DiagnosticCategory.Message, "Basic_Options_6172", "Basic Options"),
6017         Strict_Type_Checking_Options: diag(6173, ts.DiagnosticCategory.Message, "Strict_Type_Checking_Options_6173", "Strict Type-Checking Options"),
6018         Module_Resolution_Options: diag(6174, ts.DiagnosticCategory.Message, "Module_Resolution_Options_6174", "Module Resolution Options"),
6019         Source_Map_Options: diag(6175, ts.DiagnosticCategory.Message, "Source_Map_Options_6175", "Source Map Options"),
6020         Additional_Checks: diag(6176, ts.DiagnosticCategory.Message, "Additional_Checks_6176", "Additional Checks"),
6021         Experimental_Options: diag(6177, ts.DiagnosticCategory.Message, "Experimental_Options_6177", "Experimental Options"),
6022         Advanced_Options: diag(6178, ts.DiagnosticCategory.Message, "Advanced_Options_6178", "Advanced Options"),
6023         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'."),
6024         Enable_all_strict_type_checking_options: diag(6180, ts.DiagnosticCategory.Message, "Enable_all_strict_type_checking_options_6180", "Enable all strict type-checking options."),
6025         List_of_language_service_plugins: diag(6181, ts.DiagnosticCategory.Message, "List_of_language_service_plugins_6181", "List of language service plugins."),
6026         Scoped_package_detected_looking_in_0: diag(6182, ts.DiagnosticCategory.Message, "Scoped_package_detected_looking_in_0_6182", "Scoped package detected, looking in '{0}'"),
6027         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."),
6028         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."),
6029         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."),
6030         Enable_strict_checking_of_function_types: diag(6186, ts.DiagnosticCategory.Message, "Enable_strict_checking_of_function_types_6186", "Enable strict checking of function types."),
6031         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."),
6032         Numeric_separators_are_not_allowed_here: diag(6188, ts.DiagnosticCategory.Error, "Numeric_separators_are_not_allowed_here_6188", "Numeric separators are not allowed here."),
6033         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."),
6034         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."),
6035         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),
6036         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."),
6037         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."),
6038         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)."),
6039         _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),
6040         Include_modules_imported_with_json_extension: diag(6197, ts.DiagnosticCategory.Message, "Include_modules_imported_with_json_extension_6197", "Include modules imported with '.json' extension"),
6041         All_destructured_elements_are_unused: diag(6198, ts.DiagnosticCategory.Error, "All_destructured_elements_are_unused_6198", "All destructured elements are unused.", true),
6042         All_variables_are_unused: diag(6199, ts.DiagnosticCategory.Error, "All_variables_are_unused_6199", "All variables are unused.", true),
6043         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}"),
6044         Conflicts_are_in_this_file: diag(6201, ts.DiagnosticCategory.Message, "Conflicts_are_in_this_file_6201", "Conflicts are in this file."),
6045         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}"),
6046         _0_was_also_declared_here: diag(6203, ts.DiagnosticCategory.Message, "_0_was_also_declared_here_6203", "'{0}' was also declared here."),
6047         and_here: diag(6204, ts.DiagnosticCategory.Message, "and_here_6204", "and here."),
6048         All_type_parameters_are_unused: diag(6205, ts.DiagnosticCategory.Error, "All_type_parameters_are_unused_6205", "All type parameters are unused."),
6049         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."),
6050         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}'."),
6051         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}'."),
6052         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."),
6053         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."),
6054         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."),
6055         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?"),
6056         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?"),
6057         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."),
6058         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}'."),
6059         Found_1_error: diag(6216, ts.DiagnosticCategory.Message, "Found_1_error_6216", "Found 1 error."),
6060         Found_0_errors: diag(6217, ts.DiagnosticCategory.Message, "Found_0_errors_6217", "Found {0} errors."),
6061         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}'. ========"),
6062         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}. ========"),
6063         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."),
6064         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."),
6065         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."),
6066         Generates_a_CPU_profile: diag(6223, ts.DiagnosticCategory.Message, "Generates_a_CPU_profile_6223", "Generates a CPU profile."),
6067         Disable_solution_searching_for_this_project: diag(6224, ts.DiagnosticCategory.Message, "Disable_solution_searching_for_this_project_6224", "Disable solution searching for this project."),
6068         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'."),
6069         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'."),
6070         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'."),
6071         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."),
6072         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}'."),
6073         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."),
6074         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}."),
6075         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."),
6076         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."),
6077         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 '()'?"),
6078         Disable_loading_referenced_projects: diag(6235, ts.DiagnosticCategory.Message, "Disable_loading_referenced_projects_6235", "Disable loading referenced projects."),
6079         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."),
6080         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."),
6081         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"),
6082         Projects_to_reference: diag(6300, ts.DiagnosticCategory.Message, "Projects_to_reference_6300", "Projects to reference"),
6083         Enable_project_compilation: diag(6302, ts.DiagnosticCategory.Message, "Enable_project_compilation_6302", "Enable project compilation"),
6084         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."),
6085         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}'."),
6086         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."),
6087         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."),
6088         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"),
6089         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"),
6090         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."),
6091         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}'"),
6092         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}'"),
6093         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"),
6094         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"),
6095         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"),
6096         Projects_in_this_build_Colon_0: diag(6355, ts.DiagnosticCategory.Message, "Projects_in_this_build_Colon_0_6355", "Projects in this build: {0}"),
6097         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}"),
6098         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}'"),
6099         Building_project_0: diag(6358, ts.DiagnosticCategory.Message, "Building_project_0_6358", "Building project '{0}'..."),
6100         Updating_output_timestamps_of_project_0: diag(6359, ts.DiagnosticCategory.Message, "Updating_output_timestamps_of_project_0_6359", "Updating output timestamps of project '{0}'..."),
6101         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"),
6102         Project_0_is_up_to_date: diag(6361, ts.DiagnosticCategory.Message, "Project_0_is_up_to_date_6361", "Project '{0}' is up to date"),
6103         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"),
6104         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"),
6105         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"),
6106         Delete_the_outputs_of_all_projects: diag(6365, ts.DiagnosticCategory.Message, "Delete_the_outputs_of_all_projects_6365", "Delete the outputs of all projects"),
6107         Enable_verbose_logging: diag(6366, ts.DiagnosticCategory.Message, "Enable_verbose_logging_6366", "Enable verbose logging"),
6108         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')"),
6109         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"),
6110         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."),
6111         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."),
6112         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}'..."),
6113         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"),
6114         Updating_output_of_project_0: diag(6373, ts.DiagnosticCategory.Message, "Updating_output_of_project_0_6373", "Updating output of project '{0}'..."),
6115         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}'"),
6116         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}'"),
6117         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}'"),
6118         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}'"),
6119         Enable_incremental_compilation: diag(6378, ts.DiagnosticCategory.Message, "Enable_incremental_compilation_6378", "Enable incremental compilation"),
6120         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."),
6121         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"),
6122         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}'"),
6123         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"),
6124         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"),
6125         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."),
6126         _0_is_deprecated: diag(6385, ts.DiagnosticCategory.Suggestion, "_0_is_deprecated_6385", "'{0}' is deprecated.", undefined, undefined, true),
6127         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."),
6128         The_signature_0_of_1_is_deprecated: diag(6387, ts.DiagnosticCategory.Suggestion, "The_signature_0_of_1_is_deprecated_6387", "The signature '{0}' of '{1}' is deprecated.", undefined, undefined, true),
6129         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}'"),
6130         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."),
6131         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."),
6132         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."),
6133         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?"),
6134         Print_names_of_files_and_the_reason_they_are_part_of_the_compilation: diag(6505, ts.DiagnosticCategory.Message, "Print_names_of_files_and_the_reason_they_are_part_of_the_compilation_6505", "Print names of files and the reason they are part of the compilation."),
6135         Require_undeclared_properties_from_index_signatures_to_use_element_accesses: diag(6803, ts.DiagnosticCategory.Error, "Require_undeclared_properties_from_index_signatures_to_use_element_accesses_6803", "Require undeclared properties from index signatures to use element accesses."),
6136         Include_undefined_in_index_signature_results: diag(6800, ts.DiagnosticCategory.Message, "Include_undefined_in_index_signature_results_6800", "Include 'undefined' in index signature results"),
6137         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."),
6138         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."),
6139         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."),
6140         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."),
6141         _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."),
6142         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."),
6143         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."),
6144         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."),
6145         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'."),
6146         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."),
6147         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."),
6148         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."),
6149         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."),
6150         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."),
6151         _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."),
6152         _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."),
6153         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."),
6154         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."),
6155         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."),
6156         Unreachable_code_detected: diag(7027, ts.DiagnosticCategory.Error, "Unreachable_code_detected_7027", "Unreachable code detected.", true),
6157         Unused_label: diag(7028, ts.DiagnosticCategory.Error, "Unused_label_7028", "Unused label.", true),
6158         Fallthrough_case_in_switch: diag(7029, ts.DiagnosticCategory.Error, "Fallthrough_case_in_switch_7029", "Fallthrough case in switch."),
6159         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."),
6160         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."),
6161         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."),
6162         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."),
6163         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."),
6164         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}';`"),
6165         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}'."),
6166         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'."),
6167         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."),
6168         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."),
6169         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}`"),
6170         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'."),
6171         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."),
6172         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."),
6173         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."),
6174         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."),
6175         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."),
6176         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."),
6177         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."),
6178         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."),
6179         _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."),
6180         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}'?"),
6181         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}'?"),
6182         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}'."),
6183         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}'."),
6184         _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."),
6185         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."),
6186         yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation: diag(7057, ts.DiagnosticCategory.Error, "yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_t_7057", "'yield' expression implicitly results in an 'any' type because its containing generator lacks a return-type annotation."),
6187         You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
6188         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."),
6189         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."),
6190         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."),
6191         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."),
6192         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."),
6193         _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."),
6194         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."),
6195         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."),
6196         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."),
6197         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."),
6198         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."),
6199         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."),
6200         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."),
6201         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}'."),
6202         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}'."),
6203         Report_errors_in_js_files: diag(8019, ts.DiagnosticCategory.Message, "Report_errors_in_js_files_8019", "Report errors in .js files."),
6204         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."),
6205         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."),
6206         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."),
6207         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."),
6208         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."),
6209         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."),
6210         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."),
6211         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."),
6212         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."),
6213         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."),
6214         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."),
6215         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."),
6216         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}'."),
6217         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."),
6218         The_tag_was_first_specified_here: diag(8034, ts.DiagnosticCategory.Error, "The_tag_was_first_specified_here_8034", "The tag was first specified here."),
6219         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."),
6220         class_expressions_are_not_currently_supported: diag(9003, ts.DiagnosticCategory.Error, "class_expressions_are_not_currently_supported_9003", "'class' expressions are not currently supported."),
6221         Language_service_is_disabled: diag(9004, ts.DiagnosticCategory.Error, "Language_service_is_disabled_9004", "Language service is disabled."),
6222         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."),
6223         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."),
6224         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'."),
6225         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."),
6226         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}'."),
6227         JSX_attribute_expected: diag(17003, ts.DiagnosticCategory.Error, "JSX_attribute_expected_17003", "JSX attribute expected."),
6228         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."),
6229         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'."),
6230         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."),
6231         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."),
6232         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."),
6233         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."),
6234         Unknown_type_acquisition_option_0: diag(17010, ts.DiagnosticCategory.Error, "Unknown_type_acquisition_option_0_17010", "Unknown type acquisition option '{0}'."),
6235         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."),
6236         _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}'?"),
6237         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."),
6238         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."),
6239         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."),
6240         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."),
6241         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."),
6242         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}'?"),
6243         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}"),
6244         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."),
6245         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."),
6246         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}'."),
6247         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."),
6248         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."),
6249         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."),
6250         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."),
6251         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."),
6252         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."),
6253         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."),
6254         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."),
6255         Add_missing_super_call: diag(90001, ts.DiagnosticCategory.Message, "Add_missing_super_call_90001", "Add missing 'super()' call"),
6256         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"),
6257         Change_extends_to_implements: diag(90003, ts.DiagnosticCategory.Message, "Change_extends_to_implements_90003", "Change 'extends' to 'implements'"),
6258         Remove_unused_declaration_for_Colon_0: diag(90004, ts.DiagnosticCategory.Message, "Remove_unused_declaration_for_Colon_0_90004", "Remove unused declaration for: '{0}'"),
6259         Remove_import_from_0: diag(90005, ts.DiagnosticCategory.Message, "Remove_import_from_0_90005", "Remove import from '{0}'"),
6260         Implement_interface_0: diag(90006, ts.DiagnosticCategory.Message, "Implement_interface_0_90006", "Implement interface '{0}'"),
6261         Implement_inherited_abstract_class: diag(90007, ts.DiagnosticCategory.Message, "Implement_inherited_abstract_class_90007", "Implement inherited abstract class"),
6262         Add_0_to_unresolved_variable: diag(90008, ts.DiagnosticCategory.Message, "Add_0_to_unresolved_variable_90008", "Add '{0}.' to unresolved variable"),
6263         Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"),
6264         Remove_template_tag: diag(90011, ts.DiagnosticCategory.Message, "Remove_template_tag_90011", "Remove template tag"),
6265         Remove_type_parameters: diag(90012, ts.DiagnosticCategory.Message, "Remove_type_parameters_90012", "Remove type parameters"),
6266         Import_0_from_module_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_module_1_90013", "Import '{0}' from module \"{1}\""),
6267         Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"),
6268         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}\""),
6269         Declare_property_0: diag(90016, ts.DiagnosticCategory.Message, "Declare_property_0_90016", "Declare property '{0}'"),
6270         Add_index_signature_for_property_0: diag(90017, ts.DiagnosticCategory.Message, "Add_index_signature_for_property_0_90017", "Add index signature for property '{0}'"),
6271         Disable_checking_for_this_file: diag(90018, ts.DiagnosticCategory.Message, "Disable_checking_for_this_file_90018", "Disable checking for this file"),
6272         Ignore_this_error_message: diag(90019, ts.DiagnosticCategory.Message, "Ignore_this_error_message_90019", "Ignore this error message"),
6273         Initialize_property_0_in_the_constructor: diag(90020, ts.DiagnosticCategory.Message, "Initialize_property_0_in_the_constructor_90020", "Initialize property '{0}' in the constructor"),
6274         Initialize_static_property_0: diag(90021, ts.DiagnosticCategory.Message, "Initialize_static_property_0_90021", "Initialize static property '{0}'"),
6275         Change_spelling_to_0: diag(90022, ts.DiagnosticCategory.Message, "Change_spelling_to_0_90022", "Change spelling to '{0}'"),
6276         Declare_method_0: diag(90023, ts.DiagnosticCategory.Message, "Declare_method_0_90023", "Declare method '{0}'"),
6277         Declare_static_method_0: diag(90024, ts.DiagnosticCategory.Message, "Declare_static_method_0_90024", "Declare static method '{0}'"),
6278         Prefix_0_with_an_underscore: diag(90025, ts.DiagnosticCategory.Message, "Prefix_0_with_an_underscore_90025", "Prefix '{0}' with an underscore"),
6279         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}'"),
6280         Declare_static_property_0: diag(90027, ts.DiagnosticCategory.Message, "Declare_static_property_0_90027", "Declare static property '{0}'"),
6281         Call_decorator_expression: diag(90028, ts.DiagnosticCategory.Message, "Call_decorator_expression_90028", "Call decorator expression"),
6282         Add_async_modifier_to_containing_function: diag(90029, ts.DiagnosticCategory.Message, "Add_async_modifier_to_containing_function_90029", "Add async modifier to containing function"),
6283         Replace_infer_0_with_unknown: diag(90030, ts.DiagnosticCategory.Message, "Replace_infer_0_with_unknown_90030", "Replace 'infer {0}' with 'unknown'"),
6284         Replace_all_unused_infer_with_unknown: diag(90031, ts.DiagnosticCategory.Message, "Replace_all_unused_infer_with_unknown_90031", "Replace all unused 'infer' with 'unknown'"),
6285         Import_default_0_from_module_1: diag(90032, ts.DiagnosticCategory.Message, "Import_default_0_from_module_1_90032", "Import default '{0}' from module \"{1}\""),
6286         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}\""),
6287         Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"),
6288         Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"),
6289         Replace_0_with_Promise_1: diag(90036, ts.DiagnosticCategory.Message, "Replace_0_with_Promise_1_90036", "Replace '{0}' with 'Promise<{1}>'"),
6290         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"),
6291         Declare_private_method_0: diag(90038, ts.DiagnosticCategory.Message, "Declare_private_method_0_90038", "Declare private method '{0}'"),
6292         Remove_unused_destructuring_declaration: diag(90039, ts.DiagnosticCategory.Message, "Remove_unused_destructuring_declaration_90039", "Remove unused destructuring declaration"),
6293         Remove_unused_declarations_for_Colon_0: diag(90041, ts.DiagnosticCategory.Message, "Remove_unused_declarations_for_Colon_0_90041", "Remove unused declarations for: '{0}'"),
6294         Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."),
6295         Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
6296         Convert_function_0_to_class: diag(95002, ts.DiagnosticCategory.Message, "Convert_function_0_to_class_95002", "Convert function '{0}' to class"),
6297         Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
6298         Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
6299         Extract_function: diag(95005, ts.DiagnosticCategory.Message, "Extract_function_95005", "Extract function"),
6300         Extract_constant: diag(95006, ts.DiagnosticCategory.Message, "Extract_constant_95006", "Extract constant"),
6301         Extract_to_0_in_enclosing_scope: diag(95007, ts.DiagnosticCategory.Message, "Extract_to_0_in_enclosing_scope_95007", "Extract to {0} in enclosing scope"),
6302         Extract_to_0_in_1_scope: diag(95008, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_scope_95008", "Extract to {0} in {1} scope"),
6303         Annotate_with_type_from_JSDoc: diag(95009, ts.DiagnosticCategory.Message, "Annotate_with_type_from_JSDoc_95009", "Annotate with type from JSDoc"),
6304         Annotate_with_types_from_JSDoc: diag(95010, ts.DiagnosticCategory.Message, "Annotate_with_types_from_JSDoc_95010", "Annotate with types from JSDoc"),
6305         Infer_type_of_0_from_usage: diag(95011, ts.DiagnosticCategory.Message, "Infer_type_of_0_from_usage_95011", "Infer type of '{0}' from usage"),
6306         Infer_parameter_types_from_usage: diag(95012, ts.DiagnosticCategory.Message, "Infer_parameter_types_from_usage_95012", "Infer parameter types from usage"),
6307         Convert_to_default_import: diag(95013, ts.DiagnosticCategory.Message, "Convert_to_default_import_95013", "Convert to default import"),
6308         Install_0: diag(95014, ts.DiagnosticCategory.Message, "Install_0_95014", "Install '{0}'"),
6309         Replace_import_with_0: diag(95015, ts.DiagnosticCategory.Message, "Replace_import_with_0_95015", "Replace import with '{0}'."),
6310         Use_synthetic_default_member: diag(95016, ts.DiagnosticCategory.Message, "Use_synthetic_default_member_95016", "Use synthetic 'default' member."),
6311         Convert_to_ES6_module: diag(95017, ts.DiagnosticCategory.Message, "Convert_to_ES6_module_95017", "Convert to ES6 module"),
6312         Add_undefined_type_to_property_0: diag(95018, ts.DiagnosticCategory.Message, "Add_undefined_type_to_property_0_95018", "Add 'undefined' type to property '{0}'"),
6313         Add_initializer_to_property_0: diag(95019, ts.DiagnosticCategory.Message, "Add_initializer_to_property_0_95019", "Add initializer to property '{0}'"),
6314         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}'"),
6315         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"),
6316         Add_all_missing_members: diag(95022, ts.DiagnosticCategory.Message, "Add_all_missing_members_95022", "Add all missing members"),
6317         Infer_all_types_from_usage: diag(95023, ts.DiagnosticCategory.Message, "Infer_all_types_from_usage_95023", "Infer all types from usage"),
6318         Delete_all_unused_declarations: diag(95024, ts.DiagnosticCategory.Message, "Delete_all_unused_declarations_95024", "Delete all unused declarations"),
6319         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"),
6320         Fix_all_detected_spelling_errors: diag(95026, ts.DiagnosticCategory.Message, "Fix_all_detected_spelling_errors_95026", "Fix all detected spelling errors"),
6321         Add_initializers_to_all_uninitialized_properties: diag(95027, ts.DiagnosticCategory.Message, "Add_initializers_to_all_uninitialized_properties_95027", "Add initializers to all uninitialized properties"),
6322         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"),
6323         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"),
6324         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"),
6325         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)"),
6326         Implement_all_unimplemented_interfaces: diag(95032, ts.DiagnosticCategory.Message, "Implement_all_unimplemented_interfaces_95032", "Implement all unimplemented interfaces"),
6327         Install_all_missing_types_packages: diag(95033, ts.DiagnosticCategory.Message, "Install_all_missing_types_packages_95033", "Install all missing types packages"),
6328         Rewrite_all_as_indexed_access_types: diag(95034, ts.DiagnosticCategory.Message, "Rewrite_all_as_indexed_access_types_95034", "Rewrite all as indexed access types"),
6329         Convert_all_to_default_imports: diag(95035, ts.DiagnosticCategory.Message, "Convert_all_to_default_imports_95035", "Convert all to default imports"),
6330         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"),
6331         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"),
6332         Change_all_extended_interfaces_to_implements: diag(95038, ts.DiagnosticCategory.Message, "Change_all_extended_interfaces_to_implements_95038", "Change all extended interfaces to 'implements'"),
6333         Add_all_missing_super_calls: diag(95039, ts.DiagnosticCategory.Message, "Add_all_missing_super_calls_95039", "Add all missing super calls"),
6334         Implement_all_inherited_abstract_classes: diag(95040, ts.DiagnosticCategory.Message, "Implement_all_inherited_abstract_classes_95040", "Implement all inherited abstract classes"),
6335         Add_all_missing_async_modifiers: diag(95041, ts.DiagnosticCategory.Message, "Add_all_missing_async_modifiers_95041", "Add all missing 'async' modifiers"),
6336         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"),
6337         Annotate_everything_with_types_from_JSDoc: diag(95043, ts.DiagnosticCategory.Message, "Annotate_everything_with_types_from_JSDoc_95043", "Annotate everything with types from JSDoc"),
6338         Add_to_all_uncalled_decorators: diag(95044, ts.DiagnosticCategory.Message, "Add_to_all_uncalled_decorators_95044", "Add '()' to all uncalled decorators"),
6339         Convert_all_constructor_functions_to_classes: diag(95045, ts.DiagnosticCategory.Message, "Convert_all_constructor_functions_to_classes_95045", "Convert all constructor functions to classes"),
6340         Generate_get_and_set_accessors: diag(95046, ts.DiagnosticCategory.Message, "Generate_get_and_set_accessors_95046", "Generate 'get' and 'set' accessors"),
6341         Convert_require_to_import: diag(95047, ts.DiagnosticCategory.Message, "Convert_require_to_import_95047", "Convert 'require' to 'import'"),
6342         Convert_all_require_to_import: diag(95048, ts.DiagnosticCategory.Message, "Convert_all_require_to_import_95048", "Convert all 'require' to 'import'"),
6343         Move_to_a_new_file: diag(95049, ts.DiagnosticCategory.Message, "Move_to_a_new_file_95049", "Move to a new file"),
6344         Remove_unreachable_code: diag(95050, ts.DiagnosticCategory.Message, "Remove_unreachable_code_95050", "Remove unreachable code"),
6345         Remove_all_unreachable_code: diag(95051, ts.DiagnosticCategory.Message, "Remove_all_unreachable_code_95051", "Remove all unreachable code"),
6346         Add_missing_typeof: diag(95052, ts.DiagnosticCategory.Message, "Add_missing_typeof_95052", "Add missing 'typeof'"),
6347         Remove_unused_label: diag(95053, ts.DiagnosticCategory.Message, "Remove_unused_label_95053", "Remove unused label"),
6348         Remove_all_unused_labels: diag(95054, ts.DiagnosticCategory.Message, "Remove_all_unused_labels_95054", "Remove all unused labels"),
6349         Convert_0_to_mapped_object_type: diag(95055, ts.DiagnosticCategory.Message, "Convert_0_to_mapped_object_type_95055", "Convert '{0}' to mapped object type"),
6350         Convert_namespace_import_to_named_imports: diag(95056, ts.DiagnosticCategory.Message, "Convert_namespace_import_to_named_imports_95056", "Convert namespace import to named imports"),
6351         Convert_named_imports_to_namespace_import: diag(95057, ts.DiagnosticCategory.Message, "Convert_named_imports_to_namespace_import_95057", "Convert named imports to namespace import"),
6352         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"),
6353         Add_braces_to_arrow_function: diag(95059, ts.DiagnosticCategory.Message, "Add_braces_to_arrow_function_95059", "Add braces to arrow function"),
6354         Remove_braces_from_arrow_function: diag(95060, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_95060", "Remove braces from arrow function"),
6355         Convert_default_export_to_named_export: diag(95061, ts.DiagnosticCategory.Message, "Convert_default_export_to_named_export_95061", "Convert default export to named export"),
6356         Convert_named_export_to_default_export: diag(95062, ts.DiagnosticCategory.Message, "Convert_named_export_to_default_export_95062", "Convert named export to default export"),
6357         Add_missing_enum_member_0: diag(95063, ts.DiagnosticCategory.Message, "Add_missing_enum_member_0_95063", "Add missing enum member '{0}'"),
6358         Add_all_missing_imports: diag(95064, ts.DiagnosticCategory.Message, "Add_all_missing_imports_95064", "Add all missing imports"),
6359         Convert_to_async_function: diag(95065, ts.DiagnosticCategory.Message, "Convert_to_async_function_95065", "Convert to async function"),
6360         Convert_all_to_async_functions: diag(95066, ts.DiagnosticCategory.Message, "Convert_all_to_async_functions_95066", "Convert all to async functions"),
6361         Add_missing_call_parentheses: diag(95067, ts.DiagnosticCategory.Message, "Add_missing_call_parentheses_95067", "Add missing call parentheses"),
6362         Add_all_missing_call_parentheses: diag(95068, ts.DiagnosticCategory.Message, "Add_all_missing_call_parentheses_95068", "Add all missing call parentheses"),
6363         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"),
6364         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"),
6365         Add_missing_new_operator_to_call: diag(95071, ts.DiagnosticCategory.Message, "Add_missing_new_operator_to_call_95071", "Add missing 'new' operator to call"),
6366         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"),
6367         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"),
6368         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"),
6369         Convert_parameters_to_destructured_object: diag(95075, ts.DiagnosticCategory.Message, "Convert_parameters_to_destructured_object_95075", "Convert parameters to destructured object"),
6370         Allow_accessing_UMD_globals_from_modules: diag(95076, ts.DiagnosticCategory.Message, "Allow_accessing_UMD_globals_from_modules_95076", "Allow accessing UMD globals from modules."),
6371         Extract_type: diag(95077, ts.DiagnosticCategory.Message, "Extract_type_95077", "Extract type"),
6372         Extract_to_type_alias: diag(95078, ts.DiagnosticCategory.Message, "Extract_to_type_alias_95078", "Extract to type alias"),
6373         Extract_to_typedef: diag(95079, ts.DiagnosticCategory.Message, "Extract_to_typedef_95079", "Extract to typedef"),
6374         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"),
6375         Add_const_to_unresolved_variable: diag(95081, ts.DiagnosticCategory.Message, "Add_const_to_unresolved_variable_95081", "Add 'const' to unresolved variable"),
6376         Add_const_to_all_unresolved_variables: diag(95082, ts.DiagnosticCategory.Message, "Add_const_to_all_unresolved_variables_95082", "Add 'const' to all unresolved variables"),
6377         Add_await: diag(95083, ts.DiagnosticCategory.Message, "Add_await_95083", "Add 'await'"),
6378         Add_await_to_initializer_for_0: diag(95084, ts.DiagnosticCategory.Message, "Add_await_to_initializer_for_0_95084", "Add 'await' to initializer for '{0}'"),
6379         Fix_all_expressions_possibly_missing_await: diag(95085, ts.DiagnosticCategory.Message, "Fix_all_expressions_possibly_missing_await_95085", "Fix all expressions possibly missing 'await'"),
6380         Remove_unnecessary_await: diag(95086, ts.DiagnosticCategory.Message, "Remove_unnecessary_await_95086", "Remove unnecessary 'await'"),
6381         Remove_all_unnecessary_uses_of_await: diag(95087, ts.DiagnosticCategory.Message, "Remove_all_unnecessary_uses_of_await_95087", "Remove all unnecessary uses of 'await'"),
6382         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"),
6383         Add_await_to_initializers: diag(95089, ts.DiagnosticCategory.Message, "Add_await_to_initializers_95089", "Add 'await' to initializers"),
6384         Extract_to_interface: diag(95090, ts.DiagnosticCategory.Message, "Extract_to_interface_95090", "Extract to interface"),
6385         Convert_to_a_bigint_numeric_literal: diag(95091, ts.DiagnosticCategory.Message, "Convert_to_a_bigint_numeric_literal_95091", "Convert to a bigint numeric literal"),
6386         Convert_all_to_bigint_numeric_literals: diag(95092, ts.DiagnosticCategory.Message, "Convert_all_to_bigint_numeric_literals_95092", "Convert all to bigint numeric literals"),
6387         Convert_const_to_let: diag(95093, ts.DiagnosticCategory.Message, "Convert_const_to_let_95093", "Convert 'const' to 'let'"),
6388         Prefix_with_declare: diag(95094, ts.DiagnosticCategory.Message, "Prefix_with_declare_95094", "Prefix with 'declare'"),
6389         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'"),
6390         Convert_to_template_string: diag(95096, ts.DiagnosticCategory.Message, "Convert_to_template_string_95096", "Convert to template string"),
6391         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"),
6392         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}'"),
6393         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}'"),
6394         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"),
6395         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"),
6396         Add_class_tag: diag(95102, ts.DiagnosticCategory.Message, "Add_class_tag_95102", "Add '@class' tag"),
6397         Add_this_tag: diag(95103, ts.DiagnosticCategory.Message, "Add_this_tag_95103", "Add '@this' tag"),
6398         Add_this_parameter: diag(95104, ts.DiagnosticCategory.Message, "Add_this_parameter_95104", "Add 'this' parameter."),
6399         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"),
6400         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"),
6401         Fix_all_implicit_this_errors: diag(95107, ts.DiagnosticCategory.Message, "Fix_all_implicit_this_errors_95107", "Fix all implicit-'this' errors"),
6402         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"),
6403         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"),
6404         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"),
6405         Add_a_return_statement: diag(95111, ts.DiagnosticCategory.Message, "Add_a_return_statement_95111", "Add a return statement"),
6406         Remove_braces_from_arrow_function_body: diag(95112, ts.DiagnosticCategory.Message, "Remove_braces_from_arrow_function_body_95112", "Remove braces from arrow function body"),
6407         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"),
6408         Add_all_missing_return_statement: diag(95114, ts.DiagnosticCategory.Message, "Add_all_missing_return_statement_95114", "Add all missing return statement"),
6409         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"),
6410         Wrap_all_object_literal_with_parentheses: diag(95116, ts.DiagnosticCategory.Message, "Wrap_all_object_literal_with_parentheses_95116", "Wrap all object literal with parentheses"),
6411         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"),
6412         Convert_overload_list_to_single_signature: diag(95118, ts.DiagnosticCategory.Message, "Convert_overload_list_to_single_signature_95118", "Convert overload list to single signature"),
6413         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"),
6414         Wrap_in_JSX_fragment: diag(95120, ts.DiagnosticCategory.Message, "Wrap_in_JSX_fragment_95120", "Wrap in JSX fragment"),
6415         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"),
6416         Convert_arrow_function_or_function_expression: diag(95122, ts.DiagnosticCategory.Message, "Convert_arrow_function_or_function_expression_95122", "Convert arrow function or function expression"),
6417         Convert_to_anonymous_function: diag(95123, ts.DiagnosticCategory.Message, "Convert_to_anonymous_function_95123", "Convert to anonymous function"),
6418         Convert_to_named_function: diag(95124, ts.DiagnosticCategory.Message, "Convert_to_named_function_95124", "Convert to named function"),
6419         Convert_to_arrow_function: diag(95125, ts.DiagnosticCategory.Message, "Convert_to_arrow_function_95125", "Convert to arrow function"),
6420         Remove_parentheses: diag(95126, ts.DiagnosticCategory.Message, "Remove_parentheses_95126", "Remove parentheses"),
6421         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"),
6422         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"),
6423         Could_not_find_export_statement: diag(95129, ts.DiagnosticCategory.Message, "Could_not_find_export_statement_95129", "Could not find export statement"),
6424         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"),
6425         Could_not_find_import_clause: diag(95131, ts.DiagnosticCategory.Message, "Could_not_find_import_clause_95131", "Could not find import clause"),
6426         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"),
6427         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"),
6428         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"),
6429         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"),
6430         Name_is_not_valid: diag(95136, ts.DiagnosticCategory.Message, "Name_is_not_valid_95136", "Name is not valid"),
6431         Can_only_convert_property_with_modifier: diag(95137, ts.DiagnosticCategory.Message, "Can_only_convert_property_with_modifier_95137", "Can only convert property with modifier"),
6432         Switch_each_misused_0_to_1: diag(95138, ts.DiagnosticCategory.Message, "Switch_each_misused_0_to_1_95138", "Switch each misused '{0}' to '{1}'"),
6433         Convert_to_optional_chain_expression: diag(95139, ts.DiagnosticCategory.Message, "Convert_to_optional_chain_expression_95139", "Convert to optional chain expression"),
6434         Could_not_find_convertible_access_expression: diag(95140, ts.DiagnosticCategory.Message, "Could_not_find_convertible_access_expression_95140", "Could not find convertible access expression"),
6435         Could_not_find_matching_access_expressions: diag(95141, ts.DiagnosticCategory.Message, "Could_not_find_matching_access_expressions_95141", "Could not find matching access expressions"),
6436         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"),
6437         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"),
6438         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"),
6439         Use_element_access_for_0: diag(95145, ts.DiagnosticCategory.Message, "Use_element_access_for_0_95145", "Use element access for '{0}'"),
6440         Use_element_access_for_all_undeclared_properties: diag(95146, ts.DiagnosticCategory.Message, "Use_element_access_for_all_undeclared_properties_95146", "Use element access for all undeclared properties."),
6441         Delete_all_unused_imports: diag(95147, ts.DiagnosticCategory.Message, "Delete_all_unused_imports_95147", "Delete all unused imports"),
6442         Infer_function_return_type: diag(95148, ts.DiagnosticCategory.Message, "Infer_function_return_type_95148", "Infer function return type"),
6443         Return_type_must_be_inferred_from_a_function: diag(95149, ts.DiagnosticCategory.Message, "Return_type_must_be_inferred_from_a_function_95149", "Return type must be inferred from a function"),
6444         Could_not_determine_function_return_type: diag(95150, ts.DiagnosticCategory.Message, "Could_not_determine_function_return_type_95150", "Could not determine function return type"),
6445         Could_not_convert_to_arrow_function: diag(95151, ts.DiagnosticCategory.Message, "Could_not_convert_to_arrow_function_95151", "Could not convert to arrow function"),
6446         Could_not_convert_to_named_function: diag(95152, ts.DiagnosticCategory.Message, "Could_not_convert_to_named_function_95152", "Could not convert to named function"),
6447         Could_not_convert_to_anonymous_function: diag(95153, ts.DiagnosticCategory.Message, "Could_not_convert_to_anonymous_function_95153", "Could not convert to anonymous function"),
6448         Can_only_convert_string_concatenation: diag(95154, ts.DiagnosticCategory.Message, "Can_only_convert_string_concatenation_95154", "Can only convert string concatenation"),
6449         Selection_is_not_a_valid_statement_or_statements: diag(95155, ts.DiagnosticCategory.Message, "Selection_is_not_a_valid_statement_or_statements_95155", "Selection is not a valid statement or statements"),
6450         Add_missing_function_declaration_0: diag(95156, ts.DiagnosticCategory.Message, "Add_missing_function_declaration_0_95156", "Add missing function declaration '{0}'"),
6451         Add_all_missing_function_declarations: diag(95157, ts.DiagnosticCategory.Message, "Add_all_missing_function_declarations_95157", "Add all missing function declarations"),
6452         Method_not_implemented: diag(95158, ts.DiagnosticCategory.Message, "Method_not_implemented_95158", "Method not implemented."),
6453         Function_not_implemented: diag(95159, ts.DiagnosticCategory.Message, "Function_not_implemented_95159", "Function not implemented."),
6454         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."),
6455         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'."),
6456         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?"),
6457         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."),
6458         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."),
6459         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."),
6460         constructor_is_a_reserved_word: diag(18012, ts.DiagnosticCategory.Error, "constructor_is_a_reserved_word_18012", "'#constructor' is a reserved word."),
6461         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."),
6462         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."),
6463         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}'."),
6464         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."),
6465         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"),
6466         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"),
6467         _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."),
6468         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."),
6469         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."),
6470         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."),
6471         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."),
6472         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."),
6473         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."),
6474         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."),
6475         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."),
6476         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."),
6477         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."),
6478         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."),
6479         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'."),
6480         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."),
6481     };
6482 })(ts || (ts = {}));
6483 var ts;
6484 (function (ts) {
6485     var _a;
6486     function tokenIsIdentifierOrKeyword(token) {
6487         return token >= 78;
6488     }
6489     ts.tokenIsIdentifierOrKeyword = tokenIsIdentifierOrKeyword;
6490     function tokenIsIdentifierOrKeywordOrGreaterThan(token) {
6491         return token === 31 || tokenIsIdentifierOrKeyword(token);
6492     }
6493     ts.tokenIsIdentifierOrKeywordOrGreaterThan = tokenIsIdentifierOrKeywordOrGreaterThan;
6494     var textToKeywordObj = (_a = {
6495             abstract: 125,
6496             any: 128,
6497             as: 126,
6498             asserts: 127,
6499             bigint: 155,
6500             boolean: 131,
6501             break: 80,
6502             case: 81,
6503             catch: 82,
6504             class: 83,
6505             continue: 85,
6506             const: 84
6507         },
6508         _a["" + "constructor"] = 132,
6509         _a.debugger = 86,
6510         _a.declare = 133,
6511         _a.default = 87,
6512         _a.delete = 88,
6513         _a.do = 89,
6514         _a.else = 90,
6515         _a.enum = 91,
6516         _a.export = 92,
6517         _a.extends = 93,
6518         _a.false = 94,
6519         _a.finally = 95,
6520         _a.for = 96,
6521         _a.from = 153,
6522         _a.function = 97,
6523         _a.get = 134,
6524         _a.if = 98,
6525         _a.implements = 116,
6526         _a.import = 99,
6527         _a.in = 100,
6528         _a.infer = 135,
6529         _a.instanceof = 101,
6530         _a.interface = 117,
6531         _a.intrinsic = 136,
6532         _a.is = 137,
6533         _a.keyof = 138,
6534         _a.let = 118,
6535         _a.module = 139,
6536         _a.namespace = 140,
6537         _a.never = 141,
6538         _a.new = 102,
6539         _a.null = 103,
6540         _a.number = 144,
6541         _a.object = 145,
6542         _a.package = 119,
6543         _a.private = 120,
6544         _a.protected = 121,
6545         _a.public = 122,
6546         _a.readonly = 142,
6547         _a.require = 143,
6548         _a.global = 154,
6549         _a.return = 104,
6550         _a.set = 146,
6551         _a.static = 123,
6552         _a.string = 147,
6553         _a.super = 105,
6554         _a.switch = 106,
6555         _a.symbol = 148,
6556         _a.this = 107,
6557         _a.throw = 108,
6558         _a.true = 109,
6559         _a.try = 110,
6560         _a.type = 149,
6561         _a.typeof = 111,
6562         _a.undefined = 150,
6563         _a.unique = 151,
6564         _a.unknown = 152,
6565         _a.var = 112,
6566         _a.void = 113,
6567         _a.while = 114,
6568         _a.with = 115,
6569         _a.yield = 124,
6570         _a.async = 129,
6571         _a.await = 130,
6572         _a.of = 156,
6573         _a);
6574     var textToKeyword = new ts.Map(ts.getEntries(textToKeywordObj));
6575     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 })));
6576     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,];
6577     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,];
6578     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,];
6579     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,];
6580     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];
6581     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];
6582     var commentDirectiveRegExSingleLine = /^\s*\/\/\/?\s*@(ts-expect-error|ts-ignore)/;
6583     var commentDirectiveRegExMultiLine = /^\s*(?:\/|\*)*\s*@(ts-expect-error|ts-ignore)/;
6584     function lookupInUnicodeMap(code, map) {
6585         if (code < map[0]) {
6586             return false;
6587         }
6588         var lo = 0;
6589         var hi = map.length;
6590         var mid;
6591         while (lo + 1 < hi) {
6592             mid = lo + (hi - lo) / 2;
6593             mid -= mid % 2;
6594             if (map[mid] <= code && code <= map[mid + 1]) {
6595                 return true;
6596             }
6597             if (code < map[mid]) {
6598                 hi = mid;
6599             }
6600             else {
6601                 lo = mid + 2;
6602             }
6603         }
6604         return false;
6605     }
6606     function isUnicodeIdentifierStart(code, languageVersion) {
6607         return languageVersion >= 2 ?
6608             lookupInUnicodeMap(code, unicodeESNextIdentifierStart) :
6609             languageVersion === 1 ? lookupInUnicodeMap(code, unicodeES5IdentifierStart) :
6610                 lookupInUnicodeMap(code, unicodeES3IdentifierStart);
6611     }
6612     ts.isUnicodeIdentifierStart = isUnicodeIdentifierStart;
6613     function isUnicodeIdentifierPart(code, languageVersion) {
6614         return languageVersion >= 2 ?
6615             lookupInUnicodeMap(code, unicodeESNextIdentifierPart) :
6616             languageVersion === 1 ? lookupInUnicodeMap(code, unicodeES5IdentifierPart) :
6617                 lookupInUnicodeMap(code, unicodeES3IdentifierPart);
6618     }
6619     function makeReverseMap(source) {
6620         var result = [];
6621         source.forEach(function (value, name) {
6622             result[value] = name;
6623         });
6624         return result;
6625     }
6626     var tokenStrings = makeReverseMap(textToToken);
6627     function tokenToString(t) {
6628         return tokenStrings[t];
6629     }
6630     ts.tokenToString = tokenToString;
6631     function stringToToken(s) {
6632         return textToToken.get(s);
6633     }
6634     ts.stringToToken = stringToToken;
6635     function computeLineStarts(text) {
6636         var result = new Array();
6637         var pos = 0;
6638         var lineStart = 0;
6639         while (pos < text.length) {
6640             var ch = text.charCodeAt(pos);
6641             pos++;
6642             switch (ch) {
6643                 case 13:
6644                     if (text.charCodeAt(pos) === 10) {
6645                         pos++;
6646                     }
6647                 case 10:
6648                     result.push(lineStart);
6649                     lineStart = pos;
6650                     break;
6651                 default:
6652                     if (ch > 127 && isLineBreak(ch)) {
6653                         result.push(lineStart);
6654                         lineStart = pos;
6655                     }
6656                     break;
6657             }
6658         }
6659         result.push(lineStart);
6660         return result;
6661     }
6662     ts.computeLineStarts = computeLineStarts;
6663     function getPositionOfLineAndCharacter(sourceFile, line, character, allowEdits) {
6664         return sourceFile.getPositionOfLineAndCharacter ?
6665             sourceFile.getPositionOfLineAndCharacter(line, character, allowEdits) :
6666             computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character, sourceFile.text, allowEdits);
6667     }
6668     ts.getPositionOfLineAndCharacter = getPositionOfLineAndCharacter;
6669     function computePositionOfLineAndCharacter(lineStarts, line, character, debugText, allowEdits) {
6670         if (line < 0 || line >= lineStarts.length) {
6671             if (allowEdits) {
6672                 line = line < 0 ? 0 : line >= lineStarts.length ? lineStarts.length - 1 : line;
6673             }
6674             else {
6675                 ts.Debug.fail("Bad line number. Line: " + line + ", lineStarts.length: " + lineStarts.length + " , line map is correct? " + (debugText !== undefined ? ts.arraysEqual(lineStarts, computeLineStarts(debugText)) : "unknown"));
6676             }
6677         }
6678         var res = lineStarts[line] + character;
6679         if (allowEdits) {
6680             return res > lineStarts[line + 1] ? lineStarts[line + 1] : typeof debugText === "string" && res > debugText.length ? debugText.length : res;
6681         }
6682         if (line < lineStarts.length - 1) {
6683             ts.Debug.assert(res < lineStarts[line + 1]);
6684         }
6685         else if (debugText !== undefined) {
6686             ts.Debug.assert(res <= debugText.length);
6687         }
6688         return res;
6689     }
6690     ts.computePositionOfLineAndCharacter = computePositionOfLineAndCharacter;
6691     function getLineStarts(sourceFile) {
6692         return sourceFile.lineMap || (sourceFile.lineMap = computeLineStarts(sourceFile.text));
6693     }
6694     ts.getLineStarts = getLineStarts;
6695     function computeLineAndCharacterOfPosition(lineStarts, position) {
6696         var lineNumber = computeLineOfPosition(lineStarts, position);
6697         return {
6698             line: lineNumber,
6699             character: position - lineStarts[lineNumber]
6700         };
6701     }
6702     ts.computeLineAndCharacterOfPosition = computeLineAndCharacterOfPosition;
6703     function computeLineOfPosition(lineStarts, position, lowerBound) {
6704         var lineNumber = ts.binarySearch(lineStarts, position, ts.identity, ts.compareValues, lowerBound);
6705         if (lineNumber < 0) {
6706             lineNumber = ~lineNumber - 1;
6707             ts.Debug.assert(lineNumber !== -1, "position cannot precede the beginning of the file");
6708         }
6709         return lineNumber;
6710     }
6711     ts.computeLineOfPosition = computeLineOfPosition;
6712     function getLinesBetweenPositions(sourceFile, pos1, pos2) {
6713         if (pos1 === pos2)
6714             return 0;
6715         var lineStarts = getLineStarts(sourceFile);
6716         var lower = Math.min(pos1, pos2);
6717         var isNegative = lower === pos2;
6718         var upper = isNegative ? pos1 : pos2;
6719         var lowerLine = computeLineOfPosition(lineStarts, lower);
6720         var upperLine = computeLineOfPosition(lineStarts, upper, lowerLine);
6721         return isNegative ? lowerLine - upperLine : upperLine - lowerLine;
6722     }
6723     ts.getLinesBetweenPositions = getLinesBetweenPositions;
6724     function getLineAndCharacterOfPosition(sourceFile, position) {
6725         return computeLineAndCharacterOfPosition(getLineStarts(sourceFile), position);
6726     }
6727     ts.getLineAndCharacterOfPosition = getLineAndCharacterOfPosition;
6728     function isWhiteSpaceLike(ch) {
6729         return isWhiteSpaceSingleLine(ch) || isLineBreak(ch);
6730     }
6731     ts.isWhiteSpaceLike = isWhiteSpaceLike;
6732     function isWhiteSpaceSingleLine(ch) {
6733         return ch === 32 ||
6734             ch === 9 ||
6735             ch === 11 ||
6736             ch === 12 ||
6737             ch === 160 ||
6738             ch === 133 ||
6739             ch === 5760 ||
6740             ch >= 8192 && ch <= 8203 ||
6741             ch === 8239 ||
6742             ch === 8287 ||
6743             ch === 12288 ||
6744             ch === 65279;
6745     }
6746     ts.isWhiteSpaceSingleLine = isWhiteSpaceSingleLine;
6747     function isLineBreak(ch) {
6748         return ch === 10 ||
6749             ch === 13 ||
6750             ch === 8232 ||
6751             ch === 8233;
6752     }
6753     ts.isLineBreak = isLineBreak;
6754     function isDigit(ch) {
6755         return ch >= 48 && ch <= 57;
6756     }
6757     function isHexDigit(ch) {
6758         return isDigit(ch) || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102;
6759     }
6760     function isCodePoint(code) {
6761         return code <= 0x10FFFF;
6762     }
6763     function isOctalDigit(ch) {
6764         return ch >= 48 && ch <= 55;
6765     }
6766     ts.isOctalDigit = isOctalDigit;
6767     function couldStartTrivia(text, pos) {
6768         var ch = text.charCodeAt(pos);
6769         switch (ch) {
6770             case 13:
6771             case 10:
6772             case 9:
6773             case 11:
6774             case 12:
6775             case 32:
6776             case 47:
6777             case 60:
6778             case 124:
6779             case 61:
6780             case 62:
6781                 return true;
6782             case 35:
6783                 return pos === 0;
6784             default:
6785                 return ch > 127;
6786         }
6787     }
6788     ts.couldStartTrivia = couldStartTrivia;
6789     function skipTrivia(text, pos, stopAfterLineBreak, stopAtComments) {
6790         if (stopAtComments === void 0) { stopAtComments = false; }
6791         if (ts.positionIsSynthesized(pos)) {
6792             return pos;
6793         }
6794         while (true) {
6795             var ch = text.charCodeAt(pos);
6796             switch (ch) {
6797                 case 13:
6798                     if (text.charCodeAt(pos + 1) === 10) {
6799                         pos++;
6800                     }
6801                 case 10:
6802                     pos++;
6803                     if (stopAfterLineBreak) {
6804                         return pos;
6805                     }
6806                     continue;
6807                 case 9:
6808                 case 11:
6809                 case 12:
6810                 case 32:
6811                     pos++;
6812                     continue;
6813                 case 47:
6814                     if (stopAtComments) {
6815                         break;
6816                     }
6817                     if (text.charCodeAt(pos + 1) === 47) {
6818                         pos += 2;
6819                         while (pos < text.length) {
6820                             if (isLineBreak(text.charCodeAt(pos))) {
6821                                 break;
6822                             }
6823                             pos++;
6824                         }
6825                         continue;
6826                     }
6827                     if (text.charCodeAt(pos + 1) === 42) {
6828                         pos += 2;
6829                         while (pos < text.length) {
6830                             if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) {
6831                                 pos += 2;
6832                                 break;
6833                             }
6834                             pos++;
6835                         }
6836                         continue;
6837                     }
6838                     break;
6839                 case 60:
6840                 case 124:
6841                 case 61:
6842                 case 62:
6843                     if (isConflictMarkerTrivia(text, pos)) {
6844                         pos = scanConflictMarkerTrivia(text, pos);
6845                         continue;
6846                     }
6847                     break;
6848                 case 35:
6849                     if (pos === 0 && isShebangTrivia(text, pos)) {
6850                         pos = scanShebangTrivia(text, pos);
6851                         continue;
6852                     }
6853                     break;
6854                 default:
6855                     if (ch > 127 && (isWhiteSpaceLike(ch))) {
6856                         pos++;
6857                         continue;
6858                     }
6859                     break;
6860             }
6861             return pos;
6862         }
6863     }
6864     ts.skipTrivia = skipTrivia;
6865     var mergeConflictMarkerLength = "<<<<<<<".length;
6866     function isConflictMarkerTrivia(text, pos) {
6867         ts.Debug.assert(pos >= 0);
6868         if (pos === 0 || isLineBreak(text.charCodeAt(pos - 1))) {
6869             var ch = text.charCodeAt(pos);
6870             if ((pos + mergeConflictMarkerLength) < text.length) {
6871                 for (var i = 0; i < mergeConflictMarkerLength; i++) {
6872                     if (text.charCodeAt(pos + i) !== ch) {
6873                         return false;
6874                     }
6875                 }
6876                 return ch === 61 ||
6877                     text.charCodeAt(pos + mergeConflictMarkerLength) === 32;
6878             }
6879         }
6880         return false;
6881     }
6882     function scanConflictMarkerTrivia(text, pos, error) {
6883         if (error) {
6884             error(ts.Diagnostics.Merge_conflict_marker_encountered, pos, mergeConflictMarkerLength);
6885         }
6886         var ch = text.charCodeAt(pos);
6887         var len = text.length;
6888         if (ch === 60 || ch === 62) {
6889             while (pos < len && !isLineBreak(text.charCodeAt(pos))) {
6890                 pos++;
6891             }
6892         }
6893         else {
6894             ts.Debug.assert(ch === 124 || ch === 61);
6895             while (pos < len) {
6896                 var currentChar = text.charCodeAt(pos);
6897                 if ((currentChar === 61 || currentChar === 62) && currentChar !== ch && isConflictMarkerTrivia(text, pos)) {
6898                     break;
6899                 }
6900                 pos++;
6901             }
6902         }
6903         return pos;
6904     }
6905     var shebangTriviaRegex = /^#!.*/;
6906     function isShebangTrivia(text, pos) {
6907         ts.Debug.assert(pos === 0);
6908         return shebangTriviaRegex.test(text);
6909     }
6910     ts.isShebangTrivia = isShebangTrivia;
6911     function scanShebangTrivia(text, pos) {
6912         var shebang = shebangTriviaRegex.exec(text)[0];
6913         pos = pos + shebang.length;
6914         return pos;
6915     }
6916     ts.scanShebangTrivia = scanShebangTrivia;
6917     function iterateCommentRanges(reduce, text, pos, trailing, cb, state, initial) {
6918         var pendingPos;
6919         var pendingEnd;
6920         var pendingKind;
6921         var pendingHasTrailingNewLine;
6922         var hasPendingCommentRange = false;
6923         var collecting = trailing;
6924         var accumulator = initial;
6925         if (pos === 0) {
6926             collecting = true;
6927             var shebang = getShebang(text);
6928             if (shebang) {
6929                 pos = shebang.length;
6930             }
6931         }
6932         scan: while (pos >= 0 && pos < text.length) {
6933             var ch = text.charCodeAt(pos);
6934             switch (ch) {
6935                 case 13:
6936                     if (text.charCodeAt(pos + 1) === 10) {
6937                         pos++;
6938                     }
6939                 case 10:
6940                     pos++;
6941                     if (trailing) {
6942                         break scan;
6943                     }
6944                     collecting = true;
6945                     if (hasPendingCommentRange) {
6946                         pendingHasTrailingNewLine = true;
6947                     }
6948                     continue;
6949                 case 9:
6950                 case 11:
6951                 case 12:
6952                 case 32:
6953                     pos++;
6954                     continue;
6955                 case 47:
6956                     var nextChar = text.charCodeAt(pos + 1);
6957                     var hasTrailingNewLine = false;
6958                     if (nextChar === 47 || nextChar === 42) {
6959                         var kind = nextChar === 47 ? 2 : 3;
6960                         var startPos = pos;
6961                         pos += 2;
6962                         if (nextChar === 47) {
6963                             while (pos < text.length) {
6964                                 if (isLineBreak(text.charCodeAt(pos))) {
6965                                     hasTrailingNewLine = true;
6966                                     break;
6967                                 }
6968                                 pos++;
6969                             }
6970                         }
6971                         else {
6972                             while (pos < text.length) {
6973                                 if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) === 47) {
6974                                     pos += 2;
6975                                     break;
6976                                 }
6977                                 pos++;
6978                             }
6979                         }
6980                         if (collecting) {
6981                             if (hasPendingCommentRange) {
6982                                 accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator);
6983                                 if (!reduce && accumulator) {
6984                                     return accumulator;
6985                                 }
6986                             }
6987                             pendingPos = startPos;
6988                             pendingEnd = pos;
6989                             pendingKind = kind;
6990                             pendingHasTrailingNewLine = hasTrailingNewLine;
6991                             hasPendingCommentRange = true;
6992                         }
6993                         continue;
6994                     }
6995                     break scan;
6996                 default:
6997                     if (ch > 127 && (isWhiteSpaceLike(ch))) {
6998                         if (hasPendingCommentRange && isLineBreak(ch)) {
6999                             pendingHasTrailingNewLine = true;
7000                         }
7001                         pos++;
7002                         continue;
7003                     }
7004                     break scan;
7005             }
7006         }
7007         if (hasPendingCommentRange) {
7008             accumulator = cb(pendingPos, pendingEnd, pendingKind, pendingHasTrailingNewLine, state, accumulator);
7009         }
7010         return accumulator;
7011     }
7012     function forEachLeadingCommentRange(text, pos, cb, state) {
7013         return iterateCommentRanges(false, text, pos, false, cb, state);
7014     }
7015     ts.forEachLeadingCommentRange = forEachLeadingCommentRange;
7016     function forEachTrailingCommentRange(text, pos, cb, state) {
7017         return iterateCommentRanges(false, text, pos, true, cb, state);
7018     }
7019     ts.forEachTrailingCommentRange = forEachTrailingCommentRange;
7020     function reduceEachLeadingCommentRange(text, pos, cb, state, initial) {
7021         return iterateCommentRanges(true, text, pos, false, cb, state, initial);
7022     }
7023     ts.reduceEachLeadingCommentRange = reduceEachLeadingCommentRange;
7024     function reduceEachTrailingCommentRange(text, pos, cb, state, initial) {
7025         return iterateCommentRanges(true, text, pos, true, cb, state, initial);
7026     }
7027     ts.reduceEachTrailingCommentRange = reduceEachTrailingCommentRange;
7028     function appendCommentRange(pos, end, kind, hasTrailingNewLine, _state, comments) {
7029         if (!comments) {
7030             comments = [];
7031         }
7032         comments.push({ kind: kind, pos: pos, end: end, hasTrailingNewLine: hasTrailingNewLine });
7033         return comments;
7034     }
7035     function getLeadingCommentRanges(text, pos) {
7036         return reduceEachLeadingCommentRange(text, pos, appendCommentRange, undefined, undefined);
7037     }
7038     ts.getLeadingCommentRanges = getLeadingCommentRanges;
7039     function getTrailingCommentRanges(text, pos) {
7040         return reduceEachTrailingCommentRange(text, pos, appendCommentRange, undefined, undefined);
7041     }
7042     ts.getTrailingCommentRanges = getTrailingCommentRanges;
7043     function getShebang(text) {
7044         var match = shebangTriviaRegex.exec(text);
7045         if (match) {
7046             return match[0];
7047         }
7048     }
7049     ts.getShebang = getShebang;
7050     function isIdentifierStart(ch, languageVersion) {
7051         return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 ||
7052             ch === 36 || ch === 95 ||
7053             ch > 127 && isUnicodeIdentifierStart(ch, languageVersion);
7054     }
7055     ts.isIdentifierStart = isIdentifierStart;
7056     function isIdentifierPart(ch, languageVersion, identifierVariant) {
7057         return ch >= 65 && ch <= 90 || ch >= 97 && ch <= 122 ||
7058             ch >= 48 && ch <= 57 || ch === 36 || ch === 95 ||
7059             (identifierVariant === 1 ? (ch === 45 || ch === 58) : false) ||
7060             ch > 127 && isUnicodeIdentifierPart(ch, languageVersion);
7061     }
7062     ts.isIdentifierPart = isIdentifierPart;
7063     function isIdentifierText(name, languageVersion, identifierVariant) {
7064         var ch = codePointAt(name, 0);
7065         if (!isIdentifierStart(ch, languageVersion)) {
7066             return false;
7067         }
7068         for (var i = charSize(ch); i < name.length; i += charSize(ch)) {
7069             if (!isIdentifierPart(ch = codePointAt(name, i), languageVersion, identifierVariant)) {
7070                 return false;
7071             }
7072         }
7073         return true;
7074     }
7075     ts.isIdentifierText = isIdentifierText;
7076     function createScanner(languageVersion, skipTrivia, languageVariant, textInitial, onError, start, length) {
7077         if (languageVariant === void 0) { languageVariant = 0; }
7078         var text = textInitial;
7079         var pos;
7080         var end;
7081         var startPos;
7082         var tokenPos;
7083         var token;
7084         var tokenValue;
7085         var tokenFlags;
7086         var commentDirectives;
7087         var inJSDocType = 0;
7088         setText(text, start, length);
7089         var scanner = {
7090             getStartPos: function () { return startPos; },
7091             getTextPos: function () { return pos; },
7092             getToken: function () { return token; },
7093             getTokenPos: function () { return tokenPos; },
7094             getTokenText: function () { return text.substring(tokenPos, pos); },
7095             getTokenValue: function () { return tokenValue; },
7096             hasUnicodeEscape: function () { return (tokenFlags & 1024) !== 0; },
7097             hasExtendedUnicodeEscape: function () { return (tokenFlags & 8) !== 0; },
7098             hasPrecedingLineBreak: function () { return (tokenFlags & 1) !== 0; },
7099             hasPrecedingJSDocComment: function () { return (tokenFlags & 2) !== 0; },
7100             isIdentifier: function () { return token === 78 || token > 115; },
7101             isReservedWord: function () { return token >= 80 && token <= 115; },
7102             isUnterminated: function () { return (tokenFlags & 4) !== 0; },
7103             getCommentDirectives: function () { return commentDirectives; },
7104             getNumericLiteralFlags: function () { return tokenFlags & 1008; },
7105             getTokenFlags: function () { return tokenFlags; },
7106             reScanGreaterToken: reScanGreaterToken,
7107             reScanAsteriskEqualsToken: reScanAsteriskEqualsToken,
7108             reScanSlashToken: reScanSlashToken,
7109             reScanTemplateToken: reScanTemplateToken,
7110             reScanTemplateHeadOrNoSubstitutionTemplate: reScanTemplateHeadOrNoSubstitutionTemplate,
7111             scanJsxIdentifier: scanJsxIdentifier,
7112             scanJsxAttributeValue: scanJsxAttributeValue,
7113             reScanJsxAttributeValue: reScanJsxAttributeValue,
7114             reScanJsxToken: reScanJsxToken,
7115             reScanLessThanToken: reScanLessThanToken,
7116             reScanQuestionToken: reScanQuestionToken,
7117             reScanInvalidIdentifier: reScanInvalidIdentifier,
7118             scanJsxToken: scanJsxToken,
7119             scanJsDocToken: scanJsDocToken,
7120             scan: scan,
7121             getText: getText,
7122             clearCommentDirectives: clearCommentDirectives,
7123             setText: setText,
7124             setScriptTarget: setScriptTarget,
7125             setLanguageVariant: setLanguageVariant,
7126             setOnError: setOnError,
7127             setTextPos: setTextPos,
7128             setInJSDocType: setInJSDocType,
7129             tryScan: tryScan,
7130             lookAhead: lookAhead,
7131             scanRange: scanRange,
7132         };
7133         if (ts.Debug.isDebugging) {
7134             Object.defineProperty(scanner, "__debugShowCurrentPositionInText", {
7135                 get: function () {
7136                     var text = scanner.getText();
7137                     return text.slice(0, scanner.getStartPos()) + "â•‘" + text.slice(scanner.getStartPos());
7138                 },
7139             });
7140         }
7141         return scanner;
7142         function error(message, errPos, length) {
7143             if (errPos === void 0) { errPos = pos; }
7144             if (onError) {
7145                 var oldPos = pos;
7146                 pos = errPos;
7147                 onError(message, length || 0);
7148                 pos = oldPos;
7149             }
7150         }
7151         function scanNumberFragment() {
7152             var start = pos;
7153             var allowSeparator = false;
7154             var isPreviousTokenSeparator = false;
7155             var result = "";
7156             while (true) {
7157                 var ch = text.charCodeAt(pos);
7158                 if (ch === 95) {
7159                     tokenFlags |= 512;
7160                     if (allowSeparator) {
7161                         allowSeparator = false;
7162                         isPreviousTokenSeparator = true;
7163                         result += text.substring(start, pos);
7164                     }
7165                     else if (isPreviousTokenSeparator) {
7166                         error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
7167                     }
7168                     else {
7169                         error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
7170                     }
7171                     pos++;
7172                     start = pos;
7173                     continue;
7174                 }
7175                 if (isDigit(ch)) {
7176                     allowSeparator = true;
7177                     isPreviousTokenSeparator = false;
7178                     pos++;
7179                     continue;
7180                 }
7181                 break;
7182             }
7183             if (text.charCodeAt(pos - 1) === 95) {
7184                 error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
7185             }
7186             return result + text.substring(start, pos);
7187         }
7188         function scanNumber() {
7189             var start = pos;
7190             var mainFragment = scanNumberFragment();
7191             var decimalFragment;
7192             var scientificFragment;
7193             if (text.charCodeAt(pos) === 46) {
7194                 pos++;
7195                 decimalFragment = scanNumberFragment();
7196             }
7197             var end = pos;
7198             if (text.charCodeAt(pos) === 69 || text.charCodeAt(pos) === 101) {
7199                 pos++;
7200                 tokenFlags |= 16;
7201                 if (text.charCodeAt(pos) === 43 || text.charCodeAt(pos) === 45)
7202                     pos++;
7203                 var preNumericPart = pos;
7204                 var finalFragment = scanNumberFragment();
7205                 if (!finalFragment) {
7206                     error(ts.Diagnostics.Digit_expected);
7207                 }
7208                 else {
7209                     scientificFragment = text.substring(end, preNumericPart) + finalFragment;
7210                     end = pos;
7211                 }
7212             }
7213             var result;
7214             if (tokenFlags & 512) {
7215                 result = mainFragment;
7216                 if (decimalFragment) {
7217                     result += "." + decimalFragment;
7218                 }
7219                 if (scientificFragment) {
7220                     result += scientificFragment;
7221                 }
7222             }
7223             else {
7224                 result = text.substring(start, end);
7225             }
7226             if (decimalFragment !== undefined || tokenFlags & 16) {
7227                 checkForIdentifierStartAfterNumericLiteral(start, decimalFragment === undefined && !!(tokenFlags & 16));
7228                 return {
7229                     type: 8,
7230                     value: "" + +result
7231                 };
7232             }
7233             else {
7234                 tokenValue = result;
7235                 var type = checkBigIntSuffix();
7236                 checkForIdentifierStartAfterNumericLiteral(start);
7237                 return { type: type, value: tokenValue };
7238             }
7239         }
7240         function checkForIdentifierStartAfterNumericLiteral(numericStart, isScientific) {
7241             if (!isIdentifierStart(codePointAt(text, pos), languageVersion)) {
7242                 return;
7243             }
7244             var identifierStart = pos;
7245             var length = scanIdentifierParts().length;
7246             if (length === 1 && text[identifierStart] === "n") {
7247                 if (isScientific) {
7248                     error(ts.Diagnostics.A_bigint_literal_cannot_use_exponential_notation, numericStart, identifierStart - numericStart + 1);
7249                 }
7250                 else {
7251                     error(ts.Diagnostics.A_bigint_literal_must_be_an_integer, numericStart, identifierStart - numericStart + 1);
7252                 }
7253             }
7254             else {
7255                 error(ts.Diagnostics.An_identifier_or_keyword_cannot_immediately_follow_a_numeric_literal, identifierStart, length);
7256                 pos = identifierStart;
7257             }
7258         }
7259         function scanOctalDigits() {
7260             var start = pos;
7261             while (isOctalDigit(text.charCodeAt(pos))) {
7262                 pos++;
7263             }
7264             return +(text.substring(start, pos));
7265         }
7266         function scanExactNumberOfHexDigits(count, canHaveSeparators) {
7267             var valueString = scanHexDigits(count, false, canHaveSeparators);
7268             return valueString ? parseInt(valueString, 16) : -1;
7269         }
7270         function scanMinimumNumberOfHexDigits(count, canHaveSeparators) {
7271             return scanHexDigits(count, true, canHaveSeparators);
7272         }
7273         function scanHexDigits(minCount, scanAsManyAsPossible, canHaveSeparators) {
7274             var valueChars = [];
7275             var allowSeparator = false;
7276             var isPreviousTokenSeparator = false;
7277             while (valueChars.length < minCount || scanAsManyAsPossible) {
7278                 var ch = text.charCodeAt(pos);
7279                 if (canHaveSeparators && ch === 95) {
7280                     tokenFlags |= 512;
7281                     if (allowSeparator) {
7282                         allowSeparator = false;
7283                         isPreviousTokenSeparator = true;
7284                     }
7285                     else if (isPreviousTokenSeparator) {
7286                         error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
7287                     }
7288                     else {
7289                         error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
7290                     }
7291                     pos++;
7292                     continue;
7293                 }
7294                 allowSeparator = canHaveSeparators;
7295                 if (ch >= 65 && ch <= 70) {
7296                     ch += 97 - 65;
7297                 }
7298                 else if (!((ch >= 48 && ch <= 57) ||
7299                     (ch >= 97 && ch <= 102))) {
7300                     break;
7301                 }
7302                 valueChars.push(ch);
7303                 pos++;
7304                 isPreviousTokenSeparator = false;
7305             }
7306             if (valueChars.length < minCount) {
7307                 valueChars = [];
7308             }
7309             if (text.charCodeAt(pos - 1) === 95) {
7310                 error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
7311             }
7312             return String.fromCharCode.apply(String, valueChars);
7313         }
7314         function scanString(jsxAttributeString) {
7315             if (jsxAttributeString === void 0) { jsxAttributeString = false; }
7316             var quote = text.charCodeAt(pos);
7317             pos++;
7318             var result = "";
7319             var start = pos;
7320             while (true) {
7321                 if (pos >= end) {
7322                     result += text.substring(start, pos);
7323                     tokenFlags |= 4;
7324                     error(ts.Diagnostics.Unterminated_string_literal);
7325                     break;
7326                 }
7327                 var ch = text.charCodeAt(pos);
7328                 if (ch === quote) {
7329                     result += text.substring(start, pos);
7330                     pos++;
7331                     break;
7332                 }
7333                 if (ch === 92 && !jsxAttributeString) {
7334                     result += text.substring(start, pos);
7335                     result += scanEscapeSequence();
7336                     start = pos;
7337                     continue;
7338                 }
7339                 if (isLineBreak(ch) && !jsxAttributeString) {
7340                     result += text.substring(start, pos);
7341                     tokenFlags |= 4;
7342                     error(ts.Diagnostics.Unterminated_string_literal);
7343                     break;
7344                 }
7345                 pos++;
7346             }
7347             return result;
7348         }
7349         function scanTemplateAndSetTokenValue(isTaggedTemplate) {
7350             var startedWithBacktick = text.charCodeAt(pos) === 96;
7351             pos++;
7352             var start = pos;
7353             var contents = "";
7354             var resultingToken;
7355             while (true) {
7356                 if (pos >= end) {
7357                     contents += text.substring(start, pos);
7358                     tokenFlags |= 4;
7359                     error(ts.Diagnostics.Unterminated_template_literal);
7360                     resultingToken = startedWithBacktick ? 14 : 17;
7361                     break;
7362                 }
7363                 var currChar = text.charCodeAt(pos);
7364                 if (currChar === 96) {
7365                     contents += text.substring(start, pos);
7366                     pos++;
7367                     resultingToken = startedWithBacktick ? 14 : 17;
7368                     break;
7369                 }
7370                 if (currChar === 36 && pos + 1 < end && text.charCodeAt(pos + 1) === 123) {
7371                     contents += text.substring(start, pos);
7372                     pos += 2;
7373                     resultingToken = startedWithBacktick ? 15 : 16;
7374                     break;
7375                 }
7376                 if (currChar === 92) {
7377                     contents += text.substring(start, pos);
7378                     contents += scanEscapeSequence(isTaggedTemplate);
7379                     start = pos;
7380                     continue;
7381                 }
7382                 if (currChar === 13) {
7383                     contents += text.substring(start, pos);
7384                     pos++;
7385                     if (pos < end && text.charCodeAt(pos) === 10) {
7386                         pos++;
7387                     }
7388                     contents += "\n";
7389                     start = pos;
7390                     continue;
7391                 }
7392                 pos++;
7393             }
7394             ts.Debug.assert(resultingToken !== undefined);
7395             tokenValue = contents;
7396             return resultingToken;
7397         }
7398         function scanEscapeSequence(isTaggedTemplate) {
7399             var start = pos;
7400             pos++;
7401             if (pos >= end) {
7402                 error(ts.Diagnostics.Unexpected_end_of_text);
7403                 return "";
7404             }
7405             var ch = text.charCodeAt(pos);
7406             pos++;
7407             switch (ch) {
7408                 case 48:
7409                     if (isTaggedTemplate && pos < end && isDigit(text.charCodeAt(pos))) {
7410                         pos++;
7411                         tokenFlags |= 2048;
7412                         return text.substring(start, pos);
7413                     }
7414                     return "\0";
7415                 case 98:
7416                     return "\b";
7417                 case 116:
7418                     return "\t";
7419                 case 110:
7420                     return "\n";
7421                 case 118:
7422                     return "\v";
7423                 case 102:
7424                     return "\f";
7425                 case 114:
7426                     return "\r";
7427                 case 39:
7428                     return "\'";
7429                 case 34:
7430                     return "\"";
7431                 case 117:
7432                     if (isTaggedTemplate) {
7433                         for (var escapePos = pos; escapePos < pos + 4; escapePos++) {
7434                             if (escapePos < end && !isHexDigit(text.charCodeAt(escapePos)) && text.charCodeAt(escapePos) !== 123) {
7435                                 pos = escapePos;
7436                                 tokenFlags |= 2048;
7437                                 return text.substring(start, pos);
7438                             }
7439                         }
7440                     }
7441                     if (pos < end && text.charCodeAt(pos) === 123) {
7442                         pos++;
7443                         if (isTaggedTemplate && !isHexDigit(text.charCodeAt(pos))) {
7444                             tokenFlags |= 2048;
7445                             return text.substring(start, pos);
7446                         }
7447                         if (isTaggedTemplate) {
7448                             var savePos = pos;
7449                             var escapedValueString = scanMinimumNumberOfHexDigits(1, false);
7450                             var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
7451                             if (!isCodePoint(escapedValue) || text.charCodeAt(pos) !== 125) {
7452                                 tokenFlags |= 2048;
7453                                 return text.substring(start, pos);
7454                             }
7455                             else {
7456                                 pos = savePos;
7457                             }
7458                         }
7459                         tokenFlags |= 8;
7460                         return scanExtendedUnicodeEscape();
7461                     }
7462                     tokenFlags |= 1024;
7463                     return scanHexadecimalEscape(4);
7464                 case 120:
7465                     if (isTaggedTemplate) {
7466                         if (!isHexDigit(text.charCodeAt(pos))) {
7467                             tokenFlags |= 2048;
7468                             return text.substring(start, pos);
7469                         }
7470                         else if (!isHexDigit(text.charCodeAt(pos + 1))) {
7471                             pos++;
7472                             tokenFlags |= 2048;
7473                             return text.substring(start, pos);
7474                         }
7475                     }
7476                     return scanHexadecimalEscape(2);
7477                 case 13:
7478                     if (pos < end && text.charCodeAt(pos) === 10) {
7479                         pos++;
7480                     }
7481                 case 10:
7482                 case 8232:
7483                 case 8233:
7484                     return "";
7485                 default:
7486                     return String.fromCharCode(ch);
7487             }
7488         }
7489         function scanHexadecimalEscape(numDigits) {
7490             var escapedValue = scanExactNumberOfHexDigits(numDigits, false);
7491             if (escapedValue >= 0) {
7492                 return String.fromCharCode(escapedValue);
7493             }
7494             else {
7495                 error(ts.Diagnostics.Hexadecimal_digit_expected);
7496                 return "";
7497             }
7498         }
7499         function scanExtendedUnicodeEscape() {
7500             var escapedValueString = scanMinimumNumberOfHexDigits(1, false);
7501             var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
7502             var isInvalidExtendedEscape = false;
7503             if (escapedValue < 0) {
7504                 error(ts.Diagnostics.Hexadecimal_digit_expected);
7505                 isInvalidExtendedEscape = true;
7506             }
7507             else if (escapedValue > 0x10FFFF) {
7508                 error(ts.Diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive);
7509                 isInvalidExtendedEscape = true;
7510             }
7511             if (pos >= end) {
7512                 error(ts.Diagnostics.Unexpected_end_of_text);
7513                 isInvalidExtendedEscape = true;
7514             }
7515             else if (text.charCodeAt(pos) === 125) {
7516                 pos++;
7517             }
7518             else {
7519                 error(ts.Diagnostics.Unterminated_Unicode_escape_sequence);
7520                 isInvalidExtendedEscape = true;
7521             }
7522             if (isInvalidExtendedEscape) {
7523                 return "";
7524             }
7525             return utf16EncodeAsString(escapedValue);
7526         }
7527         function peekUnicodeEscape() {
7528             if (pos + 5 < end && text.charCodeAt(pos + 1) === 117) {
7529                 var start_1 = pos;
7530                 pos += 2;
7531                 var value = scanExactNumberOfHexDigits(4, false);
7532                 pos = start_1;
7533                 return value;
7534             }
7535             return -1;
7536         }
7537         function peekExtendedUnicodeEscape() {
7538             if (languageVersion >= 2 && codePointAt(text, pos + 1) === 117 && codePointAt(text, pos + 2) === 123) {
7539                 var start_2 = pos;
7540                 pos += 3;
7541                 var escapedValueString = scanMinimumNumberOfHexDigits(1, false);
7542                 var escapedValue = escapedValueString ? parseInt(escapedValueString, 16) : -1;
7543                 pos = start_2;
7544                 return escapedValue;
7545             }
7546             return -1;
7547         }
7548         function scanIdentifierParts() {
7549             var result = "";
7550             var start = pos;
7551             while (pos < end) {
7552                 var ch = codePointAt(text, pos);
7553                 if (isIdentifierPart(ch, languageVersion)) {
7554                     pos += charSize(ch);
7555                 }
7556                 else if (ch === 92) {
7557                     ch = peekExtendedUnicodeEscape();
7558                     if (ch >= 0 && isIdentifierPart(ch, languageVersion)) {
7559                         pos += 3;
7560                         tokenFlags |= 8;
7561                         result += scanExtendedUnicodeEscape();
7562                         start = pos;
7563                         continue;
7564                     }
7565                     ch = peekUnicodeEscape();
7566                     if (!(ch >= 0 && isIdentifierPart(ch, languageVersion))) {
7567                         break;
7568                     }
7569                     tokenFlags |= 1024;
7570                     result += text.substring(start, pos);
7571                     result += utf16EncodeAsString(ch);
7572                     pos += 6;
7573                     start = pos;
7574                 }
7575                 else {
7576                     break;
7577                 }
7578             }
7579             result += text.substring(start, pos);
7580             return result;
7581         }
7582         function getIdentifierToken() {
7583             var len = tokenValue.length;
7584             if (len >= 2 && len <= 12) {
7585                 var ch = tokenValue.charCodeAt(0);
7586                 if (ch >= 97 && ch <= 122) {
7587                     var keyword = textToKeyword.get(tokenValue);
7588                     if (keyword !== undefined) {
7589                         return token = keyword;
7590                     }
7591                 }
7592             }
7593             return token = 78;
7594         }
7595         function scanBinaryOrOctalDigits(base) {
7596             var value = "";
7597             var separatorAllowed = false;
7598             var isPreviousTokenSeparator = false;
7599             while (true) {
7600                 var ch = text.charCodeAt(pos);
7601                 if (ch === 95) {
7602                     tokenFlags |= 512;
7603                     if (separatorAllowed) {
7604                         separatorAllowed = false;
7605                         isPreviousTokenSeparator = true;
7606                     }
7607                     else if (isPreviousTokenSeparator) {
7608                         error(ts.Diagnostics.Multiple_consecutive_numeric_separators_are_not_permitted, pos, 1);
7609                     }
7610                     else {
7611                         error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos, 1);
7612                     }
7613                     pos++;
7614                     continue;
7615                 }
7616                 separatorAllowed = true;
7617                 if (!isDigit(ch) || ch - 48 >= base) {
7618                     break;
7619                 }
7620                 value += text[pos];
7621                 pos++;
7622                 isPreviousTokenSeparator = false;
7623             }
7624             if (text.charCodeAt(pos - 1) === 95) {
7625                 error(ts.Diagnostics.Numeric_separators_are_not_allowed_here, pos - 1, 1);
7626             }
7627             return value;
7628         }
7629         function checkBigIntSuffix() {
7630             if (text.charCodeAt(pos) === 110) {
7631                 tokenValue += "n";
7632                 if (tokenFlags & 384) {
7633                     tokenValue = ts.parsePseudoBigInt(tokenValue) + "n";
7634                 }
7635                 pos++;
7636                 return 9;
7637             }
7638             else {
7639                 var numericValue = tokenFlags & 128
7640                     ? parseInt(tokenValue.slice(2), 2)
7641                     : tokenFlags & 256
7642                         ? parseInt(tokenValue.slice(2), 8)
7643                         : +tokenValue;
7644                 tokenValue = "" + numericValue;
7645                 return 8;
7646             }
7647         }
7648         function scan() {
7649             var _a;
7650             startPos = pos;
7651             tokenFlags = 0;
7652             var asteriskSeen = false;
7653             while (true) {
7654                 tokenPos = pos;
7655                 if (pos >= end) {
7656                     return token = 1;
7657                 }
7658                 var ch = codePointAt(text, pos);
7659                 if (ch === 35 && pos === 0 && isShebangTrivia(text, pos)) {
7660                     pos = scanShebangTrivia(text, pos);
7661                     if (skipTrivia) {
7662                         continue;
7663                     }
7664                     else {
7665                         return token = 6;
7666                     }
7667                 }
7668                 switch (ch) {
7669                     case 10:
7670                     case 13:
7671                         tokenFlags |= 1;
7672                         if (skipTrivia) {
7673                             pos++;
7674                             continue;
7675                         }
7676                         else {
7677                             if (ch === 13 && pos + 1 < end && text.charCodeAt(pos + 1) === 10) {
7678                                 pos += 2;
7679                             }
7680                             else {
7681                                 pos++;
7682                             }
7683                             return token = 4;
7684                         }
7685                     case 9:
7686                     case 11:
7687                     case 12:
7688                     case 32:
7689                     case 160:
7690                     case 5760:
7691                     case 8192:
7692                     case 8193:
7693                     case 8194:
7694                     case 8195:
7695                     case 8196:
7696                     case 8197:
7697                     case 8198:
7698                     case 8199:
7699                     case 8200:
7700                     case 8201:
7701                     case 8202:
7702                     case 8203:
7703                     case 8239:
7704                     case 8287:
7705                     case 12288:
7706                     case 65279:
7707                         if (skipTrivia) {
7708                             pos++;
7709                             continue;
7710                         }
7711                         else {
7712                             while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) {
7713                                 pos++;
7714                             }
7715                             return token = 5;
7716                         }
7717                     case 33:
7718                         if (text.charCodeAt(pos + 1) === 61) {
7719                             if (text.charCodeAt(pos + 2) === 61) {
7720                                 return pos += 3, token = 37;
7721                             }
7722                             return pos += 2, token = 35;
7723                         }
7724                         pos++;
7725                         return token = 53;
7726                     case 34:
7727                     case 39:
7728                         tokenValue = scanString();
7729                         return token = 10;
7730                     case 96:
7731                         return token = scanTemplateAndSetTokenValue(false);
7732                     case 37:
7733                         if (text.charCodeAt(pos + 1) === 61) {
7734                             return pos += 2, token = 68;
7735                         }
7736                         pos++;
7737                         return token = 44;
7738                     case 38:
7739                         if (text.charCodeAt(pos + 1) === 38) {
7740                             if (text.charCodeAt(pos + 2) === 61) {
7741                                 return pos += 3, token = 75;
7742                             }
7743                             return pos += 2, token = 55;
7744                         }
7745                         if (text.charCodeAt(pos + 1) === 61) {
7746                             return pos += 2, token = 72;
7747                         }
7748                         pos++;
7749                         return token = 50;
7750                     case 40:
7751                         pos++;
7752                         return token = 20;
7753                     case 41:
7754                         pos++;
7755                         return token = 21;
7756                     case 42:
7757                         if (text.charCodeAt(pos + 1) === 61) {
7758                             return pos += 2, token = 65;
7759                         }
7760                         if (text.charCodeAt(pos + 1) === 42) {
7761                             if (text.charCodeAt(pos + 2) === 61) {
7762                                 return pos += 3, token = 66;
7763                             }
7764                             return pos += 2, token = 42;
7765                         }
7766                         pos++;
7767                         if (inJSDocType && !asteriskSeen && (tokenFlags & 1)) {
7768                             asteriskSeen = true;
7769                             continue;
7770                         }
7771                         return token = 41;
7772                     case 43:
7773                         if (text.charCodeAt(pos + 1) === 43) {
7774                             return pos += 2, token = 45;
7775                         }
7776                         if (text.charCodeAt(pos + 1) === 61) {
7777                             return pos += 2, token = 63;
7778                         }
7779                         pos++;
7780                         return token = 39;
7781                     case 44:
7782                         pos++;
7783                         return token = 27;
7784                     case 45:
7785                         if (text.charCodeAt(pos + 1) === 45) {
7786                             return pos += 2, token = 46;
7787                         }
7788                         if (text.charCodeAt(pos + 1) === 61) {
7789                             return pos += 2, token = 64;
7790                         }
7791                         pos++;
7792                         return token = 40;
7793                     case 46:
7794                         if (isDigit(text.charCodeAt(pos + 1))) {
7795                             tokenValue = scanNumber().value;
7796                             return token = 8;
7797                         }
7798                         if (text.charCodeAt(pos + 1) === 46 && text.charCodeAt(pos + 2) === 46) {
7799                             return pos += 3, token = 25;
7800                         }
7801                         pos++;
7802                         return token = 24;
7803                     case 47:
7804                         if (text.charCodeAt(pos + 1) === 47) {
7805                             pos += 2;
7806                             while (pos < end) {
7807                                 if (isLineBreak(text.charCodeAt(pos))) {
7808                                     break;
7809                                 }
7810                                 pos++;
7811                             }
7812                             commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(tokenPos, pos), commentDirectiveRegExSingleLine, tokenPos);
7813                             if (skipTrivia) {
7814                                 continue;
7815                             }
7816                             else {
7817                                 return token = 2;
7818                             }
7819                         }
7820                         if (text.charCodeAt(pos + 1) === 42) {
7821                             pos += 2;
7822                             if (text.charCodeAt(pos) === 42 && text.charCodeAt(pos + 1) !== 47) {
7823                                 tokenFlags |= 2;
7824                             }
7825                             var commentClosed = false;
7826                             var lastLineStart = tokenPos;
7827                             while (pos < end) {
7828                                 var ch_1 = text.charCodeAt(pos);
7829                                 if (ch_1 === 42 && text.charCodeAt(pos + 1) === 47) {
7830                                     pos += 2;
7831                                     commentClosed = true;
7832                                     break;
7833                                 }
7834                                 pos++;
7835                                 if (isLineBreak(ch_1)) {
7836                                     lastLineStart = pos;
7837                                     tokenFlags |= 1;
7838                                 }
7839                             }
7840                             commentDirectives = appendIfCommentDirective(commentDirectives, text.slice(lastLineStart, pos), commentDirectiveRegExMultiLine, lastLineStart);
7841                             if (!commentClosed) {
7842                                 error(ts.Diagnostics.Asterisk_Slash_expected);
7843                             }
7844                             if (skipTrivia) {
7845                                 continue;
7846                             }
7847                             else {
7848                                 if (!commentClosed) {
7849                                     tokenFlags |= 4;
7850                                 }
7851                                 return token = 3;
7852                             }
7853                         }
7854                         if (text.charCodeAt(pos + 1) === 61) {
7855                             return pos += 2, token = 67;
7856                         }
7857                         pos++;
7858                         return token = 43;
7859                     case 48:
7860                         if (pos + 2 < end && (text.charCodeAt(pos + 1) === 88 || text.charCodeAt(pos + 1) === 120)) {
7861                             pos += 2;
7862                             tokenValue = scanMinimumNumberOfHexDigits(1, true);
7863                             if (!tokenValue) {
7864                                 error(ts.Diagnostics.Hexadecimal_digit_expected);
7865                                 tokenValue = "0";
7866                             }
7867                             tokenValue = "0x" + tokenValue;
7868                             tokenFlags |= 64;
7869                             return token = checkBigIntSuffix();
7870                         }
7871                         else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 66 || text.charCodeAt(pos + 1) === 98)) {
7872                             pos += 2;
7873                             tokenValue = scanBinaryOrOctalDigits(2);
7874                             if (!tokenValue) {
7875                                 error(ts.Diagnostics.Binary_digit_expected);
7876                                 tokenValue = "0";
7877                             }
7878                             tokenValue = "0b" + tokenValue;
7879                             tokenFlags |= 128;
7880                             return token = checkBigIntSuffix();
7881                         }
7882                         else if (pos + 2 < end && (text.charCodeAt(pos + 1) === 79 || text.charCodeAt(pos + 1) === 111)) {
7883                             pos += 2;
7884                             tokenValue = scanBinaryOrOctalDigits(8);
7885                             if (!tokenValue) {
7886                                 error(ts.Diagnostics.Octal_digit_expected);
7887                                 tokenValue = "0";
7888                             }
7889                             tokenValue = "0o" + tokenValue;
7890                             tokenFlags |= 256;
7891                             return token = checkBigIntSuffix();
7892                         }
7893                         if (pos + 1 < end && isOctalDigit(text.charCodeAt(pos + 1))) {
7894                             tokenValue = "" + scanOctalDigits();
7895                             tokenFlags |= 32;
7896                             return token = 8;
7897                         }
7898                     case 49:
7899                     case 50:
7900                     case 51:
7901                     case 52:
7902                     case 53:
7903                     case 54:
7904                     case 55:
7905                     case 56:
7906                     case 57:
7907                         (_a = scanNumber(), token = _a.type, tokenValue = _a.value);
7908                         return token;
7909                     case 58:
7910                         pos++;
7911                         return token = 58;
7912                     case 59:
7913                         pos++;
7914                         return token = 26;
7915                     case 60:
7916                         if (isConflictMarkerTrivia(text, pos)) {
7917                             pos = scanConflictMarkerTrivia(text, pos, error);
7918                             if (skipTrivia) {
7919                                 continue;
7920                             }
7921                             else {
7922                                 return token = 7;
7923                             }
7924                         }
7925                         if (text.charCodeAt(pos + 1) === 60) {
7926                             if (text.charCodeAt(pos + 2) === 61) {
7927                                 return pos += 3, token = 69;
7928                             }
7929                             return pos += 2, token = 47;
7930                         }
7931                         if (text.charCodeAt(pos + 1) === 61) {
7932                             return pos += 2, token = 32;
7933                         }
7934                         if (languageVariant === 1 &&
7935                             text.charCodeAt(pos + 1) === 47 &&
7936                             text.charCodeAt(pos + 2) !== 42) {
7937                             return pos += 2, token = 30;
7938                         }
7939                         pos++;
7940                         return token = 29;
7941                     case 61:
7942                         if (isConflictMarkerTrivia(text, pos)) {
7943                             pos = scanConflictMarkerTrivia(text, pos, error);
7944                             if (skipTrivia) {
7945                                 continue;
7946                             }
7947                             else {
7948                                 return token = 7;
7949                             }
7950                         }
7951                         if (text.charCodeAt(pos + 1) === 61) {
7952                             if (text.charCodeAt(pos + 2) === 61) {
7953                                 return pos += 3, token = 36;
7954                             }
7955                             return pos += 2, token = 34;
7956                         }
7957                         if (text.charCodeAt(pos + 1) === 62) {
7958                             return pos += 2, token = 38;
7959                         }
7960                         pos++;
7961                         return token = 62;
7962                     case 62:
7963                         if (isConflictMarkerTrivia(text, pos)) {
7964                             pos = scanConflictMarkerTrivia(text, pos, error);
7965                             if (skipTrivia) {
7966                                 continue;
7967                             }
7968                             else {
7969                                 return token = 7;
7970                             }
7971                         }
7972                         pos++;
7973                         return token = 31;
7974                     case 63:
7975                         if (text.charCodeAt(pos + 1) === 46 && !isDigit(text.charCodeAt(pos + 2))) {
7976                             return pos += 2, token = 28;
7977                         }
7978                         if (text.charCodeAt(pos + 1) === 63) {
7979                             if (text.charCodeAt(pos + 2) === 61) {
7980                                 return pos += 3, token = 76;
7981                             }
7982                             return pos += 2, token = 60;
7983                         }
7984                         pos++;
7985                         return token = 57;
7986                     case 91:
7987                         pos++;
7988                         return token = 22;
7989                     case 93:
7990                         pos++;
7991                         return token = 23;
7992                     case 94:
7993                         if (text.charCodeAt(pos + 1) === 61) {
7994                             return pos += 2, token = 77;
7995                         }
7996                         pos++;
7997                         return token = 52;
7998                     case 123:
7999                         pos++;
8000                         return token = 18;
8001                     case 124:
8002                         if (isConflictMarkerTrivia(text, pos)) {
8003                             pos = scanConflictMarkerTrivia(text, pos, error);
8004                             if (skipTrivia) {
8005                                 continue;
8006                             }
8007                             else {
8008                                 return token = 7;
8009                             }
8010                         }
8011                         if (text.charCodeAt(pos + 1) === 124) {
8012                             if (text.charCodeAt(pos + 2) === 61) {
8013                                 return pos += 3, token = 74;
8014                             }
8015                             return pos += 2, token = 56;
8016                         }
8017                         if (text.charCodeAt(pos + 1) === 61) {
8018                             return pos += 2, token = 73;
8019                         }
8020                         pos++;
8021                         return token = 51;
8022                     case 125:
8023                         pos++;
8024                         return token = 19;
8025                     case 126:
8026                         pos++;
8027                         return token = 54;
8028                     case 64:
8029                         pos++;
8030                         return token = 59;
8031                     case 92:
8032                         var extendedCookedChar = peekExtendedUnicodeEscape();
8033                         if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) {
8034                             pos += 3;
8035                             tokenFlags |= 8;
8036                             tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts();
8037                             return token = getIdentifierToken();
8038                         }
8039                         var cookedChar = peekUnicodeEscape();
8040                         if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) {
8041                             pos += 6;
8042                             tokenFlags |= 1024;
8043                             tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
8044                             return token = getIdentifierToken();
8045                         }
8046                         error(ts.Diagnostics.Invalid_character);
8047                         pos++;
8048                         return token = 0;
8049                     case 35:
8050                         if (pos !== 0 && text[pos + 1] === "!") {
8051                             error(ts.Diagnostics.can_only_be_used_at_the_start_of_a_file);
8052                             pos++;
8053                             return token = 0;
8054                         }
8055                         pos++;
8056                         if (isIdentifierStart(ch = text.charCodeAt(pos), languageVersion)) {
8057                             pos++;
8058                             while (pos < end && isIdentifierPart(ch = text.charCodeAt(pos), languageVersion))
8059                                 pos++;
8060                             tokenValue = text.substring(tokenPos, pos);
8061                             if (ch === 92) {
8062                                 tokenValue += scanIdentifierParts();
8063                             }
8064                         }
8065                         else {
8066                             tokenValue = "#";
8067                             error(ts.Diagnostics.Invalid_character);
8068                         }
8069                         return token = 79;
8070                     default:
8071                         var identifierKind = scanIdentifier(ch, languageVersion);
8072                         if (identifierKind) {
8073                             return token = identifierKind;
8074                         }
8075                         else if (isWhiteSpaceSingleLine(ch)) {
8076                             pos += charSize(ch);
8077                             continue;
8078                         }
8079                         else if (isLineBreak(ch)) {
8080                             tokenFlags |= 1;
8081                             pos += charSize(ch);
8082                             continue;
8083                         }
8084                         error(ts.Diagnostics.Invalid_character);
8085                         pos += charSize(ch);
8086                         return token = 0;
8087                 }
8088             }
8089         }
8090         function reScanInvalidIdentifier() {
8091             ts.Debug.assert(token === 0, "'reScanInvalidIdentifier' should only be called when the current token is 'SyntaxKind.Unknown'.");
8092             pos = tokenPos = startPos;
8093             tokenFlags = 0;
8094             var ch = codePointAt(text, pos);
8095             var identifierKind = scanIdentifier(ch, 99);
8096             if (identifierKind) {
8097                 return token = identifierKind;
8098             }
8099             pos += charSize(ch);
8100             return token;
8101         }
8102         function scanIdentifier(startCharacter, languageVersion) {
8103             var ch = startCharacter;
8104             if (isIdentifierStart(ch, languageVersion)) {
8105                 pos += charSize(ch);
8106                 while (pos < end && isIdentifierPart(ch = codePointAt(text, pos), languageVersion))
8107                     pos += charSize(ch);
8108                 tokenValue = text.substring(tokenPos, pos);
8109                 if (ch === 92) {
8110                     tokenValue += scanIdentifierParts();
8111                 }
8112                 return getIdentifierToken();
8113             }
8114         }
8115         function reScanGreaterToken() {
8116             if (token === 31) {
8117                 if (text.charCodeAt(pos) === 62) {
8118                     if (text.charCodeAt(pos + 1) === 62) {
8119                         if (text.charCodeAt(pos + 2) === 61) {
8120                             return pos += 3, token = 71;
8121                         }
8122                         return pos += 2, token = 49;
8123                     }
8124                     if (text.charCodeAt(pos + 1) === 61) {
8125                         return pos += 2, token = 70;
8126                     }
8127                     pos++;
8128                     return token = 48;
8129                 }
8130                 if (text.charCodeAt(pos) === 61) {
8131                     pos++;
8132                     return token = 33;
8133                 }
8134             }
8135             return token;
8136         }
8137         function reScanAsteriskEqualsToken() {
8138             ts.Debug.assert(token === 65, "'reScanAsteriskEqualsToken' should only be called on a '*='");
8139             pos = tokenPos + 1;
8140             return token = 62;
8141         }
8142         function reScanSlashToken() {
8143             if (token === 43 || token === 67) {
8144                 var p = tokenPos + 1;
8145                 var inEscape = false;
8146                 var inCharacterClass = false;
8147                 while (true) {
8148                     if (p >= end) {
8149                         tokenFlags |= 4;
8150                         error(ts.Diagnostics.Unterminated_regular_expression_literal);
8151                         break;
8152                     }
8153                     var ch = text.charCodeAt(p);
8154                     if (isLineBreak(ch)) {
8155                         tokenFlags |= 4;
8156                         error(ts.Diagnostics.Unterminated_regular_expression_literal);
8157                         break;
8158                     }
8159                     if (inEscape) {
8160                         inEscape = false;
8161                     }
8162                     else if (ch === 47 && !inCharacterClass) {
8163                         p++;
8164                         break;
8165                     }
8166                     else if (ch === 91) {
8167                         inCharacterClass = true;
8168                     }
8169                     else if (ch === 92) {
8170                         inEscape = true;
8171                     }
8172                     else if (ch === 93) {
8173                         inCharacterClass = false;
8174                     }
8175                     p++;
8176                 }
8177                 while (p < end && isIdentifierPart(text.charCodeAt(p), languageVersion)) {
8178                     p++;
8179                 }
8180                 pos = p;
8181                 tokenValue = text.substring(tokenPos, pos);
8182                 token = 13;
8183             }
8184             return token;
8185         }
8186         function appendIfCommentDirective(commentDirectives, text, commentDirectiveRegEx, lineStart) {
8187             var type = getDirectiveFromComment(text, commentDirectiveRegEx);
8188             if (type === undefined) {
8189                 return commentDirectives;
8190             }
8191             return ts.append(commentDirectives, {
8192                 range: { pos: lineStart, end: pos },
8193                 type: type,
8194             });
8195         }
8196         function getDirectiveFromComment(text, commentDirectiveRegEx) {
8197             var match = commentDirectiveRegEx.exec(text);
8198             if (!match) {
8199                 return undefined;
8200             }
8201             switch (match[1]) {
8202                 case "ts-expect-error":
8203                     return 0;
8204                 case "ts-ignore":
8205                     return 1;
8206             }
8207             return undefined;
8208         }
8209         function reScanTemplateToken(isTaggedTemplate) {
8210             ts.Debug.assert(token === 19, "'reScanTemplateToken' should only be called on a '}'");
8211             pos = tokenPos;
8212             return token = scanTemplateAndSetTokenValue(isTaggedTemplate);
8213         }
8214         function reScanTemplateHeadOrNoSubstitutionTemplate() {
8215             pos = tokenPos;
8216             return token = scanTemplateAndSetTokenValue(true);
8217         }
8218         function reScanJsxToken() {
8219             pos = tokenPos = startPos;
8220             return token = scanJsxToken();
8221         }
8222         function reScanLessThanToken() {
8223             if (token === 47) {
8224                 pos = tokenPos + 1;
8225                 return token = 29;
8226             }
8227             return token;
8228         }
8229         function reScanQuestionToken() {
8230             ts.Debug.assert(token === 60, "'reScanQuestionToken' should only be called on a '??'");
8231             pos = tokenPos + 1;
8232             return token = 57;
8233         }
8234         function scanJsxToken() {
8235             startPos = tokenPos = pos;
8236             if (pos >= end) {
8237                 return token = 1;
8238             }
8239             var char = text.charCodeAt(pos);
8240             if (char === 60) {
8241                 if (text.charCodeAt(pos + 1) === 47) {
8242                     pos += 2;
8243                     return token = 30;
8244                 }
8245                 pos++;
8246                 return token = 29;
8247             }
8248             if (char === 123) {
8249                 pos++;
8250                 return token = 18;
8251             }
8252             var firstNonWhitespace = 0;
8253             var lastNonWhitespace = -1;
8254             while (pos < end) {
8255                 if (!isWhiteSpaceSingleLine(char)) {
8256                     lastNonWhitespace = pos;
8257                 }
8258                 char = text.charCodeAt(pos);
8259                 if (char === 123) {
8260                     break;
8261                 }
8262                 if (char === 60) {
8263                     if (isConflictMarkerTrivia(text, pos)) {
8264                         pos = scanConflictMarkerTrivia(text, pos, error);
8265                         return token = 7;
8266                     }
8267                     break;
8268                 }
8269                 if (char === 62) {
8270                     error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_gt, pos, 1);
8271                 }
8272                 if (char === 125) {
8273                     error(ts.Diagnostics.Unexpected_token_Did_you_mean_or_rbrace, pos, 1);
8274                 }
8275                 if (lastNonWhitespace > 0)
8276                     lastNonWhitespace++;
8277                 if (isLineBreak(char) && firstNonWhitespace === 0) {
8278                     firstNonWhitespace = -1;
8279                 }
8280                 else if (!isWhiteSpaceLike(char)) {
8281                     firstNonWhitespace = pos;
8282                 }
8283                 pos++;
8284             }
8285             var endPosition = lastNonWhitespace === -1 ? pos : lastNonWhitespace;
8286             tokenValue = text.substring(startPos, endPosition);
8287             return firstNonWhitespace === -1 ? 12 : 11;
8288         }
8289         function scanJsxIdentifier() {
8290             if (tokenIsIdentifierOrKeyword(token)) {
8291                 var namespaceSeparator = false;
8292                 while (pos < end) {
8293                     var ch = text.charCodeAt(pos);
8294                     if (ch === 45) {
8295                         tokenValue += "-";
8296                         pos++;
8297                         continue;
8298                     }
8299                     else if (ch === 58 && !namespaceSeparator) {
8300                         tokenValue += ":";
8301                         pos++;
8302                         namespaceSeparator = true;
8303                         continue;
8304                     }
8305                     var oldPos = pos;
8306                     tokenValue += scanIdentifierParts();
8307                     if (pos === oldPos) {
8308                         break;
8309                     }
8310                 }
8311                 if (tokenValue.slice(-1) === ":") {
8312                     tokenValue = tokenValue.slice(0, -1);
8313                     pos--;
8314                 }
8315             }
8316             return token;
8317         }
8318         function scanJsxAttributeValue() {
8319             startPos = pos;
8320             switch (text.charCodeAt(pos)) {
8321                 case 34:
8322                 case 39:
8323                     tokenValue = scanString(true);
8324                     return token = 10;
8325                 default:
8326                     return scan();
8327             }
8328         }
8329         function reScanJsxAttributeValue() {
8330             pos = tokenPos = startPos;
8331             return scanJsxAttributeValue();
8332         }
8333         function scanJsDocToken() {
8334             startPos = tokenPos = pos;
8335             tokenFlags = 0;
8336             if (pos >= end) {
8337                 return token = 1;
8338             }
8339             var ch = codePointAt(text, pos);
8340             pos += charSize(ch);
8341             switch (ch) {
8342                 case 9:
8343                 case 11:
8344                 case 12:
8345                 case 32:
8346                     while (pos < end && isWhiteSpaceSingleLine(text.charCodeAt(pos))) {
8347                         pos++;
8348                     }
8349                     return token = 5;
8350                 case 64:
8351                     return token = 59;
8352                 case 13:
8353                     if (text.charCodeAt(pos) === 10) {
8354                         pos++;
8355                     }
8356                 case 10:
8357                     tokenFlags |= 1;
8358                     return token = 4;
8359                 case 42:
8360                     return token = 41;
8361                 case 123:
8362                     return token = 18;
8363                 case 125:
8364                     return token = 19;
8365                 case 91:
8366                     return token = 22;
8367                 case 93:
8368                     return token = 23;
8369                 case 60:
8370                     return token = 29;
8371                 case 62:
8372                     return token = 31;
8373                 case 61:
8374                     return token = 62;
8375                 case 44:
8376                     return token = 27;
8377                 case 46:
8378                     return token = 24;
8379                 case 96:
8380                     return token = 61;
8381                 case 92:
8382                     pos--;
8383                     var extendedCookedChar = peekExtendedUnicodeEscape();
8384                     if (extendedCookedChar >= 0 && isIdentifierStart(extendedCookedChar, languageVersion)) {
8385                         pos += 3;
8386                         tokenFlags |= 8;
8387                         tokenValue = scanExtendedUnicodeEscape() + scanIdentifierParts();
8388                         return token = getIdentifierToken();
8389                     }
8390                     var cookedChar = peekUnicodeEscape();
8391                     if (cookedChar >= 0 && isIdentifierStart(cookedChar, languageVersion)) {
8392                         pos += 6;
8393                         tokenFlags |= 1024;
8394                         tokenValue = String.fromCharCode(cookedChar) + scanIdentifierParts();
8395                         return token = getIdentifierToken();
8396                     }
8397                     pos++;
8398                     return token = 0;
8399             }
8400             if (isIdentifierStart(ch, languageVersion)) {
8401                 var char = ch;
8402                 while (pos < end && isIdentifierPart(char = codePointAt(text, pos), languageVersion) || text.charCodeAt(pos) === 45)
8403                     pos += charSize(char);
8404                 tokenValue = text.substring(tokenPos, pos);
8405                 if (char === 92) {
8406                     tokenValue += scanIdentifierParts();
8407                 }
8408                 return token = getIdentifierToken();
8409             }
8410             else {
8411                 return token = 0;
8412             }
8413         }
8414         function speculationHelper(callback, isLookahead) {
8415             var savePos = pos;
8416             var saveStartPos = startPos;
8417             var saveTokenPos = tokenPos;
8418             var saveToken = token;
8419             var saveTokenValue = tokenValue;
8420             var saveTokenFlags = tokenFlags;
8421             var result = callback();
8422             if (!result || isLookahead) {
8423                 pos = savePos;
8424                 startPos = saveStartPos;
8425                 tokenPos = saveTokenPos;
8426                 token = saveToken;
8427                 tokenValue = saveTokenValue;
8428                 tokenFlags = saveTokenFlags;
8429             }
8430             return result;
8431         }
8432         function scanRange(start, length, callback) {
8433             var saveEnd = end;
8434             var savePos = pos;
8435             var saveStartPos = startPos;
8436             var saveTokenPos = tokenPos;
8437             var saveToken = token;
8438             var saveTokenValue = tokenValue;
8439             var saveTokenFlags = tokenFlags;
8440             var saveErrorExpectations = commentDirectives;
8441             setText(text, start, length);
8442             var result = callback();
8443             end = saveEnd;
8444             pos = savePos;
8445             startPos = saveStartPos;
8446             tokenPos = saveTokenPos;
8447             token = saveToken;
8448             tokenValue = saveTokenValue;
8449             tokenFlags = saveTokenFlags;
8450             commentDirectives = saveErrorExpectations;
8451             return result;
8452         }
8453         function lookAhead(callback) {
8454             return speculationHelper(callback, true);
8455         }
8456         function tryScan(callback) {
8457             return speculationHelper(callback, false);
8458         }
8459         function getText() {
8460             return text;
8461         }
8462         function clearCommentDirectives() {
8463             commentDirectives = undefined;
8464         }
8465         function setText(newText, start, length) {
8466             text = newText || "";
8467             end = length === undefined ? text.length : start + length;
8468             setTextPos(start || 0);
8469         }
8470         function setOnError(errorCallback) {
8471             onError = errorCallback;
8472         }
8473         function setScriptTarget(scriptTarget) {
8474             languageVersion = scriptTarget;
8475         }
8476         function setLanguageVariant(variant) {
8477             languageVariant = variant;
8478         }
8479         function setTextPos(textPos) {
8480             ts.Debug.assert(textPos >= 0);
8481             pos = textPos;
8482             startPos = textPos;
8483             tokenPos = textPos;
8484             token = 0;
8485             tokenValue = undefined;
8486             tokenFlags = 0;
8487         }
8488         function setInJSDocType(inType) {
8489             inJSDocType += inType ? 1 : -1;
8490         }
8491     }
8492     ts.createScanner = createScanner;
8493     var codePointAt = String.prototype.codePointAt ? function (s, i) { return s.codePointAt(i); } : function codePointAt(str, i) {
8494         var size = str.length;
8495         if (i < 0 || i >= size) {
8496             return undefined;
8497         }
8498         var first = str.charCodeAt(i);
8499         if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) {
8500             var second = str.charCodeAt(i + 1);
8501             if (second >= 0xDC00 && second <= 0xDFFF) {
8502                 return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000;
8503             }
8504         }
8505         return first;
8506     };
8507     function charSize(ch) {
8508         if (ch >= 0x10000) {
8509             return 2;
8510         }
8511         return 1;
8512     }
8513     function utf16EncodeAsStringFallback(codePoint) {
8514         ts.Debug.assert(0x0 <= codePoint && codePoint <= 0x10FFFF);
8515         if (codePoint <= 65535) {
8516             return String.fromCharCode(codePoint);
8517         }
8518         var codeUnit1 = Math.floor((codePoint - 65536) / 1024) + 0xD800;
8519         var codeUnit2 = ((codePoint - 65536) % 1024) + 0xDC00;
8520         return String.fromCharCode(codeUnit1, codeUnit2);
8521     }
8522     var utf16EncodeAsStringWorker = String.fromCodePoint ? function (codePoint) { return String.fromCodePoint(codePoint); } : utf16EncodeAsStringFallback;
8523     function utf16EncodeAsString(codePoint) {
8524         return utf16EncodeAsStringWorker(codePoint);
8525     }
8526     ts.utf16EncodeAsString = utf16EncodeAsString;
8527 })(ts || (ts = {}));
8528 var ts;
8529 (function (ts) {
8530     function isExternalModuleNameRelative(moduleName) {
8531         return ts.pathIsRelative(moduleName) || ts.isRootedDiskPath(moduleName);
8532     }
8533     ts.isExternalModuleNameRelative = isExternalModuleNameRelative;
8534     function sortAndDeduplicateDiagnostics(diagnostics) {
8535         return ts.sortAndDeduplicate(diagnostics, ts.compareDiagnostics);
8536     }
8537     ts.sortAndDeduplicateDiagnostics = sortAndDeduplicateDiagnostics;
8538     function getDefaultLibFileName(options) {
8539         switch (options.target) {
8540             case 99:
8541                 return "lib.esnext.full.d.ts";
8542             case 7:
8543                 return "lib.es2020.full.d.ts";
8544             case 6:
8545                 return "lib.es2019.full.d.ts";
8546             case 5:
8547                 return "lib.es2018.full.d.ts";
8548             case 4:
8549                 return "lib.es2017.full.d.ts";
8550             case 3:
8551                 return "lib.es2016.full.d.ts";
8552             case 2:
8553                 return "lib.es6.d.ts";
8554             default:
8555                 return "lib.d.ts";
8556         }
8557     }
8558     ts.getDefaultLibFileName = getDefaultLibFileName;
8559     function textSpanEnd(span) {
8560         return span.start + span.length;
8561     }
8562     ts.textSpanEnd = textSpanEnd;
8563     function textSpanIsEmpty(span) {
8564         return span.length === 0;
8565     }
8566     ts.textSpanIsEmpty = textSpanIsEmpty;
8567     function textSpanContainsPosition(span, position) {
8568         return position >= span.start && position < textSpanEnd(span);
8569     }
8570     ts.textSpanContainsPosition = textSpanContainsPosition;
8571     function textRangeContainsPositionInclusive(span, position) {
8572         return position >= span.pos && position <= span.end;
8573     }
8574     ts.textRangeContainsPositionInclusive = textRangeContainsPositionInclusive;
8575     function textSpanContainsTextSpan(span, other) {
8576         return other.start >= span.start && textSpanEnd(other) <= textSpanEnd(span);
8577     }
8578     ts.textSpanContainsTextSpan = textSpanContainsTextSpan;
8579     function textSpanOverlapsWith(span, other) {
8580         return textSpanOverlap(span, other) !== undefined;
8581     }
8582     ts.textSpanOverlapsWith = textSpanOverlapsWith;
8583     function textSpanOverlap(span1, span2) {
8584         var overlap = textSpanIntersection(span1, span2);
8585         return overlap && overlap.length === 0 ? undefined : overlap;
8586     }
8587     ts.textSpanOverlap = textSpanOverlap;
8588     function textSpanIntersectsWithTextSpan(span, other) {
8589         return decodedTextSpanIntersectsWith(span.start, span.length, other.start, other.length);
8590     }
8591     ts.textSpanIntersectsWithTextSpan = textSpanIntersectsWithTextSpan;
8592     function textSpanIntersectsWith(span, start, length) {
8593         return decodedTextSpanIntersectsWith(span.start, span.length, start, length);
8594     }
8595     ts.textSpanIntersectsWith = textSpanIntersectsWith;
8596     function decodedTextSpanIntersectsWith(start1, length1, start2, length2) {
8597         var end1 = start1 + length1;
8598         var end2 = start2 + length2;
8599         return start2 <= end1 && end2 >= start1;
8600     }
8601     ts.decodedTextSpanIntersectsWith = decodedTextSpanIntersectsWith;
8602     function textSpanIntersectsWithPosition(span, position) {
8603         return position <= textSpanEnd(span) && position >= span.start;
8604     }
8605     ts.textSpanIntersectsWithPosition = textSpanIntersectsWithPosition;
8606     function textSpanIntersection(span1, span2) {
8607         var start = Math.max(span1.start, span2.start);
8608         var end = Math.min(textSpanEnd(span1), textSpanEnd(span2));
8609         return start <= end ? createTextSpanFromBounds(start, end) : undefined;
8610     }
8611     ts.textSpanIntersection = textSpanIntersection;
8612     function createTextSpan(start, length) {
8613         if (start < 0) {
8614             throw new Error("start < 0");
8615         }
8616         if (length < 0) {
8617             throw new Error("length < 0");
8618         }
8619         return { start: start, length: length };
8620     }
8621     ts.createTextSpan = createTextSpan;
8622     function createTextSpanFromBounds(start, end) {
8623         return createTextSpan(start, end - start);
8624     }
8625     ts.createTextSpanFromBounds = createTextSpanFromBounds;
8626     function textChangeRangeNewSpan(range) {
8627         return createTextSpan(range.span.start, range.newLength);
8628     }
8629     ts.textChangeRangeNewSpan = textChangeRangeNewSpan;
8630     function textChangeRangeIsUnchanged(range) {
8631         return textSpanIsEmpty(range.span) && range.newLength === 0;
8632     }
8633     ts.textChangeRangeIsUnchanged = textChangeRangeIsUnchanged;
8634     function createTextChangeRange(span, newLength) {
8635         if (newLength < 0) {
8636             throw new Error("newLength < 0");
8637         }
8638         return { span: span, newLength: newLength };
8639     }
8640     ts.createTextChangeRange = createTextChangeRange;
8641     ts.unchangedTextChangeRange = createTextChangeRange(createTextSpan(0, 0), 0);
8642     function collapseTextChangeRangesAcrossMultipleVersions(changes) {
8643         if (changes.length === 0) {
8644             return ts.unchangedTextChangeRange;
8645         }
8646         if (changes.length === 1) {
8647             return changes[0];
8648         }
8649         var change0 = changes[0];
8650         var oldStartN = change0.span.start;
8651         var oldEndN = textSpanEnd(change0.span);
8652         var newEndN = oldStartN + change0.newLength;
8653         for (var i = 1; i < changes.length; i++) {
8654             var nextChange = changes[i];
8655             var oldStart1 = oldStartN;
8656             var oldEnd1 = oldEndN;
8657             var newEnd1 = newEndN;
8658             var oldStart2 = nextChange.span.start;
8659             var oldEnd2 = textSpanEnd(nextChange.span);
8660             var newEnd2 = oldStart2 + nextChange.newLength;
8661             oldStartN = Math.min(oldStart1, oldStart2);
8662             oldEndN = Math.max(oldEnd1, oldEnd1 + (oldEnd2 - newEnd1));
8663             newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
8664         }
8665         return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), newEndN - oldStartN);
8666     }
8667     ts.collapseTextChangeRangesAcrossMultipleVersions = collapseTextChangeRangesAcrossMultipleVersions;
8668     function getTypeParameterOwner(d) {
8669         if (d && d.kind === 159) {
8670             for (var current = d; current; current = current.parent) {
8671                 if (isFunctionLike(current) || isClassLike(current) || current.kind === 253) {
8672                     return current;
8673                 }
8674             }
8675         }
8676     }
8677     ts.getTypeParameterOwner = getTypeParameterOwner;
8678     function isParameterPropertyDeclaration(node, parent) {
8679         return ts.hasSyntacticModifier(node, 92) && parent.kind === 166;
8680     }
8681     ts.isParameterPropertyDeclaration = isParameterPropertyDeclaration;
8682     function isEmptyBindingPattern(node) {
8683         if (isBindingPattern(node)) {
8684             return ts.every(node.elements, isEmptyBindingElement);
8685         }
8686         return false;
8687     }
8688     ts.isEmptyBindingPattern = isEmptyBindingPattern;
8689     function isEmptyBindingElement(node) {
8690         if (ts.isOmittedExpression(node)) {
8691             return true;
8692         }
8693         return isEmptyBindingPattern(node.name);
8694     }
8695     ts.isEmptyBindingElement = isEmptyBindingElement;
8696     function walkUpBindingElementsAndPatterns(binding) {
8697         var node = binding.parent;
8698         while (ts.isBindingElement(node.parent)) {
8699             node = node.parent.parent;
8700         }
8701         return node.parent;
8702     }
8703     ts.walkUpBindingElementsAndPatterns = walkUpBindingElementsAndPatterns;
8704     function getCombinedFlags(node, getFlags) {
8705         if (ts.isBindingElement(node)) {
8706             node = walkUpBindingElementsAndPatterns(node);
8707         }
8708         var flags = getFlags(node);
8709         if (node.kind === 249) {
8710             node = node.parent;
8711         }
8712         if (node && node.kind === 250) {
8713             flags |= getFlags(node);
8714             node = node.parent;
8715         }
8716         if (node && node.kind === 232) {
8717             flags |= getFlags(node);
8718         }
8719         return flags;
8720     }
8721     function getCombinedModifierFlags(node) {
8722         return getCombinedFlags(node, ts.getEffectiveModifierFlags);
8723     }
8724     ts.getCombinedModifierFlags = getCombinedModifierFlags;
8725     function getCombinedNodeFlagsAlwaysIncludeJSDoc(node) {
8726         return getCombinedFlags(node, ts.getEffectiveModifierFlagsAlwaysIncludeJSDoc);
8727     }
8728     ts.getCombinedNodeFlagsAlwaysIncludeJSDoc = getCombinedNodeFlagsAlwaysIncludeJSDoc;
8729     function getCombinedNodeFlags(node) {
8730         return getCombinedFlags(node, function (n) { return n.flags; });
8731     }
8732     ts.getCombinedNodeFlags = getCombinedNodeFlags;
8733     ts.supportedLocaleDirectories = ["cs", "de", "es", "fr", "it", "ja", "ko", "pl", "pt-br", "ru", "tr", "zh-cn", "zh-tw"];
8734     function validateLocaleAndSetLanguage(locale, sys, errors) {
8735         var lowerCaseLocale = locale.toLowerCase();
8736         var matchResult = /^([a-z]+)([_\-]([a-z]+))?$/.exec(lowerCaseLocale);
8737         if (!matchResult) {
8738             if (errors) {
8739                 errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Locale_must_be_of_the_form_language_or_language_territory_For_example_0_or_1, "en", "ja-jp"));
8740             }
8741             return;
8742         }
8743         var language = matchResult[1];
8744         var territory = matchResult[3];
8745         if (ts.contains(ts.supportedLocaleDirectories, lowerCaseLocale) && !trySetLanguageAndTerritory(language, territory, errors)) {
8746             trySetLanguageAndTerritory(language, undefined, errors);
8747         }
8748         ts.setUILocale(locale);
8749         function trySetLanguageAndTerritory(language, territory, errors) {
8750             var compilerFilePath = ts.normalizePath(sys.getExecutingFilePath());
8751             var containingDirectoryPath = ts.getDirectoryPath(compilerFilePath);
8752             var filePath = ts.combinePaths(containingDirectoryPath, language);
8753             if (territory) {
8754                 filePath = filePath + "-" + territory;
8755             }
8756             filePath = sys.resolvePath(ts.combinePaths(filePath, "diagnosticMessages.generated.json"));
8757             if (!sys.fileExists(filePath)) {
8758                 return false;
8759             }
8760             var fileContents = "";
8761             try {
8762                 fileContents = sys.readFile(filePath);
8763             }
8764             catch (e) {
8765                 if (errors) {
8766                     errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unable_to_open_file_0, filePath));
8767                 }
8768                 return false;
8769             }
8770             try {
8771                 ts.setLocalizedDiagnosticMessages(JSON.parse(fileContents));
8772             }
8773             catch (_a) {
8774                 if (errors) {
8775                     errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Corrupted_locale_file_0, filePath));
8776                 }
8777                 return false;
8778             }
8779             return true;
8780         }
8781     }
8782     ts.validateLocaleAndSetLanguage = validateLocaleAndSetLanguage;
8783     function getOriginalNode(node, nodeTest) {
8784         if (node) {
8785             while (node.original !== undefined) {
8786                 node = node.original;
8787             }
8788         }
8789         return !nodeTest || nodeTest(node) ? node : undefined;
8790     }
8791     ts.getOriginalNode = getOriginalNode;
8792     function findAncestor(node, callback) {
8793         while (node) {
8794             var result = callback(node);
8795             if (result === "quit") {
8796                 return undefined;
8797             }
8798             else if (result) {
8799                 return node;
8800             }
8801             node = node.parent;
8802         }
8803         return undefined;
8804     }
8805     ts.findAncestor = findAncestor;
8806     function isParseTreeNode(node) {
8807         return (node.flags & 8) === 0;
8808     }
8809     ts.isParseTreeNode = isParseTreeNode;
8810     function getParseTreeNode(node, nodeTest) {
8811         if (node === undefined || isParseTreeNode(node)) {
8812             return node;
8813         }
8814         node = node.original;
8815         while (node) {
8816             if (isParseTreeNode(node)) {
8817                 return !nodeTest || nodeTest(node) ? node : undefined;
8818             }
8819             node = node.original;
8820         }
8821     }
8822     ts.getParseTreeNode = getParseTreeNode;
8823     function escapeLeadingUnderscores(identifier) {
8824         return (identifier.length >= 2 && identifier.charCodeAt(0) === 95 && identifier.charCodeAt(1) === 95 ? "_" + identifier : identifier);
8825     }
8826     ts.escapeLeadingUnderscores = escapeLeadingUnderscores;
8827     function unescapeLeadingUnderscores(identifier) {
8828         var id = identifier;
8829         return id.length >= 3 && id.charCodeAt(0) === 95 && id.charCodeAt(1) === 95 && id.charCodeAt(2) === 95 ? id.substr(1) : id;
8830     }
8831     ts.unescapeLeadingUnderscores = unescapeLeadingUnderscores;
8832     function idText(identifierOrPrivateName) {
8833         return unescapeLeadingUnderscores(identifierOrPrivateName.escapedText);
8834     }
8835     ts.idText = idText;
8836     function symbolName(symbol) {
8837         if (symbol.valueDeclaration && isPrivateIdentifierPropertyDeclaration(symbol.valueDeclaration)) {
8838             return idText(symbol.valueDeclaration.name);
8839         }
8840         return unescapeLeadingUnderscores(symbol.escapedName);
8841     }
8842     ts.symbolName = symbolName;
8843     function nameForNamelessJSDocTypedef(declaration) {
8844         var hostNode = declaration.parent.parent;
8845         if (!hostNode) {
8846             return undefined;
8847         }
8848         if (isDeclaration(hostNode)) {
8849             return getDeclarationIdentifier(hostNode);
8850         }
8851         switch (hostNode.kind) {
8852             case 232:
8853                 if (hostNode.declarationList && hostNode.declarationList.declarations[0]) {
8854                     return getDeclarationIdentifier(hostNode.declarationList.declarations[0]);
8855                 }
8856                 break;
8857             case 233:
8858                 var expr = hostNode.expression;
8859                 if (expr.kind === 216 && expr.operatorToken.kind === 62) {
8860                     expr = expr.left;
8861                 }
8862                 switch (expr.kind) {
8863                     case 201:
8864                         return expr.name;
8865                     case 202:
8866                         var arg = expr.argumentExpression;
8867                         if (ts.isIdentifier(arg)) {
8868                             return arg;
8869                         }
8870                 }
8871                 break;
8872             case 207: {
8873                 return getDeclarationIdentifier(hostNode.expression);
8874             }
8875             case 245: {
8876                 if (isDeclaration(hostNode.statement) || isExpression(hostNode.statement)) {
8877                     return getDeclarationIdentifier(hostNode.statement);
8878                 }
8879                 break;
8880             }
8881         }
8882     }
8883     function getDeclarationIdentifier(node) {
8884         var name = getNameOfDeclaration(node);
8885         return name && ts.isIdentifier(name) ? name : undefined;
8886     }
8887     function nodeHasName(statement, name) {
8888         if (isNamedDeclaration(statement) && ts.isIdentifier(statement.name) && idText(statement.name) === idText(name)) {
8889             return true;
8890         }
8891         if (ts.isVariableStatement(statement) && ts.some(statement.declarationList.declarations, function (d) { return nodeHasName(d, name); })) {
8892             return true;
8893         }
8894         return false;
8895     }
8896     ts.nodeHasName = nodeHasName;
8897     function getNameOfJSDocTypedef(declaration) {
8898         return declaration.name || nameForNamelessJSDocTypedef(declaration);
8899     }
8900     ts.getNameOfJSDocTypedef = getNameOfJSDocTypedef;
8901     function isNamedDeclaration(node) {
8902         return !!node.name;
8903     }
8904     ts.isNamedDeclaration = isNamedDeclaration;
8905     function getNonAssignedNameOfDeclaration(declaration) {
8906         switch (declaration.kind) {
8907             case 78:
8908                 return declaration;
8909             case 333:
8910             case 326: {
8911                 var name = declaration.name;
8912                 if (name.kind === 157) {
8913                     return name.right;
8914                 }
8915                 break;
8916             }
8917             case 203:
8918             case 216: {
8919                 var expr_1 = declaration;
8920                 switch (ts.getAssignmentDeclarationKind(expr_1)) {
8921                     case 1:
8922                     case 4:
8923                     case 5:
8924                     case 3:
8925                         return ts.getElementOrPropertyAccessArgumentExpressionOrName(expr_1.left);
8926                     case 7:
8927                     case 8:
8928                     case 9:
8929                         return expr_1.arguments[1];
8930                     default:
8931                         return undefined;
8932                 }
8933             }
8934             case 331:
8935                 return getNameOfJSDocTypedef(declaration);
8936             case 325:
8937                 return nameForNamelessJSDocTypedef(declaration);
8938             case 266: {
8939                 var expression = declaration.expression;
8940                 return ts.isIdentifier(expression) ? expression : undefined;
8941             }
8942             case 202:
8943                 var expr = declaration;
8944                 if (ts.isBindableStaticElementAccessExpression(expr)) {
8945                     return expr.argumentExpression;
8946                 }
8947         }
8948         return declaration.name;
8949     }
8950     ts.getNonAssignedNameOfDeclaration = getNonAssignedNameOfDeclaration;
8951     function getNameOfDeclaration(declaration) {
8952         if (declaration === undefined)
8953             return undefined;
8954         return getNonAssignedNameOfDeclaration(declaration) ||
8955             (ts.isFunctionExpression(declaration) || ts.isClassExpression(declaration) ? getAssignedName(declaration) : undefined);
8956     }
8957     ts.getNameOfDeclaration = getNameOfDeclaration;
8958     function getAssignedName(node) {
8959         if (!node.parent) {
8960             return undefined;
8961         }
8962         else if (ts.isPropertyAssignment(node.parent) || ts.isBindingElement(node.parent)) {
8963             return node.parent.name;
8964         }
8965         else if (ts.isBinaryExpression(node.parent) && node === node.parent.right) {
8966             if (ts.isIdentifier(node.parent.left)) {
8967                 return node.parent.left;
8968             }
8969             else if (ts.isAccessExpression(node.parent.left)) {
8970                 return ts.getElementOrPropertyAccessArgumentExpressionOrName(node.parent.left);
8971             }
8972         }
8973         else if (ts.isVariableDeclaration(node.parent) && ts.isIdentifier(node.parent.name)) {
8974             return node.parent.name;
8975         }
8976     }
8977     ts.getAssignedName = getAssignedName;
8978     function getJSDocParameterTagsWorker(param, noCache) {
8979         if (param.name) {
8980             if (ts.isIdentifier(param.name)) {
8981                 var name_1 = param.name.escapedText;
8982                 return getJSDocTagsWorker(param.parent, noCache).filter(function (tag) { return ts.isJSDocParameterTag(tag) && ts.isIdentifier(tag.name) && tag.name.escapedText === name_1; });
8983             }
8984             else {
8985                 var i = param.parent.parameters.indexOf(param);
8986                 ts.Debug.assert(i > -1, "Parameters should always be in their parents' parameter list");
8987                 var paramTags = getJSDocTagsWorker(param.parent, noCache).filter(ts.isJSDocParameterTag);
8988                 if (i < paramTags.length) {
8989                     return [paramTags[i]];
8990                 }
8991             }
8992         }
8993         return ts.emptyArray;
8994     }
8995     function getJSDocParameterTags(param) {
8996         return getJSDocParameterTagsWorker(param, false);
8997     }
8998     ts.getJSDocParameterTags = getJSDocParameterTags;
8999     function getJSDocParameterTagsNoCache(param) {
9000         return getJSDocParameterTagsWorker(param, true);
9001     }
9002     ts.getJSDocParameterTagsNoCache = getJSDocParameterTagsNoCache;
9003     function getJSDocTypeParameterTagsWorker(param, noCache) {
9004         var name = param.name.escapedText;
9005         return getJSDocTagsWorker(param.parent, noCache).filter(function (tag) {
9006             return ts.isJSDocTemplateTag(tag) && tag.typeParameters.some(function (tp) { return tp.name.escapedText === name; });
9007         });
9008     }
9009     function getJSDocTypeParameterTags(param) {
9010         return getJSDocTypeParameterTagsWorker(param, false);
9011     }
9012     ts.getJSDocTypeParameterTags = getJSDocTypeParameterTags;
9013     function getJSDocTypeParameterTagsNoCache(param) {
9014         return getJSDocTypeParameterTagsWorker(param, true);
9015     }
9016     ts.getJSDocTypeParameterTagsNoCache = getJSDocTypeParameterTagsNoCache;
9017     function hasJSDocParameterTags(node) {
9018         return !!getFirstJSDocTag(node, ts.isJSDocParameterTag);
9019     }
9020     ts.hasJSDocParameterTags = hasJSDocParameterTags;
9021     function getJSDocAugmentsTag(node) {
9022         return getFirstJSDocTag(node, ts.isJSDocAugmentsTag);
9023     }
9024     ts.getJSDocAugmentsTag = getJSDocAugmentsTag;
9025     function getJSDocImplementsTags(node) {
9026         return getAllJSDocTags(node, ts.isJSDocImplementsTag);
9027     }
9028     ts.getJSDocImplementsTags = getJSDocImplementsTags;
9029     function getJSDocClassTag(node) {
9030         return getFirstJSDocTag(node, ts.isJSDocClassTag);
9031     }
9032     ts.getJSDocClassTag = getJSDocClassTag;
9033     function getJSDocPublicTag(node) {
9034         return getFirstJSDocTag(node, ts.isJSDocPublicTag);
9035     }
9036     ts.getJSDocPublicTag = getJSDocPublicTag;
9037     function getJSDocPublicTagNoCache(node) {
9038         return getFirstJSDocTag(node, ts.isJSDocPublicTag, true);
9039     }
9040     ts.getJSDocPublicTagNoCache = getJSDocPublicTagNoCache;
9041     function getJSDocPrivateTag(node) {
9042         return getFirstJSDocTag(node, ts.isJSDocPrivateTag);
9043     }
9044     ts.getJSDocPrivateTag = getJSDocPrivateTag;
9045     function getJSDocPrivateTagNoCache(node) {
9046         return getFirstJSDocTag(node, ts.isJSDocPrivateTag, true);
9047     }
9048     ts.getJSDocPrivateTagNoCache = getJSDocPrivateTagNoCache;
9049     function getJSDocProtectedTag(node) {
9050         return getFirstJSDocTag(node, ts.isJSDocProtectedTag);
9051     }
9052     ts.getJSDocProtectedTag = getJSDocProtectedTag;
9053     function getJSDocProtectedTagNoCache(node) {
9054         return getFirstJSDocTag(node, ts.isJSDocProtectedTag, true);
9055     }
9056     ts.getJSDocProtectedTagNoCache = getJSDocProtectedTagNoCache;
9057     function getJSDocReadonlyTag(node) {
9058         return getFirstJSDocTag(node, ts.isJSDocReadonlyTag);
9059     }
9060     ts.getJSDocReadonlyTag = getJSDocReadonlyTag;
9061     function getJSDocReadonlyTagNoCache(node) {
9062         return getFirstJSDocTag(node, ts.isJSDocReadonlyTag, true);
9063     }
9064     ts.getJSDocReadonlyTagNoCache = getJSDocReadonlyTagNoCache;
9065     function getJSDocDeprecatedTag(node) {
9066         return getFirstJSDocTag(node, ts.isJSDocDeprecatedTag);
9067     }
9068     ts.getJSDocDeprecatedTag = getJSDocDeprecatedTag;
9069     function getJSDocDeprecatedTagNoCache(node) {
9070         return getFirstJSDocTag(node, ts.isJSDocDeprecatedTag, true);
9071     }
9072     ts.getJSDocDeprecatedTagNoCache = getJSDocDeprecatedTagNoCache;
9073     function getJSDocEnumTag(node) {
9074         return getFirstJSDocTag(node, ts.isJSDocEnumTag);
9075     }
9076     ts.getJSDocEnumTag = getJSDocEnumTag;
9077     function getJSDocThisTag(node) {
9078         return getFirstJSDocTag(node, ts.isJSDocThisTag);
9079     }
9080     ts.getJSDocThisTag = getJSDocThisTag;
9081     function getJSDocReturnTag(node) {
9082         return getFirstJSDocTag(node, ts.isJSDocReturnTag);
9083     }
9084     ts.getJSDocReturnTag = getJSDocReturnTag;
9085     function getJSDocTemplateTag(node) {
9086         return getFirstJSDocTag(node, ts.isJSDocTemplateTag);
9087     }
9088     ts.getJSDocTemplateTag = getJSDocTemplateTag;
9089     function getJSDocTypeTag(node) {
9090         var tag = getFirstJSDocTag(node, ts.isJSDocTypeTag);
9091         if (tag && tag.typeExpression && tag.typeExpression.type) {
9092             return tag;
9093         }
9094         return undefined;
9095     }
9096     ts.getJSDocTypeTag = getJSDocTypeTag;
9097     function getJSDocType(node) {
9098         var tag = getFirstJSDocTag(node, ts.isJSDocTypeTag);
9099         if (!tag && ts.isParameter(node)) {
9100             tag = ts.find(getJSDocParameterTags(node), function (tag) { return !!tag.typeExpression; });
9101         }
9102         return tag && tag.typeExpression && tag.typeExpression.type;
9103     }
9104     ts.getJSDocType = getJSDocType;
9105     function getJSDocReturnType(node) {
9106         var returnTag = getJSDocReturnTag(node);
9107         if (returnTag && returnTag.typeExpression) {
9108             return returnTag.typeExpression.type;
9109         }
9110         var typeTag = getJSDocTypeTag(node);
9111         if (typeTag && typeTag.typeExpression) {
9112             var type = typeTag.typeExpression.type;
9113             if (ts.isTypeLiteralNode(type)) {
9114                 var sig = ts.find(type.members, ts.isCallSignatureDeclaration);
9115                 return sig && sig.type;
9116             }
9117             if (ts.isFunctionTypeNode(type) || ts.isJSDocFunctionType(type)) {
9118                 return type.type;
9119             }
9120         }
9121     }
9122     ts.getJSDocReturnType = getJSDocReturnType;
9123     function getJSDocTagsWorker(node, noCache) {
9124         var tags = node.jsDocCache;
9125         if (tags === undefined || noCache) {
9126             var comments = ts.getJSDocCommentsAndTags(node, noCache);
9127             ts.Debug.assert(comments.length < 2 || comments[0] !== comments[1]);
9128             tags = ts.flatMap(comments, function (j) { return ts.isJSDoc(j) ? j.tags : j; });
9129             if (!noCache) {
9130                 node.jsDocCache = tags;
9131             }
9132         }
9133         return tags;
9134     }
9135     function getJSDocTags(node) {
9136         return getJSDocTagsWorker(node, false);
9137     }
9138     ts.getJSDocTags = getJSDocTags;
9139     function getJSDocTagsNoCache(node) {
9140         return getJSDocTagsWorker(node, true);
9141     }
9142     ts.getJSDocTagsNoCache = getJSDocTagsNoCache;
9143     function getFirstJSDocTag(node, predicate, noCache) {
9144         return ts.find(getJSDocTagsWorker(node, noCache), predicate);
9145     }
9146     function getAllJSDocTags(node, predicate) {
9147         return getJSDocTags(node).filter(predicate);
9148     }
9149     ts.getAllJSDocTags = getAllJSDocTags;
9150     function getAllJSDocTagsOfKind(node, kind) {
9151         return getJSDocTags(node).filter(function (doc) { return doc.kind === kind; });
9152     }
9153     ts.getAllJSDocTagsOfKind = getAllJSDocTagsOfKind;
9154     function getEffectiveTypeParameterDeclarations(node) {
9155         if (ts.isJSDocSignature(node)) {
9156             return ts.emptyArray;
9157         }
9158         if (ts.isJSDocTypeAlias(node)) {
9159             ts.Debug.assert(node.parent.kind === 311);
9160             return ts.flatMap(node.parent.tags, function (tag) { return ts.isJSDocTemplateTag(tag) ? tag.typeParameters : undefined; });
9161         }
9162         if (node.typeParameters) {
9163             return node.typeParameters;
9164         }
9165         if (ts.isInJSFile(node)) {
9166             var decls = ts.getJSDocTypeParameterDeclarations(node);
9167             if (decls.length) {
9168                 return decls;
9169             }
9170             var typeTag = getJSDocType(node);
9171             if (typeTag && ts.isFunctionTypeNode(typeTag) && typeTag.typeParameters) {
9172                 return typeTag.typeParameters;
9173             }
9174         }
9175         return ts.emptyArray;
9176     }
9177     ts.getEffectiveTypeParameterDeclarations = getEffectiveTypeParameterDeclarations;
9178     function getEffectiveConstraintOfTypeParameter(node) {
9179         return node.constraint ? node.constraint :
9180             ts.isJSDocTemplateTag(node.parent) && node === node.parent.typeParameters[0] ? node.parent.constraint :
9181                 undefined;
9182     }
9183     ts.getEffectiveConstraintOfTypeParameter = getEffectiveConstraintOfTypeParameter;
9184     function isIdentifierOrPrivateIdentifier(node) {
9185         return node.kind === 78 || node.kind === 79;
9186     }
9187     ts.isIdentifierOrPrivateIdentifier = isIdentifierOrPrivateIdentifier;
9188     function isGetOrSetAccessorDeclaration(node) {
9189         return node.kind === 168 || node.kind === 167;
9190     }
9191     ts.isGetOrSetAccessorDeclaration = isGetOrSetAccessorDeclaration;
9192     function isPropertyAccessChain(node) {
9193         return ts.isPropertyAccessExpression(node) && !!(node.flags & 32);
9194     }
9195     ts.isPropertyAccessChain = isPropertyAccessChain;
9196     function isElementAccessChain(node) {
9197         return ts.isElementAccessExpression(node) && !!(node.flags & 32);
9198     }
9199     ts.isElementAccessChain = isElementAccessChain;
9200     function isCallChain(node) {
9201         return ts.isCallExpression(node) && !!(node.flags & 32);
9202     }
9203     ts.isCallChain = isCallChain;
9204     function isOptionalChain(node) {
9205         var kind = node.kind;
9206         return !!(node.flags & 32) &&
9207             (kind === 201
9208                 || kind === 202
9209                 || kind === 203
9210                 || kind === 225);
9211     }
9212     ts.isOptionalChain = isOptionalChain;
9213     function isOptionalChainRoot(node) {
9214         return isOptionalChain(node) && !ts.isNonNullExpression(node) && !!node.questionDotToken;
9215     }
9216     ts.isOptionalChainRoot = isOptionalChainRoot;
9217     function isExpressionOfOptionalChainRoot(node) {
9218         return isOptionalChainRoot(node.parent) && node.parent.expression === node;
9219     }
9220     ts.isExpressionOfOptionalChainRoot = isExpressionOfOptionalChainRoot;
9221     function isOutermostOptionalChain(node) {
9222         return !isOptionalChain(node.parent)
9223             || isOptionalChainRoot(node.parent)
9224             || node !== node.parent.expression;
9225     }
9226     ts.isOutermostOptionalChain = isOutermostOptionalChain;
9227     function isNullishCoalesce(node) {
9228         return node.kind === 216 && node.operatorToken.kind === 60;
9229     }
9230     ts.isNullishCoalesce = isNullishCoalesce;
9231     function isConstTypeReference(node) {
9232         return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) &&
9233             node.typeName.escapedText === "const" && !node.typeArguments;
9234     }
9235     ts.isConstTypeReference = isConstTypeReference;
9236     function skipPartiallyEmittedExpressions(node) {
9237         return ts.skipOuterExpressions(node, 8);
9238     }
9239     ts.skipPartiallyEmittedExpressions = skipPartiallyEmittedExpressions;
9240     function isNonNullChain(node) {
9241         return ts.isNonNullExpression(node) && !!(node.flags & 32);
9242     }
9243     ts.isNonNullChain = isNonNullChain;
9244     function isBreakOrContinueStatement(node) {
9245         return node.kind === 241 || node.kind === 240;
9246     }
9247     ts.isBreakOrContinueStatement = isBreakOrContinueStatement;
9248     function isNamedExportBindings(node) {
9249         return node.kind === 269 || node.kind === 268;
9250     }
9251     ts.isNamedExportBindings = isNamedExportBindings;
9252     function isUnparsedTextLike(node) {
9253         switch (node.kind) {
9254             case 294:
9255             case 295:
9256                 return true;
9257             default:
9258                 return false;
9259         }
9260     }
9261     ts.isUnparsedTextLike = isUnparsedTextLike;
9262     function isUnparsedNode(node) {
9263         return isUnparsedTextLike(node) ||
9264             node.kind === 292 ||
9265             node.kind === 296;
9266     }
9267     ts.isUnparsedNode = isUnparsedNode;
9268     function isJSDocPropertyLikeTag(node) {
9269         return node.kind === 333 || node.kind === 326;
9270     }
9271     ts.isJSDocPropertyLikeTag = isJSDocPropertyLikeTag;
9272     function isNode(node) {
9273         return isNodeKind(node.kind);
9274     }
9275     ts.isNode = isNode;
9276     function isNodeKind(kind) {
9277         return kind >= 157;
9278     }
9279     ts.isNodeKind = isNodeKind;
9280     function isToken(n) {
9281         return n.kind >= 0 && n.kind <= 156;
9282     }
9283     ts.isToken = isToken;
9284     function isNodeArray(array) {
9285         return array.hasOwnProperty("pos") && array.hasOwnProperty("end");
9286     }
9287     ts.isNodeArray = isNodeArray;
9288     function isLiteralKind(kind) {
9289         return 8 <= kind && kind <= 14;
9290     }
9291     ts.isLiteralKind = isLiteralKind;
9292     function isLiteralExpression(node) {
9293         return isLiteralKind(node.kind);
9294     }
9295     ts.isLiteralExpression = isLiteralExpression;
9296     function isTemplateLiteralKind(kind) {
9297         return 14 <= kind && kind <= 17;
9298     }
9299     ts.isTemplateLiteralKind = isTemplateLiteralKind;
9300     function isTemplateLiteralToken(node) {
9301         return isTemplateLiteralKind(node.kind);
9302     }
9303     ts.isTemplateLiteralToken = isTemplateLiteralToken;
9304     function isTemplateMiddleOrTemplateTail(node) {
9305         var kind = node.kind;
9306         return kind === 16
9307             || kind === 17;
9308     }
9309     ts.isTemplateMiddleOrTemplateTail = isTemplateMiddleOrTemplateTail;
9310     function isImportOrExportSpecifier(node) {
9311         return ts.isImportSpecifier(node) || ts.isExportSpecifier(node);
9312     }
9313     ts.isImportOrExportSpecifier = isImportOrExportSpecifier;
9314     function isTypeOnlyImportOrExportDeclaration(node) {
9315         switch (node.kind) {
9316             case 265:
9317             case 270:
9318                 return node.parent.parent.isTypeOnly;
9319             case 263:
9320                 return node.parent.isTypeOnly;
9321             case 262:
9322             case 260:
9323                 return node.isTypeOnly;
9324             default:
9325                 return false;
9326         }
9327     }
9328     ts.isTypeOnlyImportOrExportDeclaration = isTypeOnlyImportOrExportDeclaration;
9329     function isStringTextContainingNode(node) {
9330         return node.kind === 10 || isTemplateLiteralKind(node.kind);
9331     }
9332     ts.isStringTextContainingNode = isStringTextContainingNode;
9333     function isGeneratedIdentifier(node) {
9334         return ts.isIdentifier(node) && (node.autoGenerateFlags & 7) > 0;
9335     }
9336     ts.isGeneratedIdentifier = isGeneratedIdentifier;
9337     function isPrivateIdentifierPropertyDeclaration(node) {
9338         return ts.isPropertyDeclaration(node) && ts.isPrivateIdentifier(node.name);
9339     }
9340     ts.isPrivateIdentifierPropertyDeclaration = isPrivateIdentifierPropertyDeclaration;
9341     function isPrivateIdentifierPropertyAccessExpression(node) {
9342         return ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name);
9343     }
9344     ts.isPrivateIdentifierPropertyAccessExpression = isPrivateIdentifierPropertyAccessExpression;
9345     function isModifierKind(token) {
9346         switch (token) {
9347             case 125:
9348             case 129:
9349             case 84:
9350             case 133:
9351             case 87:
9352             case 92:
9353             case 122:
9354             case 120:
9355             case 121:
9356             case 142:
9357             case 123:
9358                 return true;
9359         }
9360         return false;
9361     }
9362     ts.isModifierKind = isModifierKind;
9363     function isParameterPropertyModifier(kind) {
9364         return !!(ts.modifierToFlag(kind) & 92);
9365     }
9366     ts.isParameterPropertyModifier = isParameterPropertyModifier;
9367     function isClassMemberModifier(idToken) {
9368         return isParameterPropertyModifier(idToken) || idToken === 123;
9369     }
9370     ts.isClassMemberModifier = isClassMemberModifier;
9371     function isModifier(node) {
9372         return isModifierKind(node.kind);
9373     }
9374     ts.isModifier = isModifier;
9375     function isEntityName(node) {
9376         var kind = node.kind;
9377         return kind === 157
9378             || kind === 78;
9379     }
9380     ts.isEntityName = isEntityName;
9381     function isPropertyName(node) {
9382         var kind = node.kind;
9383         return kind === 78
9384             || kind === 79
9385             || kind === 10
9386             || kind === 8
9387             || kind === 158;
9388     }
9389     ts.isPropertyName = isPropertyName;
9390     function isBindingName(node) {
9391         var kind = node.kind;
9392         return kind === 78
9393             || kind === 196
9394             || kind === 197;
9395     }
9396     ts.isBindingName = isBindingName;
9397     function isFunctionLike(node) {
9398         return node && isFunctionLikeKind(node.kind);
9399     }
9400     ts.isFunctionLike = isFunctionLike;
9401     function isFunctionLikeDeclaration(node) {
9402         return node && isFunctionLikeDeclarationKind(node.kind);
9403     }
9404     ts.isFunctionLikeDeclaration = isFunctionLikeDeclaration;
9405     function isFunctionLikeDeclarationKind(kind) {
9406         switch (kind) {
9407             case 251:
9408             case 165:
9409             case 166:
9410             case 167:
9411             case 168:
9412             case 208:
9413             case 209:
9414                 return true;
9415             default:
9416                 return false;
9417         }
9418     }
9419     function isFunctionLikeKind(kind) {
9420         switch (kind) {
9421             case 164:
9422             case 169:
9423             case 313:
9424             case 170:
9425             case 171:
9426             case 174:
9427             case 308:
9428             case 175:
9429                 return true;
9430             default:
9431                 return isFunctionLikeDeclarationKind(kind);
9432         }
9433     }
9434     ts.isFunctionLikeKind = isFunctionLikeKind;
9435     function isFunctionOrModuleBlock(node) {
9436         return ts.isSourceFile(node) || ts.isModuleBlock(node) || ts.isBlock(node) && isFunctionLike(node.parent);
9437     }
9438     ts.isFunctionOrModuleBlock = isFunctionOrModuleBlock;
9439     function isClassElement(node) {
9440         var kind = node.kind;
9441         return kind === 166
9442             || kind === 163
9443             || kind === 165
9444             || kind === 167
9445             || kind === 168
9446             || kind === 171
9447             || kind === 229;
9448     }
9449     ts.isClassElement = isClassElement;
9450     function isClassLike(node) {
9451         return node && (node.kind === 252 || node.kind === 221);
9452     }
9453     ts.isClassLike = isClassLike;
9454     function isAccessor(node) {
9455         return node && (node.kind === 167 || node.kind === 168);
9456     }
9457     ts.isAccessor = isAccessor;
9458     function isMethodOrAccessor(node) {
9459         switch (node.kind) {
9460             case 165:
9461             case 167:
9462             case 168:
9463                 return true;
9464             default:
9465                 return false;
9466         }
9467     }
9468     ts.isMethodOrAccessor = isMethodOrAccessor;
9469     function isTypeElement(node) {
9470         var kind = node.kind;
9471         return kind === 170
9472             || kind === 169
9473             || kind === 162
9474             || kind === 164
9475             || kind === 171;
9476     }
9477     ts.isTypeElement = isTypeElement;
9478     function isClassOrTypeElement(node) {
9479         return isTypeElement(node) || isClassElement(node);
9480     }
9481     ts.isClassOrTypeElement = isClassOrTypeElement;
9482     function isObjectLiteralElementLike(node) {
9483         var kind = node.kind;
9484         return kind === 288
9485             || kind === 289
9486             || kind === 290
9487             || kind === 165
9488             || kind === 167
9489             || kind === 168;
9490     }
9491     ts.isObjectLiteralElementLike = isObjectLiteralElementLike;
9492     function isTypeNode(node) {
9493         return ts.isTypeNodeKind(node.kind);
9494     }
9495     ts.isTypeNode = isTypeNode;
9496     function isFunctionOrConstructorTypeNode(node) {
9497         switch (node.kind) {
9498             case 174:
9499             case 175:
9500                 return true;
9501         }
9502         return false;
9503     }
9504     ts.isFunctionOrConstructorTypeNode = isFunctionOrConstructorTypeNode;
9505     function isBindingPattern(node) {
9506         if (node) {
9507             var kind = node.kind;
9508             return kind === 197
9509                 || kind === 196;
9510         }
9511         return false;
9512     }
9513     ts.isBindingPattern = isBindingPattern;
9514     function isAssignmentPattern(node) {
9515         var kind = node.kind;
9516         return kind === 199
9517             || kind === 200;
9518     }
9519     ts.isAssignmentPattern = isAssignmentPattern;
9520     function isArrayBindingElement(node) {
9521         var kind = node.kind;
9522         return kind === 198
9523             || kind === 222;
9524     }
9525     ts.isArrayBindingElement = isArrayBindingElement;
9526     function isDeclarationBindingElement(bindingElement) {
9527         switch (bindingElement.kind) {
9528             case 249:
9529             case 160:
9530             case 198:
9531                 return true;
9532         }
9533         return false;
9534     }
9535     ts.isDeclarationBindingElement = isDeclarationBindingElement;
9536     function isBindingOrAssignmentPattern(node) {
9537         return isObjectBindingOrAssignmentPattern(node)
9538             || isArrayBindingOrAssignmentPattern(node);
9539     }
9540     ts.isBindingOrAssignmentPattern = isBindingOrAssignmentPattern;
9541     function isObjectBindingOrAssignmentPattern(node) {
9542         switch (node.kind) {
9543             case 196:
9544             case 200:
9545                 return true;
9546         }
9547         return false;
9548     }
9549     ts.isObjectBindingOrAssignmentPattern = isObjectBindingOrAssignmentPattern;
9550     function isArrayBindingOrAssignmentPattern(node) {
9551         switch (node.kind) {
9552             case 197:
9553             case 199:
9554                 return true;
9555         }
9556         return false;
9557     }
9558     ts.isArrayBindingOrAssignmentPattern = isArrayBindingOrAssignmentPattern;
9559     function isPropertyAccessOrQualifiedNameOrImportTypeNode(node) {
9560         var kind = node.kind;
9561         return kind === 201
9562             || kind === 157
9563             || kind === 195;
9564     }
9565     ts.isPropertyAccessOrQualifiedNameOrImportTypeNode = isPropertyAccessOrQualifiedNameOrImportTypeNode;
9566     function isPropertyAccessOrQualifiedName(node) {
9567         var kind = node.kind;
9568         return kind === 201
9569             || kind === 157;
9570     }
9571     ts.isPropertyAccessOrQualifiedName = isPropertyAccessOrQualifiedName;
9572     function isCallLikeExpression(node) {
9573         switch (node.kind) {
9574             case 275:
9575             case 274:
9576             case 203:
9577             case 204:
9578             case 205:
9579             case 161:
9580                 return true;
9581             default:
9582                 return false;
9583         }
9584     }
9585     ts.isCallLikeExpression = isCallLikeExpression;
9586     function isCallOrNewExpression(node) {
9587         return node.kind === 203 || node.kind === 204;
9588     }
9589     ts.isCallOrNewExpression = isCallOrNewExpression;
9590     function isTemplateLiteral(node) {
9591         var kind = node.kind;
9592         return kind === 218
9593             || kind === 14;
9594     }
9595     ts.isTemplateLiteral = isTemplateLiteral;
9596     function isLeftHandSideExpression(node) {
9597         return isLeftHandSideExpressionKind(skipPartiallyEmittedExpressions(node).kind);
9598     }
9599     ts.isLeftHandSideExpression = isLeftHandSideExpression;
9600     function isLeftHandSideExpressionKind(kind) {
9601         switch (kind) {
9602             case 201:
9603             case 202:
9604             case 204:
9605             case 203:
9606             case 273:
9607             case 274:
9608             case 277:
9609             case 205:
9610             case 199:
9611             case 207:
9612             case 200:
9613             case 221:
9614             case 208:
9615             case 78:
9616             case 13:
9617             case 8:
9618             case 9:
9619             case 10:
9620             case 14:
9621             case 218:
9622             case 94:
9623             case 103:
9624             case 107:
9625             case 109:
9626             case 105:
9627             case 225:
9628             case 226:
9629             case 99:
9630                 return true;
9631             default:
9632                 return false;
9633         }
9634     }
9635     function isUnaryExpression(node) {
9636         return isUnaryExpressionKind(skipPartiallyEmittedExpressions(node).kind);
9637     }
9638     ts.isUnaryExpression = isUnaryExpression;
9639     function isUnaryExpressionKind(kind) {
9640         switch (kind) {
9641             case 214:
9642             case 215:
9643             case 210:
9644             case 211:
9645             case 212:
9646             case 213:
9647             case 206:
9648                 return true;
9649             default:
9650                 return isLeftHandSideExpressionKind(kind);
9651         }
9652     }
9653     function isUnaryExpressionWithWrite(expr) {
9654         switch (expr.kind) {
9655             case 215:
9656                 return true;
9657             case 214:
9658                 return expr.operator === 45 ||
9659                     expr.operator === 46;
9660             default:
9661                 return false;
9662         }
9663     }
9664     ts.isUnaryExpressionWithWrite = isUnaryExpressionWithWrite;
9665     function isExpression(node) {
9666         return isExpressionKind(skipPartiallyEmittedExpressions(node).kind);
9667     }
9668     ts.isExpression = isExpression;
9669     function isExpressionKind(kind) {
9670         switch (kind) {
9671             case 217:
9672             case 219:
9673             case 209:
9674             case 216:
9675             case 220:
9676             case 224:
9677             case 222:
9678             case 337:
9679             case 336:
9680                 return true;
9681             default:
9682                 return isUnaryExpressionKind(kind);
9683         }
9684     }
9685     function isAssertionExpression(node) {
9686         var kind = node.kind;
9687         return kind === 206
9688             || kind === 224;
9689     }
9690     ts.isAssertionExpression = isAssertionExpression;
9691     function isNotEmittedOrPartiallyEmittedNode(node) {
9692         return ts.isNotEmittedStatement(node)
9693             || ts.isPartiallyEmittedExpression(node);
9694     }
9695     ts.isNotEmittedOrPartiallyEmittedNode = isNotEmittedOrPartiallyEmittedNode;
9696     function isIterationStatement(node, lookInLabeledStatements) {
9697         switch (node.kind) {
9698             case 237:
9699             case 238:
9700             case 239:
9701             case 235:
9702             case 236:
9703                 return true;
9704             case 245:
9705                 return lookInLabeledStatements && isIterationStatement(node.statement, lookInLabeledStatements);
9706         }
9707         return false;
9708     }
9709     ts.isIterationStatement = isIterationStatement;
9710     function isScopeMarker(node) {
9711         return ts.isExportAssignment(node) || ts.isExportDeclaration(node);
9712     }
9713     ts.isScopeMarker = isScopeMarker;
9714     function hasScopeMarker(statements) {
9715         return ts.some(statements, isScopeMarker);
9716     }
9717     ts.hasScopeMarker = hasScopeMarker;
9718     function needsScopeMarker(result) {
9719         return !ts.isAnyImportOrReExport(result) && !ts.isExportAssignment(result) && !ts.hasSyntacticModifier(result, 1) && !ts.isAmbientModule(result);
9720     }
9721     ts.needsScopeMarker = needsScopeMarker;
9722     function isExternalModuleIndicator(result) {
9723         return ts.isAnyImportOrReExport(result) || ts.isExportAssignment(result) || ts.hasSyntacticModifier(result, 1);
9724     }
9725     ts.isExternalModuleIndicator = isExternalModuleIndicator;
9726     function isForInOrOfStatement(node) {
9727         return node.kind === 238 || node.kind === 239;
9728     }
9729     ts.isForInOrOfStatement = isForInOrOfStatement;
9730     function isConciseBody(node) {
9731         return ts.isBlock(node)
9732             || isExpression(node);
9733     }
9734     ts.isConciseBody = isConciseBody;
9735     function isFunctionBody(node) {
9736         return ts.isBlock(node);
9737     }
9738     ts.isFunctionBody = isFunctionBody;
9739     function isForInitializer(node) {
9740         return ts.isVariableDeclarationList(node)
9741             || isExpression(node);
9742     }
9743     ts.isForInitializer = isForInitializer;
9744     function isModuleBody(node) {
9745         var kind = node.kind;
9746         return kind === 257
9747             || kind === 256
9748             || kind === 78;
9749     }
9750     ts.isModuleBody = isModuleBody;
9751     function isNamespaceBody(node) {
9752         var kind = node.kind;
9753         return kind === 257
9754             || kind === 256;
9755     }
9756     ts.isNamespaceBody = isNamespaceBody;
9757     function isJSDocNamespaceBody(node) {
9758         var kind = node.kind;
9759         return kind === 78
9760             || kind === 256;
9761     }
9762     ts.isJSDocNamespaceBody = isJSDocNamespaceBody;
9763     function isNamedImportBindings(node) {
9764         var kind = node.kind;
9765         return kind === 264
9766             || kind === 263;
9767     }
9768     ts.isNamedImportBindings = isNamedImportBindings;
9769     function isModuleOrEnumDeclaration(node) {
9770         return node.kind === 256 || node.kind === 255;
9771     }
9772     ts.isModuleOrEnumDeclaration = isModuleOrEnumDeclaration;
9773     function isDeclarationKind(kind) {
9774         return kind === 209
9775             || kind === 198
9776             || kind === 252
9777             || kind === 221
9778             || kind === 166
9779             || kind === 255
9780             || kind === 291
9781             || kind === 270
9782             || kind === 251
9783             || kind === 208
9784             || kind === 167
9785             || kind === 262
9786             || kind === 260
9787             || kind === 265
9788             || kind === 253
9789             || kind === 280
9790             || kind === 165
9791             || kind === 164
9792             || kind === 256
9793             || kind === 259
9794             || kind === 263
9795             || kind === 269
9796             || kind === 160
9797             || kind === 288
9798             || kind === 163
9799             || kind === 162
9800             || kind === 168
9801             || kind === 289
9802             || kind === 254
9803             || kind === 159
9804             || kind === 249
9805             || kind === 331
9806             || kind === 324
9807             || kind === 333;
9808     }
9809     function isDeclarationStatementKind(kind) {
9810         return kind === 251
9811             || kind === 271
9812             || kind === 252
9813             || kind === 253
9814             || kind === 254
9815             || kind === 255
9816             || kind === 256
9817             || kind === 261
9818             || kind === 260
9819             || kind === 267
9820             || kind === 266
9821             || kind === 259;
9822     }
9823     function isStatementKindButNotDeclarationKind(kind) {
9824         return kind === 241
9825             || kind === 240
9826             || kind === 248
9827             || kind === 235
9828             || kind === 233
9829             || kind === 231
9830             || kind === 238
9831             || kind === 239
9832             || kind === 237
9833             || kind === 234
9834             || kind === 245
9835             || kind === 242
9836             || kind === 244
9837             || kind === 246
9838             || kind === 247
9839             || kind === 232
9840             || kind === 236
9841             || kind === 243
9842             || kind === 335
9843             || kind === 339
9844             || kind === 338;
9845     }
9846     function isDeclaration(node) {
9847         if (node.kind === 159) {
9848             return (node.parent && node.parent.kind !== 330) || ts.isInJSFile(node);
9849         }
9850         return isDeclarationKind(node.kind);
9851     }
9852     ts.isDeclaration = isDeclaration;
9853     function isDeclarationStatement(node) {
9854         return isDeclarationStatementKind(node.kind);
9855     }
9856     ts.isDeclarationStatement = isDeclarationStatement;
9857     function isStatementButNotDeclaration(node) {
9858         return isStatementKindButNotDeclarationKind(node.kind);
9859     }
9860     ts.isStatementButNotDeclaration = isStatementButNotDeclaration;
9861     function isStatement(node) {
9862         var kind = node.kind;
9863         return isStatementKindButNotDeclarationKind(kind)
9864             || isDeclarationStatementKind(kind)
9865             || isBlockStatement(node);
9866     }
9867     ts.isStatement = isStatement;
9868     function isBlockStatement(node) {
9869         if (node.kind !== 230)
9870             return false;
9871         if (node.parent !== undefined) {
9872             if (node.parent.kind === 247 || node.parent.kind === 287) {
9873                 return false;
9874             }
9875         }
9876         return !ts.isFunctionBlock(node);
9877     }
9878     function isStatementOrBlock(node) {
9879         var kind = node.kind;
9880         return isStatementKindButNotDeclarationKind(kind)
9881             || isDeclarationStatementKind(kind)
9882             || kind === 230;
9883     }
9884     ts.isStatementOrBlock = isStatementOrBlock;
9885     function isModuleReference(node) {
9886         var kind = node.kind;
9887         return kind === 272
9888             || kind === 157
9889             || kind === 78;
9890     }
9891     ts.isModuleReference = isModuleReference;
9892     function isJsxTagNameExpression(node) {
9893         var kind = node.kind;
9894         return kind === 107
9895             || kind === 78
9896             || kind === 201;
9897     }
9898     ts.isJsxTagNameExpression = isJsxTagNameExpression;
9899     function isJsxChild(node) {
9900         var kind = node.kind;
9901         return kind === 273
9902             || kind === 283
9903             || kind === 274
9904             || kind === 11
9905             || kind === 277;
9906     }
9907     ts.isJsxChild = isJsxChild;
9908     function isJsxAttributeLike(node) {
9909         var kind = node.kind;
9910         return kind === 280
9911             || kind === 282;
9912     }
9913     ts.isJsxAttributeLike = isJsxAttributeLike;
9914     function isStringLiteralOrJsxExpression(node) {
9915         var kind = node.kind;
9916         return kind === 10
9917             || kind === 283;
9918     }
9919     ts.isStringLiteralOrJsxExpression = isStringLiteralOrJsxExpression;
9920     function isJsxOpeningLikeElement(node) {
9921         var kind = node.kind;
9922         return kind === 275
9923             || kind === 274;
9924     }
9925     ts.isJsxOpeningLikeElement = isJsxOpeningLikeElement;
9926     function isCaseOrDefaultClause(node) {
9927         var kind = node.kind;
9928         return kind === 284
9929             || kind === 285;
9930     }
9931     ts.isCaseOrDefaultClause = isCaseOrDefaultClause;
9932     function isJSDocNode(node) {
9933         return node.kind >= 301 && node.kind <= 333;
9934     }
9935     ts.isJSDocNode = isJSDocNode;
9936     function isJSDocCommentContainingNode(node) {
9937         return node.kind === 311 || node.kind === 310 || isJSDocTag(node) || ts.isJSDocTypeLiteral(node) || ts.isJSDocSignature(node);
9938     }
9939     ts.isJSDocCommentContainingNode = isJSDocCommentContainingNode;
9940     function isJSDocTag(node) {
9941         return node.kind >= 314 && node.kind <= 333;
9942     }
9943     ts.isJSDocTag = isJSDocTag;
9944     function isSetAccessor(node) {
9945         return node.kind === 168;
9946     }
9947     ts.isSetAccessor = isSetAccessor;
9948     function isGetAccessor(node) {
9949         return node.kind === 167;
9950     }
9951     ts.isGetAccessor = isGetAccessor;
9952     function hasJSDocNodes(node) {
9953         var jsDoc = node.jsDoc;
9954         return !!jsDoc && jsDoc.length > 0;
9955     }
9956     ts.hasJSDocNodes = hasJSDocNodes;
9957     function hasType(node) {
9958         return !!node.type;
9959     }
9960     ts.hasType = hasType;
9961     function hasInitializer(node) {
9962         return !!node.initializer;
9963     }
9964     ts.hasInitializer = hasInitializer;
9965     function hasOnlyExpressionInitializer(node) {
9966         switch (node.kind) {
9967             case 249:
9968             case 160:
9969             case 198:
9970             case 162:
9971             case 163:
9972             case 288:
9973             case 291:
9974                 return true;
9975             default:
9976                 return false;
9977         }
9978     }
9979     ts.hasOnlyExpressionInitializer = hasOnlyExpressionInitializer;
9980     function isObjectLiteralElement(node) {
9981         return node.kind === 280 || node.kind === 282 || isObjectLiteralElementLike(node);
9982     }
9983     ts.isObjectLiteralElement = isObjectLiteralElement;
9984     function isTypeReferenceType(node) {
9985         return node.kind === 173 || node.kind === 223;
9986     }
9987     ts.isTypeReferenceType = isTypeReferenceType;
9988     var MAX_SMI_X86 = 1073741823;
9989     function guessIndentation(lines) {
9990         var indentation = MAX_SMI_X86;
9991         for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
9992             var line = lines_1[_i];
9993             if (!line.length) {
9994                 continue;
9995             }
9996             var i = 0;
9997             for (; i < line.length && i < indentation; i++) {
9998                 if (!ts.isWhiteSpaceLike(line.charCodeAt(i))) {
9999                     break;
10000                 }
10001             }
10002             if (i < indentation) {
10003                 indentation = i;
10004             }
10005             if (indentation === 0) {
10006                 return 0;
10007             }
10008         }
10009         return indentation === MAX_SMI_X86 ? undefined : indentation;
10010     }
10011     ts.guessIndentation = guessIndentation;
10012     function isStringLiteralLike(node) {
10013         return node.kind === 10 || node.kind === 14;
10014     }
10015     ts.isStringLiteralLike = isStringLiteralLike;
10016 })(ts || (ts = {}));
10017 var ts;
10018 (function (ts) {
10019     ts.resolvingEmptyArray = [];
10020     ts.externalHelpersModuleNameText = "tslib";
10021     ts.defaultMaximumTruncationLength = 160;
10022     ts.noTruncationMaximumTruncationLength = 1000000;
10023     function getDeclarationOfKind(symbol, kind) {
10024         var declarations = symbol.declarations;
10025         if (declarations) {
10026             for (var _i = 0, declarations_1 = declarations; _i < declarations_1.length; _i++) {
10027                 var declaration = declarations_1[_i];
10028                 if (declaration.kind === kind) {
10029                     return declaration;
10030                 }
10031             }
10032         }
10033         return undefined;
10034     }
10035     ts.getDeclarationOfKind = getDeclarationOfKind;
10036     function createUnderscoreEscapedMap() {
10037         return new ts.Map();
10038     }
10039     ts.createUnderscoreEscapedMap = createUnderscoreEscapedMap;
10040     function hasEntries(map) {
10041         return !!map && !!map.size;
10042     }
10043     ts.hasEntries = hasEntries;
10044     function createSymbolTable(symbols) {
10045         var result = new ts.Map();
10046         if (symbols) {
10047             for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
10048                 var symbol = symbols_1[_i];
10049                 result.set(symbol.escapedName, symbol);
10050             }
10051         }
10052         return result;
10053     }
10054     ts.createSymbolTable = createSymbolTable;
10055     function isTransientSymbol(symbol) {
10056         return (symbol.flags & 33554432) !== 0;
10057     }
10058     ts.isTransientSymbol = isTransientSymbol;
10059     var stringWriter = createSingleLineStringWriter();
10060     function createSingleLineStringWriter() {
10061         var str = "";
10062         var writeText = function (text) { return str += text; };
10063         return {
10064             getText: function () { return str; },
10065             write: writeText,
10066             rawWrite: writeText,
10067             writeKeyword: writeText,
10068             writeOperator: writeText,
10069             writePunctuation: writeText,
10070             writeSpace: writeText,
10071             writeStringLiteral: writeText,
10072             writeLiteral: writeText,
10073             writeParameter: writeText,
10074             writeProperty: writeText,
10075             writeSymbol: function (s, _) { return writeText(s); },
10076             writeTrailingSemicolon: writeText,
10077             writeComment: writeText,
10078             getTextPos: function () { return str.length; },
10079             getLine: function () { return 0; },
10080             getColumn: function () { return 0; },
10081             getIndent: function () { return 0; },
10082             isAtStartOfLine: function () { return false; },
10083             hasTrailingComment: function () { return false; },
10084             hasTrailingWhitespace: function () { return !!str.length && ts.isWhiteSpaceLike(str.charCodeAt(str.length - 1)); },
10085             writeLine: function () { return str += " "; },
10086             increaseIndent: ts.noop,
10087             decreaseIndent: ts.noop,
10088             clear: function () { return str = ""; },
10089             trackSymbol: ts.noop,
10090             reportInaccessibleThisError: ts.noop,
10091             reportInaccessibleUniqueSymbolError: ts.noop,
10092             reportPrivateInBaseOfClassExpression: ts.noop,
10093         };
10094     }
10095     function changesAffectModuleResolution(oldOptions, newOptions) {
10096         return oldOptions.configFilePath !== newOptions.configFilePath ||
10097             optionsHaveModuleResolutionChanges(oldOptions, newOptions);
10098     }
10099     ts.changesAffectModuleResolution = changesAffectModuleResolution;
10100     function optionsHaveModuleResolutionChanges(oldOptions, newOptions) {
10101         return ts.moduleResolutionOptionDeclarations.some(function (o) {
10102             return !isJsonEqual(getCompilerOptionValue(oldOptions, o), getCompilerOptionValue(newOptions, o));
10103         });
10104     }
10105     ts.optionsHaveModuleResolutionChanges = optionsHaveModuleResolutionChanges;
10106     function forEachAncestor(node, callback) {
10107         while (true) {
10108             var res = callback(node);
10109             if (res === "quit")
10110                 return undefined;
10111             if (res !== undefined)
10112                 return res;
10113             if (ts.isSourceFile(node))
10114                 return undefined;
10115             node = node.parent;
10116         }
10117     }
10118     ts.forEachAncestor = forEachAncestor;
10119     function forEachEntry(map, callback) {
10120         var iterator = map.entries();
10121         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
10122             var _a = iterResult.value, key = _a[0], value = _a[1];
10123             var result = callback(value, key);
10124             if (result) {
10125                 return result;
10126             }
10127         }
10128         return undefined;
10129     }
10130     ts.forEachEntry = forEachEntry;
10131     function forEachKey(map, callback) {
10132         var iterator = map.keys();
10133         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
10134             var result = callback(iterResult.value);
10135             if (result) {
10136                 return result;
10137             }
10138         }
10139         return undefined;
10140     }
10141     ts.forEachKey = forEachKey;
10142     function copyEntries(source, target) {
10143         source.forEach(function (value, key) {
10144             target.set(key, value);
10145         });
10146     }
10147     ts.copyEntries = copyEntries;
10148     function usingSingleLineStringWriter(action) {
10149         var oldString = stringWriter.getText();
10150         try {
10151             action(stringWriter);
10152             return stringWriter.getText();
10153         }
10154         finally {
10155             stringWriter.clear();
10156             stringWriter.writeKeyword(oldString);
10157         }
10158     }
10159     ts.usingSingleLineStringWriter = usingSingleLineStringWriter;
10160     function getFullWidth(node) {
10161         return node.end - node.pos;
10162     }
10163     ts.getFullWidth = getFullWidth;
10164     function getResolvedModule(sourceFile, moduleNameText) {
10165         return sourceFile && sourceFile.resolvedModules && sourceFile.resolvedModules.get(moduleNameText);
10166     }
10167     ts.getResolvedModule = getResolvedModule;
10168     function setResolvedModule(sourceFile, moduleNameText, resolvedModule) {
10169         if (!sourceFile.resolvedModules) {
10170             sourceFile.resolvedModules = new ts.Map();
10171         }
10172         sourceFile.resolvedModules.set(moduleNameText, resolvedModule);
10173     }
10174     ts.setResolvedModule = setResolvedModule;
10175     function setResolvedTypeReferenceDirective(sourceFile, typeReferenceDirectiveName, resolvedTypeReferenceDirective) {
10176         if (!sourceFile.resolvedTypeReferenceDirectiveNames) {
10177             sourceFile.resolvedTypeReferenceDirectiveNames = new ts.Map();
10178         }
10179         sourceFile.resolvedTypeReferenceDirectiveNames.set(typeReferenceDirectiveName, resolvedTypeReferenceDirective);
10180     }
10181     ts.setResolvedTypeReferenceDirective = setResolvedTypeReferenceDirective;
10182     function projectReferenceIsEqualTo(oldRef, newRef) {
10183         return oldRef.path === newRef.path &&
10184             !oldRef.prepend === !newRef.prepend &&
10185             !oldRef.circular === !newRef.circular;
10186     }
10187     ts.projectReferenceIsEqualTo = projectReferenceIsEqualTo;
10188     function moduleResolutionIsEqualTo(oldResolution, newResolution) {
10189         return oldResolution.isExternalLibraryImport === newResolution.isExternalLibraryImport &&
10190             oldResolution.extension === newResolution.extension &&
10191             oldResolution.resolvedFileName === newResolution.resolvedFileName &&
10192             oldResolution.originalPath === newResolution.originalPath &&
10193             packageIdIsEqual(oldResolution.packageId, newResolution.packageId);
10194     }
10195     ts.moduleResolutionIsEqualTo = moduleResolutionIsEqualTo;
10196     function packageIdIsEqual(a, b) {
10197         return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version;
10198     }
10199     function packageIdToString(_a) {
10200         var name = _a.name, subModuleName = _a.subModuleName, version = _a.version;
10201         var fullName = subModuleName ? name + "/" + subModuleName : name;
10202         return fullName + "@" + version;
10203     }
10204     ts.packageIdToString = packageIdToString;
10205     function typeDirectiveIsEqualTo(oldResolution, newResolution) {
10206         return oldResolution.resolvedFileName === newResolution.resolvedFileName && oldResolution.primary === newResolution.primary;
10207     }
10208     ts.typeDirectiveIsEqualTo = typeDirectiveIsEqualTo;
10209     function hasChangesInResolutions(names, newResolutions, oldResolutions, comparer) {
10210         ts.Debug.assert(names.length === newResolutions.length);
10211         for (var i = 0; i < names.length; i++) {
10212             var newResolution = newResolutions[i];
10213             var oldResolution = oldResolutions && oldResolutions.get(names[i]);
10214             var changed = oldResolution
10215                 ? !newResolution || !comparer(oldResolution, newResolution)
10216                 : newResolution;
10217             if (changed) {
10218                 return true;
10219             }
10220         }
10221         return false;
10222     }
10223     ts.hasChangesInResolutions = hasChangesInResolutions;
10224     function containsParseError(node) {
10225         aggregateChildData(node);
10226         return (node.flags & 262144) !== 0;
10227     }
10228     ts.containsParseError = containsParseError;
10229     function aggregateChildData(node) {
10230         if (!(node.flags & 524288)) {
10231             var thisNodeOrAnySubNodesHasError = ((node.flags & 65536) !== 0) ||
10232                 ts.forEachChild(node, containsParseError);
10233             if (thisNodeOrAnySubNodesHasError) {
10234                 node.flags |= 262144;
10235             }
10236             node.flags |= 524288;
10237         }
10238     }
10239     function getSourceFileOfNode(node) {
10240         while (node && node.kind !== 297) {
10241             node = node.parent;
10242         }
10243         return node;
10244     }
10245     ts.getSourceFileOfNode = getSourceFileOfNode;
10246     function isStatementWithLocals(node) {
10247         switch (node.kind) {
10248             case 230:
10249             case 258:
10250             case 237:
10251             case 238:
10252             case 239:
10253                 return true;
10254         }
10255         return false;
10256     }
10257     ts.isStatementWithLocals = isStatementWithLocals;
10258     function getStartPositionOfLine(line, sourceFile) {
10259         ts.Debug.assert(line >= 0);
10260         return ts.getLineStarts(sourceFile)[line];
10261     }
10262     ts.getStartPositionOfLine = getStartPositionOfLine;
10263     function nodePosToString(node) {
10264         var file = getSourceFileOfNode(node);
10265         var loc = ts.getLineAndCharacterOfPosition(file, node.pos);
10266         return file.fileName + "(" + (loc.line + 1) + "," + (loc.character + 1) + ")";
10267     }
10268     ts.nodePosToString = nodePosToString;
10269     function getEndLinePosition(line, sourceFile) {
10270         ts.Debug.assert(line >= 0);
10271         var lineStarts = ts.getLineStarts(sourceFile);
10272         var lineIndex = line;
10273         var sourceText = sourceFile.text;
10274         if (lineIndex + 1 === lineStarts.length) {
10275             return sourceText.length - 1;
10276         }
10277         else {
10278             var start = lineStarts[lineIndex];
10279             var pos = lineStarts[lineIndex + 1] - 1;
10280             ts.Debug.assert(ts.isLineBreak(sourceText.charCodeAt(pos)));
10281             while (start <= pos && ts.isLineBreak(sourceText.charCodeAt(pos))) {
10282                 pos--;
10283             }
10284             return pos;
10285         }
10286     }
10287     ts.getEndLinePosition = getEndLinePosition;
10288     function isFileLevelUniqueName(sourceFile, name, hasGlobalName) {
10289         return !(hasGlobalName && hasGlobalName(name)) && !sourceFile.identifiers.has(name);
10290     }
10291     ts.isFileLevelUniqueName = isFileLevelUniqueName;
10292     function nodeIsMissing(node) {
10293         if (node === undefined) {
10294             return true;
10295         }
10296         return node.pos === node.end && node.pos >= 0 && node.kind !== 1;
10297     }
10298     ts.nodeIsMissing = nodeIsMissing;
10299     function nodeIsPresent(node) {
10300         return !nodeIsMissing(node);
10301     }
10302     ts.nodeIsPresent = nodeIsPresent;
10303     function insertStatementsAfterPrologue(to, from, isPrologueDirective) {
10304         if (from === undefined || from.length === 0)
10305             return to;
10306         var statementIndex = 0;
10307         for (; statementIndex < to.length; ++statementIndex) {
10308             if (!isPrologueDirective(to[statementIndex])) {
10309                 break;
10310             }
10311         }
10312         to.splice.apply(to, __spreadArray([statementIndex, 0], from));
10313         return to;
10314     }
10315     function insertStatementAfterPrologue(to, statement, isPrologueDirective) {
10316         if (statement === undefined)
10317             return to;
10318         var statementIndex = 0;
10319         for (; statementIndex < to.length; ++statementIndex) {
10320             if (!isPrologueDirective(to[statementIndex])) {
10321                 break;
10322             }
10323         }
10324         to.splice(statementIndex, 0, statement);
10325         return to;
10326     }
10327     function isAnyPrologueDirective(node) {
10328         return isPrologueDirective(node) || !!(getEmitFlags(node) & 1048576);
10329     }
10330     function insertStatementsAfterStandardPrologue(to, from) {
10331         return insertStatementsAfterPrologue(to, from, isPrologueDirective);
10332     }
10333     ts.insertStatementsAfterStandardPrologue = insertStatementsAfterStandardPrologue;
10334     function insertStatementsAfterCustomPrologue(to, from) {
10335         return insertStatementsAfterPrologue(to, from, isAnyPrologueDirective);
10336     }
10337     ts.insertStatementsAfterCustomPrologue = insertStatementsAfterCustomPrologue;
10338     function insertStatementAfterStandardPrologue(to, statement) {
10339         return insertStatementAfterPrologue(to, statement, isPrologueDirective);
10340     }
10341     ts.insertStatementAfterStandardPrologue = insertStatementAfterStandardPrologue;
10342     function insertStatementAfterCustomPrologue(to, statement) {
10343         return insertStatementAfterPrologue(to, statement, isAnyPrologueDirective);
10344     }
10345     ts.insertStatementAfterCustomPrologue = insertStatementAfterCustomPrologue;
10346     function isRecognizedTripleSlashComment(text, commentPos, commentEnd) {
10347         if (text.charCodeAt(commentPos + 1) === 47 &&
10348             commentPos + 2 < commentEnd &&
10349             text.charCodeAt(commentPos + 2) === 47) {
10350             var textSubStr = text.substring(commentPos, commentEnd);
10351             return textSubStr.match(ts.fullTripleSlashReferencePathRegEx) ||
10352                 textSubStr.match(ts.fullTripleSlashAMDReferencePathRegEx) ||
10353                 textSubStr.match(fullTripleSlashReferenceTypeReferenceDirectiveRegEx) ||
10354                 textSubStr.match(defaultLibReferenceRegEx) ?
10355                 true : false;
10356         }
10357         return false;
10358     }
10359     ts.isRecognizedTripleSlashComment = isRecognizedTripleSlashComment;
10360     function isPinnedComment(text, start) {
10361         return text.charCodeAt(start + 1) === 42 &&
10362             text.charCodeAt(start + 2) === 33;
10363     }
10364     ts.isPinnedComment = isPinnedComment;
10365     function createCommentDirectivesMap(sourceFile, commentDirectives) {
10366         var directivesByLine = new ts.Map(commentDirectives.map(function (commentDirective) { return ([
10367             "" + ts.getLineAndCharacterOfPosition(sourceFile, commentDirective.range.end).line,
10368             commentDirective,
10369         ]); }));
10370         var usedLines = new ts.Map();
10371         return { getUnusedExpectations: getUnusedExpectations, markUsed: markUsed };
10372         function getUnusedExpectations() {
10373             return ts.arrayFrom(directivesByLine.entries())
10374                 .filter(function (_a) {
10375                 var line = _a[0], directive = _a[1];
10376                 return directive.type === 0 && !usedLines.get(line);
10377             })
10378                 .map(function (_a) {
10379                 var _ = _a[0], directive = _a[1];
10380                 return directive;
10381             });
10382         }
10383         function markUsed(line) {
10384             if (!directivesByLine.has("" + line)) {
10385                 return false;
10386             }
10387             usedLines.set("" + line, true);
10388             return true;
10389         }
10390     }
10391     ts.createCommentDirectivesMap = createCommentDirectivesMap;
10392     function getTokenPosOfNode(node, sourceFile, includeJsDoc) {
10393         if (nodeIsMissing(node)) {
10394             return node.pos;
10395         }
10396         if (ts.isJSDocNode(node) || node.kind === 11) {
10397             return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos, false, true);
10398         }
10399         if (includeJsDoc && ts.hasJSDocNodes(node)) {
10400             return getTokenPosOfNode(node.jsDoc[0], sourceFile);
10401         }
10402         if (node.kind === 334 && node._children.length > 0) {
10403             return getTokenPosOfNode(node._children[0], sourceFile, includeJsDoc);
10404         }
10405         return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.pos);
10406     }
10407     ts.getTokenPosOfNode = getTokenPosOfNode;
10408     function getNonDecoratorTokenPosOfNode(node, sourceFile) {
10409         if (nodeIsMissing(node) || !node.decorators) {
10410             return getTokenPosOfNode(node, sourceFile);
10411         }
10412         return ts.skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end);
10413     }
10414     ts.getNonDecoratorTokenPosOfNode = getNonDecoratorTokenPosOfNode;
10415     function getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia) {
10416         if (includeTrivia === void 0) { includeTrivia = false; }
10417         return getTextOfNodeFromSourceText(sourceFile.text, node, includeTrivia);
10418     }
10419     ts.getSourceTextOfNodeFromSourceFile = getSourceTextOfNodeFromSourceFile;
10420     function isJSDocTypeExpressionOrChild(node) {
10421         return !!ts.findAncestor(node, ts.isJSDocTypeExpression);
10422     }
10423     function isExportNamespaceAsDefaultDeclaration(node) {
10424         return !!(ts.isExportDeclaration(node) && node.exportClause && ts.isNamespaceExport(node.exportClause) && node.exportClause.name.escapedText === "default");
10425     }
10426     ts.isExportNamespaceAsDefaultDeclaration = isExportNamespaceAsDefaultDeclaration;
10427     function getTextOfNodeFromSourceText(sourceText, node, includeTrivia) {
10428         if (includeTrivia === void 0) { includeTrivia = false; }
10429         if (nodeIsMissing(node)) {
10430             return "";
10431         }
10432         var text = sourceText.substring(includeTrivia ? node.pos : ts.skipTrivia(sourceText, node.pos), node.end);
10433         if (isJSDocTypeExpressionOrChild(node)) {
10434             text = text.replace(/(^|\r?\n|\r)\s*\*\s*/g, "$1");
10435         }
10436         return text;
10437     }
10438     ts.getTextOfNodeFromSourceText = getTextOfNodeFromSourceText;
10439     function getTextOfNode(node, includeTrivia) {
10440         if (includeTrivia === void 0) { includeTrivia = false; }
10441         return getSourceTextOfNodeFromSourceFile(getSourceFileOfNode(node), node, includeTrivia);
10442     }
10443     ts.getTextOfNode = getTextOfNode;
10444     function getPos(range) {
10445         return range.pos;
10446     }
10447     function indexOfNode(nodeArray, node) {
10448         return ts.binarySearch(nodeArray, node, getPos, ts.compareValues);
10449     }
10450     ts.indexOfNode = indexOfNode;
10451     function getEmitFlags(node) {
10452         var emitNode = node.emitNode;
10453         return emitNode && emitNode.flags || 0;
10454     }
10455     ts.getEmitFlags = getEmitFlags;
10456     ;
10457     function getScriptTargetFeatures() {
10458         return {
10459             es2015: {
10460                 Array: ["find", "findIndex", "fill", "copyWithin", "entries", "keys", "values"],
10461                 RegExp: ["flags", "sticky", "unicode"],
10462                 Reflect: ["apply", "construct", "defineProperty", "deleteProperty", "get", " getOwnPropertyDescriptor", "getPrototypeOf", "has", "isExtensible", "ownKeys", "preventExtensions", "set", "setPrototypeOf"],
10463                 ArrayConstructor: ["from", "of"],
10464                 ObjectConstructor: ["assign", "getOwnPropertySymbols", "keys", "is", "setPrototypeOf"],
10465                 NumberConstructor: ["isFinite", "isInteger", "isNaN", "isSafeInteger", "parseFloat", "parseInt"],
10466                 Math: ["clz32", "imul", "sign", "log10", "log2", "log1p", "expm1", "cosh", "sinh", "tanh", "acosh", "asinh", "atanh", "hypot", "trunc", "fround", "cbrt"],
10467                 Map: ["entries", "keys", "values"],
10468                 Set: ["entries", "keys", "values"],
10469                 Promise: ts.emptyArray,
10470                 PromiseConstructor: ["all", "race", "reject", "resolve"],
10471                 Symbol: ["for", "keyFor"],
10472                 WeakMap: ["entries", "keys", "values"],
10473                 WeakSet: ["entries", "keys", "values"],
10474                 Iterator: ts.emptyArray,
10475                 AsyncIterator: ts.emptyArray,
10476                 String: ["codePointAt", "includes", "endsWith", "normalize", "repeat", "startsWith", "anchor", "big", "blink", "bold", "fixed", "fontcolor", "fontsize", "italics", "link", "small", "strike", "sub", "sup"],
10477                 StringConstructor: ["fromCodePoint", "raw"]
10478             },
10479             es2016: {
10480                 Array: ["includes"]
10481             },
10482             es2017: {
10483                 Atomics: ts.emptyArray,
10484                 SharedArrayBuffer: ts.emptyArray,
10485                 String: ["padStart", "padEnd"],
10486                 ObjectConstructor: ["values", "entries", "getOwnPropertyDescriptors"],
10487                 DateTimeFormat: ["formatToParts"]
10488             },
10489             es2018: {
10490                 Promise: ["finally"],
10491                 RegExpMatchArray: ["groups"],
10492                 RegExpExecArray: ["groups"],
10493                 RegExp: ["dotAll"],
10494                 Intl: ["PluralRules"],
10495                 AsyncIterable: ts.emptyArray,
10496                 AsyncIterableIterator: ts.emptyArray,
10497                 AsyncGenerator: ts.emptyArray,
10498                 AsyncGeneratorFunction: ts.emptyArray,
10499             },
10500             es2019: {
10501                 Array: ["flat", "flatMap"],
10502                 ObjectConstructor: ["fromEntries"],
10503                 String: ["trimStart", "trimEnd", "trimLeft", "trimRight"],
10504                 Symbol: ["description"]
10505             },
10506             es2020: {
10507                 BigInt: ts.emptyArray,
10508                 BigInt64Array: ts.emptyArray,
10509                 BigUint64Array: ts.emptyArray,
10510                 PromiseConstructor: ["allSettled"],
10511                 SymbolConstructor: ["matchAll"],
10512                 String: ["matchAll"],
10513                 DataView: ["setBigInt64", "setBigUint64", "getBigInt64", "getBigUint64"],
10514                 RelativeTimeFormat: ["format", "formatToParts", "resolvedOptions"]
10515             },
10516             esnext: {
10517                 PromiseConstructor: ["any"],
10518                 String: ["replaceAll"],
10519                 NumberFormat: ["formatToParts"]
10520             }
10521         };
10522     }
10523     ts.getScriptTargetFeatures = getScriptTargetFeatures;
10524     function getLiteralText(node, sourceFile, flags) {
10525         if (canUseOriginalText(node, flags)) {
10526             return getSourceTextOfNodeFromSourceFile(sourceFile, node);
10527         }
10528         switch (node.kind) {
10529             case 10: {
10530                 var escapeText = flags & 2 ? escapeJsxAttributeString :
10531                     flags & 1 || (getEmitFlags(node) & 16777216) ? escapeString :
10532                         escapeNonAsciiString;
10533                 if (node.singleQuote) {
10534                     return "'" + escapeText(node.text, 39) + "'";
10535                 }
10536                 else {
10537                     return '"' + escapeText(node.text, 34) + '"';
10538                 }
10539             }
10540             case 14:
10541             case 15:
10542             case 16:
10543             case 17: {
10544                 var escapeText = flags & 1 || (getEmitFlags(node) & 16777216) ? escapeString :
10545                     escapeNonAsciiString;
10546                 var rawText = node.rawText || escapeTemplateSubstitution(escapeText(node.text, 96));
10547                 switch (node.kind) {
10548                     case 14:
10549                         return "`" + rawText + "`";
10550                     case 15:
10551                         return "`" + rawText + "${";
10552                     case 16:
10553                         return "}" + rawText + "${";
10554                     case 17:
10555                         return "}" + rawText + "`";
10556                 }
10557                 break;
10558             }
10559             case 8:
10560             case 9:
10561                 return node.text;
10562             case 13:
10563                 if (flags & 4 && node.isUnterminated) {
10564                     return node.text + (node.text.charCodeAt(node.text.length - 1) === 92 ? " /" : "/");
10565                 }
10566                 return node.text;
10567         }
10568         return ts.Debug.fail("Literal kind '" + node.kind + "' not accounted for.");
10569     }
10570     ts.getLiteralText = getLiteralText;
10571     function canUseOriginalText(node, flags) {
10572         if (nodeIsSynthesized(node) || !node.parent || (flags & 4 && node.isUnterminated)) {
10573             return false;
10574         }
10575         if (ts.isNumericLiteral(node) && node.numericLiteralFlags & 512) {
10576             return !!(flags & 8);
10577         }
10578         return !ts.isBigIntLiteral(node);
10579     }
10580     function getTextOfConstantValue(value) {
10581         return ts.isString(value) ? '"' + escapeNonAsciiString(value) + '"' : "" + value;
10582     }
10583     ts.getTextOfConstantValue = getTextOfConstantValue;
10584     function makeIdentifierFromModuleName(moduleName) {
10585         return ts.getBaseFileName(moduleName).replace(/^(\d)/, "_$1").replace(/\W/g, "_");
10586     }
10587     ts.makeIdentifierFromModuleName = makeIdentifierFromModuleName;
10588     function isBlockOrCatchScoped(declaration) {
10589         return (ts.getCombinedNodeFlags(declaration) & 3) !== 0 ||
10590             isCatchClauseVariableDeclarationOrBindingElement(declaration);
10591     }
10592     ts.isBlockOrCatchScoped = isBlockOrCatchScoped;
10593     function isCatchClauseVariableDeclarationOrBindingElement(declaration) {
10594         var node = getRootDeclaration(declaration);
10595         return node.kind === 249 && node.parent.kind === 287;
10596     }
10597     ts.isCatchClauseVariableDeclarationOrBindingElement = isCatchClauseVariableDeclarationOrBindingElement;
10598     function isAmbientModule(node) {
10599         return ts.isModuleDeclaration(node) && (node.name.kind === 10 || isGlobalScopeAugmentation(node));
10600     }
10601     ts.isAmbientModule = isAmbientModule;
10602     function isModuleWithStringLiteralName(node) {
10603         return ts.isModuleDeclaration(node) && node.name.kind === 10;
10604     }
10605     ts.isModuleWithStringLiteralName = isModuleWithStringLiteralName;
10606     function isNonGlobalAmbientModule(node) {
10607         return ts.isModuleDeclaration(node) && ts.isStringLiteral(node.name);
10608     }
10609     ts.isNonGlobalAmbientModule = isNonGlobalAmbientModule;
10610     function isEffectiveModuleDeclaration(node) {
10611         return ts.isModuleDeclaration(node) || ts.isIdentifier(node);
10612     }
10613     ts.isEffectiveModuleDeclaration = isEffectiveModuleDeclaration;
10614     function isShorthandAmbientModuleSymbol(moduleSymbol) {
10615         return isShorthandAmbientModule(moduleSymbol.valueDeclaration);
10616     }
10617     ts.isShorthandAmbientModuleSymbol = isShorthandAmbientModuleSymbol;
10618     function isShorthandAmbientModule(node) {
10619         return node && node.kind === 256 && (!node.body);
10620     }
10621     function isBlockScopedContainerTopLevel(node) {
10622         return node.kind === 297 ||
10623             node.kind === 256 ||
10624             ts.isFunctionLike(node);
10625     }
10626     ts.isBlockScopedContainerTopLevel = isBlockScopedContainerTopLevel;
10627     function isGlobalScopeAugmentation(module) {
10628         return !!(module.flags & 1024);
10629     }
10630     ts.isGlobalScopeAugmentation = isGlobalScopeAugmentation;
10631     function isExternalModuleAugmentation(node) {
10632         return isAmbientModule(node) && isModuleAugmentationExternal(node);
10633     }
10634     ts.isExternalModuleAugmentation = isExternalModuleAugmentation;
10635     function isModuleAugmentationExternal(node) {
10636         switch (node.parent.kind) {
10637             case 297:
10638                 return ts.isExternalModule(node.parent);
10639             case 257:
10640                 return isAmbientModule(node.parent.parent) && ts.isSourceFile(node.parent.parent.parent) && !ts.isExternalModule(node.parent.parent.parent);
10641         }
10642         return false;
10643     }
10644     ts.isModuleAugmentationExternal = isModuleAugmentationExternal;
10645     function getNonAugmentationDeclaration(symbol) {
10646         return ts.find(symbol.declarations, function (d) { return !isExternalModuleAugmentation(d) && !(ts.isModuleDeclaration(d) && isGlobalScopeAugmentation(d)); });
10647     }
10648     ts.getNonAugmentationDeclaration = getNonAugmentationDeclaration;
10649     function isEffectiveExternalModule(node, compilerOptions) {
10650         return ts.isExternalModule(node) || compilerOptions.isolatedModules || ((getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS) && !!node.commonJsModuleIndicator);
10651     }
10652     ts.isEffectiveExternalModule = isEffectiveExternalModule;
10653     function isEffectiveStrictModeSourceFile(node, compilerOptions) {
10654         switch (node.scriptKind) {
10655             case 1:
10656             case 3:
10657             case 2:
10658             case 4:
10659                 break;
10660             default:
10661                 return false;
10662         }
10663         if (node.isDeclarationFile) {
10664             return false;
10665         }
10666         if (getStrictOptionValue(compilerOptions, "alwaysStrict")) {
10667             return true;
10668         }
10669         if (ts.startsWithUseStrict(node.statements)) {
10670             return true;
10671         }
10672         if (ts.isExternalModule(node) || compilerOptions.isolatedModules) {
10673             if (getEmitModuleKind(compilerOptions) >= ts.ModuleKind.ES2015) {
10674                 return true;
10675             }
10676             return !compilerOptions.noImplicitUseStrict;
10677         }
10678         return false;
10679     }
10680     ts.isEffectiveStrictModeSourceFile = isEffectiveStrictModeSourceFile;
10681     function isBlockScope(node, parentNode) {
10682         switch (node.kind) {
10683             case 297:
10684             case 258:
10685             case 287:
10686             case 256:
10687             case 237:
10688             case 238:
10689             case 239:
10690             case 166:
10691             case 165:
10692             case 167:
10693             case 168:
10694             case 251:
10695             case 208:
10696             case 209:
10697                 return true;
10698             case 230:
10699                 return !ts.isFunctionLike(parentNode);
10700         }
10701         return false;
10702     }
10703     ts.isBlockScope = isBlockScope;
10704     function isDeclarationWithTypeParameters(node) {
10705         switch (node.kind) {
10706             case 324:
10707             case 331:
10708             case 313:
10709                 return true;
10710             default:
10711                 ts.assertType(node);
10712                 return isDeclarationWithTypeParameterChildren(node);
10713         }
10714     }
10715     ts.isDeclarationWithTypeParameters = isDeclarationWithTypeParameters;
10716     function isDeclarationWithTypeParameterChildren(node) {
10717         switch (node.kind) {
10718             case 169:
10719             case 170:
10720             case 164:
10721             case 171:
10722             case 174:
10723             case 175:
10724             case 308:
10725             case 252:
10726             case 221:
10727             case 253:
10728             case 254:
10729             case 330:
10730             case 251:
10731             case 165:
10732             case 166:
10733             case 167:
10734             case 168:
10735             case 208:
10736             case 209:
10737                 return true;
10738             default:
10739                 ts.assertType(node);
10740                 return false;
10741         }
10742     }
10743     ts.isDeclarationWithTypeParameterChildren = isDeclarationWithTypeParameterChildren;
10744     function isAnyImportSyntax(node) {
10745         switch (node.kind) {
10746             case 261:
10747             case 260:
10748                 return true;
10749             default:
10750                 return false;
10751         }
10752     }
10753     ts.isAnyImportSyntax = isAnyImportSyntax;
10754     function isLateVisibilityPaintedStatement(node) {
10755         switch (node.kind) {
10756             case 261:
10757             case 260:
10758             case 232:
10759             case 252:
10760             case 251:
10761             case 256:
10762             case 254:
10763             case 253:
10764             case 255:
10765                 return true;
10766             default:
10767                 return false;
10768         }
10769     }
10770     ts.isLateVisibilityPaintedStatement = isLateVisibilityPaintedStatement;
10771     function hasPossibleExternalModuleReference(node) {
10772         return isAnyImportOrReExport(node) || ts.isModuleDeclaration(node) || ts.isImportTypeNode(node) || isImportCall(node);
10773     }
10774     ts.hasPossibleExternalModuleReference = hasPossibleExternalModuleReference;
10775     function isAnyImportOrReExport(node) {
10776         return isAnyImportSyntax(node) || ts.isExportDeclaration(node);
10777     }
10778     ts.isAnyImportOrReExport = isAnyImportOrReExport;
10779     function getEnclosingBlockScopeContainer(node) {
10780         return ts.findAncestor(node.parent, function (current) { return isBlockScope(current, current.parent); });
10781     }
10782     ts.getEnclosingBlockScopeContainer = getEnclosingBlockScopeContainer;
10783     function declarationNameToString(name) {
10784         return !name || getFullWidth(name) === 0 ? "(Missing)" : getTextOfNode(name);
10785     }
10786     ts.declarationNameToString = declarationNameToString;
10787     function getNameFromIndexInfo(info) {
10788         return info.declaration ? declarationNameToString(info.declaration.parameters[0].name) : undefined;
10789     }
10790     ts.getNameFromIndexInfo = getNameFromIndexInfo;
10791     function isComputedNonLiteralName(name) {
10792         return name.kind === 158 && !isStringOrNumericLiteralLike(name.expression);
10793     }
10794     ts.isComputedNonLiteralName = isComputedNonLiteralName;
10795     function getTextOfPropertyName(name) {
10796         switch (name.kind) {
10797             case 78:
10798             case 79:
10799                 return name.escapedText;
10800             case 10:
10801             case 8:
10802             case 14:
10803                 return ts.escapeLeadingUnderscores(name.text);
10804             case 158:
10805                 if (isStringOrNumericLiteralLike(name.expression))
10806                     return ts.escapeLeadingUnderscores(name.expression.text);
10807                 return ts.Debug.fail("Text of property name cannot be read from non-literal-valued ComputedPropertyNames");
10808             default:
10809                 return ts.Debug.assertNever(name);
10810         }
10811     }
10812     ts.getTextOfPropertyName = getTextOfPropertyName;
10813     function entityNameToString(name) {
10814         switch (name.kind) {
10815             case 107:
10816                 return "this";
10817             case 79:
10818             case 78:
10819                 return getFullWidth(name) === 0 ? ts.idText(name) : getTextOfNode(name);
10820             case 157:
10821                 return entityNameToString(name.left) + "." + entityNameToString(name.right);
10822             case 201:
10823                 if (ts.isIdentifier(name.name) || ts.isPrivateIdentifier(name.name)) {
10824                     return entityNameToString(name.expression) + "." + entityNameToString(name.name);
10825                 }
10826                 else {
10827                     return ts.Debug.assertNever(name.name);
10828                 }
10829             default:
10830                 return ts.Debug.assertNever(name);
10831         }
10832     }
10833     ts.entityNameToString = entityNameToString;
10834     function createDiagnosticForNode(node, message, arg0, arg1, arg2, arg3) {
10835         var sourceFile = getSourceFileOfNode(node);
10836         return createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2, arg3);
10837     }
10838     ts.createDiagnosticForNode = createDiagnosticForNode;
10839     function createDiagnosticForNodeArray(sourceFile, nodes, message, arg0, arg1, arg2, arg3) {
10840         var start = ts.skipTrivia(sourceFile.text, nodes.pos);
10841         return createFileDiagnostic(sourceFile, start, nodes.end - start, message, arg0, arg1, arg2, arg3);
10842     }
10843     ts.createDiagnosticForNodeArray = createDiagnosticForNodeArray;
10844     function createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2, arg3) {
10845         var span = getErrorSpanForNode(sourceFile, node);
10846         return createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2, arg3);
10847     }
10848     ts.createDiagnosticForNodeInSourceFile = createDiagnosticForNodeInSourceFile;
10849     function createDiagnosticForNodeFromMessageChain(node, messageChain, relatedInformation) {
10850         var sourceFile = getSourceFileOfNode(node);
10851         var span = getErrorSpanForNode(sourceFile, node);
10852         return createFileDiagnosticFromMessageChain(sourceFile, span.start, span.length, messageChain, relatedInformation);
10853     }
10854     ts.createDiagnosticForNodeFromMessageChain = createDiagnosticForNodeFromMessageChain;
10855     function assertDiagnosticLocation(file, start, length) {
10856         ts.Debug.assertGreaterThanOrEqual(start, 0);
10857         ts.Debug.assertGreaterThanOrEqual(length, 0);
10858         if (file) {
10859             ts.Debug.assertLessThanOrEqual(start, file.text.length);
10860             ts.Debug.assertLessThanOrEqual(start + length, file.text.length);
10861         }
10862     }
10863     function createFileDiagnosticFromMessageChain(file, start, length, messageChain, relatedInformation) {
10864         assertDiagnosticLocation(file, start, length);
10865         return {
10866             file: file,
10867             start: start,
10868             length: length,
10869             code: messageChain.code,
10870             category: messageChain.category,
10871             messageText: messageChain.next ? messageChain : messageChain.messageText,
10872             relatedInformation: relatedInformation
10873         };
10874     }
10875     ts.createFileDiagnosticFromMessageChain = createFileDiagnosticFromMessageChain;
10876     function createDiagnosticForFileFromMessageChain(sourceFile, messageChain, relatedInformation) {
10877         return {
10878             file: sourceFile,
10879             start: 0,
10880             length: 0,
10881             code: messageChain.code,
10882             category: messageChain.category,
10883             messageText: messageChain.next ? messageChain : messageChain.messageText,
10884             relatedInformation: relatedInformation
10885         };
10886     }
10887     ts.createDiagnosticForFileFromMessageChain = createDiagnosticForFileFromMessageChain;
10888     function createDiagnosticForRange(sourceFile, range, message) {
10889         return {
10890             file: sourceFile,
10891             start: range.pos,
10892             length: range.end - range.pos,
10893             code: message.code,
10894             category: message.category,
10895             messageText: message.message,
10896         };
10897     }
10898     ts.createDiagnosticForRange = createDiagnosticForRange;
10899     function getSpanOfTokenAtPosition(sourceFile, pos) {
10900         var scanner = ts.createScanner(sourceFile.languageVersion, true, sourceFile.languageVariant, sourceFile.text, undefined, pos);
10901         scanner.scan();
10902         var start = scanner.getTokenPos();
10903         return ts.createTextSpanFromBounds(start, scanner.getTextPos());
10904     }
10905     ts.getSpanOfTokenAtPosition = getSpanOfTokenAtPosition;
10906     function getErrorSpanForArrowFunction(sourceFile, node) {
10907         var pos = ts.skipTrivia(sourceFile.text, node.pos);
10908         if (node.body && node.body.kind === 230) {
10909             var startLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.pos).line;
10910             var endLine = ts.getLineAndCharacterOfPosition(sourceFile, node.body.end).line;
10911             if (startLine < endLine) {
10912                 return ts.createTextSpan(pos, getEndLinePosition(startLine, sourceFile) - pos + 1);
10913             }
10914         }
10915         return ts.createTextSpanFromBounds(pos, node.end);
10916     }
10917     function getErrorSpanForNode(sourceFile, node) {
10918         var errorNode = node;
10919         switch (node.kind) {
10920             case 297:
10921                 var pos_1 = ts.skipTrivia(sourceFile.text, 0, false);
10922                 if (pos_1 === sourceFile.text.length) {
10923                     return ts.createTextSpan(0, 0);
10924                 }
10925                 return getSpanOfTokenAtPosition(sourceFile, pos_1);
10926             case 249:
10927             case 198:
10928             case 252:
10929             case 221:
10930             case 253:
10931             case 256:
10932             case 255:
10933             case 291:
10934             case 251:
10935             case 208:
10936             case 165:
10937             case 167:
10938             case 168:
10939             case 254:
10940             case 163:
10941             case 162:
10942                 errorNode = node.name;
10943                 break;
10944             case 209:
10945                 return getErrorSpanForArrowFunction(sourceFile, node);
10946             case 284:
10947             case 285:
10948                 var start = ts.skipTrivia(sourceFile.text, node.pos);
10949                 var end = node.statements.length > 0 ? node.statements[0].pos : node.end;
10950                 return ts.createTextSpanFromBounds(start, end);
10951         }
10952         if (errorNode === undefined) {
10953             return getSpanOfTokenAtPosition(sourceFile, node.pos);
10954         }
10955         ts.Debug.assert(!ts.isJSDoc(errorNode));
10956         var isMissing = nodeIsMissing(errorNode);
10957         var pos = isMissing || ts.isJsxText(node)
10958             ? errorNode.pos
10959             : ts.skipTrivia(sourceFile.text, errorNode.pos);
10960         if (isMissing) {
10961             ts.Debug.assert(pos === errorNode.pos, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10962             ts.Debug.assert(pos === errorNode.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10963         }
10964         else {
10965             ts.Debug.assert(pos >= errorNode.pos, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10966             ts.Debug.assert(pos <= errorNode.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809");
10967         }
10968         return ts.createTextSpanFromBounds(pos, errorNode.end);
10969     }
10970     ts.getErrorSpanForNode = getErrorSpanForNode;
10971     function isExternalOrCommonJsModule(file) {
10972         return (file.externalModuleIndicator || file.commonJsModuleIndicator) !== undefined;
10973     }
10974     ts.isExternalOrCommonJsModule = isExternalOrCommonJsModule;
10975     function isJsonSourceFile(file) {
10976         return file.scriptKind === 6;
10977     }
10978     ts.isJsonSourceFile = isJsonSourceFile;
10979     function isEnumConst(node) {
10980         return !!(ts.getCombinedModifierFlags(node) & 2048);
10981     }
10982     ts.isEnumConst = isEnumConst;
10983     function isDeclarationReadonly(declaration) {
10984         return !!(ts.getCombinedModifierFlags(declaration) & 64 && !ts.isParameterPropertyDeclaration(declaration, declaration.parent));
10985     }
10986     ts.isDeclarationReadonly = isDeclarationReadonly;
10987     function isVarConst(node) {
10988         return !!(ts.getCombinedNodeFlags(node) & 2);
10989     }
10990     ts.isVarConst = isVarConst;
10991     function isLet(node) {
10992         return !!(ts.getCombinedNodeFlags(node) & 1);
10993     }
10994     ts.isLet = isLet;
10995     function isSuperCall(n) {
10996         return n.kind === 203 && n.expression.kind === 105;
10997     }
10998     ts.isSuperCall = isSuperCall;
10999     function isImportCall(n) {
11000         return n.kind === 203 && n.expression.kind === 99;
11001     }
11002     ts.isImportCall = isImportCall;
11003     function isImportMeta(n) {
11004         return ts.isMetaProperty(n)
11005             && n.keywordToken === 99
11006             && n.name.escapedText === "meta";
11007     }
11008     ts.isImportMeta = isImportMeta;
11009     function isLiteralImportTypeNode(n) {
11010         return ts.isImportTypeNode(n) && ts.isLiteralTypeNode(n.argument) && ts.isStringLiteral(n.argument.literal);
11011     }
11012     ts.isLiteralImportTypeNode = isLiteralImportTypeNode;
11013     function isPrologueDirective(node) {
11014         return node.kind === 233
11015             && node.expression.kind === 10;
11016     }
11017     ts.isPrologueDirective = isPrologueDirective;
11018     function isCustomPrologue(node) {
11019         return !!(getEmitFlags(node) & 1048576);
11020     }
11021     ts.isCustomPrologue = isCustomPrologue;
11022     function isHoistedFunction(node) {
11023         return isCustomPrologue(node)
11024             && ts.isFunctionDeclaration(node);
11025     }
11026     ts.isHoistedFunction = isHoistedFunction;
11027     function isHoistedVariable(node) {
11028         return ts.isIdentifier(node.name)
11029             && !node.initializer;
11030     }
11031     function isHoistedVariableStatement(node) {
11032         return isCustomPrologue(node)
11033             && ts.isVariableStatement(node)
11034             && ts.every(node.declarationList.declarations, isHoistedVariable);
11035     }
11036     ts.isHoistedVariableStatement = isHoistedVariableStatement;
11037     function getLeadingCommentRangesOfNode(node, sourceFileOfNode) {
11038         return node.kind !== 11 ? ts.getLeadingCommentRanges(sourceFileOfNode.text, node.pos) : undefined;
11039     }
11040     ts.getLeadingCommentRangesOfNode = getLeadingCommentRangesOfNode;
11041     function getJSDocCommentRanges(node, text) {
11042         var commentRanges = (node.kind === 160 ||
11043             node.kind === 159 ||
11044             node.kind === 208 ||
11045             node.kind === 209 ||
11046             node.kind === 207) ?
11047             ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) :
11048             ts.getLeadingCommentRanges(text, node.pos);
11049         return ts.filter(commentRanges, function (comment) {
11050             return text.charCodeAt(comment.pos + 1) === 42 &&
11051                 text.charCodeAt(comment.pos + 2) === 42 &&
11052                 text.charCodeAt(comment.pos + 3) !== 47;
11053         });
11054     }
11055     ts.getJSDocCommentRanges = getJSDocCommentRanges;
11056     ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
11057     var fullTripleSlashReferenceTypeReferenceDirectiveRegEx = /^(\/\/\/\s*<reference\s+types\s*=\s*)('|")(.+?)\2.*?\/>/;
11058     ts.fullTripleSlashAMDReferencePathRegEx = /^(\/\/\/\s*<amd-dependency\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
11059     var defaultLibReferenceRegEx = /^(\/\/\/\s*<reference\s+no-default-lib\s*=\s*)('|")(.+?)\2\s*\/>/;
11060     function isPartOfTypeNode(node) {
11061         if (172 <= node.kind && node.kind <= 195) {
11062             return true;
11063         }
11064         switch (node.kind) {
11065             case 128:
11066             case 152:
11067             case 144:
11068             case 155:
11069             case 147:
11070             case 131:
11071             case 148:
11072             case 145:
11073             case 150:
11074             case 141:
11075                 return true;
11076             case 113:
11077                 return node.parent.kind !== 212;
11078             case 223:
11079                 return !isExpressionWithTypeArgumentsInClassExtendsClause(node);
11080             case 159:
11081                 return node.parent.kind === 190 || node.parent.kind === 185;
11082             case 78:
11083                 if (node.parent.kind === 157 && node.parent.right === node) {
11084                     node = node.parent;
11085                 }
11086                 else if (node.parent.kind === 201 && node.parent.name === node) {
11087                     node = node.parent;
11088                 }
11089                 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'.");
11090             case 157:
11091             case 201:
11092             case 107: {
11093                 var parent = node.parent;
11094                 if (parent.kind === 176) {
11095                     return false;
11096                 }
11097                 if (parent.kind === 195) {
11098                     return !parent.isTypeOf;
11099                 }
11100                 if (172 <= parent.kind && parent.kind <= 195) {
11101                     return true;
11102                 }
11103                 switch (parent.kind) {
11104                     case 223:
11105                         return !isExpressionWithTypeArgumentsInClassExtendsClause(parent);
11106                     case 159:
11107                         return node === parent.constraint;
11108                     case 330:
11109                         return node === parent.constraint;
11110                     case 163:
11111                     case 162:
11112                     case 160:
11113                     case 249:
11114                         return node === parent.type;
11115                     case 251:
11116                     case 208:
11117                     case 209:
11118                     case 166:
11119                     case 165:
11120                     case 164:
11121                     case 167:
11122                     case 168:
11123                         return node === parent.type;
11124                     case 169:
11125                     case 170:
11126                     case 171:
11127                         return node === parent.type;
11128                     case 206:
11129                         return node === parent.type;
11130                     case 203:
11131                     case 204:
11132                         return ts.contains(parent.typeArguments, node);
11133                     case 205:
11134                         return false;
11135                 }
11136             }
11137         }
11138         return false;
11139     }
11140     ts.isPartOfTypeNode = isPartOfTypeNode;
11141     function isChildOfNodeWithKind(node, kind) {
11142         while (node) {
11143             if (node.kind === kind) {
11144                 return true;
11145             }
11146             node = node.parent;
11147         }
11148         return false;
11149     }
11150     ts.isChildOfNodeWithKind = isChildOfNodeWithKind;
11151     function forEachReturnStatement(body, visitor) {
11152         return traverse(body);
11153         function traverse(node) {
11154             switch (node.kind) {
11155                 case 242:
11156                     return visitor(node);
11157                 case 258:
11158                 case 230:
11159                 case 234:
11160                 case 235:
11161                 case 236:
11162                 case 237:
11163                 case 238:
11164                 case 239:
11165                 case 243:
11166                 case 244:
11167                 case 284:
11168                 case 285:
11169                 case 245:
11170                 case 247:
11171                 case 287:
11172                     return ts.forEachChild(node, traverse);
11173             }
11174         }
11175     }
11176     ts.forEachReturnStatement = forEachReturnStatement;
11177     function forEachYieldExpression(body, visitor) {
11178         return traverse(body);
11179         function traverse(node) {
11180             switch (node.kind) {
11181                 case 219:
11182                     visitor(node);
11183                     var operand = node.expression;
11184                     if (operand) {
11185                         traverse(operand);
11186                     }
11187                     return;
11188                 case 255:
11189                 case 253:
11190                 case 256:
11191                 case 254:
11192                     return;
11193                 default:
11194                     if (ts.isFunctionLike(node)) {
11195                         if (node.name && node.name.kind === 158) {
11196                             traverse(node.name.expression);
11197                             return;
11198                         }
11199                     }
11200                     else if (!isPartOfTypeNode(node)) {
11201                         ts.forEachChild(node, traverse);
11202                     }
11203             }
11204         }
11205     }
11206     ts.forEachYieldExpression = forEachYieldExpression;
11207     function getRestParameterElementType(node) {
11208         if (node && node.kind === 178) {
11209             return node.elementType;
11210         }
11211         else if (node && node.kind === 173) {
11212             return ts.singleOrUndefined(node.typeArguments);
11213         }
11214         else {
11215             return undefined;
11216         }
11217     }
11218     ts.getRestParameterElementType = getRestParameterElementType;
11219     function getMembersOfDeclaration(node) {
11220         switch (node.kind) {
11221             case 253:
11222             case 252:
11223             case 221:
11224             case 177:
11225                 return node.members;
11226             case 200:
11227                 return node.properties;
11228         }
11229     }
11230     ts.getMembersOfDeclaration = getMembersOfDeclaration;
11231     function isVariableLike(node) {
11232         if (node) {
11233             switch (node.kind) {
11234                 case 198:
11235                 case 291:
11236                 case 160:
11237                 case 288:
11238                 case 163:
11239                 case 162:
11240                 case 289:
11241                 case 249:
11242                     return true;
11243             }
11244         }
11245         return false;
11246     }
11247     ts.isVariableLike = isVariableLike;
11248     function isVariableLikeOrAccessor(node) {
11249         return isVariableLike(node) || ts.isAccessor(node);
11250     }
11251     ts.isVariableLikeOrAccessor = isVariableLikeOrAccessor;
11252     function isVariableDeclarationInVariableStatement(node) {
11253         return node.parent.kind === 250
11254             && node.parent.parent.kind === 232;
11255     }
11256     ts.isVariableDeclarationInVariableStatement = isVariableDeclarationInVariableStatement;
11257     function isValidESSymbolDeclaration(node) {
11258         return ts.isVariableDeclaration(node) ? isVarConst(node) && ts.isIdentifier(node.name) && isVariableDeclarationInVariableStatement(node) :
11259             ts.isPropertyDeclaration(node) ? hasEffectiveReadonlyModifier(node) && hasStaticModifier(node) :
11260                 ts.isPropertySignature(node) && hasEffectiveReadonlyModifier(node);
11261     }
11262     ts.isValidESSymbolDeclaration = isValidESSymbolDeclaration;
11263     function introducesArgumentsExoticObject(node) {
11264         switch (node.kind) {
11265             case 165:
11266             case 164:
11267             case 166:
11268             case 167:
11269             case 168:
11270             case 251:
11271             case 208:
11272                 return true;
11273         }
11274         return false;
11275     }
11276     ts.introducesArgumentsExoticObject = introducesArgumentsExoticObject;
11277     function unwrapInnermostStatementOfLabel(node, beforeUnwrapLabelCallback) {
11278         while (true) {
11279             if (beforeUnwrapLabelCallback) {
11280                 beforeUnwrapLabelCallback(node);
11281             }
11282             if (node.statement.kind !== 245) {
11283                 return node.statement;
11284             }
11285             node = node.statement;
11286         }
11287     }
11288     ts.unwrapInnermostStatementOfLabel = unwrapInnermostStatementOfLabel;
11289     function isFunctionBlock(node) {
11290         return node && node.kind === 230 && ts.isFunctionLike(node.parent);
11291     }
11292     ts.isFunctionBlock = isFunctionBlock;
11293     function isObjectLiteralMethod(node) {
11294         return node && node.kind === 165 && node.parent.kind === 200;
11295     }
11296     ts.isObjectLiteralMethod = isObjectLiteralMethod;
11297     function isObjectLiteralOrClassExpressionMethod(node) {
11298         return node.kind === 165 &&
11299             (node.parent.kind === 200 ||
11300                 node.parent.kind === 221);
11301     }
11302     ts.isObjectLiteralOrClassExpressionMethod = isObjectLiteralOrClassExpressionMethod;
11303     function isIdentifierTypePredicate(predicate) {
11304         return predicate && predicate.kind === 1;
11305     }
11306     ts.isIdentifierTypePredicate = isIdentifierTypePredicate;
11307     function isThisTypePredicate(predicate) {
11308         return predicate && predicate.kind === 0;
11309     }
11310     ts.isThisTypePredicate = isThisTypePredicate;
11311     function getPropertyAssignment(objectLiteral, key, key2) {
11312         return objectLiteral.properties.filter(function (property) {
11313             if (property.kind === 288) {
11314                 var propName = getTextOfPropertyName(property.name);
11315                 return key === propName || (!!key2 && key2 === propName);
11316             }
11317             return false;
11318         });
11319     }
11320     ts.getPropertyAssignment = getPropertyAssignment;
11321     function getPropertyArrayElementValue(objectLiteral, propKey, elementValue) {
11322         return ts.firstDefined(getPropertyAssignment(objectLiteral, propKey), function (property) {
11323             return ts.isArrayLiteralExpression(property.initializer) ?
11324                 ts.find(property.initializer.elements, function (element) { return ts.isStringLiteral(element) && element.text === elementValue; }) :
11325                 undefined;
11326         });
11327     }
11328     ts.getPropertyArrayElementValue = getPropertyArrayElementValue;
11329     function getTsConfigObjectLiteralExpression(tsConfigSourceFile) {
11330         if (tsConfigSourceFile && tsConfigSourceFile.statements.length) {
11331             var expression = tsConfigSourceFile.statements[0].expression;
11332             return ts.tryCast(expression, ts.isObjectLiteralExpression);
11333         }
11334     }
11335     ts.getTsConfigObjectLiteralExpression = getTsConfigObjectLiteralExpression;
11336     function getTsConfigPropArrayElementValue(tsConfigSourceFile, propKey, elementValue) {
11337         return ts.firstDefined(getTsConfigPropArray(tsConfigSourceFile, propKey), function (property) {
11338             return ts.isArrayLiteralExpression(property.initializer) ?
11339                 ts.find(property.initializer.elements, function (element) { return ts.isStringLiteral(element) && element.text === elementValue; }) :
11340                 undefined;
11341         });
11342     }
11343     ts.getTsConfigPropArrayElementValue = getTsConfigPropArrayElementValue;
11344     function getTsConfigPropArray(tsConfigSourceFile, propKey) {
11345         var jsonObjectLiteral = getTsConfigObjectLiteralExpression(tsConfigSourceFile);
11346         return jsonObjectLiteral ? getPropertyAssignment(jsonObjectLiteral, propKey) : ts.emptyArray;
11347     }
11348     ts.getTsConfigPropArray = getTsConfigPropArray;
11349     function getContainingFunction(node) {
11350         return ts.findAncestor(node.parent, ts.isFunctionLike);
11351     }
11352     ts.getContainingFunction = getContainingFunction;
11353     function getContainingFunctionDeclaration(node) {
11354         return ts.findAncestor(node.parent, ts.isFunctionLikeDeclaration);
11355     }
11356     ts.getContainingFunctionDeclaration = getContainingFunctionDeclaration;
11357     function getContainingClass(node) {
11358         return ts.findAncestor(node.parent, ts.isClassLike);
11359     }
11360     ts.getContainingClass = getContainingClass;
11361     function getThisContainer(node, includeArrowFunctions) {
11362         ts.Debug.assert(node.kind !== 297);
11363         while (true) {
11364             node = node.parent;
11365             if (!node) {
11366                 return ts.Debug.fail();
11367             }
11368             switch (node.kind) {
11369                 case 158:
11370                     if (ts.isClassLike(node.parent.parent)) {
11371                         return node;
11372                     }
11373                     node = node.parent;
11374                     break;
11375                 case 161:
11376                     if (node.parent.kind === 160 && ts.isClassElement(node.parent.parent)) {
11377                         node = node.parent.parent;
11378                     }
11379                     else if (ts.isClassElement(node.parent)) {
11380                         node = node.parent;
11381                     }
11382                     break;
11383                 case 209:
11384                     if (!includeArrowFunctions) {
11385                         continue;
11386                     }
11387                 case 251:
11388                 case 208:
11389                 case 256:
11390                 case 163:
11391                 case 162:
11392                 case 165:
11393                 case 164:
11394                 case 166:
11395                 case 167:
11396                 case 168:
11397                 case 169:
11398                 case 170:
11399                 case 171:
11400                 case 255:
11401                 case 297:
11402                     return node;
11403             }
11404         }
11405     }
11406     ts.getThisContainer = getThisContainer;
11407     function isInTopLevelContext(node) {
11408         if (ts.isIdentifier(node) && (ts.isClassDeclaration(node.parent) || ts.isFunctionDeclaration(node.parent)) && node.parent.name === node) {
11409             node = node.parent;
11410         }
11411         var container = getThisContainer(node, true);
11412         return ts.isSourceFile(container);
11413     }
11414     ts.isInTopLevelContext = isInTopLevelContext;
11415     function getNewTargetContainer(node) {
11416         var container = getThisContainer(node, false);
11417         if (container) {
11418             switch (container.kind) {
11419                 case 166:
11420                 case 251:
11421                 case 208:
11422                     return container;
11423             }
11424         }
11425         return undefined;
11426     }
11427     ts.getNewTargetContainer = getNewTargetContainer;
11428     function getSuperContainer(node, stopOnFunctions) {
11429         while (true) {
11430             node = node.parent;
11431             if (!node) {
11432                 return node;
11433             }
11434             switch (node.kind) {
11435                 case 158:
11436                     node = node.parent;
11437                     break;
11438                 case 251:
11439                 case 208:
11440                 case 209:
11441                     if (!stopOnFunctions) {
11442                         continue;
11443                     }
11444                 case 163:
11445                 case 162:
11446                 case 165:
11447                 case 164:
11448                 case 166:
11449                 case 167:
11450                 case 168:
11451                     return node;
11452                 case 161:
11453                     if (node.parent.kind === 160 && ts.isClassElement(node.parent.parent)) {
11454                         node = node.parent.parent;
11455                     }
11456                     else if (ts.isClassElement(node.parent)) {
11457                         node = node.parent;
11458                     }
11459                     break;
11460             }
11461         }
11462     }
11463     ts.getSuperContainer = getSuperContainer;
11464     function getImmediatelyInvokedFunctionExpression(func) {
11465         if (func.kind === 208 || func.kind === 209) {
11466             var prev = func;
11467             var parent = func.parent;
11468             while (parent.kind === 207) {
11469                 prev = parent;
11470                 parent = parent.parent;
11471             }
11472             if (parent.kind === 203 && parent.expression === prev) {
11473                 return parent;
11474             }
11475         }
11476     }
11477     ts.getImmediatelyInvokedFunctionExpression = getImmediatelyInvokedFunctionExpression;
11478     function isSuperOrSuperProperty(node) {
11479         return node.kind === 105
11480             || isSuperProperty(node);
11481     }
11482     ts.isSuperOrSuperProperty = isSuperOrSuperProperty;
11483     function isSuperProperty(node) {
11484         var kind = node.kind;
11485         return (kind === 201 || kind === 202)
11486             && node.expression.kind === 105;
11487     }
11488     ts.isSuperProperty = isSuperProperty;
11489     function isThisProperty(node) {
11490         var kind = node.kind;
11491         return (kind === 201 || kind === 202)
11492             && node.expression.kind === 107;
11493     }
11494     ts.isThisProperty = isThisProperty;
11495     function isThisInitializedDeclaration(node) {
11496         var _a;
11497         return !!node && ts.isVariableDeclaration(node) && ((_a = node.initializer) === null || _a === void 0 ? void 0 : _a.kind) === 107;
11498     }
11499     ts.isThisInitializedDeclaration = isThisInitializedDeclaration;
11500     function getEntityNameFromTypeNode(node) {
11501         switch (node.kind) {
11502             case 173:
11503                 return node.typeName;
11504             case 223:
11505                 return isEntityNameExpression(node.expression)
11506                     ? node.expression
11507                     : undefined;
11508             case 78:
11509             case 157:
11510                 return node;
11511         }
11512         return undefined;
11513     }
11514     ts.getEntityNameFromTypeNode = getEntityNameFromTypeNode;
11515     function getInvokedExpression(node) {
11516         switch (node.kind) {
11517             case 205:
11518                 return node.tag;
11519             case 275:
11520             case 274:
11521                 return node.tagName;
11522             default:
11523                 return node.expression;
11524         }
11525     }
11526     ts.getInvokedExpression = getInvokedExpression;
11527     function nodeCanBeDecorated(node, parent, grandparent) {
11528         if (ts.isNamedDeclaration(node) && ts.isPrivateIdentifier(node.name)) {
11529             return false;
11530         }
11531         switch (node.kind) {
11532             case 252:
11533                 return true;
11534             case 163:
11535                 return parent.kind === 252;
11536             case 167:
11537             case 168:
11538             case 165:
11539                 return node.body !== undefined
11540                     && parent.kind === 252;
11541             case 160:
11542                 return parent.body !== undefined
11543                     && (parent.kind === 166
11544                         || parent.kind === 165
11545                         || parent.kind === 168)
11546                     && grandparent.kind === 252;
11547         }
11548         return false;
11549     }
11550     ts.nodeCanBeDecorated = nodeCanBeDecorated;
11551     function nodeIsDecorated(node, parent, grandparent) {
11552         return node.decorators !== undefined
11553             && nodeCanBeDecorated(node, parent, grandparent);
11554     }
11555     ts.nodeIsDecorated = nodeIsDecorated;
11556     function nodeOrChildIsDecorated(node, parent, grandparent) {
11557         return nodeIsDecorated(node, parent, grandparent) || childIsDecorated(node, parent);
11558     }
11559     ts.nodeOrChildIsDecorated = nodeOrChildIsDecorated;
11560     function childIsDecorated(node, parent) {
11561         switch (node.kind) {
11562             case 252:
11563                 return ts.some(node.members, function (m) { return nodeOrChildIsDecorated(m, node, parent); });
11564             case 165:
11565             case 168:
11566                 return ts.some(node.parameters, function (p) { return nodeIsDecorated(p, node, parent); });
11567             default:
11568                 return false;
11569         }
11570     }
11571     ts.childIsDecorated = childIsDecorated;
11572     function isJSXTagName(node) {
11573         var parent = node.parent;
11574         if (parent.kind === 275 ||
11575             parent.kind === 274 ||
11576             parent.kind === 276) {
11577             return parent.tagName === node;
11578         }
11579         return false;
11580     }
11581     ts.isJSXTagName = isJSXTagName;
11582     function isExpressionNode(node) {
11583         switch (node.kind) {
11584             case 105:
11585             case 103:
11586             case 109:
11587             case 94:
11588             case 13:
11589             case 199:
11590             case 200:
11591             case 201:
11592             case 202:
11593             case 203:
11594             case 204:
11595             case 205:
11596             case 224:
11597             case 206:
11598             case 225:
11599             case 207:
11600             case 208:
11601             case 221:
11602             case 209:
11603             case 212:
11604             case 210:
11605             case 211:
11606             case 214:
11607             case 215:
11608             case 216:
11609             case 217:
11610             case 220:
11611             case 218:
11612             case 222:
11613             case 273:
11614             case 274:
11615             case 277:
11616             case 219:
11617             case 213:
11618             case 226:
11619                 return true;
11620             case 157:
11621                 while (node.parent.kind === 157) {
11622                     node = node.parent;
11623                 }
11624                 return node.parent.kind === 176 || isJSXTagName(node);
11625             case 78:
11626                 if (node.parent.kind === 176 || isJSXTagName(node)) {
11627                     return true;
11628                 }
11629             case 8:
11630             case 9:
11631             case 10:
11632             case 14:
11633             case 107:
11634                 return isInExpressionContext(node);
11635             default:
11636                 return false;
11637         }
11638     }
11639     ts.isExpressionNode = isExpressionNode;
11640     function isInExpressionContext(node) {
11641         var parent = node.parent;
11642         switch (parent.kind) {
11643             case 249:
11644             case 160:
11645             case 163:
11646             case 162:
11647             case 291:
11648             case 288:
11649             case 198:
11650                 return parent.initializer === node;
11651             case 233:
11652             case 234:
11653             case 235:
11654             case 236:
11655             case 242:
11656             case 243:
11657             case 244:
11658             case 284:
11659             case 246:
11660                 return parent.expression === node;
11661             case 237:
11662                 var forStatement = parent;
11663                 return (forStatement.initializer === node && forStatement.initializer.kind !== 250) ||
11664                     forStatement.condition === node ||
11665                     forStatement.incrementor === node;
11666             case 238:
11667             case 239:
11668                 var forInStatement = parent;
11669                 return (forInStatement.initializer === node && forInStatement.initializer.kind !== 250) ||
11670                     forInStatement.expression === node;
11671             case 206:
11672             case 224:
11673                 return node === parent.expression;
11674             case 228:
11675                 return node === parent.expression;
11676             case 158:
11677                 return node === parent.expression;
11678             case 161:
11679             case 283:
11680             case 282:
11681             case 290:
11682                 return true;
11683             case 223:
11684                 return parent.expression === node && isExpressionWithTypeArgumentsInClassExtendsClause(parent);
11685             case 289:
11686                 return parent.objectAssignmentInitializer === node;
11687             default:
11688                 return isExpressionNode(parent);
11689         }
11690     }
11691     ts.isInExpressionContext = isInExpressionContext;
11692     function isPartOfTypeQuery(node) {
11693         while (node.kind === 157 || node.kind === 78) {
11694             node = node.parent;
11695         }
11696         return node.kind === 176;
11697     }
11698     ts.isPartOfTypeQuery = isPartOfTypeQuery;
11699     function isExternalModuleImportEqualsDeclaration(node) {
11700         return node.kind === 260 && node.moduleReference.kind === 272;
11701     }
11702     ts.isExternalModuleImportEqualsDeclaration = isExternalModuleImportEqualsDeclaration;
11703     function getExternalModuleImportEqualsDeclarationExpression(node) {
11704         ts.Debug.assert(isExternalModuleImportEqualsDeclaration(node));
11705         return node.moduleReference.expression;
11706     }
11707     ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression;
11708     function getExternalModuleRequireArgument(node) {
11709         return isRequireVariableDeclaration(node, true)
11710             && getLeftmostAccessExpression(node.initializer).arguments[0];
11711     }
11712     ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument;
11713     function isInternalModuleImportEqualsDeclaration(node) {
11714         return node.kind === 260 && node.moduleReference.kind !== 272;
11715     }
11716     ts.isInternalModuleImportEqualsDeclaration = isInternalModuleImportEqualsDeclaration;
11717     function isSourceFileJS(file) {
11718         return isInJSFile(file);
11719     }
11720     ts.isSourceFileJS = isSourceFileJS;
11721     function isSourceFileNotJS(file) {
11722         return !isInJSFile(file);
11723     }
11724     ts.isSourceFileNotJS = isSourceFileNotJS;
11725     function isInJSFile(node) {
11726         return !!node && !!(node.flags & 131072);
11727     }
11728     ts.isInJSFile = isInJSFile;
11729     function isInJsonFile(node) {
11730         return !!node && !!(node.flags & 33554432);
11731     }
11732     ts.isInJsonFile = isInJsonFile;
11733     function isSourceFileNotJson(file) {
11734         return !isJsonSourceFile(file);
11735     }
11736     ts.isSourceFileNotJson = isSourceFileNotJson;
11737     function isInJSDoc(node) {
11738         return !!node && !!(node.flags & 4194304);
11739     }
11740     ts.isInJSDoc = isInJSDoc;
11741     function isJSDocIndexSignature(node) {
11742         return ts.isTypeReferenceNode(node) &&
11743             ts.isIdentifier(node.typeName) &&
11744             node.typeName.escapedText === "Object" &&
11745             node.typeArguments && node.typeArguments.length === 2 &&
11746             (node.typeArguments[0].kind === 147 || node.typeArguments[0].kind === 144);
11747     }
11748     ts.isJSDocIndexSignature = isJSDocIndexSignature;
11749     function isRequireCall(callExpression, requireStringLiteralLikeArgument) {
11750         if (callExpression.kind !== 203) {
11751             return false;
11752         }
11753         var _a = callExpression, expression = _a.expression, args = _a.arguments;
11754         if (expression.kind !== 78 || expression.escapedText !== "require") {
11755             return false;
11756         }
11757         if (args.length !== 1) {
11758             return false;
11759         }
11760         var arg = args[0];
11761         return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg);
11762     }
11763     ts.isRequireCall = isRequireCall;
11764     function isRequireVariableDeclaration(node, requireStringLiteralLikeArgument) {
11765         if (node.kind === 198) {
11766             node = node.parent.parent;
11767         }
11768         return ts.isVariableDeclaration(node) && !!node.initializer && isRequireCall(getLeftmostAccessExpression(node.initializer), requireStringLiteralLikeArgument);
11769     }
11770     ts.isRequireVariableDeclaration = isRequireVariableDeclaration;
11771     function isRequireVariableStatement(node, requireStringLiteralLikeArgument) {
11772         if (requireStringLiteralLikeArgument === void 0) { requireStringLiteralLikeArgument = true; }
11773         return ts.isVariableStatement(node)
11774             && node.declarationList.declarations.length > 0
11775             && ts.every(node.declarationList.declarations, function (decl) { return isRequireVariableDeclaration(decl, requireStringLiteralLikeArgument); });
11776     }
11777     ts.isRequireVariableStatement = isRequireVariableStatement;
11778     function isSingleOrDoubleQuote(charCode) {
11779         return charCode === 39 || charCode === 34;
11780     }
11781     ts.isSingleOrDoubleQuote = isSingleOrDoubleQuote;
11782     function isStringDoubleQuoted(str, sourceFile) {
11783         return getSourceTextOfNodeFromSourceFile(sourceFile, str).charCodeAt(0) === 34;
11784     }
11785     ts.isStringDoubleQuoted = isStringDoubleQuoted;
11786     function isAssignmentDeclaration(decl) {
11787         return ts.isBinaryExpression(decl) || isAccessExpression(decl) || ts.isIdentifier(decl) || ts.isCallExpression(decl);
11788     }
11789     ts.isAssignmentDeclaration = isAssignmentDeclaration;
11790     function getEffectiveInitializer(node) {
11791         if (isInJSFile(node) && node.initializer &&
11792             ts.isBinaryExpression(node.initializer) &&
11793             (node.initializer.operatorToken.kind === 56 || node.initializer.operatorToken.kind === 60) &&
11794             node.name && isEntityNameExpression(node.name) && isSameEntityName(node.name, node.initializer.left)) {
11795             return node.initializer.right;
11796         }
11797         return node.initializer;
11798     }
11799     ts.getEffectiveInitializer = getEffectiveInitializer;
11800     function getDeclaredExpandoInitializer(node) {
11801         var init = getEffectiveInitializer(node);
11802         return init && getExpandoInitializer(init, isPrototypeAccess(node.name));
11803     }
11804     ts.getDeclaredExpandoInitializer = getDeclaredExpandoInitializer;
11805     function hasExpandoValueProperty(node, isPrototypeAssignment) {
11806         return ts.forEach(node.properties, function (p) {
11807             return ts.isPropertyAssignment(p) &&
11808                 ts.isIdentifier(p.name) &&
11809                 p.name.escapedText === "value" &&
11810                 p.initializer &&
11811                 getExpandoInitializer(p.initializer, isPrototypeAssignment);
11812         });
11813     }
11814     function getAssignedExpandoInitializer(node) {
11815         if (node && node.parent && ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62) {
11816             var isPrototypeAssignment = isPrototypeAccess(node.parent.left);
11817             return getExpandoInitializer(node.parent.right, isPrototypeAssignment) ||
11818                 getDefaultedExpandoInitializer(node.parent.left, node.parent.right, isPrototypeAssignment);
11819         }
11820         if (node && ts.isCallExpression(node) && isBindableObjectDefinePropertyCall(node)) {
11821             var result = hasExpandoValueProperty(node.arguments[2], node.arguments[1].text === "prototype");
11822             if (result) {
11823                 return result;
11824             }
11825         }
11826     }
11827     ts.getAssignedExpandoInitializer = getAssignedExpandoInitializer;
11828     function getExpandoInitializer(initializer, isPrototypeAssignment) {
11829         if (ts.isCallExpression(initializer)) {
11830             var e = skipParentheses(initializer.expression);
11831             return e.kind === 208 || e.kind === 209 ? initializer : undefined;
11832         }
11833         if (initializer.kind === 208 ||
11834             initializer.kind === 221 ||
11835             initializer.kind === 209) {
11836             return initializer;
11837         }
11838         if (ts.isObjectLiteralExpression(initializer) && (initializer.properties.length === 0 || isPrototypeAssignment)) {
11839             return initializer;
11840         }
11841     }
11842     ts.getExpandoInitializer = getExpandoInitializer;
11843     function getDefaultedExpandoInitializer(name, initializer, isPrototypeAssignment) {
11844         var e = ts.isBinaryExpression(initializer)
11845             && (initializer.operatorToken.kind === 56 || initializer.operatorToken.kind === 60)
11846             && getExpandoInitializer(initializer.right, isPrototypeAssignment);
11847         if (e && isSameEntityName(name, initializer.left)) {
11848             return e;
11849         }
11850     }
11851     function isDefaultedExpandoInitializer(node) {
11852         var name = ts.isVariableDeclaration(node.parent) ? node.parent.name :
11853             ts.isBinaryExpression(node.parent) && node.parent.operatorToken.kind === 62 ? node.parent.left :
11854                 undefined;
11855         return name && getExpandoInitializer(node.right, isPrototypeAccess(name)) && isEntityNameExpression(name) && isSameEntityName(name, node.left);
11856     }
11857     ts.isDefaultedExpandoInitializer = isDefaultedExpandoInitializer;
11858     function getNameOfExpando(node) {
11859         if (ts.isBinaryExpression(node.parent)) {
11860             var parent = ((node.parent.operatorToken.kind === 56 || node.parent.operatorToken.kind === 60) && ts.isBinaryExpression(node.parent.parent)) ? node.parent.parent : node.parent;
11861             if (parent.operatorToken.kind === 62 && ts.isIdentifier(parent.left)) {
11862                 return parent.left;
11863             }
11864         }
11865         else if (ts.isVariableDeclaration(node.parent)) {
11866             return node.parent.name;
11867         }
11868     }
11869     ts.getNameOfExpando = getNameOfExpando;
11870     function isSameEntityName(name, initializer) {
11871         if (isPropertyNameLiteral(name) && isPropertyNameLiteral(initializer)) {
11872             return getTextOfIdentifierOrLiteral(name) === getTextOfIdentifierOrLiteral(initializer);
11873         }
11874         if (ts.isIdentifier(name) && isLiteralLikeAccess(initializer) &&
11875             (initializer.expression.kind === 107 ||
11876                 ts.isIdentifier(initializer.expression) &&
11877                     (initializer.expression.escapedText === "window" ||
11878                         initializer.expression.escapedText === "self" ||
11879                         initializer.expression.escapedText === "global"))) {
11880             var nameOrArgument = getNameOrArgument(initializer);
11881             if (ts.isPrivateIdentifier(nameOrArgument)) {
11882                 ts.Debug.fail("Unexpected PrivateIdentifier in name expression with literal-like access.");
11883             }
11884             return isSameEntityName(name, nameOrArgument);
11885         }
11886         if (isLiteralLikeAccess(name) && isLiteralLikeAccess(initializer)) {
11887             return getElementOrPropertyAccessName(name) === getElementOrPropertyAccessName(initializer)
11888                 && isSameEntityName(name.expression, initializer.expression);
11889         }
11890         return false;
11891     }
11892     ts.isSameEntityName = isSameEntityName;
11893     function getRightMostAssignedExpression(node) {
11894         while (isAssignmentExpression(node, true)) {
11895             node = node.right;
11896         }
11897         return node;
11898     }
11899     ts.getRightMostAssignedExpression = getRightMostAssignedExpression;
11900     function isExportsIdentifier(node) {
11901         return ts.isIdentifier(node) && node.escapedText === "exports";
11902     }
11903     ts.isExportsIdentifier = isExportsIdentifier;
11904     function isModuleIdentifier(node) {
11905         return ts.isIdentifier(node) && node.escapedText === "module";
11906     }
11907     ts.isModuleIdentifier = isModuleIdentifier;
11908     function isModuleExportsAccessExpression(node) {
11909         return (ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node))
11910             && isModuleIdentifier(node.expression)
11911             && getElementOrPropertyAccessName(node) === "exports";
11912     }
11913     ts.isModuleExportsAccessExpression = isModuleExportsAccessExpression;
11914     function getAssignmentDeclarationKind(expr) {
11915         var special = getAssignmentDeclarationKindWorker(expr);
11916         return special === 5 || isInJSFile(expr) ? special : 0;
11917     }
11918     ts.getAssignmentDeclarationKind = getAssignmentDeclarationKind;
11919     function isBindableObjectDefinePropertyCall(expr) {
11920         return ts.length(expr.arguments) === 3 &&
11921             ts.isPropertyAccessExpression(expr.expression) &&
11922             ts.isIdentifier(expr.expression.expression) &&
11923             ts.idText(expr.expression.expression) === "Object" &&
11924             ts.idText(expr.expression.name) === "defineProperty" &&
11925             isStringOrNumericLiteralLike(expr.arguments[1]) &&
11926             isBindableStaticNameExpression(expr.arguments[0], true);
11927     }
11928     ts.isBindableObjectDefinePropertyCall = isBindableObjectDefinePropertyCall;
11929     function isLiteralLikeAccess(node) {
11930         return ts.isPropertyAccessExpression(node) || isLiteralLikeElementAccess(node);
11931     }
11932     ts.isLiteralLikeAccess = isLiteralLikeAccess;
11933     function isLiteralLikeElementAccess(node) {
11934         return ts.isElementAccessExpression(node) && (isStringOrNumericLiteralLike(node.argumentExpression) ||
11935             isWellKnownSymbolSyntactically(node.argumentExpression));
11936     }
11937     ts.isLiteralLikeElementAccess = isLiteralLikeElementAccess;
11938     function isBindableStaticAccessExpression(node, excludeThisKeyword) {
11939         return ts.isPropertyAccessExpression(node) && (!excludeThisKeyword && node.expression.kind === 107 || ts.isIdentifier(node.name) && isBindableStaticNameExpression(node.expression, true))
11940             || isBindableStaticElementAccessExpression(node, excludeThisKeyword);
11941     }
11942     ts.isBindableStaticAccessExpression = isBindableStaticAccessExpression;
11943     function isBindableStaticElementAccessExpression(node, excludeThisKeyword) {
11944         return isLiteralLikeElementAccess(node)
11945             && ((!excludeThisKeyword && node.expression.kind === 107) ||
11946                 isEntityNameExpression(node.expression) ||
11947                 isBindableStaticAccessExpression(node.expression, true));
11948     }
11949     ts.isBindableStaticElementAccessExpression = isBindableStaticElementAccessExpression;
11950     function isBindableStaticNameExpression(node, excludeThisKeyword) {
11951         return isEntityNameExpression(node) || isBindableStaticAccessExpression(node, excludeThisKeyword);
11952     }
11953     ts.isBindableStaticNameExpression = isBindableStaticNameExpression;
11954     function getNameOrArgument(expr) {
11955         if (ts.isPropertyAccessExpression(expr)) {
11956             return expr.name;
11957         }
11958         return expr.argumentExpression;
11959     }
11960     ts.getNameOrArgument = getNameOrArgument;
11961     function getAssignmentDeclarationKindWorker(expr) {
11962         if (ts.isCallExpression(expr)) {
11963             if (!isBindableObjectDefinePropertyCall(expr)) {
11964                 return 0;
11965             }
11966             var entityName = expr.arguments[0];
11967             if (isExportsIdentifier(entityName) || isModuleExportsAccessExpression(entityName)) {
11968                 return 8;
11969             }
11970             if (isBindableStaticAccessExpression(entityName) && getElementOrPropertyAccessName(entityName) === "prototype") {
11971                 return 9;
11972             }
11973             return 7;
11974         }
11975         if (expr.operatorToken.kind !== 62 || !isAccessExpression(expr.left) || isVoidZero(getRightMostAssignedExpression(expr))) {
11976             return 0;
11977         }
11978         if (isBindableStaticNameExpression(expr.left.expression, true) && getElementOrPropertyAccessName(expr.left) === "prototype" && ts.isObjectLiteralExpression(getInitializerOfBinaryExpression(expr))) {
11979             return 6;
11980         }
11981         return getAssignmentDeclarationPropertyAccessKind(expr.left);
11982     }
11983     function isVoidZero(node) {
11984         return ts.isVoidExpression(node) && ts.isNumericLiteral(node.expression) && node.expression.text === "0";
11985     }
11986     function getElementOrPropertyAccessArgumentExpressionOrName(node) {
11987         if (ts.isPropertyAccessExpression(node)) {
11988             return node.name;
11989         }
11990         var arg = skipParentheses(node.argumentExpression);
11991         if (ts.isNumericLiteral(arg) || ts.isStringLiteralLike(arg)) {
11992             return arg;
11993         }
11994         return node;
11995     }
11996     ts.getElementOrPropertyAccessArgumentExpressionOrName = getElementOrPropertyAccessArgumentExpressionOrName;
11997     function getElementOrPropertyAccessName(node) {
11998         var name = getElementOrPropertyAccessArgumentExpressionOrName(node);
11999         if (name) {
12000             if (ts.isIdentifier(name)) {
12001                 return name.escapedText;
12002             }
12003             if (ts.isStringLiteralLike(name) || ts.isNumericLiteral(name)) {
12004                 return ts.escapeLeadingUnderscores(name.text);
12005             }
12006         }
12007         if (ts.isElementAccessExpression(node) && isWellKnownSymbolSyntactically(node.argumentExpression)) {
12008             return getPropertyNameForKnownSymbolName(ts.idText(node.argumentExpression.name));
12009         }
12010         return undefined;
12011     }
12012     ts.getElementOrPropertyAccessName = getElementOrPropertyAccessName;
12013     function getAssignmentDeclarationPropertyAccessKind(lhs) {
12014         if (lhs.expression.kind === 107) {
12015             return 4;
12016         }
12017         else if (isModuleExportsAccessExpression(lhs)) {
12018             return 2;
12019         }
12020         else if (isBindableStaticNameExpression(lhs.expression, true)) {
12021             if (isPrototypeAccess(lhs.expression)) {
12022                 return 3;
12023             }
12024             var nextToLast = lhs;
12025             while (!ts.isIdentifier(nextToLast.expression)) {
12026                 nextToLast = nextToLast.expression;
12027             }
12028             var id = nextToLast.expression;
12029             if ((id.escapedText === "exports" ||
12030                 id.escapedText === "module" && getElementOrPropertyAccessName(nextToLast) === "exports") &&
12031                 isBindableStaticAccessExpression(lhs)) {
12032                 return 1;
12033             }
12034             if (isBindableStaticNameExpression(lhs, true) || (ts.isElementAccessExpression(lhs) && isDynamicName(lhs))) {
12035                 return 5;
12036             }
12037         }
12038         return 0;
12039     }
12040     ts.getAssignmentDeclarationPropertyAccessKind = getAssignmentDeclarationPropertyAccessKind;
12041     function getInitializerOfBinaryExpression(expr) {
12042         while (ts.isBinaryExpression(expr.right)) {
12043             expr = expr.right;
12044         }
12045         return expr.right;
12046     }
12047     ts.getInitializerOfBinaryExpression = getInitializerOfBinaryExpression;
12048     function isPrototypePropertyAssignment(node) {
12049         return ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 3;
12050     }
12051     ts.isPrototypePropertyAssignment = isPrototypePropertyAssignment;
12052     function isSpecialPropertyDeclaration(expr) {
12053         return isInJSFile(expr) &&
12054             expr.parent && expr.parent.kind === 233 &&
12055             (!ts.isElementAccessExpression(expr) || isLiteralLikeElementAccess(expr)) &&
12056             !!ts.getJSDocTypeTag(expr.parent);
12057     }
12058     ts.isSpecialPropertyDeclaration = isSpecialPropertyDeclaration;
12059     function setValueDeclaration(symbol, node) {
12060         var valueDeclaration = symbol.valueDeclaration;
12061         if (!valueDeclaration ||
12062             !(node.flags & 8388608 && !(valueDeclaration.flags & 8388608)) &&
12063                 (isAssignmentDeclaration(valueDeclaration) && !isAssignmentDeclaration(node)) ||
12064             (valueDeclaration.kind !== node.kind && isEffectiveModuleDeclaration(valueDeclaration))) {
12065             symbol.valueDeclaration = node;
12066         }
12067     }
12068     ts.setValueDeclaration = setValueDeclaration;
12069     function isFunctionSymbol(symbol) {
12070         if (!symbol || !symbol.valueDeclaration) {
12071             return false;
12072         }
12073         var decl = symbol.valueDeclaration;
12074         return decl.kind === 251 || ts.isVariableDeclaration(decl) && decl.initializer && ts.isFunctionLike(decl.initializer);
12075     }
12076     ts.isFunctionSymbol = isFunctionSymbol;
12077     function importFromModuleSpecifier(node) {
12078         return tryGetImportFromModuleSpecifier(node) || ts.Debug.failBadSyntaxKind(node.parent);
12079     }
12080     ts.importFromModuleSpecifier = importFromModuleSpecifier;
12081     function tryGetImportFromModuleSpecifier(node) {
12082         switch (node.parent.kind) {
12083             case 261:
12084             case 267:
12085                 return node.parent;
12086             case 272:
12087                 return node.parent.parent;
12088             case 203:
12089                 return isImportCall(node.parent) || isRequireCall(node.parent, false) ? node.parent : undefined;
12090             case 191:
12091                 ts.Debug.assert(ts.isStringLiteral(node));
12092                 return ts.tryCast(node.parent.parent, ts.isImportTypeNode);
12093             default:
12094                 return undefined;
12095         }
12096     }
12097     ts.tryGetImportFromModuleSpecifier = tryGetImportFromModuleSpecifier;
12098     function getExternalModuleName(node) {
12099         switch (node.kind) {
12100             case 261:
12101             case 267:
12102                 return node.moduleSpecifier;
12103             case 260:
12104                 return node.moduleReference.kind === 272 ? node.moduleReference.expression : undefined;
12105             case 195:
12106                 return isLiteralImportTypeNode(node) ? node.argument.literal : undefined;
12107             case 203:
12108                 return node.arguments[0];
12109             case 256:
12110                 return node.name.kind === 10 ? node.name : undefined;
12111             default:
12112                 return ts.Debug.assertNever(node);
12113         }
12114     }
12115     ts.getExternalModuleName = getExternalModuleName;
12116     function getNamespaceDeclarationNode(node) {
12117         switch (node.kind) {
12118             case 261:
12119                 return node.importClause && ts.tryCast(node.importClause.namedBindings, ts.isNamespaceImport);
12120             case 260:
12121                 return node;
12122             case 267:
12123                 return node.exportClause && ts.tryCast(node.exportClause, ts.isNamespaceExport);
12124             default:
12125                 return ts.Debug.assertNever(node);
12126         }
12127     }
12128     ts.getNamespaceDeclarationNode = getNamespaceDeclarationNode;
12129     function isDefaultImport(node) {
12130         return node.kind === 261 && !!node.importClause && !!node.importClause.name;
12131     }
12132     ts.isDefaultImport = isDefaultImport;
12133     function forEachImportClauseDeclaration(node, action) {
12134         if (node.name) {
12135             var result = action(node);
12136             if (result)
12137                 return result;
12138         }
12139         if (node.namedBindings) {
12140             var result = ts.isNamespaceImport(node.namedBindings)
12141                 ? action(node.namedBindings)
12142                 : ts.forEach(node.namedBindings.elements, action);
12143             if (result)
12144                 return result;
12145         }
12146     }
12147     ts.forEachImportClauseDeclaration = forEachImportClauseDeclaration;
12148     function hasQuestionToken(node) {
12149         if (node) {
12150             switch (node.kind) {
12151                 case 160:
12152                 case 165:
12153                 case 164:
12154                 case 289:
12155                 case 288:
12156                 case 163:
12157                 case 162:
12158                     return node.questionToken !== undefined;
12159             }
12160         }
12161         return false;
12162     }
12163     ts.hasQuestionToken = hasQuestionToken;
12164     function isJSDocConstructSignature(node) {
12165         var param = ts.isJSDocFunctionType(node) ? ts.firstOrUndefined(node.parameters) : undefined;
12166         var name = ts.tryCast(param && param.name, ts.isIdentifier);
12167         return !!name && name.escapedText === "new";
12168     }
12169     ts.isJSDocConstructSignature = isJSDocConstructSignature;
12170     function isJSDocTypeAlias(node) {
12171         return node.kind === 331 || node.kind === 324 || node.kind === 325;
12172     }
12173     ts.isJSDocTypeAlias = isJSDocTypeAlias;
12174     function isTypeAlias(node) {
12175         return isJSDocTypeAlias(node) || ts.isTypeAliasDeclaration(node);
12176     }
12177     ts.isTypeAlias = isTypeAlias;
12178     function getSourceOfAssignment(node) {
12179         return ts.isExpressionStatement(node) &&
12180             ts.isBinaryExpression(node.expression) &&
12181             node.expression.operatorToken.kind === 62
12182             ? getRightMostAssignedExpression(node.expression)
12183             : undefined;
12184     }
12185     function getSourceOfDefaultedAssignment(node) {
12186         return ts.isExpressionStatement(node) &&
12187             ts.isBinaryExpression(node.expression) &&
12188             getAssignmentDeclarationKind(node.expression) !== 0 &&
12189             ts.isBinaryExpression(node.expression.right) &&
12190             (node.expression.right.operatorToken.kind === 56 || node.expression.right.operatorToken.kind === 60)
12191             ? node.expression.right.right
12192             : undefined;
12193     }
12194     function getSingleInitializerOfVariableStatementOrPropertyDeclaration(node) {
12195         switch (node.kind) {
12196             case 232:
12197                 var v = getSingleVariableOfVariableStatement(node);
12198                 return v && v.initializer;
12199             case 163:
12200                 return node.initializer;
12201             case 288:
12202                 return node.initializer;
12203         }
12204     }
12205     ts.getSingleInitializerOfVariableStatementOrPropertyDeclaration = getSingleInitializerOfVariableStatementOrPropertyDeclaration;
12206     function getSingleVariableOfVariableStatement(node) {
12207         return ts.isVariableStatement(node) ? ts.firstOrUndefined(node.declarationList.declarations) : undefined;
12208     }
12209     ts.getSingleVariableOfVariableStatement = getSingleVariableOfVariableStatement;
12210     function getNestedModuleDeclaration(node) {
12211         return ts.isModuleDeclaration(node) &&
12212             node.body &&
12213             node.body.kind === 256
12214             ? node.body
12215             : undefined;
12216     }
12217     function getJSDocCommentsAndTags(hostNode, noCache) {
12218         var result;
12219         if (isVariableLike(hostNode) && ts.hasInitializer(hostNode) && ts.hasJSDocNodes(hostNode.initializer)) {
12220             result = ts.append(result, ts.last(hostNode.initializer.jsDoc));
12221         }
12222         var node = hostNode;
12223         while (node && node.parent) {
12224             if (ts.hasJSDocNodes(node)) {
12225                 result = ts.append(result, ts.last(node.jsDoc));
12226             }
12227             if (node.kind === 160) {
12228                 result = ts.addRange(result, (noCache ? ts.getJSDocParameterTagsNoCache : ts.getJSDocParameterTags)(node));
12229                 break;
12230             }
12231             if (node.kind === 159) {
12232                 result = ts.addRange(result, (noCache ? ts.getJSDocTypeParameterTagsNoCache : ts.getJSDocTypeParameterTags)(node));
12233                 break;
12234             }
12235             node = getNextJSDocCommentLocation(node);
12236         }
12237         return result || ts.emptyArray;
12238     }
12239     ts.getJSDocCommentsAndTags = getJSDocCommentsAndTags;
12240     function getNextJSDocCommentLocation(node) {
12241         var parent = node.parent;
12242         if (parent.kind === 288 ||
12243             parent.kind === 266 ||
12244             parent.kind === 163 ||
12245             parent.kind === 233 && node.kind === 201 ||
12246             getNestedModuleDeclaration(parent) ||
12247             ts.isBinaryExpression(node) && node.operatorToken.kind === 62) {
12248             return parent;
12249         }
12250         else if (parent.parent &&
12251             (getSingleVariableOfVariableStatement(parent.parent) === node ||
12252                 ts.isBinaryExpression(parent) && parent.operatorToken.kind === 62)) {
12253             return parent.parent;
12254         }
12255         else if (parent.parent && parent.parent.parent &&
12256             (getSingleVariableOfVariableStatement(parent.parent.parent) ||
12257                 getSingleInitializerOfVariableStatementOrPropertyDeclaration(parent.parent.parent) === node ||
12258                 getSourceOfDefaultedAssignment(parent.parent.parent))) {
12259             return parent.parent.parent;
12260         }
12261     }
12262     ts.getNextJSDocCommentLocation = getNextJSDocCommentLocation;
12263     function getParameterSymbolFromJSDoc(node) {
12264         if (node.symbol) {
12265             return node.symbol;
12266         }
12267         if (!ts.isIdentifier(node.name)) {
12268             return undefined;
12269         }
12270         var name = node.name.escapedText;
12271         var decl = getHostSignatureFromJSDoc(node);
12272         if (!decl) {
12273             return undefined;
12274         }
12275         var parameter = ts.find(decl.parameters, function (p) { return p.name.kind === 78 && p.name.escapedText === name; });
12276         return parameter && parameter.symbol;
12277     }
12278     ts.getParameterSymbolFromJSDoc = getParameterSymbolFromJSDoc;
12279     function getHostSignatureFromJSDoc(node) {
12280         var host = getEffectiveJSDocHost(node);
12281         return host && ts.isFunctionLike(host) ? host : undefined;
12282     }
12283     ts.getHostSignatureFromJSDoc = getHostSignatureFromJSDoc;
12284     function getEffectiveJSDocHost(node) {
12285         var host = getJSDocHost(node);
12286         if (host) {
12287             return getSourceOfDefaultedAssignment(host)
12288                 || getSourceOfAssignment(host)
12289                 || getSingleInitializerOfVariableStatementOrPropertyDeclaration(host)
12290                 || getSingleVariableOfVariableStatement(host)
12291                 || getNestedModuleDeclaration(host)
12292                 || host;
12293         }
12294     }
12295     ts.getEffectiveJSDocHost = getEffectiveJSDocHost;
12296     function getJSDocHost(node) {
12297         var jsDoc = getJSDocRoot(node);
12298         if (!jsDoc) {
12299             return undefined;
12300         }
12301         var host = jsDoc.parent;
12302         if (host && host.jsDoc && jsDoc === ts.lastOrUndefined(host.jsDoc)) {
12303             return host;
12304         }
12305     }
12306     ts.getJSDocHost = getJSDocHost;
12307     function getJSDocRoot(node) {
12308         return ts.findAncestor(node.parent, ts.isJSDoc);
12309     }
12310     ts.getJSDocRoot = getJSDocRoot;
12311     function getTypeParameterFromJsDoc(node) {
12312         var name = node.name.escapedText;
12313         var typeParameters = node.parent.parent.parent.typeParameters;
12314         return typeParameters && ts.find(typeParameters, function (p) { return p.name.escapedText === name; });
12315     }
12316     ts.getTypeParameterFromJsDoc = getTypeParameterFromJsDoc;
12317     function hasRestParameter(s) {
12318         var last = ts.lastOrUndefined(s.parameters);
12319         return !!last && isRestParameter(last);
12320     }
12321     ts.hasRestParameter = hasRestParameter;
12322     function isRestParameter(node) {
12323         var type = ts.isJSDocParameterTag(node) ? (node.typeExpression && node.typeExpression.type) : node.type;
12324         return node.dotDotDotToken !== undefined || !!type && type.kind === 309;
12325     }
12326     ts.isRestParameter = isRestParameter;
12327     function hasTypeArguments(node) {
12328         return !!node.typeArguments;
12329     }
12330     ts.hasTypeArguments = hasTypeArguments;
12331     function getAssignmentTargetKind(node) {
12332         var parent = node.parent;
12333         while (true) {
12334             switch (parent.kind) {
12335                 case 216:
12336                     var binaryOperator = parent.operatorToken.kind;
12337                     return isAssignmentOperator(binaryOperator) && parent.left === node ?
12338                         binaryOperator === 62 || isLogicalOrCoalescingAssignmentOperator(binaryOperator) ? 1 : 2 :
12339                         0;
12340                 case 214:
12341                 case 215:
12342                     var unaryOperator = parent.operator;
12343                     return unaryOperator === 45 || unaryOperator === 46 ? 2 : 0;
12344                 case 238:
12345                 case 239:
12346                     return parent.initializer === node ? 1 : 0;
12347                 case 207:
12348                 case 199:
12349                 case 220:
12350                 case 225:
12351                     node = parent;
12352                     break;
12353                 case 289:
12354                     if (parent.name !== node) {
12355                         return 0;
12356                     }
12357                     node = parent.parent;
12358                     break;
12359                 case 288:
12360                     if (parent.name === node) {
12361                         return 0;
12362                     }
12363                     node = parent.parent;
12364                     break;
12365                 default:
12366                     return 0;
12367             }
12368             parent = node.parent;
12369         }
12370     }
12371     ts.getAssignmentTargetKind = getAssignmentTargetKind;
12372     function isAssignmentTarget(node) {
12373         return getAssignmentTargetKind(node) !== 0;
12374     }
12375     ts.isAssignmentTarget = isAssignmentTarget;
12376     function isNodeWithPossibleHoistedDeclaration(node) {
12377         switch (node.kind) {
12378             case 230:
12379             case 232:
12380             case 243:
12381             case 234:
12382             case 244:
12383             case 258:
12384             case 284:
12385             case 285:
12386             case 245:
12387             case 237:
12388             case 238:
12389             case 239:
12390             case 235:
12391             case 236:
12392             case 247:
12393             case 287:
12394                 return true;
12395         }
12396         return false;
12397     }
12398     ts.isNodeWithPossibleHoistedDeclaration = isNodeWithPossibleHoistedDeclaration;
12399     function isValueSignatureDeclaration(node) {
12400         return ts.isFunctionExpression(node) || ts.isArrowFunction(node) || ts.isMethodOrAccessor(node) || ts.isFunctionDeclaration(node) || ts.isConstructorDeclaration(node);
12401     }
12402     ts.isValueSignatureDeclaration = isValueSignatureDeclaration;
12403     function walkUp(node, kind) {
12404         while (node && node.kind === kind) {
12405             node = node.parent;
12406         }
12407         return node;
12408     }
12409     function walkUpParenthesizedTypes(node) {
12410         return walkUp(node, 186);
12411     }
12412     ts.walkUpParenthesizedTypes = walkUpParenthesizedTypes;
12413     function walkUpParenthesizedExpressions(node) {
12414         return walkUp(node, 207);
12415     }
12416     ts.walkUpParenthesizedExpressions = walkUpParenthesizedExpressions;
12417     function walkUpParenthesizedTypesAndGetParentAndChild(node) {
12418         var child;
12419         while (node && node.kind === 186) {
12420             child = node;
12421             node = node.parent;
12422         }
12423         return [child, node];
12424     }
12425     ts.walkUpParenthesizedTypesAndGetParentAndChild = walkUpParenthesizedTypesAndGetParentAndChild;
12426     function skipParentheses(node) {
12427         return ts.skipOuterExpressions(node, 1);
12428     }
12429     ts.skipParentheses = skipParentheses;
12430     function skipParenthesesUp(node) {
12431         while (node.kind === 207) {
12432             node = node.parent;
12433         }
12434         return node;
12435     }
12436     function isDeleteTarget(node) {
12437         if (node.kind !== 201 && node.kind !== 202) {
12438             return false;
12439         }
12440         node = walkUpParenthesizedExpressions(node.parent);
12441         return node && node.kind === 210;
12442     }
12443     ts.isDeleteTarget = isDeleteTarget;
12444     function isNodeDescendantOf(node, ancestor) {
12445         while (node) {
12446             if (node === ancestor)
12447                 return true;
12448             node = node.parent;
12449         }
12450         return false;
12451     }
12452     ts.isNodeDescendantOf = isNodeDescendantOf;
12453     function isDeclarationName(name) {
12454         return !ts.isSourceFile(name) && !ts.isBindingPattern(name) && ts.isDeclaration(name.parent) && name.parent.name === name;
12455     }
12456     ts.isDeclarationName = isDeclarationName;
12457     function getDeclarationFromName(name) {
12458         var parent = name.parent;
12459         switch (name.kind) {
12460             case 10:
12461             case 14:
12462             case 8:
12463                 if (ts.isComputedPropertyName(parent))
12464                     return parent.parent;
12465             case 78:
12466                 if (ts.isDeclaration(parent)) {
12467                     return parent.name === name ? parent : undefined;
12468                 }
12469                 else if (ts.isQualifiedName(parent)) {
12470                     var tag = parent.parent;
12471                     return ts.isJSDocParameterTag(tag) && tag.name === parent ? tag : undefined;
12472                 }
12473                 else {
12474                     var binExp = parent.parent;
12475                     return ts.isBinaryExpression(binExp) &&
12476                         getAssignmentDeclarationKind(binExp) !== 0 &&
12477                         (binExp.left.symbol || binExp.symbol) &&
12478                         ts.getNameOfDeclaration(binExp) === name
12479                         ? binExp
12480                         : undefined;
12481                 }
12482             case 79:
12483                 return ts.isDeclaration(parent) && parent.name === name ? parent : undefined;
12484             default:
12485                 return undefined;
12486         }
12487     }
12488     ts.getDeclarationFromName = getDeclarationFromName;
12489     function isLiteralComputedPropertyDeclarationName(node) {
12490         return isStringOrNumericLiteralLike(node) &&
12491             node.parent.kind === 158 &&
12492             ts.isDeclaration(node.parent.parent);
12493     }
12494     ts.isLiteralComputedPropertyDeclarationName = isLiteralComputedPropertyDeclarationName;
12495     function isIdentifierName(node) {
12496         var parent = node.parent;
12497         switch (parent.kind) {
12498             case 163:
12499             case 162:
12500             case 165:
12501             case 164:
12502             case 167:
12503             case 168:
12504             case 291:
12505             case 288:
12506             case 201:
12507                 return parent.name === node;
12508             case 157:
12509                 return parent.right === node;
12510             case 198:
12511             case 265:
12512                 return parent.propertyName === node;
12513             case 270:
12514             case 280:
12515                 return true;
12516         }
12517         return false;
12518     }
12519     ts.isIdentifierName = isIdentifierName;
12520     function isAliasSymbolDeclaration(node) {
12521         return node.kind === 260 ||
12522             node.kind === 259 ||
12523             node.kind === 262 && !!node.name ||
12524             node.kind === 263 ||
12525             node.kind === 269 ||
12526             node.kind === 265 ||
12527             node.kind === 270 ||
12528             node.kind === 266 && exportAssignmentIsAlias(node) ||
12529             ts.isBinaryExpression(node) && getAssignmentDeclarationKind(node) === 2 && exportAssignmentIsAlias(node) ||
12530             ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62 && isAliasableExpression(node.parent.right) ||
12531             node.kind === 289 ||
12532             node.kind === 288 && isAliasableExpression(node.initializer);
12533     }
12534     ts.isAliasSymbolDeclaration = isAliasSymbolDeclaration;
12535     function getAliasDeclarationFromName(node) {
12536         switch (node.parent.kind) {
12537             case 262:
12538             case 265:
12539             case 263:
12540             case 270:
12541             case 266:
12542             case 260:
12543                 return node.parent;
12544             case 157:
12545                 do {
12546                     node = node.parent;
12547                 } while (node.parent.kind === 157);
12548                 return getAliasDeclarationFromName(node);
12549         }
12550     }
12551     ts.getAliasDeclarationFromName = getAliasDeclarationFromName;
12552     function isAliasableExpression(e) {
12553         return isEntityNameExpression(e) || ts.isClassExpression(e);
12554     }
12555     ts.isAliasableExpression = isAliasableExpression;
12556     function exportAssignmentIsAlias(node) {
12557         var e = getExportAssignmentExpression(node);
12558         return isAliasableExpression(e);
12559     }
12560     ts.exportAssignmentIsAlias = exportAssignmentIsAlias;
12561     function getExportAssignmentExpression(node) {
12562         return ts.isExportAssignment(node) ? node.expression : node.right;
12563     }
12564     ts.getExportAssignmentExpression = getExportAssignmentExpression;
12565     function getPropertyAssignmentAliasLikeExpression(node) {
12566         return node.kind === 289 ? node.name : node.kind === 288 ? node.initializer :
12567             node.parent.right;
12568     }
12569     ts.getPropertyAssignmentAliasLikeExpression = getPropertyAssignmentAliasLikeExpression;
12570     function getEffectiveBaseTypeNode(node) {
12571         var baseType = getClassExtendsHeritageElement(node);
12572         if (baseType && isInJSFile(node)) {
12573             var tag = ts.getJSDocAugmentsTag(node);
12574             if (tag) {
12575                 return tag.class;
12576             }
12577         }
12578         return baseType;
12579     }
12580     ts.getEffectiveBaseTypeNode = getEffectiveBaseTypeNode;
12581     function getClassExtendsHeritageElement(node) {
12582         var heritageClause = getHeritageClause(node.heritageClauses, 93);
12583         return heritageClause && heritageClause.types.length > 0 ? heritageClause.types[0] : undefined;
12584     }
12585     ts.getClassExtendsHeritageElement = getClassExtendsHeritageElement;
12586     function getEffectiveImplementsTypeNodes(node) {
12587         if (isInJSFile(node)) {
12588             return ts.getJSDocImplementsTags(node).map(function (n) { return n.class; });
12589         }
12590         else {
12591             var heritageClause = getHeritageClause(node.heritageClauses, 116);
12592             return heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.types;
12593         }
12594     }
12595     ts.getEffectiveImplementsTypeNodes = getEffectiveImplementsTypeNodes;
12596     function getAllSuperTypeNodes(node) {
12597         return ts.isInterfaceDeclaration(node) ? getInterfaceBaseTypeNodes(node) || ts.emptyArray :
12598             ts.isClassLike(node) ? ts.concatenate(ts.singleElementArray(getEffectiveBaseTypeNode(node)), getEffectiveImplementsTypeNodes(node)) || ts.emptyArray :
12599                 ts.emptyArray;
12600     }
12601     ts.getAllSuperTypeNodes = getAllSuperTypeNodes;
12602     function getInterfaceBaseTypeNodes(node) {
12603         var heritageClause = getHeritageClause(node.heritageClauses, 93);
12604         return heritageClause ? heritageClause.types : undefined;
12605     }
12606     ts.getInterfaceBaseTypeNodes = getInterfaceBaseTypeNodes;
12607     function getHeritageClause(clauses, kind) {
12608         if (clauses) {
12609             for (var _i = 0, clauses_1 = clauses; _i < clauses_1.length; _i++) {
12610                 var clause = clauses_1[_i];
12611                 if (clause.token === kind) {
12612                     return clause;
12613                 }
12614             }
12615         }
12616         return undefined;
12617     }
12618     ts.getHeritageClause = getHeritageClause;
12619     function getAncestor(node, kind) {
12620         while (node) {
12621             if (node.kind === kind) {
12622                 return node;
12623             }
12624             node = node.parent;
12625         }
12626         return undefined;
12627     }
12628     ts.getAncestor = getAncestor;
12629     function isKeyword(token) {
12630         return 80 <= token && token <= 156;
12631     }
12632     ts.isKeyword = isKeyword;
12633     function isContextualKeyword(token) {
12634         return 125 <= token && token <= 156;
12635     }
12636     ts.isContextualKeyword = isContextualKeyword;
12637     function isNonContextualKeyword(token) {
12638         return isKeyword(token) && !isContextualKeyword(token);
12639     }
12640     ts.isNonContextualKeyword = isNonContextualKeyword;
12641     function isFutureReservedKeyword(token) {
12642         return 116 <= token && token <= 124;
12643     }
12644     ts.isFutureReservedKeyword = isFutureReservedKeyword;
12645     function isStringANonContextualKeyword(name) {
12646         var token = ts.stringToToken(name);
12647         return token !== undefined && isNonContextualKeyword(token);
12648     }
12649     ts.isStringANonContextualKeyword = isStringANonContextualKeyword;
12650     function isStringAKeyword(name) {
12651         var token = ts.stringToToken(name);
12652         return token !== undefined && isKeyword(token);
12653     }
12654     ts.isStringAKeyword = isStringAKeyword;
12655     function isIdentifierANonContextualKeyword(_a) {
12656         var originalKeywordKind = _a.originalKeywordKind;
12657         return !!originalKeywordKind && !isContextualKeyword(originalKeywordKind);
12658     }
12659     ts.isIdentifierANonContextualKeyword = isIdentifierANonContextualKeyword;
12660     function isTrivia(token) {
12661         return 2 <= token && token <= 7;
12662     }
12663     ts.isTrivia = isTrivia;
12664     function getFunctionFlags(node) {
12665         if (!node) {
12666             return 4;
12667         }
12668         var flags = 0;
12669         switch (node.kind) {
12670             case 251:
12671             case 208:
12672             case 165:
12673                 if (node.asteriskToken) {
12674                     flags |= 1;
12675                 }
12676             case 209:
12677                 if (hasSyntacticModifier(node, 256)) {
12678                     flags |= 2;
12679                 }
12680                 break;
12681         }
12682         if (!node.body) {
12683             flags |= 4;
12684         }
12685         return flags;
12686     }
12687     ts.getFunctionFlags = getFunctionFlags;
12688     function isAsyncFunction(node) {
12689         switch (node.kind) {
12690             case 251:
12691             case 208:
12692             case 209:
12693             case 165:
12694                 return node.body !== undefined
12695                     && node.asteriskToken === undefined
12696                     && hasSyntacticModifier(node, 256);
12697         }
12698         return false;
12699     }
12700     ts.isAsyncFunction = isAsyncFunction;
12701     function isStringOrNumericLiteralLike(node) {
12702         return ts.isStringLiteralLike(node) || ts.isNumericLiteral(node);
12703     }
12704     ts.isStringOrNumericLiteralLike = isStringOrNumericLiteralLike;
12705     function isSignedNumericLiteral(node) {
12706         return ts.isPrefixUnaryExpression(node) && (node.operator === 39 || node.operator === 40) && ts.isNumericLiteral(node.operand);
12707     }
12708     ts.isSignedNumericLiteral = isSignedNumericLiteral;
12709     function hasDynamicName(declaration) {
12710         var name = ts.getNameOfDeclaration(declaration);
12711         return !!name && isDynamicName(name);
12712     }
12713     ts.hasDynamicName = hasDynamicName;
12714     function isDynamicName(name) {
12715         if (!(name.kind === 158 || name.kind === 202)) {
12716             return false;
12717         }
12718         var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression;
12719         return !isStringOrNumericLiteralLike(expr) &&
12720             !isSignedNumericLiteral(expr) &&
12721             !isWellKnownSymbolSyntactically(expr);
12722     }
12723     ts.isDynamicName = isDynamicName;
12724     function isWellKnownSymbolSyntactically(node) {
12725         return ts.isPropertyAccessExpression(node) && isESSymbolIdentifier(node.expression);
12726     }
12727     ts.isWellKnownSymbolSyntactically = isWellKnownSymbolSyntactically;
12728     function getPropertyNameForPropertyNameNode(name) {
12729         switch (name.kind) {
12730             case 78:
12731             case 79:
12732                 return name.escapedText;
12733             case 10:
12734             case 8:
12735                 return ts.escapeLeadingUnderscores(name.text);
12736             case 158:
12737                 var nameExpression = name.expression;
12738                 if (isWellKnownSymbolSyntactically(nameExpression)) {
12739                     return getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name));
12740                 }
12741                 else if (isStringOrNumericLiteralLike(nameExpression)) {
12742                     return ts.escapeLeadingUnderscores(nameExpression.text);
12743                 }
12744                 else if (isSignedNumericLiteral(nameExpression)) {
12745                     if (nameExpression.operator === 40) {
12746                         return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text;
12747                     }
12748                     return nameExpression.operand.text;
12749                 }
12750                 return undefined;
12751             default:
12752                 return ts.Debug.assertNever(name);
12753         }
12754     }
12755     ts.getPropertyNameForPropertyNameNode = getPropertyNameForPropertyNameNode;
12756     function isPropertyNameLiteral(node) {
12757         switch (node.kind) {
12758             case 78:
12759             case 10:
12760             case 14:
12761             case 8:
12762                 return true;
12763             default:
12764                 return false;
12765         }
12766     }
12767     ts.isPropertyNameLiteral = isPropertyNameLiteral;
12768     function getTextOfIdentifierOrLiteral(node) {
12769         return ts.isIdentifierOrPrivateIdentifier(node) ? ts.idText(node) : node.text;
12770     }
12771     ts.getTextOfIdentifierOrLiteral = getTextOfIdentifierOrLiteral;
12772     function getEscapedTextOfIdentifierOrLiteral(node) {
12773         return ts.isIdentifierOrPrivateIdentifier(node) ? node.escapedText : ts.escapeLeadingUnderscores(node.text);
12774     }
12775     ts.getEscapedTextOfIdentifierOrLiteral = getEscapedTextOfIdentifierOrLiteral;
12776     function getPropertyNameForUniqueESSymbol(symbol) {
12777         return "__@" + ts.getSymbolId(symbol) + "@" + symbol.escapedName;
12778     }
12779     ts.getPropertyNameForUniqueESSymbol = getPropertyNameForUniqueESSymbol;
12780     function getPropertyNameForKnownSymbolName(symbolName) {
12781         return "__@" + symbolName;
12782     }
12783     ts.getPropertyNameForKnownSymbolName = getPropertyNameForKnownSymbolName;
12784     function getSymbolNameForPrivateIdentifier(containingClassSymbol, description) {
12785         return "__#" + ts.getSymbolId(containingClassSymbol) + "@" + description;
12786     }
12787     ts.getSymbolNameForPrivateIdentifier = getSymbolNameForPrivateIdentifier;
12788     function isKnownSymbol(symbol) {
12789         return ts.startsWith(symbol.escapedName, "__@");
12790     }
12791     ts.isKnownSymbol = isKnownSymbol;
12792     function isESSymbolIdentifier(node) {
12793         return node.kind === 78 && node.escapedText === "Symbol";
12794     }
12795     ts.isESSymbolIdentifier = isESSymbolIdentifier;
12796     function isPushOrUnshiftIdentifier(node) {
12797         return node.escapedText === "push" || node.escapedText === "unshift";
12798     }
12799     ts.isPushOrUnshiftIdentifier = isPushOrUnshiftIdentifier;
12800     function isParameterDeclaration(node) {
12801         var root = getRootDeclaration(node);
12802         return root.kind === 160;
12803     }
12804     ts.isParameterDeclaration = isParameterDeclaration;
12805     function getRootDeclaration(node) {
12806         while (node.kind === 198) {
12807             node = node.parent.parent;
12808         }
12809         return node;
12810     }
12811     ts.getRootDeclaration = getRootDeclaration;
12812     function nodeStartsNewLexicalEnvironment(node) {
12813         var kind = node.kind;
12814         return kind === 166
12815             || kind === 208
12816             || kind === 251
12817             || kind === 209
12818             || kind === 165
12819             || kind === 167
12820             || kind === 168
12821             || kind === 256
12822             || kind === 297;
12823     }
12824     ts.nodeStartsNewLexicalEnvironment = nodeStartsNewLexicalEnvironment;
12825     function nodeIsSynthesized(range) {
12826         return positionIsSynthesized(range.pos)
12827             || positionIsSynthesized(range.end);
12828     }
12829     ts.nodeIsSynthesized = nodeIsSynthesized;
12830     function getOriginalSourceFile(sourceFile) {
12831         return ts.getParseTreeNode(sourceFile, ts.isSourceFile) || sourceFile;
12832     }
12833     ts.getOriginalSourceFile = getOriginalSourceFile;
12834     function getExpressionAssociativity(expression) {
12835         var operator = getOperator(expression);
12836         var hasArguments = expression.kind === 204 && expression.arguments !== undefined;
12837         return getOperatorAssociativity(expression.kind, operator, hasArguments);
12838     }
12839     ts.getExpressionAssociativity = getExpressionAssociativity;
12840     function getOperatorAssociativity(kind, operator, hasArguments) {
12841         switch (kind) {
12842             case 204:
12843                 return hasArguments ? 0 : 1;
12844             case 214:
12845             case 211:
12846             case 212:
12847             case 210:
12848             case 213:
12849             case 217:
12850             case 219:
12851                 return 1;
12852             case 216:
12853                 switch (operator) {
12854                     case 42:
12855                     case 62:
12856                     case 63:
12857                     case 64:
12858                     case 66:
12859                     case 65:
12860                     case 67:
12861                     case 68:
12862                     case 69:
12863                     case 70:
12864                     case 71:
12865                     case 72:
12866                     case 77:
12867                     case 73:
12868                     case 74:
12869                     case 75:
12870                     case 76:
12871                         return 1;
12872                 }
12873         }
12874         return 0;
12875     }
12876     ts.getOperatorAssociativity = getOperatorAssociativity;
12877     function getExpressionPrecedence(expression) {
12878         var operator = getOperator(expression);
12879         var hasArguments = expression.kind === 204 && expression.arguments !== undefined;
12880         return getOperatorPrecedence(expression.kind, operator, hasArguments);
12881     }
12882     ts.getExpressionPrecedence = getExpressionPrecedence;
12883     function getOperator(expression) {
12884         if (expression.kind === 216) {
12885             return expression.operatorToken.kind;
12886         }
12887         else if (expression.kind === 214 || expression.kind === 215) {
12888             return expression.operator;
12889         }
12890         else {
12891             return expression.kind;
12892         }
12893     }
12894     ts.getOperator = getOperator;
12895     function getOperatorPrecedence(nodeKind, operatorKind, hasArguments) {
12896         switch (nodeKind) {
12897             case 337:
12898                 return 0;
12899             case 220:
12900                 return 1;
12901             case 219:
12902                 return 2;
12903             case 217:
12904                 return 4;
12905             case 216:
12906                 switch (operatorKind) {
12907                     case 27:
12908                         return 0;
12909                     case 62:
12910                     case 63:
12911                     case 64:
12912                     case 66:
12913                     case 65:
12914                     case 67:
12915                     case 68:
12916                     case 69:
12917                     case 70:
12918                     case 71:
12919                     case 72:
12920                     case 77:
12921                     case 73:
12922                     case 74:
12923                     case 75:
12924                     case 76:
12925                         return 3;
12926                     default:
12927                         return getBinaryOperatorPrecedence(operatorKind);
12928                 }
12929             case 206:
12930             case 225:
12931             case 214:
12932             case 211:
12933             case 212:
12934             case 210:
12935             case 213:
12936                 return 16;
12937             case 215:
12938                 return 17;
12939             case 203:
12940                 return 18;
12941             case 204:
12942                 return hasArguments ? 19 : 18;
12943             case 205:
12944             case 201:
12945             case 202:
12946                 return 19;
12947             case 224:
12948                 return 11;
12949             case 107:
12950             case 105:
12951             case 78:
12952             case 103:
12953             case 109:
12954             case 94:
12955             case 8:
12956             case 9:
12957             case 10:
12958             case 199:
12959             case 200:
12960             case 208:
12961             case 209:
12962             case 221:
12963             case 13:
12964             case 14:
12965             case 218:
12966             case 207:
12967             case 222:
12968             case 273:
12969             case 274:
12970             case 277:
12971                 return 20;
12972             default:
12973                 return -1;
12974         }
12975     }
12976     ts.getOperatorPrecedence = getOperatorPrecedence;
12977     function getBinaryOperatorPrecedence(kind) {
12978         switch (kind) {
12979             case 60:
12980                 return 4;
12981             case 56:
12982                 return 5;
12983             case 55:
12984                 return 6;
12985             case 51:
12986                 return 7;
12987             case 52:
12988                 return 8;
12989             case 50:
12990                 return 9;
12991             case 34:
12992             case 35:
12993             case 36:
12994             case 37:
12995                 return 10;
12996             case 29:
12997             case 31:
12998             case 32:
12999             case 33:
13000             case 101:
13001             case 100:
13002             case 126:
13003                 return 11;
13004             case 47:
13005             case 48:
13006             case 49:
13007                 return 12;
13008             case 39:
13009             case 40:
13010                 return 13;
13011             case 41:
13012             case 43:
13013             case 44:
13014                 return 14;
13015             case 42:
13016                 return 15;
13017         }
13018         return -1;
13019     }
13020     ts.getBinaryOperatorPrecedence = getBinaryOperatorPrecedence;
13021     function getSemanticJsxChildren(children) {
13022         return ts.filter(children, function (i) {
13023             switch (i.kind) {
13024                 case 283:
13025                     return !!i.expression;
13026                 case 11:
13027                     return !i.containsOnlyTriviaWhiteSpaces;
13028                 default:
13029                     return true;
13030             }
13031         });
13032     }
13033     ts.getSemanticJsxChildren = getSemanticJsxChildren;
13034     function createDiagnosticCollection() {
13035         var nonFileDiagnostics = [];
13036         var filesWithDiagnostics = [];
13037         var fileDiagnostics = new ts.Map();
13038         var hasReadNonFileDiagnostics = false;
13039         return {
13040             add: add,
13041             lookup: lookup,
13042             getGlobalDiagnostics: getGlobalDiagnostics,
13043             getDiagnostics: getDiagnostics,
13044         };
13045         function lookup(diagnostic) {
13046             var diagnostics;
13047             if (diagnostic.file) {
13048                 diagnostics = fileDiagnostics.get(diagnostic.file.fileName);
13049             }
13050             else {
13051                 diagnostics = nonFileDiagnostics;
13052             }
13053             if (!diagnostics) {
13054                 return undefined;
13055             }
13056             var result = ts.binarySearch(diagnostics, diagnostic, ts.identity, compareDiagnosticsSkipRelatedInformation);
13057             if (result >= 0) {
13058                 return diagnostics[result];
13059             }
13060             return undefined;
13061         }
13062         function add(diagnostic) {
13063             var diagnostics;
13064             if (diagnostic.file) {
13065                 diagnostics = fileDiagnostics.get(diagnostic.file.fileName);
13066                 if (!diagnostics) {
13067                     diagnostics = [];
13068                     fileDiagnostics.set(diagnostic.file.fileName, diagnostics);
13069                     ts.insertSorted(filesWithDiagnostics, diagnostic.file.fileName, ts.compareStringsCaseSensitive);
13070                 }
13071             }
13072             else {
13073                 if (hasReadNonFileDiagnostics) {
13074                     hasReadNonFileDiagnostics = false;
13075                     nonFileDiagnostics = nonFileDiagnostics.slice();
13076                 }
13077                 diagnostics = nonFileDiagnostics;
13078             }
13079             ts.insertSorted(diagnostics, diagnostic, compareDiagnostics);
13080         }
13081         function getGlobalDiagnostics() {
13082             hasReadNonFileDiagnostics = true;
13083             return nonFileDiagnostics;
13084         }
13085         function getDiagnostics(fileName) {
13086             if (fileName) {
13087                 return fileDiagnostics.get(fileName) || [];
13088             }
13089             var fileDiags = ts.flatMapToMutable(filesWithDiagnostics, function (f) { return fileDiagnostics.get(f); });
13090             if (!nonFileDiagnostics.length) {
13091                 return fileDiags;
13092             }
13093             fileDiags.unshift.apply(fileDiags, nonFileDiagnostics);
13094             return fileDiags;
13095         }
13096     }
13097     ts.createDiagnosticCollection = createDiagnosticCollection;
13098     var templateSubstitutionRegExp = /\$\{/g;
13099     function escapeTemplateSubstitution(str) {
13100         return str.replace(templateSubstitutionRegExp, "\\${");
13101     }
13102     function hasInvalidEscape(template) {
13103         return template && !!(ts.isNoSubstitutionTemplateLiteral(template)
13104             ? template.templateFlags
13105             : (template.head.templateFlags || ts.some(template.templateSpans, function (span) { return !!span.literal.templateFlags; })));
13106     }
13107     ts.hasInvalidEscape = hasInvalidEscape;
13108     var doubleQuoteEscapedCharsRegExp = /[\\\"\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
13109     var singleQuoteEscapedCharsRegExp = /[\\\'\u0000-\u001f\t\v\f\b\r\n\u2028\u2029\u0085]/g;
13110     var backtickQuoteEscapedCharsRegExp = /[\\`]/g;
13111     var escapedCharsMap = new ts.Map(ts.getEntries({
13112         "\t": "\\t",
13113         "\v": "\\v",
13114         "\f": "\\f",
13115         "\b": "\\b",
13116         "\r": "\\r",
13117         "\n": "\\n",
13118         "\\": "\\\\",
13119         "\"": "\\\"",
13120         "\'": "\\\'",
13121         "\`": "\\\`",
13122         "\u2028": "\\u2028",
13123         "\u2029": "\\u2029",
13124         "\u0085": "\\u0085"
13125     }));
13126     function encodeUtf16EscapeSequence(charCode) {
13127         var hexCharCode = charCode.toString(16).toUpperCase();
13128         var paddedHexCode = ("0000" + hexCharCode).slice(-4);
13129         return "\\u" + paddedHexCode;
13130     }
13131     function getReplacement(c, offset, input) {
13132         if (c.charCodeAt(0) === 0) {
13133             var lookAhead = input.charCodeAt(offset + c.length);
13134             if (lookAhead >= 48 && lookAhead <= 57) {
13135                 return "\\x00";
13136             }
13137             return "\\0";
13138         }
13139         return escapedCharsMap.get(c) || encodeUtf16EscapeSequence(c.charCodeAt(0));
13140     }
13141     function escapeString(s, quoteChar) {
13142         var escapedCharsRegExp = quoteChar === 96 ? backtickQuoteEscapedCharsRegExp :
13143             quoteChar === 39 ? singleQuoteEscapedCharsRegExp :
13144                 doubleQuoteEscapedCharsRegExp;
13145         return s.replace(escapedCharsRegExp, getReplacement);
13146     }
13147     ts.escapeString = escapeString;
13148     var nonAsciiCharacters = /[^\u0000-\u007F]/g;
13149     function escapeNonAsciiString(s, quoteChar) {
13150         s = escapeString(s, quoteChar);
13151         return nonAsciiCharacters.test(s) ?
13152             s.replace(nonAsciiCharacters, function (c) { return encodeUtf16EscapeSequence(c.charCodeAt(0)); }) :
13153             s;
13154     }
13155     ts.escapeNonAsciiString = escapeNonAsciiString;
13156     var jsxDoubleQuoteEscapedCharsRegExp = /[\"\u0000-\u001f\u2028\u2029\u0085]/g;
13157     var jsxSingleQuoteEscapedCharsRegExp = /[\'\u0000-\u001f\u2028\u2029\u0085]/g;
13158     var jsxEscapedCharsMap = new ts.Map(ts.getEntries({
13159         "\"": "&quot;",
13160         "\'": "&apos;"
13161     }));
13162     function encodeJsxCharacterEntity(charCode) {
13163         var hexCharCode = charCode.toString(16).toUpperCase();
13164         return "&#x" + hexCharCode + ";";
13165     }
13166     function getJsxAttributeStringReplacement(c) {
13167         if (c.charCodeAt(0) === 0) {
13168             return "&#0;";
13169         }
13170         return jsxEscapedCharsMap.get(c) || encodeJsxCharacterEntity(c.charCodeAt(0));
13171     }
13172     function escapeJsxAttributeString(s, quoteChar) {
13173         var escapedCharsRegExp = quoteChar === 39 ? jsxSingleQuoteEscapedCharsRegExp :
13174             jsxDoubleQuoteEscapedCharsRegExp;
13175         return s.replace(escapedCharsRegExp, getJsxAttributeStringReplacement);
13176     }
13177     ts.escapeJsxAttributeString = escapeJsxAttributeString;
13178     function stripQuotes(name) {
13179         var length = name.length;
13180         if (length >= 2 && name.charCodeAt(0) === name.charCodeAt(length - 1) && isQuoteOrBacktick(name.charCodeAt(0))) {
13181             return name.substring(1, length - 1);
13182         }
13183         return name;
13184     }
13185     ts.stripQuotes = stripQuotes;
13186     function isQuoteOrBacktick(charCode) {
13187         return charCode === 39 ||
13188             charCode === 34 ||
13189             charCode === 96;
13190     }
13191     function isIntrinsicJsxName(name) {
13192         var ch = name.charCodeAt(0);
13193         return (ch >= 97 && ch <= 122) || ts.stringContains(name, "-") || ts.stringContains(name, ":");
13194     }
13195     ts.isIntrinsicJsxName = isIntrinsicJsxName;
13196     var indentStrings = ["", "    "];
13197     function getIndentString(level) {
13198         var singleLevel = indentStrings[1];
13199         for (var current = indentStrings.length; current <= level; current++) {
13200             indentStrings.push(indentStrings[current - 1] + singleLevel);
13201         }
13202         return indentStrings[level];
13203     }
13204     ts.getIndentString = getIndentString;
13205     function getIndentSize() {
13206         return indentStrings[1].length;
13207     }
13208     ts.getIndentSize = getIndentSize;
13209     function createTextWriter(newLine) {
13210         var output;
13211         var indent;
13212         var lineStart;
13213         var lineCount;
13214         var linePos;
13215         var hasTrailingComment = false;
13216         function updateLineCountAndPosFor(s) {
13217             var lineStartsOfS = ts.computeLineStarts(s);
13218             if (lineStartsOfS.length > 1) {
13219                 lineCount = lineCount + lineStartsOfS.length - 1;
13220                 linePos = output.length - s.length + ts.last(lineStartsOfS);
13221                 lineStart = (linePos - output.length) === 0;
13222             }
13223             else {
13224                 lineStart = false;
13225             }
13226         }
13227         function writeText(s) {
13228             if (s && s.length) {
13229                 if (lineStart) {
13230                     s = getIndentString(indent) + s;
13231                     lineStart = false;
13232                 }
13233                 output += s;
13234                 updateLineCountAndPosFor(s);
13235             }
13236         }
13237         function write(s) {
13238             if (s)
13239                 hasTrailingComment = false;
13240             writeText(s);
13241         }
13242         function writeComment(s) {
13243             if (s)
13244                 hasTrailingComment = true;
13245             writeText(s);
13246         }
13247         function reset() {
13248             output = "";
13249             indent = 0;
13250             lineStart = true;
13251             lineCount = 0;
13252             linePos = 0;
13253             hasTrailingComment = false;
13254         }
13255         function rawWrite(s) {
13256             if (s !== undefined) {
13257                 output += s;
13258                 updateLineCountAndPosFor(s);
13259                 hasTrailingComment = false;
13260             }
13261         }
13262         function writeLiteral(s) {
13263             if (s && s.length) {
13264                 write(s);
13265             }
13266         }
13267         function writeLine(force) {
13268             if (!lineStart || force) {
13269                 output += newLine;
13270                 lineCount++;
13271                 linePos = output.length;
13272                 lineStart = true;
13273                 hasTrailingComment = false;
13274             }
13275         }
13276         function getTextPosWithWriteLine() {
13277             return lineStart ? output.length : (output.length + newLine.length);
13278         }
13279         reset();
13280         return {
13281             write: write,
13282             rawWrite: rawWrite,
13283             writeLiteral: writeLiteral,
13284             writeLine: writeLine,
13285             increaseIndent: function () { indent++; },
13286             decreaseIndent: function () { indent--; },
13287             getIndent: function () { return indent; },
13288             getTextPos: function () { return output.length; },
13289             getLine: function () { return lineCount; },
13290             getColumn: function () { return lineStart ? indent * getIndentSize() : output.length - linePos; },
13291             getText: function () { return output; },
13292             isAtStartOfLine: function () { return lineStart; },
13293             hasTrailingComment: function () { return hasTrailingComment; },
13294             hasTrailingWhitespace: function () { return !!output.length && ts.isWhiteSpaceLike(output.charCodeAt(output.length - 1)); },
13295             clear: reset,
13296             reportInaccessibleThisError: ts.noop,
13297             reportPrivateInBaseOfClassExpression: ts.noop,
13298             reportInaccessibleUniqueSymbolError: ts.noop,
13299             trackSymbol: ts.noop,
13300             writeKeyword: write,
13301             writeOperator: write,
13302             writeParameter: write,
13303             writeProperty: write,
13304             writePunctuation: write,
13305             writeSpace: write,
13306             writeStringLiteral: write,
13307             writeSymbol: function (s, _) { return write(s); },
13308             writeTrailingSemicolon: write,
13309             writeComment: writeComment,
13310             getTextPosWithWriteLine: getTextPosWithWriteLine
13311         };
13312     }
13313     ts.createTextWriter = createTextWriter;
13314     function getTrailingSemicolonDeferringWriter(writer) {
13315         var pendingTrailingSemicolon = false;
13316         function commitPendingTrailingSemicolon() {
13317             if (pendingTrailingSemicolon) {
13318                 writer.writeTrailingSemicolon(";");
13319                 pendingTrailingSemicolon = false;
13320             }
13321         }
13322         return __assign(__assign({}, writer), { writeTrailingSemicolon: function () {
13323                 pendingTrailingSemicolon = true;
13324             },
13325             writeLiteral: function (s) {
13326                 commitPendingTrailingSemicolon();
13327                 writer.writeLiteral(s);
13328             },
13329             writeStringLiteral: function (s) {
13330                 commitPendingTrailingSemicolon();
13331                 writer.writeStringLiteral(s);
13332             },
13333             writeSymbol: function (s, sym) {
13334                 commitPendingTrailingSemicolon();
13335                 writer.writeSymbol(s, sym);
13336             },
13337             writePunctuation: function (s) {
13338                 commitPendingTrailingSemicolon();
13339                 writer.writePunctuation(s);
13340             },
13341             writeKeyword: function (s) {
13342                 commitPendingTrailingSemicolon();
13343                 writer.writeKeyword(s);
13344             },
13345             writeOperator: function (s) {
13346                 commitPendingTrailingSemicolon();
13347                 writer.writeOperator(s);
13348             },
13349             writeParameter: function (s) {
13350                 commitPendingTrailingSemicolon();
13351                 writer.writeParameter(s);
13352             },
13353             writeSpace: function (s) {
13354                 commitPendingTrailingSemicolon();
13355                 writer.writeSpace(s);
13356             },
13357             writeProperty: function (s) {
13358                 commitPendingTrailingSemicolon();
13359                 writer.writeProperty(s);
13360             },
13361             writeComment: function (s) {
13362                 commitPendingTrailingSemicolon();
13363                 writer.writeComment(s);
13364             },
13365             writeLine: function () {
13366                 commitPendingTrailingSemicolon();
13367                 writer.writeLine();
13368             },
13369             increaseIndent: function () {
13370                 commitPendingTrailingSemicolon();
13371                 writer.increaseIndent();
13372             },
13373             decreaseIndent: function () {
13374                 commitPendingTrailingSemicolon();
13375                 writer.decreaseIndent();
13376             } });
13377     }
13378     ts.getTrailingSemicolonDeferringWriter = getTrailingSemicolonDeferringWriter;
13379     function hostUsesCaseSensitiveFileNames(host) {
13380         return host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : false;
13381     }
13382     ts.hostUsesCaseSensitiveFileNames = hostUsesCaseSensitiveFileNames;
13383     function hostGetCanonicalFileName(host) {
13384         return ts.createGetCanonicalFileName(hostUsesCaseSensitiveFileNames(host));
13385     }
13386     ts.hostGetCanonicalFileName = hostGetCanonicalFileName;
13387     function getResolvedExternalModuleName(host, file, referenceFile) {
13388         return file.moduleName || getExternalModuleNameFromPath(host, file.fileName, referenceFile && referenceFile.fileName);
13389     }
13390     ts.getResolvedExternalModuleName = getResolvedExternalModuleName;
13391     function getCanonicalAbsolutePath(host, path) {
13392         return host.getCanonicalFileName(ts.getNormalizedAbsolutePath(path, host.getCurrentDirectory()));
13393     }
13394     function getExternalModuleNameFromDeclaration(host, resolver, declaration) {
13395         var file = resolver.getExternalModuleFileFromDeclaration(declaration);
13396         if (!file || file.isDeclarationFile) {
13397             return undefined;
13398         }
13399         var specifier = getExternalModuleName(declaration);
13400         if (specifier && ts.isStringLiteralLike(specifier) && !ts.pathIsRelative(specifier.text) &&
13401             getCanonicalAbsolutePath(host, file.path).indexOf(getCanonicalAbsolutePath(host, ts.ensureTrailingDirectorySeparator(host.getCommonSourceDirectory()))) === -1) {
13402             return undefined;
13403         }
13404         return getResolvedExternalModuleName(host, file);
13405     }
13406     ts.getExternalModuleNameFromDeclaration = getExternalModuleNameFromDeclaration;
13407     function getExternalModuleNameFromPath(host, fileName, referencePath) {
13408         var getCanonicalFileName = function (f) { return host.getCanonicalFileName(f); };
13409         var dir = ts.toPath(referencePath ? ts.getDirectoryPath(referencePath) : host.getCommonSourceDirectory(), host.getCurrentDirectory(), getCanonicalFileName);
13410         var filePath = ts.getNormalizedAbsolutePath(fileName, host.getCurrentDirectory());
13411         var relativePath = ts.getRelativePathToDirectoryOrUrl(dir, filePath, dir, getCanonicalFileName, false);
13412         var extensionless = removeFileExtension(relativePath);
13413         return referencePath ? ts.ensurePathIsNonModuleName(extensionless) : extensionless;
13414     }
13415     ts.getExternalModuleNameFromPath = getExternalModuleNameFromPath;
13416     function getOwnEmitOutputFilePath(fileName, host, extension) {
13417         var compilerOptions = host.getCompilerOptions();
13418         var emitOutputFilePathWithoutExtension;
13419         if (compilerOptions.outDir) {
13420             emitOutputFilePathWithoutExtension = removeFileExtension(getSourceFilePathInNewDir(fileName, host, compilerOptions.outDir));
13421         }
13422         else {
13423             emitOutputFilePathWithoutExtension = removeFileExtension(fileName);
13424         }
13425         return emitOutputFilePathWithoutExtension + extension;
13426     }
13427     ts.getOwnEmitOutputFilePath = getOwnEmitOutputFilePath;
13428     function getDeclarationEmitOutputFilePath(fileName, host) {
13429         return getDeclarationEmitOutputFilePathWorker(fileName, host.getCompilerOptions(), host.getCurrentDirectory(), host.getCommonSourceDirectory(), function (f) { return host.getCanonicalFileName(f); });
13430     }
13431     ts.getDeclarationEmitOutputFilePath = getDeclarationEmitOutputFilePath;
13432     function getDeclarationEmitOutputFilePathWorker(fileName, options, currentDirectory, commonSourceDirectory, getCanonicalFileName) {
13433         var outputDir = options.declarationDir || options.outDir;
13434         var path = outputDir
13435             ? getSourceFilePathInNewDirWorker(fileName, outputDir, currentDirectory, commonSourceDirectory, getCanonicalFileName)
13436             : fileName;
13437         return removeFileExtension(path) + ".d.ts";
13438     }
13439     ts.getDeclarationEmitOutputFilePathWorker = getDeclarationEmitOutputFilePathWorker;
13440     function outFile(options) {
13441         return options.outFile || options.out;
13442     }
13443     ts.outFile = outFile;
13444     function getPathsBasePath(options, host) {
13445         var _a, _b;
13446         if (!options.paths)
13447             return undefined;
13448         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'.");
13449     }
13450     ts.getPathsBasePath = getPathsBasePath;
13451     function getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit) {
13452         var options = host.getCompilerOptions();
13453         if (outFile(options)) {
13454             var moduleKind = getEmitModuleKind(options);
13455             var moduleEmitEnabled_1 = options.emitDeclarationOnly || moduleKind === ts.ModuleKind.AMD || moduleKind === ts.ModuleKind.System;
13456             return ts.filter(host.getSourceFiles(), function (sourceFile) {
13457                 return (moduleEmitEnabled_1 || !ts.isExternalModule(sourceFile)) &&
13458                     sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit);
13459             });
13460         }
13461         else {
13462             var sourceFiles = targetSourceFile === undefined ? host.getSourceFiles() : [targetSourceFile];
13463             return ts.filter(sourceFiles, function (sourceFile) { return sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit); });
13464         }
13465     }
13466     ts.getSourceFilesToEmit = getSourceFilesToEmit;
13467     function sourceFileMayBeEmitted(sourceFile, host, forceDtsEmit) {
13468         var options = host.getCompilerOptions();
13469         return !(options.noEmitForJsFiles && isSourceFileJS(sourceFile)) &&
13470             !sourceFile.isDeclarationFile &&
13471             !host.isSourceFileFromExternalLibrary(sourceFile) &&
13472             !(isJsonSourceFile(sourceFile) && host.getResolvedProjectReferenceToRedirect(sourceFile.fileName)) &&
13473             (forceDtsEmit || !host.isSourceOfProjectReferenceRedirect(sourceFile.fileName));
13474     }
13475     ts.sourceFileMayBeEmitted = sourceFileMayBeEmitted;
13476     function getSourceFilePathInNewDir(fileName, host, newDirPath) {
13477         return getSourceFilePathInNewDirWorker(fileName, newDirPath, host.getCurrentDirectory(), host.getCommonSourceDirectory(), function (f) { return host.getCanonicalFileName(f); });
13478     }
13479     ts.getSourceFilePathInNewDir = getSourceFilePathInNewDir;
13480     function getSourceFilePathInNewDirWorker(fileName, newDirPath, currentDirectory, commonSourceDirectory, getCanonicalFileName) {
13481         var sourceFilePath = ts.getNormalizedAbsolutePath(fileName, currentDirectory);
13482         var isSourceFileInCommonSourceDirectory = getCanonicalFileName(sourceFilePath).indexOf(getCanonicalFileName(commonSourceDirectory)) === 0;
13483         sourceFilePath = isSourceFileInCommonSourceDirectory ? sourceFilePath.substring(commonSourceDirectory.length) : sourceFilePath;
13484         return ts.combinePaths(newDirPath, sourceFilePath);
13485     }
13486     ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker;
13487     function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) {
13488         host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) {
13489             diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
13490         }, sourceFiles);
13491     }
13492     ts.writeFile = writeFile;
13493     function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) {
13494         if (directoryPath.length > ts.getRootLength(directoryPath) && !directoryExists(directoryPath)) {
13495             var parentDirectory = ts.getDirectoryPath(directoryPath);
13496             ensureDirectoriesExist(parentDirectory, createDirectory, directoryExists);
13497             createDirectory(directoryPath);
13498         }
13499     }
13500     function writeFileEnsuringDirectories(path, data, writeByteOrderMark, writeFile, createDirectory, directoryExists) {
13501         try {
13502             writeFile(path, data, writeByteOrderMark);
13503         }
13504         catch (_a) {
13505             ensureDirectoriesExist(ts.getDirectoryPath(ts.normalizePath(path)), createDirectory, directoryExists);
13506             writeFile(path, data, writeByteOrderMark);
13507         }
13508     }
13509     ts.writeFileEnsuringDirectories = writeFileEnsuringDirectories;
13510     function getLineOfLocalPosition(sourceFile, pos) {
13511         var lineStarts = ts.getLineStarts(sourceFile);
13512         return ts.computeLineOfPosition(lineStarts, pos);
13513     }
13514     ts.getLineOfLocalPosition = getLineOfLocalPosition;
13515     function getLineOfLocalPositionFromLineMap(lineMap, pos) {
13516         return ts.computeLineOfPosition(lineMap, pos);
13517     }
13518     ts.getLineOfLocalPositionFromLineMap = getLineOfLocalPositionFromLineMap;
13519     function getFirstConstructorWithBody(node) {
13520         return ts.find(node.members, function (member) { return ts.isConstructorDeclaration(member) && nodeIsPresent(member.body); });
13521     }
13522     ts.getFirstConstructorWithBody = getFirstConstructorWithBody;
13523     function getSetAccessorValueParameter(accessor) {
13524         if (accessor && accessor.parameters.length > 0) {
13525             var hasThis = accessor.parameters.length === 2 && parameterIsThisKeyword(accessor.parameters[0]);
13526             return accessor.parameters[hasThis ? 1 : 0];
13527         }
13528     }
13529     ts.getSetAccessorValueParameter = getSetAccessorValueParameter;
13530     function getSetAccessorTypeAnnotationNode(accessor) {
13531         var parameter = getSetAccessorValueParameter(accessor);
13532         return parameter && parameter.type;
13533     }
13534     ts.getSetAccessorTypeAnnotationNode = getSetAccessorTypeAnnotationNode;
13535     function getThisParameter(signature) {
13536         if (signature.parameters.length && !ts.isJSDocSignature(signature)) {
13537             var thisParameter = signature.parameters[0];
13538             if (parameterIsThisKeyword(thisParameter)) {
13539                 return thisParameter;
13540             }
13541         }
13542     }
13543     ts.getThisParameter = getThisParameter;
13544     function parameterIsThisKeyword(parameter) {
13545         return isThisIdentifier(parameter.name);
13546     }
13547     ts.parameterIsThisKeyword = parameterIsThisKeyword;
13548     function isThisIdentifier(node) {
13549         return !!node && node.kind === 78 && identifierIsThisKeyword(node);
13550     }
13551     ts.isThisIdentifier = isThisIdentifier;
13552     function identifierIsThisKeyword(id) {
13553         return id.originalKeywordKind === 107;
13554     }
13555     ts.identifierIsThisKeyword = identifierIsThisKeyword;
13556     function getAllAccessorDeclarations(declarations, accessor) {
13557         var firstAccessor;
13558         var secondAccessor;
13559         var getAccessor;
13560         var setAccessor;
13561         if (hasDynamicName(accessor)) {
13562             firstAccessor = accessor;
13563             if (accessor.kind === 167) {
13564                 getAccessor = accessor;
13565             }
13566             else if (accessor.kind === 168) {
13567                 setAccessor = accessor;
13568             }
13569             else {
13570                 ts.Debug.fail("Accessor has wrong kind");
13571             }
13572         }
13573         else {
13574             ts.forEach(declarations, function (member) {
13575                 if (ts.isAccessor(member)
13576                     && hasSyntacticModifier(member, 32) === hasSyntacticModifier(accessor, 32)) {
13577                     var memberName = getPropertyNameForPropertyNameNode(member.name);
13578                     var accessorName = getPropertyNameForPropertyNameNode(accessor.name);
13579                     if (memberName === accessorName) {
13580                         if (!firstAccessor) {
13581                             firstAccessor = member;
13582                         }
13583                         else if (!secondAccessor) {
13584                             secondAccessor = member;
13585                         }
13586                         if (member.kind === 167 && !getAccessor) {
13587                             getAccessor = member;
13588                         }
13589                         if (member.kind === 168 && !setAccessor) {
13590                             setAccessor = member;
13591                         }
13592                     }
13593                 }
13594             });
13595         }
13596         return {
13597             firstAccessor: firstAccessor,
13598             secondAccessor: secondAccessor,
13599             getAccessor: getAccessor,
13600             setAccessor: setAccessor
13601         };
13602     }
13603     ts.getAllAccessorDeclarations = getAllAccessorDeclarations;
13604     function getEffectiveTypeAnnotationNode(node) {
13605         if (!isInJSFile(node) && ts.isFunctionDeclaration(node))
13606             return undefined;
13607         var type = node.type;
13608         if (type || !isInJSFile(node))
13609             return type;
13610         return ts.isJSDocPropertyLikeTag(node) ? node.typeExpression && node.typeExpression.type : ts.getJSDocType(node);
13611     }
13612     ts.getEffectiveTypeAnnotationNode = getEffectiveTypeAnnotationNode;
13613     function getTypeAnnotationNode(node) {
13614         return node.type;
13615     }
13616     ts.getTypeAnnotationNode = getTypeAnnotationNode;
13617     function getEffectiveReturnTypeNode(node) {
13618         return ts.isJSDocSignature(node) ?
13619             node.type && node.type.typeExpression && node.type.typeExpression.type :
13620             node.type || (isInJSFile(node) ? ts.getJSDocReturnType(node) : undefined);
13621     }
13622     ts.getEffectiveReturnTypeNode = getEffectiveReturnTypeNode;
13623     function getJSDocTypeParameterDeclarations(node) {
13624         return ts.flatMap(ts.getJSDocTags(node), function (tag) { return isNonTypeAliasTemplate(tag) ? tag.typeParameters : undefined; });
13625     }
13626     ts.getJSDocTypeParameterDeclarations = getJSDocTypeParameterDeclarations;
13627     function isNonTypeAliasTemplate(tag) {
13628         return ts.isJSDocTemplateTag(tag) && !(tag.parent.kind === 311 && tag.parent.tags.some(isJSDocTypeAlias));
13629     }
13630     function getEffectiveSetAccessorTypeAnnotationNode(node) {
13631         var parameter = getSetAccessorValueParameter(node);
13632         return parameter && getEffectiveTypeAnnotationNode(parameter);
13633     }
13634     ts.getEffectiveSetAccessorTypeAnnotationNode = getEffectiveSetAccessorTypeAnnotationNode;
13635     function emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments) {
13636         emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, node.pos, leadingComments);
13637     }
13638     ts.emitNewLineBeforeLeadingComments = emitNewLineBeforeLeadingComments;
13639     function emitNewLineBeforeLeadingCommentsOfPosition(lineMap, writer, pos, leadingComments) {
13640         if (leadingComments && leadingComments.length && pos !== leadingComments[0].pos &&
13641             getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, leadingComments[0].pos)) {
13642             writer.writeLine();
13643         }
13644     }
13645     ts.emitNewLineBeforeLeadingCommentsOfPosition = emitNewLineBeforeLeadingCommentsOfPosition;
13646     function emitNewLineBeforeLeadingCommentOfPosition(lineMap, writer, pos, commentPos) {
13647         if (pos !== commentPos &&
13648             getLineOfLocalPositionFromLineMap(lineMap, pos) !== getLineOfLocalPositionFromLineMap(lineMap, commentPos)) {
13649             writer.writeLine();
13650         }
13651     }
13652     ts.emitNewLineBeforeLeadingCommentOfPosition = emitNewLineBeforeLeadingCommentOfPosition;
13653     function emitComments(text, lineMap, writer, comments, leadingSeparator, trailingSeparator, newLine, writeComment) {
13654         if (comments && comments.length > 0) {
13655             if (leadingSeparator) {
13656                 writer.writeSpace(" ");
13657             }
13658             var emitInterveningSeparator = false;
13659             for (var _i = 0, comments_1 = comments; _i < comments_1.length; _i++) {
13660                 var comment = comments_1[_i];
13661                 if (emitInterveningSeparator) {
13662                     writer.writeSpace(" ");
13663                     emitInterveningSeparator = false;
13664                 }
13665                 writeComment(text, lineMap, writer, comment.pos, comment.end, newLine);
13666                 if (comment.hasTrailingNewLine) {
13667                     writer.writeLine();
13668                 }
13669                 else {
13670                     emitInterveningSeparator = true;
13671                 }
13672             }
13673             if (emitInterveningSeparator && trailingSeparator) {
13674                 writer.writeSpace(" ");
13675             }
13676         }
13677     }
13678     ts.emitComments = emitComments;
13679     function emitDetachedComments(text, lineMap, writer, writeComment, node, newLine, removeComments) {
13680         var leadingComments;
13681         var currentDetachedCommentInfo;
13682         if (removeComments) {
13683             if (node.pos === 0) {
13684                 leadingComments = ts.filter(ts.getLeadingCommentRanges(text, node.pos), isPinnedCommentLocal);
13685             }
13686         }
13687         else {
13688             leadingComments = ts.getLeadingCommentRanges(text, node.pos);
13689         }
13690         if (leadingComments) {
13691             var detachedComments = [];
13692             var lastComment = void 0;
13693             for (var _i = 0, leadingComments_1 = leadingComments; _i < leadingComments_1.length; _i++) {
13694                 var comment = leadingComments_1[_i];
13695                 if (lastComment) {
13696                     var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, lastComment.end);
13697                     var commentLine = getLineOfLocalPositionFromLineMap(lineMap, comment.pos);
13698                     if (commentLine >= lastCommentLine + 2) {
13699                         break;
13700                     }
13701                 }
13702                 detachedComments.push(comment);
13703                 lastComment = comment;
13704             }
13705             if (detachedComments.length) {
13706                 var lastCommentLine = getLineOfLocalPositionFromLineMap(lineMap, ts.last(detachedComments).end);
13707                 var nodeLine = getLineOfLocalPositionFromLineMap(lineMap, ts.skipTrivia(text, node.pos));
13708                 if (nodeLine >= lastCommentLine + 2) {
13709                     emitNewLineBeforeLeadingComments(lineMap, writer, node, leadingComments);
13710                     emitComments(text, lineMap, writer, detachedComments, false, true, newLine, writeComment);
13711                     currentDetachedCommentInfo = { nodePos: node.pos, detachedCommentEndPos: ts.last(detachedComments).end };
13712                 }
13713             }
13714         }
13715         return currentDetachedCommentInfo;
13716         function isPinnedCommentLocal(comment) {
13717             return isPinnedComment(text, comment.pos);
13718         }
13719     }
13720     ts.emitDetachedComments = emitDetachedComments;
13721     function writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine) {
13722         if (text.charCodeAt(commentPos + 1) === 42) {
13723             var firstCommentLineAndCharacter = ts.computeLineAndCharacterOfPosition(lineMap, commentPos);
13724             var lineCount = lineMap.length;
13725             var firstCommentLineIndent = void 0;
13726             for (var pos = commentPos, currentLine = firstCommentLineAndCharacter.line; pos < commentEnd; currentLine++) {
13727                 var nextLineStart = (currentLine + 1) === lineCount
13728                     ? text.length + 1
13729                     : lineMap[currentLine + 1];
13730                 if (pos !== commentPos) {
13731                     if (firstCommentLineIndent === undefined) {
13732                         firstCommentLineIndent = calculateIndent(text, lineMap[firstCommentLineAndCharacter.line], commentPos);
13733                     }
13734                     var currentWriterIndentSpacing = writer.getIndent() * getIndentSize();
13735                     var spacesToEmit = currentWriterIndentSpacing - firstCommentLineIndent + calculateIndent(text, pos, nextLineStart);
13736                     if (spacesToEmit > 0) {
13737                         var numberOfSingleSpacesToEmit = spacesToEmit % getIndentSize();
13738                         var indentSizeSpaceString = getIndentString((spacesToEmit - numberOfSingleSpacesToEmit) / getIndentSize());
13739                         writer.rawWrite(indentSizeSpaceString);
13740                         while (numberOfSingleSpacesToEmit) {
13741                             writer.rawWrite(" ");
13742                             numberOfSingleSpacesToEmit--;
13743                         }
13744                     }
13745                     else {
13746                         writer.rawWrite("");
13747                     }
13748                 }
13749                 writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart);
13750                 pos = nextLineStart;
13751             }
13752         }
13753         else {
13754             writer.writeComment(text.substring(commentPos, commentEnd));
13755         }
13756     }
13757     ts.writeCommentRange = writeCommentRange;
13758     function writeTrimmedCurrentLine(text, commentEnd, writer, newLine, pos, nextLineStart) {
13759         var end = Math.min(commentEnd, nextLineStart - 1);
13760         var currentLineText = text.substring(pos, end).replace(/^\s+|\s+$/g, "");
13761         if (currentLineText) {
13762             writer.writeComment(currentLineText);
13763             if (end !== commentEnd) {
13764                 writer.writeLine();
13765             }
13766         }
13767         else {
13768             writer.rawWrite(newLine);
13769         }
13770     }
13771     function calculateIndent(text, pos, end) {
13772         var currentLineIndent = 0;
13773         for (; pos < end && ts.isWhiteSpaceSingleLine(text.charCodeAt(pos)); pos++) {
13774             if (text.charCodeAt(pos) === 9) {
13775                 currentLineIndent += getIndentSize() - (currentLineIndent % getIndentSize());
13776             }
13777             else {
13778                 currentLineIndent++;
13779             }
13780         }
13781         return currentLineIndent;
13782     }
13783     function hasEffectiveModifiers(node) {
13784         return getEffectiveModifierFlags(node) !== 0;
13785     }
13786     ts.hasEffectiveModifiers = hasEffectiveModifiers;
13787     function hasSyntacticModifiers(node) {
13788         return getSyntacticModifierFlags(node) !== 0;
13789     }
13790     ts.hasSyntacticModifiers = hasSyntacticModifiers;
13791     function hasEffectiveModifier(node, flags) {
13792         return !!getSelectedEffectiveModifierFlags(node, flags);
13793     }
13794     ts.hasEffectiveModifier = hasEffectiveModifier;
13795     function hasSyntacticModifier(node, flags) {
13796         return !!getSelectedSyntacticModifierFlags(node, flags);
13797     }
13798     ts.hasSyntacticModifier = hasSyntacticModifier;
13799     function hasStaticModifier(node) {
13800         return hasSyntacticModifier(node, 32);
13801     }
13802     ts.hasStaticModifier = hasStaticModifier;
13803     function hasEffectiveReadonlyModifier(node) {
13804         return hasEffectiveModifier(node, 64);
13805     }
13806     ts.hasEffectiveReadonlyModifier = hasEffectiveReadonlyModifier;
13807     function getSelectedEffectiveModifierFlags(node, flags) {
13808         return getEffectiveModifierFlags(node) & flags;
13809     }
13810     ts.getSelectedEffectiveModifierFlags = getSelectedEffectiveModifierFlags;
13811     function getSelectedSyntacticModifierFlags(node, flags) {
13812         return getSyntacticModifierFlags(node) & flags;
13813     }
13814     ts.getSelectedSyntacticModifierFlags = getSelectedSyntacticModifierFlags;
13815     function getModifierFlagsWorker(node, includeJSDoc, alwaysIncludeJSDoc) {
13816         if (node.kind >= 0 && node.kind <= 156) {
13817             return 0;
13818         }
13819         if (!(node.modifierFlagsCache & 536870912)) {
13820             node.modifierFlagsCache = getSyntacticModifierFlagsNoCache(node) | 536870912;
13821         }
13822         if (includeJSDoc && !(node.modifierFlagsCache & 4096) && (alwaysIncludeJSDoc || isInJSFile(node)) && node.parent) {
13823             node.modifierFlagsCache |= getJSDocModifierFlagsNoCache(node) | 4096;
13824         }
13825         return node.modifierFlagsCache & ~(536870912 | 4096);
13826     }
13827     function getEffectiveModifierFlags(node) {
13828         return getModifierFlagsWorker(node, true);
13829     }
13830     ts.getEffectiveModifierFlags = getEffectiveModifierFlags;
13831     function getEffectiveModifierFlagsAlwaysIncludeJSDoc(node) {
13832         return getModifierFlagsWorker(node, true, true);
13833     }
13834     ts.getEffectiveModifierFlagsAlwaysIncludeJSDoc = getEffectiveModifierFlagsAlwaysIncludeJSDoc;
13835     function getSyntacticModifierFlags(node) {
13836         return getModifierFlagsWorker(node, false);
13837     }
13838     ts.getSyntacticModifierFlags = getSyntacticModifierFlags;
13839     function getJSDocModifierFlagsNoCache(node) {
13840         var flags = 0;
13841         if (!!node.parent && !ts.isParameter(node)) {
13842             if (isInJSFile(node)) {
13843                 if (ts.getJSDocPublicTagNoCache(node))
13844                     flags |= 4;
13845                 if (ts.getJSDocPrivateTagNoCache(node))
13846                     flags |= 8;
13847                 if (ts.getJSDocProtectedTagNoCache(node))
13848                     flags |= 16;
13849                 if (ts.getJSDocReadonlyTagNoCache(node))
13850                     flags |= 64;
13851             }
13852             if (ts.getJSDocDeprecatedTagNoCache(node))
13853                 flags |= 8192;
13854         }
13855         return flags;
13856     }
13857     function getEffectiveModifierFlagsNoCache(node) {
13858         return getSyntacticModifierFlagsNoCache(node) | getJSDocModifierFlagsNoCache(node);
13859     }
13860     ts.getEffectiveModifierFlagsNoCache = getEffectiveModifierFlagsNoCache;
13861     function getSyntacticModifierFlagsNoCache(node) {
13862         var flags = modifiersToFlags(node.modifiers);
13863         if (node.flags & 4 || (node.kind === 78 && node.isInJSDocNamespace)) {
13864             flags |= 1;
13865         }
13866         return flags;
13867     }
13868     ts.getSyntacticModifierFlagsNoCache = getSyntacticModifierFlagsNoCache;
13869     function modifiersToFlags(modifiers) {
13870         var flags = 0;
13871         if (modifiers) {
13872             for (var _i = 0, modifiers_1 = modifiers; _i < modifiers_1.length; _i++) {
13873                 var modifier = modifiers_1[_i];
13874                 flags |= modifierToFlag(modifier.kind);
13875             }
13876         }
13877         return flags;
13878     }
13879     ts.modifiersToFlags = modifiersToFlags;
13880     function modifierToFlag(token) {
13881         switch (token) {
13882             case 123: return 32;
13883             case 122: return 4;
13884             case 121: return 16;
13885             case 120: return 8;
13886             case 125: return 128;
13887             case 92: return 1;
13888             case 133: return 2;
13889             case 84: return 2048;
13890             case 87: return 512;
13891             case 129: return 256;
13892             case 142: return 64;
13893         }
13894         return 0;
13895     }
13896     ts.modifierToFlag = modifierToFlag;
13897     function isLogicalOperator(token) {
13898         return token === 56
13899             || token === 55
13900             || token === 53;
13901     }
13902     ts.isLogicalOperator = isLogicalOperator;
13903     function isLogicalOrCoalescingAssignmentOperator(token) {
13904         return token === 74
13905             || token === 75
13906             || token === 76;
13907     }
13908     ts.isLogicalOrCoalescingAssignmentOperator = isLogicalOrCoalescingAssignmentOperator;
13909     function isLogicalOrCoalescingAssignmentExpression(expr) {
13910         return isLogicalOrCoalescingAssignmentOperator(expr.operatorToken.kind);
13911     }
13912     ts.isLogicalOrCoalescingAssignmentExpression = isLogicalOrCoalescingAssignmentExpression;
13913     function isAssignmentOperator(token) {
13914         return token >= 62 && token <= 77;
13915     }
13916     ts.isAssignmentOperator = isAssignmentOperator;
13917     function tryGetClassExtendingExpressionWithTypeArguments(node) {
13918         var cls = tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node);
13919         return cls && !cls.isImplements ? cls.class : undefined;
13920     }
13921     ts.tryGetClassExtendingExpressionWithTypeArguments = tryGetClassExtendingExpressionWithTypeArguments;
13922     function tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node) {
13923         return ts.isExpressionWithTypeArguments(node)
13924             && ts.isHeritageClause(node.parent)
13925             && ts.isClassLike(node.parent.parent)
13926             ? { class: node.parent.parent, isImplements: node.parent.token === 116 }
13927             : undefined;
13928     }
13929     ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments = tryGetClassImplementingOrExtendingExpressionWithTypeArguments;
13930     function isAssignmentExpression(node, excludeCompoundAssignment) {
13931         return ts.isBinaryExpression(node)
13932             && (excludeCompoundAssignment
13933                 ? node.operatorToken.kind === 62
13934                 : isAssignmentOperator(node.operatorToken.kind))
13935             && ts.isLeftHandSideExpression(node.left);
13936     }
13937     ts.isAssignmentExpression = isAssignmentExpression;
13938     function isDestructuringAssignment(node) {
13939         if (isAssignmentExpression(node, true)) {
13940             var kind = node.left.kind;
13941             return kind === 200
13942                 || kind === 199;
13943         }
13944         return false;
13945     }
13946     ts.isDestructuringAssignment = isDestructuringAssignment;
13947     function isExpressionWithTypeArgumentsInClassExtendsClause(node) {
13948         return tryGetClassExtendingExpressionWithTypeArguments(node) !== undefined;
13949     }
13950     ts.isExpressionWithTypeArgumentsInClassExtendsClause = isExpressionWithTypeArgumentsInClassExtendsClause;
13951     function isEntityNameExpression(node) {
13952         return node.kind === 78 || isPropertyAccessEntityNameExpression(node);
13953     }
13954     ts.isEntityNameExpression = isEntityNameExpression;
13955     function getFirstIdentifier(node) {
13956         switch (node.kind) {
13957             case 78:
13958                 return node;
13959             case 157:
13960                 do {
13961                     node = node.left;
13962                 } while (node.kind !== 78);
13963                 return node;
13964             case 201:
13965                 do {
13966                     node = node.expression;
13967                 } while (node.kind !== 78);
13968                 return node;
13969         }
13970     }
13971     ts.getFirstIdentifier = getFirstIdentifier;
13972     function isDottedName(node) {
13973         return node.kind === 78 || node.kind === 107 || node.kind === 105 ||
13974             node.kind === 201 && isDottedName(node.expression) ||
13975             node.kind === 207 && isDottedName(node.expression);
13976     }
13977     ts.isDottedName = isDottedName;
13978     function isPropertyAccessEntityNameExpression(node) {
13979         return ts.isPropertyAccessExpression(node) && ts.isIdentifier(node.name) && isEntityNameExpression(node.expression);
13980     }
13981     ts.isPropertyAccessEntityNameExpression = isPropertyAccessEntityNameExpression;
13982     function tryGetPropertyAccessOrIdentifierToString(expr) {
13983         if (ts.isPropertyAccessExpression(expr)) {
13984             var baseStr = tryGetPropertyAccessOrIdentifierToString(expr.expression);
13985             if (baseStr !== undefined) {
13986                 return baseStr + "." + entityNameToString(expr.name);
13987             }
13988         }
13989         else if (ts.isElementAccessExpression(expr)) {
13990             var baseStr = tryGetPropertyAccessOrIdentifierToString(expr.expression);
13991             if (baseStr !== undefined && ts.isPropertyName(expr.argumentExpression)) {
13992                 return baseStr + "." + getPropertyNameForPropertyNameNode(expr.argumentExpression);
13993             }
13994         }
13995         else if (ts.isIdentifier(expr)) {
13996             return ts.unescapeLeadingUnderscores(expr.escapedText);
13997         }
13998         return undefined;
13999     }
14000     ts.tryGetPropertyAccessOrIdentifierToString = tryGetPropertyAccessOrIdentifierToString;
14001     function isPrototypeAccess(node) {
14002         return isBindableStaticAccessExpression(node) && getElementOrPropertyAccessName(node) === "prototype";
14003     }
14004     ts.isPrototypeAccess = isPrototypeAccess;
14005     function isRightSideOfQualifiedNameOrPropertyAccess(node) {
14006         return (node.parent.kind === 157 && node.parent.right === node) ||
14007             (node.parent.kind === 201 && node.parent.name === node);
14008     }
14009     ts.isRightSideOfQualifiedNameOrPropertyAccess = isRightSideOfQualifiedNameOrPropertyAccess;
14010     function isEmptyObjectLiteral(expression) {
14011         return expression.kind === 200 &&
14012             expression.properties.length === 0;
14013     }
14014     ts.isEmptyObjectLiteral = isEmptyObjectLiteral;
14015     function isEmptyArrayLiteral(expression) {
14016         return expression.kind === 199 &&
14017             expression.elements.length === 0;
14018     }
14019     ts.isEmptyArrayLiteral = isEmptyArrayLiteral;
14020     function getLocalSymbolForExportDefault(symbol) {
14021         if (!isExportDefaultSymbol(symbol))
14022             return undefined;
14023         for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
14024             var decl = _a[_i];
14025             if (decl.localSymbol)
14026                 return decl.localSymbol;
14027         }
14028         return undefined;
14029     }
14030     ts.getLocalSymbolForExportDefault = getLocalSymbolForExportDefault;
14031     function isExportDefaultSymbol(symbol) {
14032         return symbol && ts.length(symbol.declarations) > 0 && hasSyntacticModifier(symbol.declarations[0], 512);
14033     }
14034     function tryExtractTSExtension(fileName) {
14035         return ts.find(ts.supportedTSExtensionsForExtractExtension, function (extension) { return ts.fileExtensionIs(fileName, extension); });
14036     }
14037     ts.tryExtractTSExtension = tryExtractTSExtension;
14038     function getExpandedCharCodes(input) {
14039         var output = [];
14040         var length = input.length;
14041         for (var i = 0; i < length; i++) {
14042             var charCode = input.charCodeAt(i);
14043             if (charCode < 0x80) {
14044                 output.push(charCode);
14045             }
14046             else if (charCode < 0x800) {
14047                 output.push((charCode >> 6) | 192);
14048                 output.push((charCode & 63) | 128);
14049             }
14050             else if (charCode < 0x10000) {
14051                 output.push((charCode >> 12) | 224);
14052                 output.push(((charCode >> 6) & 63) | 128);
14053                 output.push((charCode & 63) | 128);
14054             }
14055             else if (charCode < 0x20000) {
14056                 output.push((charCode >> 18) | 240);
14057                 output.push(((charCode >> 12) & 63) | 128);
14058                 output.push(((charCode >> 6) & 63) | 128);
14059                 output.push((charCode & 63) | 128);
14060             }
14061             else {
14062                 ts.Debug.assert(false, "Unexpected code point");
14063             }
14064         }
14065         return output;
14066     }
14067     var base64Digits = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
14068     function convertToBase64(input) {
14069         var result = "";
14070         var charCodes = getExpandedCharCodes(input);
14071         var i = 0;
14072         var length = charCodes.length;
14073         var byte1, byte2, byte3, byte4;
14074         while (i < length) {
14075             byte1 = charCodes[i] >> 2;
14076             byte2 = (charCodes[i] & 3) << 4 | charCodes[i + 1] >> 4;
14077             byte3 = (charCodes[i + 1] & 15) << 2 | charCodes[i + 2] >> 6;
14078             byte4 = charCodes[i + 2] & 63;
14079             if (i + 1 >= length) {
14080                 byte3 = byte4 = 64;
14081             }
14082             else if (i + 2 >= length) {
14083                 byte4 = 64;
14084             }
14085             result += base64Digits.charAt(byte1) + base64Digits.charAt(byte2) + base64Digits.charAt(byte3) + base64Digits.charAt(byte4);
14086             i += 3;
14087         }
14088         return result;
14089     }
14090     ts.convertToBase64 = convertToBase64;
14091     function getStringFromExpandedCharCodes(codes) {
14092         var output = "";
14093         var i = 0;
14094         var length = codes.length;
14095         while (i < length) {
14096             var charCode = codes[i];
14097             if (charCode < 0x80) {
14098                 output += String.fromCharCode(charCode);
14099                 i++;
14100             }
14101             else if ((charCode & 192) === 192) {
14102                 var value = charCode & 63;
14103                 i++;
14104                 var nextCode = codes[i];
14105                 while ((nextCode & 192) === 128) {
14106                     value = (value << 6) | (nextCode & 63);
14107                     i++;
14108                     nextCode = codes[i];
14109                 }
14110                 output += String.fromCharCode(value);
14111             }
14112             else {
14113                 output += String.fromCharCode(charCode);
14114                 i++;
14115             }
14116         }
14117         return output;
14118     }
14119     function base64encode(host, input) {
14120         if (host && host.base64encode) {
14121             return host.base64encode(input);
14122         }
14123         return convertToBase64(input);
14124     }
14125     ts.base64encode = base64encode;
14126     function base64decode(host, input) {
14127         if (host && host.base64decode) {
14128             return host.base64decode(input);
14129         }
14130         var length = input.length;
14131         var expandedCharCodes = [];
14132         var i = 0;
14133         while (i < length) {
14134             if (input.charCodeAt(i) === base64Digits.charCodeAt(64)) {
14135                 break;
14136             }
14137             var ch1 = base64Digits.indexOf(input[i]);
14138             var ch2 = base64Digits.indexOf(input[i + 1]);
14139             var ch3 = base64Digits.indexOf(input[i + 2]);
14140             var ch4 = base64Digits.indexOf(input[i + 3]);
14141             var code1 = ((ch1 & 63) << 2) | ((ch2 >> 4) & 3);
14142             var code2 = ((ch2 & 15) << 4) | ((ch3 >> 2) & 15);
14143             var code3 = ((ch3 & 3) << 6) | (ch4 & 63);
14144             if (code2 === 0 && ch3 !== 0) {
14145                 expandedCharCodes.push(code1);
14146             }
14147             else if (code3 === 0 && ch4 !== 0) {
14148                 expandedCharCodes.push(code1, code2);
14149             }
14150             else {
14151                 expandedCharCodes.push(code1, code2, code3);
14152             }
14153             i += 4;
14154         }
14155         return getStringFromExpandedCharCodes(expandedCharCodes);
14156     }
14157     ts.base64decode = base64decode;
14158     function readJson(path, host) {
14159         try {
14160             var jsonText = host.readFile(path);
14161             if (!jsonText)
14162                 return {};
14163             var result = ts.parseConfigFileTextToJson(path, jsonText);
14164             if (result.error) {
14165                 return {};
14166             }
14167             return result.config;
14168         }
14169         catch (e) {
14170             return {};
14171         }
14172     }
14173     ts.readJson = readJson;
14174     function directoryProbablyExists(directoryName, host) {
14175         return !host.directoryExists || host.directoryExists(directoryName);
14176     }
14177     ts.directoryProbablyExists = directoryProbablyExists;
14178     var carriageReturnLineFeed = "\r\n";
14179     var lineFeed = "\n";
14180     function getNewLineCharacter(options, getNewLine) {
14181         switch (options.newLine) {
14182             case 0:
14183                 return carriageReturnLineFeed;
14184             case 1:
14185                 return lineFeed;
14186         }
14187         return getNewLine ? getNewLine() : ts.sys ? ts.sys.newLine : carriageReturnLineFeed;
14188     }
14189     ts.getNewLineCharacter = getNewLineCharacter;
14190     function createRange(pos, end) {
14191         if (end === void 0) { end = pos; }
14192         ts.Debug.assert(end >= pos || end === -1);
14193         return { pos: pos, end: end };
14194     }
14195     ts.createRange = createRange;
14196     function moveRangeEnd(range, end) {
14197         return createRange(range.pos, end);
14198     }
14199     ts.moveRangeEnd = moveRangeEnd;
14200     function moveRangePos(range, pos) {
14201         return createRange(pos, range.end);
14202     }
14203     ts.moveRangePos = moveRangePos;
14204     function moveRangePastDecorators(node) {
14205         return node.decorators && node.decorators.length > 0
14206             ? moveRangePos(node, node.decorators.end)
14207             : node;
14208     }
14209     ts.moveRangePastDecorators = moveRangePastDecorators;
14210     function moveRangePastModifiers(node) {
14211         return node.modifiers && node.modifiers.length > 0
14212             ? moveRangePos(node, node.modifiers.end)
14213             : moveRangePastDecorators(node);
14214     }
14215     ts.moveRangePastModifiers = moveRangePastModifiers;
14216     function isCollapsedRange(range) {
14217         return range.pos === range.end;
14218     }
14219     ts.isCollapsedRange = isCollapsedRange;
14220     function createTokenRange(pos, token) {
14221         return createRange(pos, pos + ts.tokenToString(token).length);
14222     }
14223     ts.createTokenRange = createTokenRange;
14224     function rangeIsOnSingleLine(range, sourceFile) {
14225         return rangeStartIsOnSameLineAsRangeEnd(range, range, sourceFile);
14226     }
14227     ts.rangeIsOnSingleLine = rangeIsOnSingleLine;
14228     function rangeStartPositionsAreOnSameLine(range1, range2, sourceFile) {
14229         return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile, false), getStartPositionOfRange(range2, sourceFile, false), sourceFile);
14230     }
14231     ts.rangeStartPositionsAreOnSameLine = rangeStartPositionsAreOnSameLine;
14232     function rangeEndPositionsAreOnSameLine(range1, range2, sourceFile) {
14233         return positionsAreOnSameLine(range1.end, range2.end, sourceFile);
14234     }
14235     ts.rangeEndPositionsAreOnSameLine = rangeEndPositionsAreOnSameLine;
14236     function rangeStartIsOnSameLineAsRangeEnd(range1, range2, sourceFile) {
14237         return positionsAreOnSameLine(getStartPositionOfRange(range1, sourceFile, false), range2.end, sourceFile);
14238     }
14239     ts.rangeStartIsOnSameLineAsRangeEnd = rangeStartIsOnSameLineAsRangeEnd;
14240     function rangeEndIsOnSameLineAsRangeStart(range1, range2, sourceFile) {
14241         return positionsAreOnSameLine(range1.end, getStartPositionOfRange(range2, sourceFile, false), sourceFile);
14242     }
14243     ts.rangeEndIsOnSameLineAsRangeStart = rangeEndIsOnSameLineAsRangeStart;
14244     function getLinesBetweenRangeEndAndRangeStart(range1, range2, sourceFile, includeSecondRangeComments) {
14245         var range2Start = getStartPositionOfRange(range2, sourceFile, includeSecondRangeComments);
14246         return ts.getLinesBetweenPositions(sourceFile, range1.end, range2Start);
14247     }
14248     ts.getLinesBetweenRangeEndAndRangeStart = getLinesBetweenRangeEndAndRangeStart;
14249     function getLinesBetweenRangeEndPositions(range1, range2, sourceFile) {
14250         return ts.getLinesBetweenPositions(sourceFile, range1.end, range2.end);
14251     }
14252     ts.getLinesBetweenRangeEndPositions = getLinesBetweenRangeEndPositions;
14253     function isNodeArrayMultiLine(list, sourceFile) {
14254         return !positionsAreOnSameLine(list.pos, list.end, sourceFile);
14255     }
14256     ts.isNodeArrayMultiLine = isNodeArrayMultiLine;
14257     function positionsAreOnSameLine(pos1, pos2, sourceFile) {
14258         return ts.getLinesBetweenPositions(sourceFile, pos1, pos2) === 0;
14259     }
14260     ts.positionsAreOnSameLine = positionsAreOnSameLine;
14261     function getStartPositionOfRange(range, sourceFile, includeComments) {
14262         return positionIsSynthesized(range.pos) ? -1 : ts.skipTrivia(sourceFile.text, range.pos, false, includeComments);
14263     }
14264     ts.getStartPositionOfRange = getStartPositionOfRange;
14265     function getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(pos, stopPos, sourceFile, includeComments) {
14266         var startPos = ts.skipTrivia(sourceFile.text, pos, false, includeComments);
14267         var prevPos = getPreviousNonWhitespacePosition(startPos, stopPos, sourceFile);
14268         return ts.getLinesBetweenPositions(sourceFile, prevPos !== null && prevPos !== void 0 ? prevPos : stopPos, startPos);
14269     }
14270     ts.getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter = getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter;
14271     function getLinesBetweenPositionAndNextNonWhitespaceCharacter(pos, stopPos, sourceFile, includeComments) {
14272         var nextPos = ts.skipTrivia(sourceFile.text, pos, false, includeComments);
14273         return ts.getLinesBetweenPositions(sourceFile, pos, Math.min(stopPos, nextPos));
14274     }
14275     ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter = getLinesBetweenPositionAndNextNonWhitespaceCharacter;
14276     function getPreviousNonWhitespacePosition(pos, stopPos, sourceFile) {
14277         if (stopPos === void 0) { stopPos = 0; }
14278         while (pos-- > stopPos) {
14279             if (!ts.isWhiteSpaceLike(sourceFile.text.charCodeAt(pos))) {
14280                 return pos;
14281             }
14282         }
14283     }
14284     function isDeclarationNameOfEnumOrNamespace(node) {
14285         var parseNode = ts.getParseTreeNode(node);
14286         if (parseNode) {
14287             switch (parseNode.parent.kind) {
14288                 case 255:
14289                 case 256:
14290                     return parseNode === parseNode.parent.name;
14291             }
14292         }
14293         return false;
14294     }
14295     ts.isDeclarationNameOfEnumOrNamespace = isDeclarationNameOfEnumOrNamespace;
14296     function getInitializedVariables(node) {
14297         return ts.filter(node.declarations, isInitializedVariable);
14298     }
14299     ts.getInitializedVariables = getInitializedVariables;
14300     function isInitializedVariable(node) {
14301         return node.initializer !== undefined;
14302     }
14303     function isWatchSet(options) {
14304         return options.watch && options.hasOwnProperty("watch");
14305     }
14306     ts.isWatchSet = isWatchSet;
14307     function closeFileWatcher(watcher) {
14308         watcher.close();
14309     }
14310     ts.closeFileWatcher = closeFileWatcher;
14311     function getCheckFlags(symbol) {
14312         return symbol.flags & 33554432 ? symbol.checkFlags : 0;
14313     }
14314     ts.getCheckFlags = getCheckFlags;
14315     function getDeclarationModifierFlagsFromSymbol(s) {
14316         if (s.valueDeclaration) {
14317             var flags = ts.getCombinedModifierFlags(s.valueDeclaration);
14318             return s.parent && s.parent.flags & 32 ? flags : flags & ~28;
14319         }
14320         if (getCheckFlags(s) & 6) {
14321             var checkFlags = s.checkFlags;
14322             var accessModifier = checkFlags & 1024 ? 8 :
14323                 checkFlags & 256 ? 4 :
14324                     16;
14325             var staticModifier = checkFlags & 2048 ? 32 : 0;
14326             return accessModifier | staticModifier;
14327         }
14328         if (s.flags & 4194304) {
14329             return 4 | 32;
14330         }
14331         return 0;
14332     }
14333     ts.getDeclarationModifierFlagsFromSymbol = getDeclarationModifierFlagsFromSymbol;
14334     function skipAlias(symbol, checker) {
14335         return symbol.flags & 2097152 ? checker.getAliasedSymbol(symbol) : symbol;
14336     }
14337     ts.skipAlias = skipAlias;
14338     function getCombinedLocalAndExportSymbolFlags(symbol) {
14339         return symbol.exportSymbol ? symbol.exportSymbol.flags | symbol.flags : symbol.flags;
14340     }
14341     ts.getCombinedLocalAndExportSymbolFlags = getCombinedLocalAndExportSymbolFlags;
14342     function isWriteOnlyAccess(node) {
14343         return accessKind(node) === 1;
14344     }
14345     ts.isWriteOnlyAccess = isWriteOnlyAccess;
14346     function isWriteAccess(node) {
14347         return accessKind(node) !== 0;
14348     }
14349     ts.isWriteAccess = isWriteAccess;
14350     function accessKind(node) {
14351         var parent = node.parent;
14352         if (!parent)
14353             return 0;
14354         switch (parent.kind) {
14355             case 207:
14356                 return accessKind(parent);
14357             case 215:
14358             case 214:
14359                 var operator = parent.operator;
14360                 return operator === 45 || operator === 46 ? writeOrReadWrite() : 0;
14361             case 216:
14362                 var _a = parent, left = _a.left, operatorToken = _a.operatorToken;
14363                 return left === node && isAssignmentOperator(operatorToken.kind) ?
14364                     operatorToken.kind === 62 ? 1 : writeOrReadWrite()
14365                     : 0;
14366             case 201:
14367                 return parent.name !== node ? 0 : accessKind(parent);
14368             case 288: {
14369                 var parentAccess = accessKind(parent.parent);
14370                 return node === parent.name ? reverseAccessKind(parentAccess) : parentAccess;
14371             }
14372             case 289:
14373                 return node === parent.objectAssignmentInitializer ? 0 : accessKind(parent.parent);
14374             case 199:
14375                 return accessKind(parent);
14376             default:
14377                 return 0;
14378         }
14379         function writeOrReadWrite() {
14380             return parent.parent && skipParenthesesUp(parent.parent).kind === 233 ? 1 : 2;
14381         }
14382     }
14383     function reverseAccessKind(a) {
14384         switch (a) {
14385             case 0:
14386                 return 1;
14387             case 1:
14388                 return 0;
14389             case 2:
14390                 return 2;
14391             default:
14392                 return ts.Debug.assertNever(a);
14393         }
14394     }
14395     function compareDataObjects(dst, src) {
14396         if (!dst || !src || Object.keys(dst).length !== Object.keys(src).length) {
14397             return false;
14398         }
14399         for (var e in dst) {
14400             if (typeof dst[e] === "object") {
14401                 if (!compareDataObjects(dst[e], src[e])) {
14402                     return false;
14403                 }
14404             }
14405             else if (typeof dst[e] !== "function") {
14406                 if (dst[e] !== src[e]) {
14407                     return false;
14408                 }
14409             }
14410         }
14411         return true;
14412     }
14413     ts.compareDataObjects = compareDataObjects;
14414     function clearMap(map, onDeleteValue) {
14415         map.forEach(onDeleteValue);
14416         map.clear();
14417     }
14418     ts.clearMap = clearMap;
14419     function mutateMapSkippingNewValues(map, newMap, options) {
14420         var onDeleteValue = options.onDeleteValue, onExistingValue = options.onExistingValue;
14421         map.forEach(function (existingValue, key) {
14422             var valueInNewMap = newMap.get(key);
14423             if (valueInNewMap === undefined) {
14424                 map.delete(key);
14425                 onDeleteValue(existingValue, key);
14426             }
14427             else if (onExistingValue) {
14428                 onExistingValue(existingValue, valueInNewMap, key);
14429             }
14430         });
14431     }
14432     ts.mutateMapSkippingNewValues = mutateMapSkippingNewValues;
14433     function mutateMap(map, newMap, options) {
14434         mutateMapSkippingNewValues(map, newMap, options);
14435         var createNewValue = options.createNewValue;
14436         newMap.forEach(function (valueInNewMap, key) {
14437             if (!map.has(key)) {
14438                 map.set(key, createNewValue(key, valueInNewMap));
14439             }
14440         });
14441     }
14442     ts.mutateMap = mutateMap;
14443     function isAbstractConstructorSymbol(symbol) {
14444         if (symbol.flags & 32) {
14445             var declaration = getClassLikeDeclarationOfSymbol(symbol);
14446             return !!declaration && hasSyntacticModifier(declaration, 128);
14447         }
14448         return false;
14449     }
14450     ts.isAbstractConstructorSymbol = isAbstractConstructorSymbol;
14451     function getClassLikeDeclarationOfSymbol(symbol) {
14452         return ts.find(symbol.declarations, ts.isClassLike);
14453     }
14454     ts.getClassLikeDeclarationOfSymbol = getClassLikeDeclarationOfSymbol;
14455     function getObjectFlags(type) {
14456         return type.flags & 3899393 ? type.objectFlags : 0;
14457     }
14458     ts.getObjectFlags = getObjectFlags;
14459     function typeHasCallOrConstructSignatures(type, checker) {
14460         return checker.getSignaturesOfType(type, 0).length !== 0 || checker.getSignaturesOfType(type, 1).length !== 0;
14461     }
14462     ts.typeHasCallOrConstructSignatures = typeHasCallOrConstructSignatures;
14463     function forSomeAncestorDirectory(directory, callback) {
14464         return !!ts.forEachAncestorDirectory(directory, function (d) { return callback(d) ? true : undefined; });
14465     }
14466     ts.forSomeAncestorDirectory = forSomeAncestorDirectory;
14467     function isUMDExportSymbol(symbol) {
14468         return !!symbol && !!symbol.declarations && !!symbol.declarations[0] && ts.isNamespaceExportDeclaration(symbol.declarations[0]);
14469     }
14470     ts.isUMDExportSymbol = isUMDExportSymbol;
14471     function showModuleSpecifier(_a) {
14472         var moduleSpecifier = _a.moduleSpecifier;
14473         return ts.isStringLiteral(moduleSpecifier) ? moduleSpecifier.text : getTextOfNode(moduleSpecifier);
14474     }
14475     ts.showModuleSpecifier = showModuleSpecifier;
14476     function getLastChild(node) {
14477         var lastChild;
14478         ts.forEachChild(node, function (child) {
14479             if (nodeIsPresent(child))
14480                 lastChild = child;
14481         }, function (children) {
14482             for (var i = children.length - 1; i >= 0; i--) {
14483                 if (nodeIsPresent(children[i])) {
14484                     lastChild = children[i];
14485                     break;
14486                 }
14487             }
14488         });
14489         return lastChild;
14490     }
14491     ts.getLastChild = getLastChild;
14492     function addToSeen(seen, key, value) {
14493         if (value === void 0) { value = true; }
14494         key = String(key);
14495         if (seen.has(key)) {
14496             return false;
14497         }
14498         seen.set(key, value);
14499         return true;
14500     }
14501     ts.addToSeen = addToSeen;
14502     function isObjectTypeDeclaration(node) {
14503         return ts.isClassLike(node) || ts.isInterfaceDeclaration(node) || ts.isTypeLiteralNode(node);
14504     }
14505     ts.isObjectTypeDeclaration = isObjectTypeDeclaration;
14506     function isTypeNodeKind(kind) {
14507         return (kind >= 172 && kind <= 195)
14508             || kind === 128
14509             || kind === 152
14510             || kind === 144
14511             || kind === 155
14512             || kind === 145
14513             || kind === 131
14514             || kind === 147
14515             || kind === 148
14516             || kind === 113
14517             || kind === 150
14518             || kind === 141
14519             || kind === 223
14520             || kind === 303
14521             || kind === 304
14522             || kind === 305
14523             || kind === 306
14524             || kind === 307
14525             || kind === 308
14526             || kind === 309;
14527     }
14528     ts.isTypeNodeKind = isTypeNodeKind;
14529     function isAccessExpression(node) {
14530         return node.kind === 201 || node.kind === 202;
14531     }
14532     ts.isAccessExpression = isAccessExpression;
14533     function getNameOfAccessExpression(node) {
14534         if (node.kind === 201) {
14535             return node.name;
14536         }
14537         ts.Debug.assert(node.kind === 202);
14538         return node.argumentExpression;
14539     }
14540     ts.getNameOfAccessExpression = getNameOfAccessExpression;
14541     function isBundleFileTextLike(section) {
14542         switch (section.kind) {
14543             case "text":
14544             case "internal":
14545                 return true;
14546             default:
14547                 return false;
14548         }
14549     }
14550     ts.isBundleFileTextLike = isBundleFileTextLike;
14551     function isNamedImportsOrExports(node) {
14552         return node.kind === 264 || node.kind === 268;
14553     }
14554     ts.isNamedImportsOrExports = isNamedImportsOrExports;
14555     function getLeftmostAccessExpression(expr) {
14556         while (isAccessExpression(expr)) {
14557             expr = expr.expression;
14558         }
14559         return expr;
14560     }
14561     ts.getLeftmostAccessExpression = getLeftmostAccessExpression;
14562     function getLeftmostExpression(node, stopAtCallExpressions) {
14563         while (true) {
14564             switch (node.kind) {
14565                 case 215:
14566                     node = node.operand;
14567                     continue;
14568                 case 216:
14569                     node = node.left;
14570                     continue;
14571                 case 217:
14572                     node = node.condition;
14573                     continue;
14574                 case 205:
14575                     node = node.tag;
14576                     continue;
14577                 case 203:
14578                     if (stopAtCallExpressions) {
14579                         return node;
14580                     }
14581                 case 224:
14582                 case 202:
14583                 case 201:
14584                 case 225:
14585                 case 336:
14586                     node = node.expression;
14587                     continue;
14588             }
14589             return node;
14590         }
14591     }
14592     ts.getLeftmostExpression = getLeftmostExpression;
14593     function Symbol(flags, name) {
14594         this.flags = flags;
14595         this.escapedName = name;
14596         this.declarations = undefined;
14597         this.valueDeclaration = undefined;
14598         this.id = undefined;
14599         this.mergeId = undefined;
14600         this.parent = undefined;
14601     }
14602     function Type(checker, flags) {
14603         this.flags = flags;
14604         if (ts.Debug.isDebugging || ts.tracing) {
14605             this.checker = checker;
14606         }
14607     }
14608     function Signature(checker, flags) {
14609         this.flags = flags;
14610         if (ts.Debug.isDebugging) {
14611             this.checker = checker;
14612         }
14613     }
14614     function Node(kind, pos, end) {
14615         this.pos = pos;
14616         this.end = end;
14617         this.kind = kind;
14618         this.id = 0;
14619         this.flags = 0;
14620         this.modifierFlagsCache = 0;
14621         this.transformFlags = 0;
14622         this.parent = undefined;
14623         this.original = undefined;
14624     }
14625     function Token(kind, pos, end) {
14626         this.pos = pos;
14627         this.end = end;
14628         this.kind = kind;
14629         this.id = 0;
14630         this.flags = 0;
14631         this.transformFlags = 0;
14632         this.parent = undefined;
14633     }
14634     function Identifier(kind, pos, end) {
14635         this.pos = pos;
14636         this.end = end;
14637         this.kind = kind;
14638         this.id = 0;
14639         this.flags = 0;
14640         this.transformFlags = 0;
14641         this.parent = undefined;
14642         this.original = undefined;
14643         this.flowNode = undefined;
14644     }
14645     function SourceMapSource(fileName, text, skipTrivia) {
14646         this.fileName = fileName;
14647         this.text = text;
14648         this.skipTrivia = skipTrivia || (function (pos) { return pos; });
14649     }
14650     ts.objectAllocator = {
14651         getNodeConstructor: function () { return Node; },
14652         getTokenConstructor: function () { return Token; },
14653         getIdentifierConstructor: function () { return Identifier; },
14654         getPrivateIdentifierConstructor: function () { return Node; },
14655         getSourceFileConstructor: function () { return Node; },
14656         getSymbolConstructor: function () { return Symbol; },
14657         getTypeConstructor: function () { return Type; },
14658         getSignatureConstructor: function () { return Signature; },
14659         getSourceMapSourceConstructor: function () { return SourceMapSource; },
14660     };
14661     function setObjectAllocator(alloc) {
14662         ts.objectAllocator = alloc;
14663     }
14664     ts.setObjectAllocator = setObjectAllocator;
14665     function formatStringFromArgs(text, args, baseIndex) {
14666         if (baseIndex === void 0) { baseIndex = 0; }
14667         return text.replace(/{(\d+)}/g, function (_match, index) { return "" + ts.Debug.checkDefined(args[+index + baseIndex]); });
14668     }
14669     ts.formatStringFromArgs = formatStringFromArgs;
14670     function setLocalizedDiagnosticMessages(messages) {
14671         ts.localizedDiagnosticMessages = messages;
14672     }
14673     ts.setLocalizedDiagnosticMessages = setLocalizedDiagnosticMessages;
14674     function getLocaleSpecificMessage(message) {
14675         return ts.localizedDiagnosticMessages && ts.localizedDiagnosticMessages[message.key] || message.message;
14676     }
14677     ts.getLocaleSpecificMessage = getLocaleSpecificMessage;
14678     function createDetachedDiagnostic(fileName, start, length, message) {
14679         assertDiagnosticLocation(undefined, start, length);
14680         var text = getLocaleSpecificMessage(message);
14681         if (arguments.length > 4) {
14682             text = formatStringFromArgs(text, arguments, 4);
14683         }
14684         return {
14685             file: undefined,
14686             start: start,
14687             length: length,
14688             messageText: text,
14689             category: message.category,
14690             code: message.code,
14691             reportsUnnecessary: message.reportsUnnecessary,
14692             fileName: fileName,
14693         };
14694     }
14695     ts.createDetachedDiagnostic = createDetachedDiagnostic;
14696     function isDiagnosticWithDetachedLocation(diagnostic) {
14697         return diagnostic.file === undefined
14698             && diagnostic.start !== undefined
14699             && diagnostic.length !== undefined
14700             && typeof diagnostic.fileName === "string";
14701     }
14702     function attachFileToDiagnostic(diagnostic, file) {
14703         var fileName = file.fileName || "";
14704         var length = file.text.length;
14705         ts.Debug.assertEqual(diagnostic.fileName, fileName);
14706         ts.Debug.assertLessThanOrEqual(diagnostic.start, length);
14707         ts.Debug.assertLessThanOrEqual(diagnostic.start + diagnostic.length, length);
14708         var diagnosticWithLocation = {
14709             file: file,
14710             start: diagnostic.start,
14711             length: diagnostic.length,
14712             messageText: diagnostic.messageText,
14713             category: diagnostic.category,
14714             code: diagnostic.code,
14715             reportsUnnecessary: diagnostic.reportsUnnecessary
14716         };
14717         if (diagnostic.relatedInformation) {
14718             diagnosticWithLocation.relatedInformation = [];
14719             for (var _i = 0, _a = diagnostic.relatedInformation; _i < _a.length; _i++) {
14720                 var related = _a[_i];
14721                 if (isDiagnosticWithDetachedLocation(related) && related.fileName === fileName) {
14722                     ts.Debug.assertLessThanOrEqual(related.start, length);
14723                     ts.Debug.assertLessThanOrEqual(related.start + related.length, length);
14724                     diagnosticWithLocation.relatedInformation.push(attachFileToDiagnostic(related, file));
14725                 }
14726                 else {
14727                     diagnosticWithLocation.relatedInformation.push(related);
14728                 }
14729             }
14730         }
14731         return diagnosticWithLocation;
14732     }
14733     function attachFileToDiagnostics(diagnostics, file) {
14734         var diagnosticsWithLocation = [];
14735         for (var _i = 0, diagnostics_1 = diagnostics; _i < diagnostics_1.length; _i++) {
14736             var diagnostic = diagnostics_1[_i];
14737             diagnosticsWithLocation.push(attachFileToDiagnostic(diagnostic, file));
14738         }
14739         return diagnosticsWithLocation;
14740     }
14741     ts.attachFileToDiagnostics = attachFileToDiagnostics;
14742     function createFileDiagnostic(file, start, length, message) {
14743         assertDiagnosticLocation(file, start, length);
14744         var text = getLocaleSpecificMessage(message);
14745         if (arguments.length > 4) {
14746             text = formatStringFromArgs(text, arguments, 4);
14747         }
14748         return {
14749             file: file,
14750             start: start,
14751             length: length,
14752             messageText: text,
14753             category: message.category,
14754             code: message.code,
14755             reportsUnnecessary: message.reportsUnnecessary,
14756             reportsDeprecated: message.reportsDeprecated
14757         };
14758     }
14759     ts.createFileDiagnostic = createFileDiagnostic;
14760     function formatMessage(_dummy, message) {
14761         var text = getLocaleSpecificMessage(message);
14762         if (arguments.length > 2) {
14763             text = formatStringFromArgs(text, arguments, 2);
14764         }
14765         return text;
14766     }
14767     ts.formatMessage = formatMessage;
14768     function createCompilerDiagnostic(message) {
14769         var text = getLocaleSpecificMessage(message);
14770         if (arguments.length > 1) {
14771             text = formatStringFromArgs(text, arguments, 1);
14772         }
14773         return {
14774             file: undefined,
14775             start: undefined,
14776             length: undefined,
14777             messageText: text,
14778             category: message.category,
14779             code: message.code,
14780             reportsUnnecessary: message.reportsUnnecessary,
14781             reportsDeprecated: message.reportsDeprecated
14782         };
14783     }
14784     ts.createCompilerDiagnostic = createCompilerDiagnostic;
14785     function createCompilerDiagnosticFromMessageChain(chain, relatedInformation) {
14786         return {
14787             file: undefined,
14788             start: undefined,
14789             length: undefined,
14790             code: chain.code,
14791             category: chain.category,
14792             messageText: chain.next ? chain : chain.messageText,
14793             relatedInformation: relatedInformation
14794         };
14795     }
14796     ts.createCompilerDiagnosticFromMessageChain = createCompilerDiagnosticFromMessageChain;
14797     function chainDiagnosticMessages(details, message) {
14798         var text = getLocaleSpecificMessage(message);
14799         if (arguments.length > 2) {
14800             text = formatStringFromArgs(text, arguments, 2);
14801         }
14802         return {
14803             messageText: text,
14804             category: message.category,
14805             code: message.code,
14806             next: details === undefined || Array.isArray(details) ? details : [details]
14807         };
14808     }
14809     ts.chainDiagnosticMessages = chainDiagnosticMessages;
14810     function concatenateDiagnosticMessageChains(headChain, tailChain) {
14811         var lastChain = headChain;
14812         while (lastChain.next) {
14813             lastChain = lastChain.next[0];
14814         }
14815         lastChain.next = [tailChain];
14816     }
14817     ts.concatenateDiagnosticMessageChains = concatenateDiagnosticMessageChains;
14818     function getDiagnosticFilePath(diagnostic) {
14819         return diagnostic.file ? diagnostic.file.path : undefined;
14820     }
14821     function compareDiagnostics(d1, d2) {
14822         return compareDiagnosticsSkipRelatedInformation(d1, d2) ||
14823             compareRelatedInformation(d1, d2) ||
14824             0;
14825     }
14826     ts.compareDiagnostics = compareDiagnostics;
14827     function compareDiagnosticsSkipRelatedInformation(d1, d2) {
14828         return ts.compareStringsCaseSensitive(getDiagnosticFilePath(d1), getDiagnosticFilePath(d2)) ||
14829             ts.compareValues(d1.start, d2.start) ||
14830             ts.compareValues(d1.length, d2.length) ||
14831             ts.compareValues(d1.code, d2.code) ||
14832             compareMessageText(d1.messageText, d2.messageText) ||
14833             0;
14834     }
14835     ts.compareDiagnosticsSkipRelatedInformation = compareDiagnosticsSkipRelatedInformation;
14836     function compareRelatedInformation(d1, d2) {
14837         if (!d1.relatedInformation && !d2.relatedInformation) {
14838             return 0;
14839         }
14840         if (d1.relatedInformation && d2.relatedInformation) {
14841             return ts.compareValues(d1.relatedInformation.length, d2.relatedInformation.length) || ts.forEach(d1.relatedInformation, function (d1i, index) {
14842                 var d2i = d2.relatedInformation[index];
14843                 return compareDiagnostics(d1i, d2i);
14844             }) || 0;
14845         }
14846         return d1.relatedInformation ? -1 : 1;
14847     }
14848     function compareMessageText(t1, t2) {
14849         if (typeof t1 === "string" && typeof t2 === "string") {
14850             return ts.compareStringsCaseSensitive(t1, t2);
14851         }
14852         else if (typeof t1 === "string") {
14853             return -1;
14854         }
14855         else if (typeof t2 === "string") {
14856             return 1;
14857         }
14858         var res = ts.compareStringsCaseSensitive(t1.messageText, t2.messageText);
14859         if (res) {
14860             return res;
14861         }
14862         if (!t1.next && !t2.next) {
14863             return 0;
14864         }
14865         if (!t1.next) {
14866             return -1;
14867         }
14868         if (!t2.next) {
14869             return 1;
14870         }
14871         var len = Math.min(t1.next.length, t2.next.length);
14872         for (var i = 0; i < len; i++) {
14873             res = compareMessageText(t1.next[i], t2.next[i]);
14874             if (res) {
14875                 return res;
14876             }
14877         }
14878         if (t1.next.length < t2.next.length) {
14879             return -1;
14880         }
14881         else if (t1.next.length > t2.next.length) {
14882             return 1;
14883         }
14884         return 0;
14885     }
14886     function getLanguageVariant(scriptKind) {
14887         return scriptKind === 4 || scriptKind === 2 || scriptKind === 1 || scriptKind === 6 ? 1 : 0;
14888     }
14889     ts.getLanguageVariant = getLanguageVariant;
14890     function getEmitScriptTarget(compilerOptions) {
14891         return compilerOptions.target || 0;
14892     }
14893     ts.getEmitScriptTarget = getEmitScriptTarget;
14894     function getEmitModuleKind(compilerOptions) {
14895         return typeof compilerOptions.module === "number" ?
14896             compilerOptions.module :
14897             getEmitScriptTarget(compilerOptions) >= 2 ? ts.ModuleKind.ES2015 : ts.ModuleKind.CommonJS;
14898     }
14899     ts.getEmitModuleKind = getEmitModuleKind;
14900     function getEmitModuleResolutionKind(compilerOptions) {
14901         var moduleResolution = compilerOptions.moduleResolution;
14902         if (moduleResolution === undefined) {
14903             moduleResolution = getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic;
14904         }
14905         return moduleResolution;
14906     }
14907     ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
14908     function hasJsonModuleEmitEnabled(options) {
14909         switch (getEmitModuleKind(options)) {
14910             case ts.ModuleKind.CommonJS:
14911             case ts.ModuleKind.AMD:
14912             case ts.ModuleKind.ES2015:
14913             case ts.ModuleKind.ES2020:
14914             case ts.ModuleKind.ESNext:
14915                 return true;
14916             default:
14917                 return false;
14918         }
14919     }
14920     ts.hasJsonModuleEmitEnabled = hasJsonModuleEmitEnabled;
14921     function unreachableCodeIsError(options) {
14922         return options.allowUnreachableCode === false;
14923     }
14924     ts.unreachableCodeIsError = unreachableCodeIsError;
14925     function unusedLabelIsError(options) {
14926         return options.allowUnusedLabels === false;
14927     }
14928     ts.unusedLabelIsError = unusedLabelIsError;
14929     function getAreDeclarationMapsEnabled(options) {
14930         return !!(getEmitDeclarations(options) && options.declarationMap);
14931     }
14932     ts.getAreDeclarationMapsEnabled = getAreDeclarationMapsEnabled;
14933     function getAllowSyntheticDefaultImports(compilerOptions) {
14934         var moduleKind = getEmitModuleKind(compilerOptions);
14935         return compilerOptions.allowSyntheticDefaultImports !== undefined
14936             ? compilerOptions.allowSyntheticDefaultImports
14937             : compilerOptions.esModuleInterop ||
14938                 moduleKind === ts.ModuleKind.System;
14939     }
14940     ts.getAllowSyntheticDefaultImports = getAllowSyntheticDefaultImports;
14941     function getEmitDeclarations(compilerOptions) {
14942         return !!(compilerOptions.declaration || compilerOptions.composite);
14943     }
14944     ts.getEmitDeclarations = getEmitDeclarations;
14945     function shouldPreserveConstEnums(compilerOptions) {
14946         return !!(compilerOptions.preserveConstEnums || compilerOptions.isolatedModules);
14947     }
14948     ts.shouldPreserveConstEnums = shouldPreserveConstEnums;
14949     function isIncrementalCompilation(options) {
14950         return !!(options.incremental || options.composite);
14951     }
14952     ts.isIncrementalCompilation = isIncrementalCompilation;
14953     function getStrictOptionValue(compilerOptions, flag) {
14954         return compilerOptions[flag] === undefined ? !!compilerOptions.strict : !!compilerOptions[flag];
14955     }
14956     ts.getStrictOptionValue = getStrictOptionValue;
14957     function getAllowJSCompilerOption(compilerOptions) {
14958         return compilerOptions.allowJs === undefined ? !!compilerOptions.checkJs : compilerOptions.allowJs;
14959     }
14960     ts.getAllowJSCompilerOption = getAllowJSCompilerOption;
14961     function compilerOptionsAffectSemanticDiagnostics(newOptions, oldOptions) {
14962         return oldOptions !== newOptions &&
14963             ts.semanticDiagnosticsOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); });
14964     }
14965     ts.compilerOptionsAffectSemanticDiagnostics = compilerOptionsAffectSemanticDiagnostics;
14966     function compilerOptionsAffectEmit(newOptions, oldOptions) {
14967         return oldOptions !== newOptions &&
14968             ts.affectsEmitOptionDeclarations.some(function (option) { return !isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)); });
14969     }
14970     ts.compilerOptionsAffectEmit = compilerOptionsAffectEmit;
14971     function getCompilerOptionValue(options, option) {
14972         return option.strictFlag ? getStrictOptionValue(options, option.name) : options[option.name];
14973     }
14974     ts.getCompilerOptionValue = getCompilerOptionValue;
14975     function getJSXTransformEnabled(options) {
14976         var jsx = options.jsx;
14977         return jsx === 2 || jsx === 4 || jsx === 5;
14978     }
14979     ts.getJSXTransformEnabled = getJSXTransformEnabled;
14980     function getJSXImplicitImportBase(compilerOptions, file) {
14981         var jsxImportSourcePragmas = file === null || file === void 0 ? void 0 : file.pragmas.get("jsximportsource");
14982         var jsxImportSourcePragma = ts.isArray(jsxImportSourcePragmas) ? jsxImportSourcePragmas[0] : jsxImportSourcePragmas;
14983         return compilerOptions.jsx === 4 ||
14984             compilerOptions.jsx === 5 ||
14985             compilerOptions.jsxImportSource ||
14986             jsxImportSourcePragma ?
14987             (jsxImportSourcePragma === null || jsxImportSourcePragma === void 0 ? void 0 : jsxImportSourcePragma.arguments.factory) || compilerOptions.jsxImportSource || "react" :
14988             undefined;
14989     }
14990     ts.getJSXImplicitImportBase = getJSXImplicitImportBase;
14991     function getJSXRuntimeImport(base, options) {
14992         return base ? base + "/" + (options.jsx === 5 ? "jsx-dev-runtime" : "jsx-runtime") : undefined;
14993     }
14994     ts.getJSXRuntimeImport = getJSXRuntimeImport;
14995     function hasZeroOrOneAsteriskCharacter(str) {
14996         var seenAsterisk = false;
14997         for (var i = 0; i < str.length; i++) {
14998             if (str.charCodeAt(i) === 42) {
14999                 if (!seenAsterisk) {
15000                     seenAsterisk = true;
15001                 }
15002                 else {
15003                     return false;
15004                 }
15005             }
15006         }
15007         return true;
15008     }
15009     ts.hasZeroOrOneAsteriskCharacter = hasZeroOrOneAsteriskCharacter;
15010     function createSymlinkCache(cwd, getCanonicalFileName) {
15011         var symlinkedDirectories;
15012         var symlinkedDirectoriesByRealpath;
15013         var symlinkedFiles;
15014         return {
15015             getSymlinkedFiles: function () { return symlinkedFiles; },
15016             getSymlinkedDirectories: function () { return symlinkedDirectories; },
15017             getSymlinkedDirectoriesByRealpath: function () { return symlinkedDirectoriesByRealpath; },
15018             setSymlinkedFile: function (path, real) { return (symlinkedFiles || (symlinkedFiles = new ts.Map())).set(path, real); },
15019             setSymlinkedDirectory: function (symlink, real) {
15020                 var symlinkPath = ts.toPath(symlink, cwd, getCanonicalFileName);
15021                 if (!containsIgnoredPath(symlinkPath)) {
15022                     symlinkPath = ts.ensureTrailingDirectorySeparator(symlinkPath);
15023                     if (real !== false && !(symlinkedDirectories === null || symlinkedDirectories === void 0 ? void 0 : symlinkedDirectories.has(symlinkPath))) {
15024                         (symlinkedDirectoriesByRealpath || (symlinkedDirectoriesByRealpath = ts.createMultiMap())).add(ts.ensureTrailingDirectorySeparator(real.realPath), symlink);
15025                     }
15026                     (symlinkedDirectories || (symlinkedDirectories = new ts.Map())).set(symlinkPath, real);
15027                 }
15028             }
15029         };
15030     }
15031     ts.createSymlinkCache = createSymlinkCache;
15032     function discoverProbableSymlinks(files, getCanonicalFileName, cwd) {
15033         var cache = createSymlinkCache(cwd, getCanonicalFileName);
15034         var symlinks = ts.flatten(ts.mapDefined(files, function (sf) {
15035             return sf.resolvedModules && ts.compact(ts.arrayFrom(ts.mapIterator(sf.resolvedModules.values(), function (res) {
15036                 return res && res.originalPath && res.resolvedFileName !== res.originalPath ? [res.resolvedFileName, res.originalPath] : undefined;
15037             })));
15038         }));
15039         for (var _i = 0, symlinks_1 = symlinks; _i < symlinks_1.length; _i++) {
15040             var _a = symlinks_1[_i], resolvedPath = _a[0], originalPath = _a[1];
15041             var _b = guessDirectorySymlink(resolvedPath, originalPath, cwd, getCanonicalFileName) || ts.emptyArray, commonResolved = _b[0], commonOriginal = _b[1];
15042             if (commonResolved && commonOriginal) {
15043                 cache.setSymlinkedDirectory(commonOriginal, { real: commonResolved, realPath: ts.toPath(commonResolved, cwd, getCanonicalFileName) });
15044             }
15045         }
15046         return cache;
15047     }
15048     ts.discoverProbableSymlinks = discoverProbableSymlinks;
15049     function guessDirectorySymlink(a, b, cwd, getCanonicalFileName) {
15050         var aParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(a, cwd));
15051         var bParts = ts.getPathComponents(ts.getNormalizedAbsolutePath(b, cwd));
15052         var isDirectory = false;
15053         while (!isNodeModulesOrScopedPackageDirectory(aParts[aParts.length - 2], getCanonicalFileName) &&
15054             !isNodeModulesOrScopedPackageDirectory(bParts[bParts.length - 2], getCanonicalFileName) &&
15055             getCanonicalFileName(aParts[aParts.length - 1]) === getCanonicalFileName(bParts[bParts.length - 1])) {
15056             aParts.pop();
15057             bParts.pop();
15058             isDirectory = true;
15059         }
15060         return isDirectory ? [ts.getPathFromPathComponents(aParts), ts.getPathFromPathComponents(bParts)] : undefined;
15061     }
15062     function isNodeModulesOrScopedPackageDirectory(s, getCanonicalFileName) {
15063         return getCanonicalFileName(s) === "node_modules" || ts.startsWith(s, "@");
15064     }
15065     function stripLeadingDirectorySeparator(s) {
15066         return ts.isAnyDirectorySeparator(s.charCodeAt(0)) ? s.slice(1) : undefined;
15067     }
15068     function tryRemoveDirectoryPrefix(path, dirPath, getCanonicalFileName) {
15069         var withoutPrefix = ts.tryRemovePrefix(path, dirPath, getCanonicalFileName);
15070         return withoutPrefix === undefined ? undefined : stripLeadingDirectorySeparator(withoutPrefix);
15071     }
15072     ts.tryRemoveDirectoryPrefix = tryRemoveDirectoryPrefix;
15073     var reservedCharacterPattern = /[^\w\s\/]/g;
15074     function regExpEscape(text) {
15075         return text.replace(reservedCharacterPattern, escapeRegExpCharacter);
15076     }
15077     ts.regExpEscape = regExpEscape;
15078     function escapeRegExpCharacter(match) {
15079         return "\\" + match;
15080     }
15081     var wildcardCharCodes = [42, 63];
15082     ts.commonPackageFolders = ["node_modules", "bower_components", "jspm_packages"];
15083     var implicitExcludePathRegexPattern = "(?!(" + ts.commonPackageFolders.join("|") + ")(/|$))";
15084     var filesMatcher = {
15085         singleAsteriskRegexFragment: "([^./]|(\\.(?!min\\.js$))?)*",
15086         doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?",
15087         replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, filesMatcher.singleAsteriskRegexFragment); }
15088     };
15089     var directoriesMatcher = {
15090         singleAsteriskRegexFragment: "[^/]*",
15091         doubleAsteriskRegexFragment: "(/" + implicitExcludePathRegexPattern + "[^/.][^/]*)*?",
15092         replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, directoriesMatcher.singleAsteriskRegexFragment); }
15093     };
15094     var excludeMatcher = {
15095         singleAsteriskRegexFragment: "[^/]*",
15096         doubleAsteriskRegexFragment: "(/.+?)?",
15097         replaceWildcardCharacter: function (match) { return replaceWildcardCharacter(match, excludeMatcher.singleAsteriskRegexFragment); }
15098     };
15099     var wildcardMatchers = {
15100         files: filesMatcher,
15101         directories: directoriesMatcher,
15102         exclude: excludeMatcher
15103     };
15104     function getRegularExpressionForWildcard(specs, basePath, usage) {
15105         var patterns = getRegularExpressionsForWildcards(specs, basePath, usage);
15106         if (!patterns || !patterns.length) {
15107             return undefined;
15108         }
15109         var pattern = patterns.map(function (pattern) { return "(" + pattern + ")"; }).join("|");
15110         var terminator = usage === "exclude" ? "($|/)" : "$";
15111         return "^(" + pattern + ")" + terminator;
15112     }
15113     ts.getRegularExpressionForWildcard = getRegularExpressionForWildcard;
15114     function getRegularExpressionsForWildcards(specs, basePath, usage) {
15115         if (specs === undefined || specs.length === 0) {
15116             return undefined;
15117         }
15118         return ts.flatMap(specs, function (spec) {
15119             return spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]);
15120         });
15121     }
15122     ts.getRegularExpressionsForWildcards = getRegularExpressionsForWildcards;
15123     function isImplicitGlob(lastPathComponent) {
15124         return !/[.*?]/.test(lastPathComponent);
15125     }
15126     ts.isImplicitGlob = isImplicitGlob;
15127     function getPatternFromSpec(spec, basePath, usage) {
15128         var pattern = spec && getSubPatternFromSpec(spec, basePath, usage, wildcardMatchers[usage]);
15129         return pattern && "^(" + pattern + ")" + (usage === "exclude" ? "($|/)" : "$");
15130     }
15131     ts.getPatternFromSpec = getPatternFromSpec;
15132     function getSubPatternFromSpec(spec, basePath, usage, _a) {
15133         var singleAsteriskRegexFragment = _a.singleAsteriskRegexFragment, doubleAsteriskRegexFragment = _a.doubleAsteriskRegexFragment, replaceWildcardCharacter = _a.replaceWildcardCharacter;
15134         var subpattern = "";
15135         var hasWrittenComponent = false;
15136         var components = ts.getNormalizedPathComponents(spec, basePath);
15137         var lastComponent = ts.last(components);
15138         if (usage !== "exclude" && lastComponent === "**") {
15139             return undefined;
15140         }
15141         components[0] = ts.removeTrailingDirectorySeparator(components[0]);
15142         if (isImplicitGlob(lastComponent)) {
15143             components.push("**", "*");
15144         }
15145         var optionalCount = 0;
15146         for (var _i = 0, components_1 = components; _i < components_1.length; _i++) {
15147             var component = components_1[_i];
15148             if (component === "**") {
15149                 subpattern += doubleAsteriskRegexFragment;
15150             }
15151             else {
15152                 if (usage === "directories") {
15153                     subpattern += "(";
15154                     optionalCount++;
15155                 }
15156                 if (hasWrittenComponent) {
15157                     subpattern += ts.directorySeparator;
15158                 }
15159                 if (usage !== "exclude") {
15160                     var componentPattern = "";
15161                     if (component.charCodeAt(0) === 42) {
15162                         componentPattern += "([^./]" + singleAsteriskRegexFragment + ")?";
15163                         component = component.substr(1);
15164                     }
15165                     else if (component.charCodeAt(0) === 63) {
15166                         componentPattern += "[^./]";
15167                         component = component.substr(1);
15168                     }
15169                     componentPattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
15170                     if (componentPattern !== component) {
15171                         subpattern += implicitExcludePathRegexPattern;
15172                     }
15173                     subpattern += componentPattern;
15174                 }
15175                 else {
15176                     subpattern += component.replace(reservedCharacterPattern, replaceWildcardCharacter);
15177                 }
15178             }
15179             hasWrittenComponent = true;
15180         }
15181         while (optionalCount > 0) {
15182             subpattern += ")?";
15183             optionalCount--;
15184         }
15185         return subpattern;
15186     }
15187     function replaceWildcardCharacter(match, singleAsteriskRegexFragment) {
15188         return match === "*" ? singleAsteriskRegexFragment : match === "?" ? "[^/]" : "\\" + match;
15189     }
15190     function getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory) {
15191         path = ts.normalizePath(path);
15192         currentDirectory = ts.normalizePath(currentDirectory);
15193         var absolutePath = ts.combinePaths(currentDirectory, path);
15194         return {
15195             includeFilePatterns: ts.map(getRegularExpressionsForWildcards(includes, absolutePath, "files"), function (pattern) { return "^" + pattern + "$"; }),
15196             includeFilePattern: getRegularExpressionForWildcard(includes, absolutePath, "files"),
15197             includeDirectoryPattern: getRegularExpressionForWildcard(includes, absolutePath, "directories"),
15198             excludePattern: getRegularExpressionForWildcard(excludes, absolutePath, "exclude"),
15199             basePaths: getBasePaths(path, includes, useCaseSensitiveFileNames)
15200         };
15201     }
15202     ts.getFileMatcherPatterns = getFileMatcherPatterns;
15203     function getRegexFromPattern(pattern, useCaseSensitiveFileNames) {
15204         return new RegExp(pattern, useCaseSensitiveFileNames ? "" : "i");
15205     }
15206     ts.getRegexFromPattern = getRegexFromPattern;
15207     function matchFiles(path, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath) {
15208         path = ts.normalizePath(path);
15209         currentDirectory = ts.normalizePath(currentDirectory);
15210         var patterns = getFileMatcherPatterns(path, excludes, includes, useCaseSensitiveFileNames, currentDirectory);
15211         var includeFileRegexes = patterns.includeFilePatterns && patterns.includeFilePatterns.map(function (pattern) { return getRegexFromPattern(pattern, useCaseSensitiveFileNames); });
15212         var includeDirectoryRegex = patterns.includeDirectoryPattern && getRegexFromPattern(patterns.includeDirectoryPattern, useCaseSensitiveFileNames);
15213         var excludeRegex = patterns.excludePattern && getRegexFromPattern(patterns.excludePattern, useCaseSensitiveFileNames);
15214         var results = includeFileRegexes ? includeFileRegexes.map(function () { return []; }) : [[]];
15215         var visited = new ts.Map();
15216         var toCanonical = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
15217         for (var _i = 0, _a = patterns.basePaths; _i < _a.length; _i++) {
15218             var basePath = _a[_i];
15219             visitDirectory(basePath, ts.combinePaths(currentDirectory, basePath), depth);
15220         }
15221         return ts.flatten(results);
15222         function visitDirectory(path, absolutePath, depth) {
15223             var canonicalPath = toCanonical(realpath(absolutePath));
15224             if (visited.has(canonicalPath))
15225                 return;
15226             visited.set(canonicalPath, true);
15227             var _a = getFileSystemEntries(path), files = _a.files, directories = _a.directories;
15228             var _loop_1 = function (current) {
15229                 var name = ts.combinePaths(path, current);
15230                 var absoluteName = ts.combinePaths(absolutePath, current);
15231                 if (extensions && !ts.fileExtensionIsOneOf(name, extensions))
15232                     return "continue";
15233                 if (excludeRegex && excludeRegex.test(absoluteName))
15234                     return "continue";
15235                 if (!includeFileRegexes) {
15236                     results[0].push(name);
15237                 }
15238                 else {
15239                     var includeIndex = ts.findIndex(includeFileRegexes, function (re) { return re.test(absoluteName); });
15240                     if (includeIndex !== -1) {
15241                         results[includeIndex].push(name);
15242                     }
15243                 }
15244             };
15245             for (var _i = 0, _b = ts.sort(files, ts.compareStringsCaseSensitive); _i < _b.length; _i++) {
15246                 var current = _b[_i];
15247                 _loop_1(current);
15248             }
15249             if (depth !== undefined) {
15250                 depth--;
15251                 if (depth === 0) {
15252                     return;
15253                 }
15254             }
15255             for (var _c = 0, _d = ts.sort(directories, ts.compareStringsCaseSensitive); _c < _d.length; _c++) {
15256                 var current = _d[_c];
15257                 var name = ts.combinePaths(path, current);
15258                 var absoluteName = ts.combinePaths(absolutePath, current);
15259                 if ((!includeDirectoryRegex || includeDirectoryRegex.test(absoluteName)) &&
15260                     (!excludeRegex || !excludeRegex.test(absoluteName))) {
15261                     visitDirectory(name, absoluteName, depth);
15262                 }
15263             }
15264         }
15265     }
15266     ts.matchFiles = matchFiles;
15267     function getBasePaths(path, includes, useCaseSensitiveFileNames) {
15268         var basePaths = [path];
15269         if (includes) {
15270             var includeBasePaths = [];
15271             for (var _i = 0, includes_1 = includes; _i < includes_1.length; _i++) {
15272                 var include = includes_1[_i];
15273                 var absolute = ts.isRootedDiskPath(include) ? include : ts.normalizePath(ts.combinePaths(path, include));
15274                 includeBasePaths.push(getIncludeBasePath(absolute));
15275             }
15276             includeBasePaths.sort(ts.getStringComparer(!useCaseSensitiveFileNames));
15277             var _loop_2 = function (includeBasePath) {
15278                 if (ts.every(basePaths, function (basePath) { return !ts.containsPath(basePath, includeBasePath, path, !useCaseSensitiveFileNames); })) {
15279                     basePaths.push(includeBasePath);
15280                 }
15281             };
15282             for (var _a = 0, includeBasePaths_1 = includeBasePaths; _a < includeBasePaths_1.length; _a++) {
15283                 var includeBasePath = includeBasePaths_1[_a];
15284                 _loop_2(includeBasePath);
15285             }
15286         }
15287         return basePaths;
15288     }
15289     function getIncludeBasePath(absolute) {
15290         var wildcardOffset = ts.indexOfAnyCharCode(absolute, wildcardCharCodes);
15291         if (wildcardOffset < 0) {
15292             return !ts.hasExtension(absolute)
15293                 ? absolute
15294                 : ts.removeTrailingDirectorySeparator(ts.getDirectoryPath(absolute));
15295         }
15296         return absolute.substring(0, absolute.lastIndexOf(ts.directorySeparator, wildcardOffset));
15297     }
15298     function ensureScriptKind(fileName, scriptKind) {
15299         return scriptKind || getScriptKindFromFileName(fileName) || 3;
15300     }
15301     ts.ensureScriptKind = ensureScriptKind;
15302     function getScriptKindFromFileName(fileName) {
15303         var ext = fileName.substr(fileName.lastIndexOf("."));
15304         switch (ext.toLowerCase()) {
15305             case ".js":
15306                 return 1;
15307             case ".jsx":
15308                 return 2;
15309             case ".ts":
15310                 return 3;
15311             case ".tsx":
15312                 return 4;
15313             case ".json":
15314                 return 6;
15315             default:
15316                 return 0;
15317         }
15318     }
15319     ts.getScriptKindFromFileName = getScriptKindFromFileName;
15320     ts.supportedTSExtensions = [".ts", ".tsx", ".d.ts"];
15321     ts.supportedTSExtensionsWithJson = [".ts", ".tsx", ".d.ts", ".json"];
15322     ts.supportedTSExtensionsForExtractExtension = [".d.ts", ".ts", ".tsx"];
15323     ts.supportedJSExtensions = [".js", ".jsx"];
15324     ts.supportedJSAndJsonExtensions = [".js", ".jsx", ".json"];
15325     var allSupportedExtensions = __spreadArray(__spreadArray([], ts.supportedTSExtensions), ts.supportedJSExtensions);
15326     var allSupportedExtensionsWithJson = __spreadArray(__spreadArray(__spreadArray([], ts.supportedTSExtensions), ts.supportedJSExtensions), [".json"]);
15327     function getSupportedExtensions(options, extraFileExtensions) {
15328         var needJsExtensions = options && getAllowJSCompilerOption(options);
15329         if (!extraFileExtensions || extraFileExtensions.length === 0) {
15330             return needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions;
15331         }
15332         var extensions = __spreadArray(__spreadArray([], needJsExtensions ? allSupportedExtensions : ts.supportedTSExtensions), ts.mapDefined(extraFileExtensions, function (x) { return x.scriptKind === 7 || needJsExtensions && isJSLike(x.scriptKind) ? x.extension : undefined; }));
15333         return ts.deduplicate(extensions, ts.equateStringsCaseSensitive, ts.compareStringsCaseSensitive);
15334     }
15335     ts.getSupportedExtensions = getSupportedExtensions;
15336     function getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions) {
15337         if (!options || !options.resolveJsonModule) {
15338             return supportedExtensions;
15339         }
15340         if (supportedExtensions === allSupportedExtensions) {
15341             return allSupportedExtensionsWithJson;
15342         }
15343         if (supportedExtensions === ts.supportedTSExtensions) {
15344             return ts.supportedTSExtensionsWithJson;
15345         }
15346         return __spreadArray(__spreadArray([], supportedExtensions), [".json"]);
15347     }
15348     ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule = getSuppoertedExtensionsWithJsonIfResolveJsonModule;
15349     function isJSLike(scriptKind) {
15350         return scriptKind === 1 || scriptKind === 2;
15351     }
15352     function hasJSFileExtension(fileName) {
15353         return ts.some(ts.supportedJSExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); });
15354     }
15355     ts.hasJSFileExtension = hasJSFileExtension;
15356     function hasTSFileExtension(fileName) {
15357         return ts.some(ts.supportedTSExtensions, function (extension) { return ts.fileExtensionIs(fileName, extension); });
15358     }
15359     ts.hasTSFileExtension = hasTSFileExtension;
15360     function isSupportedSourceFileName(fileName, compilerOptions, extraFileExtensions) {
15361         if (!fileName) {
15362             return false;
15363         }
15364         var supportedExtensions = getSupportedExtensions(compilerOptions, extraFileExtensions);
15365         for (var _i = 0, _a = getSuppoertedExtensionsWithJsonIfResolveJsonModule(compilerOptions, supportedExtensions); _i < _a.length; _i++) {
15366             var extension = _a[_i];
15367             if (ts.fileExtensionIs(fileName, extension)) {
15368                 return true;
15369             }
15370         }
15371         return false;
15372     }
15373     ts.isSupportedSourceFileName = isSupportedSourceFileName;
15374     function numberOfDirectorySeparators(str) {
15375         var match = str.match(/\//g);
15376         return match ? match.length : 0;
15377     }
15378     function compareNumberOfDirectorySeparators(path1, path2) {
15379         return ts.compareValues(numberOfDirectorySeparators(path1), numberOfDirectorySeparators(path2));
15380     }
15381     ts.compareNumberOfDirectorySeparators = compareNumberOfDirectorySeparators;
15382     function getExtensionPriority(path, supportedExtensions) {
15383         for (var i = supportedExtensions.length - 1; i >= 0; i--) {
15384             if (ts.fileExtensionIs(path, supportedExtensions[i])) {
15385                 return adjustExtensionPriority(i, supportedExtensions);
15386             }
15387         }
15388         return 0;
15389     }
15390     ts.getExtensionPriority = getExtensionPriority;
15391     function adjustExtensionPriority(extensionPriority, supportedExtensions) {
15392         if (extensionPriority < 2) {
15393             return 0;
15394         }
15395         else if (extensionPriority < supportedExtensions.length) {
15396             return 2;
15397         }
15398         else {
15399             return supportedExtensions.length;
15400         }
15401     }
15402     ts.adjustExtensionPriority = adjustExtensionPriority;
15403     function getNextLowestExtensionPriority(extensionPriority, supportedExtensions) {
15404         if (extensionPriority < 2) {
15405             return 2;
15406         }
15407         else {
15408             return supportedExtensions.length;
15409         }
15410     }
15411     ts.getNextLowestExtensionPriority = getNextLowestExtensionPriority;
15412     var extensionsToRemove = [".d.ts", ".ts", ".js", ".tsx", ".jsx", ".json"];
15413     function removeFileExtension(path) {
15414         for (var _i = 0, extensionsToRemove_1 = extensionsToRemove; _i < extensionsToRemove_1.length; _i++) {
15415             var ext = extensionsToRemove_1[_i];
15416             var extensionless = tryRemoveExtension(path, ext);
15417             if (extensionless !== undefined) {
15418                 return extensionless;
15419             }
15420         }
15421         return path;
15422     }
15423     ts.removeFileExtension = removeFileExtension;
15424     function tryRemoveExtension(path, extension) {
15425         return ts.fileExtensionIs(path, extension) ? removeExtension(path, extension) : undefined;
15426     }
15427     ts.tryRemoveExtension = tryRemoveExtension;
15428     function removeExtension(path, extension) {
15429         return path.substring(0, path.length - extension.length);
15430     }
15431     ts.removeExtension = removeExtension;
15432     function changeExtension(path, newExtension) {
15433         return ts.changeAnyExtension(path, newExtension, extensionsToRemove, false);
15434     }
15435     ts.changeExtension = changeExtension;
15436     function tryParsePattern(pattern) {
15437         ts.Debug.assert(hasZeroOrOneAsteriskCharacter(pattern));
15438         var indexOfStar = pattern.indexOf("*");
15439         return indexOfStar === -1 ? undefined : {
15440             prefix: pattern.substr(0, indexOfStar),
15441             suffix: pattern.substr(indexOfStar + 1)
15442         };
15443     }
15444     ts.tryParsePattern = tryParsePattern;
15445     function positionIsSynthesized(pos) {
15446         return !(pos >= 0);
15447     }
15448     ts.positionIsSynthesized = positionIsSynthesized;
15449     function extensionIsTS(ext) {
15450         return ext === ".ts" || ext === ".tsx" || ext === ".d.ts";
15451     }
15452     ts.extensionIsTS = extensionIsTS;
15453     function resolutionExtensionIsTSOrJson(ext) {
15454         return extensionIsTS(ext) || ext === ".json";
15455     }
15456     ts.resolutionExtensionIsTSOrJson = resolutionExtensionIsTSOrJson;
15457     function extensionFromPath(path) {
15458         var ext = tryGetExtensionFromPath(path);
15459         return ext !== undefined ? ext : ts.Debug.fail("File " + path + " has unknown extension.");
15460     }
15461     ts.extensionFromPath = extensionFromPath;
15462     function isAnySupportedFileExtension(path) {
15463         return tryGetExtensionFromPath(path) !== undefined;
15464     }
15465     ts.isAnySupportedFileExtension = isAnySupportedFileExtension;
15466     function tryGetExtensionFromPath(path) {
15467         return ts.find(extensionsToRemove, function (e) { return ts.fileExtensionIs(path, e); });
15468     }
15469     ts.tryGetExtensionFromPath = tryGetExtensionFromPath;
15470     function isCheckJsEnabledForFile(sourceFile, compilerOptions) {
15471         return sourceFile.checkJsDirective ? sourceFile.checkJsDirective.enabled : compilerOptions.checkJs;
15472     }
15473     ts.isCheckJsEnabledForFile = isCheckJsEnabledForFile;
15474     ts.emptyFileSystemEntries = {
15475         files: ts.emptyArray,
15476         directories: ts.emptyArray
15477     };
15478     function matchPatternOrExact(patternStrings, candidate) {
15479         var patterns = [];
15480         for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) {
15481             var patternString = patternStrings_1[_i];
15482             if (!hasZeroOrOneAsteriskCharacter(patternString))
15483                 continue;
15484             var pattern = tryParsePattern(patternString);
15485             if (pattern) {
15486                 patterns.push(pattern);
15487             }
15488             else if (patternString === candidate) {
15489                 return patternString;
15490             }
15491         }
15492         return ts.findBestPatternMatch(patterns, function (_) { return _; }, candidate);
15493     }
15494     ts.matchPatternOrExact = matchPatternOrExact;
15495     function sliceAfter(arr, value) {
15496         var index = arr.indexOf(value);
15497         ts.Debug.assert(index !== -1);
15498         return arr.slice(index);
15499     }
15500     ts.sliceAfter = sliceAfter;
15501     function addRelatedInfo(diagnostic) {
15502         var _a;
15503         var relatedInformation = [];
15504         for (var _i = 1; _i < arguments.length; _i++) {
15505             relatedInformation[_i - 1] = arguments[_i];
15506         }
15507         if (!relatedInformation.length) {
15508             return diagnostic;
15509         }
15510         if (!diagnostic.relatedInformation) {
15511             diagnostic.relatedInformation = [];
15512         }
15513         ts.Debug.assert(diagnostic.relatedInformation !== ts.emptyArray, "Diagnostic had empty array singleton for related info, but is still being constructed!");
15514         (_a = diagnostic.relatedInformation).push.apply(_a, relatedInformation);
15515         return diagnostic;
15516     }
15517     ts.addRelatedInfo = addRelatedInfo;
15518     function minAndMax(arr, getValue) {
15519         ts.Debug.assert(arr.length !== 0);
15520         var min = getValue(arr[0]);
15521         var max = min;
15522         for (var i = 1; i < arr.length; i++) {
15523             var value = getValue(arr[i]);
15524             if (value < min) {
15525                 min = value;
15526             }
15527             else if (value > max) {
15528                 max = value;
15529             }
15530         }
15531         return { min: min, max: max };
15532     }
15533     ts.minAndMax = minAndMax;
15534     function rangeOfNode(node) {
15535         return { pos: getTokenPosOfNode(node), end: node.end };
15536     }
15537     ts.rangeOfNode = rangeOfNode;
15538     function rangeOfTypeParameters(sourceFile, typeParameters) {
15539         var pos = typeParameters.pos - 1;
15540         var end = ts.skipTrivia(sourceFile.text, typeParameters.end) + 1;
15541         return { pos: pos, end: end };
15542     }
15543     ts.rangeOfTypeParameters = rangeOfTypeParameters;
15544     function skipTypeChecking(sourceFile, options, host) {
15545         return (options.skipLibCheck && sourceFile.isDeclarationFile ||
15546             options.skipDefaultLibCheck && sourceFile.hasNoDefaultLib) ||
15547             host.isSourceOfProjectReferenceRedirect(sourceFile.fileName);
15548     }
15549     ts.skipTypeChecking = skipTypeChecking;
15550     function isJsonEqual(a, b) {
15551         return a === b || typeof a === "object" && a !== null && typeof b === "object" && b !== null && ts.equalOwnProperties(a, b, isJsonEqual);
15552     }
15553     ts.isJsonEqual = isJsonEqual;
15554     function parsePseudoBigInt(stringValue) {
15555         var log2Base;
15556         switch (stringValue.charCodeAt(1)) {
15557             case 98:
15558             case 66:
15559                 log2Base = 1;
15560                 break;
15561             case 111:
15562             case 79:
15563                 log2Base = 3;
15564                 break;
15565             case 120:
15566             case 88:
15567                 log2Base = 4;
15568                 break;
15569             default:
15570                 var nIndex = stringValue.length - 1;
15571                 var nonZeroStart = 0;
15572                 while (stringValue.charCodeAt(nonZeroStart) === 48) {
15573                     nonZeroStart++;
15574                 }
15575                 return stringValue.slice(nonZeroStart, nIndex) || "0";
15576         }
15577         var startIndex = 2, endIndex = stringValue.length - 1;
15578         var bitsNeeded = (endIndex - startIndex) * log2Base;
15579         var segments = new Uint16Array((bitsNeeded >>> 4) + (bitsNeeded & 15 ? 1 : 0));
15580         for (var i = endIndex - 1, bitOffset = 0; i >= startIndex; i--, bitOffset += log2Base) {
15581             var segment = bitOffset >>> 4;
15582             var digitChar = stringValue.charCodeAt(i);
15583             var digit = digitChar <= 57
15584                 ? digitChar - 48
15585                 : 10 + digitChar -
15586                     (digitChar <= 70 ? 65 : 97);
15587             var shiftedDigit = digit << (bitOffset & 15);
15588             segments[segment] |= shiftedDigit;
15589             var residual = shiftedDigit >>> 16;
15590             if (residual)
15591                 segments[segment + 1] |= residual;
15592         }
15593         var base10Value = "";
15594         var firstNonzeroSegment = segments.length - 1;
15595         var segmentsRemaining = true;
15596         while (segmentsRemaining) {
15597             var mod10 = 0;
15598             segmentsRemaining = false;
15599             for (var segment = firstNonzeroSegment; segment >= 0; segment--) {
15600                 var newSegment = mod10 << 16 | segments[segment];
15601                 var segmentValue = (newSegment / 10) | 0;
15602                 segments[segment] = segmentValue;
15603                 mod10 = newSegment - segmentValue * 10;
15604                 if (segmentValue && !segmentsRemaining) {
15605                     firstNonzeroSegment = segment;
15606                     segmentsRemaining = true;
15607                 }
15608             }
15609             base10Value = mod10 + base10Value;
15610         }
15611         return base10Value;
15612     }
15613     ts.parsePseudoBigInt = parsePseudoBigInt;
15614     function pseudoBigIntToString(_a) {
15615         var negative = _a.negative, base10Value = _a.base10Value;
15616         return (negative && base10Value !== "0" ? "-" : "") + base10Value;
15617     }
15618     ts.pseudoBigIntToString = pseudoBigIntToString;
15619     function isValidTypeOnlyAliasUseSite(useSite) {
15620         return !!(useSite.flags & 8388608)
15621             || isPartOfTypeQuery(useSite)
15622             || isIdentifierInNonEmittingHeritageClause(useSite)
15623             || isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(useSite)
15624             || !isExpressionNode(useSite);
15625     }
15626     ts.isValidTypeOnlyAliasUseSite = isValidTypeOnlyAliasUseSite;
15627     function typeOnlyDeclarationIsExport(typeOnlyDeclaration) {
15628         return typeOnlyDeclaration.kind === 270;
15629     }
15630     ts.typeOnlyDeclarationIsExport = typeOnlyDeclarationIsExport;
15631     function isPartOfPossiblyValidTypeOrAbstractComputedPropertyName(node) {
15632         while (node.kind === 78 || node.kind === 201) {
15633             node = node.parent;
15634         }
15635         if (node.kind !== 158) {
15636             return false;
15637         }
15638         if (hasSyntacticModifier(node.parent, 128)) {
15639             return true;
15640         }
15641         var containerKind = node.parent.parent.kind;
15642         return containerKind === 253 || containerKind === 177;
15643     }
15644     function isIdentifierInNonEmittingHeritageClause(node) {
15645         if (node.kind !== 78)
15646             return false;
15647         var heritageClause = ts.findAncestor(node.parent, function (parent) {
15648             switch (parent.kind) {
15649                 case 286:
15650                     return true;
15651                 case 201:
15652                 case 223:
15653                     return false;
15654                 default:
15655                     return "quit";
15656             }
15657         });
15658         return (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.token) === 116 || (heritageClause === null || heritageClause === void 0 ? void 0 : heritageClause.parent.kind) === 253;
15659     }
15660     function isIdentifierTypeReference(node) {
15661         return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName);
15662     }
15663     ts.isIdentifierTypeReference = isIdentifierTypeReference;
15664     function arrayIsHomogeneous(array, comparer) {
15665         if (comparer === void 0) { comparer = ts.equateValues; }
15666         if (array.length < 2)
15667             return true;
15668         var first = array[0];
15669         for (var i = 1, length_1 = array.length; i < length_1; i++) {
15670             var target = array[i];
15671             if (!comparer(first, target))
15672                 return false;
15673         }
15674         return true;
15675     }
15676     ts.arrayIsHomogeneous = arrayIsHomogeneous;
15677     function setTextRangePos(range, pos) {
15678         range.pos = pos;
15679         return range;
15680     }
15681     ts.setTextRangePos = setTextRangePos;
15682     function setTextRangeEnd(range, end) {
15683         range.end = end;
15684         return range;
15685     }
15686     ts.setTextRangeEnd = setTextRangeEnd;
15687     function setTextRangePosEnd(range, pos, end) {
15688         return setTextRangeEnd(setTextRangePos(range, pos), end);
15689     }
15690     ts.setTextRangePosEnd = setTextRangePosEnd;
15691     function setTextRangePosWidth(range, pos, width) {
15692         return setTextRangePosEnd(range, pos, pos + width);
15693     }
15694     ts.setTextRangePosWidth = setTextRangePosWidth;
15695     function setNodeFlags(node, newFlags) {
15696         if (node) {
15697             node.flags = newFlags;
15698         }
15699         return node;
15700     }
15701     ts.setNodeFlags = setNodeFlags;
15702     function setParent(child, parent) {
15703         if (child && parent) {
15704             child.parent = parent;
15705         }
15706         return child;
15707     }
15708     ts.setParent = setParent;
15709     function setEachParent(children, parent) {
15710         if (children) {
15711             for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
15712                 var child = children_1[_i];
15713                 setParent(child, parent);
15714             }
15715         }
15716         return children;
15717     }
15718     ts.setEachParent = setEachParent;
15719     function setParentRecursive(rootNode, incremental) {
15720         if (!rootNode)
15721             return rootNode;
15722         ts.forEachChildRecursively(rootNode, ts.isJSDocNode(rootNode) ? bindParentToChildIgnoringJSDoc : bindParentToChild);
15723         return rootNode;
15724         function bindParentToChildIgnoringJSDoc(child, parent) {
15725             if (incremental && child.parent === parent) {
15726                 return "skip";
15727             }
15728             setParent(child, parent);
15729         }
15730         function bindJSDoc(child) {
15731             if (ts.hasJSDocNodes(child)) {
15732                 for (var _i = 0, _a = child.jsDoc; _i < _a.length; _i++) {
15733                     var doc = _a[_i];
15734                     bindParentToChildIgnoringJSDoc(doc, child);
15735                     ts.forEachChildRecursively(doc, bindParentToChildIgnoringJSDoc);
15736                 }
15737             }
15738         }
15739         function bindParentToChild(child, parent) {
15740             return bindParentToChildIgnoringJSDoc(child, parent) || bindJSDoc(child);
15741         }
15742     }
15743     ts.setParentRecursive = setParentRecursive;
15744     function isPackedElement(node) {
15745         return !ts.isOmittedExpression(node);
15746     }
15747     function isPackedArrayLiteral(node) {
15748         return ts.isArrayLiteralExpression(node) && ts.every(node.elements, isPackedElement);
15749     }
15750     ts.isPackedArrayLiteral = isPackedArrayLiteral;
15751     function expressionResultIsUnused(node) {
15752         ts.Debug.assertIsDefined(node.parent);
15753         while (true) {
15754             var parent = node.parent;
15755             if (ts.isParenthesizedExpression(parent)) {
15756                 node = parent;
15757                 continue;
15758             }
15759             if (ts.isExpressionStatement(parent) ||
15760                 ts.isVoidExpression(parent) ||
15761                 ts.isForStatement(parent) && (parent.initializer === node || parent.incrementor === node)) {
15762                 return true;
15763             }
15764             if (ts.isCommaListExpression(parent)) {
15765                 if (node !== ts.last(parent.elements))
15766                     return true;
15767                 node = parent;
15768                 continue;
15769             }
15770             if (ts.isBinaryExpression(parent) && parent.operatorToken.kind === 27) {
15771                 if (node === parent.left)
15772                     return true;
15773                 node = parent;
15774                 continue;
15775             }
15776             return false;
15777         }
15778     }
15779     ts.expressionResultIsUnused = expressionResultIsUnused;
15780     function containsIgnoredPath(path) {
15781         return ts.some(ts.ignoredPaths, function (p) { return ts.stringContains(path, p); });
15782     }
15783     ts.containsIgnoredPath = containsIgnoredPath;
15784 })(ts || (ts = {}));
15785 var ts;
15786 (function (ts) {
15787     function createBaseNodeFactory() {
15788         var NodeConstructor;
15789         var TokenConstructor;
15790         var IdentifierConstructor;
15791         var PrivateIdentifierConstructor;
15792         var SourceFileConstructor;
15793         return {
15794             createBaseSourceFileNode: createBaseSourceFileNode,
15795             createBaseIdentifierNode: createBaseIdentifierNode,
15796             createBasePrivateIdentifierNode: createBasePrivateIdentifierNode,
15797             createBaseTokenNode: createBaseTokenNode,
15798             createBaseNode: createBaseNode
15799         };
15800         function createBaseSourceFileNode(kind) {
15801             return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, -1, -1);
15802         }
15803         function createBaseIdentifierNode(kind) {
15804             return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, -1, -1);
15805         }
15806         function createBasePrivateIdentifierNode(kind) {
15807             return new (PrivateIdentifierConstructor || (PrivateIdentifierConstructor = ts.objectAllocator.getPrivateIdentifierConstructor()))(kind, -1, -1);
15808         }
15809         function createBaseTokenNode(kind) {
15810             return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, -1, -1);
15811         }
15812         function createBaseNode(kind) {
15813             return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, -1, -1);
15814         }
15815     }
15816     ts.createBaseNodeFactory = createBaseNodeFactory;
15817 })(ts || (ts = {}));
15818 var ts;
15819 (function (ts) {
15820     function createParenthesizerRules(factory) {
15821         return {
15822             parenthesizeLeftSideOfBinary: parenthesizeLeftSideOfBinary,
15823             parenthesizeRightSideOfBinary: parenthesizeRightSideOfBinary,
15824             parenthesizeExpressionOfComputedPropertyName: parenthesizeExpressionOfComputedPropertyName,
15825             parenthesizeConditionOfConditionalExpression: parenthesizeConditionOfConditionalExpression,
15826             parenthesizeBranchOfConditionalExpression: parenthesizeBranchOfConditionalExpression,
15827             parenthesizeExpressionOfExportDefault: parenthesizeExpressionOfExportDefault,
15828             parenthesizeExpressionOfNew: parenthesizeExpressionOfNew,
15829             parenthesizeLeftSideOfAccess: parenthesizeLeftSideOfAccess,
15830             parenthesizeOperandOfPostfixUnary: parenthesizeOperandOfPostfixUnary,
15831             parenthesizeOperandOfPrefixUnary: parenthesizeOperandOfPrefixUnary,
15832             parenthesizeExpressionsOfCommaDelimitedList: parenthesizeExpressionsOfCommaDelimitedList,
15833             parenthesizeExpressionForDisallowedComma: parenthesizeExpressionForDisallowedComma,
15834             parenthesizeExpressionOfExpressionStatement: parenthesizeExpressionOfExpressionStatement,
15835             parenthesizeConciseBodyOfArrowFunction: parenthesizeConciseBodyOfArrowFunction,
15836             parenthesizeMemberOfConditionalType: parenthesizeMemberOfConditionalType,
15837             parenthesizeMemberOfElementType: parenthesizeMemberOfElementType,
15838             parenthesizeElementTypeOfArrayType: parenthesizeElementTypeOfArrayType,
15839             parenthesizeConstituentTypesOfUnionOrIntersectionType: parenthesizeConstituentTypesOfUnionOrIntersectionType,
15840             parenthesizeTypeArguments: parenthesizeTypeArguments,
15841         };
15842         function binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand) {
15843             var binaryOperatorPrecedence = ts.getOperatorPrecedence(216, binaryOperator);
15844             var binaryOperatorAssociativity = ts.getOperatorAssociativity(216, binaryOperator);
15845             var emittedOperand = ts.skipPartiallyEmittedExpressions(operand);
15846             if (!isLeftSideOfBinary && operand.kind === 209 && binaryOperatorPrecedence > 3) {
15847                 return true;
15848             }
15849             var operandPrecedence = ts.getExpressionPrecedence(emittedOperand);
15850             switch (ts.compareValues(operandPrecedence, binaryOperatorPrecedence)) {
15851                 case -1:
15852                     if (!isLeftSideOfBinary
15853                         && binaryOperatorAssociativity === 1
15854                         && operand.kind === 219) {
15855                         return false;
15856                     }
15857                     return true;
15858                 case 1:
15859                     return false;
15860                 case 0:
15861                     if (isLeftSideOfBinary) {
15862                         return binaryOperatorAssociativity === 1;
15863                     }
15864                     else {
15865                         if (ts.isBinaryExpression(emittedOperand)
15866                             && emittedOperand.operatorToken.kind === binaryOperator) {
15867                             if (operatorHasAssociativeProperty(binaryOperator)) {
15868                                 return false;
15869                             }
15870                             if (binaryOperator === 39) {
15871                                 var leftKind = leftOperand ? getLiteralKindOfBinaryPlusOperand(leftOperand) : 0;
15872                                 if (ts.isLiteralKind(leftKind) && leftKind === getLiteralKindOfBinaryPlusOperand(emittedOperand)) {
15873                                     return false;
15874                                 }
15875                             }
15876                         }
15877                         var operandAssociativity = ts.getExpressionAssociativity(emittedOperand);
15878                         return operandAssociativity === 0;
15879                     }
15880             }
15881         }
15882         function operatorHasAssociativeProperty(binaryOperator) {
15883             return binaryOperator === 41
15884                 || binaryOperator === 51
15885                 || binaryOperator === 50
15886                 || binaryOperator === 52;
15887         }
15888         function getLiteralKindOfBinaryPlusOperand(node) {
15889             node = ts.skipPartiallyEmittedExpressions(node);
15890             if (ts.isLiteralKind(node.kind)) {
15891                 return node.kind;
15892             }
15893             if (node.kind === 216 && node.operatorToken.kind === 39) {
15894                 if (node.cachedLiteralKind !== undefined) {
15895                     return node.cachedLiteralKind;
15896                 }
15897                 var leftKind = getLiteralKindOfBinaryPlusOperand(node.left);
15898                 var literalKind = ts.isLiteralKind(leftKind)
15899                     && leftKind === getLiteralKindOfBinaryPlusOperand(node.right)
15900                     ? leftKind
15901                     : 0;
15902                 node.cachedLiteralKind = literalKind;
15903                 return literalKind;
15904             }
15905             return 0;
15906         }
15907         function parenthesizeBinaryOperand(binaryOperator, operand, isLeftSideOfBinary, leftOperand) {
15908             var skipped = ts.skipPartiallyEmittedExpressions(operand);
15909             if (skipped.kind === 207) {
15910                 return operand;
15911             }
15912             return binaryOperandNeedsParentheses(binaryOperator, operand, isLeftSideOfBinary, leftOperand)
15913                 ? factory.createParenthesizedExpression(operand)
15914                 : operand;
15915         }
15916         function parenthesizeLeftSideOfBinary(binaryOperator, leftSide) {
15917             return parenthesizeBinaryOperand(binaryOperator, leftSide, true);
15918         }
15919         function parenthesizeRightSideOfBinary(binaryOperator, leftSide, rightSide) {
15920             return parenthesizeBinaryOperand(binaryOperator, rightSide, false, leftSide);
15921         }
15922         function parenthesizeExpressionOfComputedPropertyName(expression) {
15923             return ts.isCommaSequence(expression) ? factory.createParenthesizedExpression(expression) : expression;
15924         }
15925         function parenthesizeConditionOfConditionalExpression(condition) {
15926             var conditionalPrecedence = ts.getOperatorPrecedence(217, 57);
15927             var emittedCondition = ts.skipPartiallyEmittedExpressions(condition);
15928             var conditionPrecedence = ts.getExpressionPrecedence(emittedCondition);
15929             if (ts.compareValues(conditionPrecedence, conditionalPrecedence) !== 1) {
15930                 return factory.createParenthesizedExpression(condition);
15931             }
15932             return condition;
15933         }
15934         function parenthesizeBranchOfConditionalExpression(branch) {
15935             var emittedExpression = ts.skipPartiallyEmittedExpressions(branch);
15936             return ts.isCommaSequence(emittedExpression)
15937                 ? factory.createParenthesizedExpression(branch)
15938                 : branch;
15939         }
15940         function parenthesizeExpressionOfExportDefault(expression) {
15941             var check = ts.skipPartiallyEmittedExpressions(expression);
15942             var needsParens = ts.isCommaSequence(check);
15943             if (!needsParens) {
15944                 switch (ts.getLeftmostExpression(check, false).kind) {
15945                     case 221:
15946                     case 208:
15947                         needsParens = true;
15948                 }
15949             }
15950             return needsParens ? factory.createParenthesizedExpression(expression) : expression;
15951         }
15952         function parenthesizeExpressionOfNew(expression) {
15953             var leftmostExpr = ts.getLeftmostExpression(expression, true);
15954             switch (leftmostExpr.kind) {
15955                 case 203:
15956                     return factory.createParenthesizedExpression(expression);
15957                 case 204:
15958                     return !leftmostExpr.arguments
15959                         ? factory.createParenthesizedExpression(expression)
15960                         : expression;
15961             }
15962             return parenthesizeLeftSideOfAccess(expression);
15963         }
15964         function parenthesizeLeftSideOfAccess(expression) {
15965             var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
15966             if (ts.isLeftHandSideExpression(emittedExpression)
15967                 && (emittedExpression.kind !== 204 || emittedExpression.arguments)) {
15968                 return expression;
15969             }
15970             return ts.setTextRange(factory.createParenthesizedExpression(expression), expression);
15971         }
15972         function parenthesizeOperandOfPostfixUnary(operand) {
15973             return ts.isLeftHandSideExpression(operand) ? operand : ts.setTextRange(factory.createParenthesizedExpression(operand), operand);
15974         }
15975         function parenthesizeOperandOfPrefixUnary(operand) {
15976             return ts.isUnaryExpression(operand) ? operand : ts.setTextRange(factory.createParenthesizedExpression(operand), operand);
15977         }
15978         function parenthesizeExpressionsOfCommaDelimitedList(elements) {
15979             var result = ts.sameMap(elements, parenthesizeExpressionForDisallowedComma);
15980             return ts.setTextRange(factory.createNodeArray(result, elements.hasTrailingComma), elements);
15981         }
15982         function parenthesizeExpressionForDisallowedComma(expression) {
15983             var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
15984             var expressionPrecedence = ts.getExpressionPrecedence(emittedExpression);
15985             var commaPrecedence = ts.getOperatorPrecedence(216, 27);
15986             return expressionPrecedence > commaPrecedence ? expression : ts.setTextRange(factory.createParenthesizedExpression(expression), expression);
15987         }
15988         function parenthesizeExpressionOfExpressionStatement(expression) {
15989             var emittedExpression = ts.skipPartiallyEmittedExpressions(expression);
15990             if (ts.isCallExpression(emittedExpression)) {
15991                 var callee = emittedExpression.expression;
15992                 var kind = ts.skipPartiallyEmittedExpressions(callee).kind;
15993                 if (kind === 208 || kind === 209) {
15994                     var updated = factory.updateCallExpression(emittedExpression, ts.setTextRange(factory.createParenthesizedExpression(callee), callee), emittedExpression.typeArguments, emittedExpression.arguments);
15995                     return factory.restoreOuterExpressions(expression, updated, 8);
15996                 }
15997             }
15998             var leftmostExpressionKind = ts.getLeftmostExpression(emittedExpression, false).kind;
15999             if (leftmostExpressionKind === 200 || leftmostExpressionKind === 208) {
16000                 return ts.setTextRange(factory.createParenthesizedExpression(expression), expression);
16001             }
16002             return expression;
16003         }
16004         function parenthesizeConciseBodyOfArrowFunction(body) {
16005             if (!ts.isBlock(body) && (ts.isCommaSequence(body) || ts.getLeftmostExpression(body, false).kind === 200)) {
16006                 return ts.setTextRange(factory.createParenthesizedExpression(body), body);
16007             }
16008             return body;
16009         }
16010         function parenthesizeMemberOfConditionalType(member) {
16011             return member.kind === 184 ? factory.createParenthesizedType(member) : member;
16012         }
16013         function parenthesizeMemberOfElementType(member) {
16014             switch (member.kind) {
16015                 case 182:
16016                 case 183:
16017                 case 174:
16018                 case 175:
16019                     return factory.createParenthesizedType(member);
16020             }
16021             return parenthesizeMemberOfConditionalType(member);
16022         }
16023         function parenthesizeElementTypeOfArrayType(member) {
16024             switch (member.kind) {
16025                 case 176:
16026                 case 188:
16027                 case 185:
16028                     return factory.createParenthesizedType(member);
16029             }
16030             return parenthesizeMemberOfElementType(member);
16031         }
16032         function parenthesizeConstituentTypesOfUnionOrIntersectionType(members) {
16033             return factory.createNodeArray(ts.sameMap(members, parenthesizeMemberOfElementType));
16034         }
16035         function parenthesizeOrdinalTypeArgument(node, i) {
16036             return i === 0 && ts.isFunctionOrConstructorTypeNode(node) && node.typeParameters ? factory.createParenthesizedType(node) : node;
16037         }
16038         function parenthesizeTypeArguments(typeArguments) {
16039             if (ts.some(typeArguments)) {
16040                 return factory.createNodeArray(ts.sameMap(typeArguments, parenthesizeOrdinalTypeArgument));
16041             }
16042         }
16043     }
16044     ts.createParenthesizerRules = createParenthesizerRules;
16045     ts.nullParenthesizerRules = {
16046         parenthesizeLeftSideOfBinary: function (_binaryOperator, leftSide) { return leftSide; },
16047         parenthesizeRightSideOfBinary: function (_binaryOperator, _leftSide, rightSide) { return rightSide; },
16048         parenthesizeExpressionOfComputedPropertyName: ts.identity,
16049         parenthesizeConditionOfConditionalExpression: ts.identity,
16050         parenthesizeBranchOfConditionalExpression: ts.identity,
16051         parenthesizeExpressionOfExportDefault: ts.identity,
16052         parenthesizeExpressionOfNew: function (expression) { return ts.cast(expression, ts.isLeftHandSideExpression); },
16053         parenthesizeLeftSideOfAccess: function (expression) { return ts.cast(expression, ts.isLeftHandSideExpression); },
16054         parenthesizeOperandOfPostfixUnary: function (operand) { return ts.cast(operand, ts.isLeftHandSideExpression); },
16055         parenthesizeOperandOfPrefixUnary: function (operand) { return ts.cast(operand, ts.isUnaryExpression); },
16056         parenthesizeExpressionsOfCommaDelimitedList: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
16057         parenthesizeExpressionForDisallowedComma: ts.identity,
16058         parenthesizeExpressionOfExpressionStatement: ts.identity,
16059         parenthesizeConciseBodyOfArrowFunction: ts.identity,
16060         parenthesizeMemberOfConditionalType: ts.identity,
16061         parenthesizeMemberOfElementType: ts.identity,
16062         parenthesizeElementTypeOfArrayType: ts.identity,
16063         parenthesizeConstituentTypesOfUnionOrIntersectionType: function (nodes) { return ts.cast(nodes, ts.isNodeArray); },
16064         parenthesizeTypeArguments: function (nodes) { return nodes && ts.cast(nodes, ts.isNodeArray); },
16065     };
16066 })(ts || (ts = {}));
16067 var ts;
16068 (function (ts) {
16069     function createNodeConverters(factory) {
16070         return {
16071             convertToFunctionBlock: convertToFunctionBlock,
16072             convertToFunctionExpression: convertToFunctionExpression,
16073             convertToArrayAssignmentElement: convertToArrayAssignmentElement,
16074             convertToObjectAssignmentElement: convertToObjectAssignmentElement,
16075             convertToAssignmentPattern: convertToAssignmentPattern,
16076             convertToObjectAssignmentPattern: convertToObjectAssignmentPattern,
16077             convertToArrayAssignmentPattern: convertToArrayAssignmentPattern,
16078             convertToAssignmentElementTarget: convertToAssignmentElementTarget,
16079         };
16080         function convertToFunctionBlock(node, multiLine) {
16081             if (ts.isBlock(node))
16082                 return node;
16083             var returnStatement = factory.createReturnStatement(node);
16084             ts.setTextRange(returnStatement, node);
16085             var body = factory.createBlock([returnStatement], multiLine);
16086             ts.setTextRange(body, node);
16087             return body;
16088         }
16089         function convertToFunctionExpression(node) {
16090             if (!node.body)
16091                 return ts.Debug.fail("Cannot convert a FunctionDeclaration without a body");
16092             var updated = factory.createFunctionExpression(node.modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body);
16093             ts.setOriginalNode(updated, node);
16094             ts.setTextRange(updated, node);
16095             if (ts.getStartsOnNewLine(node)) {
16096                 ts.setStartsOnNewLine(updated, true);
16097             }
16098             return updated;
16099         }
16100         function convertToArrayAssignmentElement(element) {
16101             if (ts.isBindingElement(element)) {
16102                 if (element.dotDotDotToken) {
16103                     ts.Debug.assertNode(element.name, ts.isIdentifier);
16104                     return ts.setOriginalNode(ts.setTextRange(factory.createSpreadElement(element.name), element), element);
16105                 }
16106                 var expression = convertToAssignmentElementTarget(element.name);
16107                 return element.initializer
16108                     ? ts.setOriginalNode(ts.setTextRange(factory.createAssignment(expression, element.initializer), element), element)
16109                     : expression;
16110             }
16111             return ts.cast(element, ts.isExpression);
16112         }
16113         function convertToObjectAssignmentElement(element) {
16114             if (ts.isBindingElement(element)) {
16115                 if (element.dotDotDotToken) {
16116                     ts.Debug.assertNode(element.name, ts.isIdentifier);
16117                     return ts.setOriginalNode(ts.setTextRange(factory.createSpreadAssignment(element.name), element), element);
16118                 }
16119                 if (element.propertyName) {
16120                     var expression = convertToAssignmentElementTarget(element.name);
16121                     return ts.setOriginalNode(ts.setTextRange(factory.createPropertyAssignment(element.propertyName, element.initializer ? factory.createAssignment(expression, element.initializer) : expression), element), element);
16122                 }
16123                 ts.Debug.assertNode(element.name, ts.isIdentifier);
16124                 return ts.setOriginalNode(ts.setTextRange(factory.createShorthandPropertyAssignment(element.name, element.initializer), element), element);
16125             }
16126             return ts.cast(element, ts.isObjectLiteralElementLike);
16127         }
16128         function convertToAssignmentPattern(node) {
16129             switch (node.kind) {
16130                 case 197:
16131                 case 199:
16132                     return convertToArrayAssignmentPattern(node);
16133                 case 196:
16134                 case 200:
16135                     return convertToObjectAssignmentPattern(node);
16136             }
16137         }
16138         function convertToObjectAssignmentPattern(node) {
16139             if (ts.isObjectBindingPattern(node)) {
16140                 return ts.setOriginalNode(ts.setTextRange(factory.createObjectLiteralExpression(ts.map(node.elements, convertToObjectAssignmentElement)), node), node);
16141             }
16142             return ts.cast(node, ts.isObjectLiteralExpression);
16143         }
16144         function convertToArrayAssignmentPattern(node) {
16145             if (ts.isArrayBindingPattern(node)) {
16146                 return ts.setOriginalNode(ts.setTextRange(factory.createArrayLiteralExpression(ts.map(node.elements, convertToArrayAssignmentElement)), node), node);
16147             }
16148             return ts.cast(node, ts.isArrayLiteralExpression);
16149         }
16150         function convertToAssignmentElementTarget(node) {
16151             if (ts.isBindingPattern(node)) {
16152                 return convertToAssignmentPattern(node);
16153             }
16154             return ts.cast(node, ts.isExpression);
16155         }
16156     }
16157     ts.createNodeConverters = createNodeConverters;
16158     ts.nullNodeConverters = {
16159         convertToFunctionBlock: ts.notImplemented,
16160         convertToFunctionExpression: ts.notImplemented,
16161         convertToArrayAssignmentElement: ts.notImplemented,
16162         convertToObjectAssignmentElement: ts.notImplemented,
16163         convertToAssignmentPattern: ts.notImplemented,
16164         convertToObjectAssignmentPattern: ts.notImplemented,
16165         convertToArrayAssignmentPattern: ts.notImplemented,
16166         convertToAssignmentElementTarget: ts.notImplemented,
16167     };
16168 })(ts || (ts = {}));
16169 var ts;
16170 (function (ts) {
16171     var nextAutoGenerateId = 0;
16172     function createNodeFactory(flags, baseFactory) {
16173         var update = flags & 8 ? updateWithoutOriginal : updateWithOriginal;
16174         var parenthesizerRules = ts.memoize(function () { return flags & 1 ? ts.nullParenthesizerRules : ts.createParenthesizerRules(factory); });
16175         var converters = ts.memoize(function () { return flags & 2 ? ts.nullNodeConverters : ts.createNodeConverters(factory); });
16176         var getBinaryCreateFunction = ts.memoizeOne(function (operator) { return function (left, right) { return createBinaryExpression(left, operator, right); }; });
16177         var getPrefixUnaryCreateFunction = ts.memoizeOne(function (operator) { return function (operand) { return createPrefixUnaryExpression(operator, operand); }; });
16178         var getPostfixUnaryCreateFunction = ts.memoizeOne(function (operator) { return function (operand) { return createPostfixUnaryExpression(operand, operator); }; });
16179         var getJSDocPrimaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function () { return createJSDocPrimaryTypeWorker(kind); }; });
16180         var getJSDocUnaryTypeCreateFunction = ts.memoizeOne(function (kind) { return function (type) { return createJSDocUnaryTypeWorker(kind, type); }; });
16181         var getJSDocUnaryTypeUpdateFunction = ts.memoizeOne(function (kind) { return function (node, type) { return updateJSDocUnaryTypeWorker(kind, node, type); }; });
16182         var getJSDocSimpleTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, comment) { return createJSDocSimpleTagWorker(kind, tagName, comment); }; });
16183         var getJSDocSimpleTagUpdateFunction = ts.memoizeOne(function (kind) { return function (node, tagName, comment) { return updateJSDocSimpleTagWorker(kind, node, tagName, comment); }; });
16184         var getJSDocTypeLikeTagCreateFunction = ts.memoizeOne(function (kind) { return function (tagName, typeExpression, comment) { return createJSDocTypeLikeTagWorker(kind, tagName, typeExpression, comment); }; });
16185         var getJSDocTypeLikeTagUpdateFunction = ts.memoizeOne(function (kind) { return function (node, tagName, typeExpression, comment) { return updateJSDocTypeLikeTagWorker(kind, node, tagName, typeExpression, comment); }; });
16186         var factory = {
16187             get parenthesizer() { return parenthesizerRules(); },
16188             get converters() { return converters(); },
16189             createNodeArray: createNodeArray,
16190             createNumericLiteral: createNumericLiteral,
16191             createBigIntLiteral: createBigIntLiteral,
16192             createStringLiteral: createStringLiteral,
16193             createStringLiteralFromNode: createStringLiteralFromNode,
16194             createRegularExpressionLiteral: createRegularExpressionLiteral,
16195             createLiteralLikeNode: createLiteralLikeNode,
16196             createIdentifier: createIdentifier,
16197             updateIdentifier: updateIdentifier,
16198             createTempVariable: createTempVariable,
16199             createLoopVariable: createLoopVariable,
16200             createUniqueName: createUniqueName,
16201             getGeneratedNameForNode: getGeneratedNameForNode,
16202             createPrivateIdentifier: createPrivateIdentifier,
16203             createToken: createToken,
16204             createSuper: createSuper,
16205             createThis: createThis,
16206             createNull: createNull,
16207             createTrue: createTrue,
16208             createFalse: createFalse,
16209             createModifier: createModifier,
16210             createModifiersFromModifierFlags: createModifiersFromModifierFlags,
16211             createQualifiedName: createQualifiedName,
16212             updateQualifiedName: updateQualifiedName,
16213             createComputedPropertyName: createComputedPropertyName,
16214             updateComputedPropertyName: updateComputedPropertyName,
16215             createTypeParameterDeclaration: createTypeParameterDeclaration,
16216             updateTypeParameterDeclaration: updateTypeParameterDeclaration,
16217             createParameterDeclaration: createParameterDeclaration,
16218             updateParameterDeclaration: updateParameterDeclaration,
16219             createDecorator: createDecorator,
16220             updateDecorator: updateDecorator,
16221             createPropertySignature: createPropertySignature,
16222             updatePropertySignature: updatePropertySignature,
16223             createPropertyDeclaration: createPropertyDeclaration,
16224             updatePropertyDeclaration: updatePropertyDeclaration,
16225             createMethodSignature: createMethodSignature,
16226             updateMethodSignature: updateMethodSignature,
16227             createMethodDeclaration: createMethodDeclaration,
16228             updateMethodDeclaration: updateMethodDeclaration,
16229             createConstructorDeclaration: createConstructorDeclaration,
16230             updateConstructorDeclaration: updateConstructorDeclaration,
16231             createGetAccessorDeclaration: createGetAccessorDeclaration,
16232             updateGetAccessorDeclaration: updateGetAccessorDeclaration,
16233             createSetAccessorDeclaration: createSetAccessorDeclaration,
16234             updateSetAccessorDeclaration: updateSetAccessorDeclaration,
16235             createCallSignature: createCallSignature,
16236             updateCallSignature: updateCallSignature,
16237             createConstructSignature: createConstructSignature,
16238             updateConstructSignature: updateConstructSignature,
16239             createIndexSignature: createIndexSignature,
16240             updateIndexSignature: updateIndexSignature,
16241             createTemplateLiteralTypeSpan: createTemplateLiteralTypeSpan,
16242             updateTemplateLiteralTypeSpan: updateTemplateLiteralTypeSpan,
16243             createKeywordTypeNode: createKeywordTypeNode,
16244             createTypePredicateNode: createTypePredicateNode,
16245             updateTypePredicateNode: updateTypePredicateNode,
16246             createTypeReferenceNode: createTypeReferenceNode,
16247             updateTypeReferenceNode: updateTypeReferenceNode,
16248             createFunctionTypeNode: createFunctionTypeNode,
16249             updateFunctionTypeNode: updateFunctionTypeNode,
16250             createConstructorTypeNode: createConstructorTypeNode,
16251             updateConstructorTypeNode: updateConstructorTypeNode,
16252             createTypeQueryNode: createTypeQueryNode,
16253             updateTypeQueryNode: updateTypeQueryNode,
16254             createTypeLiteralNode: createTypeLiteralNode,
16255             updateTypeLiteralNode: updateTypeLiteralNode,
16256             createArrayTypeNode: createArrayTypeNode,
16257             updateArrayTypeNode: updateArrayTypeNode,
16258             createTupleTypeNode: createTupleTypeNode,
16259             updateTupleTypeNode: updateTupleTypeNode,
16260             createNamedTupleMember: createNamedTupleMember,
16261             updateNamedTupleMember: updateNamedTupleMember,
16262             createOptionalTypeNode: createOptionalTypeNode,
16263             updateOptionalTypeNode: updateOptionalTypeNode,
16264             createRestTypeNode: createRestTypeNode,
16265             updateRestTypeNode: updateRestTypeNode,
16266             createUnionTypeNode: createUnionTypeNode,
16267             updateUnionTypeNode: updateUnionTypeNode,
16268             createIntersectionTypeNode: createIntersectionTypeNode,
16269             updateIntersectionTypeNode: updateIntersectionTypeNode,
16270             createConditionalTypeNode: createConditionalTypeNode,
16271             updateConditionalTypeNode: updateConditionalTypeNode,
16272             createInferTypeNode: createInferTypeNode,
16273             updateInferTypeNode: updateInferTypeNode,
16274             createImportTypeNode: createImportTypeNode,
16275             updateImportTypeNode: updateImportTypeNode,
16276             createParenthesizedType: createParenthesizedType,
16277             updateParenthesizedType: updateParenthesizedType,
16278             createThisTypeNode: createThisTypeNode,
16279             createTypeOperatorNode: createTypeOperatorNode,
16280             updateTypeOperatorNode: updateTypeOperatorNode,
16281             createIndexedAccessTypeNode: createIndexedAccessTypeNode,
16282             updateIndexedAccessTypeNode: updateIndexedAccessTypeNode,
16283             createMappedTypeNode: createMappedTypeNode,
16284             updateMappedTypeNode: updateMappedTypeNode,
16285             createLiteralTypeNode: createLiteralTypeNode,
16286             updateLiteralTypeNode: updateLiteralTypeNode,
16287             createTemplateLiteralType: createTemplateLiteralType,
16288             updateTemplateLiteralType: updateTemplateLiteralType,
16289             createObjectBindingPattern: createObjectBindingPattern,
16290             updateObjectBindingPattern: updateObjectBindingPattern,
16291             createArrayBindingPattern: createArrayBindingPattern,
16292             updateArrayBindingPattern: updateArrayBindingPattern,
16293             createBindingElement: createBindingElement,
16294             updateBindingElement: updateBindingElement,
16295             createArrayLiteralExpression: createArrayLiteralExpression,
16296             updateArrayLiteralExpression: updateArrayLiteralExpression,
16297             createObjectLiteralExpression: createObjectLiteralExpression,
16298             updateObjectLiteralExpression: updateObjectLiteralExpression,
16299             createPropertyAccessExpression: flags & 4 ?
16300                 function (expression, name) { return ts.setEmitFlags(createPropertyAccessExpression(expression, name), 131072); } :
16301                 createPropertyAccessExpression,
16302             updatePropertyAccessExpression: updatePropertyAccessExpression,
16303             createPropertyAccessChain: flags & 4 ?
16304                 function (expression, questionDotToken, name) { return ts.setEmitFlags(createPropertyAccessChain(expression, questionDotToken, name), 131072); } :
16305                 createPropertyAccessChain,
16306             updatePropertyAccessChain: updatePropertyAccessChain,
16307             createElementAccessExpression: createElementAccessExpression,
16308             updateElementAccessExpression: updateElementAccessExpression,
16309             createElementAccessChain: createElementAccessChain,
16310             updateElementAccessChain: updateElementAccessChain,
16311             createCallExpression: createCallExpression,
16312             updateCallExpression: updateCallExpression,
16313             createCallChain: createCallChain,
16314             updateCallChain: updateCallChain,
16315             createNewExpression: createNewExpression,
16316             updateNewExpression: updateNewExpression,
16317             createTaggedTemplateExpression: createTaggedTemplateExpression,
16318             updateTaggedTemplateExpression: updateTaggedTemplateExpression,
16319             createTypeAssertion: createTypeAssertion,
16320             updateTypeAssertion: updateTypeAssertion,
16321             createParenthesizedExpression: createParenthesizedExpression,
16322             updateParenthesizedExpression: updateParenthesizedExpression,
16323             createFunctionExpression: createFunctionExpression,
16324             updateFunctionExpression: updateFunctionExpression,
16325             createArrowFunction: createArrowFunction,
16326             updateArrowFunction: updateArrowFunction,
16327             createDeleteExpression: createDeleteExpression,
16328             updateDeleteExpression: updateDeleteExpression,
16329             createTypeOfExpression: createTypeOfExpression,
16330             updateTypeOfExpression: updateTypeOfExpression,
16331             createVoidExpression: createVoidExpression,
16332             updateVoidExpression: updateVoidExpression,
16333             createAwaitExpression: createAwaitExpression,
16334             updateAwaitExpression: updateAwaitExpression,
16335             createPrefixUnaryExpression: createPrefixUnaryExpression,
16336             updatePrefixUnaryExpression: updatePrefixUnaryExpression,
16337             createPostfixUnaryExpression: createPostfixUnaryExpression,
16338             updatePostfixUnaryExpression: updatePostfixUnaryExpression,
16339             createBinaryExpression: createBinaryExpression,
16340             updateBinaryExpression: updateBinaryExpression,
16341             createConditionalExpression: createConditionalExpression,
16342             updateConditionalExpression: updateConditionalExpression,
16343             createTemplateExpression: createTemplateExpression,
16344             updateTemplateExpression: updateTemplateExpression,
16345             createTemplateHead: createTemplateHead,
16346             createTemplateMiddle: createTemplateMiddle,
16347             createTemplateTail: createTemplateTail,
16348             createNoSubstitutionTemplateLiteral: createNoSubstitutionTemplateLiteral,
16349             createTemplateLiteralLikeNode: createTemplateLiteralLikeNode,
16350             createYieldExpression: createYieldExpression,
16351             updateYieldExpression: updateYieldExpression,
16352             createSpreadElement: createSpreadElement,
16353             updateSpreadElement: updateSpreadElement,
16354             createClassExpression: createClassExpression,
16355             updateClassExpression: updateClassExpression,
16356             createOmittedExpression: createOmittedExpression,
16357             createExpressionWithTypeArguments: createExpressionWithTypeArguments,
16358             updateExpressionWithTypeArguments: updateExpressionWithTypeArguments,
16359             createAsExpression: createAsExpression,
16360             updateAsExpression: updateAsExpression,
16361             createNonNullExpression: createNonNullExpression,
16362             updateNonNullExpression: updateNonNullExpression,
16363             createNonNullChain: createNonNullChain,
16364             updateNonNullChain: updateNonNullChain,
16365             createMetaProperty: createMetaProperty,
16366             updateMetaProperty: updateMetaProperty,
16367             createTemplateSpan: createTemplateSpan,
16368             updateTemplateSpan: updateTemplateSpan,
16369             createSemicolonClassElement: createSemicolonClassElement,
16370             createBlock: createBlock,
16371             updateBlock: updateBlock,
16372             createVariableStatement: createVariableStatement,
16373             updateVariableStatement: updateVariableStatement,
16374             createEmptyStatement: createEmptyStatement,
16375             createExpressionStatement: createExpressionStatement,
16376             updateExpressionStatement: updateExpressionStatement,
16377             createIfStatement: createIfStatement,
16378             updateIfStatement: updateIfStatement,
16379             createDoStatement: createDoStatement,
16380             updateDoStatement: updateDoStatement,
16381             createWhileStatement: createWhileStatement,
16382             updateWhileStatement: updateWhileStatement,
16383             createForStatement: createForStatement,
16384             updateForStatement: updateForStatement,
16385             createForInStatement: createForInStatement,
16386             updateForInStatement: updateForInStatement,
16387             createForOfStatement: createForOfStatement,
16388             updateForOfStatement: updateForOfStatement,
16389             createContinueStatement: createContinueStatement,
16390             updateContinueStatement: updateContinueStatement,
16391             createBreakStatement: createBreakStatement,
16392             updateBreakStatement: updateBreakStatement,
16393             createReturnStatement: createReturnStatement,
16394             updateReturnStatement: updateReturnStatement,
16395             createWithStatement: createWithStatement,
16396             updateWithStatement: updateWithStatement,
16397             createSwitchStatement: createSwitchStatement,
16398             updateSwitchStatement: updateSwitchStatement,
16399             createLabeledStatement: createLabeledStatement,
16400             updateLabeledStatement: updateLabeledStatement,
16401             createThrowStatement: createThrowStatement,
16402             updateThrowStatement: updateThrowStatement,
16403             createTryStatement: createTryStatement,
16404             updateTryStatement: updateTryStatement,
16405             createDebuggerStatement: createDebuggerStatement,
16406             createVariableDeclaration: createVariableDeclaration,
16407             updateVariableDeclaration: updateVariableDeclaration,
16408             createVariableDeclarationList: createVariableDeclarationList,
16409             updateVariableDeclarationList: updateVariableDeclarationList,
16410             createFunctionDeclaration: createFunctionDeclaration,
16411             updateFunctionDeclaration: updateFunctionDeclaration,
16412             createClassDeclaration: createClassDeclaration,
16413             updateClassDeclaration: updateClassDeclaration,
16414             createInterfaceDeclaration: createInterfaceDeclaration,
16415             updateInterfaceDeclaration: updateInterfaceDeclaration,
16416             createTypeAliasDeclaration: createTypeAliasDeclaration,
16417             updateTypeAliasDeclaration: updateTypeAliasDeclaration,
16418             createEnumDeclaration: createEnumDeclaration,
16419             updateEnumDeclaration: updateEnumDeclaration,
16420             createModuleDeclaration: createModuleDeclaration,
16421             updateModuleDeclaration: updateModuleDeclaration,
16422             createModuleBlock: createModuleBlock,
16423             updateModuleBlock: updateModuleBlock,
16424             createCaseBlock: createCaseBlock,
16425             updateCaseBlock: updateCaseBlock,
16426             createNamespaceExportDeclaration: createNamespaceExportDeclaration,
16427             updateNamespaceExportDeclaration: updateNamespaceExportDeclaration,
16428             createImportEqualsDeclaration: createImportEqualsDeclaration,
16429             updateImportEqualsDeclaration: updateImportEqualsDeclaration,
16430             createImportDeclaration: createImportDeclaration,
16431             updateImportDeclaration: updateImportDeclaration,
16432             createImportClause: createImportClause,
16433             updateImportClause: updateImportClause,
16434             createNamespaceImport: createNamespaceImport,
16435             updateNamespaceImport: updateNamespaceImport,
16436             createNamespaceExport: createNamespaceExport,
16437             updateNamespaceExport: updateNamespaceExport,
16438             createNamedImports: createNamedImports,
16439             updateNamedImports: updateNamedImports,
16440             createImportSpecifier: createImportSpecifier,
16441             updateImportSpecifier: updateImportSpecifier,
16442             createExportAssignment: createExportAssignment,
16443             updateExportAssignment: updateExportAssignment,
16444             createExportDeclaration: createExportDeclaration,
16445             updateExportDeclaration: updateExportDeclaration,
16446             createNamedExports: createNamedExports,
16447             updateNamedExports: updateNamedExports,
16448             createExportSpecifier: createExportSpecifier,
16449             updateExportSpecifier: updateExportSpecifier,
16450             createMissingDeclaration: createMissingDeclaration,
16451             createExternalModuleReference: createExternalModuleReference,
16452             updateExternalModuleReference: updateExternalModuleReference,
16453             get createJSDocAllType() { return getJSDocPrimaryTypeCreateFunction(303); },
16454             get createJSDocUnknownType() { return getJSDocPrimaryTypeCreateFunction(304); },
16455             get createJSDocNonNullableType() { return getJSDocUnaryTypeCreateFunction(306); },
16456             get updateJSDocNonNullableType() { return getJSDocUnaryTypeUpdateFunction(306); },
16457             get createJSDocNullableType() { return getJSDocUnaryTypeCreateFunction(305); },
16458             get updateJSDocNullableType() { return getJSDocUnaryTypeUpdateFunction(305); },
16459             get createJSDocOptionalType() { return getJSDocUnaryTypeCreateFunction(307); },
16460             get updateJSDocOptionalType() { return getJSDocUnaryTypeUpdateFunction(307); },
16461             get createJSDocVariadicType() { return getJSDocUnaryTypeCreateFunction(309); },
16462             get updateJSDocVariadicType() { return getJSDocUnaryTypeUpdateFunction(309); },
16463             get createJSDocNamepathType() { return getJSDocUnaryTypeCreateFunction(310); },
16464             get updateJSDocNamepathType() { return getJSDocUnaryTypeUpdateFunction(310); },
16465             createJSDocFunctionType: createJSDocFunctionType,
16466             updateJSDocFunctionType: updateJSDocFunctionType,
16467             createJSDocTypeLiteral: createJSDocTypeLiteral,
16468             updateJSDocTypeLiteral: updateJSDocTypeLiteral,
16469             createJSDocTypeExpression: createJSDocTypeExpression,
16470             updateJSDocTypeExpression: updateJSDocTypeExpression,
16471             createJSDocSignature: createJSDocSignature,
16472             updateJSDocSignature: updateJSDocSignature,
16473             createJSDocTemplateTag: createJSDocTemplateTag,
16474             updateJSDocTemplateTag: updateJSDocTemplateTag,
16475             createJSDocTypedefTag: createJSDocTypedefTag,
16476             updateJSDocTypedefTag: updateJSDocTypedefTag,
16477             createJSDocParameterTag: createJSDocParameterTag,
16478             updateJSDocParameterTag: updateJSDocParameterTag,
16479             createJSDocPropertyTag: createJSDocPropertyTag,
16480             updateJSDocPropertyTag: updateJSDocPropertyTag,
16481             createJSDocCallbackTag: createJSDocCallbackTag,
16482             updateJSDocCallbackTag: updateJSDocCallbackTag,
16483             createJSDocAugmentsTag: createJSDocAugmentsTag,
16484             updateJSDocAugmentsTag: updateJSDocAugmentsTag,
16485             createJSDocImplementsTag: createJSDocImplementsTag,
16486             updateJSDocImplementsTag: updateJSDocImplementsTag,
16487             createJSDocSeeTag: createJSDocSeeTag,
16488             updateJSDocSeeTag: updateJSDocSeeTag,
16489             createJSDocNameReference: createJSDocNameReference,
16490             updateJSDocNameReference: updateJSDocNameReference,
16491             get createJSDocTypeTag() { return getJSDocTypeLikeTagCreateFunction(329); },
16492             get updateJSDocTypeTag() { return getJSDocTypeLikeTagUpdateFunction(329); },
16493             get createJSDocReturnTag() { return getJSDocTypeLikeTagCreateFunction(327); },
16494             get updateJSDocReturnTag() { return getJSDocTypeLikeTagUpdateFunction(327); },
16495             get createJSDocThisTag() { return getJSDocTypeLikeTagCreateFunction(328); },
16496             get updateJSDocThisTag() { return getJSDocTypeLikeTagUpdateFunction(328); },
16497             get createJSDocEnumTag() { return getJSDocTypeLikeTagCreateFunction(325); },
16498             get updateJSDocEnumTag() { return getJSDocTypeLikeTagUpdateFunction(325); },
16499             get createJSDocAuthorTag() { return getJSDocSimpleTagCreateFunction(317); },
16500             get updateJSDocAuthorTag() { return getJSDocSimpleTagUpdateFunction(317); },
16501             get createJSDocClassTag() { return getJSDocSimpleTagCreateFunction(319); },
16502             get updateJSDocClassTag() { return getJSDocSimpleTagUpdateFunction(319); },
16503             get createJSDocPublicTag() { return getJSDocSimpleTagCreateFunction(320); },
16504             get updateJSDocPublicTag() { return getJSDocSimpleTagUpdateFunction(320); },
16505             get createJSDocPrivateTag() { return getJSDocSimpleTagCreateFunction(321); },
16506             get updateJSDocPrivateTag() { return getJSDocSimpleTagUpdateFunction(321); },
16507             get createJSDocProtectedTag() { return getJSDocSimpleTagCreateFunction(322); },
16508             get updateJSDocProtectedTag() { return getJSDocSimpleTagUpdateFunction(322); },
16509             get createJSDocReadonlyTag() { return getJSDocSimpleTagCreateFunction(323); },
16510             get updateJSDocReadonlyTag() { return getJSDocSimpleTagUpdateFunction(323); },
16511             get createJSDocDeprecatedTag() { return getJSDocSimpleTagCreateFunction(318); },
16512             get updateJSDocDeprecatedTag() { return getJSDocSimpleTagUpdateFunction(318); },
16513             createJSDocUnknownTag: createJSDocUnknownTag,
16514             updateJSDocUnknownTag: updateJSDocUnknownTag,
16515             createJSDocComment: createJSDocComment,
16516             updateJSDocComment: updateJSDocComment,
16517             createJsxElement: createJsxElement,
16518             updateJsxElement: updateJsxElement,
16519             createJsxSelfClosingElement: createJsxSelfClosingElement,
16520             updateJsxSelfClosingElement: updateJsxSelfClosingElement,
16521             createJsxOpeningElement: createJsxOpeningElement,
16522             updateJsxOpeningElement: updateJsxOpeningElement,
16523             createJsxClosingElement: createJsxClosingElement,
16524             updateJsxClosingElement: updateJsxClosingElement,
16525             createJsxFragment: createJsxFragment,
16526             createJsxText: createJsxText,
16527             updateJsxText: updateJsxText,
16528             createJsxOpeningFragment: createJsxOpeningFragment,
16529             createJsxJsxClosingFragment: createJsxJsxClosingFragment,
16530             updateJsxFragment: updateJsxFragment,
16531             createJsxAttribute: createJsxAttribute,
16532             updateJsxAttribute: updateJsxAttribute,
16533             createJsxAttributes: createJsxAttributes,
16534             updateJsxAttributes: updateJsxAttributes,
16535             createJsxSpreadAttribute: createJsxSpreadAttribute,
16536             updateJsxSpreadAttribute: updateJsxSpreadAttribute,
16537             createJsxExpression: createJsxExpression,
16538             updateJsxExpression: updateJsxExpression,
16539             createCaseClause: createCaseClause,
16540             updateCaseClause: updateCaseClause,
16541             createDefaultClause: createDefaultClause,
16542             updateDefaultClause: updateDefaultClause,
16543             createHeritageClause: createHeritageClause,
16544             updateHeritageClause: updateHeritageClause,
16545             createCatchClause: createCatchClause,
16546             updateCatchClause: updateCatchClause,
16547             createPropertyAssignment: createPropertyAssignment,
16548             updatePropertyAssignment: updatePropertyAssignment,
16549             createShorthandPropertyAssignment: createShorthandPropertyAssignment,
16550             updateShorthandPropertyAssignment: updateShorthandPropertyAssignment,
16551             createSpreadAssignment: createSpreadAssignment,
16552             updateSpreadAssignment: updateSpreadAssignment,
16553             createEnumMember: createEnumMember,
16554             updateEnumMember: updateEnumMember,
16555             createSourceFile: createSourceFile,
16556             updateSourceFile: updateSourceFile,
16557             createBundle: createBundle,
16558             updateBundle: updateBundle,
16559             createUnparsedSource: createUnparsedSource,
16560             createUnparsedPrologue: createUnparsedPrologue,
16561             createUnparsedPrepend: createUnparsedPrepend,
16562             createUnparsedTextLike: createUnparsedTextLike,
16563             createUnparsedSyntheticReference: createUnparsedSyntheticReference,
16564             createInputFiles: createInputFiles,
16565             createSyntheticExpression: createSyntheticExpression,
16566             createSyntaxList: createSyntaxList,
16567             createNotEmittedStatement: createNotEmittedStatement,
16568             createPartiallyEmittedExpression: createPartiallyEmittedExpression,
16569             updatePartiallyEmittedExpression: updatePartiallyEmittedExpression,
16570             createCommaListExpression: createCommaListExpression,
16571             updateCommaListExpression: updateCommaListExpression,
16572             createEndOfDeclarationMarker: createEndOfDeclarationMarker,
16573             createMergeDeclarationMarker: createMergeDeclarationMarker,
16574             createSyntheticReferenceExpression: createSyntheticReferenceExpression,
16575             updateSyntheticReferenceExpression: updateSyntheticReferenceExpression,
16576             cloneNode: cloneNode,
16577             get createComma() { return getBinaryCreateFunction(27); },
16578             get createAssignment() { return getBinaryCreateFunction(62); },
16579             get createLogicalOr() { return getBinaryCreateFunction(56); },
16580             get createLogicalAnd() { return getBinaryCreateFunction(55); },
16581             get createBitwiseOr() { return getBinaryCreateFunction(51); },
16582             get createBitwiseXor() { return getBinaryCreateFunction(52); },
16583             get createBitwiseAnd() { return getBinaryCreateFunction(50); },
16584             get createStrictEquality() { return getBinaryCreateFunction(36); },
16585             get createStrictInequality() { return getBinaryCreateFunction(37); },
16586             get createEquality() { return getBinaryCreateFunction(34); },
16587             get createInequality() { return getBinaryCreateFunction(35); },
16588             get createLessThan() { return getBinaryCreateFunction(29); },
16589             get createLessThanEquals() { return getBinaryCreateFunction(32); },
16590             get createGreaterThan() { return getBinaryCreateFunction(31); },
16591             get createGreaterThanEquals() { return getBinaryCreateFunction(33); },
16592             get createLeftShift() { return getBinaryCreateFunction(47); },
16593             get createRightShift() { return getBinaryCreateFunction(48); },
16594             get createUnsignedRightShift() { return getBinaryCreateFunction(49); },
16595             get createAdd() { return getBinaryCreateFunction(39); },
16596             get createSubtract() { return getBinaryCreateFunction(40); },
16597             get createMultiply() { return getBinaryCreateFunction(41); },
16598             get createDivide() { return getBinaryCreateFunction(43); },
16599             get createModulo() { return getBinaryCreateFunction(44); },
16600             get createExponent() { return getBinaryCreateFunction(42); },
16601             get createPrefixPlus() { return getPrefixUnaryCreateFunction(39); },
16602             get createPrefixMinus() { return getPrefixUnaryCreateFunction(40); },
16603             get createPrefixIncrement() { return getPrefixUnaryCreateFunction(45); },
16604             get createPrefixDecrement() { return getPrefixUnaryCreateFunction(46); },
16605             get createBitwiseNot() { return getPrefixUnaryCreateFunction(54); },
16606             get createLogicalNot() { return getPrefixUnaryCreateFunction(53); },
16607             get createPostfixIncrement() { return getPostfixUnaryCreateFunction(45); },
16608             get createPostfixDecrement() { return getPostfixUnaryCreateFunction(46); },
16609             createImmediatelyInvokedFunctionExpression: createImmediatelyInvokedFunctionExpression,
16610             createImmediatelyInvokedArrowFunction: createImmediatelyInvokedArrowFunction,
16611             createVoidZero: createVoidZero,
16612             createExportDefault: createExportDefault,
16613             createExternalModuleExport: createExternalModuleExport,
16614             createTypeCheck: createTypeCheck,
16615             createMethodCall: createMethodCall,
16616             createGlobalMethodCall: createGlobalMethodCall,
16617             createFunctionBindCall: createFunctionBindCall,
16618             createFunctionCallCall: createFunctionCallCall,
16619             createFunctionApplyCall: createFunctionApplyCall,
16620             createArraySliceCall: createArraySliceCall,
16621             createArrayConcatCall: createArrayConcatCall,
16622             createObjectDefinePropertyCall: createObjectDefinePropertyCall,
16623             createPropertyDescriptor: createPropertyDescriptor,
16624             createCallBinding: createCallBinding,
16625             inlineExpressions: inlineExpressions,
16626             getInternalName: getInternalName,
16627             getLocalName: getLocalName,
16628             getExportName: getExportName,
16629             getDeclarationName: getDeclarationName,
16630             getNamespaceMemberName: getNamespaceMemberName,
16631             getExternalModuleOrNamespaceExportName: getExternalModuleOrNamespaceExportName,
16632             restoreOuterExpressions: restoreOuterExpressions,
16633             restoreEnclosingLabel: restoreEnclosingLabel,
16634             createUseStrictPrologue: createUseStrictPrologue,
16635             copyPrologue: copyPrologue,
16636             copyStandardPrologue: copyStandardPrologue,
16637             copyCustomPrologue: copyCustomPrologue,
16638             ensureUseStrict: ensureUseStrict,
16639             liftToBlock: liftToBlock,
16640             mergeLexicalEnvironment: mergeLexicalEnvironment,
16641             updateModifiers: updateModifiers,
16642         };
16643         return factory;
16644         function createNodeArray(elements, hasTrailingComma) {
16645             if (elements === undefined || elements === ts.emptyArray) {
16646                 elements = [];
16647             }
16648             else if (ts.isNodeArray(elements)) {
16649                 if (elements.transformFlags === undefined) {
16650                     aggregateChildrenFlags(elements);
16651                 }
16652                 ts.Debug.attachNodeArrayDebugInfo(elements);
16653                 return elements;
16654             }
16655             var length = elements.length;
16656             var array = (length >= 1 && length <= 4 ? elements.slice() : elements);
16657             ts.setTextRangePosEnd(array, -1, -1);
16658             array.hasTrailingComma = !!hasTrailingComma;
16659             aggregateChildrenFlags(array);
16660             ts.Debug.attachNodeArrayDebugInfo(array);
16661             return array;
16662         }
16663         function createBaseNode(kind) {
16664             return baseFactory.createBaseNode(kind);
16665         }
16666         function createBaseDeclaration(kind, decorators, modifiers) {
16667             var node = createBaseNode(kind);
16668             node.decorators = asNodeArray(decorators);
16669             node.modifiers = asNodeArray(modifiers);
16670             node.transformFlags |=
16671                 propagateChildrenFlags(node.decorators) |
16672                     propagateChildrenFlags(node.modifiers);
16673             node.symbol = undefined;
16674             node.localSymbol = undefined;
16675             node.locals = undefined;
16676             node.nextContainer = undefined;
16677             return node;
16678         }
16679         function createBaseNamedDeclaration(kind, decorators, modifiers, name) {
16680             var node = createBaseDeclaration(kind, decorators, modifiers);
16681             name = asName(name);
16682             node.name = name;
16683             if (name) {
16684                 switch (node.kind) {
16685                     case 165:
16686                     case 167:
16687                     case 168:
16688                     case 163:
16689                     case 288:
16690                         if (ts.isIdentifier(name)) {
16691                             node.transformFlags |= propagateIdentifierNameFlags(name);
16692                             break;
16693                         }
16694                     default:
16695                         node.transformFlags |= propagateChildFlags(name);
16696                         break;
16697                 }
16698             }
16699             return node;
16700         }
16701         function createBaseGenericNamedDeclaration(kind, decorators, modifiers, name, typeParameters) {
16702             var node = createBaseNamedDeclaration(kind, decorators, modifiers, name);
16703             node.typeParameters = asNodeArray(typeParameters);
16704             node.transformFlags |= propagateChildrenFlags(node.typeParameters);
16705             if (typeParameters)
16706                 node.transformFlags |= 1;
16707             return node;
16708         }
16709         function createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type) {
16710             var node = createBaseGenericNamedDeclaration(kind, decorators, modifiers, name, typeParameters);
16711             node.parameters = createNodeArray(parameters);
16712             node.type = type;
16713             node.transformFlags |=
16714                 propagateChildrenFlags(node.parameters) |
16715                     propagateChildFlags(node.type);
16716             if (type)
16717                 node.transformFlags |= 1;
16718             return node;
16719         }
16720         function updateBaseSignatureDeclaration(updated, original) {
16721             if (original.typeArguments)
16722                 updated.typeArguments = original.typeArguments;
16723             return update(updated, original);
16724         }
16725         function createBaseFunctionLikeDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type, body) {
16726             var node = createBaseSignatureDeclaration(kind, decorators, modifiers, name, typeParameters, parameters, type);
16727             node.body = body;
16728             node.transformFlags |= propagateChildFlags(node.body) & ~8388608;
16729             if (!body)
16730                 node.transformFlags |= 1;
16731             return node;
16732         }
16733         function updateBaseFunctionLikeDeclaration(updated, original) {
16734             if (original.exclamationToken)
16735                 updated.exclamationToken = original.exclamationToken;
16736             if (original.typeArguments)
16737                 updated.typeArguments = original.typeArguments;
16738             return updateBaseSignatureDeclaration(updated, original);
16739         }
16740         function createBaseInterfaceOrClassLikeDeclaration(kind, decorators, modifiers, name, typeParameters, heritageClauses) {
16741             var node = createBaseGenericNamedDeclaration(kind, decorators, modifiers, name, typeParameters);
16742             node.heritageClauses = asNodeArray(heritageClauses);
16743             node.transformFlags |= propagateChildrenFlags(node.heritageClauses);
16744             return node;
16745         }
16746         function createBaseClassLikeDeclaration(kind, decorators, modifiers, name, typeParameters, heritageClauses, members) {
16747             var node = createBaseInterfaceOrClassLikeDeclaration(kind, decorators, modifiers, name, typeParameters, heritageClauses);
16748             node.members = createNodeArray(members);
16749             node.transformFlags |= propagateChildrenFlags(node.members);
16750             return node;
16751         }
16752         function createBaseBindingLikeDeclaration(kind, decorators, modifiers, name, initializer) {
16753             var node = createBaseNamedDeclaration(kind, decorators, modifiers, name);
16754             node.initializer = initializer;
16755             node.transformFlags |= propagateChildFlags(node.initializer);
16756             return node;
16757         }
16758         function createBaseVariableLikeDeclaration(kind, decorators, modifiers, name, type, initializer) {
16759             var node = createBaseBindingLikeDeclaration(kind, decorators, modifiers, name, initializer);
16760             node.type = type;
16761             node.transformFlags |= propagateChildFlags(type);
16762             if (type)
16763                 node.transformFlags |= 1;
16764             return node;
16765         }
16766         function createBaseLiteral(kind, text) {
16767             var node = createBaseToken(kind);
16768             node.text = text;
16769             return node;
16770         }
16771         function createNumericLiteral(value, numericLiteralFlags) {
16772             if (numericLiteralFlags === void 0) { numericLiteralFlags = 0; }
16773             var node = createBaseLiteral(8, typeof value === "number" ? value + "" : value);
16774             node.numericLiteralFlags = numericLiteralFlags;
16775             if (numericLiteralFlags & 384)
16776                 node.transformFlags |= 256;
16777             return node;
16778         }
16779         function createBigIntLiteral(value) {
16780             var node = createBaseLiteral(9, typeof value === "string" ? value : ts.pseudoBigIntToString(value) + "n");
16781             node.transformFlags |= 4;
16782             return node;
16783         }
16784         function createBaseStringLiteral(text, isSingleQuote) {
16785             var node = createBaseLiteral(10, text);
16786             node.singleQuote = isSingleQuote;
16787             return node;
16788         }
16789         function createStringLiteral(text, isSingleQuote, hasExtendedUnicodeEscape) {
16790             var node = createBaseStringLiteral(text, isSingleQuote);
16791             node.hasExtendedUnicodeEscape = hasExtendedUnicodeEscape;
16792             if (hasExtendedUnicodeEscape)
16793                 node.transformFlags |= 256;
16794             return node;
16795         }
16796         function createStringLiteralFromNode(sourceNode) {
16797             var node = createBaseStringLiteral(ts.getTextOfIdentifierOrLiteral(sourceNode), undefined);
16798             node.textSourceNode = sourceNode;
16799             return node;
16800         }
16801         function createRegularExpressionLiteral(text) {
16802             var node = createBaseLiteral(13, text);
16803             return node;
16804         }
16805         function createLiteralLikeNode(kind, text) {
16806             switch (kind) {
16807                 case 8: return createNumericLiteral(text, 0);
16808                 case 9: return createBigIntLiteral(text);
16809                 case 10: return createStringLiteral(text, undefined);
16810                 case 11: return createJsxText(text, false);
16811                 case 12: return createJsxText(text, true);
16812                 case 13: return createRegularExpressionLiteral(text);
16813                 case 14: return createTemplateLiteralLikeNode(kind, text, undefined, 0);
16814             }
16815         }
16816         function createBaseIdentifier(text, originalKeywordKind) {
16817             if (originalKeywordKind === undefined && text) {
16818                 originalKeywordKind = ts.stringToToken(text);
16819             }
16820             if (originalKeywordKind === 78) {
16821                 originalKeywordKind = undefined;
16822             }
16823             var node = baseFactory.createBaseIdentifierNode(78);
16824             node.originalKeywordKind = originalKeywordKind;
16825             node.escapedText = ts.escapeLeadingUnderscores(text);
16826             return node;
16827         }
16828         function createBaseGeneratedIdentifier(text, autoGenerateFlags) {
16829             var node = createBaseIdentifier(text, undefined);
16830             node.autoGenerateFlags = autoGenerateFlags;
16831             node.autoGenerateId = nextAutoGenerateId;
16832             nextAutoGenerateId++;
16833             return node;
16834         }
16835         function createIdentifier(text, typeArguments, originalKeywordKind) {
16836             var node = createBaseIdentifier(text, originalKeywordKind);
16837             if (typeArguments) {
16838                 node.typeArguments = createNodeArray(typeArguments);
16839             }
16840             if (node.originalKeywordKind === 130) {
16841                 node.transformFlags |= 8388608;
16842             }
16843             return node;
16844         }
16845         function updateIdentifier(node, typeArguments) {
16846             return node.typeArguments !== typeArguments
16847                 ? update(createIdentifier(ts.idText(node), typeArguments), node)
16848                 : node;
16849         }
16850         function createTempVariable(recordTempVariable, reservedInNestedScopes) {
16851             var flags = 1;
16852             if (reservedInNestedScopes)
16853                 flags |= 8;
16854             var name = createBaseGeneratedIdentifier("", flags);
16855             if (recordTempVariable) {
16856                 recordTempVariable(name);
16857             }
16858             return name;
16859         }
16860         function createLoopVariable() {
16861             return createBaseGeneratedIdentifier("", 2);
16862         }
16863         function createUniqueName(text, flags) {
16864             if (flags === void 0) { flags = 0; }
16865             ts.Debug.assert(!(flags & 7), "Argument out of range: flags");
16866             ts.Debug.assert((flags & (16 | 32)) !== 32, "GeneratedIdentifierFlags.FileLevel cannot be set without also setting GeneratedIdentifierFlags.Optimistic");
16867             return createBaseGeneratedIdentifier(text, 3 | flags);
16868         }
16869         function getGeneratedNameForNode(node, flags) {
16870             if (flags === void 0) { flags = 0; }
16871             ts.Debug.assert(!(flags & 7), "Argument out of range: flags");
16872             var name = createBaseGeneratedIdentifier(node && ts.isIdentifier(node) ? ts.idText(node) : "", 4 | flags);
16873             name.original = node;
16874             return name;
16875         }
16876         function createPrivateIdentifier(text) {
16877             if (!ts.startsWith(text, "#"))
16878                 ts.Debug.fail("First character of private identifier must be #: " + text);
16879             var node = baseFactory.createBasePrivateIdentifierNode(79);
16880             node.escapedText = ts.escapeLeadingUnderscores(text);
16881             node.transformFlags |= 4194304;
16882             return node;
16883         }
16884         function createBaseToken(kind) {
16885             return baseFactory.createBaseTokenNode(kind);
16886         }
16887         function createToken(token) {
16888             ts.Debug.assert(token >= 0 && token <= 156, "Invalid token");
16889             ts.Debug.assert(token <= 14 || token >= 17, "Invalid token. Use 'createTemplateLiteralLikeNode' to create template literals.");
16890             ts.Debug.assert(token <= 8 || token >= 14, "Invalid token. Use 'createLiteralLikeNode' to create literals.");
16891             ts.Debug.assert(token !== 78, "Invalid token. Use 'createIdentifier' to create identifiers");
16892             var node = createBaseToken(token);
16893             var transformFlags = 0;
16894             switch (token) {
16895                 case 129:
16896                     transformFlags =
16897                         64 |
16898                             32;
16899                     break;
16900                 case 122:
16901                 case 120:
16902                 case 121:
16903                 case 142:
16904                 case 125:
16905                 case 133:
16906                 case 84:
16907                 case 128:
16908                 case 144:
16909                 case 155:
16910                 case 141:
16911                 case 145:
16912                 case 147:
16913                 case 131:
16914                 case 148:
16915                 case 113:
16916                 case 152:
16917                 case 150:
16918                     transformFlags = 1;
16919                     break;
16920                 case 123:
16921                 case 105:
16922                     transformFlags = 256;
16923                     break;
16924                 case 107:
16925                     transformFlags = 4096;
16926                     break;
16927             }
16928             if (transformFlags) {
16929                 node.transformFlags |= transformFlags;
16930             }
16931             return node;
16932         }
16933         function createSuper() {
16934             return createToken(105);
16935         }
16936         function createThis() {
16937             return createToken(107);
16938         }
16939         function createNull() {
16940             return createToken(103);
16941         }
16942         function createTrue() {
16943             return createToken(109);
16944         }
16945         function createFalse() {
16946             return createToken(94);
16947         }
16948         function createModifier(kind) {
16949             return createToken(kind);
16950         }
16951         function createModifiersFromModifierFlags(flags) {
16952             var result = [];
16953             if (flags & 1) {
16954                 result.push(createModifier(92));
16955             }
16956             if (flags & 2) {
16957                 result.push(createModifier(133));
16958             }
16959             if (flags & 512) {
16960                 result.push(createModifier(87));
16961             }
16962             if (flags & 2048) {
16963                 result.push(createModifier(84));
16964             }
16965             if (flags & 4) {
16966                 result.push(createModifier(122));
16967             }
16968             if (flags & 8) {
16969                 result.push(createModifier(120));
16970             }
16971             if (flags & 16) {
16972                 result.push(createModifier(121));
16973             }
16974             if (flags & 128) {
16975                 result.push(createModifier(125));
16976             }
16977             if (flags & 32) {
16978                 result.push(createModifier(123));
16979             }
16980             if (flags & 64) {
16981                 result.push(createModifier(142));
16982             }
16983             if (flags & 256) {
16984                 result.push(createModifier(129));
16985             }
16986             return result;
16987         }
16988         function createQualifiedName(left, right) {
16989             var node = createBaseNode(157);
16990             node.left = left;
16991             node.right = asName(right);
16992             node.transformFlags |=
16993                 propagateChildFlags(node.left) |
16994                     propagateIdentifierNameFlags(node.right);
16995             return node;
16996         }
16997         function updateQualifiedName(node, left, right) {
16998             return node.left !== left
16999                 || node.right !== right
17000                 ? update(createQualifiedName(left, right), node)
17001                 : node;
17002         }
17003         function createComputedPropertyName(expression) {
17004             var node = createBaseNode(158);
17005             node.expression = parenthesizerRules().parenthesizeExpressionOfComputedPropertyName(expression);
17006             node.transformFlags |=
17007                 propagateChildFlags(node.expression) |
17008                     256 |
17009                     32768;
17010             return node;
17011         }
17012         function updateComputedPropertyName(node, expression) {
17013             return node.expression !== expression
17014                 ? update(createComputedPropertyName(expression), node)
17015                 : node;
17016         }
17017         function createTypeParameterDeclaration(name, constraint, defaultType) {
17018             var node = createBaseNamedDeclaration(159, undefined, undefined, name);
17019             node.constraint = constraint;
17020             node.default = defaultType;
17021             node.transformFlags = 1;
17022             return node;
17023         }
17024         function updateTypeParameterDeclaration(node, name, constraint, defaultType) {
17025             return node.name !== name
17026                 || node.constraint !== constraint
17027                 || node.default !== defaultType
17028                 ? update(createTypeParameterDeclaration(name, constraint, defaultType), node)
17029                 : node;
17030         }
17031         function createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) {
17032             var node = createBaseVariableLikeDeclaration(160, decorators, modifiers, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer));
17033             node.dotDotDotToken = dotDotDotToken;
17034             node.questionToken = questionToken;
17035             if (ts.isThisIdentifier(node.name)) {
17036                 node.transformFlags = 1;
17037             }
17038             else {
17039                 node.transformFlags |=
17040                     propagateChildFlags(node.dotDotDotToken) |
17041                         propagateChildFlags(node.questionToken);
17042                 if (questionToken)
17043                     node.transformFlags |= 1;
17044                 if (ts.modifiersToFlags(node.modifiers) & 92)
17045                     node.transformFlags |= 2048;
17046                 if (initializer || dotDotDotToken)
17047                     node.transformFlags |= 256;
17048             }
17049             return node;
17050         }
17051         function updateParameterDeclaration(node, decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer) {
17052             return node.decorators !== decorators
17053                 || node.modifiers !== modifiers
17054                 || node.dotDotDotToken !== dotDotDotToken
17055                 || node.name !== name
17056                 || node.questionToken !== questionToken
17057                 || node.type !== type
17058                 || node.initializer !== initializer
17059                 ? update(createParameterDeclaration(decorators, modifiers, dotDotDotToken, name, questionToken, type, initializer), node)
17060                 : node;
17061         }
17062         function createDecorator(expression) {
17063             var node = createBaseNode(161);
17064             node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
17065             node.transformFlags |=
17066                 propagateChildFlags(node.expression) |
17067                     1 |
17068                     2048;
17069             return node;
17070         }
17071         function updateDecorator(node, expression) {
17072             return node.expression !== expression
17073                 ? update(createDecorator(expression), node)
17074                 : node;
17075         }
17076         function createPropertySignature(modifiers, name, questionToken, type) {
17077             var node = createBaseNamedDeclaration(162, undefined, modifiers, name);
17078             node.type = type;
17079             node.questionToken = questionToken;
17080             node.transformFlags = 1;
17081             return node;
17082         }
17083         function updatePropertySignature(node, modifiers, name, questionToken, type) {
17084             return node.modifiers !== modifiers
17085                 || node.name !== name
17086                 || node.questionToken !== questionToken
17087                 || node.type !== type
17088                 ? update(createPropertySignature(modifiers, name, questionToken, type), node)
17089                 : node;
17090         }
17091         function createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer) {
17092             var node = createBaseVariableLikeDeclaration(163, decorators, modifiers, name, type, initializer);
17093             node.questionToken = questionOrExclamationToken && ts.isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined;
17094             node.exclamationToken = questionOrExclamationToken && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined;
17095             node.transformFlags |=
17096                 propagateChildFlags(node.questionToken) |
17097                     propagateChildFlags(node.exclamationToken) |
17098                     4194304;
17099             if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) {
17100                 node.transformFlags |= 2048;
17101             }
17102             if (questionOrExclamationToken || ts.modifiersToFlags(node.modifiers) & 2) {
17103                 node.transformFlags |= 1;
17104             }
17105             return node;
17106         }
17107         function updatePropertyDeclaration(node, decorators, modifiers, name, questionOrExclamationToken, type, initializer) {
17108             return node.decorators !== decorators
17109                 || node.modifiers !== modifiers
17110                 || node.name !== name
17111                 || node.questionToken !== (questionOrExclamationToken !== undefined && ts.isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined)
17112                 || node.exclamationToken !== (questionOrExclamationToken !== undefined && ts.isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined)
17113                 || node.type !== type
17114                 || node.initializer !== initializer
17115                 ? update(createPropertyDeclaration(decorators, modifiers, name, questionOrExclamationToken, type, initializer), node)
17116                 : node;
17117         }
17118         function createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type) {
17119             var node = createBaseSignatureDeclaration(164, undefined, modifiers, name, typeParameters, parameters, type);
17120             node.questionToken = questionToken;
17121             node.transformFlags = 1;
17122             return node;
17123         }
17124         function updateMethodSignature(node, modifiers, name, questionToken, typeParameters, parameters, type) {
17125             return node.modifiers !== modifiers
17126                 || node.name !== name
17127                 || node.questionToken !== questionToken
17128                 || node.typeParameters !== typeParameters
17129                 || node.parameters !== parameters
17130                 || node.type !== type
17131                 ? updateBaseSignatureDeclaration(createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type), node)
17132                 : node;
17133         }
17134         function createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) {
17135             var node = createBaseFunctionLikeDeclaration(165, decorators, modifiers, name, typeParameters, parameters, type, body);
17136             node.asteriskToken = asteriskToken;
17137             node.questionToken = questionToken;
17138             node.transformFlags |=
17139                 propagateChildFlags(node.asteriskToken) |
17140                     propagateChildFlags(node.questionToken) |
17141                     256;
17142             if (questionToken) {
17143                 node.transformFlags |= 1;
17144             }
17145             if (ts.modifiersToFlags(node.modifiers) & 256) {
17146                 if (asteriskToken) {
17147                     node.transformFlags |= 32;
17148                 }
17149                 else {
17150                     node.transformFlags |= 64;
17151                 }
17152             }
17153             else if (asteriskToken) {
17154                 node.transformFlags |= 512;
17155             }
17156             return node;
17157         }
17158         function updateMethodDeclaration(node, decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body) {
17159             return node.decorators !== decorators
17160                 || node.modifiers !== modifiers
17161                 || node.asteriskToken !== asteriskToken
17162                 || node.name !== name
17163                 || node.questionToken !== questionToken
17164                 || node.typeParameters !== typeParameters
17165                 || node.parameters !== parameters
17166                 || node.type !== type
17167                 || node.body !== body
17168                 ? updateBaseFunctionLikeDeclaration(createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node)
17169                 : node;
17170         }
17171         function createConstructorDeclaration(decorators, modifiers, parameters, body) {
17172             var node = createBaseFunctionLikeDeclaration(166, decorators, modifiers, undefined, undefined, parameters, undefined, body);
17173             node.transformFlags |= 256;
17174             return node;
17175         }
17176         function updateConstructorDeclaration(node, decorators, modifiers, parameters, body) {
17177             return node.decorators !== decorators
17178                 || node.modifiers !== modifiers
17179                 || node.parameters !== parameters
17180                 || node.body !== body
17181                 ? updateBaseFunctionLikeDeclaration(createConstructorDeclaration(decorators, modifiers, parameters, body), node)
17182                 : node;
17183         }
17184         function createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) {
17185             return createBaseFunctionLikeDeclaration(167, decorators, modifiers, name, undefined, parameters, type, body);
17186         }
17187         function updateGetAccessorDeclaration(node, decorators, modifiers, name, parameters, type, body) {
17188             return node.decorators !== decorators
17189                 || node.modifiers !== modifiers
17190                 || node.name !== name
17191                 || node.parameters !== parameters
17192                 || node.type !== type
17193                 || node.body !== body
17194                 ? updateBaseFunctionLikeDeclaration(createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body), node)
17195                 : node;
17196         }
17197         function createSetAccessorDeclaration(decorators, modifiers, name, parameters, body) {
17198             return createBaseFunctionLikeDeclaration(168, decorators, modifiers, name, undefined, parameters, undefined, body);
17199         }
17200         function updateSetAccessorDeclaration(node, decorators, modifiers, name, parameters, body) {
17201             return node.decorators !== decorators
17202                 || node.modifiers !== modifiers
17203                 || node.name !== name
17204                 || node.parameters !== parameters
17205                 || node.body !== body
17206                 ? updateBaseFunctionLikeDeclaration(createSetAccessorDeclaration(decorators, modifiers, name, parameters, body), node)
17207                 : node;
17208         }
17209         function createCallSignature(typeParameters, parameters, type) {
17210             var node = createBaseSignatureDeclaration(169, undefined, undefined, undefined, typeParameters, parameters, type);
17211             node.transformFlags = 1;
17212             return node;
17213         }
17214         function updateCallSignature(node, typeParameters, parameters, type) {
17215             return node.typeParameters !== typeParameters
17216                 || node.parameters !== parameters
17217                 || node.type !== type
17218                 ? updateBaseSignatureDeclaration(createCallSignature(typeParameters, parameters, type), node)
17219                 : node;
17220         }
17221         function createConstructSignature(typeParameters, parameters, type) {
17222             var node = createBaseSignatureDeclaration(170, undefined, undefined, undefined, typeParameters, parameters, type);
17223             node.transformFlags = 1;
17224             return node;
17225         }
17226         function updateConstructSignature(node, typeParameters, parameters, type) {
17227             return node.typeParameters !== typeParameters
17228                 || node.parameters !== parameters
17229                 || node.type !== type
17230                 ? updateBaseSignatureDeclaration(createConstructSignature(typeParameters, parameters, type), node)
17231                 : node;
17232         }
17233         function createIndexSignature(decorators, modifiers, parameters, type) {
17234             var node = createBaseSignatureDeclaration(171, decorators, modifiers, undefined, undefined, parameters, type);
17235             node.transformFlags = 1;
17236             return node;
17237         }
17238         function updateIndexSignature(node, decorators, modifiers, parameters, type) {
17239             return node.parameters !== parameters
17240                 || node.type !== type
17241                 || node.decorators !== decorators
17242                 || node.modifiers !== modifiers
17243                 ? updateBaseSignatureDeclaration(createIndexSignature(decorators, modifiers, parameters, type), node)
17244                 : node;
17245         }
17246         function createTemplateLiteralTypeSpan(type, literal) {
17247             var node = createBaseNode(194);
17248             node.type = type;
17249             node.literal = literal;
17250             node.transformFlags = 1;
17251             return node;
17252         }
17253         function updateTemplateLiteralTypeSpan(node, type, literal) {
17254             return node.type !== type
17255                 || node.literal !== literal
17256                 ? update(createTemplateLiteralTypeSpan(type, literal), node)
17257                 : node;
17258         }
17259         function createKeywordTypeNode(kind) {
17260             return createToken(kind);
17261         }
17262         function createTypePredicateNode(assertsModifier, parameterName, type) {
17263             var node = createBaseNode(172);
17264             node.assertsModifier = assertsModifier;
17265             node.parameterName = asName(parameterName);
17266             node.type = type;
17267             node.transformFlags = 1;
17268             return node;
17269         }
17270         function updateTypePredicateNode(node, assertsModifier, parameterName, type) {
17271             return node.assertsModifier !== assertsModifier
17272                 || node.parameterName !== parameterName
17273                 || node.type !== type
17274                 ? update(createTypePredicateNode(assertsModifier, parameterName, type), node)
17275                 : node;
17276         }
17277         function createTypeReferenceNode(typeName, typeArguments) {
17278             var node = createBaseNode(173);
17279             node.typeName = asName(typeName);
17280             node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(createNodeArray(typeArguments));
17281             node.transformFlags = 1;
17282             return node;
17283         }
17284         function updateTypeReferenceNode(node, typeName, typeArguments) {
17285             return node.typeName !== typeName
17286                 || node.typeArguments !== typeArguments
17287                 ? update(createTypeReferenceNode(typeName, typeArguments), node)
17288                 : node;
17289         }
17290         function createFunctionTypeNode(typeParameters, parameters, type) {
17291             var node = createBaseSignatureDeclaration(174, undefined, undefined, undefined, typeParameters, parameters, type);
17292             node.transformFlags = 1;
17293             return node;
17294         }
17295         function updateFunctionTypeNode(node, typeParameters, parameters, type) {
17296             return node.typeParameters !== typeParameters
17297                 || node.parameters !== parameters
17298                 || node.type !== type
17299                 ? updateBaseSignatureDeclaration(createFunctionTypeNode(typeParameters, parameters, type), node)
17300                 : node;
17301         }
17302         function createConstructorTypeNode() {
17303             var args = [];
17304             for (var _i = 0; _i < arguments.length; _i++) {
17305                 args[_i] = arguments[_i];
17306             }
17307             return args.length === 4 ? createConstructorTypeNode1.apply(void 0, args) :
17308                 args.length === 3 ? createConstructorTypeNode2.apply(void 0, args) :
17309                     ts.Debug.fail("Incorrect number of arguments specified.");
17310         }
17311         function createConstructorTypeNode1(modifiers, typeParameters, parameters, type) {
17312             var node = createBaseSignatureDeclaration(175, undefined, modifiers, undefined, typeParameters, parameters, type);
17313             node.transformFlags = 1;
17314             return node;
17315         }
17316         function createConstructorTypeNode2(typeParameters, parameters, type) {
17317             return createConstructorTypeNode1(undefined, typeParameters, parameters, type);
17318         }
17319         function updateConstructorTypeNode() {
17320             var args = [];
17321             for (var _i = 0; _i < arguments.length; _i++) {
17322                 args[_i] = arguments[_i];
17323             }
17324             return args.length === 5 ? updateConstructorTypeNode1.apply(void 0, args) :
17325                 args.length === 4 ? updateConstructorTypeNode2.apply(void 0, args) :
17326                     ts.Debug.fail("Incorrect number of arguments specified.");
17327         }
17328         function updateConstructorTypeNode1(node, modifiers, typeParameters, parameters, type) {
17329             return node.modifiers !== modifiers
17330                 || node.typeParameters !== typeParameters
17331                 || node.parameters !== parameters
17332                 || node.type !== type
17333                 ? updateBaseSignatureDeclaration(createConstructorTypeNode(modifiers, typeParameters, parameters, type), node)
17334                 : node;
17335         }
17336         function updateConstructorTypeNode2(node, typeParameters, parameters, type) {
17337             return updateConstructorTypeNode1(node, node.modifiers, typeParameters, parameters, type);
17338         }
17339         function createTypeQueryNode(exprName) {
17340             var node = createBaseNode(176);
17341             node.exprName = exprName;
17342             node.transformFlags = 1;
17343             return node;
17344         }
17345         function updateTypeQueryNode(node, exprName) {
17346             return node.exprName !== exprName
17347                 ? update(createTypeQueryNode(exprName), node)
17348                 : node;
17349         }
17350         function createTypeLiteralNode(members) {
17351             var node = createBaseNode(177);
17352             node.members = createNodeArray(members);
17353             node.transformFlags = 1;
17354             return node;
17355         }
17356         function updateTypeLiteralNode(node, members) {
17357             return node.members !== members
17358                 ? update(createTypeLiteralNode(members), node)
17359                 : node;
17360         }
17361         function createArrayTypeNode(elementType) {
17362             var node = createBaseNode(178);
17363             node.elementType = parenthesizerRules().parenthesizeElementTypeOfArrayType(elementType);
17364             node.transformFlags = 1;
17365             return node;
17366         }
17367         function updateArrayTypeNode(node, elementType) {
17368             return node.elementType !== elementType
17369                 ? update(createArrayTypeNode(elementType), node)
17370                 : node;
17371         }
17372         function createTupleTypeNode(elements) {
17373             var node = createBaseNode(179);
17374             node.elements = createNodeArray(elements);
17375             node.transformFlags = 1;
17376             return node;
17377         }
17378         function updateTupleTypeNode(node, elements) {
17379             return node.elements !== elements
17380                 ? update(createTupleTypeNode(elements), node)
17381                 : node;
17382         }
17383         function createNamedTupleMember(dotDotDotToken, name, questionToken, type) {
17384             var node = createBaseNode(192);
17385             node.dotDotDotToken = dotDotDotToken;
17386             node.name = name;
17387             node.questionToken = questionToken;
17388             node.type = type;
17389             node.transformFlags = 1;
17390             return node;
17391         }
17392         function updateNamedTupleMember(node, dotDotDotToken, name, questionToken, type) {
17393             return node.dotDotDotToken !== dotDotDotToken
17394                 || node.name !== name
17395                 || node.questionToken !== questionToken
17396                 || node.type !== type
17397                 ? update(createNamedTupleMember(dotDotDotToken, name, questionToken, type), node)
17398                 : node;
17399         }
17400         function createOptionalTypeNode(type) {
17401             var node = createBaseNode(180);
17402             node.type = parenthesizerRules().parenthesizeElementTypeOfArrayType(type);
17403             node.transformFlags = 1;
17404             return node;
17405         }
17406         function updateOptionalTypeNode(node, type) {
17407             return node.type !== type
17408                 ? update(createOptionalTypeNode(type), node)
17409                 : node;
17410         }
17411         function createRestTypeNode(type) {
17412             var node = createBaseNode(181);
17413             node.type = type;
17414             node.transformFlags = 1;
17415             return node;
17416         }
17417         function updateRestTypeNode(node, type) {
17418             return node.type !== type
17419                 ? update(createRestTypeNode(type), node)
17420                 : node;
17421         }
17422         function createUnionOrIntersectionTypeNode(kind, types) {
17423             var node = createBaseNode(kind);
17424             node.types = parenthesizerRules().parenthesizeConstituentTypesOfUnionOrIntersectionType(types);
17425             node.transformFlags = 1;
17426             return node;
17427         }
17428         function updateUnionOrIntersectionTypeNode(node, types) {
17429             return node.types !== types
17430                 ? update(createUnionOrIntersectionTypeNode(node.kind, types), node)
17431                 : node;
17432         }
17433         function createUnionTypeNode(types) {
17434             return createUnionOrIntersectionTypeNode(182, types);
17435         }
17436         function updateUnionTypeNode(node, types) {
17437             return updateUnionOrIntersectionTypeNode(node, types);
17438         }
17439         function createIntersectionTypeNode(types) {
17440             return createUnionOrIntersectionTypeNode(183, types);
17441         }
17442         function updateIntersectionTypeNode(node, types) {
17443             return updateUnionOrIntersectionTypeNode(node, types);
17444         }
17445         function createConditionalTypeNode(checkType, extendsType, trueType, falseType) {
17446             var node = createBaseNode(184);
17447             node.checkType = parenthesizerRules().parenthesizeMemberOfConditionalType(checkType);
17448             node.extendsType = parenthesizerRules().parenthesizeMemberOfConditionalType(extendsType);
17449             node.trueType = trueType;
17450             node.falseType = falseType;
17451             node.transformFlags = 1;
17452             return node;
17453         }
17454         function updateConditionalTypeNode(node, checkType, extendsType, trueType, falseType) {
17455             return node.checkType !== checkType
17456                 || node.extendsType !== extendsType
17457                 || node.trueType !== trueType
17458                 || node.falseType !== falseType
17459                 ? update(createConditionalTypeNode(checkType, extendsType, trueType, falseType), node)
17460                 : node;
17461         }
17462         function createInferTypeNode(typeParameter) {
17463             var node = createBaseNode(185);
17464             node.typeParameter = typeParameter;
17465             node.transformFlags = 1;
17466             return node;
17467         }
17468         function updateInferTypeNode(node, typeParameter) {
17469             return node.typeParameter !== typeParameter
17470                 ? update(createInferTypeNode(typeParameter), node)
17471                 : node;
17472         }
17473         function createTemplateLiteralType(head, templateSpans) {
17474             var node = createBaseNode(193);
17475             node.head = head;
17476             node.templateSpans = createNodeArray(templateSpans);
17477             node.transformFlags = 1;
17478             return node;
17479         }
17480         function updateTemplateLiteralType(node, head, templateSpans) {
17481             return node.head !== head
17482                 || node.templateSpans !== templateSpans
17483                 ? update(createTemplateLiteralType(head, templateSpans), node)
17484                 : node;
17485         }
17486         function createImportTypeNode(argument, qualifier, typeArguments, isTypeOf) {
17487             if (isTypeOf === void 0) { isTypeOf = false; }
17488             var node = createBaseNode(195);
17489             node.argument = argument;
17490             node.qualifier = qualifier;
17491             node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
17492             node.isTypeOf = isTypeOf;
17493             node.transformFlags = 1;
17494             return node;
17495         }
17496         function updateImportTypeNode(node, argument, qualifier, typeArguments, isTypeOf) {
17497             if (isTypeOf === void 0) { isTypeOf = node.isTypeOf; }
17498             return node.argument !== argument
17499                 || node.qualifier !== qualifier
17500                 || node.typeArguments !== typeArguments
17501                 || node.isTypeOf !== isTypeOf
17502                 ? update(createImportTypeNode(argument, qualifier, typeArguments, isTypeOf), node)
17503                 : node;
17504         }
17505         function createParenthesizedType(type) {
17506             var node = createBaseNode(186);
17507             node.type = type;
17508             node.transformFlags = 1;
17509             return node;
17510         }
17511         function updateParenthesizedType(node, type) {
17512             return node.type !== type
17513                 ? update(createParenthesizedType(type), node)
17514                 : node;
17515         }
17516         function createThisTypeNode() {
17517             var node = createBaseNode(187);
17518             node.transformFlags = 1;
17519             return node;
17520         }
17521         function createTypeOperatorNode(operator, type) {
17522             var node = createBaseNode(188);
17523             node.operator = operator;
17524             node.type = parenthesizerRules().parenthesizeMemberOfElementType(type);
17525             node.transformFlags = 1;
17526             return node;
17527         }
17528         function updateTypeOperatorNode(node, type) {
17529             return node.type !== type
17530                 ? update(createTypeOperatorNode(node.operator, type), node)
17531                 : node;
17532         }
17533         function createIndexedAccessTypeNode(objectType, indexType) {
17534             var node = createBaseNode(189);
17535             node.objectType = parenthesizerRules().parenthesizeMemberOfElementType(objectType);
17536             node.indexType = indexType;
17537             node.transformFlags = 1;
17538             return node;
17539         }
17540         function updateIndexedAccessTypeNode(node, objectType, indexType) {
17541             return node.objectType !== objectType
17542                 || node.indexType !== indexType
17543                 ? update(createIndexedAccessTypeNode(objectType, indexType), node)
17544                 : node;
17545         }
17546         function createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type) {
17547             var node = createBaseNode(190);
17548             node.readonlyToken = readonlyToken;
17549             node.typeParameter = typeParameter;
17550             node.nameType = nameType;
17551             node.questionToken = questionToken;
17552             node.type = type;
17553             node.transformFlags = 1;
17554             return node;
17555         }
17556         function updateMappedTypeNode(node, readonlyToken, typeParameter, nameType, questionToken, type) {
17557             return node.readonlyToken !== readonlyToken
17558                 || node.typeParameter !== typeParameter
17559                 || node.nameType !== nameType
17560                 || node.questionToken !== questionToken
17561                 || node.type !== type
17562                 ? update(createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type), node)
17563                 : node;
17564         }
17565         function createLiteralTypeNode(literal) {
17566             var node = createBaseNode(191);
17567             node.literal = literal;
17568             node.transformFlags = 1;
17569             return node;
17570         }
17571         function updateLiteralTypeNode(node, literal) {
17572             return node.literal !== literal
17573                 ? update(createLiteralTypeNode(literal), node)
17574                 : node;
17575         }
17576         function createObjectBindingPattern(elements) {
17577             var node = createBaseNode(196);
17578             node.elements = createNodeArray(elements);
17579             node.transformFlags |=
17580                 propagateChildrenFlags(node.elements) |
17581                     256 |
17582                     131072;
17583             if (node.transformFlags & 8192) {
17584                 node.transformFlags |=
17585                     32 |
17586                         16384;
17587             }
17588             return node;
17589         }
17590         function updateObjectBindingPattern(node, elements) {
17591             return node.elements !== elements
17592                 ? update(createObjectBindingPattern(elements), node)
17593                 : node;
17594         }
17595         function createArrayBindingPattern(elements) {
17596             var node = createBaseNode(197);
17597             node.elements = createNodeArray(elements);
17598             node.transformFlags |=
17599                 propagateChildrenFlags(node.elements) |
17600                     256 |
17601                     131072;
17602             return node;
17603         }
17604         function updateArrayBindingPattern(node, elements) {
17605             return node.elements !== elements
17606                 ? update(createArrayBindingPattern(elements), node)
17607                 : node;
17608         }
17609         function createBindingElement(dotDotDotToken, propertyName, name, initializer) {
17610             var node = createBaseBindingLikeDeclaration(198, undefined, undefined, name, initializer);
17611             node.propertyName = asName(propertyName);
17612             node.dotDotDotToken = dotDotDotToken;
17613             node.transformFlags |=
17614                 propagateChildFlags(node.dotDotDotToken) |
17615                     256;
17616             if (node.propertyName) {
17617                 node.transformFlags |= ts.isIdentifier(node.propertyName) ?
17618                     propagateIdentifierNameFlags(node.propertyName) :
17619                     propagateChildFlags(node.propertyName);
17620             }
17621             if (dotDotDotToken)
17622                 node.transformFlags |= 8192;
17623             return node;
17624         }
17625         function updateBindingElement(node, dotDotDotToken, propertyName, name, initializer) {
17626             return node.propertyName !== propertyName
17627                 || node.dotDotDotToken !== dotDotDotToken
17628                 || node.name !== name
17629                 || node.initializer !== initializer
17630                 ? update(createBindingElement(dotDotDotToken, propertyName, name, initializer), node)
17631                 : node;
17632         }
17633         function createBaseExpression(kind) {
17634             var node = createBaseNode(kind);
17635             return node;
17636         }
17637         function createArrayLiteralExpression(elements, multiLine) {
17638             var node = createBaseExpression(199);
17639             node.elements = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(elements));
17640             node.multiLine = multiLine;
17641             node.transformFlags |= propagateChildrenFlags(node.elements);
17642             return node;
17643         }
17644         function updateArrayLiteralExpression(node, elements) {
17645             return node.elements !== elements
17646                 ? update(createArrayLiteralExpression(elements, node.multiLine), node)
17647                 : node;
17648         }
17649         function createObjectLiteralExpression(properties, multiLine) {
17650             var node = createBaseExpression(200);
17651             node.properties = createNodeArray(properties);
17652             node.multiLine = multiLine;
17653             node.transformFlags |= propagateChildrenFlags(node.properties);
17654             return node;
17655         }
17656         function updateObjectLiteralExpression(node, properties) {
17657             return node.properties !== properties
17658                 ? update(createObjectLiteralExpression(properties, node.multiLine), node)
17659                 : node;
17660         }
17661         function createPropertyAccessExpression(expression, name) {
17662             var node = createBaseExpression(201);
17663             node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
17664             node.name = asName(name);
17665             node.transformFlags =
17666                 propagateChildFlags(node.expression) |
17667                     (ts.isIdentifier(node.name) ?
17668                         propagateIdentifierNameFlags(node.name) :
17669                         propagateChildFlags(node.name));
17670             if (ts.isSuperKeyword(expression)) {
17671                 node.transformFlags |=
17672                     64 |
17673                         32;
17674             }
17675             return node;
17676         }
17677         function updatePropertyAccessExpression(node, expression, name) {
17678             if (ts.isPropertyAccessChain(node)) {
17679                 return updatePropertyAccessChain(node, expression, node.questionDotToken, ts.cast(name, ts.isIdentifier));
17680             }
17681             return node.expression !== expression
17682                 || node.name !== name
17683                 ? update(createPropertyAccessExpression(expression, name), node)
17684                 : node;
17685         }
17686         function createPropertyAccessChain(expression, questionDotToken, name) {
17687             var node = createBaseExpression(201);
17688             node.flags |= 32;
17689             node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
17690             node.questionDotToken = questionDotToken;
17691             node.name = asName(name);
17692             node.transformFlags |=
17693                 8 |
17694                     propagateChildFlags(node.expression) |
17695                     propagateChildFlags(node.questionDotToken) |
17696                     (ts.isIdentifier(node.name) ?
17697                         propagateIdentifierNameFlags(node.name) :
17698                         propagateChildFlags(node.name));
17699             return node;
17700         }
17701         function updatePropertyAccessChain(node, expression, questionDotToken, name) {
17702             ts.Debug.assert(!!(node.flags & 32), "Cannot update a PropertyAccessExpression using updatePropertyAccessChain. Use updatePropertyAccess instead.");
17703             return node.expression !== expression
17704                 || node.questionDotToken !== questionDotToken
17705                 || node.name !== name
17706                 ? update(createPropertyAccessChain(expression, questionDotToken, name), node)
17707                 : node;
17708         }
17709         function createElementAccessExpression(expression, index) {
17710             var node = createBaseExpression(202);
17711             node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
17712             node.argumentExpression = asExpression(index);
17713             node.transformFlags |=
17714                 propagateChildFlags(node.expression) |
17715                     propagateChildFlags(node.argumentExpression);
17716             if (ts.isSuperKeyword(expression)) {
17717                 node.transformFlags |=
17718                     64 |
17719                         32;
17720             }
17721             return node;
17722         }
17723         function updateElementAccessExpression(node, expression, argumentExpression) {
17724             if (ts.isElementAccessChain(node)) {
17725                 return updateElementAccessChain(node, expression, node.questionDotToken, argumentExpression);
17726             }
17727             return node.expression !== expression
17728                 || node.argumentExpression !== argumentExpression
17729                 ? update(createElementAccessExpression(expression, argumentExpression), node)
17730                 : node;
17731         }
17732         function createElementAccessChain(expression, questionDotToken, index) {
17733             var node = createBaseExpression(202);
17734             node.flags |= 32;
17735             node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
17736             node.questionDotToken = questionDotToken;
17737             node.argumentExpression = asExpression(index);
17738             node.transformFlags |=
17739                 propagateChildFlags(node.expression) |
17740                     propagateChildFlags(node.questionDotToken) |
17741                     propagateChildFlags(node.argumentExpression) |
17742                     8;
17743             return node;
17744         }
17745         function updateElementAccessChain(node, expression, questionDotToken, argumentExpression) {
17746             ts.Debug.assert(!!(node.flags & 32), "Cannot update a ElementAccessExpression using updateElementAccessChain. Use updateElementAccess instead.");
17747             return node.expression !== expression
17748                 || node.questionDotToken !== questionDotToken
17749                 || node.argumentExpression !== argumentExpression
17750                 ? update(createElementAccessChain(expression, questionDotToken, argumentExpression), node)
17751                 : node;
17752         }
17753         function createCallExpression(expression, typeArguments, argumentsArray) {
17754             var node = createBaseExpression(203);
17755             node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
17756             node.typeArguments = asNodeArray(typeArguments);
17757             node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
17758             node.transformFlags |=
17759                 propagateChildFlags(node.expression) |
17760                     propagateChildrenFlags(node.typeArguments) |
17761                     propagateChildrenFlags(node.arguments);
17762             if (node.typeArguments) {
17763                 node.transformFlags |= 1;
17764             }
17765             if (ts.isImportKeyword(node.expression)) {
17766                 node.transformFlags |= 2097152;
17767             }
17768             else if (ts.isSuperProperty(node.expression)) {
17769                 node.transformFlags |= 4096;
17770             }
17771             return node;
17772         }
17773         function updateCallExpression(node, expression, typeArguments, argumentsArray) {
17774             if (ts.isCallChain(node)) {
17775                 return updateCallChain(node, expression, node.questionDotToken, typeArguments, argumentsArray);
17776             }
17777             return node.expression !== expression
17778                 || node.typeArguments !== typeArguments
17779                 || node.arguments !== argumentsArray
17780                 ? update(createCallExpression(expression, typeArguments, argumentsArray), node)
17781                 : node;
17782         }
17783         function createCallChain(expression, questionDotToken, typeArguments, argumentsArray) {
17784             var node = createBaseExpression(203);
17785             node.flags |= 32;
17786             node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
17787             node.questionDotToken = questionDotToken;
17788             node.typeArguments = asNodeArray(typeArguments);
17789             node.arguments = parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(createNodeArray(argumentsArray));
17790             node.transformFlags |=
17791                 propagateChildFlags(node.expression) |
17792                     propagateChildFlags(node.questionDotToken) |
17793                     propagateChildrenFlags(node.typeArguments) |
17794                     propagateChildrenFlags(node.arguments) |
17795                     8;
17796             if (node.typeArguments) {
17797                 node.transformFlags |= 1;
17798             }
17799             if (ts.isSuperProperty(node.expression)) {
17800                 node.transformFlags |= 4096;
17801             }
17802             return node;
17803         }
17804         function updateCallChain(node, expression, questionDotToken, typeArguments, argumentsArray) {
17805             ts.Debug.assert(!!(node.flags & 32), "Cannot update a CallExpression using updateCallChain. Use updateCall instead.");
17806             return node.expression !== expression
17807                 || node.questionDotToken !== questionDotToken
17808                 || node.typeArguments !== typeArguments
17809                 || node.arguments !== argumentsArray
17810                 ? update(createCallChain(expression, questionDotToken, typeArguments, argumentsArray), node)
17811                 : node;
17812         }
17813         function createNewExpression(expression, typeArguments, argumentsArray) {
17814             var node = createBaseExpression(204);
17815             node.expression = parenthesizerRules().parenthesizeExpressionOfNew(expression);
17816             node.typeArguments = asNodeArray(typeArguments);
17817             node.arguments = argumentsArray ? parenthesizerRules().parenthesizeExpressionsOfCommaDelimitedList(argumentsArray) : undefined;
17818             node.transformFlags |=
17819                 propagateChildFlags(node.expression) |
17820                     propagateChildrenFlags(node.typeArguments) |
17821                     propagateChildrenFlags(node.arguments) |
17822                     8;
17823             if (node.typeArguments) {
17824                 node.transformFlags |= 1;
17825             }
17826             return node;
17827         }
17828         function updateNewExpression(node, expression, typeArguments, argumentsArray) {
17829             return node.expression !== expression
17830                 || node.typeArguments !== typeArguments
17831                 || node.arguments !== argumentsArray
17832                 ? update(createNewExpression(expression, typeArguments, argumentsArray), node)
17833                 : node;
17834         }
17835         function createTaggedTemplateExpression(tag, typeArguments, template) {
17836             var node = createBaseExpression(205);
17837             node.tag = parenthesizerRules().parenthesizeLeftSideOfAccess(tag);
17838             node.typeArguments = asNodeArray(typeArguments);
17839             node.template = template;
17840             node.transformFlags |=
17841                 propagateChildFlags(node.tag) |
17842                     propagateChildrenFlags(node.typeArguments) |
17843                     propagateChildFlags(node.template) |
17844                     256;
17845             if (node.typeArguments) {
17846                 node.transformFlags |= 1;
17847             }
17848             if (ts.hasInvalidEscape(node.template)) {
17849                 node.transformFlags |= 32;
17850             }
17851             return node;
17852         }
17853         function updateTaggedTemplateExpression(node, tag, typeArguments, template) {
17854             return node.tag !== tag
17855                 || node.typeArguments !== typeArguments
17856                 || node.template !== template
17857                 ? update(createTaggedTemplateExpression(tag, typeArguments, template), node)
17858                 : node;
17859         }
17860         function createTypeAssertion(type, expression) {
17861             var node = createBaseExpression(206);
17862             node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression);
17863             node.type = type;
17864             node.transformFlags |=
17865                 propagateChildFlags(node.expression) |
17866                     propagateChildFlags(node.type) |
17867                     1;
17868             return node;
17869         }
17870         function updateTypeAssertion(node, type, expression) {
17871             return node.type !== type
17872                 || node.expression !== expression
17873                 ? update(createTypeAssertion(type, expression), node)
17874                 : node;
17875         }
17876         function createParenthesizedExpression(expression) {
17877             var node = createBaseExpression(207);
17878             node.expression = expression;
17879             node.transformFlags = propagateChildFlags(node.expression);
17880             return node;
17881         }
17882         function updateParenthesizedExpression(node, expression) {
17883             return node.expression !== expression
17884                 ? update(createParenthesizedExpression(expression), node)
17885                 : node;
17886         }
17887         function createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
17888             var node = createBaseFunctionLikeDeclaration(208, undefined, modifiers, name, typeParameters, parameters, type, body);
17889             node.asteriskToken = asteriskToken;
17890             node.transformFlags |= propagateChildFlags(node.asteriskToken);
17891             if (node.typeParameters) {
17892                 node.transformFlags |= 1;
17893             }
17894             if (ts.modifiersToFlags(node.modifiers) & 256) {
17895                 if (node.asteriskToken) {
17896                     node.transformFlags |= 32;
17897                 }
17898                 else {
17899                     node.transformFlags |= 64;
17900                 }
17901             }
17902             else if (node.asteriskToken) {
17903                 node.transformFlags |= 512;
17904             }
17905             return node;
17906         }
17907         function updateFunctionExpression(node, modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
17908             return node.name !== name
17909                 || node.modifiers !== modifiers
17910                 || node.asteriskToken !== asteriskToken
17911                 || node.typeParameters !== typeParameters
17912                 || node.parameters !== parameters
17913                 || node.type !== type
17914                 || node.body !== body
17915                 ? updateBaseFunctionLikeDeclaration(createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body), node)
17916                 : node;
17917         }
17918         function createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) {
17919             var node = createBaseFunctionLikeDeclaration(209, undefined, modifiers, undefined, typeParameters, parameters, type, parenthesizerRules().parenthesizeConciseBodyOfArrowFunction(body));
17920             node.equalsGreaterThanToken = equalsGreaterThanToken !== null && equalsGreaterThanToken !== void 0 ? equalsGreaterThanToken : createToken(38);
17921             node.transformFlags |=
17922                 propagateChildFlags(node.equalsGreaterThanToken) |
17923                     256;
17924             if (ts.modifiersToFlags(node.modifiers) & 256) {
17925                 node.transformFlags |= 64;
17926             }
17927             return node;
17928         }
17929         function updateArrowFunction(node, modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body) {
17930             return node.modifiers !== modifiers
17931                 || node.typeParameters !== typeParameters
17932                 || node.parameters !== parameters
17933                 || node.type !== type
17934                 || node.equalsGreaterThanToken !== equalsGreaterThanToken
17935                 || node.body !== body
17936                 ? updateBaseFunctionLikeDeclaration(createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body), node)
17937                 : node;
17938         }
17939         function createDeleteExpression(expression) {
17940             var node = createBaseExpression(210);
17941             node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression);
17942             node.transformFlags |= propagateChildFlags(node.expression);
17943             return node;
17944         }
17945         function updateDeleteExpression(node, expression) {
17946             return node.expression !== expression
17947                 ? update(createDeleteExpression(expression), node)
17948                 : node;
17949         }
17950         function createTypeOfExpression(expression) {
17951             var node = createBaseExpression(211);
17952             node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression);
17953             node.transformFlags |= propagateChildFlags(node.expression);
17954             return node;
17955         }
17956         function updateTypeOfExpression(node, expression) {
17957             return node.expression !== expression
17958                 ? update(createTypeOfExpression(expression), node)
17959                 : node;
17960         }
17961         function createVoidExpression(expression) {
17962             var node = createBaseExpression(212);
17963             node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression);
17964             node.transformFlags |= propagateChildFlags(node.expression);
17965             return node;
17966         }
17967         function updateVoidExpression(node, expression) {
17968             return node.expression !== expression
17969                 ? update(createVoidExpression(expression), node)
17970                 : node;
17971         }
17972         function createAwaitExpression(expression) {
17973             var node = createBaseExpression(213);
17974             node.expression = parenthesizerRules().parenthesizeOperandOfPrefixUnary(expression);
17975             node.transformFlags |=
17976                 propagateChildFlags(node.expression) |
17977                     64 |
17978                     32 |
17979                     524288;
17980             return node;
17981         }
17982         function updateAwaitExpression(node, expression) {
17983             return node.expression !== expression
17984                 ? update(createAwaitExpression(expression), node)
17985                 : node;
17986         }
17987         function createPrefixUnaryExpression(operator, operand) {
17988             var node = createBaseExpression(214);
17989             node.operator = operator;
17990             node.operand = parenthesizerRules().parenthesizeOperandOfPrefixUnary(operand);
17991             node.transformFlags |= propagateChildFlags(node.operand);
17992             return node;
17993         }
17994         function updatePrefixUnaryExpression(node, operand) {
17995             return node.operand !== operand
17996                 ? update(createPrefixUnaryExpression(node.operator, operand), node)
17997                 : node;
17998         }
17999         function createPostfixUnaryExpression(operand, operator) {
18000             var node = createBaseExpression(215);
18001             node.operator = operator;
18002             node.operand = parenthesizerRules().parenthesizeOperandOfPostfixUnary(operand);
18003             node.transformFlags = propagateChildFlags(node.operand);
18004             return node;
18005         }
18006         function updatePostfixUnaryExpression(node, operand) {
18007             return node.operand !== operand
18008                 ? update(createPostfixUnaryExpression(operand, node.operator), node)
18009                 : node;
18010         }
18011         function createBinaryExpression(left, operator, right) {
18012             var node = createBaseExpression(216);
18013             var operatorToken = asToken(operator);
18014             var operatorKind = operatorToken.kind;
18015             node.left = parenthesizerRules().parenthesizeLeftSideOfBinary(operatorKind, left);
18016             node.operatorToken = operatorToken;
18017             node.right = parenthesizerRules().parenthesizeRightSideOfBinary(operatorKind, node.left, right);
18018             node.transformFlags |=
18019                 propagateChildFlags(node.left) |
18020                     propagateChildFlags(node.operatorToken) |
18021                     propagateChildFlags(node.right);
18022             if (operatorKind === 60) {
18023                 node.transformFlags |= 8;
18024             }
18025             else if (operatorKind === 62) {
18026                 if (ts.isObjectLiteralExpression(node.left)) {
18027                     node.transformFlags |=
18028                         256 |
18029                             32 |
18030                             1024 |
18031                             propagateAssignmentPatternFlags(node.left);
18032                 }
18033                 else if (ts.isArrayLiteralExpression(node.left)) {
18034                     node.transformFlags |=
18035                         256 |
18036                             1024 |
18037                             propagateAssignmentPatternFlags(node.left);
18038                 }
18039             }
18040             else if (operatorKind === 42 || operatorKind === 66) {
18041                 node.transformFlags |= 128;
18042             }
18043             else if (ts.isLogicalOrCoalescingAssignmentOperator(operatorKind)) {
18044                 node.transformFlags |= 4;
18045             }
18046             return node;
18047         }
18048         function propagateAssignmentPatternFlags(node) {
18049             if (node.transformFlags & 16384)
18050                 return 16384;
18051             if (node.transformFlags & 32) {
18052                 for (var _i = 0, _a = ts.getElementsOfBindingOrAssignmentPattern(node); _i < _a.length; _i++) {
18053                     var element = _a[_i];
18054                     var target = ts.getTargetOfBindingOrAssignmentElement(element);
18055                     if (target && ts.isAssignmentPattern(target)) {
18056                         if (target.transformFlags & 16384) {
18057                             return 16384;
18058                         }
18059                         if (target.transformFlags & 32) {
18060                             var flags_1 = propagateAssignmentPatternFlags(target);
18061                             if (flags_1)
18062                                 return flags_1;
18063                         }
18064                     }
18065                 }
18066             }
18067             return 0;
18068         }
18069         function updateBinaryExpression(node, left, operator, right) {
18070             return node.left !== left
18071                 || node.operatorToken !== operator
18072                 || node.right !== right
18073                 ? update(createBinaryExpression(left, operator, right), node)
18074                 : node;
18075         }
18076         function createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse) {
18077             var node = createBaseExpression(217);
18078             node.condition = parenthesizerRules().parenthesizeConditionOfConditionalExpression(condition);
18079             node.questionToken = questionToken !== null && questionToken !== void 0 ? questionToken : createToken(57);
18080             node.whenTrue = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenTrue);
18081             node.colonToken = colonToken !== null && colonToken !== void 0 ? colonToken : createToken(58);
18082             node.whenFalse = parenthesizerRules().parenthesizeBranchOfConditionalExpression(whenFalse);
18083             node.transformFlags |=
18084                 propagateChildFlags(node.condition) |
18085                     propagateChildFlags(node.questionToken) |
18086                     propagateChildFlags(node.whenTrue) |
18087                     propagateChildFlags(node.colonToken) |
18088                     propagateChildFlags(node.whenFalse);
18089             return node;
18090         }
18091         function updateConditionalExpression(node, condition, questionToken, whenTrue, colonToken, whenFalse) {
18092             return node.condition !== condition
18093                 || node.questionToken !== questionToken
18094                 || node.whenTrue !== whenTrue
18095                 || node.colonToken !== colonToken
18096                 || node.whenFalse !== whenFalse
18097                 ? update(createConditionalExpression(condition, questionToken, whenTrue, colonToken, whenFalse), node)
18098                 : node;
18099         }
18100         function createTemplateExpression(head, templateSpans) {
18101             var node = createBaseExpression(218);
18102             node.head = head;
18103             node.templateSpans = createNodeArray(templateSpans);
18104             node.transformFlags |=
18105                 propagateChildFlags(node.head) |
18106                     propagateChildrenFlags(node.templateSpans) |
18107                     256;
18108             return node;
18109         }
18110         function updateTemplateExpression(node, head, templateSpans) {
18111             return node.head !== head
18112                 || node.templateSpans !== templateSpans
18113                 ? update(createTemplateExpression(head, templateSpans), node)
18114                 : node;
18115         }
18116         function createTemplateLiteralLikeNodeChecked(kind, text, rawText, templateFlags) {
18117             if (templateFlags === void 0) { templateFlags = 0; }
18118             ts.Debug.assert(!(templateFlags & ~2048), "Unsupported template flags.");
18119             var cooked = undefined;
18120             if (rawText !== undefined && rawText !== text) {
18121                 cooked = getCookedText(kind, rawText);
18122                 if (typeof cooked === "object") {
18123                     return ts.Debug.fail("Invalid raw text");
18124                 }
18125             }
18126             if (text === undefined) {
18127                 if (cooked === undefined) {
18128                     return ts.Debug.fail("Arguments 'text' and 'rawText' may not both be undefined.");
18129                 }
18130                 text = cooked;
18131             }
18132             else if (cooked !== undefined) {
18133                 ts.Debug.assert(text === cooked, "Expected argument 'text' to be the normalized (i.e. 'cooked') version of argument 'rawText'.");
18134             }
18135             return createTemplateLiteralLikeNode(kind, text, rawText, templateFlags);
18136         }
18137         function createTemplateLiteralLikeNode(kind, text, rawText, templateFlags) {
18138             var node = createBaseToken(kind);
18139             node.text = text;
18140             node.rawText = rawText;
18141             node.templateFlags = templateFlags & 2048;
18142             node.transformFlags |= 256;
18143             if (node.templateFlags) {
18144                 node.transformFlags |= 32;
18145             }
18146             return node;
18147         }
18148         function createTemplateHead(text, rawText, templateFlags) {
18149             return createTemplateLiteralLikeNodeChecked(15, text, rawText, templateFlags);
18150         }
18151         function createTemplateMiddle(text, rawText, templateFlags) {
18152             return createTemplateLiteralLikeNodeChecked(16, text, rawText, templateFlags);
18153         }
18154         function createTemplateTail(text, rawText, templateFlags) {
18155             return createTemplateLiteralLikeNodeChecked(17, text, rawText, templateFlags);
18156         }
18157         function createNoSubstitutionTemplateLiteral(text, rawText, templateFlags) {
18158             return createTemplateLiteralLikeNodeChecked(14, text, rawText, templateFlags);
18159         }
18160         function createYieldExpression(asteriskToken, expression) {
18161             ts.Debug.assert(!asteriskToken || !!expression, "A `YieldExpression` with an asteriskToken must have an expression.");
18162             var node = createBaseExpression(219);
18163             node.expression = expression && parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
18164             node.asteriskToken = asteriskToken;
18165             node.transformFlags |=
18166                 propagateChildFlags(node.expression) |
18167                     propagateChildFlags(node.asteriskToken) |
18168                     256 |
18169                     32 |
18170                     262144;
18171             return node;
18172         }
18173         function updateYieldExpression(node, asteriskToken, expression) {
18174             return node.expression !== expression
18175                 || node.asteriskToken !== asteriskToken
18176                 ? update(createYieldExpression(asteriskToken, expression), node)
18177                 : node;
18178         }
18179         function createSpreadElement(expression) {
18180             var node = createBaseExpression(220);
18181             node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
18182             node.transformFlags |=
18183                 propagateChildFlags(node.expression) |
18184                     256 |
18185                     8192;
18186             return node;
18187         }
18188         function updateSpreadElement(node, expression) {
18189             return node.expression !== expression
18190                 ? update(createSpreadElement(expression), node)
18191                 : node;
18192         }
18193         function createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members) {
18194             var node = createBaseClassLikeDeclaration(221, decorators, modifiers, name, typeParameters, heritageClauses, members);
18195             node.transformFlags |= 256;
18196             return node;
18197         }
18198         function updateClassExpression(node, decorators, modifiers, name, typeParameters, heritageClauses, members) {
18199             return node.decorators !== decorators
18200                 || node.modifiers !== modifiers
18201                 || node.name !== name
18202                 || node.typeParameters !== typeParameters
18203                 || node.heritageClauses !== heritageClauses
18204                 || node.members !== members
18205                 ? update(createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members), node)
18206                 : node;
18207         }
18208         function createOmittedExpression() {
18209             return createBaseExpression(222);
18210         }
18211         function createExpressionWithTypeArguments(expression, typeArguments) {
18212             var node = createBaseNode(223);
18213             node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
18214             node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments);
18215             node.transformFlags |=
18216                 propagateChildFlags(node.expression) |
18217                     propagateChildrenFlags(node.typeArguments) |
18218                     256;
18219             return node;
18220         }
18221         function updateExpressionWithTypeArguments(node, expression, typeArguments) {
18222             return node.expression !== expression
18223                 || node.typeArguments !== typeArguments
18224                 ? update(createExpressionWithTypeArguments(expression, typeArguments), node)
18225                 : node;
18226         }
18227         function createAsExpression(expression, type) {
18228             var node = createBaseExpression(224);
18229             node.expression = expression;
18230             node.type = type;
18231             node.transformFlags |=
18232                 propagateChildFlags(node.expression) |
18233                     propagateChildFlags(node.type) |
18234                     1;
18235             return node;
18236         }
18237         function updateAsExpression(node, expression, type) {
18238             return node.expression !== expression
18239                 || node.type !== type
18240                 ? update(createAsExpression(expression, type), node)
18241                 : node;
18242         }
18243         function createNonNullExpression(expression) {
18244             var node = createBaseExpression(225);
18245             node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
18246             node.transformFlags |=
18247                 propagateChildFlags(node.expression) |
18248                     1;
18249             return node;
18250         }
18251         function updateNonNullExpression(node, expression) {
18252             if (ts.isNonNullChain(node)) {
18253                 return updateNonNullChain(node, expression);
18254             }
18255             return node.expression !== expression
18256                 ? update(createNonNullExpression(expression), node)
18257                 : node;
18258         }
18259         function createNonNullChain(expression) {
18260             var node = createBaseExpression(225);
18261             node.flags |= 32;
18262             node.expression = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
18263             node.transformFlags |=
18264                 propagateChildFlags(node.expression) |
18265                     1;
18266             return node;
18267         }
18268         function updateNonNullChain(node, expression) {
18269             ts.Debug.assert(!!(node.flags & 32), "Cannot update a NonNullExpression using updateNonNullChain. Use updateNonNullExpression instead.");
18270             return node.expression !== expression
18271                 ? update(createNonNullChain(expression), node)
18272                 : node;
18273         }
18274         function createMetaProperty(keywordToken, name) {
18275             var node = createBaseExpression(226);
18276             node.keywordToken = keywordToken;
18277             node.name = name;
18278             node.transformFlags |= propagateChildFlags(node.name);
18279             switch (keywordToken) {
18280                 case 102:
18281                     node.transformFlags |= 256;
18282                     break;
18283                 case 99:
18284                     node.transformFlags |= 4;
18285                     break;
18286                 default:
18287                     return ts.Debug.assertNever(keywordToken);
18288             }
18289             return node;
18290         }
18291         function updateMetaProperty(node, name) {
18292             return node.name !== name
18293                 ? update(createMetaProperty(node.keywordToken, name), node)
18294                 : node;
18295         }
18296         function createTemplateSpan(expression, literal) {
18297             var node = createBaseNode(228);
18298             node.expression = expression;
18299             node.literal = literal;
18300             node.transformFlags |=
18301                 propagateChildFlags(node.expression) |
18302                     propagateChildFlags(node.literal) |
18303                     256;
18304             return node;
18305         }
18306         function updateTemplateSpan(node, expression, literal) {
18307             return node.expression !== expression
18308                 || node.literal !== literal
18309                 ? update(createTemplateSpan(expression, literal), node)
18310                 : node;
18311         }
18312         function createSemicolonClassElement() {
18313             var node = createBaseNode(229);
18314             node.transformFlags |= 256;
18315             return node;
18316         }
18317         function createBlock(statements, multiLine) {
18318             var node = createBaseNode(230);
18319             node.statements = createNodeArray(statements);
18320             node.multiLine = multiLine;
18321             node.transformFlags |= propagateChildrenFlags(node.statements);
18322             return node;
18323         }
18324         function updateBlock(node, statements) {
18325             return node.statements !== statements
18326                 ? update(createBlock(statements, node.multiLine), node)
18327                 : node;
18328         }
18329         function createVariableStatement(modifiers, declarationList) {
18330             var node = createBaseDeclaration(232, undefined, modifiers);
18331             node.declarationList = ts.isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList;
18332             node.transformFlags |=
18333                 propagateChildFlags(node.declarationList);
18334             if (ts.modifiersToFlags(node.modifiers) & 2) {
18335                 node.transformFlags = 1;
18336             }
18337             return node;
18338         }
18339         function updateVariableStatement(node, modifiers, declarationList) {
18340             return node.modifiers !== modifiers
18341                 || node.declarationList !== declarationList
18342                 ? update(createVariableStatement(modifiers, declarationList), node)
18343                 : node;
18344         }
18345         function createEmptyStatement() {
18346             return createBaseNode(231);
18347         }
18348         function createExpressionStatement(expression) {
18349             var node = createBaseNode(233);
18350             node.expression = parenthesizerRules().parenthesizeExpressionOfExpressionStatement(expression);
18351             node.transformFlags |= propagateChildFlags(node.expression);
18352             return node;
18353         }
18354         function updateExpressionStatement(node, expression) {
18355             return node.expression !== expression
18356                 ? update(createExpressionStatement(expression), node)
18357                 : node;
18358         }
18359         function createIfStatement(expression, thenStatement, elseStatement) {
18360             var node = createBaseNode(234);
18361             node.expression = expression;
18362             node.thenStatement = asEmbeddedStatement(thenStatement);
18363             node.elseStatement = asEmbeddedStatement(elseStatement);
18364             node.transformFlags |=
18365                 propagateChildFlags(node.expression) |
18366                     propagateChildFlags(node.thenStatement) |
18367                     propagateChildFlags(node.elseStatement);
18368             return node;
18369         }
18370         function updateIfStatement(node, expression, thenStatement, elseStatement) {
18371             return node.expression !== expression
18372                 || node.thenStatement !== thenStatement
18373                 || node.elseStatement !== elseStatement
18374                 ? update(createIfStatement(expression, thenStatement, elseStatement), node)
18375                 : node;
18376         }
18377         function createDoStatement(statement, expression) {
18378             var node = createBaseNode(235);
18379             node.statement = asEmbeddedStatement(statement);
18380             node.expression = expression;
18381             node.transformFlags |=
18382                 propagateChildFlags(node.statement) |
18383                     propagateChildFlags(node.expression);
18384             return node;
18385         }
18386         function updateDoStatement(node, statement, expression) {
18387             return node.statement !== statement
18388                 || node.expression !== expression
18389                 ? update(createDoStatement(statement, expression), node)
18390                 : node;
18391         }
18392         function createWhileStatement(expression, statement) {
18393             var node = createBaseNode(236);
18394             node.expression = expression;
18395             node.statement = asEmbeddedStatement(statement);
18396             node.transformFlags |=
18397                 propagateChildFlags(node.expression) |
18398                     propagateChildFlags(node.statement);
18399             return node;
18400         }
18401         function updateWhileStatement(node, expression, statement) {
18402             return node.expression !== expression
18403                 || node.statement !== statement
18404                 ? update(createWhileStatement(expression, statement), node)
18405                 : node;
18406         }
18407         function createForStatement(initializer, condition, incrementor, statement) {
18408             var node = createBaseNode(237);
18409             node.initializer = initializer;
18410             node.condition = condition;
18411             node.incrementor = incrementor;
18412             node.statement = asEmbeddedStatement(statement);
18413             node.transformFlags |=
18414                 propagateChildFlags(node.initializer) |
18415                     propagateChildFlags(node.condition) |
18416                     propagateChildFlags(node.incrementor) |
18417                     propagateChildFlags(node.statement);
18418             return node;
18419         }
18420         function updateForStatement(node, initializer, condition, incrementor, statement) {
18421             return node.initializer !== initializer
18422                 || node.condition !== condition
18423                 || node.incrementor !== incrementor
18424                 || node.statement !== statement
18425                 ? update(createForStatement(initializer, condition, incrementor, statement), node)
18426                 : node;
18427         }
18428         function createForInStatement(initializer, expression, statement) {
18429             var node = createBaseNode(238);
18430             node.initializer = initializer;
18431             node.expression = expression;
18432             node.statement = asEmbeddedStatement(statement);
18433             node.transformFlags |=
18434                 propagateChildFlags(node.initializer) |
18435                     propagateChildFlags(node.expression) |
18436                     propagateChildFlags(node.statement);
18437             return node;
18438         }
18439         function updateForInStatement(node, initializer, expression, statement) {
18440             return node.initializer !== initializer
18441                 || node.expression !== expression
18442                 || node.statement !== statement
18443                 ? update(createForInStatement(initializer, expression, statement), node)
18444                 : node;
18445         }
18446         function createForOfStatement(awaitModifier, initializer, expression, statement) {
18447             var node = createBaseNode(239);
18448             node.awaitModifier = awaitModifier;
18449             node.initializer = initializer;
18450             node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
18451             node.statement = asEmbeddedStatement(statement);
18452             node.transformFlags |=
18453                 propagateChildFlags(node.awaitModifier) |
18454                     propagateChildFlags(node.initializer) |
18455                     propagateChildFlags(node.expression) |
18456                     propagateChildFlags(node.statement) |
18457                     256;
18458             if (awaitModifier)
18459                 node.transformFlags |= 32;
18460             return node;
18461         }
18462         function updateForOfStatement(node, awaitModifier, initializer, expression, statement) {
18463             return node.awaitModifier !== awaitModifier
18464                 || node.initializer !== initializer
18465                 || node.expression !== expression
18466                 || node.statement !== statement
18467                 ? update(createForOfStatement(awaitModifier, initializer, expression, statement), node)
18468                 : node;
18469         }
18470         function createContinueStatement(label) {
18471             var node = createBaseNode(240);
18472             node.label = asName(label);
18473             node.transformFlags |=
18474                 propagateChildFlags(node.label) |
18475                     1048576;
18476             return node;
18477         }
18478         function updateContinueStatement(node, label) {
18479             return node.label !== label
18480                 ? update(createContinueStatement(label), node)
18481                 : node;
18482         }
18483         function createBreakStatement(label) {
18484             var node = createBaseNode(241);
18485             node.label = asName(label);
18486             node.transformFlags |=
18487                 propagateChildFlags(node.label) |
18488                     1048576;
18489             return node;
18490         }
18491         function updateBreakStatement(node, label) {
18492             return node.label !== label
18493                 ? update(createBreakStatement(label), node)
18494                 : node;
18495         }
18496         function createReturnStatement(expression) {
18497             var node = createBaseNode(242);
18498             node.expression = expression;
18499             node.transformFlags |=
18500                 propagateChildFlags(node.expression) |
18501                     32 |
18502                     1048576;
18503             return node;
18504         }
18505         function updateReturnStatement(node, expression) {
18506             return node.expression !== expression
18507                 ? update(createReturnStatement(expression), node)
18508                 : node;
18509         }
18510         function createWithStatement(expression, statement) {
18511             var node = createBaseNode(243);
18512             node.expression = expression;
18513             node.statement = asEmbeddedStatement(statement);
18514             node.transformFlags |=
18515                 propagateChildFlags(node.expression) |
18516                     propagateChildFlags(node.statement);
18517             return node;
18518         }
18519         function updateWithStatement(node, expression, statement) {
18520             return node.expression !== expression
18521                 || node.statement !== statement
18522                 ? update(createWithStatement(expression, statement), node)
18523                 : node;
18524         }
18525         function createSwitchStatement(expression, caseBlock) {
18526             var node = createBaseNode(244);
18527             node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
18528             node.caseBlock = caseBlock;
18529             node.transformFlags |=
18530                 propagateChildFlags(node.expression) |
18531                     propagateChildFlags(node.caseBlock);
18532             return node;
18533         }
18534         function updateSwitchStatement(node, expression, caseBlock) {
18535             return node.expression !== expression
18536                 || node.caseBlock !== caseBlock
18537                 ? update(createSwitchStatement(expression, caseBlock), node)
18538                 : node;
18539         }
18540         function createLabeledStatement(label, statement) {
18541             var node = createBaseNode(245);
18542             node.label = asName(label);
18543             node.statement = asEmbeddedStatement(statement);
18544             node.transformFlags |=
18545                 propagateChildFlags(node.label) |
18546                     propagateChildFlags(node.statement);
18547             return node;
18548         }
18549         function updateLabeledStatement(node, label, statement) {
18550             return node.label !== label
18551                 || node.statement !== statement
18552                 ? update(createLabeledStatement(label, statement), node)
18553                 : node;
18554         }
18555         function createThrowStatement(expression) {
18556             var node = createBaseNode(246);
18557             node.expression = expression;
18558             node.transformFlags |= propagateChildFlags(node.expression);
18559             return node;
18560         }
18561         function updateThrowStatement(node, expression) {
18562             return node.expression !== expression
18563                 ? update(createThrowStatement(expression), node)
18564                 : node;
18565         }
18566         function createTryStatement(tryBlock, catchClause, finallyBlock) {
18567             var node = createBaseNode(247);
18568             node.tryBlock = tryBlock;
18569             node.catchClause = catchClause;
18570             node.finallyBlock = finallyBlock;
18571             node.transformFlags |=
18572                 propagateChildFlags(node.tryBlock) |
18573                     propagateChildFlags(node.catchClause) |
18574                     propagateChildFlags(node.finallyBlock);
18575             return node;
18576         }
18577         function updateTryStatement(node, tryBlock, catchClause, finallyBlock) {
18578             return node.tryBlock !== tryBlock
18579                 || node.catchClause !== catchClause
18580                 || node.finallyBlock !== finallyBlock
18581                 ? update(createTryStatement(tryBlock, catchClause, finallyBlock), node)
18582                 : node;
18583         }
18584         function createDebuggerStatement() {
18585             return createBaseNode(248);
18586         }
18587         function createVariableDeclaration(name, exclamationToken, type, initializer) {
18588             var node = createBaseVariableLikeDeclaration(249, undefined, undefined, name, type, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer));
18589             node.exclamationToken = exclamationToken;
18590             node.transformFlags |= propagateChildFlags(node.exclamationToken);
18591             if (exclamationToken) {
18592                 node.transformFlags |= 1;
18593             }
18594             return node;
18595         }
18596         function updateVariableDeclaration(node, name, exclamationToken, type, initializer) {
18597             return node.name !== name
18598                 || node.type !== type
18599                 || node.exclamationToken !== exclamationToken
18600                 || node.initializer !== initializer
18601                 ? update(createVariableDeclaration(name, exclamationToken, type, initializer), node)
18602                 : node;
18603         }
18604         function createVariableDeclarationList(declarations, flags) {
18605             if (flags === void 0) { flags = 0; }
18606             var node = createBaseNode(250);
18607             node.flags |= flags & 3;
18608             node.declarations = createNodeArray(declarations);
18609             node.transformFlags |=
18610                 propagateChildrenFlags(node.declarations) |
18611                     1048576;
18612             if (flags & 3) {
18613                 node.transformFlags |=
18614                     256 |
18615                         65536;
18616             }
18617             return node;
18618         }
18619         function updateVariableDeclarationList(node, declarations) {
18620             return node.declarations !== declarations
18621                 ? update(createVariableDeclarationList(declarations, node.flags), node)
18622                 : node;
18623         }
18624         function createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
18625             var node = createBaseFunctionLikeDeclaration(251, decorators, modifiers, name, typeParameters, parameters, type, body);
18626             node.asteriskToken = asteriskToken;
18627             if (!node.body || ts.modifiersToFlags(node.modifiers) & 2) {
18628                 node.transformFlags = 1;
18629             }
18630             else {
18631                 node.transformFlags |=
18632                     propagateChildFlags(node.asteriskToken) |
18633                         1048576;
18634                 if (ts.modifiersToFlags(node.modifiers) & 256) {
18635                     if (node.asteriskToken) {
18636                         node.transformFlags |= 32;
18637                     }
18638                     else {
18639                         node.transformFlags |= 64;
18640                     }
18641                 }
18642                 else if (node.asteriskToken) {
18643                     node.transformFlags |= 512;
18644                 }
18645             }
18646             return node;
18647         }
18648         function updateFunctionDeclaration(node, decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body) {
18649             return node.decorators !== decorators
18650                 || node.modifiers !== modifiers
18651                 || node.asteriskToken !== asteriskToken
18652                 || node.name !== name
18653                 || node.typeParameters !== typeParameters
18654                 || node.parameters !== parameters
18655                 || node.type !== type
18656                 || node.body !== body
18657                 ? updateBaseFunctionLikeDeclaration(createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body), node)
18658                 : node;
18659         }
18660         function createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) {
18661             var node = createBaseClassLikeDeclaration(252, decorators, modifiers, name, typeParameters, heritageClauses, members);
18662             if (ts.modifiersToFlags(node.modifiers) & 2) {
18663                 node.transformFlags = 1;
18664             }
18665             else {
18666                 node.transformFlags |= 256;
18667                 if (node.transformFlags & 2048) {
18668                     node.transformFlags |= 1;
18669                 }
18670             }
18671             return node;
18672         }
18673         function updateClassDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) {
18674             return node.decorators !== decorators
18675                 || node.modifiers !== modifiers
18676                 || node.name !== name
18677                 || node.typeParameters !== typeParameters
18678                 || node.heritageClauses !== heritageClauses
18679                 || node.members !== members
18680                 ? update(createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node)
18681                 : node;
18682         }
18683         function createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) {
18684             var node = createBaseInterfaceOrClassLikeDeclaration(253, decorators, modifiers, name, typeParameters, heritageClauses);
18685             node.members = createNodeArray(members);
18686             node.transformFlags = 1;
18687             return node;
18688         }
18689         function updateInterfaceDeclaration(node, decorators, modifiers, name, typeParameters, heritageClauses, members) {
18690             return node.decorators !== decorators
18691                 || node.modifiers !== modifiers
18692                 || node.name !== name
18693                 || node.typeParameters !== typeParameters
18694                 || node.heritageClauses !== heritageClauses
18695                 || node.members !== members
18696                 ? update(createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node)
18697                 : node;
18698         }
18699         function createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type) {
18700             var node = createBaseGenericNamedDeclaration(254, decorators, modifiers, name, typeParameters);
18701             node.type = type;
18702             node.transformFlags = 1;
18703             return node;
18704         }
18705         function updateTypeAliasDeclaration(node, decorators, modifiers, name, typeParameters, type) {
18706             return node.decorators !== decorators
18707                 || node.modifiers !== modifiers
18708                 || node.name !== name
18709                 || node.typeParameters !== typeParameters
18710                 || node.type !== type
18711                 ? update(createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type), node)
18712                 : node;
18713         }
18714         function createEnumDeclaration(decorators, modifiers, name, members) {
18715             var node = createBaseNamedDeclaration(255, decorators, modifiers, name);
18716             node.members = createNodeArray(members);
18717             node.transformFlags |=
18718                 propagateChildrenFlags(node.members) |
18719                     1;
18720             node.transformFlags &= ~8388608;
18721             return node;
18722         }
18723         function updateEnumDeclaration(node, decorators, modifiers, name, members) {
18724             return node.decorators !== decorators
18725                 || node.modifiers !== modifiers
18726                 || node.name !== name
18727                 || node.members !== members
18728                 ? update(createEnumDeclaration(decorators, modifiers, name, members), node)
18729                 : node;
18730         }
18731         function createModuleDeclaration(decorators, modifiers, name, body, flags) {
18732             if (flags === void 0) { flags = 0; }
18733             var node = createBaseDeclaration(256, decorators, modifiers);
18734             node.flags |= flags & (16 | 4 | 1024);
18735             node.name = name;
18736             node.body = body;
18737             if (ts.modifiersToFlags(node.modifiers) & 2) {
18738                 node.transformFlags = 1;
18739             }
18740             else {
18741                 node.transformFlags |=
18742                     propagateChildFlags(node.name) |
18743                         propagateChildFlags(node.body) |
18744                         1;
18745             }
18746             node.transformFlags &= ~8388608;
18747             return node;
18748         }
18749         function updateModuleDeclaration(node, decorators, modifiers, name, body) {
18750             return node.decorators !== decorators
18751                 || node.modifiers !== modifiers
18752                 || node.name !== name
18753                 || node.body !== body
18754                 ? update(createModuleDeclaration(decorators, modifiers, name, body, node.flags), node)
18755                 : node;
18756         }
18757         function createModuleBlock(statements) {
18758             var node = createBaseNode(257);
18759             node.statements = createNodeArray(statements);
18760             node.transformFlags |= propagateChildrenFlags(node.statements);
18761             return node;
18762         }
18763         function updateModuleBlock(node, statements) {
18764             return node.statements !== statements
18765                 ? update(createModuleBlock(statements), node)
18766                 : node;
18767         }
18768         function createCaseBlock(clauses) {
18769             var node = createBaseNode(258);
18770             node.clauses = createNodeArray(clauses);
18771             node.transformFlags |= propagateChildrenFlags(node.clauses);
18772             return node;
18773         }
18774         function updateCaseBlock(node, clauses) {
18775             return node.clauses !== clauses
18776                 ? update(createCaseBlock(clauses), node)
18777                 : node;
18778         }
18779         function createNamespaceExportDeclaration(name) {
18780             var node = createBaseNamedDeclaration(259, undefined, undefined, name);
18781             node.transformFlags = 1;
18782             return node;
18783         }
18784         function updateNamespaceExportDeclaration(node, name) {
18785             return node.name !== name
18786                 ? update(createNamespaceExportDeclaration(name), node)
18787                 : node;
18788         }
18789         function createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference) {
18790             var node = createBaseNamedDeclaration(260, decorators, modifiers, name);
18791             node.isTypeOnly = isTypeOnly;
18792             node.moduleReference = moduleReference;
18793             node.transformFlags |= propagateChildFlags(node.moduleReference);
18794             if (!ts.isExternalModuleReference(node.moduleReference))
18795                 node.transformFlags |= 1;
18796             node.transformFlags &= ~8388608;
18797             return node;
18798         }
18799         function updateImportEqualsDeclaration(node, decorators, modifiers, isTypeOnly, name, moduleReference) {
18800             return node.decorators !== decorators
18801                 || node.modifiers !== modifiers
18802                 || node.isTypeOnly !== isTypeOnly
18803                 || node.name !== name
18804                 || node.moduleReference !== moduleReference
18805                 ? update(createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference), node)
18806                 : node;
18807         }
18808         function createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier) {
18809             var node = createBaseDeclaration(261, decorators, modifiers);
18810             node.importClause = importClause;
18811             node.moduleSpecifier = moduleSpecifier;
18812             node.transformFlags |=
18813                 propagateChildFlags(node.importClause) |
18814                     propagateChildFlags(node.moduleSpecifier);
18815             node.transformFlags &= ~8388608;
18816             return node;
18817         }
18818         function updateImportDeclaration(node, decorators, modifiers, importClause, moduleSpecifier) {
18819             return node.decorators !== decorators
18820                 || node.modifiers !== modifiers
18821                 || node.importClause !== importClause
18822                 || node.moduleSpecifier !== moduleSpecifier
18823                 ? update(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier), node)
18824                 : node;
18825         }
18826         function createImportClause(isTypeOnly, name, namedBindings) {
18827             var node = createBaseNode(262);
18828             node.isTypeOnly = isTypeOnly;
18829             node.name = name;
18830             node.namedBindings = namedBindings;
18831             node.transformFlags |=
18832                 propagateChildFlags(node.name) |
18833                     propagateChildFlags(node.namedBindings);
18834             if (isTypeOnly) {
18835                 node.transformFlags |= 1;
18836             }
18837             node.transformFlags &= ~8388608;
18838             return node;
18839         }
18840         function updateImportClause(node, isTypeOnly, name, namedBindings) {
18841             return node.isTypeOnly !== isTypeOnly
18842                 || node.name !== name
18843                 || node.namedBindings !== namedBindings
18844                 ? update(createImportClause(isTypeOnly, name, namedBindings), node)
18845                 : node;
18846         }
18847         function createNamespaceImport(name) {
18848             var node = createBaseNode(263);
18849             node.name = name;
18850             node.transformFlags |= propagateChildFlags(node.name);
18851             node.transformFlags &= ~8388608;
18852             return node;
18853         }
18854         function updateNamespaceImport(node, name) {
18855             return node.name !== name
18856                 ? update(createNamespaceImport(name), node)
18857                 : node;
18858         }
18859         function createNamespaceExport(name) {
18860             var node = createBaseNode(269);
18861             node.name = name;
18862             node.transformFlags |=
18863                 propagateChildFlags(node.name) |
18864                     4;
18865             node.transformFlags &= ~8388608;
18866             return node;
18867         }
18868         function updateNamespaceExport(node, name) {
18869             return node.name !== name
18870                 ? update(createNamespaceExport(name), node)
18871                 : node;
18872         }
18873         function createNamedImports(elements) {
18874             var node = createBaseNode(264);
18875             node.elements = createNodeArray(elements);
18876             node.transformFlags |= propagateChildrenFlags(node.elements);
18877             node.transformFlags &= ~8388608;
18878             return node;
18879         }
18880         function updateNamedImports(node, elements) {
18881             return node.elements !== elements
18882                 ? update(createNamedImports(elements), node)
18883                 : node;
18884         }
18885         function createImportSpecifier(propertyName, name) {
18886             var node = createBaseNode(265);
18887             node.propertyName = propertyName;
18888             node.name = name;
18889             node.transformFlags |=
18890                 propagateChildFlags(node.propertyName) |
18891                     propagateChildFlags(node.name);
18892             node.transformFlags &= ~8388608;
18893             return node;
18894         }
18895         function updateImportSpecifier(node, propertyName, name) {
18896             return node.propertyName !== propertyName
18897                 || node.name !== name
18898                 ? update(createImportSpecifier(propertyName, name), node)
18899                 : node;
18900         }
18901         function createExportAssignment(decorators, modifiers, isExportEquals, expression) {
18902             var node = createBaseDeclaration(266, decorators, modifiers);
18903             node.isExportEquals = isExportEquals;
18904             node.expression = isExportEquals
18905                 ? parenthesizerRules().parenthesizeRightSideOfBinary(62, undefined, expression)
18906                 : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression);
18907             node.transformFlags |= propagateChildFlags(node.expression);
18908             node.transformFlags &= ~8388608;
18909             return node;
18910         }
18911         function updateExportAssignment(node, decorators, modifiers, expression) {
18912             return node.decorators !== decorators
18913                 || node.modifiers !== modifiers
18914                 || node.expression !== expression
18915                 ? update(createExportAssignment(decorators, modifiers, node.isExportEquals, expression), node)
18916                 : node;
18917         }
18918         function createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier) {
18919             var node = createBaseDeclaration(267, decorators, modifiers);
18920             node.isTypeOnly = isTypeOnly;
18921             node.exportClause = exportClause;
18922             node.moduleSpecifier = moduleSpecifier;
18923             node.transformFlags |=
18924                 propagateChildFlags(node.exportClause) |
18925                     propagateChildFlags(node.moduleSpecifier);
18926             node.transformFlags &= ~8388608;
18927             return node;
18928         }
18929         function updateExportDeclaration(node, decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier) {
18930             return node.decorators !== decorators
18931                 || node.modifiers !== modifiers
18932                 || node.isTypeOnly !== isTypeOnly
18933                 || node.exportClause !== exportClause
18934                 || node.moduleSpecifier !== moduleSpecifier
18935                 ? update(createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier), node)
18936                 : node;
18937         }
18938         function createNamedExports(elements) {
18939             var node = createBaseNode(268);
18940             node.elements = createNodeArray(elements);
18941             node.transformFlags |= propagateChildrenFlags(node.elements);
18942             node.transformFlags &= ~8388608;
18943             return node;
18944         }
18945         function updateNamedExports(node, elements) {
18946             return node.elements !== elements
18947                 ? update(createNamedExports(elements), node)
18948                 : node;
18949         }
18950         function createExportSpecifier(propertyName, name) {
18951             var node = createBaseNode(270);
18952             node.propertyName = asName(propertyName);
18953             node.name = asName(name);
18954             node.transformFlags |=
18955                 propagateChildFlags(node.propertyName) |
18956                     propagateChildFlags(node.name);
18957             node.transformFlags &= ~8388608;
18958             return node;
18959         }
18960         function updateExportSpecifier(node, propertyName, name) {
18961             return node.propertyName !== propertyName
18962                 || node.name !== name
18963                 ? update(createExportSpecifier(propertyName, name), node)
18964                 : node;
18965         }
18966         function createMissingDeclaration() {
18967             var node = createBaseDeclaration(271, undefined, undefined);
18968             return node;
18969         }
18970         function createExternalModuleReference(expression) {
18971             var node = createBaseNode(272);
18972             node.expression = expression;
18973             node.transformFlags |= propagateChildFlags(node.expression);
18974             node.transformFlags &= ~8388608;
18975             return node;
18976         }
18977         function updateExternalModuleReference(node, expression) {
18978             return node.expression !== expression
18979                 ? update(createExternalModuleReference(expression), node)
18980                 : node;
18981         }
18982         function createJSDocPrimaryTypeWorker(kind) {
18983             return createBaseNode(kind);
18984         }
18985         function createJSDocUnaryTypeWorker(kind, type) {
18986             var node = createBaseNode(kind);
18987             node.type = type;
18988             return node;
18989         }
18990         function updateJSDocUnaryTypeWorker(kind, node, type) {
18991             return node.type !== type
18992                 ? update(createJSDocUnaryTypeWorker(kind, type), node)
18993                 : node;
18994         }
18995         function createJSDocFunctionType(parameters, type) {
18996             var node = createBaseSignatureDeclaration(308, undefined, undefined, undefined, undefined, parameters, type);
18997             return node;
18998         }
18999         function updateJSDocFunctionType(node, parameters, type) {
19000             return node.parameters !== parameters
19001                 || node.type !== type
19002                 ? update(createJSDocFunctionType(parameters, type), node)
19003                 : node;
19004         }
19005         function createJSDocTypeLiteral(propertyTags, isArrayType) {
19006             if (isArrayType === void 0) { isArrayType = false; }
19007             var node = createBaseNode(312);
19008             node.jsDocPropertyTags = asNodeArray(propertyTags);
19009             node.isArrayType = isArrayType;
19010             return node;
19011         }
19012         function updateJSDocTypeLiteral(node, propertyTags, isArrayType) {
19013             return node.jsDocPropertyTags !== propertyTags
19014                 || node.isArrayType !== isArrayType
19015                 ? update(createJSDocTypeLiteral(propertyTags, isArrayType), node)
19016                 : node;
19017         }
19018         function createJSDocTypeExpression(type) {
19019             var node = createBaseNode(301);
19020             node.type = type;
19021             return node;
19022         }
19023         function updateJSDocTypeExpression(node, type) {
19024             return node.type !== type
19025                 ? update(createJSDocTypeExpression(type), node)
19026                 : node;
19027         }
19028         function createJSDocSignature(typeParameters, parameters, type) {
19029             var node = createBaseNode(313);
19030             node.typeParameters = asNodeArray(typeParameters);
19031             node.parameters = createNodeArray(parameters);
19032             node.type = type;
19033             return node;
19034         }
19035         function updateJSDocSignature(node, typeParameters, parameters, type) {
19036             return node.typeParameters !== typeParameters
19037                 || node.parameters !== parameters
19038                 || node.type !== type
19039                 ? update(createJSDocSignature(typeParameters, parameters, type), node)
19040                 : node;
19041         }
19042         function getDefaultTagName(node) {
19043             var defaultTagName = getDefaultTagNameForKind(node.kind);
19044             return node.tagName.escapedText === ts.escapeLeadingUnderscores(defaultTagName)
19045                 ? node.tagName
19046                 : createIdentifier(defaultTagName);
19047         }
19048         function createBaseJSDocTag(kind, tagName, comment) {
19049             var node = createBaseNode(kind);
19050             node.tagName = tagName;
19051             node.comment = comment;
19052             return node;
19053         }
19054         function createJSDocTemplateTag(tagName, constraint, typeParameters, comment) {
19055             var node = createBaseJSDocTag(330, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("template"), comment);
19056             node.constraint = constraint;
19057             node.typeParameters = createNodeArray(typeParameters);
19058             return node;
19059         }
19060         function updateJSDocTemplateTag(node, tagName, constraint, typeParameters, comment) {
19061             if (tagName === void 0) { tagName = getDefaultTagName(node); }
19062             return node.tagName !== tagName
19063                 || node.constraint !== constraint
19064                 || node.typeParameters !== typeParameters
19065                 || node.comment !== comment
19066                 ? update(createJSDocTemplateTag(tagName, constraint, typeParameters, comment), node)
19067                 : node;
19068         }
19069         function createJSDocTypedefTag(tagName, typeExpression, fullName, comment) {
19070             var node = createBaseJSDocTag(331, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("typedef"), comment);
19071             node.typeExpression = typeExpression;
19072             node.fullName = fullName;
19073             node.name = ts.getJSDocTypeAliasName(fullName);
19074             return node;
19075         }
19076         function updateJSDocTypedefTag(node, tagName, typeExpression, fullName, comment) {
19077             if (tagName === void 0) { tagName = getDefaultTagName(node); }
19078             return node.tagName !== tagName
19079                 || node.typeExpression !== typeExpression
19080                 || node.fullName !== fullName
19081                 || node.comment !== comment
19082                 ? update(createJSDocTypedefTag(tagName, typeExpression, fullName, comment), node)
19083                 : node;
19084         }
19085         function createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) {
19086             var node = createBaseJSDocTag(326, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("param"), comment);
19087             node.typeExpression = typeExpression;
19088             node.name = name;
19089             node.isNameFirst = !!isNameFirst;
19090             node.isBracketed = isBracketed;
19091             return node;
19092         }
19093         function updateJSDocParameterTag(node, tagName, name, isBracketed, typeExpression, isNameFirst, comment) {
19094             if (tagName === void 0) { tagName = getDefaultTagName(node); }
19095             return node.tagName !== tagName
19096                 || node.name !== name
19097                 || node.isBracketed !== isBracketed
19098                 || node.typeExpression !== typeExpression
19099                 || node.isNameFirst !== isNameFirst
19100                 || node.comment !== comment
19101                 ? update(createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment), node)
19102                 : node;
19103         }
19104         function createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment) {
19105             var node = createBaseJSDocTag(333, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("prop"), comment);
19106             node.typeExpression = typeExpression;
19107             node.name = name;
19108             node.isNameFirst = !!isNameFirst;
19109             node.isBracketed = isBracketed;
19110             return node;
19111         }
19112         function updateJSDocPropertyTag(node, tagName, name, isBracketed, typeExpression, isNameFirst, comment) {
19113             if (tagName === void 0) { tagName = getDefaultTagName(node); }
19114             return node.tagName !== tagName
19115                 || node.name !== name
19116                 || node.isBracketed !== isBracketed
19117                 || node.typeExpression !== typeExpression
19118                 || node.isNameFirst !== isNameFirst
19119                 || node.comment !== comment
19120                 ? update(createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment), node)
19121                 : node;
19122         }
19123         function createJSDocCallbackTag(tagName, typeExpression, fullName, comment) {
19124             var node = createBaseJSDocTag(324, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("callback"), comment);
19125             node.typeExpression = typeExpression;
19126             node.fullName = fullName;
19127             node.name = ts.getJSDocTypeAliasName(fullName);
19128             return node;
19129         }
19130         function updateJSDocCallbackTag(node, tagName, typeExpression, fullName, comment) {
19131             if (tagName === void 0) { tagName = getDefaultTagName(node); }
19132             return node.tagName !== tagName
19133                 || node.typeExpression !== typeExpression
19134                 || node.fullName !== fullName
19135                 || node.comment !== comment
19136                 ? update(createJSDocCallbackTag(tagName, typeExpression, fullName, comment), node)
19137                 : node;
19138         }
19139         function createJSDocAugmentsTag(tagName, className, comment) {
19140             var node = createBaseJSDocTag(315, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("augments"), comment);
19141             node.class = className;
19142             return node;
19143         }
19144         function updateJSDocAugmentsTag(node, tagName, className, comment) {
19145             if (tagName === void 0) { tagName = getDefaultTagName(node); }
19146             return node.tagName !== tagName
19147                 || node.class !== className
19148                 || node.comment !== comment
19149                 ? update(createJSDocAugmentsTag(tagName, className, comment), node)
19150                 : node;
19151         }
19152         function createJSDocImplementsTag(tagName, className, comment) {
19153             var node = createBaseJSDocTag(316, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("implements"), comment);
19154             node.class = className;
19155             return node;
19156         }
19157         function createJSDocSeeTag(tagName, name, comment) {
19158             var node = createBaseJSDocTag(332, tagName !== null && tagName !== void 0 ? tagName : createIdentifier("see"), comment);
19159             node.name = name;
19160             return node;
19161         }
19162         function updateJSDocSeeTag(node, tagName, name, comment) {
19163             return node.tagName !== tagName
19164                 || node.name !== name
19165                 || node.comment !== comment
19166                 ? update(createJSDocSeeTag(tagName, name, comment), node)
19167                 : node;
19168         }
19169         function createJSDocNameReference(name) {
19170             var node = createBaseNode(302);
19171             node.name = name;
19172             return node;
19173         }
19174         function updateJSDocNameReference(node, name) {
19175             return node.name !== name
19176                 ? update(createJSDocNameReference(name), node)
19177                 : node;
19178         }
19179         function updateJSDocImplementsTag(node, tagName, className, comment) {
19180             if (tagName === void 0) { tagName = getDefaultTagName(node); }
19181             return node.tagName !== tagName
19182                 || node.class !== className
19183                 || node.comment !== comment
19184                 ? update(createJSDocImplementsTag(tagName, className, comment), node)
19185                 : node;
19186         }
19187         function createJSDocSimpleTagWorker(kind, tagName, comment) {
19188             var node = createBaseJSDocTag(kind, tagName !== null && tagName !== void 0 ? tagName : createIdentifier(getDefaultTagNameForKind(kind)), comment);
19189             return node;
19190         }
19191         function updateJSDocSimpleTagWorker(kind, node, tagName, comment) {
19192             if (tagName === void 0) { tagName = getDefaultTagName(node); }
19193             return node.tagName !== tagName
19194                 || node.comment !== comment
19195                 ? update(createJSDocSimpleTagWorker(kind, tagName, comment), node) :
19196                 node;
19197         }
19198         function createJSDocTypeLikeTagWorker(kind, tagName, typeExpression, comment) {
19199             var node = createBaseJSDocTag(kind, tagName !== null && tagName !== void 0 ? tagName : createIdentifier(getDefaultTagNameForKind(kind)), comment);
19200             node.typeExpression = typeExpression;
19201             return node;
19202         }
19203         function updateJSDocTypeLikeTagWorker(kind, node, tagName, typeExpression, comment) {
19204             if (tagName === void 0) { tagName = getDefaultTagName(node); }
19205             return node.tagName !== tagName
19206                 || node.typeExpression !== typeExpression
19207                 || node.comment !== comment
19208                 ? update(createJSDocTypeLikeTagWorker(kind, tagName, typeExpression, comment), node)
19209                 : node;
19210         }
19211         function createJSDocUnknownTag(tagName, comment) {
19212             var node = createBaseJSDocTag(314, tagName, comment);
19213             return node;
19214         }
19215         function updateJSDocUnknownTag(node, tagName, comment) {
19216             return node.tagName !== tagName
19217                 || node.comment !== comment
19218                 ? update(createJSDocUnknownTag(tagName, comment), node)
19219                 : node;
19220         }
19221         function createJSDocComment(comment, tags) {
19222             var node = createBaseNode(311);
19223             node.comment = comment;
19224             node.tags = asNodeArray(tags);
19225             return node;
19226         }
19227         function updateJSDocComment(node, comment, tags) {
19228             return node.comment !== comment
19229                 || node.tags !== tags
19230                 ? update(createJSDocComment(comment, tags), node)
19231                 : node;
19232         }
19233         function createJsxElement(openingElement, children, closingElement) {
19234             var node = createBaseNode(273);
19235             node.openingElement = openingElement;
19236             node.children = createNodeArray(children);
19237             node.closingElement = closingElement;
19238             node.transformFlags |=
19239                 propagateChildFlags(node.openingElement) |
19240                     propagateChildrenFlags(node.children) |
19241                     propagateChildFlags(node.closingElement) |
19242                     2;
19243             return node;
19244         }
19245         function updateJsxElement(node, openingElement, children, closingElement) {
19246             return node.openingElement !== openingElement
19247                 || node.children !== children
19248                 || node.closingElement !== closingElement
19249                 ? update(createJsxElement(openingElement, children, closingElement), node)
19250                 : node;
19251         }
19252         function createJsxSelfClosingElement(tagName, typeArguments, attributes) {
19253             var node = createBaseNode(274);
19254             node.tagName = tagName;
19255             node.typeArguments = asNodeArray(typeArguments);
19256             node.attributes = attributes;
19257             node.transformFlags |=
19258                 propagateChildFlags(node.tagName) |
19259                     propagateChildrenFlags(node.typeArguments) |
19260                     propagateChildFlags(node.attributes) |
19261                     2;
19262             if (node.typeArguments) {
19263                 node.transformFlags |= 1;
19264             }
19265             return node;
19266         }
19267         function updateJsxSelfClosingElement(node, tagName, typeArguments, attributes) {
19268             return node.tagName !== tagName
19269                 || node.typeArguments !== typeArguments
19270                 || node.attributes !== attributes
19271                 ? update(createJsxSelfClosingElement(tagName, typeArguments, attributes), node)
19272                 : node;
19273         }
19274         function createJsxOpeningElement(tagName, typeArguments, attributes) {
19275             var node = createBaseNode(275);
19276             node.tagName = tagName;
19277             node.typeArguments = asNodeArray(typeArguments);
19278             node.attributes = attributes;
19279             node.transformFlags |=
19280                 propagateChildFlags(node.tagName) |
19281                     propagateChildrenFlags(node.typeArguments) |
19282                     propagateChildFlags(node.attributes) |
19283                     2;
19284             if (typeArguments) {
19285                 node.transformFlags |= 1;
19286             }
19287             return node;
19288         }
19289         function updateJsxOpeningElement(node, tagName, typeArguments, attributes) {
19290             return node.tagName !== tagName
19291                 || node.typeArguments !== typeArguments
19292                 || node.attributes !== attributes
19293                 ? update(createJsxOpeningElement(tagName, typeArguments, attributes), node)
19294                 : node;
19295         }
19296         function createJsxClosingElement(tagName) {
19297             var node = createBaseNode(276);
19298             node.tagName = tagName;
19299             node.transformFlags |=
19300                 propagateChildFlags(node.tagName) |
19301                     2;
19302             return node;
19303         }
19304         function updateJsxClosingElement(node, tagName) {
19305             return node.tagName !== tagName
19306                 ? update(createJsxClosingElement(tagName), node)
19307                 : node;
19308         }
19309         function createJsxFragment(openingFragment, children, closingFragment) {
19310             var node = createBaseNode(277);
19311             node.openingFragment = openingFragment;
19312             node.children = createNodeArray(children);
19313             node.closingFragment = closingFragment;
19314             node.transformFlags |=
19315                 propagateChildFlags(node.openingFragment) |
19316                     propagateChildrenFlags(node.children) |
19317                     propagateChildFlags(node.closingFragment) |
19318                     2;
19319             return node;
19320         }
19321         function updateJsxFragment(node, openingFragment, children, closingFragment) {
19322             return node.openingFragment !== openingFragment
19323                 || node.children !== children
19324                 || node.closingFragment !== closingFragment
19325                 ? update(createJsxFragment(openingFragment, children, closingFragment), node)
19326                 : node;
19327         }
19328         function createJsxText(text, containsOnlyTriviaWhiteSpaces) {
19329             var node = createBaseNode(11);
19330             node.text = text;
19331             node.containsOnlyTriviaWhiteSpaces = !!containsOnlyTriviaWhiteSpaces;
19332             node.transformFlags |= 2;
19333             return node;
19334         }
19335         function updateJsxText(node, text, containsOnlyTriviaWhiteSpaces) {
19336             return node.text !== text
19337                 || node.containsOnlyTriviaWhiteSpaces !== containsOnlyTriviaWhiteSpaces
19338                 ? update(createJsxText(text, containsOnlyTriviaWhiteSpaces), node)
19339                 : node;
19340         }
19341         function createJsxOpeningFragment() {
19342             var node = createBaseNode(278);
19343             node.transformFlags |= 2;
19344             return node;
19345         }
19346         function createJsxJsxClosingFragment() {
19347             var node = createBaseNode(279);
19348             node.transformFlags |= 2;
19349             return node;
19350         }
19351         function createJsxAttribute(name, initializer) {
19352             var node = createBaseNode(280);
19353             node.name = name;
19354             node.initializer = initializer;
19355             node.transformFlags |=
19356                 propagateChildFlags(node.name) |
19357                     propagateChildFlags(node.initializer) |
19358                     2;
19359             return node;
19360         }
19361         function updateJsxAttribute(node, name, initializer) {
19362             return node.name !== name
19363                 || node.initializer !== initializer
19364                 ? update(createJsxAttribute(name, initializer), node)
19365                 : node;
19366         }
19367         function createJsxAttributes(properties) {
19368             var node = createBaseNode(281);
19369             node.properties = createNodeArray(properties);
19370             node.transformFlags |=
19371                 propagateChildrenFlags(node.properties) |
19372                     2;
19373             return node;
19374         }
19375         function updateJsxAttributes(node, properties) {
19376             return node.properties !== properties
19377                 ? update(createJsxAttributes(properties), node)
19378                 : node;
19379         }
19380         function createJsxSpreadAttribute(expression) {
19381             var node = createBaseNode(282);
19382             node.expression = expression;
19383             node.transformFlags |=
19384                 propagateChildFlags(node.expression) |
19385                     2;
19386             return node;
19387         }
19388         function updateJsxSpreadAttribute(node, expression) {
19389             return node.expression !== expression
19390                 ? update(createJsxSpreadAttribute(expression), node)
19391                 : node;
19392         }
19393         function createJsxExpression(dotDotDotToken, expression) {
19394             var node = createBaseNode(283);
19395             node.dotDotDotToken = dotDotDotToken;
19396             node.expression = expression;
19397             node.transformFlags |=
19398                 propagateChildFlags(node.dotDotDotToken) |
19399                     propagateChildFlags(node.expression) |
19400                     2;
19401             return node;
19402         }
19403         function updateJsxExpression(node, expression) {
19404             return node.expression !== expression
19405                 ? update(createJsxExpression(node.dotDotDotToken, expression), node)
19406                 : node;
19407         }
19408         function createCaseClause(expression, statements) {
19409             var node = createBaseNode(284);
19410             node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
19411             node.statements = createNodeArray(statements);
19412             node.transformFlags |=
19413                 propagateChildFlags(node.expression) |
19414                     propagateChildrenFlags(node.statements);
19415             return node;
19416         }
19417         function updateCaseClause(node, expression, statements) {
19418             return node.expression !== expression
19419                 || node.statements !== statements
19420                 ? update(createCaseClause(expression, statements), node)
19421                 : node;
19422         }
19423         function createDefaultClause(statements) {
19424             var node = createBaseNode(285);
19425             node.statements = createNodeArray(statements);
19426             node.transformFlags = propagateChildrenFlags(node.statements);
19427             return node;
19428         }
19429         function updateDefaultClause(node, statements) {
19430             return node.statements !== statements
19431                 ? update(createDefaultClause(statements), node)
19432                 : node;
19433         }
19434         function createHeritageClause(token, types) {
19435             var node = createBaseNode(286);
19436             node.token = token;
19437             node.types = createNodeArray(types);
19438             node.transformFlags |= propagateChildrenFlags(node.types);
19439             switch (token) {
19440                 case 93:
19441                     node.transformFlags |= 256;
19442                     break;
19443                 case 116:
19444                     node.transformFlags |= 1;
19445                     break;
19446                 default:
19447                     return ts.Debug.assertNever(token);
19448             }
19449             return node;
19450         }
19451         function updateHeritageClause(node, types) {
19452             return node.types !== types
19453                 ? update(createHeritageClause(node.token, types), node)
19454                 : node;
19455         }
19456         function createCatchClause(variableDeclaration, block) {
19457             var node = createBaseNode(287);
19458             variableDeclaration = !ts.isString(variableDeclaration) ? variableDeclaration : createVariableDeclaration(variableDeclaration, undefined, undefined, undefined);
19459             node.variableDeclaration = variableDeclaration;
19460             node.block = block;
19461             node.transformFlags |=
19462                 propagateChildFlags(node.variableDeclaration) |
19463                     propagateChildFlags(node.block);
19464             if (!variableDeclaration)
19465                 node.transformFlags |= 16;
19466             return node;
19467         }
19468         function updateCatchClause(node, variableDeclaration, block) {
19469             return node.variableDeclaration !== variableDeclaration
19470                 || node.block !== block
19471                 ? update(createCatchClause(variableDeclaration, block), node)
19472                 : node;
19473         }
19474         function createPropertyAssignment(name, initializer) {
19475             var node = createBaseNamedDeclaration(288, undefined, undefined, name);
19476             node.initializer = parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer);
19477             node.transformFlags |=
19478                 propagateChildFlags(node.name) |
19479                     propagateChildFlags(node.initializer);
19480             return node;
19481         }
19482         function finishUpdatePropertyAssignment(updated, original) {
19483             if (original.decorators)
19484                 updated.decorators = original.decorators;
19485             if (original.modifiers)
19486                 updated.modifiers = original.modifiers;
19487             if (original.questionToken)
19488                 updated.questionToken = original.questionToken;
19489             if (original.exclamationToken)
19490                 updated.exclamationToken = original.exclamationToken;
19491             return update(updated, original);
19492         }
19493         function updatePropertyAssignment(node, name, initializer) {
19494             return node.name !== name
19495                 || node.initializer !== initializer
19496                 ? finishUpdatePropertyAssignment(createPropertyAssignment(name, initializer), node)
19497                 : node;
19498         }
19499         function createShorthandPropertyAssignment(name, objectAssignmentInitializer) {
19500             var node = createBaseNamedDeclaration(289, undefined, undefined, name);
19501             node.objectAssignmentInitializer = objectAssignmentInitializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(objectAssignmentInitializer);
19502             node.transformFlags |=
19503                 propagateChildFlags(node.objectAssignmentInitializer) |
19504                     256;
19505             return node;
19506         }
19507         function finishUpdateShorthandPropertyAssignment(updated, original) {
19508             if (original.decorators)
19509                 updated.decorators = original.decorators;
19510             if (original.modifiers)
19511                 updated.modifiers = original.modifiers;
19512             if (original.equalsToken)
19513                 updated.equalsToken = original.equalsToken;
19514             if (original.questionToken)
19515                 updated.questionToken = original.questionToken;
19516             if (original.exclamationToken)
19517                 updated.exclamationToken = original.exclamationToken;
19518             return update(updated, original);
19519         }
19520         function updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer) {
19521             return node.name !== name
19522                 || node.objectAssignmentInitializer !== objectAssignmentInitializer
19523                 ? finishUpdateShorthandPropertyAssignment(createShorthandPropertyAssignment(name, objectAssignmentInitializer), node)
19524                 : node;
19525         }
19526         function createSpreadAssignment(expression) {
19527             var node = createBaseNode(290);
19528             node.expression = parenthesizerRules().parenthesizeExpressionForDisallowedComma(expression);
19529             node.transformFlags |=
19530                 propagateChildFlags(node.expression) |
19531                     32 |
19532                     16384;
19533             return node;
19534         }
19535         function updateSpreadAssignment(node, expression) {
19536             return node.expression !== expression
19537                 ? update(createSpreadAssignment(expression), node)
19538                 : node;
19539         }
19540         function createEnumMember(name, initializer) {
19541             var node = createBaseNode(291);
19542             node.name = asName(name);
19543             node.initializer = initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer);
19544             node.transformFlags |=
19545                 propagateChildFlags(node.name) |
19546                     propagateChildFlags(node.initializer) |
19547                     1;
19548             return node;
19549         }
19550         function updateEnumMember(node, name, initializer) {
19551             return node.name !== name
19552                 || node.initializer !== initializer
19553                 ? update(createEnumMember(name, initializer), node)
19554                 : node;
19555         }
19556         function createSourceFile(statements, endOfFileToken, flags) {
19557             var node = baseFactory.createBaseSourceFileNode(297);
19558             node.statements = createNodeArray(statements);
19559             node.endOfFileToken = endOfFileToken;
19560             node.flags |= flags;
19561             node.fileName = "";
19562             node.text = "";
19563             node.languageVersion = 0;
19564             node.languageVariant = 0;
19565             node.scriptKind = 0;
19566             node.isDeclarationFile = false;
19567             node.hasNoDefaultLib = false;
19568             node.transformFlags |=
19569                 propagateChildrenFlags(node.statements) |
19570                     propagateChildFlags(node.endOfFileToken);
19571             return node;
19572         }
19573         function cloneSourceFileWithChanges(source, statements, isDeclarationFile, referencedFiles, typeReferences, hasNoDefaultLib, libReferences) {
19574             var node = baseFactory.createBaseSourceFileNode(297);
19575             for (var p in source) {
19576                 if (p === "emitNode" || ts.hasProperty(node, p) || !ts.hasProperty(source, p))
19577                     continue;
19578                 node[p] = source[p];
19579             }
19580             node.flags |= source.flags;
19581             node.statements = createNodeArray(statements);
19582             node.endOfFileToken = source.endOfFileToken;
19583             node.isDeclarationFile = isDeclarationFile;
19584             node.referencedFiles = referencedFiles;
19585             node.typeReferenceDirectives = typeReferences;
19586             node.hasNoDefaultLib = hasNoDefaultLib;
19587             node.libReferenceDirectives = libReferences;
19588             node.transformFlags =
19589                 propagateChildrenFlags(node.statements) |
19590                     propagateChildFlags(node.endOfFileToken);
19591             return node;
19592         }
19593         function updateSourceFile(node, statements, isDeclarationFile, referencedFiles, typeReferenceDirectives, hasNoDefaultLib, libReferenceDirectives) {
19594             if (isDeclarationFile === void 0) { isDeclarationFile = node.isDeclarationFile; }
19595             if (referencedFiles === void 0) { referencedFiles = node.referencedFiles; }
19596             if (typeReferenceDirectives === void 0) { typeReferenceDirectives = node.typeReferenceDirectives; }
19597             if (hasNoDefaultLib === void 0) { hasNoDefaultLib = node.hasNoDefaultLib; }
19598             if (libReferenceDirectives === void 0) { libReferenceDirectives = node.libReferenceDirectives; }
19599             return node.statements !== statements
19600                 || node.isDeclarationFile !== isDeclarationFile
19601                 || node.referencedFiles !== referencedFiles
19602                 || node.typeReferenceDirectives !== typeReferenceDirectives
19603                 || node.hasNoDefaultLib !== hasNoDefaultLib
19604                 || node.libReferenceDirectives !== libReferenceDirectives
19605                 ? update(cloneSourceFileWithChanges(node, statements, isDeclarationFile, referencedFiles, typeReferenceDirectives, hasNoDefaultLib, libReferenceDirectives), node)
19606                 : node;
19607         }
19608         function createBundle(sourceFiles, prepends) {
19609             if (prepends === void 0) { prepends = ts.emptyArray; }
19610             var node = createBaseNode(298);
19611             node.prepends = prepends;
19612             node.sourceFiles = sourceFiles;
19613             return node;
19614         }
19615         function updateBundle(node, sourceFiles, prepends) {
19616             if (prepends === void 0) { prepends = ts.emptyArray; }
19617             return node.sourceFiles !== sourceFiles
19618                 || node.prepends !== prepends
19619                 ? update(createBundle(sourceFiles, prepends), node)
19620                 : node;
19621         }
19622         function createUnparsedSource(prologues, syntheticReferences, texts) {
19623             var node = createBaseNode(299);
19624             node.prologues = prologues;
19625             node.syntheticReferences = syntheticReferences;
19626             node.texts = texts;
19627             node.fileName = "";
19628             node.text = "";
19629             node.referencedFiles = ts.emptyArray;
19630             node.libReferenceDirectives = ts.emptyArray;
19631             node.getLineAndCharacterOfPosition = function (pos) { return ts.getLineAndCharacterOfPosition(node, pos); };
19632             return node;
19633         }
19634         function createBaseUnparsedNode(kind, data) {
19635             var node = createBaseNode(kind);
19636             node.data = data;
19637             return node;
19638         }
19639         function createUnparsedPrologue(data) {
19640             return createBaseUnparsedNode(292, data);
19641         }
19642         function createUnparsedPrepend(data, texts) {
19643             var node = createBaseUnparsedNode(293, data);
19644             node.texts = texts;
19645             return node;
19646         }
19647         function createUnparsedTextLike(data, internal) {
19648             return createBaseUnparsedNode(internal ? 295 : 294, data);
19649         }
19650         function createUnparsedSyntheticReference(section) {
19651             var node = createBaseNode(296);
19652             node.data = section.data;
19653             node.section = section;
19654             return node;
19655         }
19656         function createInputFiles() {
19657             var node = createBaseNode(300);
19658             node.javascriptText = "";
19659             node.declarationText = "";
19660             return node;
19661         }
19662         function createSyntheticExpression(type, isSpread, tupleNameSource) {
19663             if (isSpread === void 0) { isSpread = false; }
19664             var node = createBaseNode(227);
19665             node.type = type;
19666             node.isSpread = isSpread;
19667             node.tupleNameSource = tupleNameSource;
19668             return node;
19669         }
19670         function createSyntaxList(children) {
19671             var node = createBaseNode(334);
19672             node._children = children;
19673             return node;
19674         }
19675         function createNotEmittedStatement(original) {
19676             var node = createBaseNode(335);
19677             node.original = original;
19678             ts.setTextRange(node, original);
19679             return node;
19680         }
19681         function createPartiallyEmittedExpression(expression, original) {
19682             var node = createBaseNode(336);
19683             node.expression = expression;
19684             node.original = original;
19685             node.transformFlags |=
19686                 propagateChildFlags(node.expression) |
19687                     1;
19688             ts.setTextRange(node, original);
19689             return node;
19690         }
19691         function updatePartiallyEmittedExpression(node, expression) {
19692             return node.expression !== expression
19693                 ? update(createPartiallyEmittedExpression(expression, node.original), node)
19694                 : node;
19695         }
19696         function flattenCommaElements(node) {
19697             if (ts.nodeIsSynthesized(node) && !ts.isParseTreeNode(node) && !node.original && !node.emitNode && !node.id) {
19698                 if (ts.isCommaListExpression(node)) {
19699                     return node.elements;
19700                 }
19701                 if (ts.isBinaryExpression(node) && ts.isCommaToken(node.operatorToken)) {
19702                     return [node.left, node.right];
19703                 }
19704             }
19705             return node;
19706         }
19707         function createCommaListExpression(elements) {
19708             var node = createBaseNode(337);
19709             node.elements = createNodeArray(ts.sameFlatMap(elements, flattenCommaElements));
19710             node.transformFlags |= propagateChildrenFlags(node.elements);
19711             return node;
19712         }
19713         function updateCommaListExpression(node, elements) {
19714             return node.elements !== elements
19715                 ? update(createCommaListExpression(elements), node)
19716                 : node;
19717         }
19718         function createEndOfDeclarationMarker(original) {
19719             var node = createBaseNode(339);
19720             node.emitNode = {};
19721             node.original = original;
19722             return node;
19723         }
19724         function createMergeDeclarationMarker(original) {
19725             var node = createBaseNode(338);
19726             node.emitNode = {};
19727             node.original = original;
19728             return node;
19729         }
19730         function createSyntheticReferenceExpression(expression, thisArg) {
19731             var node = createBaseNode(340);
19732             node.expression = expression;
19733             node.thisArg = thisArg;
19734             node.transformFlags |=
19735                 propagateChildFlags(node.expression) |
19736                     propagateChildFlags(node.thisArg);
19737             return node;
19738         }
19739         function updateSyntheticReferenceExpression(node, expression, thisArg) {
19740             return node.expression !== expression
19741                 || node.thisArg !== thisArg
19742                 ? update(createSyntheticReferenceExpression(expression, thisArg), node)
19743                 : node;
19744         }
19745         function cloneNode(node) {
19746             if (node === undefined) {
19747                 return node;
19748             }
19749             var clone = ts.isSourceFile(node) ? baseFactory.createBaseSourceFileNode(297) :
19750                 ts.isIdentifier(node) ? baseFactory.createBaseIdentifierNode(78) :
19751                     ts.isPrivateIdentifier(node) ? baseFactory.createBasePrivateIdentifierNode(79) :
19752                         !ts.isNodeKind(node.kind) ? baseFactory.createBaseTokenNode(node.kind) :
19753                             baseFactory.createBaseNode(node.kind);
19754             clone.flags |= (node.flags & ~8);
19755             clone.transformFlags = node.transformFlags;
19756             setOriginalNode(clone, node);
19757             for (var key in node) {
19758                 if (clone.hasOwnProperty(key) || !node.hasOwnProperty(key)) {
19759                     continue;
19760                 }
19761                 clone[key] = node[key];
19762             }
19763             return clone;
19764         }
19765         function createImmediatelyInvokedFunctionExpression(statements, param, paramValue) {
19766             return createCallExpression(createFunctionExpression(undefined, undefined, undefined, undefined, param ? [param] : [], undefined, createBlock(statements, true)), undefined, paramValue ? [paramValue] : []);
19767         }
19768         function createImmediatelyInvokedArrowFunction(statements, param, paramValue) {
19769             return createCallExpression(createArrowFunction(undefined, undefined, param ? [param] : [], undefined, undefined, createBlock(statements, true)), undefined, paramValue ? [paramValue] : []);
19770         }
19771         function createVoidZero() {
19772             return createVoidExpression(createNumericLiteral("0"));
19773         }
19774         function createExportDefault(expression) {
19775             return createExportAssignment(undefined, undefined, false, expression);
19776         }
19777         function createExternalModuleExport(exportName) {
19778             return createExportDeclaration(undefined, undefined, false, createNamedExports([
19779                 createExportSpecifier(undefined, exportName)
19780             ]));
19781         }
19782         function createTypeCheck(value, tag) {
19783             return tag === "undefined"
19784                 ? factory.createStrictEquality(value, createVoidZero())
19785                 : factory.createStrictEquality(createTypeOfExpression(value), createStringLiteral(tag));
19786         }
19787         function createMethodCall(object, methodName, argumentsList) {
19788             return createCallExpression(createPropertyAccessExpression(object, methodName), undefined, argumentsList);
19789         }
19790         function createFunctionBindCall(target, thisArg, argumentsList) {
19791             return createMethodCall(target, "bind", __spreadArray([thisArg], argumentsList));
19792         }
19793         function createFunctionCallCall(target, thisArg, argumentsList) {
19794             return createMethodCall(target, "call", __spreadArray([thisArg], argumentsList));
19795         }
19796         function createFunctionApplyCall(target, thisArg, argumentsExpression) {
19797             return createMethodCall(target, "apply", [thisArg, argumentsExpression]);
19798         }
19799         function createGlobalMethodCall(globalObjectName, methodName, argumentsList) {
19800             return createMethodCall(createIdentifier(globalObjectName), methodName, argumentsList);
19801         }
19802         function createArraySliceCall(array, start) {
19803             return createMethodCall(array, "slice", start === undefined ? [] : [asExpression(start)]);
19804         }
19805         function createArrayConcatCall(array, argumentsList) {
19806             return createMethodCall(array, "concat", argumentsList);
19807         }
19808         function createObjectDefinePropertyCall(target, propertyName, attributes) {
19809             return createGlobalMethodCall("Object", "defineProperty", [target, asExpression(propertyName), attributes]);
19810         }
19811         function tryAddPropertyAssignment(properties, propertyName, expression) {
19812             if (expression) {
19813                 properties.push(createPropertyAssignment(propertyName, expression));
19814                 return true;
19815             }
19816             return false;
19817         }
19818         function createPropertyDescriptor(attributes, singleLine) {
19819             var properties = [];
19820             tryAddPropertyAssignment(properties, "enumerable", asExpression(attributes.enumerable));
19821             tryAddPropertyAssignment(properties, "configurable", asExpression(attributes.configurable));
19822             var isData = tryAddPropertyAssignment(properties, "writable", asExpression(attributes.writable));
19823             isData = tryAddPropertyAssignment(properties, "value", attributes.value) || isData;
19824             var isAccessor = tryAddPropertyAssignment(properties, "get", attributes.get);
19825             isAccessor = tryAddPropertyAssignment(properties, "set", attributes.set) || isAccessor;
19826             ts.Debug.assert(!(isData && isAccessor), "A PropertyDescriptor may not be both an accessor descriptor and a data descriptor.");
19827             return createObjectLiteralExpression(properties, !singleLine);
19828         }
19829         function updateOuterExpression(outerExpression, expression) {
19830             switch (outerExpression.kind) {
19831                 case 207: return updateParenthesizedExpression(outerExpression, expression);
19832                 case 206: return updateTypeAssertion(outerExpression, outerExpression.type, expression);
19833                 case 224: return updateAsExpression(outerExpression, expression, outerExpression.type);
19834                 case 225: return updateNonNullExpression(outerExpression, expression);
19835                 case 336: return updatePartiallyEmittedExpression(outerExpression, expression);
19836             }
19837         }
19838         function isIgnorableParen(node) {
19839             return ts.isParenthesizedExpression(node)
19840                 && ts.nodeIsSynthesized(node)
19841                 && ts.nodeIsSynthesized(ts.getSourceMapRange(node))
19842                 && ts.nodeIsSynthesized(ts.getCommentRange(node))
19843                 && !ts.some(ts.getSyntheticLeadingComments(node))
19844                 && !ts.some(ts.getSyntheticTrailingComments(node));
19845         }
19846         function restoreOuterExpressions(outerExpression, innerExpression, kinds) {
19847             if (kinds === void 0) { kinds = 15; }
19848             if (outerExpression && ts.isOuterExpression(outerExpression, kinds) && !isIgnorableParen(outerExpression)) {
19849                 return updateOuterExpression(outerExpression, restoreOuterExpressions(outerExpression.expression, innerExpression));
19850             }
19851             return innerExpression;
19852         }
19853         function restoreEnclosingLabel(node, outermostLabeledStatement, afterRestoreLabelCallback) {
19854             if (!outermostLabeledStatement) {
19855                 return node;
19856             }
19857             var updated = updateLabeledStatement(outermostLabeledStatement, outermostLabeledStatement.label, ts.isLabeledStatement(outermostLabeledStatement.statement)
19858                 ? restoreEnclosingLabel(node, outermostLabeledStatement.statement)
19859                 : node);
19860             if (afterRestoreLabelCallback) {
19861                 afterRestoreLabelCallback(outermostLabeledStatement);
19862             }
19863             return updated;
19864         }
19865         function shouldBeCapturedInTempVariable(node, cacheIdentifiers) {
19866             var target = ts.skipParentheses(node);
19867             switch (target.kind) {
19868                 case 78:
19869                     return cacheIdentifiers;
19870                 case 107:
19871                 case 8:
19872                 case 9:
19873                 case 10:
19874                     return false;
19875                 case 199:
19876                     var elements = target.elements;
19877                     if (elements.length === 0) {
19878                         return false;
19879                     }
19880                     return true;
19881                 case 200:
19882                     return target.properties.length > 0;
19883                 default:
19884                     return true;
19885             }
19886         }
19887         function createCallBinding(expression, recordTempVariable, languageVersion, cacheIdentifiers) {
19888             if (cacheIdentifiers === void 0) { cacheIdentifiers = false; }
19889             var callee = ts.skipOuterExpressions(expression, 15);
19890             var thisArg;
19891             var target;
19892             if (ts.isSuperProperty(callee)) {
19893                 thisArg = createThis();
19894                 target = callee;
19895             }
19896             else if (ts.isSuperKeyword(callee)) {
19897                 thisArg = createThis();
19898                 target = languageVersion !== undefined && languageVersion < 2
19899                     ? ts.setTextRange(createIdentifier("_super"), callee)
19900                     : callee;
19901             }
19902             else if (ts.getEmitFlags(callee) & 4096) {
19903                 thisArg = createVoidZero();
19904                 target = parenthesizerRules().parenthesizeLeftSideOfAccess(callee);
19905             }
19906             else if (ts.isPropertyAccessExpression(callee)) {
19907                 if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
19908                     thisArg = createTempVariable(recordTempVariable);
19909                     target = createPropertyAccessExpression(ts.setTextRange(factory.createAssignment(thisArg, callee.expression), callee.expression), callee.name);
19910                     ts.setTextRange(target, callee);
19911                 }
19912                 else {
19913                     thisArg = callee.expression;
19914                     target = callee;
19915                 }
19916             }
19917             else if (ts.isElementAccessExpression(callee)) {
19918                 if (shouldBeCapturedInTempVariable(callee.expression, cacheIdentifiers)) {
19919                     thisArg = createTempVariable(recordTempVariable);
19920                     target = createElementAccessExpression(ts.setTextRange(factory.createAssignment(thisArg, callee.expression), callee.expression), callee.argumentExpression);
19921                     ts.setTextRange(target, callee);
19922                 }
19923                 else {
19924                     thisArg = callee.expression;
19925                     target = callee;
19926                 }
19927             }
19928             else {
19929                 thisArg = createVoidZero();
19930                 target = parenthesizerRules().parenthesizeLeftSideOfAccess(expression);
19931             }
19932             return { target: target, thisArg: thisArg };
19933         }
19934         function inlineExpressions(expressions) {
19935             return expressions.length > 10
19936                 ? createCommaListExpression(expressions)
19937                 : ts.reduceLeft(expressions, factory.createComma);
19938         }
19939         function getName(node, allowComments, allowSourceMaps, emitFlags) {
19940             if (emitFlags === void 0) { emitFlags = 0; }
19941             var nodeName = ts.getNameOfDeclaration(node);
19942             if (nodeName && ts.isIdentifier(nodeName) && !ts.isGeneratedIdentifier(nodeName)) {
19943                 var name = ts.setParent(ts.setTextRange(cloneNode(nodeName), nodeName), nodeName.parent);
19944                 emitFlags |= ts.getEmitFlags(nodeName);
19945                 if (!allowSourceMaps)
19946                     emitFlags |= 48;
19947                 if (!allowComments)
19948                     emitFlags |= 1536;
19949                 if (emitFlags)
19950                     ts.setEmitFlags(name, emitFlags);
19951                 return name;
19952             }
19953             return getGeneratedNameForNode(node);
19954         }
19955         function getInternalName(node, allowComments, allowSourceMaps) {
19956             return getName(node, allowComments, allowSourceMaps, 16384 | 32768);
19957         }
19958         function getLocalName(node, allowComments, allowSourceMaps) {
19959             return getName(node, allowComments, allowSourceMaps, 16384);
19960         }
19961         function getExportName(node, allowComments, allowSourceMaps) {
19962             return getName(node, allowComments, allowSourceMaps, 8192);
19963         }
19964         function getDeclarationName(node, allowComments, allowSourceMaps) {
19965             return getName(node, allowComments, allowSourceMaps);
19966         }
19967         function getNamespaceMemberName(ns, name, allowComments, allowSourceMaps) {
19968             var qualifiedName = createPropertyAccessExpression(ns, ts.nodeIsSynthesized(name) ? name : cloneNode(name));
19969             ts.setTextRange(qualifiedName, name);
19970             var emitFlags = 0;
19971             if (!allowSourceMaps)
19972                 emitFlags |= 48;
19973             if (!allowComments)
19974                 emitFlags |= 1536;
19975             if (emitFlags)
19976                 ts.setEmitFlags(qualifiedName, emitFlags);
19977             return qualifiedName;
19978         }
19979         function getExternalModuleOrNamespaceExportName(ns, node, allowComments, allowSourceMaps) {
19980             if (ns && ts.hasSyntacticModifier(node, 1)) {
19981                 return getNamespaceMemberName(ns, getName(node), allowComments, allowSourceMaps);
19982             }
19983             return getExportName(node, allowComments, allowSourceMaps);
19984         }
19985         function copyPrologue(source, target, ensureUseStrict, visitor) {
19986             var offset = copyStandardPrologue(source, target, ensureUseStrict);
19987             return copyCustomPrologue(source, target, offset, visitor);
19988         }
19989         function isUseStrictPrologue(node) {
19990             return ts.isStringLiteral(node.expression) && node.expression.text === "use strict";
19991         }
19992         function createUseStrictPrologue() {
19993             return ts.startOnNewLine(createExpressionStatement(createStringLiteral("use strict")));
19994         }
19995         function copyStandardPrologue(source, target, ensureUseStrict) {
19996             ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array");
19997             var foundUseStrict = false;
19998             var statementOffset = 0;
19999             var numStatements = source.length;
20000             while (statementOffset < numStatements) {
20001                 var statement = source[statementOffset];
20002                 if (ts.isPrologueDirective(statement)) {
20003                     if (isUseStrictPrologue(statement)) {
20004                         foundUseStrict = true;
20005                     }
20006                     target.push(statement);
20007                 }
20008                 else {
20009                     break;
20010                 }
20011                 statementOffset++;
20012             }
20013             if (ensureUseStrict && !foundUseStrict) {
20014                 target.push(createUseStrictPrologue());
20015             }
20016             return statementOffset;
20017         }
20018         function copyCustomPrologue(source, target, statementOffset, visitor, filter) {
20019             if (filter === void 0) { filter = ts.returnTrue; }
20020             var numStatements = source.length;
20021             while (statementOffset !== undefined && statementOffset < numStatements) {
20022                 var statement = source[statementOffset];
20023                 if (ts.getEmitFlags(statement) & 1048576 && filter(statement)) {
20024                     ts.append(target, visitor ? ts.visitNode(statement, visitor, ts.isStatement) : statement);
20025                 }
20026                 else {
20027                     break;
20028                 }
20029                 statementOffset++;
20030             }
20031             return statementOffset;
20032         }
20033         function ensureUseStrict(statements) {
20034             var foundUseStrict = ts.findUseStrictPrologue(statements);
20035             if (!foundUseStrict) {
20036                 return ts.setTextRange(createNodeArray(__spreadArray([createUseStrictPrologue()], statements)), statements);
20037             }
20038             return statements;
20039         }
20040         function liftToBlock(nodes) {
20041             ts.Debug.assert(ts.every(nodes, ts.isStatementOrBlock), "Cannot lift nodes to a Block.");
20042             return ts.singleOrUndefined(nodes) || createBlock(nodes);
20043         }
20044         function findSpanEnd(array, test, start) {
20045             var i = start;
20046             while (i < array.length && test(array[i])) {
20047                 i++;
20048             }
20049             return i;
20050         }
20051         function mergeLexicalEnvironment(statements, declarations) {
20052             if (!ts.some(declarations)) {
20053                 return statements;
20054             }
20055             var leftStandardPrologueEnd = findSpanEnd(statements, ts.isPrologueDirective, 0);
20056             var leftHoistedFunctionsEnd = findSpanEnd(statements, ts.isHoistedFunction, leftStandardPrologueEnd);
20057             var leftHoistedVariablesEnd = findSpanEnd(statements, ts.isHoistedVariableStatement, leftHoistedFunctionsEnd);
20058             var rightStandardPrologueEnd = findSpanEnd(declarations, ts.isPrologueDirective, 0);
20059             var rightHoistedFunctionsEnd = findSpanEnd(declarations, ts.isHoistedFunction, rightStandardPrologueEnd);
20060             var rightHoistedVariablesEnd = findSpanEnd(declarations, ts.isHoistedVariableStatement, rightHoistedFunctionsEnd);
20061             var rightCustomPrologueEnd = findSpanEnd(declarations, ts.isCustomPrologue, rightHoistedVariablesEnd);
20062             ts.Debug.assert(rightCustomPrologueEnd === declarations.length, "Expected declarations to be valid standard or custom prologues");
20063             var left = ts.isNodeArray(statements) ? statements.slice() : statements;
20064             if (rightCustomPrologueEnd > rightHoistedVariablesEnd) {
20065                 left.splice.apply(left, __spreadArray([leftHoistedVariablesEnd, 0], declarations.slice(rightHoistedVariablesEnd, rightCustomPrologueEnd)));
20066             }
20067             if (rightHoistedVariablesEnd > rightHoistedFunctionsEnd) {
20068                 left.splice.apply(left, __spreadArray([leftHoistedFunctionsEnd, 0], declarations.slice(rightHoistedFunctionsEnd, rightHoistedVariablesEnd)));
20069             }
20070             if (rightHoistedFunctionsEnd > rightStandardPrologueEnd) {
20071                 left.splice.apply(left, __spreadArray([leftStandardPrologueEnd, 0], declarations.slice(rightStandardPrologueEnd, rightHoistedFunctionsEnd)));
20072             }
20073             if (rightStandardPrologueEnd > 0) {
20074                 if (leftStandardPrologueEnd === 0) {
20075                     left.splice.apply(left, __spreadArray([0, 0], declarations.slice(0, rightStandardPrologueEnd)));
20076                 }
20077                 else {
20078                     var leftPrologues = new ts.Map();
20079                     for (var i = 0; i < leftStandardPrologueEnd; i++) {
20080                         var leftPrologue = statements[i];
20081                         leftPrologues.set(leftPrologue.expression.text, true);
20082                     }
20083                     for (var i = rightStandardPrologueEnd - 1; i >= 0; i--) {
20084                         var rightPrologue = declarations[i];
20085                         if (!leftPrologues.has(rightPrologue.expression.text)) {
20086                             left.unshift(rightPrologue);
20087                         }
20088                     }
20089                 }
20090             }
20091             if (ts.isNodeArray(statements)) {
20092                 return ts.setTextRange(createNodeArray(left, statements.hasTrailingComma), statements);
20093             }
20094             return statements;
20095         }
20096         function updateModifiers(node, modifiers) {
20097             var _a;
20098             if (typeof modifiers === "number") {
20099                 modifiers = createModifiersFromModifierFlags(modifiers);
20100             }
20101             return ts.isParameter(node) ? updateParameterDeclaration(node, node.decorators, modifiers, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) :
20102                 ts.isPropertySignature(node) ? updatePropertySignature(node, modifiers, node.name, node.questionToken, node.type) :
20103                     ts.isPropertyDeclaration(node) ? updatePropertyDeclaration(node, node.decorators, modifiers, node.name, (_a = node.questionToken) !== null && _a !== void 0 ? _a : node.exclamationToken, node.type, node.initializer) :
20104                         ts.isMethodSignature(node) ? updateMethodSignature(node, modifiers, node.name, node.questionToken, node.typeParameters, node.parameters, node.type) :
20105                             ts.isMethodDeclaration(node) ? updateMethodDeclaration(node, node.decorators, modifiers, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) :
20106                                 ts.isConstructorDeclaration(node) ? updateConstructorDeclaration(node, node.decorators, modifiers, node.parameters, node.body) :
20107                                     ts.isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, node.decorators, modifiers, node.name, node.parameters, node.type, node.body) :
20108                                         ts.isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, node.decorators, modifiers, node.name, node.parameters, node.body) :
20109                                             ts.isIndexSignatureDeclaration(node) ? updateIndexSignature(node, node.decorators, modifiers, node.parameters, node.type) :
20110                                                 ts.isFunctionExpression(node) ? updateFunctionExpression(node, modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) :
20111                                                     ts.isArrowFunction(node) ? updateArrowFunction(node, modifiers, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, node.body) :
20112                                                         ts.isClassExpression(node) ? updateClassExpression(node, node.decorators, modifiers, node.name, node.typeParameters, node.heritageClauses, node.members) :
20113                                                             ts.isVariableStatement(node) ? updateVariableStatement(node, modifiers, node.declarationList) :
20114                                                                 ts.isFunctionDeclaration(node) ? updateFunctionDeclaration(node, node.decorators, modifiers, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) :
20115                                                                     ts.isClassDeclaration(node) ? updateClassDeclaration(node, node.decorators, modifiers, node.name, node.typeParameters, node.heritageClauses, node.members) :
20116                                                                         ts.isInterfaceDeclaration(node) ? updateInterfaceDeclaration(node, node.decorators, modifiers, node.name, node.typeParameters, node.heritageClauses, node.members) :
20117                                                                             ts.isTypeAliasDeclaration(node) ? updateTypeAliasDeclaration(node, node.decorators, modifiers, node.name, node.typeParameters, node.type) :
20118                                                                                 ts.isEnumDeclaration(node) ? updateEnumDeclaration(node, node.decorators, modifiers, node.name, node.members) :
20119                                                                                     ts.isModuleDeclaration(node) ? updateModuleDeclaration(node, node.decorators, modifiers, node.name, node.body) :
20120                                                                                         ts.isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, node.decorators, modifiers, node.isTypeOnly, node.name, node.moduleReference) :
20121                                                                                             ts.isImportDeclaration(node) ? updateImportDeclaration(node, node.decorators, modifiers, node.importClause, node.moduleSpecifier) :
20122                                                                                                 ts.isExportAssignment(node) ? updateExportAssignment(node, node.decorators, modifiers, node.expression) :
20123                                                                                                     ts.isExportDeclaration(node) ? updateExportDeclaration(node, node.decorators, modifiers, node.isTypeOnly, node.exportClause, node.moduleSpecifier) :
20124                                                                                                         ts.Debug.assertNever(node);
20125         }
20126         function asNodeArray(array) {
20127             return array ? createNodeArray(array) : undefined;
20128         }
20129         function asName(name) {
20130             return typeof name === "string" ? createIdentifier(name) :
20131                 name;
20132         }
20133         function asExpression(value) {
20134             return typeof value === "string" ? createStringLiteral(value) :
20135                 typeof value === "number" ? createNumericLiteral(value) :
20136                     typeof value === "boolean" ? value ? createTrue() : createFalse() :
20137                         value;
20138         }
20139         function asToken(value) {
20140             return typeof value === "number" ? createToken(value) : value;
20141         }
20142         function asEmbeddedStatement(statement) {
20143             return statement && ts.isNotEmittedStatement(statement) ? ts.setTextRange(setOriginalNode(createEmptyStatement(), statement), statement) : statement;
20144         }
20145     }
20146     ts.createNodeFactory = createNodeFactory;
20147     function updateWithoutOriginal(updated, original) {
20148         if (updated !== original) {
20149             ts.setTextRange(updated, original);
20150         }
20151         return updated;
20152     }
20153     function updateWithOriginal(updated, original) {
20154         if (updated !== original) {
20155             setOriginalNode(updated, original);
20156             ts.setTextRange(updated, original);
20157         }
20158         return updated;
20159     }
20160     function getDefaultTagNameForKind(kind) {
20161         switch (kind) {
20162             case 329: return "type";
20163             case 327: return "returns";
20164             case 328: return "this";
20165             case 325: return "enum";
20166             case 317: return "author";
20167             case 319: return "class";
20168             case 320: return "public";
20169             case 321: return "private";
20170             case 322: return "protected";
20171             case 323: return "readonly";
20172             case 330: return "template";
20173             case 331: return "typedef";
20174             case 326: return "param";
20175             case 333: return "prop";
20176             case 324: return "callback";
20177             case 315: return "augments";
20178             case 316: return "implements";
20179             default:
20180                 return ts.Debug.fail("Unsupported kind: " + ts.Debug.formatSyntaxKind(kind));
20181         }
20182     }
20183     var rawTextScanner;
20184     var invalidValueSentinel = {};
20185     function getCookedText(kind, rawText) {
20186         if (!rawTextScanner) {
20187             rawTextScanner = ts.createScanner(99, false, 0);
20188         }
20189         switch (kind) {
20190             case 14:
20191                 rawTextScanner.setText("`" + rawText + "`");
20192                 break;
20193             case 15:
20194                 rawTextScanner.setText("`" + rawText + "${");
20195                 break;
20196             case 16:
20197                 rawTextScanner.setText("}" + rawText + "${");
20198                 break;
20199             case 17:
20200                 rawTextScanner.setText("}" + rawText + "`");
20201                 break;
20202         }
20203         var token = rawTextScanner.scan();
20204         if (token === 23) {
20205             token = rawTextScanner.reScanTemplateToken(false);
20206         }
20207         if (rawTextScanner.isUnterminated()) {
20208             rawTextScanner.setText(undefined);
20209             return invalidValueSentinel;
20210         }
20211         var tokenValue;
20212         switch (token) {
20213             case 14:
20214             case 15:
20215             case 16:
20216             case 17:
20217                 tokenValue = rawTextScanner.getTokenValue();
20218                 break;
20219         }
20220         if (tokenValue === undefined || rawTextScanner.scan() !== 1) {
20221             rawTextScanner.setText(undefined);
20222             return invalidValueSentinel;
20223         }
20224         rawTextScanner.setText(undefined);
20225         return tokenValue;
20226     }
20227     function propagateIdentifierNameFlags(node) {
20228         return propagateChildFlags(node) & ~8388608;
20229     }
20230     function propagatePropertyNameFlagsOfChild(node, transformFlags) {
20231         return transformFlags | (node.transformFlags & 4096);
20232     }
20233     function propagateChildFlags(child) {
20234         if (!child)
20235             return 0;
20236         var childFlags = child.transformFlags & ~getTransformFlagsSubtreeExclusions(child.kind);
20237         return ts.isNamedDeclaration(child) && ts.isPropertyName(child.name) ? propagatePropertyNameFlagsOfChild(child.name, childFlags) : childFlags;
20238     }
20239     function propagateChildrenFlags(children) {
20240         return children ? children.transformFlags : 0;
20241     }
20242     function aggregateChildrenFlags(children) {
20243         var subtreeFlags = 0;
20244         for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
20245             var child = children_2[_i];
20246             subtreeFlags |= propagateChildFlags(child);
20247         }
20248         children.transformFlags = subtreeFlags;
20249     }
20250     function getTransformFlagsSubtreeExclusions(kind) {
20251         if (kind >= 172 && kind <= 195) {
20252             return -2;
20253         }
20254         switch (kind) {
20255             case 203:
20256             case 204:
20257             case 199:
20258                 return 536879104;
20259             case 256:
20260                 return 546379776;
20261             case 160:
20262                 return 536870912;
20263             case 209:
20264                 return 547309568;
20265             case 208:
20266             case 251:
20267                 return 547313664;
20268             case 250:
20269                 return 537018368;
20270             case 252:
20271             case 221:
20272                 return 536905728;
20273             case 166:
20274                 return 547311616;
20275             case 163:
20276                 return 536875008;
20277             case 165:
20278             case 167:
20279             case 168:
20280                 return 538923008;
20281             case 128:
20282             case 144:
20283             case 155:
20284             case 141:
20285             case 147:
20286             case 145:
20287             case 131:
20288             case 148:
20289             case 113:
20290             case 159:
20291             case 162:
20292             case 164:
20293             case 169:
20294             case 170:
20295             case 171:
20296             case 253:
20297             case 254:
20298                 return -2;
20299             case 200:
20300                 return 536922112;
20301             case 287:
20302                 return 536887296;
20303             case 196:
20304             case 197:
20305                 return 536879104;
20306             case 206:
20307             case 224:
20308             case 336:
20309             case 207:
20310             case 105:
20311                 return 536870912;
20312             case 201:
20313             case 202:
20314                 return 536870912;
20315             default:
20316                 return 536870912;
20317         }
20318     }
20319     ts.getTransformFlagsSubtreeExclusions = getTransformFlagsSubtreeExclusions;
20320     var baseFactory = ts.createBaseNodeFactory();
20321     function makeSynthetic(node) {
20322         node.flags |= 8;
20323         return node;
20324     }
20325     var syntheticFactory = {
20326         createBaseSourceFileNode: function (kind) { return makeSynthetic(baseFactory.createBaseSourceFileNode(kind)); },
20327         createBaseIdentifierNode: function (kind) { return makeSynthetic(baseFactory.createBaseIdentifierNode(kind)); },
20328         createBasePrivateIdentifierNode: function (kind) { return makeSynthetic(baseFactory.createBasePrivateIdentifierNode(kind)); },
20329         createBaseTokenNode: function (kind) { return makeSynthetic(baseFactory.createBaseTokenNode(kind)); },
20330         createBaseNode: function (kind) { return makeSynthetic(baseFactory.createBaseNode(kind)); },
20331     };
20332     ts.factory = createNodeFactory(4, syntheticFactory);
20333     function createUnparsedSourceFile(textOrInputFiles, mapPathOrType, mapTextOrStripInternal) {
20334         var stripInternal;
20335         var bundleFileInfo;
20336         var fileName;
20337         var text;
20338         var length;
20339         var sourceMapPath;
20340         var sourceMapText;
20341         var getText;
20342         var getSourceMapText;
20343         var oldFileOfCurrentEmit;
20344         if (!ts.isString(textOrInputFiles)) {
20345             ts.Debug.assert(mapPathOrType === "js" || mapPathOrType === "dts");
20346             fileName = (mapPathOrType === "js" ? textOrInputFiles.javascriptPath : textOrInputFiles.declarationPath) || "";
20347             sourceMapPath = mapPathOrType === "js" ? textOrInputFiles.javascriptMapPath : textOrInputFiles.declarationMapPath;
20348             getText = function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptText : textOrInputFiles.declarationText; };
20349             getSourceMapText = function () { return mapPathOrType === "js" ? textOrInputFiles.javascriptMapText : textOrInputFiles.declarationMapText; };
20350             length = function () { return getText().length; };
20351             if (textOrInputFiles.buildInfo && textOrInputFiles.buildInfo.bundle) {
20352                 ts.Debug.assert(mapTextOrStripInternal === undefined || typeof mapTextOrStripInternal === "boolean");
20353                 stripInternal = mapTextOrStripInternal;
20354                 bundleFileInfo = mapPathOrType === "js" ? textOrInputFiles.buildInfo.bundle.js : textOrInputFiles.buildInfo.bundle.dts;
20355                 oldFileOfCurrentEmit = textOrInputFiles.oldFileOfCurrentEmit;
20356             }
20357         }
20358         else {
20359             fileName = "";
20360             text = textOrInputFiles;
20361             length = textOrInputFiles.length;
20362             sourceMapPath = mapPathOrType;
20363             sourceMapText = mapTextOrStripInternal;
20364         }
20365         var node = oldFileOfCurrentEmit ?
20366             parseOldFileOfCurrentEmit(ts.Debug.assertDefined(bundleFileInfo)) :
20367             parseUnparsedSourceFile(bundleFileInfo, stripInternal, length);
20368         node.fileName = fileName;
20369         node.sourceMapPath = sourceMapPath;
20370         node.oldFileOfCurrentEmit = oldFileOfCurrentEmit;
20371         if (getText && getSourceMapText) {
20372             Object.defineProperty(node, "text", { get: getText });
20373             Object.defineProperty(node, "sourceMapText", { get: getSourceMapText });
20374         }
20375         else {
20376             ts.Debug.assert(!oldFileOfCurrentEmit);
20377             node.text = text !== null && text !== void 0 ? text : "";
20378             node.sourceMapText = sourceMapText;
20379         }
20380         return node;
20381     }
20382     ts.createUnparsedSourceFile = createUnparsedSourceFile;
20383     function parseUnparsedSourceFile(bundleFileInfo, stripInternal, length) {
20384         var prologues;
20385         var helpers;
20386         var referencedFiles;
20387         var typeReferenceDirectives;
20388         var libReferenceDirectives;
20389         var prependChildren;
20390         var texts;
20391         var hasNoDefaultLib;
20392         for (var _i = 0, _a = bundleFileInfo ? bundleFileInfo.sections : ts.emptyArray; _i < _a.length; _i++) {
20393             var section = _a[_i];
20394             switch (section.kind) {
20395                 case "prologue":
20396                     prologues = ts.append(prologues, ts.setTextRange(ts.factory.createUnparsedPrologue(section.data), section));
20397                     break;
20398                 case "emitHelpers":
20399                     helpers = ts.append(helpers, ts.getAllUnscopedEmitHelpers().get(section.data));
20400                     break;
20401                 case "no-default-lib":
20402                     hasNoDefaultLib = true;
20403                     break;
20404                 case "reference":
20405                     referencedFiles = ts.append(referencedFiles, { pos: -1, end: -1, fileName: section.data });
20406                     break;
20407                 case "type":
20408                     typeReferenceDirectives = ts.append(typeReferenceDirectives, section.data);
20409                     break;
20410                 case "lib":
20411                     libReferenceDirectives = ts.append(libReferenceDirectives, { pos: -1, end: -1, fileName: section.data });
20412                     break;
20413                 case "prepend":
20414                     var prependTexts = void 0;
20415                     for (var _b = 0, _c = section.texts; _b < _c.length; _b++) {
20416                         var text = _c[_b];
20417                         if (!stripInternal || text.kind !== "internal") {
20418                             prependTexts = ts.append(prependTexts, ts.setTextRange(ts.factory.createUnparsedTextLike(text.data, text.kind === "internal"), text));
20419                         }
20420                     }
20421                     prependChildren = ts.addRange(prependChildren, prependTexts);
20422                     texts = ts.append(texts, ts.factory.createUnparsedPrepend(section.data, prependTexts !== null && prependTexts !== void 0 ? prependTexts : ts.emptyArray));
20423                     break;
20424                 case "internal":
20425                     if (stripInternal) {
20426                         if (!texts)
20427                             texts = [];
20428                         break;
20429                     }
20430                 case "text":
20431                     texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal"), section));
20432                     break;
20433                 default:
20434                     ts.Debug.assertNever(section);
20435             }
20436         }
20437         if (!texts) {
20438             var textNode = ts.factory.createUnparsedTextLike(undefined, false);
20439             ts.setTextRangePosWidth(textNode, 0, typeof length === "function" ? length() : length);
20440             texts = [textNode];
20441         }
20442         var node = ts.parseNodeFactory.createUnparsedSource(prologues !== null && prologues !== void 0 ? prologues : ts.emptyArray, undefined, texts);
20443         ts.setEachParent(prologues, node);
20444         ts.setEachParent(texts, node);
20445         ts.setEachParent(prependChildren, node);
20446         node.hasNoDefaultLib = hasNoDefaultLib;
20447         node.helpers = helpers;
20448         node.referencedFiles = referencedFiles || ts.emptyArray;
20449         node.typeReferenceDirectives = typeReferenceDirectives;
20450         node.libReferenceDirectives = libReferenceDirectives || ts.emptyArray;
20451         return node;
20452     }
20453     function parseOldFileOfCurrentEmit(bundleFileInfo) {
20454         var texts;
20455         var syntheticReferences;
20456         for (var _i = 0, _a = bundleFileInfo.sections; _i < _a.length; _i++) {
20457             var section = _a[_i];
20458             switch (section.kind) {
20459                 case "internal":
20460                 case "text":
20461                     texts = ts.append(texts, ts.setTextRange(ts.factory.createUnparsedTextLike(section.data, section.kind === "internal"), section));
20462                     break;
20463                 case "no-default-lib":
20464                 case "reference":
20465                 case "type":
20466                 case "lib":
20467                     syntheticReferences = ts.append(syntheticReferences, ts.setTextRange(ts.factory.createUnparsedSyntheticReference(section), section));
20468                     break;
20469                 case "prologue":
20470                 case "emitHelpers":
20471                 case "prepend":
20472                     break;
20473                 default:
20474                     ts.Debug.assertNever(section);
20475             }
20476         }
20477         var node = ts.factory.createUnparsedSource(ts.emptyArray, syntheticReferences, texts !== null && texts !== void 0 ? texts : ts.emptyArray);
20478         ts.setEachParent(syntheticReferences, node);
20479         ts.setEachParent(texts, node);
20480         node.helpers = ts.map(bundleFileInfo.sources && bundleFileInfo.sources.helpers, function (name) { return ts.getAllUnscopedEmitHelpers().get(name); });
20481         return node;
20482     }
20483     function createInputFiles(javascriptTextOrReadFileText, declarationTextOrJavascriptPath, javascriptMapPath, javascriptMapTextOrDeclarationPath, declarationMapPath, declarationMapTextOrBuildInfoPath, javascriptPath, declarationPath, buildInfoPath, buildInfo, oldFileOfCurrentEmit) {
20484         var node = ts.parseNodeFactory.createInputFiles();
20485         if (!ts.isString(javascriptTextOrReadFileText)) {
20486             var cache_1 = new ts.Map();
20487             var textGetter_1 = function (path) {
20488                 if (path === undefined)
20489                     return undefined;
20490                 var value = cache_1.get(path);
20491                 if (value === undefined) {
20492                     value = javascriptTextOrReadFileText(path);
20493                     cache_1.set(path, value !== undefined ? value : false);
20494                 }
20495                 return value !== false ? value : undefined;
20496             };
20497             var definedTextGetter_1 = function (path) {
20498                 var result = textGetter_1(path);
20499                 return result !== undefined ? result : "/* Input file " + path + " was missing */\r\n";
20500             };
20501             var buildInfo_1;
20502             var getAndCacheBuildInfo_1 = function (getText) {
20503                 if (buildInfo_1 === undefined) {
20504                     var result = getText();
20505                     buildInfo_1 = result !== undefined ? ts.getBuildInfo(result) : false;
20506                 }
20507                 return buildInfo_1 || undefined;
20508             };
20509             node.javascriptPath = declarationTextOrJavascriptPath;
20510             node.javascriptMapPath = javascriptMapPath;
20511             node.declarationPath = ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath);
20512             node.declarationMapPath = declarationMapPath;
20513             node.buildInfoPath = declarationMapTextOrBuildInfoPath;
20514             Object.defineProperties(node, {
20515                 javascriptText: { get: function () { return definedTextGetter_1(declarationTextOrJavascriptPath); } },
20516                 javascriptMapText: { get: function () { return textGetter_1(javascriptMapPath); } },
20517                 declarationText: { get: function () { return definedTextGetter_1(ts.Debug.assertDefined(javascriptMapTextOrDeclarationPath)); } },
20518                 declarationMapText: { get: function () { return textGetter_1(declarationMapPath); } },
20519                 buildInfo: { get: function () { return getAndCacheBuildInfo_1(function () { return textGetter_1(declarationMapTextOrBuildInfoPath); }); } }
20520             });
20521         }
20522         else {
20523             node.javascriptText = javascriptTextOrReadFileText;
20524             node.javascriptMapPath = javascriptMapPath;
20525             node.javascriptMapText = javascriptMapTextOrDeclarationPath;
20526             node.declarationText = declarationTextOrJavascriptPath;
20527             node.declarationMapPath = declarationMapPath;
20528             node.declarationMapText = declarationMapTextOrBuildInfoPath;
20529             node.javascriptPath = javascriptPath;
20530             node.declarationPath = declarationPath;
20531             node.buildInfoPath = buildInfoPath;
20532             node.buildInfo = buildInfo;
20533             node.oldFileOfCurrentEmit = oldFileOfCurrentEmit;
20534         }
20535         return node;
20536     }
20537     ts.createInputFiles = createInputFiles;
20538     var SourceMapSource;
20539     function createSourceMapSource(fileName, text, skipTrivia) {
20540         return new (SourceMapSource || (SourceMapSource = ts.objectAllocator.getSourceMapSourceConstructor()))(fileName, text, skipTrivia);
20541     }
20542     ts.createSourceMapSource = createSourceMapSource;
20543     function setOriginalNode(node, original) {
20544         node.original = original;
20545         if (original) {
20546             var emitNode = original.emitNode;
20547             if (emitNode)
20548                 node.emitNode = mergeEmitNode(emitNode, node.emitNode);
20549         }
20550         return node;
20551     }
20552     ts.setOriginalNode = setOriginalNode;
20553     function mergeEmitNode(sourceEmitNode, destEmitNode) {
20554         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;
20555         if (!destEmitNode)
20556             destEmitNode = {};
20557         if (leadingComments)
20558             destEmitNode.leadingComments = ts.addRange(leadingComments.slice(), destEmitNode.leadingComments);
20559         if (trailingComments)
20560             destEmitNode.trailingComments = ts.addRange(trailingComments.slice(), destEmitNode.trailingComments);
20561         if (flags)
20562             destEmitNode.flags = flags;
20563         if (commentRange)
20564             destEmitNode.commentRange = commentRange;
20565         if (sourceMapRange)
20566             destEmitNode.sourceMapRange = sourceMapRange;
20567         if (tokenSourceMapRanges)
20568             destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges);
20569         if (constantValue !== undefined)
20570             destEmitNode.constantValue = constantValue;
20571         if (helpers) {
20572             for (var _i = 0, helpers_1 = helpers; _i < helpers_1.length; _i++) {
20573                 var helper = helpers_1[_i];
20574                 destEmitNode.helpers = ts.appendIfUnique(destEmitNode.helpers, helper);
20575             }
20576         }
20577         if (startsOnNewLine !== undefined)
20578             destEmitNode.startsOnNewLine = startsOnNewLine;
20579         return destEmitNode;
20580     }
20581     function mergeTokenSourceMapRanges(sourceRanges, destRanges) {
20582         if (!destRanges)
20583             destRanges = [];
20584         for (var key in sourceRanges) {
20585             destRanges[key] = sourceRanges[key];
20586         }
20587         return destRanges;
20588     }
20589 })(ts || (ts = {}));
20590 var ts;
20591 (function (ts) {
20592     function getOrCreateEmitNode(node) {
20593         var _a;
20594         if (!node.emitNode) {
20595             if (ts.isParseTreeNode(node)) {
20596                 if (node.kind === 297) {
20597                     return node.emitNode = { annotatedNodes: [node] };
20598                 }
20599                 var sourceFile = (_a = ts.getSourceFileOfNode(ts.getParseTreeNode(ts.getSourceFileOfNode(node)))) !== null && _a !== void 0 ? _a : ts.Debug.fail("Could not determine parsed source file.");
20600                 getOrCreateEmitNode(sourceFile).annotatedNodes.push(node);
20601             }
20602             node.emitNode = {};
20603         }
20604         return node.emitNode;
20605     }
20606     ts.getOrCreateEmitNode = getOrCreateEmitNode;
20607     function disposeEmitNodes(sourceFile) {
20608         var _a, _b;
20609         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;
20610         if (annotatedNodes) {
20611             for (var _i = 0, annotatedNodes_1 = annotatedNodes; _i < annotatedNodes_1.length; _i++) {
20612                 var node = annotatedNodes_1[_i];
20613                 node.emitNode = undefined;
20614             }
20615         }
20616     }
20617     ts.disposeEmitNodes = disposeEmitNodes;
20618     function removeAllComments(node) {
20619         var emitNode = getOrCreateEmitNode(node);
20620         emitNode.flags |= 1536;
20621         emitNode.leadingComments = undefined;
20622         emitNode.trailingComments = undefined;
20623         return node;
20624     }
20625     ts.removeAllComments = removeAllComments;
20626     function setEmitFlags(node, emitFlags) {
20627         getOrCreateEmitNode(node).flags = emitFlags;
20628         return node;
20629     }
20630     ts.setEmitFlags = setEmitFlags;
20631     function addEmitFlags(node, emitFlags) {
20632         var emitNode = getOrCreateEmitNode(node);
20633         emitNode.flags = emitNode.flags | emitFlags;
20634         return node;
20635     }
20636     ts.addEmitFlags = addEmitFlags;
20637     function getSourceMapRange(node) {
20638         var _a, _b;
20639         return (_b = (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.sourceMapRange) !== null && _b !== void 0 ? _b : node;
20640     }
20641     ts.getSourceMapRange = getSourceMapRange;
20642     function setSourceMapRange(node, range) {
20643         getOrCreateEmitNode(node).sourceMapRange = range;
20644         return node;
20645     }
20646     ts.setSourceMapRange = setSourceMapRange;
20647     function getTokenSourceMapRange(node, token) {
20648         var _a, _b;
20649         return (_b = (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.tokenSourceMapRanges) === null || _b === void 0 ? void 0 : _b[token];
20650     }
20651     ts.getTokenSourceMapRange = getTokenSourceMapRange;
20652     function setTokenSourceMapRange(node, token, range) {
20653         var _a;
20654         var emitNode = getOrCreateEmitNode(node);
20655         var tokenSourceMapRanges = (_a = emitNode.tokenSourceMapRanges) !== null && _a !== void 0 ? _a : (emitNode.tokenSourceMapRanges = []);
20656         tokenSourceMapRanges[token] = range;
20657         return node;
20658     }
20659     ts.setTokenSourceMapRange = setTokenSourceMapRange;
20660     function getStartsOnNewLine(node) {
20661         var _a;
20662         return (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.startsOnNewLine;
20663     }
20664     ts.getStartsOnNewLine = getStartsOnNewLine;
20665     function setStartsOnNewLine(node, newLine) {
20666         getOrCreateEmitNode(node).startsOnNewLine = newLine;
20667         return node;
20668     }
20669     ts.setStartsOnNewLine = setStartsOnNewLine;
20670     function getCommentRange(node) {
20671         var _a, _b;
20672         return (_b = (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.commentRange) !== null && _b !== void 0 ? _b : node;
20673     }
20674     ts.getCommentRange = getCommentRange;
20675     function setCommentRange(node, range) {
20676         getOrCreateEmitNode(node).commentRange = range;
20677         return node;
20678     }
20679     ts.setCommentRange = setCommentRange;
20680     function getSyntheticLeadingComments(node) {
20681         var _a;
20682         return (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.leadingComments;
20683     }
20684     ts.getSyntheticLeadingComments = getSyntheticLeadingComments;
20685     function setSyntheticLeadingComments(node, comments) {
20686         getOrCreateEmitNode(node).leadingComments = comments;
20687         return node;
20688     }
20689     ts.setSyntheticLeadingComments = setSyntheticLeadingComments;
20690     function addSyntheticLeadingComment(node, kind, text, hasTrailingNewLine) {
20691         return setSyntheticLeadingComments(node, ts.append(getSyntheticLeadingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text }));
20692     }
20693     ts.addSyntheticLeadingComment = addSyntheticLeadingComment;
20694     function getSyntheticTrailingComments(node) {
20695         var _a;
20696         return (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.trailingComments;
20697     }
20698     ts.getSyntheticTrailingComments = getSyntheticTrailingComments;
20699     function setSyntheticTrailingComments(node, comments) {
20700         getOrCreateEmitNode(node).trailingComments = comments;
20701         return node;
20702     }
20703     ts.setSyntheticTrailingComments = setSyntheticTrailingComments;
20704     function addSyntheticTrailingComment(node, kind, text, hasTrailingNewLine) {
20705         return setSyntheticTrailingComments(node, ts.append(getSyntheticTrailingComments(node), { kind: kind, pos: -1, end: -1, hasTrailingNewLine: hasTrailingNewLine, text: text }));
20706     }
20707     ts.addSyntheticTrailingComment = addSyntheticTrailingComment;
20708     function moveSyntheticComments(node, original) {
20709         setSyntheticLeadingComments(node, getSyntheticLeadingComments(original));
20710         setSyntheticTrailingComments(node, getSyntheticTrailingComments(original));
20711         var emit = getOrCreateEmitNode(original);
20712         emit.leadingComments = undefined;
20713         emit.trailingComments = undefined;
20714         return node;
20715     }
20716     ts.moveSyntheticComments = moveSyntheticComments;
20717     function getConstantValue(node) {
20718         var _a;
20719         return (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.constantValue;
20720     }
20721     ts.getConstantValue = getConstantValue;
20722     function setConstantValue(node, value) {
20723         var emitNode = getOrCreateEmitNode(node);
20724         emitNode.constantValue = value;
20725         return node;
20726     }
20727     ts.setConstantValue = setConstantValue;
20728     function addEmitHelper(node, helper) {
20729         var emitNode = getOrCreateEmitNode(node);
20730         emitNode.helpers = ts.append(emitNode.helpers, helper);
20731         return node;
20732     }
20733     ts.addEmitHelper = addEmitHelper;
20734     function addEmitHelpers(node, helpers) {
20735         if (ts.some(helpers)) {
20736             var emitNode = getOrCreateEmitNode(node);
20737             for (var _i = 0, helpers_2 = helpers; _i < helpers_2.length; _i++) {
20738                 var helper = helpers_2[_i];
20739                 emitNode.helpers = ts.appendIfUnique(emitNode.helpers, helper);
20740             }
20741         }
20742         return node;
20743     }
20744     ts.addEmitHelpers = addEmitHelpers;
20745     function removeEmitHelper(node, helper) {
20746         var _a;
20747         var helpers = (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.helpers;
20748         if (helpers) {
20749             return ts.orderedRemoveItem(helpers, helper);
20750         }
20751         return false;
20752     }
20753     ts.removeEmitHelper = removeEmitHelper;
20754     function getEmitHelpers(node) {
20755         var _a;
20756         return (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.helpers;
20757     }
20758     ts.getEmitHelpers = getEmitHelpers;
20759     function moveEmitHelpers(source, target, predicate) {
20760         var sourceEmitNode = source.emitNode;
20761         var sourceEmitHelpers = sourceEmitNode && sourceEmitNode.helpers;
20762         if (!ts.some(sourceEmitHelpers))
20763             return;
20764         var targetEmitNode = getOrCreateEmitNode(target);
20765         var helpersRemoved = 0;
20766         for (var i = 0; i < sourceEmitHelpers.length; i++) {
20767             var helper = sourceEmitHelpers[i];
20768             if (predicate(helper)) {
20769                 helpersRemoved++;
20770                 targetEmitNode.helpers = ts.appendIfUnique(targetEmitNode.helpers, helper);
20771             }
20772             else if (helpersRemoved > 0) {
20773                 sourceEmitHelpers[i - helpersRemoved] = helper;
20774             }
20775         }
20776         if (helpersRemoved > 0) {
20777             sourceEmitHelpers.length -= helpersRemoved;
20778         }
20779     }
20780     ts.moveEmitHelpers = moveEmitHelpers;
20781     function ignoreSourceNewlines(node) {
20782         getOrCreateEmitNode(node).flags |= 134217728;
20783         return node;
20784     }
20785     ts.ignoreSourceNewlines = ignoreSourceNewlines;
20786 })(ts || (ts = {}));
20787 var ts;
20788 (function (ts) {
20789     function createEmitHelperFactory(context) {
20790         var factory = context.factory;
20791         return {
20792             getUnscopedHelperName: getUnscopedHelperName,
20793             createDecorateHelper: createDecorateHelper,
20794             createMetadataHelper: createMetadataHelper,
20795             createParamHelper: createParamHelper,
20796             createAssignHelper: createAssignHelper,
20797             createAwaitHelper: createAwaitHelper,
20798             createAsyncGeneratorHelper: createAsyncGeneratorHelper,
20799             createAsyncDelegatorHelper: createAsyncDelegatorHelper,
20800             createAsyncValuesHelper: createAsyncValuesHelper,
20801             createRestHelper: createRestHelper,
20802             createAwaiterHelper: createAwaiterHelper,
20803             createExtendsHelper: createExtendsHelper,
20804             createTemplateObjectHelper: createTemplateObjectHelper,
20805             createSpreadArrayHelper: createSpreadArrayHelper,
20806             createValuesHelper: createValuesHelper,
20807             createReadHelper: createReadHelper,
20808             createGeneratorHelper: createGeneratorHelper,
20809             createCreateBindingHelper: createCreateBindingHelper,
20810             createImportStarHelper: createImportStarHelper,
20811             createImportStarCallbackHelper: createImportStarCallbackHelper,
20812             createImportDefaultHelper: createImportDefaultHelper,
20813             createExportStarHelper: createExportStarHelper,
20814             createClassPrivateFieldGetHelper: createClassPrivateFieldGetHelper,
20815             createClassPrivateFieldSetHelper: createClassPrivateFieldSetHelper,
20816         };
20817         function getUnscopedHelperName(name) {
20818             return ts.setEmitFlags(factory.createIdentifier(name), 4096 | 2);
20819         }
20820         function createDecorateHelper(decoratorExpressions, target, memberName, descriptor) {
20821             context.requestEmitHelper(ts.decorateHelper);
20822             var argumentsArray = [];
20823             argumentsArray.push(factory.createArrayLiteralExpression(decoratorExpressions, true));
20824             argumentsArray.push(target);
20825             if (memberName) {
20826                 argumentsArray.push(memberName);
20827                 if (descriptor) {
20828                     argumentsArray.push(descriptor);
20829                 }
20830             }
20831             return factory.createCallExpression(getUnscopedHelperName("__decorate"), undefined, argumentsArray);
20832         }
20833         function createMetadataHelper(metadataKey, metadataValue) {
20834             context.requestEmitHelper(ts.metadataHelper);
20835             return factory.createCallExpression(getUnscopedHelperName("__metadata"), undefined, [
20836                 factory.createStringLiteral(metadataKey),
20837                 metadataValue
20838             ]);
20839         }
20840         function createParamHelper(expression, parameterOffset, location) {
20841             context.requestEmitHelper(ts.paramHelper);
20842             return ts.setTextRange(factory.createCallExpression(getUnscopedHelperName("__param"), undefined, [
20843                 factory.createNumericLiteral(parameterOffset + ""),
20844                 expression
20845             ]), location);
20846         }
20847         function createAssignHelper(attributesSegments) {
20848             if (context.getCompilerOptions().target >= 2) {
20849                 return factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "assign"), undefined, attributesSegments);
20850             }
20851             context.requestEmitHelper(ts.assignHelper);
20852             return factory.createCallExpression(getUnscopedHelperName("__assign"), undefined, attributesSegments);
20853         }
20854         function createAwaitHelper(expression) {
20855             context.requestEmitHelper(ts.awaitHelper);
20856             return factory.createCallExpression(getUnscopedHelperName("__await"), undefined, [expression]);
20857         }
20858         function createAsyncGeneratorHelper(generatorFunc, hasLexicalThis) {
20859             context.requestEmitHelper(ts.awaitHelper);
20860             context.requestEmitHelper(ts.asyncGeneratorHelper);
20861             (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 | 524288;
20862             return factory.createCallExpression(getUnscopedHelperName("__asyncGenerator"), undefined, [
20863                 hasLexicalThis ? factory.createThis() : factory.createVoidZero(),
20864                 factory.createIdentifier("arguments"),
20865                 generatorFunc
20866             ]);
20867         }
20868         function createAsyncDelegatorHelper(expression) {
20869             context.requestEmitHelper(ts.awaitHelper);
20870             context.requestEmitHelper(ts.asyncDelegator);
20871             return factory.createCallExpression(getUnscopedHelperName("__asyncDelegator"), undefined, [expression]);
20872         }
20873         function createAsyncValuesHelper(expression) {
20874             context.requestEmitHelper(ts.asyncValues);
20875             return factory.createCallExpression(getUnscopedHelperName("__asyncValues"), undefined, [expression]);
20876         }
20877         function createRestHelper(value, elements, computedTempVariables, location) {
20878             context.requestEmitHelper(ts.restHelper);
20879             var propertyNames = [];
20880             var computedTempVariableOffset = 0;
20881             for (var i = 0; i < elements.length - 1; i++) {
20882                 var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(elements[i]);
20883                 if (propertyName) {
20884                     if (ts.isComputedPropertyName(propertyName)) {
20885                         ts.Debug.assertIsDefined(computedTempVariables, "Encountered computed property name but 'computedTempVariables' argument was not provided.");
20886                         var temp = computedTempVariables[computedTempVariableOffset];
20887                         computedTempVariableOffset++;
20888                         propertyNames.push(factory.createConditionalExpression(factory.createTypeCheck(temp, "symbol"), undefined, temp, undefined, factory.createAdd(temp, factory.createStringLiteral(""))));
20889                     }
20890                     else {
20891                         propertyNames.push(factory.createStringLiteralFromNode(propertyName));
20892                     }
20893                 }
20894             }
20895             return factory.createCallExpression(getUnscopedHelperName("__rest"), undefined, [
20896                 value,
20897                 ts.setTextRange(factory.createArrayLiteralExpression(propertyNames), location)
20898             ]);
20899         }
20900         function createAwaiterHelper(hasLexicalThis, hasLexicalArguments, promiseConstructor, body) {
20901             context.requestEmitHelper(ts.awaiterHelper);
20902             var generatorFunc = factory.createFunctionExpression(undefined, factory.createToken(41), undefined, undefined, [], undefined, body);
20903             (generatorFunc.emitNode || (generatorFunc.emitNode = {})).flags |= 262144 | 524288;
20904             return factory.createCallExpression(getUnscopedHelperName("__awaiter"), undefined, [
20905                 hasLexicalThis ? factory.createThis() : factory.createVoidZero(),
20906                 hasLexicalArguments ? factory.createIdentifier("arguments") : factory.createVoidZero(),
20907                 promiseConstructor ? ts.createExpressionFromEntityName(factory, promiseConstructor) : factory.createVoidZero(),
20908                 generatorFunc
20909             ]);
20910         }
20911         function createExtendsHelper(name) {
20912             context.requestEmitHelper(ts.extendsHelper);
20913             return factory.createCallExpression(getUnscopedHelperName("__extends"), undefined, [name, factory.createUniqueName("_super", 16 | 32)]);
20914         }
20915         function createTemplateObjectHelper(cooked, raw) {
20916             context.requestEmitHelper(ts.templateObjectHelper);
20917             return factory.createCallExpression(getUnscopedHelperName("__makeTemplateObject"), undefined, [cooked, raw]);
20918         }
20919         function createSpreadArrayHelper(to, from) {
20920             context.requestEmitHelper(ts.spreadArrayHelper);
20921             return factory.createCallExpression(getUnscopedHelperName("__spreadArray"), undefined, [to, from]);
20922         }
20923         function createValuesHelper(expression) {
20924             context.requestEmitHelper(ts.valuesHelper);
20925             return factory.createCallExpression(getUnscopedHelperName("__values"), undefined, [expression]);
20926         }
20927         function createReadHelper(iteratorRecord, count) {
20928             context.requestEmitHelper(ts.readHelper);
20929             return factory.createCallExpression(getUnscopedHelperName("__read"), undefined, count !== undefined
20930                 ? [iteratorRecord, factory.createNumericLiteral(count + "")]
20931                 : [iteratorRecord]);
20932         }
20933         function createGeneratorHelper(body) {
20934             context.requestEmitHelper(ts.generatorHelper);
20935             return factory.createCallExpression(getUnscopedHelperName("__generator"), undefined, [factory.createThis(), body]);
20936         }
20937         function createCreateBindingHelper(module, inputName, outputName) {
20938             context.requestEmitHelper(ts.createBindingHelper);
20939             return factory.createCallExpression(getUnscopedHelperName("__createBinding"), undefined, __spreadArray([factory.createIdentifier("exports"), module, inputName], (outputName ? [outputName] : [])));
20940         }
20941         function createImportStarHelper(expression) {
20942             context.requestEmitHelper(ts.importStarHelper);
20943             return factory.createCallExpression(getUnscopedHelperName("__importStar"), undefined, [expression]);
20944         }
20945         function createImportStarCallbackHelper() {
20946             context.requestEmitHelper(ts.importStarHelper);
20947             return getUnscopedHelperName("__importStar");
20948         }
20949         function createImportDefaultHelper(expression) {
20950             context.requestEmitHelper(ts.importDefaultHelper);
20951             return factory.createCallExpression(getUnscopedHelperName("__importDefault"), undefined, [expression]);
20952         }
20953         function createExportStarHelper(moduleExpression, exportsExpression) {
20954             if (exportsExpression === void 0) { exportsExpression = factory.createIdentifier("exports"); }
20955             context.requestEmitHelper(ts.exportStarHelper);
20956             context.requestEmitHelper(ts.createBindingHelper);
20957             return factory.createCallExpression(getUnscopedHelperName("__exportStar"), undefined, [moduleExpression, exportsExpression]);
20958         }
20959         function createClassPrivateFieldGetHelper(receiver, privateField) {
20960             context.requestEmitHelper(ts.classPrivateFieldGetHelper);
20961             return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldGet"), undefined, [receiver, privateField]);
20962         }
20963         function createClassPrivateFieldSetHelper(receiver, privateField, value) {
20964             context.requestEmitHelper(ts.classPrivateFieldSetHelper);
20965             return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldSet"), undefined, [receiver, privateField, value]);
20966         }
20967     }
20968     ts.createEmitHelperFactory = createEmitHelperFactory;
20969     function compareEmitHelpers(x, y) {
20970         if (x === y)
20971             return 0;
20972         if (x.priority === y.priority)
20973             return 0;
20974         if (x.priority === undefined)
20975             return 1;
20976         if (y.priority === undefined)
20977             return -1;
20978         return ts.compareValues(x.priority, y.priority);
20979     }
20980     ts.compareEmitHelpers = compareEmitHelpers;
20981     function helperString(input) {
20982         var args = [];
20983         for (var _i = 1; _i < arguments.length; _i++) {
20984             args[_i - 1] = arguments[_i];
20985         }
20986         return function (uniqueName) {
20987             var result = "";
20988             for (var i = 0; i < args.length; i++) {
20989                 result += input[i];
20990                 result += uniqueName(args[i]);
20991             }
20992             result += input[input.length - 1];
20993             return result;
20994         };
20995     }
20996     ts.helperString = helperString;
20997     ts.decorateHelper = {
20998         name: "typescript:decorate",
20999         importName: "__decorate",
21000         scoped: false,
21001         priority: 2,
21002         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            };"
21003     };
21004     ts.metadataHelper = {
21005         name: "typescript:metadata",
21006         importName: "__metadata",
21007         scoped: false,
21008         priority: 3,
21009         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            };"
21010     };
21011     ts.paramHelper = {
21012         name: "typescript:param",
21013         importName: "__param",
21014         scoped: false,
21015         priority: 4,
21016         text: "\n            var __param = (this && this.__param) || function (paramIndex, decorator) {\n                return function (target, key) { decorator(target, key, paramIndex); }\n            };"
21017     };
21018     ts.assignHelper = {
21019         name: "typescript:assign",
21020         importName: "__assign",
21021         scoped: false,
21022         priority: 1,
21023         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            };"
21024     };
21025     ts.awaitHelper = {
21026         name: "typescript:await",
21027         importName: "__await",
21028         scoped: false,
21029         text: "\n            var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }"
21030     };
21031     ts.asyncGeneratorHelper = {
21032         name: "typescript:asyncGenerator",
21033         importName: "__asyncGenerator",
21034         scoped: false,
21035         dependencies: [ts.awaitHelper],
21036         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            };"
21037     };
21038     ts.asyncDelegator = {
21039         name: "typescript:asyncDelegator",
21040         importName: "__asyncDelegator",
21041         scoped: false,
21042         dependencies: [ts.awaitHelper],
21043         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            };"
21044     };
21045     ts.asyncValues = {
21046         name: "typescript:asyncValues",
21047         importName: "__asyncValues",
21048         scoped: false,
21049         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            };"
21050     };
21051     ts.restHelper = {
21052         name: "typescript:rest",
21053         importName: "__rest",
21054         scoped: false,
21055         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            };"
21056     };
21057     ts.awaiterHelper = {
21058         name: "typescript:awaiter",
21059         importName: "__awaiter",
21060         scoped: false,
21061         priority: 5,
21062         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            };"
21063     };
21064     ts.extendsHelper = {
21065         name: "typescript:extends",
21066         importName: "__extends",
21067         scoped: false,
21068         priority: 0,
21069         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                    if (typeof b !== \"function\" && b !== null)\n                        throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\n                    extendStatics(d, b);\n                    function __() { this.constructor = d; }\n                    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\n                };\n            })();"
21070     };
21071     ts.templateObjectHelper = {
21072         name: "typescript:makeTemplateObject",
21073         importName: "__makeTemplateObject",
21074         scoped: false,
21075         priority: 0,
21076         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            };"
21077     };
21078     ts.readHelper = {
21079         name: "typescript:read",
21080         importName: "__read",
21081         scoped: false,
21082         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            };"
21083     };
21084     ts.spreadArrayHelper = {
21085         name: "typescript:spreadArray",
21086         importName: "__spreadArray",
21087         scoped: false,
21088         text: "\n            var __spreadArray = (this && this.__spreadArray) || function (to, from) {\n                for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)\n                    to[j] = from[i];\n                return to;\n            };"
21089     };
21090     ts.valuesHelper = {
21091         name: "typescript:values",
21092         importName: "__values",
21093         scoped: false,
21094         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            };"
21095     };
21096     ts.generatorHelper = {
21097         name: "typescript:generator",
21098         importName: "__generator",
21099         scoped: false,
21100         priority: 6,
21101         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            };"
21102     };
21103     ts.createBindingHelper = {
21104         name: "typescript:commonjscreatebinding",
21105         importName: "__createBinding",
21106         scoped: false,
21107         priority: 1,
21108         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            }));"
21109     };
21110     ts.setModuleDefaultHelper = {
21111         name: "typescript:commonjscreatevalue",
21112         importName: "__setModuleDefault",
21113         scoped: false,
21114         priority: 1,
21115         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            });"
21116     };
21117     ts.importStarHelper = {
21118         name: "typescript:commonjsimportstar",
21119         importName: "__importStar",
21120         scoped: false,
21121         dependencies: [ts.createBindingHelper, ts.setModuleDefaultHelper],
21122         priority: 2,
21123         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            };"
21124     };
21125     ts.importDefaultHelper = {
21126         name: "typescript:commonjsimportdefault",
21127         importName: "__importDefault",
21128         scoped: false,
21129         text: "\n            var __importDefault = (this && this.__importDefault) || function (mod) {\n                return (mod && mod.__esModule) ? mod : { \"default\": mod };\n            };"
21130     };
21131     ts.exportStarHelper = {
21132         name: "typescript:export-star",
21133         importName: "__exportStar",
21134         scoped: false,
21135         dependencies: [ts.createBindingHelper],
21136         priority: 2,
21137         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            };"
21138     };
21139     ts.classPrivateFieldGetHelper = {
21140         name: "typescript:classPrivateFieldGet",
21141         importName: "__classPrivateFieldGet",
21142         scoped: false,
21143         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            };"
21144     };
21145     ts.classPrivateFieldSetHelper = {
21146         name: "typescript:classPrivateFieldSet",
21147         importName: "__classPrivateFieldSet",
21148         scoped: false,
21149         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            };"
21150     };
21151     var allUnscopedEmitHelpers;
21152     function getAllUnscopedEmitHelpers() {
21153         return allUnscopedEmitHelpers || (allUnscopedEmitHelpers = ts.arrayToMap([
21154             ts.decorateHelper,
21155             ts.metadataHelper,
21156             ts.paramHelper,
21157             ts.assignHelper,
21158             ts.awaitHelper,
21159             ts.asyncGeneratorHelper,
21160             ts.asyncDelegator,
21161             ts.asyncValues,
21162             ts.restHelper,
21163             ts.awaiterHelper,
21164             ts.extendsHelper,
21165             ts.templateObjectHelper,
21166             ts.spreadArrayHelper,
21167             ts.valuesHelper,
21168             ts.readHelper,
21169             ts.generatorHelper,
21170             ts.importStarHelper,
21171             ts.importDefaultHelper,
21172             ts.exportStarHelper,
21173             ts.classPrivateFieldGetHelper,
21174             ts.classPrivateFieldSetHelper,
21175             ts.createBindingHelper,
21176             ts.setModuleDefaultHelper
21177         ], function (helper) { return helper.name; }));
21178     }
21179     ts.getAllUnscopedEmitHelpers = getAllUnscopedEmitHelpers;
21180     ts.asyncSuperHelper = {
21181         name: "typescript:async-super",
21182         scoped: true,
21183         text: helperString(__makeTemplateObject(["\n            const ", " = name => super[name];"], ["\n            const ", " = name => super[name];"]), "_superIndex")
21184     };
21185     ts.advancedAsyncSuperHelper = {
21186         name: "typescript:advanced-async-super",
21187         scoped: true,
21188         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")
21189     };
21190     function isCallToHelper(firstSegment, helperName) {
21191         return ts.isCallExpression(firstSegment)
21192             && ts.isIdentifier(firstSegment.expression)
21193             && (ts.getEmitFlags(firstSegment.expression) & 4096)
21194             && firstSegment.expression.escapedText === helperName;
21195     }
21196     ts.isCallToHelper = isCallToHelper;
21197 })(ts || (ts = {}));
21198 var ts;
21199 (function (ts) {
21200     function isNumericLiteral(node) {
21201         return node.kind === 8;
21202     }
21203     ts.isNumericLiteral = isNumericLiteral;
21204     function isBigIntLiteral(node) {
21205         return node.kind === 9;
21206     }
21207     ts.isBigIntLiteral = isBigIntLiteral;
21208     function isStringLiteral(node) {
21209         return node.kind === 10;
21210     }
21211     ts.isStringLiteral = isStringLiteral;
21212     function isJsxText(node) {
21213         return node.kind === 11;
21214     }
21215     ts.isJsxText = isJsxText;
21216     function isRegularExpressionLiteral(node) {
21217         return node.kind === 13;
21218     }
21219     ts.isRegularExpressionLiteral = isRegularExpressionLiteral;
21220     function isNoSubstitutionTemplateLiteral(node) {
21221         return node.kind === 14;
21222     }
21223     ts.isNoSubstitutionTemplateLiteral = isNoSubstitutionTemplateLiteral;
21224     function isTemplateHead(node) {
21225         return node.kind === 15;
21226     }
21227     ts.isTemplateHead = isTemplateHead;
21228     function isTemplateMiddle(node) {
21229         return node.kind === 16;
21230     }
21231     ts.isTemplateMiddle = isTemplateMiddle;
21232     function isTemplateTail(node) {
21233         return node.kind === 17;
21234     }
21235     ts.isTemplateTail = isTemplateTail;
21236     function isIdentifier(node) {
21237         return node.kind === 78;
21238     }
21239     ts.isIdentifier = isIdentifier;
21240     function isQualifiedName(node) {
21241         return node.kind === 157;
21242     }
21243     ts.isQualifiedName = isQualifiedName;
21244     function isComputedPropertyName(node) {
21245         return node.kind === 158;
21246     }
21247     ts.isComputedPropertyName = isComputedPropertyName;
21248     function isPrivateIdentifier(node) {
21249         return node.kind === 79;
21250     }
21251     ts.isPrivateIdentifier = isPrivateIdentifier;
21252     function isSuperKeyword(node) {
21253         return node.kind === 105;
21254     }
21255     ts.isSuperKeyword = isSuperKeyword;
21256     function isImportKeyword(node) {
21257         return node.kind === 99;
21258     }
21259     ts.isImportKeyword = isImportKeyword;
21260     function isCommaToken(node) {
21261         return node.kind === 27;
21262     }
21263     ts.isCommaToken = isCommaToken;
21264     function isQuestionToken(node) {
21265         return node.kind === 57;
21266     }
21267     ts.isQuestionToken = isQuestionToken;
21268     function isExclamationToken(node) {
21269         return node.kind === 53;
21270     }
21271     ts.isExclamationToken = isExclamationToken;
21272     function isTypeParameterDeclaration(node) {
21273         return node.kind === 159;
21274     }
21275     ts.isTypeParameterDeclaration = isTypeParameterDeclaration;
21276     function isParameter(node) {
21277         return node.kind === 160;
21278     }
21279     ts.isParameter = isParameter;
21280     function isDecorator(node) {
21281         return node.kind === 161;
21282     }
21283     ts.isDecorator = isDecorator;
21284     function isPropertySignature(node) {
21285         return node.kind === 162;
21286     }
21287     ts.isPropertySignature = isPropertySignature;
21288     function isPropertyDeclaration(node) {
21289         return node.kind === 163;
21290     }
21291     ts.isPropertyDeclaration = isPropertyDeclaration;
21292     function isMethodSignature(node) {
21293         return node.kind === 164;
21294     }
21295     ts.isMethodSignature = isMethodSignature;
21296     function isMethodDeclaration(node) {
21297         return node.kind === 165;
21298     }
21299     ts.isMethodDeclaration = isMethodDeclaration;
21300     function isConstructorDeclaration(node) {
21301         return node.kind === 166;
21302     }
21303     ts.isConstructorDeclaration = isConstructorDeclaration;
21304     function isGetAccessorDeclaration(node) {
21305         return node.kind === 167;
21306     }
21307     ts.isGetAccessorDeclaration = isGetAccessorDeclaration;
21308     function isSetAccessorDeclaration(node) {
21309         return node.kind === 168;
21310     }
21311     ts.isSetAccessorDeclaration = isSetAccessorDeclaration;
21312     function isCallSignatureDeclaration(node) {
21313         return node.kind === 169;
21314     }
21315     ts.isCallSignatureDeclaration = isCallSignatureDeclaration;
21316     function isConstructSignatureDeclaration(node) {
21317         return node.kind === 170;
21318     }
21319     ts.isConstructSignatureDeclaration = isConstructSignatureDeclaration;
21320     function isIndexSignatureDeclaration(node) {
21321         return node.kind === 171;
21322     }
21323     ts.isIndexSignatureDeclaration = isIndexSignatureDeclaration;
21324     function isTypePredicateNode(node) {
21325         return node.kind === 172;
21326     }
21327     ts.isTypePredicateNode = isTypePredicateNode;
21328     function isTypeReferenceNode(node) {
21329         return node.kind === 173;
21330     }
21331     ts.isTypeReferenceNode = isTypeReferenceNode;
21332     function isFunctionTypeNode(node) {
21333         return node.kind === 174;
21334     }
21335     ts.isFunctionTypeNode = isFunctionTypeNode;
21336     function isConstructorTypeNode(node) {
21337         return node.kind === 175;
21338     }
21339     ts.isConstructorTypeNode = isConstructorTypeNode;
21340     function isTypeQueryNode(node) {
21341         return node.kind === 176;
21342     }
21343     ts.isTypeQueryNode = isTypeQueryNode;
21344     function isTypeLiteralNode(node) {
21345         return node.kind === 177;
21346     }
21347     ts.isTypeLiteralNode = isTypeLiteralNode;
21348     function isArrayTypeNode(node) {
21349         return node.kind === 178;
21350     }
21351     ts.isArrayTypeNode = isArrayTypeNode;
21352     function isTupleTypeNode(node) {
21353         return node.kind === 179;
21354     }
21355     ts.isTupleTypeNode = isTupleTypeNode;
21356     function isNamedTupleMember(node) {
21357         return node.kind === 192;
21358     }
21359     ts.isNamedTupleMember = isNamedTupleMember;
21360     function isOptionalTypeNode(node) {
21361         return node.kind === 180;
21362     }
21363     ts.isOptionalTypeNode = isOptionalTypeNode;
21364     function isRestTypeNode(node) {
21365         return node.kind === 181;
21366     }
21367     ts.isRestTypeNode = isRestTypeNode;
21368     function isUnionTypeNode(node) {
21369         return node.kind === 182;
21370     }
21371     ts.isUnionTypeNode = isUnionTypeNode;
21372     function isIntersectionTypeNode(node) {
21373         return node.kind === 183;
21374     }
21375     ts.isIntersectionTypeNode = isIntersectionTypeNode;
21376     function isConditionalTypeNode(node) {
21377         return node.kind === 184;
21378     }
21379     ts.isConditionalTypeNode = isConditionalTypeNode;
21380     function isInferTypeNode(node) {
21381         return node.kind === 185;
21382     }
21383     ts.isInferTypeNode = isInferTypeNode;
21384     function isParenthesizedTypeNode(node) {
21385         return node.kind === 186;
21386     }
21387     ts.isParenthesizedTypeNode = isParenthesizedTypeNode;
21388     function isThisTypeNode(node) {
21389         return node.kind === 187;
21390     }
21391     ts.isThisTypeNode = isThisTypeNode;
21392     function isTypeOperatorNode(node) {
21393         return node.kind === 188;
21394     }
21395     ts.isTypeOperatorNode = isTypeOperatorNode;
21396     function isIndexedAccessTypeNode(node) {
21397         return node.kind === 189;
21398     }
21399     ts.isIndexedAccessTypeNode = isIndexedAccessTypeNode;
21400     function isMappedTypeNode(node) {
21401         return node.kind === 190;
21402     }
21403     ts.isMappedTypeNode = isMappedTypeNode;
21404     function isLiteralTypeNode(node) {
21405         return node.kind === 191;
21406     }
21407     ts.isLiteralTypeNode = isLiteralTypeNode;
21408     function isImportTypeNode(node) {
21409         return node.kind === 195;
21410     }
21411     ts.isImportTypeNode = isImportTypeNode;
21412     function isTemplateLiteralTypeSpan(node) {
21413         return node.kind === 194;
21414     }
21415     ts.isTemplateLiteralTypeSpan = isTemplateLiteralTypeSpan;
21416     function isTemplateLiteralTypeNode(node) {
21417         return node.kind === 193;
21418     }
21419     ts.isTemplateLiteralTypeNode = isTemplateLiteralTypeNode;
21420     function isObjectBindingPattern(node) {
21421         return node.kind === 196;
21422     }
21423     ts.isObjectBindingPattern = isObjectBindingPattern;
21424     function isArrayBindingPattern(node) {
21425         return node.kind === 197;
21426     }
21427     ts.isArrayBindingPattern = isArrayBindingPattern;
21428     function isBindingElement(node) {
21429         return node.kind === 198;
21430     }
21431     ts.isBindingElement = isBindingElement;
21432     function isArrayLiteralExpression(node) {
21433         return node.kind === 199;
21434     }
21435     ts.isArrayLiteralExpression = isArrayLiteralExpression;
21436     function isObjectLiteralExpression(node) {
21437         return node.kind === 200;
21438     }
21439     ts.isObjectLiteralExpression = isObjectLiteralExpression;
21440     function isPropertyAccessExpression(node) {
21441         return node.kind === 201;
21442     }
21443     ts.isPropertyAccessExpression = isPropertyAccessExpression;
21444     function isElementAccessExpression(node) {
21445         return node.kind === 202;
21446     }
21447     ts.isElementAccessExpression = isElementAccessExpression;
21448     function isCallExpression(node) {
21449         return node.kind === 203;
21450     }
21451     ts.isCallExpression = isCallExpression;
21452     function isNewExpression(node) {
21453         return node.kind === 204;
21454     }
21455     ts.isNewExpression = isNewExpression;
21456     function isTaggedTemplateExpression(node) {
21457         return node.kind === 205;
21458     }
21459     ts.isTaggedTemplateExpression = isTaggedTemplateExpression;
21460     function isTypeAssertionExpression(node) {
21461         return node.kind === 206;
21462     }
21463     ts.isTypeAssertionExpression = isTypeAssertionExpression;
21464     function isParenthesizedExpression(node) {
21465         return node.kind === 207;
21466     }
21467     ts.isParenthesizedExpression = isParenthesizedExpression;
21468     function isFunctionExpression(node) {
21469         return node.kind === 208;
21470     }
21471     ts.isFunctionExpression = isFunctionExpression;
21472     function isArrowFunction(node) {
21473         return node.kind === 209;
21474     }
21475     ts.isArrowFunction = isArrowFunction;
21476     function isDeleteExpression(node) {
21477         return node.kind === 210;
21478     }
21479     ts.isDeleteExpression = isDeleteExpression;
21480     function isTypeOfExpression(node) {
21481         return node.kind === 211;
21482     }
21483     ts.isTypeOfExpression = isTypeOfExpression;
21484     function isVoidExpression(node) {
21485         return node.kind === 212;
21486     }
21487     ts.isVoidExpression = isVoidExpression;
21488     function isAwaitExpression(node) {
21489         return node.kind === 213;
21490     }
21491     ts.isAwaitExpression = isAwaitExpression;
21492     function isPrefixUnaryExpression(node) {
21493         return node.kind === 214;
21494     }
21495     ts.isPrefixUnaryExpression = isPrefixUnaryExpression;
21496     function isPostfixUnaryExpression(node) {
21497         return node.kind === 215;
21498     }
21499     ts.isPostfixUnaryExpression = isPostfixUnaryExpression;
21500     function isBinaryExpression(node) {
21501         return node.kind === 216;
21502     }
21503     ts.isBinaryExpression = isBinaryExpression;
21504     function isConditionalExpression(node) {
21505         return node.kind === 217;
21506     }
21507     ts.isConditionalExpression = isConditionalExpression;
21508     function isTemplateExpression(node) {
21509         return node.kind === 218;
21510     }
21511     ts.isTemplateExpression = isTemplateExpression;
21512     function isYieldExpression(node) {
21513         return node.kind === 219;
21514     }
21515     ts.isYieldExpression = isYieldExpression;
21516     function isSpreadElement(node) {
21517         return node.kind === 220;
21518     }
21519     ts.isSpreadElement = isSpreadElement;
21520     function isClassExpression(node) {
21521         return node.kind === 221;
21522     }
21523     ts.isClassExpression = isClassExpression;
21524     function isOmittedExpression(node) {
21525         return node.kind === 222;
21526     }
21527     ts.isOmittedExpression = isOmittedExpression;
21528     function isExpressionWithTypeArguments(node) {
21529         return node.kind === 223;
21530     }
21531     ts.isExpressionWithTypeArguments = isExpressionWithTypeArguments;
21532     function isAsExpression(node) {
21533         return node.kind === 224;
21534     }
21535     ts.isAsExpression = isAsExpression;
21536     function isNonNullExpression(node) {
21537         return node.kind === 225;
21538     }
21539     ts.isNonNullExpression = isNonNullExpression;
21540     function isMetaProperty(node) {
21541         return node.kind === 226;
21542     }
21543     ts.isMetaProperty = isMetaProperty;
21544     function isSyntheticExpression(node) {
21545         return node.kind === 227;
21546     }
21547     ts.isSyntheticExpression = isSyntheticExpression;
21548     function isPartiallyEmittedExpression(node) {
21549         return node.kind === 336;
21550     }
21551     ts.isPartiallyEmittedExpression = isPartiallyEmittedExpression;
21552     function isCommaListExpression(node) {
21553         return node.kind === 337;
21554     }
21555     ts.isCommaListExpression = isCommaListExpression;
21556     function isTemplateSpan(node) {
21557         return node.kind === 228;
21558     }
21559     ts.isTemplateSpan = isTemplateSpan;
21560     function isSemicolonClassElement(node) {
21561         return node.kind === 229;
21562     }
21563     ts.isSemicolonClassElement = isSemicolonClassElement;
21564     function isBlock(node) {
21565         return node.kind === 230;
21566     }
21567     ts.isBlock = isBlock;
21568     function isVariableStatement(node) {
21569         return node.kind === 232;
21570     }
21571     ts.isVariableStatement = isVariableStatement;
21572     function isEmptyStatement(node) {
21573         return node.kind === 231;
21574     }
21575     ts.isEmptyStatement = isEmptyStatement;
21576     function isExpressionStatement(node) {
21577         return node.kind === 233;
21578     }
21579     ts.isExpressionStatement = isExpressionStatement;
21580     function isIfStatement(node) {
21581         return node.kind === 234;
21582     }
21583     ts.isIfStatement = isIfStatement;
21584     function isDoStatement(node) {
21585         return node.kind === 235;
21586     }
21587     ts.isDoStatement = isDoStatement;
21588     function isWhileStatement(node) {
21589         return node.kind === 236;
21590     }
21591     ts.isWhileStatement = isWhileStatement;
21592     function isForStatement(node) {
21593         return node.kind === 237;
21594     }
21595     ts.isForStatement = isForStatement;
21596     function isForInStatement(node) {
21597         return node.kind === 238;
21598     }
21599     ts.isForInStatement = isForInStatement;
21600     function isForOfStatement(node) {
21601         return node.kind === 239;
21602     }
21603     ts.isForOfStatement = isForOfStatement;
21604     function isContinueStatement(node) {
21605         return node.kind === 240;
21606     }
21607     ts.isContinueStatement = isContinueStatement;
21608     function isBreakStatement(node) {
21609         return node.kind === 241;
21610     }
21611     ts.isBreakStatement = isBreakStatement;
21612     function isReturnStatement(node) {
21613         return node.kind === 242;
21614     }
21615     ts.isReturnStatement = isReturnStatement;
21616     function isWithStatement(node) {
21617         return node.kind === 243;
21618     }
21619     ts.isWithStatement = isWithStatement;
21620     function isSwitchStatement(node) {
21621         return node.kind === 244;
21622     }
21623     ts.isSwitchStatement = isSwitchStatement;
21624     function isLabeledStatement(node) {
21625         return node.kind === 245;
21626     }
21627     ts.isLabeledStatement = isLabeledStatement;
21628     function isThrowStatement(node) {
21629         return node.kind === 246;
21630     }
21631     ts.isThrowStatement = isThrowStatement;
21632     function isTryStatement(node) {
21633         return node.kind === 247;
21634     }
21635     ts.isTryStatement = isTryStatement;
21636     function isDebuggerStatement(node) {
21637         return node.kind === 248;
21638     }
21639     ts.isDebuggerStatement = isDebuggerStatement;
21640     function isVariableDeclaration(node) {
21641         return node.kind === 249;
21642     }
21643     ts.isVariableDeclaration = isVariableDeclaration;
21644     function isVariableDeclarationList(node) {
21645         return node.kind === 250;
21646     }
21647     ts.isVariableDeclarationList = isVariableDeclarationList;
21648     function isFunctionDeclaration(node) {
21649         return node.kind === 251;
21650     }
21651     ts.isFunctionDeclaration = isFunctionDeclaration;
21652     function isClassDeclaration(node) {
21653         return node.kind === 252;
21654     }
21655     ts.isClassDeclaration = isClassDeclaration;
21656     function isInterfaceDeclaration(node) {
21657         return node.kind === 253;
21658     }
21659     ts.isInterfaceDeclaration = isInterfaceDeclaration;
21660     function isTypeAliasDeclaration(node) {
21661         return node.kind === 254;
21662     }
21663     ts.isTypeAliasDeclaration = isTypeAliasDeclaration;
21664     function isEnumDeclaration(node) {
21665         return node.kind === 255;
21666     }
21667     ts.isEnumDeclaration = isEnumDeclaration;
21668     function isModuleDeclaration(node) {
21669         return node.kind === 256;
21670     }
21671     ts.isModuleDeclaration = isModuleDeclaration;
21672     function isModuleBlock(node) {
21673         return node.kind === 257;
21674     }
21675     ts.isModuleBlock = isModuleBlock;
21676     function isCaseBlock(node) {
21677         return node.kind === 258;
21678     }
21679     ts.isCaseBlock = isCaseBlock;
21680     function isNamespaceExportDeclaration(node) {
21681         return node.kind === 259;
21682     }
21683     ts.isNamespaceExportDeclaration = isNamespaceExportDeclaration;
21684     function isImportEqualsDeclaration(node) {
21685         return node.kind === 260;
21686     }
21687     ts.isImportEqualsDeclaration = isImportEqualsDeclaration;
21688     function isImportDeclaration(node) {
21689         return node.kind === 261;
21690     }
21691     ts.isImportDeclaration = isImportDeclaration;
21692     function isImportClause(node) {
21693         return node.kind === 262;
21694     }
21695     ts.isImportClause = isImportClause;
21696     function isNamespaceImport(node) {
21697         return node.kind === 263;
21698     }
21699     ts.isNamespaceImport = isNamespaceImport;
21700     function isNamespaceExport(node) {
21701         return node.kind === 269;
21702     }
21703     ts.isNamespaceExport = isNamespaceExport;
21704     function isNamedImports(node) {
21705         return node.kind === 264;
21706     }
21707     ts.isNamedImports = isNamedImports;
21708     function isImportSpecifier(node) {
21709         return node.kind === 265;
21710     }
21711     ts.isImportSpecifier = isImportSpecifier;
21712     function isExportAssignment(node) {
21713         return node.kind === 266;
21714     }
21715     ts.isExportAssignment = isExportAssignment;
21716     function isExportDeclaration(node) {
21717         return node.kind === 267;
21718     }
21719     ts.isExportDeclaration = isExportDeclaration;
21720     function isNamedExports(node) {
21721         return node.kind === 268;
21722     }
21723     ts.isNamedExports = isNamedExports;
21724     function isExportSpecifier(node) {
21725         return node.kind === 270;
21726     }
21727     ts.isExportSpecifier = isExportSpecifier;
21728     function isMissingDeclaration(node) {
21729         return node.kind === 271;
21730     }
21731     ts.isMissingDeclaration = isMissingDeclaration;
21732     function isNotEmittedStatement(node) {
21733         return node.kind === 335;
21734     }
21735     ts.isNotEmittedStatement = isNotEmittedStatement;
21736     function isSyntheticReference(node) {
21737         return node.kind === 340;
21738     }
21739     ts.isSyntheticReference = isSyntheticReference;
21740     function isMergeDeclarationMarker(node) {
21741         return node.kind === 338;
21742     }
21743     ts.isMergeDeclarationMarker = isMergeDeclarationMarker;
21744     function isEndOfDeclarationMarker(node) {
21745         return node.kind === 339;
21746     }
21747     ts.isEndOfDeclarationMarker = isEndOfDeclarationMarker;
21748     function isExternalModuleReference(node) {
21749         return node.kind === 272;
21750     }
21751     ts.isExternalModuleReference = isExternalModuleReference;
21752     function isJsxElement(node) {
21753         return node.kind === 273;
21754     }
21755     ts.isJsxElement = isJsxElement;
21756     function isJsxSelfClosingElement(node) {
21757         return node.kind === 274;
21758     }
21759     ts.isJsxSelfClosingElement = isJsxSelfClosingElement;
21760     function isJsxOpeningElement(node) {
21761         return node.kind === 275;
21762     }
21763     ts.isJsxOpeningElement = isJsxOpeningElement;
21764     function isJsxClosingElement(node) {
21765         return node.kind === 276;
21766     }
21767     ts.isJsxClosingElement = isJsxClosingElement;
21768     function isJsxFragment(node) {
21769         return node.kind === 277;
21770     }
21771     ts.isJsxFragment = isJsxFragment;
21772     function isJsxOpeningFragment(node) {
21773         return node.kind === 278;
21774     }
21775     ts.isJsxOpeningFragment = isJsxOpeningFragment;
21776     function isJsxClosingFragment(node) {
21777         return node.kind === 279;
21778     }
21779     ts.isJsxClosingFragment = isJsxClosingFragment;
21780     function isJsxAttribute(node) {
21781         return node.kind === 280;
21782     }
21783     ts.isJsxAttribute = isJsxAttribute;
21784     function isJsxAttributes(node) {
21785         return node.kind === 281;
21786     }
21787     ts.isJsxAttributes = isJsxAttributes;
21788     function isJsxSpreadAttribute(node) {
21789         return node.kind === 282;
21790     }
21791     ts.isJsxSpreadAttribute = isJsxSpreadAttribute;
21792     function isJsxExpression(node) {
21793         return node.kind === 283;
21794     }
21795     ts.isJsxExpression = isJsxExpression;
21796     function isCaseClause(node) {
21797         return node.kind === 284;
21798     }
21799     ts.isCaseClause = isCaseClause;
21800     function isDefaultClause(node) {
21801         return node.kind === 285;
21802     }
21803     ts.isDefaultClause = isDefaultClause;
21804     function isHeritageClause(node) {
21805         return node.kind === 286;
21806     }
21807     ts.isHeritageClause = isHeritageClause;
21808     function isCatchClause(node) {
21809         return node.kind === 287;
21810     }
21811     ts.isCatchClause = isCatchClause;
21812     function isPropertyAssignment(node) {
21813         return node.kind === 288;
21814     }
21815     ts.isPropertyAssignment = isPropertyAssignment;
21816     function isShorthandPropertyAssignment(node) {
21817         return node.kind === 289;
21818     }
21819     ts.isShorthandPropertyAssignment = isShorthandPropertyAssignment;
21820     function isSpreadAssignment(node) {
21821         return node.kind === 290;
21822     }
21823     ts.isSpreadAssignment = isSpreadAssignment;
21824     function isEnumMember(node) {
21825         return node.kind === 291;
21826     }
21827     ts.isEnumMember = isEnumMember;
21828     function isUnparsedPrepend(node) {
21829         return node.kind === 293;
21830     }
21831     ts.isUnparsedPrepend = isUnparsedPrepend;
21832     function isSourceFile(node) {
21833         return node.kind === 297;
21834     }
21835     ts.isSourceFile = isSourceFile;
21836     function isBundle(node) {
21837         return node.kind === 298;
21838     }
21839     ts.isBundle = isBundle;
21840     function isUnparsedSource(node) {
21841         return node.kind === 299;
21842     }
21843     ts.isUnparsedSource = isUnparsedSource;
21844     function isJSDocTypeExpression(node) {
21845         return node.kind === 301;
21846     }
21847     ts.isJSDocTypeExpression = isJSDocTypeExpression;
21848     function isJSDocNameReference(node) {
21849         return node.kind === 302;
21850     }
21851     ts.isJSDocNameReference = isJSDocNameReference;
21852     function isJSDocAllType(node) {
21853         return node.kind === 303;
21854     }
21855     ts.isJSDocAllType = isJSDocAllType;
21856     function isJSDocUnknownType(node) {
21857         return node.kind === 304;
21858     }
21859     ts.isJSDocUnknownType = isJSDocUnknownType;
21860     function isJSDocNullableType(node) {
21861         return node.kind === 305;
21862     }
21863     ts.isJSDocNullableType = isJSDocNullableType;
21864     function isJSDocNonNullableType(node) {
21865         return node.kind === 306;
21866     }
21867     ts.isJSDocNonNullableType = isJSDocNonNullableType;
21868     function isJSDocOptionalType(node) {
21869         return node.kind === 307;
21870     }
21871     ts.isJSDocOptionalType = isJSDocOptionalType;
21872     function isJSDocFunctionType(node) {
21873         return node.kind === 308;
21874     }
21875     ts.isJSDocFunctionType = isJSDocFunctionType;
21876     function isJSDocVariadicType(node) {
21877         return node.kind === 309;
21878     }
21879     ts.isJSDocVariadicType = isJSDocVariadicType;
21880     function isJSDocNamepathType(node) {
21881         return node.kind === 310;
21882     }
21883     ts.isJSDocNamepathType = isJSDocNamepathType;
21884     function isJSDoc(node) {
21885         return node.kind === 311;
21886     }
21887     ts.isJSDoc = isJSDoc;
21888     function isJSDocTypeLiteral(node) {
21889         return node.kind === 312;
21890     }
21891     ts.isJSDocTypeLiteral = isJSDocTypeLiteral;
21892     function isJSDocSignature(node) {
21893         return node.kind === 313;
21894     }
21895     ts.isJSDocSignature = isJSDocSignature;
21896     function isJSDocAugmentsTag(node) {
21897         return node.kind === 315;
21898     }
21899     ts.isJSDocAugmentsTag = isJSDocAugmentsTag;
21900     function isJSDocAuthorTag(node) {
21901         return node.kind === 317;
21902     }
21903     ts.isJSDocAuthorTag = isJSDocAuthorTag;
21904     function isJSDocClassTag(node) {
21905         return node.kind === 319;
21906     }
21907     ts.isJSDocClassTag = isJSDocClassTag;
21908     function isJSDocCallbackTag(node) {
21909         return node.kind === 324;
21910     }
21911     ts.isJSDocCallbackTag = isJSDocCallbackTag;
21912     function isJSDocPublicTag(node) {
21913         return node.kind === 320;
21914     }
21915     ts.isJSDocPublicTag = isJSDocPublicTag;
21916     function isJSDocPrivateTag(node) {
21917         return node.kind === 321;
21918     }
21919     ts.isJSDocPrivateTag = isJSDocPrivateTag;
21920     function isJSDocProtectedTag(node) {
21921         return node.kind === 322;
21922     }
21923     ts.isJSDocProtectedTag = isJSDocProtectedTag;
21924     function isJSDocReadonlyTag(node) {
21925         return node.kind === 323;
21926     }
21927     ts.isJSDocReadonlyTag = isJSDocReadonlyTag;
21928     function isJSDocDeprecatedTag(node) {
21929         return node.kind === 318;
21930     }
21931     ts.isJSDocDeprecatedTag = isJSDocDeprecatedTag;
21932     function isJSDocSeeTag(node) {
21933         return node.kind === 332;
21934     }
21935     ts.isJSDocSeeTag = isJSDocSeeTag;
21936     function isJSDocEnumTag(node) {
21937         return node.kind === 325;
21938     }
21939     ts.isJSDocEnumTag = isJSDocEnumTag;
21940     function isJSDocParameterTag(node) {
21941         return node.kind === 326;
21942     }
21943     ts.isJSDocParameterTag = isJSDocParameterTag;
21944     function isJSDocReturnTag(node) {
21945         return node.kind === 327;
21946     }
21947     ts.isJSDocReturnTag = isJSDocReturnTag;
21948     function isJSDocThisTag(node) {
21949         return node.kind === 328;
21950     }
21951     ts.isJSDocThisTag = isJSDocThisTag;
21952     function isJSDocTypeTag(node) {
21953         return node.kind === 329;
21954     }
21955     ts.isJSDocTypeTag = isJSDocTypeTag;
21956     function isJSDocTemplateTag(node) {
21957         return node.kind === 330;
21958     }
21959     ts.isJSDocTemplateTag = isJSDocTemplateTag;
21960     function isJSDocTypedefTag(node) {
21961         return node.kind === 331;
21962     }
21963     ts.isJSDocTypedefTag = isJSDocTypedefTag;
21964     function isJSDocUnknownTag(node) {
21965         return node.kind === 314;
21966     }
21967     ts.isJSDocUnknownTag = isJSDocUnknownTag;
21968     function isJSDocPropertyTag(node) {
21969         return node.kind === 333;
21970     }
21971     ts.isJSDocPropertyTag = isJSDocPropertyTag;
21972     function isJSDocImplementsTag(node) {
21973         return node.kind === 316;
21974     }
21975     ts.isJSDocImplementsTag = isJSDocImplementsTag;
21976     function isSyntaxList(n) {
21977         return n.kind === 334;
21978     }
21979     ts.isSyntaxList = isSyntaxList;
21980 })(ts || (ts = {}));
21981 var ts;
21982 (function (ts) {
21983     function createEmptyExports(factory) {
21984         return factory.createExportDeclaration(undefined, undefined, false, factory.createNamedExports([]), undefined);
21985     }
21986     ts.createEmptyExports = createEmptyExports;
21987     function createMemberAccessForPropertyName(factory, target, memberName, location) {
21988         if (ts.isComputedPropertyName(memberName)) {
21989             return ts.setTextRange(factory.createElementAccessExpression(target, memberName.expression), location);
21990         }
21991         else {
21992             var expression = ts.setTextRange(ts.isIdentifierOrPrivateIdentifier(memberName)
21993                 ? factory.createPropertyAccessExpression(target, memberName)
21994                 : factory.createElementAccessExpression(target, memberName), memberName);
21995             ts.getOrCreateEmitNode(expression).flags |= 64;
21996             return expression;
21997         }
21998     }
21999     ts.createMemberAccessForPropertyName = createMemberAccessForPropertyName;
22000     function createReactNamespace(reactNamespace, parent) {
22001         var react = ts.parseNodeFactory.createIdentifier(reactNamespace || "React");
22002         ts.setParent(react, ts.getParseTreeNode(parent));
22003         return react;
22004     }
22005     function createJsxFactoryExpressionFromEntityName(factory, jsxFactory, parent) {
22006         if (ts.isQualifiedName(jsxFactory)) {
22007             var left = createJsxFactoryExpressionFromEntityName(factory, jsxFactory.left, parent);
22008             var right = factory.createIdentifier(ts.idText(jsxFactory.right));
22009             right.escapedText = jsxFactory.right.escapedText;
22010             return factory.createPropertyAccessExpression(left, right);
22011         }
22012         else {
22013             return createReactNamespace(ts.idText(jsxFactory), parent);
22014         }
22015     }
22016     function createJsxFactoryExpression(factory, jsxFactoryEntity, reactNamespace, parent) {
22017         return jsxFactoryEntity ?
22018             createJsxFactoryExpressionFromEntityName(factory, jsxFactoryEntity, parent) :
22019             factory.createPropertyAccessExpression(createReactNamespace(reactNamespace, parent), "createElement");
22020     }
22021     ts.createJsxFactoryExpression = createJsxFactoryExpression;
22022     function createJsxFragmentFactoryExpression(factory, jsxFragmentFactoryEntity, reactNamespace, parent) {
22023         return jsxFragmentFactoryEntity ?
22024             createJsxFactoryExpressionFromEntityName(factory, jsxFragmentFactoryEntity, parent) :
22025             factory.createPropertyAccessExpression(createReactNamespace(reactNamespace, parent), "Fragment");
22026     }
22027     function createExpressionForJsxElement(factory, callee, tagName, props, children, location) {
22028         var argumentsList = [tagName];
22029         if (props) {
22030             argumentsList.push(props);
22031         }
22032         if (children && children.length > 0) {
22033             if (!props) {
22034                 argumentsList.push(factory.createNull());
22035             }
22036             if (children.length > 1) {
22037                 for (var _i = 0, children_3 = children; _i < children_3.length; _i++) {
22038                     var child = children_3[_i];
22039                     startOnNewLine(child);
22040                     argumentsList.push(child);
22041                 }
22042             }
22043             else {
22044                 argumentsList.push(children[0]);
22045             }
22046         }
22047         return ts.setTextRange(factory.createCallExpression(callee, undefined, argumentsList), location);
22048     }
22049     ts.createExpressionForJsxElement = createExpressionForJsxElement;
22050     function createExpressionForJsxFragment(factory, jsxFactoryEntity, jsxFragmentFactoryEntity, reactNamespace, children, parentElement, location) {
22051         var tagName = createJsxFragmentFactoryExpression(factory, jsxFragmentFactoryEntity, reactNamespace, parentElement);
22052         var argumentsList = [tagName, factory.createNull()];
22053         if (children && children.length > 0) {
22054             if (children.length > 1) {
22055                 for (var _i = 0, children_4 = children; _i < children_4.length; _i++) {
22056                     var child = children_4[_i];
22057                     startOnNewLine(child);
22058                     argumentsList.push(child);
22059                 }
22060             }
22061             else {
22062                 argumentsList.push(children[0]);
22063             }
22064         }
22065         return ts.setTextRange(factory.createCallExpression(createJsxFactoryExpression(factory, jsxFactoryEntity, reactNamespace, parentElement), undefined, argumentsList), location);
22066     }
22067     ts.createExpressionForJsxFragment = createExpressionForJsxFragment;
22068     function createForOfBindingStatement(factory, node, boundValue) {
22069         if (ts.isVariableDeclarationList(node)) {
22070             var firstDeclaration = ts.first(node.declarations);
22071             var updatedDeclaration = factory.updateVariableDeclaration(firstDeclaration, firstDeclaration.name, undefined, undefined, boundValue);
22072             return ts.setTextRange(factory.createVariableStatement(undefined, factory.updateVariableDeclarationList(node, [updatedDeclaration])), node);
22073         }
22074         else {
22075             var updatedExpression = ts.setTextRange(factory.createAssignment(node, boundValue), node);
22076             return ts.setTextRange(factory.createExpressionStatement(updatedExpression), node);
22077         }
22078     }
22079     ts.createForOfBindingStatement = createForOfBindingStatement;
22080     function insertLeadingStatement(factory, dest, source) {
22081         if (ts.isBlock(dest)) {
22082             return factory.updateBlock(dest, ts.setTextRange(factory.createNodeArray(__spreadArray([source], dest.statements)), dest.statements));
22083         }
22084         else {
22085             return factory.createBlock(factory.createNodeArray([dest, source]), true);
22086         }
22087     }
22088     ts.insertLeadingStatement = insertLeadingStatement;
22089     function createExpressionFromEntityName(factory, node) {
22090         if (ts.isQualifiedName(node)) {
22091             var left = createExpressionFromEntityName(factory, node.left);
22092             var right = ts.setParent(ts.setTextRange(factory.cloneNode(node.right), node.right), node.right.parent);
22093             return ts.setTextRange(factory.createPropertyAccessExpression(left, right), node);
22094         }
22095         else {
22096             return ts.setParent(ts.setTextRange(factory.cloneNode(node), node), node.parent);
22097         }
22098     }
22099     ts.createExpressionFromEntityName = createExpressionFromEntityName;
22100     function createExpressionForPropertyName(factory, memberName) {
22101         if (ts.isIdentifier(memberName)) {
22102             return factory.createStringLiteralFromNode(memberName);
22103         }
22104         else if (ts.isComputedPropertyName(memberName)) {
22105             return ts.setParent(ts.setTextRange(factory.cloneNode(memberName.expression), memberName.expression), memberName.expression.parent);
22106         }
22107         else {
22108             return ts.setParent(ts.setTextRange(factory.cloneNode(memberName), memberName), memberName.parent);
22109         }
22110     }
22111     ts.createExpressionForPropertyName = createExpressionForPropertyName;
22112     function createExpressionForAccessorDeclaration(factory, properties, property, receiver, multiLine) {
22113         var _a = ts.getAllAccessorDeclarations(properties, property), firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
22114         if (property === firstAccessor) {
22115             return ts.setTextRange(factory.createObjectDefinePropertyCall(receiver, createExpressionForPropertyName(factory, property.name), factory.createPropertyDescriptor({
22116                 enumerable: factory.createFalse(),
22117                 configurable: true,
22118                 get: getAccessor && ts.setTextRange(ts.setOriginalNode(factory.createFunctionExpression(getAccessor.modifiers, undefined, undefined, undefined, getAccessor.parameters, undefined, getAccessor.body), getAccessor), getAccessor),
22119                 set: setAccessor && ts.setTextRange(ts.setOriginalNode(factory.createFunctionExpression(setAccessor.modifiers, undefined, undefined, undefined, setAccessor.parameters, undefined, setAccessor.body), setAccessor), setAccessor)
22120             }, !multiLine)), firstAccessor);
22121         }
22122         return undefined;
22123     }
22124     function createExpressionForPropertyAssignment(factory, property, receiver) {
22125         return ts.setOriginalNode(ts.setTextRange(factory.createAssignment(createMemberAccessForPropertyName(factory, receiver, property.name, property.name), property.initializer), property), property);
22126     }
22127     function createExpressionForShorthandPropertyAssignment(factory, property, receiver) {
22128         return ts.setOriginalNode(ts.setTextRange(factory.createAssignment(createMemberAccessForPropertyName(factory, receiver, property.name, property.name), factory.cloneNode(property.name)), property), property);
22129     }
22130     function createExpressionForMethodDeclaration(factory, method, receiver) {
22131         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);
22132     }
22133     function createExpressionForObjectLiteralElementLike(factory, node, property, receiver) {
22134         if (property.name && ts.isPrivateIdentifier(property.name)) {
22135             ts.Debug.failBadSyntaxKind(property.name, "Private identifiers are not allowed in object literals.");
22136         }
22137         switch (property.kind) {
22138             case 167:
22139             case 168:
22140                 return createExpressionForAccessorDeclaration(factory, node.properties, property, receiver, !!node.multiLine);
22141             case 288:
22142                 return createExpressionForPropertyAssignment(factory, property, receiver);
22143             case 289:
22144                 return createExpressionForShorthandPropertyAssignment(factory, property, receiver);
22145             case 165:
22146                 return createExpressionForMethodDeclaration(factory, property, receiver);
22147         }
22148     }
22149     ts.createExpressionForObjectLiteralElementLike = createExpressionForObjectLiteralElementLike;
22150     function isInternalName(node) {
22151         return (ts.getEmitFlags(node) & 32768) !== 0;
22152     }
22153     ts.isInternalName = isInternalName;
22154     function isLocalName(node) {
22155         return (ts.getEmitFlags(node) & 16384) !== 0;
22156     }
22157     ts.isLocalName = isLocalName;
22158     function isExportName(node) {
22159         return (ts.getEmitFlags(node) & 8192) !== 0;
22160     }
22161     ts.isExportName = isExportName;
22162     function isUseStrictPrologue(node) {
22163         return ts.isStringLiteral(node.expression) && node.expression.text === "use strict";
22164     }
22165     function findUseStrictPrologue(statements) {
22166         for (var _i = 0, statements_1 = statements; _i < statements_1.length; _i++) {
22167             var statement = statements_1[_i];
22168             if (ts.isPrologueDirective(statement)) {
22169                 if (isUseStrictPrologue(statement)) {
22170                     return statement;
22171                 }
22172             }
22173             else {
22174                 break;
22175             }
22176         }
22177         return undefined;
22178     }
22179     ts.findUseStrictPrologue = findUseStrictPrologue;
22180     function startsWithUseStrict(statements) {
22181         var firstStatement = ts.firstOrUndefined(statements);
22182         return firstStatement !== undefined
22183             && ts.isPrologueDirective(firstStatement)
22184             && isUseStrictPrologue(firstStatement);
22185     }
22186     ts.startsWithUseStrict = startsWithUseStrict;
22187     function isCommaSequence(node) {
22188         return node.kind === 216 && node.operatorToken.kind === 27 ||
22189             node.kind === 337;
22190     }
22191     ts.isCommaSequence = isCommaSequence;
22192     function isOuterExpression(node, kinds) {
22193         if (kinds === void 0) { kinds = 15; }
22194         switch (node.kind) {
22195             case 207:
22196                 return (kinds & 1) !== 0;
22197             case 206:
22198             case 224:
22199                 return (kinds & 2) !== 0;
22200             case 225:
22201                 return (kinds & 4) !== 0;
22202             case 336:
22203                 return (kinds & 8) !== 0;
22204         }
22205         return false;
22206     }
22207     ts.isOuterExpression = isOuterExpression;
22208     function skipOuterExpressions(node, kinds) {
22209         if (kinds === void 0) { kinds = 15; }
22210         while (isOuterExpression(node, kinds)) {
22211             node = node.expression;
22212         }
22213         return node;
22214     }
22215     ts.skipOuterExpressions = skipOuterExpressions;
22216     function skipAssertions(node) {
22217         return skipOuterExpressions(node, 6);
22218     }
22219     ts.skipAssertions = skipAssertions;
22220     function startOnNewLine(node) {
22221         return ts.setStartsOnNewLine(node, true);
22222     }
22223     ts.startOnNewLine = startOnNewLine;
22224     function getExternalHelpersModuleName(node) {
22225         var parseNode = ts.getOriginalNode(node, ts.isSourceFile);
22226         var emitNode = parseNode && parseNode.emitNode;
22227         return emitNode && emitNode.externalHelpersModuleName;
22228     }
22229     ts.getExternalHelpersModuleName = getExternalHelpersModuleName;
22230     function hasRecordedExternalHelpers(sourceFile) {
22231         var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile);
22232         var emitNode = parseNode && parseNode.emitNode;
22233         return !!emitNode && (!!emitNode.externalHelpersModuleName || !!emitNode.externalHelpers);
22234     }
22235     ts.hasRecordedExternalHelpers = hasRecordedExternalHelpers;
22236     function createExternalHelpersImportDeclarationIfNeeded(nodeFactory, helperFactory, sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault) {
22237         if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
22238             var namedBindings = void 0;
22239             var moduleKind = ts.getEmitModuleKind(compilerOptions);
22240             if (moduleKind >= ts.ModuleKind.ES2015 && moduleKind <= ts.ModuleKind.ESNext) {
22241                 var helpers = ts.getEmitHelpers(sourceFile);
22242                 if (helpers) {
22243                     var helperNames = [];
22244                     for (var _i = 0, helpers_3 = helpers; _i < helpers_3.length; _i++) {
22245                         var helper = helpers_3[_i];
22246                         if (!helper.scoped) {
22247                             var importName = helper.importName;
22248                             if (importName) {
22249                                 ts.pushIfUnique(helperNames, importName);
22250                             }
22251                         }
22252                     }
22253                     if (ts.some(helperNames)) {
22254                         helperNames.sort(ts.compareStringsCaseSensitive);
22255                         namedBindings = nodeFactory.createNamedImports(ts.map(helperNames, function (name) { return ts.isFileLevelUniqueName(sourceFile, name)
22256                             ? nodeFactory.createImportSpecifier(undefined, nodeFactory.createIdentifier(name))
22257                             : nodeFactory.createImportSpecifier(nodeFactory.createIdentifier(name), helperFactory.getUnscopedHelperName(name)); }));
22258                         var parseNode = ts.getOriginalNode(sourceFile, ts.isSourceFile);
22259                         var emitNode = ts.getOrCreateEmitNode(parseNode);
22260                         emitNode.externalHelpers = true;
22261                     }
22262                 }
22263             }
22264             else {
22265                 var externalHelpersModuleName = getOrCreateExternalHelpersModuleNameIfNeeded(nodeFactory, sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar || hasImportDefault);
22266                 if (externalHelpersModuleName) {
22267                     namedBindings = nodeFactory.createNamespaceImport(externalHelpersModuleName);
22268                 }
22269             }
22270             if (namedBindings) {
22271                 var externalHelpersImportDeclaration = nodeFactory.createImportDeclaration(undefined, undefined, nodeFactory.createImportClause(false, undefined, namedBindings), nodeFactory.createStringLiteral(ts.externalHelpersModuleNameText));
22272                 ts.addEmitFlags(externalHelpersImportDeclaration, 67108864);
22273                 return externalHelpersImportDeclaration;
22274             }
22275         }
22276     }
22277     ts.createExternalHelpersImportDeclarationIfNeeded = createExternalHelpersImportDeclarationIfNeeded;
22278     function getOrCreateExternalHelpersModuleNameIfNeeded(factory, node, compilerOptions, hasExportStarsToExportValues, hasImportStarOrImportDefault) {
22279         if (compilerOptions.importHelpers && ts.isEffectiveExternalModule(node, compilerOptions)) {
22280             var externalHelpersModuleName = getExternalHelpersModuleName(node);
22281             if (externalHelpersModuleName) {
22282                 return externalHelpersModuleName;
22283             }
22284             var moduleKind = ts.getEmitModuleKind(compilerOptions);
22285             var create = (hasExportStarsToExportValues || (compilerOptions.esModuleInterop && hasImportStarOrImportDefault))
22286                 && moduleKind !== ts.ModuleKind.System
22287                 && moduleKind < ts.ModuleKind.ES2015;
22288             if (!create) {
22289                 var helpers = ts.getEmitHelpers(node);
22290                 if (helpers) {
22291                     for (var _i = 0, helpers_4 = helpers; _i < helpers_4.length; _i++) {
22292                         var helper = helpers_4[_i];
22293                         if (!helper.scoped) {
22294                             create = true;
22295                             break;
22296                         }
22297                     }
22298                 }
22299             }
22300             if (create) {
22301                 var parseNode = ts.getOriginalNode(node, ts.isSourceFile);
22302                 var emitNode = ts.getOrCreateEmitNode(parseNode);
22303                 return emitNode.externalHelpersModuleName || (emitNode.externalHelpersModuleName = factory.createUniqueName(ts.externalHelpersModuleNameText));
22304             }
22305         }
22306     }
22307     ts.getOrCreateExternalHelpersModuleNameIfNeeded = getOrCreateExternalHelpersModuleNameIfNeeded;
22308     function getLocalNameForExternalImport(factory, node, sourceFile) {
22309         var namespaceDeclaration = ts.getNamespaceDeclarationNode(node);
22310         if (namespaceDeclaration && !ts.isDefaultImport(node) && !ts.isExportNamespaceAsDefaultDeclaration(node)) {
22311             var name = namespaceDeclaration.name;
22312             return ts.isGeneratedIdentifier(name) ? name : factory.createIdentifier(ts.getSourceTextOfNodeFromSourceFile(sourceFile, name) || ts.idText(name));
22313         }
22314         if (node.kind === 261 && node.importClause) {
22315             return factory.getGeneratedNameForNode(node);
22316         }
22317         if (node.kind === 267 && node.moduleSpecifier) {
22318             return factory.getGeneratedNameForNode(node);
22319         }
22320         return undefined;
22321     }
22322     ts.getLocalNameForExternalImport = getLocalNameForExternalImport;
22323     function getExternalModuleNameLiteral(factory, importNode, sourceFile, host, resolver, compilerOptions) {
22324         var moduleName = ts.getExternalModuleName(importNode);
22325         if (moduleName && ts.isStringLiteral(moduleName)) {
22326             return tryGetModuleNameFromDeclaration(importNode, host, factory, resolver, compilerOptions)
22327                 || tryRenameExternalModule(factory, moduleName, sourceFile)
22328                 || factory.cloneNode(moduleName);
22329         }
22330         return undefined;
22331     }
22332     ts.getExternalModuleNameLiteral = getExternalModuleNameLiteral;
22333     function tryRenameExternalModule(factory, moduleName, sourceFile) {
22334         var rename = sourceFile.renamedDependencies && sourceFile.renamedDependencies.get(moduleName.text);
22335         return rename ? factory.createStringLiteral(rename) : undefined;
22336     }
22337     function tryGetModuleNameFromFile(factory, file, host, options) {
22338         if (!file) {
22339             return undefined;
22340         }
22341         if (file.moduleName) {
22342             return factory.createStringLiteral(file.moduleName);
22343         }
22344         if (!file.isDeclarationFile && ts.outFile(options)) {
22345             return factory.createStringLiteral(ts.getExternalModuleNameFromPath(host, file.fileName));
22346         }
22347         return undefined;
22348     }
22349     ts.tryGetModuleNameFromFile = tryGetModuleNameFromFile;
22350     function tryGetModuleNameFromDeclaration(declaration, host, factory, resolver, compilerOptions) {
22351         return tryGetModuleNameFromFile(factory, resolver.getExternalModuleFileFromDeclaration(declaration), host, compilerOptions);
22352     }
22353     function getInitializerOfBindingOrAssignmentElement(bindingElement) {
22354         if (ts.isDeclarationBindingElement(bindingElement)) {
22355             return bindingElement.initializer;
22356         }
22357         if (ts.isPropertyAssignment(bindingElement)) {
22358             var initializer = bindingElement.initializer;
22359             return ts.isAssignmentExpression(initializer, true)
22360                 ? initializer.right
22361                 : undefined;
22362         }
22363         if (ts.isShorthandPropertyAssignment(bindingElement)) {
22364             return bindingElement.objectAssignmentInitializer;
22365         }
22366         if (ts.isAssignmentExpression(bindingElement, true)) {
22367             return bindingElement.right;
22368         }
22369         if (ts.isSpreadElement(bindingElement)) {
22370             return getInitializerOfBindingOrAssignmentElement(bindingElement.expression);
22371         }
22372     }
22373     ts.getInitializerOfBindingOrAssignmentElement = getInitializerOfBindingOrAssignmentElement;
22374     function getTargetOfBindingOrAssignmentElement(bindingElement) {
22375         if (ts.isDeclarationBindingElement(bindingElement)) {
22376             return bindingElement.name;
22377         }
22378         if (ts.isObjectLiteralElementLike(bindingElement)) {
22379             switch (bindingElement.kind) {
22380                 case 288:
22381                     return getTargetOfBindingOrAssignmentElement(bindingElement.initializer);
22382                 case 289:
22383                     return bindingElement.name;
22384                 case 290:
22385                     return getTargetOfBindingOrAssignmentElement(bindingElement.expression);
22386             }
22387             return undefined;
22388         }
22389         if (ts.isAssignmentExpression(bindingElement, true)) {
22390             return getTargetOfBindingOrAssignmentElement(bindingElement.left);
22391         }
22392         if (ts.isSpreadElement(bindingElement)) {
22393             return getTargetOfBindingOrAssignmentElement(bindingElement.expression);
22394         }
22395         return bindingElement;
22396     }
22397     ts.getTargetOfBindingOrAssignmentElement = getTargetOfBindingOrAssignmentElement;
22398     function getRestIndicatorOfBindingOrAssignmentElement(bindingElement) {
22399         switch (bindingElement.kind) {
22400             case 160:
22401             case 198:
22402                 return bindingElement.dotDotDotToken;
22403             case 220:
22404             case 290:
22405                 return bindingElement;
22406         }
22407         return undefined;
22408     }
22409     ts.getRestIndicatorOfBindingOrAssignmentElement = getRestIndicatorOfBindingOrAssignmentElement;
22410     function getPropertyNameOfBindingOrAssignmentElement(bindingElement) {
22411         var propertyName = tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement);
22412         ts.Debug.assert(!!propertyName || ts.isSpreadAssignment(bindingElement), "Invalid property name for binding element.");
22413         return propertyName;
22414     }
22415     ts.getPropertyNameOfBindingOrAssignmentElement = getPropertyNameOfBindingOrAssignmentElement;
22416     function tryGetPropertyNameOfBindingOrAssignmentElement(bindingElement) {
22417         switch (bindingElement.kind) {
22418             case 198:
22419                 if (bindingElement.propertyName) {
22420                     var propertyName = bindingElement.propertyName;
22421                     if (ts.isPrivateIdentifier(propertyName)) {
22422                         return ts.Debug.failBadSyntaxKind(propertyName);
22423                     }
22424                     return ts.isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression)
22425                         ? propertyName.expression
22426                         : propertyName;
22427                 }
22428                 break;
22429             case 288:
22430                 if (bindingElement.name) {
22431                     var propertyName = bindingElement.name;
22432                     if (ts.isPrivateIdentifier(propertyName)) {
22433                         return ts.Debug.failBadSyntaxKind(propertyName);
22434                     }
22435                     return ts.isComputedPropertyName(propertyName) && isStringOrNumericLiteral(propertyName.expression)
22436                         ? propertyName.expression
22437                         : propertyName;
22438                 }
22439                 break;
22440             case 290:
22441                 if (bindingElement.name && ts.isPrivateIdentifier(bindingElement.name)) {
22442                     return ts.Debug.failBadSyntaxKind(bindingElement.name);
22443                 }
22444                 return bindingElement.name;
22445         }
22446         var target = getTargetOfBindingOrAssignmentElement(bindingElement);
22447         if (target && ts.isPropertyName(target)) {
22448             return target;
22449         }
22450     }
22451     ts.tryGetPropertyNameOfBindingOrAssignmentElement = tryGetPropertyNameOfBindingOrAssignmentElement;
22452     function isStringOrNumericLiteral(node) {
22453         var kind = node.kind;
22454         return kind === 10
22455             || kind === 8;
22456     }
22457     function getElementsOfBindingOrAssignmentPattern(name) {
22458         switch (name.kind) {
22459             case 196:
22460             case 197:
22461             case 199:
22462                 return name.elements;
22463             case 200:
22464                 return name.properties;
22465         }
22466     }
22467     ts.getElementsOfBindingOrAssignmentPattern = getElementsOfBindingOrAssignmentPattern;
22468     function getJSDocTypeAliasName(fullName) {
22469         if (fullName) {
22470             var rightNode = fullName;
22471             while (true) {
22472                 if (ts.isIdentifier(rightNode) || !rightNode.body) {
22473                     return ts.isIdentifier(rightNode) ? rightNode : rightNode.name;
22474                 }
22475                 rightNode = rightNode.body;
22476             }
22477         }
22478     }
22479     ts.getJSDocTypeAliasName = getJSDocTypeAliasName;
22480     function canHaveModifiers(node) {
22481         var kind = node.kind;
22482         return kind === 160
22483             || kind === 162
22484             || kind === 163
22485             || kind === 164
22486             || kind === 165
22487             || kind === 166
22488             || kind === 167
22489             || kind === 168
22490             || kind === 171
22491             || kind === 208
22492             || kind === 209
22493             || kind === 221
22494             || kind === 232
22495             || kind === 251
22496             || kind === 252
22497             || kind === 253
22498             || kind === 254
22499             || kind === 255
22500             || kind === 256
22501             || kind === 260
22502             || kind === 261
22503             || kind === 266
22504             || kind === 267;
22505     }
22506     ts.canHaveModifiers = canHaveModifiers;
22507     function isExportModifier(node) {
22508         return node.kind === 92;
22509     }
22510     ts.isExportModifier = isExportModifier;
22511     function isAsyncModifier(node) {
22512         return node.kind === 129;
22513     }
22514     ts.isAsyncModifier = isAsyncModifier;
22515     function isStaticModifier(node) {
22516         return node.kind === 123;
22517     }
22518     ts.isStaticModifier = isStaticModifier;
22519 })(ts || (ts = {}));
22520 var ts;
22521 (function (ts) {
22522     function setTextRange(range, location) {
22523         return location ? ts.setTextRangePosEnd(range, location.pos, location.end) : range;
22524     }
22525     ts.setTextRange = setTextRange;
22526 })(ts || (ts = {}));
22527 var ts;
22528 (function (ts) {
22529     var NodeConstructor;
22530     var TokenConstructor;
22531     var IdentifierConstructor;
22532     var PrivateIdentifierConstructor;
22533     var SourceFileConstructor;
22534     ts.parseBaseNodeFactory = {
22535         createBaseSourceFileNode: function (kind) { return new (SourceFileConstructor || (SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor()))(kind, -1, -1); },
22536         createBaseIdentifierNode: function (kind) { return new (IdentifierConstructor || (IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor()))(kind, -1, -1); },
22537         createBasePrivateIdentifierNode: function (kind) { return new (PrivateIdentifierConstructor || (PrivateIdentifierConstructor = ts.objectAllocator.getPrivateIdentifierConstructor()))(kind, -1, -1); },
22538         createBaseTokenNode: function (kind) { return new (TokenConstructor || (TokenConstructor = ts.objectAllocator.getTokenConstructor()))(kind, -1, -1); },
22539         createBaseNode: function (kind) { return new (NodeConstructor || (NodeConstructor = ts.objectAllocator.getNodeConstructor()))(kind, -1, -1); },
22540     };
22541     ts.parseNodeFactory = ts.createNodeFactory(1, ts.parseBaseNodeFactory);
22542     function visitNode(cbNode, node) {
22543         return node && cbNode(node);
22544     }
22545     function visitNodes(cbNode, cbNodes, nodes) {
22546         if (nodes) {
22547             if (cbNodes) {
22548                 return cbNodes(nodes);
22549             }
22550             for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
22551                 var node = nodes_1[_i];
22552                 var result = cbNode(node);
22553                 if (result) {
22554                     return result;
22555                 }
22556             }
22557         }
22558     }
22559     function isJSDocLikeText(text, start) {
22560         return text.charCodeAt(start + 1) === 42 &&
22561             text.charCodeAt(start + 2) === 42 &&
22562             text.charCodeAt(start + 3) !== 47;
22563     }
22564     ts.isJSDocLikeText = isJSDocLikeText;
22565     function forEachChild(node, cbNode, cbNodes) {
22566         if (!node || node.kind <= 156) {
22567             return;
22568         }
22569         switch (node.kind) {
22570             case 157:
22571                 return visitNode(cbNode, node.left) ||
22572                     visitNode(cbNode, node.right);
22573             case 159:
22574                 return visitNode(cbNode, node.name) ||
22575                     visitNode(cbNode, node.constraint) ||
22576                     visitNode(cbNode, node.default) ||
22577                     visitNode(cbNode, node.expression);
22578             case 289:
22579                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22580                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22581                     visitNode(cbNode, node.name) ||
22582                     visitNode(cbNode, node.questionToken) ||
22583                     visitNode(cbNode, node.exclamationToken) ||
22584                     visitNode(cbNode, node.equalsToken) ||
22585                     visitNode(cbNode, node.objectAssignmentInitializer);
22586             case 290:
22587                 return visitNode(cbNode, node.expression);
22588             case 160:
22589                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22590                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22591                     visitNode(cbNode, node.dotDotDotToken) ||
22592                     visitNode(cbNode, node.name) ||
22593                     visitNode(cbNode, node.questionToken) ||
22594                     visitNode(cbNode, node.type) ||
22595                     visitNode(cbNode, node.initializer);
22596             case 163:
22597                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22598                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22599                     visitNode(cbNode, node.name) ||
22600                     visitNode(cbNode, node.questionToken) ||
22601                     visitNode(cbNode, node.exclamationToken) ||
22602                     visitNode(cbNode, node.type) ||
22603                     visitNode(cbNode, node.initializer);
22604             case 162:
22605                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22606                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22607                     visitNode(cbNode, node.name) ||
22608                     visitNode(cbNode, node.questionToken) ||
22609                     visitNode(cbNode, node.type) ||
22610                     visitNode(cbNode, node.initializer);
22611             case 288:
22612                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22613                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22614                     visitNode(cbNode, node.name) ||
22615                     visitNode(cbNode, node.questionToken) ||
22616                     visitNode(cbNode, node.initializer);
22617             case 249:
22618                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22619                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22620                     visitNode(cbNode, node.name) ||
22621                     visitNode(cbNode, node.exclamationToken) ||
22622                     visitNode(cbNode, node.type) ||
22623                     visitNode(cbNode, node.initializer);
22624             case 198:
22625                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22626                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22627                     visitNode(cbNode, node.dotDotDotToken) ||
22628                     visitNode(cbNode, node.propertyName) ||
22629                     visitNode(cbNode, node.name) ||
22630                     visitNode(cbNode, node.initializer);
22631             case 174:
22632             case 175:
22633             case 169:
22634             case 170:
22635             case 171:
22636                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22637                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22638                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
22639                     visitNodes(cbNode, cbNodes, node.parameters) ||
22640                     visitNode(cbNode, node.type);
22641             case 165:
22642             case 164:
22643             case 166:
22644             case 167:
22645             case 168:
22646             case 208:
22647             case 251:
22648             case 209:
22649                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22650                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22651                     visitNode(cbNode, node.asteriskToken) ||
22652                     visitNode(cbNode, node.name) ||
22653                     visitNode(cbNode, node.questionToken) ||
22654                     visitNode(cbNode, node.exclamationToken) ||
22655                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
22656                     visitNodes(cbNode, cbNodes, node.parameters) ||
22657                     visitNode(cbNode, node.type) ||
22658                     visitNode(cbNode, node.equalsGreaterThanToken) ||
22659                     visitNode(cbNode, node.body);
22660             case 173:
22661                 return visitNode(cbNode, node.typeName) ||
22662                     visitNodes(cbNode, cbNodes, node.typeArguments);
22663             case 172:
22664                 return visitNode(cbNode, node.assertsModifier) ||
22665                     visitNode(cbNode, node.parameterName) ||
22666                     visitNode(cbNode, node.type);
22667             case 176:
22668                 return visitNode(cbNode, node.exprName);
22669             case 177:
22670                 return visitNodes(cbNode, cbNodes, node.members);
22671             case 178:
22672                 return visitNode(cbNode, node.elementType);
22673             case 179:
22674                 return visitNodes(cbNode, cbNodes, node.elements);
22675             case 182:
22676             case 183:
22677                 return visitNodes(cbNode, cbNodes, node.types);
22678             case 184:
22679                 return visitNode(cbNode, node.checkType) ||
22680                     visitNode(cbNode, node.extendsType) ||
22681                     visitNode(cbNode, node.trueType) ||
22682                     visitNode(cbNode, node.falseType);
22683             case 185:
22684                 return visitNode(cbNode, node.typeParameter);
22685             case 195:
22686                 return visitNode(cbNode, node.argument) ||
22687                     visitNode(cbNode, node.qualifier) ||
22688                     visitNodes(cbNode, cbNodes, node.typeArguments);
22689             case 186:
22690             case 188:
22691                 return visitNode(cbNode, node.type);
22692             case 189:
22693                 return visitNode(cbNode, node.objectType) ||
22694                     visitNode(cbNode, node.indexType);
22695             case 190:
22696                 return visitNode(cbNode, node.readonlyToken) ||
22697                     visitNode(cbNode, node.typeParameter) ||
22698                     visitNode(cbNode, node.nameType) ||
22699                     visitNode(cbNode, node.questionToken) ||
22700                     visitNode(cbNode, node.type);
22701             case 191:
22702                 return visitNode(cbNode, node.literal);
22703             case 192:
22704                 return visitNode(cbNode, node.dotDotDotToken) ||
22705                     visitNode(cbNode, node.name) ||
22706                     visitNode(cbNode, node.questionToken) ||
22707                     visitNode(cbNode, node.type);
22708             case 196:
22709             case 197:
22710                 return visitNodes(cbNode, cbNodes, node.elements);
22711             case 199:
22712                 return visitNodes(cbNode, cbNodes, node.elements);
22713             case 200:
22714                 return visitNodes(cbNode, cbNodes, node.properties);
22715             case 201:
22716                 return visitNode(cbNode, node.expression) ||
22717                     visitNode(cbNode, node.questionDotToken) ||
22718                     visitNode(cbNode, node.name);
22719             case 202:
22720                 return visitNode(cbNode, node.expression) ||
22721                     visitNode(cbNode, node.questionDotToken) ||
22722                     visitNode(cbNode, node.argumentExpression);
22723             case 203:
22724             case 204:
22725                 return visitNode(cbNode, node.expression) ||
22726                     visitNode(cbNode, node.questionDotToken) ||
22727                     visitNodes(cbNode, cbNodes, node.typeArguments) ||
22728                     visitNodes(cbNode, cbNodes, node.arguments);
22729             case 205:
22730                 return visitNode(cbNode, node.tag) ||
22731                     visitNode(cbNode, node.questionDotToken) ||
22732                     visitNodes(cbNode, cbNodes, node.typeArguments) ||
22733                     visitNode(cbNode, node.template);
22734             case 206:
22735                 return visitNode(cbNode, node.type) ||
22736                     visitNode(cbNode, node.expression);
22737             case 207:
22738                 return visitNode(cbNode, node.expression);
22739             case 210:
22740                 return visitNode(cbNode, node.expression);
22741             case 211:
22742                 return visitNode(cbNode, node.expression);
22743             case 212:
22744                 return visitNode(cbNode, node.expression);
22745             case 214:
22746                 return visitNode(cbNode, node.operand);
22747             case 219:
22748                 return visitNode(cbNode, node.asteriskToken) ||
22749                     visitNode(cbNode, node.expression);
22750             case 213:
22751                 return visitNode(cbNode, node.expression);
22752             case 215:
22753                 return visitNode(cbNode, node.operand);
22754             case 216:
22755                 return visitNode(cbNode, node.left) ||
22756                     visitNode(cbNode, node.operatorToken) ||
22757                     visitNode(cbNode, node.right);
22758             case 224:
22759                 return visitNode(cbNode, node.expression) ||
22760                     visitNode(cbNode, node.type);
22761             case 225:
22762                 return visitNode(cbNode, node.expression);
22763             case 226:
22764                 return visitNode(cbNode, node.name);
22765             case 217:
22766                 return visitNode(cbNode, node.condition) ||
22767                     visitNode(cbNode, node.questionToken) ||
22768                     visitNode(cbNode, node.whenTrue) ||
22769                     visitNode(cbNode, node.colonToken) ||
22770                     visitNode(cbNode, node.whenFalse);
22771             case 220:
22772                 return visitNode(cbNode, node.expression);
22773             case 230:
22774             case 257:
22775                 return visitNodes(cbNode, cbNodes, node.statements);
22776             case 297:
22777                 return visitNodes(cbNode, cbNodes, node.statements) ||
22778                     visitNode(cbNode, node.endOfFileToken);
22779             case 232:
22780                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22781                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22782                     visitNode(cbNode, node.declarationList);
22783             case 250:
22784                 return visitNodes(cbNode, cbNodes, node.declarations);
22785             case 233:
22786                 return visitNode(cbNode, node.expression);
22787             case 234:
22788                 return visitNode(cbNode, node.expression) ||
22789                     visitNode(cbNode, node.thenStatement) ||
22790                     visitNode(cbNode, node.elseStatement);
22791             case 235:
22792                 return visitNode(cbNode, node.statement) ||
22793                     visitNode(cbNode, node.expression);
22794             case 236:
22795                 return visitNode(cbNode, node.expression) ||
22796                     visitNode(cbNode, node.statement);
22797             case 237:
22798                 return visitNode(cbNode, node.initializer) ||
22799                     visitNode(cbNode, node.condition) ||
22800                     visitNode(cbNode, node.incrementor) ||
22801                     visitNode(cbNode, node.statement);
22802             case 238:
22803                 return visitNode(cbNode, node.initializer) ||
22804                     visitNode(cbNode, node.expression) ||
22805                     visitNode(cbNode, node.statement);
22806             case 239:
22807                 return visitNode(cbNode, node.awaitModifier) ||
22808                     visitNode(cbNode, node.initializer) ||
22809                     visitNode(cbNode, node.expression) ||
22810                     visitNode(cbNode, node.statement);
22811             case 240:
22812             case 241:
22813                 return visitNode(cbNode, node.label);
22814             case 242:
22815                 return visitNode(cbNode, node.expression);
22816             case 243:
22817                 return visitNode(cbNode, node.expression) ||
22818                     visitNode(cbNode, node.statement);
22819             case 244:
22820                 return visitNode(cbNode, node.expression) ||
22821                     visitNode(cbNode, node.caseBlock);
22822             case 258:
22823                 return visitNodes(cbNode, cbNodes, node.clauses);
22824             case 284:
22825                 return visitNode(cbNode, node.expression) ||
22826                     visitNodes(cbNode, cbNodes, node.statements);
22827             case 285:
22828                 return visitNodes(cbNode, cbNodes, node.statements);
22829             case 245:
22830                 return visitNode(cbNode, node.label) ||
22831                     visitNode(cbNode, node.statement);
22832             case 246:
22833                 return visitNode(cbNode, node.expression);
22834             case 247:
22835                 return visitNode(cbNode, node.tryBlock) ||
22836                     visitNode(cbNode, node.catchClause) ||
22837                     visitNode(cbNode, node.finallyBlock);
22838             case 287:
22839                 return visitNode(cbNode, node.variableDeclaration) ||
22840                     visitNode(cbNode, node.block);
22841             case 161:
22842                 return visitNode(cbNode, node.expression);
22843             case 252:
22844             case 221:
22845                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22846                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22847                     visitNode(cbNode, node.name) ||
22848                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
22849                     visitNodes(cbNode, cbNodes, node.heritageClauses) ||
22850                     visitNodes(cbNode, cbNodes, node.members);
22851             case 253:
22852                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22853                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22854                     visitNode(cbNode, node.name) ||
22855                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
22856                     visitNodes(cbNode, cbNodes, node.heritageClauses) ||
22857                     visitNodes(cbNode, cbNodes, node.members);
22858             case 254:
22859                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22860                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22861                     visitNode(cbNode, node.name) ||
22862                     visitNodes(cbNode, cbNodes, node.typeParameters) ||
22863                     visitNode(cbNode, node.type);
22864             case 255:
22865                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22866                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22867                     visitNode(cbNode, node.name) ||
22868                     visitNodes(cbNode, cbNodes, node.members);
22869             case 291:
22870                 return visitNode(cbNode, node.name) ||
22871                     visitNode(cbNode, node.initializer);
22872             case 256:
22873                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22874                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22875                     visitNode(cbNode, node.name) ||
22876                     visitNode(cbNode, node.body);
22877             case 260:
22878                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22879                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22880                     visitNode(cbNode, node.name) ||
22881                     visitNode(cbNode, node.moduleReference);
22882             case 261:
22883                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22884                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22885                     visitNode(cbNode, node.importClause) ||
22886                     visitNode(cbNode, node.moduleSpecifier);
22887             case 262:
22888                 return visitNode(cbNode, node.name) ||
22889                     visitNode(cbNode, node.namedBindings);
22890             case 259:
22891                 return visitNode(cbNode, node.name);
22892             case 263:
22893                 return visitNode(cbNode, node.name);
22894             case 269:
22895                 return visitNode(cbNode, node.name);
22896             case 264:
22897             case 268:
22898                 return visitNodes(cbNode, cbNodes, node.elements);
22899             case 267:
22900                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22901                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22902                     visitNode(cbNode, node.exportClause) ||
22903                     visitNode(cbNode, node.moduleSpecifier);
22904             case 265:
22905             case 270:
22906                 return visitNode(cbNode, node.propertyName) ||
22907                     visitNode(cbNode, node.name);
22908             case 266:
22909                 return visitNodes(cbNode, cbNodes, node.decorators) ||
22910                     visitNodes(cbNode, cbNodes, node.modifiers) ||
22911                     visitNode(cbNode, node.expression);
22912             case 218:
22913                 return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans);
22914             case 228:
22915                 return visitNode(cbNode, node.expression) || visitNode(cbNode, node.literal);
22916             case 193:
22917                 return visitNode(cbNode, node.head) || visitNodes(cbNode, cbNodes, node.templateSpans);
22918             case 194:
22919                 return visitNode(cbNode, node.type) || visitNode(cbNode, node.literal);
22920             case 158:
22921                 return visitNode(cbNode, node.expression);
22922             case 286:
22923                 return visitNodes(cbNode, cbNodes, node.types);
22924             case 223:
22925                 return visitNode(cbNode, node.expression) ||
22926                     visitNodes(cbNode, cbNodes, node.typeArguments);
22927             case 272:
22928                 return visitNode(cbNode, node.expression);
22929             case 271:
22930                 return visitNodes(cbNode, cbNodes, node.decorators);
22931             case 337:
22932                 return visitNodes(cbNode, cbNodes, node.elements);
22933             case 273:
22934                 return visitNode(cbNode, node.openingElement) ||
22935                     visitNodes(cbNode, cbNodes, node.children) ||
22936                     visitNode(cbNode, node.closingElement);
22937             case 277:
22938                 return visitNode(cbNode, node.openingFragment) ||
22939                     visitNodes(cbNode, cbNodes, node.children) ||
22940                     visitNode(cbNode, node.closingFragment);
22941             case 274:
22942             case 275:
22943                 return visitNode(cbNode, node.tagName) ||
22944                     visitNodes(cbNode, cbNodes, node.typeArguments) ||
22945                     visitNode(cbNode, node.attributes);
22946             case 281:
22947                 return visitNodes(cbNode, cbNodes, node.properties);
22948             case 280:
22949                 return visitNode(cbNode, node.name) ||
22950                     visitNode(cbNode, node.initializer);
22951             case 282:
22952                 return visitNode(cbNode, node.expression);
22953             case 283:
22954                 return visitNode(cbNode, node.dotDotDotToken) ||
22955                     visitNode(cbNode, node.expression);
22956             case 276:
22957                 return visitNode(cbNode, node.tagName);
22958             case 180:
22959             case 181:
22960             case 301:
22961             case 306:
22962             case 305:
22963             case 307:
22964             case 309:
22965                 return visitNode(cbNode, node.type);
22966             case 308:
22967                 return visitNodes(cbNode, cbNodes, node.parameters) ||
22968                     visitNode(cbNode, node.type);
22969             case 311:
22970                 return visitNodes(cbNode, cbNodes, node.tags);
22971             case 332:
22972                 return visitNode(cbNode, node.tagName) ||
22973                     visitNode(cbNode, node.name);
22974             case 302:
22975                 return visitNode(cbNode, node.name);
22976             case 326:
22977             case 333:
22978                 return visitNode(cbNode, node.tagName) ||
22979                     (node.isNameFirst
22980                         ? visitNode(cbNode, node.name) ||
22981                             visitNode(cbNode, node.typeExpression)
22982                         : visitNode(cbNode, node.typeExpression) ||
22983                             visitNode(cbNode, node.name));
22984             case 317:
22985                 return visitNode(cbNode, node.tagName);
22986             case 316:
22987                 return visitNode(cbNode, node.tagName) ||
22988                     visitNode(cbNode, node.class);
22989             case 315:
22990                 return visitNode(cbNode, node.tagName) ||
22991                     visitNode(cbNode, node.class);
22992             case 330:
22993                 return visitNode(cbNode, node.tagName) ||
22994                     visitNode(cbNode, node.constraint) ||
22995                     visitNodes(cbNode, cbNodes, node.typeParameters);
22996             case 331:
22997                 return visitNode(cbNode, node.tagName) ||
22998                     (node.typeExpression &&
22999                         node.typeExpression.kind === 301
23000                         ? visitNode(cbNode, node.typeExpression) ||
23001                             visitNode(cbNode, node.fullName)
23002                         : visitNode(cbNode, node.fullName) ||
23003                             visitNode(cbNode, node.typeExpression));
23004             case 324:
23005                 return visitNode(cbNode, node.tagName) ||
23006                     visitNode(cbNode, node.fullName) ||
23007                     visitNode(cbNode, node.typeExpression);
23008             case 327:
23009             case 329:
23010             case 328:
23011             case 325:
23012                 return visitNode(cbNode, node.tagName) ||
23013                     visitNode(cbNode, node.typeExpression);
23014             case 313:
23015                 return ts.forEach(node.typeParameters, cbNode) ||
23016                     ts.forEach(node.parameters, cbNode) ||
23017                     visitNode(cbNode, node.type);
23018             case 312:
23019                 return ts.forEach(node.jsDocPropertyTags, cbNode);
23020             case 314:
23021             case 319:
23022             case 320:
23023             case 321:
23024             case 322:
23025             case 323:
23026                 return visitNode(cbNode, node.tagName);
23027             case 336:
23028                 return visitNode(cbNode, node.expression);
23029         }
23030     }
23031     ts.forEachChild = forEachChild;
23032     function forEachChildRecursively(rootNode, cbNode, cbNodes) {
23033         var queue = gatherPossibleChildren(rootNode);
23034         var parents = [];
23035         while (parents.length < queue.length) {
23036             parents.push(rootNode);
23037         }
23038         while (queue.length !== 0) {
23039             var current = queue.pop();
23040             var parent = parents.pop();
23041             if (ts.isArray(current)) {
23042                 if (cbNodes) {
23043                     var res = cbNodes(current, parent);
23044                     if (res) {
23045                         if (res === "skip")
23046                             continue;
23047                         return res;
23048                     }
23049                 }
23050                 for (var i = current.length - 1; i >= 0; --i) {
23051                     queue.push(current[i]);
23052                     parents.push(parent);
23053                 }
23054             }
23055             else {
23056                 var res = cbNode(current, parent);
23057                 if (res) {
23058                     if (res === "skip")
23059                         continue;
23060                     return res;
23061                 }
23062                 if (current.kind >= 157) {
23063                     for (var _i = 0, _a = gatherPossibleChildren(current); _i < _a.length; _i++) {
23064                         var child = _a[_i];
23065                         queue.push(child);
23066                         parents.push(current);
23067                     }
23068                 }
23069             }
23070         }
23071     }
23072     ts.forEachChildRecursively = forEachChildRecursively;
23073     function gatherPossibleChildren(node) {
23074         var children = [];
23075         forEachChild(node, addWorkItem, addWorkItem);
23076         return children;
23077         function addWorkItem(n) {
23078             children.unshift(n);
23079         }
23080     }
23081     function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) {
23082         if (setParentNodes === void 0) { setParentNodes = false; }
23083         ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse", "createSourceFile", { path: fileName }, true);
23084         ts.performance.mark("beforeParse");
23085         var result;
23086         ts.perfLogger.logStartParseSourceFile(fileName);
23087         if (languageVersion === 100) {
23088             result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, 6);
23089         }
23090         else {
23091             result = Parser.parseSourceFile(fileName, sourceText, languageVersion, undefined, setParentNodes, scriptKind);
23092         }
23093         ts.perfLogger.logStopParseSourceFile();
23094         ts.performance.mark("afterParse");
23095         ts.performance.measure("Parse", "beforeParse", "afterParse");
23096         ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
23097         return result;
23098     }
23099     ts.createSourceFile = createSourceFile;
23100     function parseIsolatedEntityName(text, languageVersion) {
23101         return Parser.parseIsolatedEntityName(text, languageVersion);
23102     }
23103     ts.parseIsolatedEntityName = parseIsolatedEntityName;
23104     function parseJsonText(fileName, sourceText) {
23105         return Parser.parseJsonText(fileName, sourceText);
23106     }
23107     ts.parseJsonText = parseJsonText;
23108     function isExternalModule(file) {
23109         return file.externalModuleIndicator !== undefined;
23110     }
23111     ts.isExternalModule = isExternalModule;
23112     function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) {
23113         if (aggressiveChecks === void 0) { aggressiveChecks = false; }
23114         var newSourceFile = IncrementalParser.updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks);
23115         newSourceFile.flags |= (sourceFile.flags & 3145728);
23116         return newSourceFile;
23117     }
23118     ts.updateSourceFile = updateSourceFile;
23119     function parseIsolatedJSDocComment(content, start, length) {
23120         var result = Parser.JSDocParser.parseIsolatedJSDocComment(content, start, length);
23121         if (result && result.jsDoc) {
23122             Parser.fixupParentReferences(result.jsDoc);
23123         }
23124         return result;
23125     }
23126     ts.parseIsolatedJSDocComment = parseIsolatedJSDocComment;
23127     function parseJSDocTypeExpressionForTests(content, start, length) {
23128         return Parser.JSDocParser.parseJSDocTypeExpressionForTests(content, start, length);
23129     }
23130     ts.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests;
23131     var Parser;
23132     (function (Parser) {
23133         var scanner = ts.createScanner(99, true);
23134         var disallowInAndDecoratorContext = 4096 | 16384;
23135         var NodeConstructor;
23136         var TokenConstructor;
23137         var IdentifierConstructor;
23138         var PrivateIdentifierConstructor;
23139         var SourceFileConstructor;
23140         function countNode(node) {
23141             nodeCount++;
23142             return node;
23143         }
23144         var baseNodeFactory = {
23145             createBaseSourceFileNode: function (kind) { return countNode(new SourceFileConstructor(kind, 0, 0)); },
23146             createBaseIdentifierNode: function (kind) { return countNode(new IdentifierConstructor(kind, 0, 0)); },
23147             createBasePrivateIdentifierNode: function (kind) { return countNode(new PrivateIdentifierConstructor(kind, 0, 0)); },
23148             createBaseTokenNode: function (kind) { return countNode(new TokenConstructor(kind, 0, 0)); },
23149             createBaseNode: function (kind) { return countNode(new NodeConstructor(kind, 0, 0)); }
23150         };
23151         var factory = ts.createNodeFactory(1 | 2 | 8, baseNodeFactory);
23152         var fileName;
23153         var sourceFlags;
23154         var sourceText;
23155         var languageVersion;
23156         var scriptKind;
23157         var languageVariant;
23158         var parseDiagnostics;
23159         var jsDocDiagnostics;
23160         var syntaxCursor;
23161         var currentToken;
23162         var nodeCount;
23163         var identifiers;
23164         var privateIdentifiers;
23165         var identifierCount;
23166         var parsingContext;
23167         var notParenthesizedArrow;
23168         var contextFlags;
23169         var topLevel = true;
23170         var parseErrorBeforeNextFinishedNode = false;
23171         function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) {
23172             if (setParentNodes === void 0) { setParentNodes = false; }
23173             scriptKind = ts.ensureScriptKind(fileName, scriptKind);
23174             if (scriptKind === 6) {
23175                 var result_3 = parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes);
23176                 ts.convertToObjectWorker(result_3, result_3.parseDiagnostics, false, undefined, undefined);
23177                 result_3.referencedFiles = ts.emptyArray;
23178                 result_3.typeReferenceDirectives = ts.emptyArray;
23179                 result_3.libReferenceDirectives = ts.emptyArray;
23180                 result_3.amdDependencies = ts.emptyArray;
23181                 result_3.hasNoDefaultLib = false;
23182                 result_3.pragmas = ts.emptyMap;
23183                 return result_3;
23184             }
23185             initializeState(fileName, sourceText, languageVersion, syntaxCursor, scriptKind);
23186             var result = parseSourceFileWorker(languageVersion, setParentNodes, scriptKind);
23187             clearState();
23188             return result;
23189         }
23190         Parser.parseSourceFile = parseSourceFile;
23191         function parseIsolatedEntityName(content, languageVersion) {
23192             initializeState("", content, languageVersion, undefined, 1);
23193             nextToken();
23194             var entityName = parseEntityName(true);
23195             var isInvalid = token() === 1 && !parseDiagnostics.length;
23196             clearState();
23197             return isInvalid ? entityName : undefined;
23198         }
23199         Parser.parseIsolatedEntityName = parseIsolatedEntityName;
23200         function parseJsonText(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes) {
23201             if (languageVersion === void 0) { languageVersion = 2; }
23202             if (setParentNodes === void 0) { setParentNodes = false; }
23203             initializeState(fileName, sourceText, languageVersion, syntaxCursor, 6);
23204             sourceFlags = contextFlags;
23205             nextToken();
23206             var pos = getNodePos();
23207             var statements, endOfFileToken;
23208             if (token() === 1) {
23209                 statements = createNodeArray([], pos, pos);
23210                 endOfFileToken = parseTokenNode();
23211             }
23212             else {
23213                 var expression = void 0;
23214                 switch (token()) {
23215                     case 22:
23216                         expression = parseArrayLiteralExpression();
23217                         break;
23218                     case 109:
23219                     case 94:
23220                     case 103:
23221                         expression = parseTokenNode();
23222                         break;
23223                     case 40:
23224                         if (lookAhead(function () { return nextToken() === 8 && nextToken() !== 58; })) {
23225                             expression = parsePrefixUnaryExpression();
23226                         }
23227                         else {
23228                             expression = parseObjectLiteralExpression();
23229                         }
23230                         break;
23231                     case 8:
23232                     case 10:
23233                         if (lookAhead(function () { return nextToken() !== 58; })) {
23234                             expression = parseLiteralNode();
23235                             break;
23236                         }
23237                     default:
23238                         expression = parseObjectLiteralExpression();
23239                         break;
23240                 }
23241                 var statement = factory.createExpressionStatement(expression);
23242                 finishNode(statement, pos);
23243                 statements = createNodeArray([statement], pos);
23244                 endOfFileToken = parseExpectedToken(1, ts.Diagnostics.Unexpected_token);
23245             }
23246             var sourceFile = createSourceFile(fileName, 2, 6, false, statements, endOfFileToken, sourceFlags);
23247             if (setParentNodes) {
23248                 fixupParentReferences(sourceFile);
23249             }
23250             sourceFile.nodeCount = nodeCount;
23251             sourceFile.identifierCount = identifierCount;
23252             sourceFile.identifiers = identifiers;
23253             sourceFile.parseDiagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
23254             if (jsDocDiagnostics) {
23255                 sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile);
23256             }
23257             var result = sourceFile;
23258             clearState();
23259             return result;
23260         }
23261         Parser.parseJsonText = parseJsonText;
23262         function initializeState(_fileName, _sourceText, _languageVersion, _syntaxCursor, _scriptKind) {
23263             NodeConstructor = ts.objectAllocator.getNodeConstructor();
23264             TokenConstructor = ts.objectAllocator.getTokenConstructor();
23265             IdentifierConstructor = ts.objectAllocator.getIdentifierConstructor();
23266             PrivateIdentifierConstructor = ts.objectAllocator.getPrivateIdentifierConstructor();
23267             SourceFileConstructor = ts.objectAllocator.getSourceFileConstructor();
23268             fileName = ts.normalizePath(_fileName);
23269             sourceText = _sourceText;
23270             languageVersion = _languageVersion;
23271             syntaxCursor = _syntaxCursor;
23272             scriptKind = _scriptKind;
23273             languageVariant = ts.getLanguageVariant(_scriptKind);
23274             parseDiagnostics = [];
23275             parsingContext = 0;
23276             identifiers = new ts.Map();
23277             privateIdentifiers = new ts.Map();
23278             identifierCount = 0;
23279             nodeCount = 0;
23280             sourceFlags = 0;
23281             topLevel = true;
23282             switch (scriptKind) {
23283                 case 1:
23284                 case 2:
23285                     contextFlags = 131072;
23286                     break;
23287                 case 6:
23288                     contextFlags = 131072 | 33554432;
23289                     break;
23290                 default:
23291                     contextFlags = 0;
23292                     break;
23293             }
23294             parseErrorBeforeNextFinishedNode = false;
23295             scanner.setText(sourceText);
23296             scanner.setOnError(scanError);
23297             scanner.setScriptTarget(languageVersion);
23298             scanner.setLanguageVariant(languageVariant);
23299         }
23300         function clearState() {
23301             scanner.clearCommentDirectives();
23302             scanner.setText("");
23303             scanner.setOnError(undefined);
23304             sourceText = undefined;
23305             languageVersion = undefined;
23306             syntaxCursor = undefined;
23307             scriptKind = undefined;
23308             languageVariant = undefined;
23309             sourceFlags = 0;
23310             parseDiagnostics = undefined;
23311             jsDocDiagnostics = undefined;
23312             parsingContext = 0;
23313             identifiers = undefined;
23314             notParenthesizedArrow = undefined;
23315             topLevel = true;
23316         }
23317         function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind) {
23318             var isDeclarationFile = isDeclarationFileName(fileName);
23319             if (isDeclarationFile) {
23320                 contextFlags |= 8388608;
23321             }
23322             sourceFlags = contextFlags;
23323             nextToken();
23324             var statements = parseList(0, parseStatement);
23325             ts.Debug.assert(token() === 1);
23326             var endOfFileToken = addJSDocComment(parseTokenNode());
23327             var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags);
23328             processCommentPragmas(sourceFile, sourceText);
23329             processPragmasIntoFields(sourceFile, reportPragmaDiagnostic);
23330             sourceFile.commentDirectives = scanner.getCommentDirectives();
23331             sourceFile.nodeCount = nodeCount;
23332             sourceFile.identifierCount = identifierCount;
23333             sourceFile.identifiers = identifiers;
23334             sourceFile.parseDiagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
23335             if (jsDocDiagnostics) {
23336                 sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile);
23337             }
23338             if (setParentNodes) {
23339                 fixupParentReferences(sourceFile);
23340             }
23341             return sourceFile;
23342             function reportPragmaDiagnostic(pos, end, diagnostic) {
23343                 parseDiagnostics.push(ts.createDetachedDiagnostic(fileName, pos, end, diagnostic));
23344             }
23345         }
23346         function withJSDoc(node, hasJSDoc) {
23347             return hasJSDoc ? addJSDocComment(node) : node;
23348         }
23349         var hasDeprecatedTag = false;
23350         function addJSDocComment(node) {
23351             ts.Debug.assert(!node.jsDoc);
23352             var jsDoc = ts.mapDefined(ts.getJSDocCommentRanges(node, sourceText), function (comment) { return JSDocParser.parseJSDocComment(node, comment.pos, comment.end - comment.pos); });
23353             if (jsDoc.length)
23354                 node.jsDoc = jsDoc;
23355             if (hasDeprecatedTag) {
23356                 hasDeprecatedTag = false;
23357                 node.flags |= 134217728;
23358             }
23359             return node;
23360         }
23361         function reparseTopLevelAwait(sourceFile) {
23362             var savedSyntaxCursor = syntaxCursor;
23363             var baseSyntaxCursor = IncrementalParser.createSyntaxCursor(sourceFile);
23364             syntaxCursor = { currentNode: currentNode };
23365             var statements = [];
23366             var savedParseDiagnostics = parseDiagnostics;
23367             parseDiagnostics = [];
23368             var pos = 0;
23369             var start = findNextStatementWithAwait(sourceFile.statements, 0);
23370             var _loop_3 = function () {
23371                 var prevStatement = sourceFile.statements[pos];
23372                 var nextStatement = sourceFile.statements[start];
23373                 ts.addRange(statements, sourceFile.statements, pos, start);
23374                 pos = findNextStatementWithoutAwait(sourceFile.statements, start);
23375                 var diagnosticStart = ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= prevStatement.pos; });
23376                 var diagnosticEnd = diagnosticStart >= 0 ? ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= nextStatement.pos; }, diagnosticStart) : -1;
23377                 if (diagnosticStart >= 0) {
23378                     ts.addRange(parseDiagnostics, savedParseDiagnostics, diagnosticStart, diagnosticEnd >= 0 ? diagnosticEnd : undefined);
23379                 }
23380                 speculationHelper(function () {
23381                     var savedContextFlags = contextFlags;
23382                     contextFlags |= 32768;
23383                     scanner.setTextPos(nextStatement.pos);
23384                     nextToken();
23385                     while (token() !== 1) {
23386                         var startPos = scanner.getStartPos();
23387                         var statement = parseListElement(0, parseStatement);
23388                         statements.push(statement);
23389                         if (startPos === scanner.getStartPos()) {
23390                             nextToken();
23391                         }
23392                         if (pos >= 0) {
23393                             var nonAwaitStatement = sourceFile.statements[pos];
23394                             if (statement.end === nonAwaitStatement.pos) {
23395                                 break;
23396                             }
23397                             if (statement.end > nonAwaitStatement.pos) {
23398                                 pos = findNextStatementWithoutAwait(sourceFile.statements, pos + 1);
23399                             }
23400                         }
23401                     }
23402                     contextFlags = savedContextFlags;
23403                 }, 2);
23404                 start = pos >= 0 ? findNextStatementWithAwait(sourceFile.statements, pos) : -1;
23405             };
23406             while (start !== -1) {
23407                 _loop_3();
23408             }
23409             if (pos >= 0) {
23410                 var prevStatement_1 = sourceFile.statements[pos];
23411                 ts.addRange(statements, sourceFile.statements, pos);
23412                 var diagnosticStart = ts.findIndex(savedParseDiagnostics, function (diagnostic) { return diagnostic.start >= prevStatement_1.pos; });
23413                 if (diagnosticStart >= 0) {
23414                     ts.addRange(parseDiagnostics, savedParseDiagnostics, diagnosticStart);
23415                 }
23416             }
23417             syntaxCursor = savedSyntaxCursor;
23418             return factory.updateSourceFile(sourceFile, ts.setTextRange(factory.createNodeArray(statements), sourceFile.statements));
23419             function containsPossibleTopLevelAwait(node) {
23420                 return !(node.flags & 32768)
23421                     && !!(node.transformFlags & 8388608);
23422             }
23423             function findNextStatementWithAwait(statements, start) {
23424                 for (var i = start; i < statements.length; i++) {
23425                     if (containsPossibleTopLevelAwait(statements[i])) {
23426                         return i;
23427                     }
23428                 }
23429                 return -1;
23430             }
23431             function findNextStatementWithoutAwait(statements, start) {
23432                 for (var i = start; i < statements.length; i++) {
23433                     if (!containsPossibleTopLevelAwait(statements[i])) {
23434                         return i;
23435                     }
23436                 }
23437                 return -1;
23438             }
23439             function currentNode(position) {
23440                 var node = baseSyntaxCursor.currentNode(position);
23441                 if (topLevel && node && containsPossibleTopLevelAwait(node)) {
23442                     node.intersectsChange = true;
23443                 }
23444                 return node;
23445             }
23446         }
23447         function fixupParentReferences(rootNode) {
23448             ts.setParentRecursive(rootNode, true);
23449         }
23450         Parser.fixupParentReferences = fixupParentReferences;
23451         function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, flags) {
23452             var sourceFile = factory.createSourceFile(statements, endOfFileToken, flags);
23453             ts.setTextRangePosWidth(sourceFile, 0, sourceText.length);
23454             setExternalModuleIndicator(sourceFile);
23455             if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 8388608) {
23456                 sourceFile = reparseTopLevelAwait(sourceFile);
23457             }
23458             sourceFile.text = sourceText;
23459             sourceFile.bindDiagnostics = [];
23460             sourceFile.bindSuggestionDiagnostics = undefined;
23461             sourceFile.languageVersion = languageVersion;
23462             sourceFile.fileName = fileName;
23463             sourceFile.languageVariant = ts.getLanguageVariant(scriptKind);
23464             sourceFile.isDeclarationFile = isDeclarationFile;
23465             sourceFile.scriptKind = scriptKind;
23466             return sourceFile;
23467         }
23468         function setContextFlag(val, flag) {
23469             if (val) {
23470                 contextFlags |= flag;
23471             }
23472             else {
23473                 contextFlags &= ~flag;
23474             }
23475         }
23476         function setDisallowInContext(val) {
23477             setContextFlag(val, 4096);
23478         }
23479         function setYieldContext(val) {
23480             setContextFlag(val, 8192);
23481         }
23482         function setDecoratorContext(val) {
23483             setContextFlag(val, 16384);
23484         }
23485         function setAwaitContext(val) {
23486             setContextFlag(val, 32768);
23487         }
23488         function doOutsideOfContext(context, func) {
23489             var contextFlagsToClear = context & contextFlags;
23490             if (contextFlagsToClear) {
23491                 setContextFlag(false, contextFlagsToClear);
23492                 var result = func();
23493                 setContextFlag(true, contextFlagsToClear);
23494                 return result;
23495             }
23496             return func();
23497         }
23498         function doInsideOfContext(context, func) {
23499             var contextFlagsToSet = context & ~contextFlags;
23500             if (contextFlagsToSet) {
23501                 setContextFlag(true, contextFlagsToSet);
23502                 var result = func();
23503                 setContextFlag(false, contextFlagsToSet);
23504                 return result;
23505             }
23506             return func();
23507         }
23508         function allowInAnd(func) {
23509             return doOutsideOfContext(4096, func);
23510         }
23511         function disallowInAnd(func) {
23512             return doInsideOfContext(4096, func);
23513         }
23514         function doInYieldContext(func) {
23515             return doInsideOfContext(8192, func);
23516         }
23517         function doInDecoratorContext(func) {
23518             return doInsideOfContext(16384, func);
23519         }
23520         function doInAwaitContext(func) {
23521             return doInsideOfContext(32768, func);
23522         }
23523         function doOutsideOfAwaitContext(func) {
23524             return doOutsideOfContext(32768, func);
23525         }
23526         function doInYieldAndAwaitContext(func) {
23527             return doInsideOfContext(8192 | 32768, func);
23528         }
23529         function doOutsideOfYieldAndAwaitContext(func) {
23530             return doOutsideOfContext(8192 | 32768, func);
23531         }
23532         function inContext(flags) {
23533             return (contextFlags & flags) !== 0;
23534         }
23535         function inYieldContext() {
23536             return inContext(8192);
23537         }
23538         function inDisallowInContext() {
23539             return inContext(4096);
23540         }
23541         function inDecoratorContext() {
23542             return inContext(16384);
23543         }
23544         function inAwaitContext() {
23545             return inContext(32768);
23546         }
23547         function parseErrorAtCurrentToken(message, arg0) {
23548             parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), message, arg0);
23549         }
23550         function parseErrorAtPosition(start, length, message, arg0) {
23551             var lastError = ts.lastOrUndefined(parseDiagnostics);
23552             if (!lastError || start !== lastError.start) {
23553                 parseDiagnostics.push(ts.createDetachedDiagnostic(fileName, start, length, message, arg0));
23554             }
23555             parseErrorBeforeNextFinishedNode = true;
23556         }
23557         function parseErrorAt(start, end, message, arg0) {
23558             parseErrorAtPosition(start, end - start, message, arg0);
23559         }
23560         function parseErrorAtRange(range, message, arg0) {
23561             parseErrorAt(range.pos, range.end, message, arg0);
23562         }
23563         function scanError(message, length) {
23564             parseErrorAtPosition(scanner.getTextPos(), length, message);
23565         }
23566         function getNodePos() {
23567             return scanner.getStartPos();
23568         }
23569         function hasPrecedingJSDocComment() {
23570             return scanner.hasPrecedingJSDocComment();
23571         }
23572         function token() {
23573             return currentToken;
23574         }
23575         function nextTokenWithoutCheck() {
23576             return currentToken = scanner.scan();
23577         }
23578         function nextTokenAnd(func) {
23579             nextToken();
23580             return func();
23581         }
23582         function nextToken() {
23583             if (ts.isKeyword(currentToken) && (scanner.hasUnicodeEscape() || scanner.hasExtendedUnicodeEscape())) {
23584                 parseErrorAt(scanner.getTokenPos(), scanner.getTextPos(), ts.Diagnostics.Keywords_cannot_contain_escape_characters);
23585             }
23586             return nextTokenWithoutCheck();
23587         }
23588         function nextTokenJSDoc() {
23589             return currentToken = scanner.scanJsDocToken();
23590         }
23591         function reScanGreaterToken() {
23592             return currentToken = scanner.reScanGreaterToken();
23593         }
23594         function reScanSlashToken() {
23595             return currentToken = scanner.reScanSlashToken();
23596         }
23597         function reScanTemplateToken(isTaggedTemplate) {
23598             return currentToken = scanner.reScanTemplateToken(isTaggedTemplate);
23599         }
23600         function reScanTemplateHeadOrNoSubstitutionTemplate() {
23601             return currentToken = scanner.reScanTemplateHeadOrNoSubstitutionTemplate();
23602         }
23603         function reScanLessThanToken() {
23604             return currentToken = scanner.reScanLessThanToken();
23605         }
23606         function scanJsxIdentifier() {
23607             return currentToken = scanner.scanJsxIdentifier();
23608         }
23609         function scanJsxText() {
23610             return currentToken = scanner.scanJsxToken();
23611         }
23612         function scanJsxAttributeValue() {
23613             return currentToken = scanner.scanJsxAttributeValue();
23614         }
23615         function speculationHelper(callback, speculationKind) {
23616             var saveToken = currentToken;
23617             var saveParseDiagnosticsLength = parseDiagnostics.length;
23618             var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
23619             var saveContextFlags = contextFlags;
23620             var result = speculationKind !== 0
23621                 ? scanner.lookAhead(callback)
23622                 : scanner.tryScan(callback);
23623             ts.Debug.assert(saveContextFlags === contextFlags);
23624             if (!result || speculationKind !== 0) {
23625                 currentToken = saveToken;
23626                 if (speculationKind !== 2) {
23627                     parseDiagnostics.length = saveParseDiagnosticsLength;
23628                 }
23629                 parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;
23630             }
23631             return result;
23632         }
23633         function lookAhead(callback) {
23634             return speculationHelper(callback, 1);
23635         }
23636         function tryParse(callback) {
23637             return speculationHelper(callback, 0);
23638         }
23639         function isBindingIdentifier() {
23640             if (token() === 78) {
23641                 return true;
23642             }
23643             return token() > 115;
23644         }
23645         function isIdentifier() {
23646             if (token() === 78) {
23647                 return true;
23648             }
23649             if (token() === 124 && inYieldContext()) {
23650                 return false;
23651             }
23652             if (token() === 130 && inAwaitContext()) {
23653                 return false;
23654             }
23655             return token() > 115;
23656         }
23657         function parseExpected(kind, diagnosticMessage, shouldAdvance) {
23658             if (shouldAdvance === void 0) { shouldAdvance = true; }
23659             if (token() === kind) {
23660                 if (shouldAdvance) {
23661                     nextToken();
23662                 }
23663                 return true;
23664             }
23665             if (diagnosticMessage) {
23666                 parseErrorAtCurrentToken(diagnosticMessage);
23667             }
23668             else {
23669                 parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind));
23670             }
23671             return false;
23672         }
23673         function parseExpectedJSDoc(kind) {
23674             if (token() === kind) {
23675                 nextTokenJSDoc();
23676                 return true;
23677             }
23678             parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(kind));
23679             return false;
23680         }
23681         function parseOptional(t) {
23682             if (token() === t) {
23683                 nextToken();
23684                 return true;
23685             }
23686             return false;
23687         }
23688         function parseOptionalToken(t) {
23689             if (token() === t) {
23690                 return parseTokenNode();
23691             }
23692             return undefined;
23693         }
23694         function parseOptionalTokenJSDoc(t) {
23695             if (token() === t) {
23696                 return parseTokenNodeJSDoc();
23697             }
23698             return undefined;
23699         }
23700         function parseExpectedToken(t, diagnosticMessage, arg0) {
23701             return parseOptionalToken(t) ||
23702                 createMissingNode(t, false, diagnosticMessage || ts.Diagnostics._0_expected, arg0 || ts.tokenToString(t));
23703         }
23704         function parseExpectedTokenJSDoc(t) {
23705             return parseOptionalTokenJSDoc(t) ||
23706                 createMissingNode(t, false, ts.Diagnostics._0_expected, ts.tokenToString(t));
23707         }
23708         function parseTokenNode() {
23709             var pos = getNodePos();
23710             var kind = token();
23711             nextToken();
23712             return finishNode(factory.createToken(kind), pos);
23713         }
23714         function parseTokenNodeJSDoc() {
23715             var pos = getNodePos();
23716             var kind = token();
23717             nextTokenJSDoc();
23718             return finishNode(factory.createToken(kind), pos);
23719         }
23720         function canParseSemicolon() {
23721             if (token() === 26) {
23722                 return true;
23723             }
23724             return token() === 19 || token() === 1 || scanner.hasPrecedingLineBreak();
23725         }
23726         function parseSemicolon() {
23727             if (canParseSemicolon()) {
23728                 if (token() === 26) {
23729                     nextToken();
23730                 }
23731                 return true;
23732             }
23733             else {
23734                 return parseExpected(26);
23735             }
23736         }
23737         function createNodeArray(elements, pos, end, hasTrailingComma) {
23738             var array = factory.createNodeArray(elements, hasTrailingComma);
23739             ts.setTextRangePosEnd(array, pos, end !== null && end !== void 0 ? end : scanner.getStartPos());
23740             return array;
23741         }
23742         function finishNode(node, pos, end) {
23743             ts.setTextRangePosEnd(node, pos, end !== null && end !== void 0 ? end : scanner.getStartPos());
23744             if (contextFlags) {
23745                 node.flags |= contextFlags;
23746             }
23747             if (parseErrorBeforeNextFinishedNode) {
23748                 parseErrorBeforeNextFinishedNode = false;
23749                 node.flags |= 65536;
23750             }
23751             return node;
23752         }
23753         function createMissingNode(kind, reportAtCurrentPosition, diagnosticMessage, arg0) {
23754             if (reportAtCurrentPosition) {
23755                 parseErrorAtPosition(scanner.getStartPos(), 0, diagnosticMessage, arg0);
23756             }
23757             else if (diagnosticMessage) {
23758                 parseErrorAtCurrentToken(diagnosticMessage, arg0);
23759             }
23760             var pos = getNodePos();
23761             var result = kind === 78 ? factory.createIdentifier("", undefined, undefined) :
23762                 ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, "", "", undefined) :
23763                     kind === 8 ? factory.createNumericLiteral("", undefined) :
23764                         kind === 10 ? factory.createStringLiteral("", undefined) :
23765                             kind === 271 ? factory.createMissingDeclaration() :
23766                                 factory.createToken(kind);
23767             return finishNode(result, pos);
23768         }
23769         function internIdentifier(text) {
23770             var identifier = identifiers.get(text);
23771             if (identifier === undefined) {
23772                 identifiers.set(text, identifier = text);
23773             }
23774             return identifier;
23775         }
23776         function createIdentifier(isIdentifier, diagnosticMessage, privateIdentifierDiagnosticMessage) {
23777             if (isIdentifier) {
23778                 identifierCount++;
23779                 var pos = getNodePos();
23780                 var originalKeywordKind = token();
23781                 var text = internIdentifier(scanner.getTokenValue());
23782                 nextTokenWithoutCheck();
23783                 return finishNode(factory.createIdentifier(text, undefined, originalKeywordKind), pos);
23784             }
23785             if (token() === 79) {
23786                 parseErrorAtCurrentToken(privateIdentifierDiagnosticMessage || ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
23787                 return createIdentifier(true);
23788             }
23789             if (token() === 0 && scanner.tryScan(function () { return scanner.reScanInvalidIdentifier() === 78; })) {
23790                 return createIdentifier(true);
23791             }
23792             identifierCount++;
23793             var reportAtCurrentPosition = token() === 1;
23794             var isReservedWord = scanner.isReservedWord();
23795             var msgArg = scanner.getTokenText();
23796             var defaultMessage = isReservedWord ?
23797                 ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here :
23798                 ts.Diagnostics.Identifier_expected;
23799             return createMissingNode(78, reportAtCurrentPosition, diagnosticMessage || defaultMessage, msgArg);
23800         }
23801         function parseBindingIdentifier(privateIdentifierDiagnosticMessage) {
23802             return createIdentifier(isBindingIdentifier(), undefined, privateIdentifierDiagnosticMessage);
23803         }
23804         function parseIdentifier(diagnosticMessage, privateIdentifierDiagnosticMessage) {
23805             return createIdentifier(isIdentifier(), diagnosticMessage, privateIdentifierDiagnosticMessage);
23806         }
23807         function parseIdentifierName(diagnosticMessage) {
23808             return createIdentifier(ts.tokenIsIdentifierOrKeyword(token()), diagnosticMessage);
23809         }
23810         function isLiteralPropertyName() {
23811             return ts.tokenIsIdentifierOrKeyword(token()) ||
23812                 token() === 10 ||
23813                 token() === 8;
23814         }
23815         function parsePropertyNameWorker(allowComputedPropertyNames) {
23816             if (token() === 10 || token() === 8) {
23817                 var node = parseLiteralNode();
23818                 node.text = internIdentifier(node.text);
23819                 return node;
23820             }
23821             if (allowComputedPropertyNames && token() === 22) {
23822                 return parseComputedPropertyName();
23823             }
23824             if (token() === 79) {
23825                 return parsePrivateIdentifier();
23826             }
23827             return parseIdentifierName();
23828         }
23829         function parsePropertyName() {
23830             return parsePropertyNameWorker(true);
23831         }
23832         function parseComputedPropertyName() {
23833             var pos = getNodePos();
23834             parseExpected(22);
23835             var expression = allowInAnd(parseExpression);
23836             parseExpected(23);
23837             return finishNode(factory.createComputedPropertyName(expression), pos);
23838         }
23839         function internPrivateIdentifier(text) {
23840             var privateIdentifier = privateIdentifiers.get(text);
23841             if (privateIdentifier === undefined) {
23842                 privateIdentifiers.set(text, privateIdentifier = text);
23843             }
23844             return privateIdentifier;
23845         }
23846         function parsePrivateIdentifier() {
23847             var pos = getNodePos();
23848             var node = factory.createPrivateIdentifier(internPrivateIdentifier(scanner.getTokenText()));
23849             nextToken();
23850             return finishNode(node, pos);
23851         }
23852         function parseContextualModifier(t) {
23853             return token() === t && tryParse(nextTokenCanFollowModifier);
23854         }
23855         function nextTokenIsOnSameLineAndCanFollowModifier() {
23856             nextToken();
23857             if (scanner.hasPrecedingLineBreak()) {
23858                 return false;
23859             }
23860             return canFollowModifier();
23861         }
23862         function nextTokenCanFollowModifier() {
23863             switch (token()) {
23864                 case 84:
23865                     return nextToken() === 91;
23866                 case 92:
23867                     nextToken();
23868                     if (token() === 87) {
23869                         return lookAhead(nextTokenCanFollowDefaultKeyword);
23870                     }
23871                     if (token() === 149) {
23872                         return lookAhead(nextTokenCanFollowExportModifier);
23873                     }
23874                     return canFollowExportModifier();
23875                 case 87:
23876                     return nextTokenCanFollowDefaultKeyword();
23877                 case 123:
23878                     return nextTokenIsOnSameLineAndCanFollowModifier();
23879                 case 134:
23880                 case 146:
23881                     nextToken();
23882                     return canFollowModifier();
23883                 default:
23884                     return nextTokenIsOnSameLineAndCanFollowModifier();
23885             }
23886         }
23887         function canFollowExportModifier() {
23888             return token() !== 41
23889                 && token() !== 126
23890                 && token() !== 18
23891                 && canFollowModifier();
23892         }
23893         function nextTokenCanFollowExportModifier() {
23894             nextToken();
23895             return canFollowExportModifier();
23896         }
23897         function parseAnyContextualModifier() {
23898             return ts.isModifierKind(token()) && tryParse(nextTokenCanFollowModifier);
23899         }
23900         function canFollowModifier() {
23901             return token() === 22
23902                 || token() === 18
23903                 || token() === 41
23904                 || token() === 25
23905                 || isLiteralPropertyName();
23906         }
23907         function nextTokenCanFollowDefaultKeyword() {
23908             nextToken();
23909             return token() === 83 || token() === 97 ||
23910                 token() === 117 ||
23911                 (token() === 125 && lookAhead(nextTokenIsClassKeywordOnSameLine)) ||
23912                 (token() === 129 && lookAhead(nextTokenIsFunctionKeywordOnSameLine));
23913         }
23914         function isListElement(parsingContext, inErrorRecovery) {
23915             var node = currentNode(parsingContext);
23916             if (node) {
23917                 return true;
23918             }
23919             switch (parsingContext) {
23920                 case 0:
23921                 case 1:
23922                 case 3:
23923                     return !(token() === 26 && inErrorRecovery) && isStartOfStatement();
23924                 case 2:
23925                     return token() === 81 || token() === 87;
23926                 case 4:
23927                     return lookAhead(isTypeMemberStart);
23928                 case 5:
23929                     return lookAhead(isClassMemberStart) || (token() === 26 && !inErrorRecovery);
23930                 case 6:
23931                     return token() === 22 || isLiteralPropertyName();
23932                 case 12:
23933                     switch (token()) {
23934                         case 22:
23935                         case 41:
23936                         case 25:
23937                         case 24:
23938                             return true;
23939                         default:
23940                             return isLiteralPropertyName();
23941                     }
23942                 case 18:
23943                     return isLiteralPropertyName();
23944                 case 9:
23945                     return token() === 22 || token() === 25 || isLiteralPropertyName();
23946                 case 7:
23947                     if (token() === 18) {
23948                         return lookAhead(isValidHeritageClauseObjectLiteral);
23949                     }
23950                     if (!inErrorRecovery) {
23951                         return isStartOfLeftHandSideExpression() && !isHeritageClauseExtendsOrImplementsKeyword();
23952                     }
23953                     else {
23954                         return isIdentifier() && !isHeritageClauseExtendsOrImplementsKeyword();
23955                     }
23956                 case 8:
23957                     return isBindingIdentifierOrPrivateIdentifierOrPattern();
23958                 case 10:
23959                     return token() === 27 || token() === 25 || isBindingIdentifierOrPrivateIdentifierOrPattern();
23960                 case 19:
23961                     return isIdentifier();
23962                 case 15:
23963                     switch (token()) {
23964                         case 27:
23965                         case 24:
23966                             return true;
23967                     }
23968                 case 11:
23969                     return token() === 25 || isStartOfExpression();
23970                 case 16:
23971                     return isStartOfParameter(false);
23972                 case 17:
23973                     return isStartOfParameter(true);
23974                 case 20:
23975                 case 21:
23976                     return token() === 27 || isStartOfType();
23977                 case 22:
23978                     return isHeritageClause();
23979                 case 23:
23980                     return ts.tokenIsIdentifierOrKeyword(token());
23981                 case 13:
23982                     return ts.tokenIsIdentifierOrKeyword(token()) || token() === 18;
23983                 case 14:
23984                     return true;
23985             }
23986             return ts.Debug.fail("Non-exhaustive case in 'isListElement'.");
23987         }
23988         function isValidHeritageClauseObjectLiteral() {
23989             ts.Debug.assert(token() === 18);
23990             if (nextToken() === 19) {
23991                 var next = nextToken();
23992                 return next === 27 || next === 18 || next === 93 || next === 116;
23993             }
23994             return true;
23995         }
23996         function nextTokenIsIdentifier() {
23997             nextToken();
23998             return isIdentifier();
23999         }
24000         function nextTokenIsIdentifierOrKeyword() {
24001             nextToken();
24002             return ts.tokenIsIdentifierOrKeyword(token());
24003         }
24004         function nextTokenIsIdentifierOrKeywordOrGreaterThan() {
24005             nextToken();
24006             return ts.tokenIsIdentifierOrKeywordOrGreaterThan(token());
24007         }
24008         function isHeritageClauseExtendsOrImplementsKeyword() {
24009             if (token() === 116 ||
24010                 token() === 93) {
24011                 return lookAhead(nextTokenIsStartOfExpression);
24012             }
24013             return false;
24014         }
24015         function nextTokenIsStartOfExpression() {
24016             nextToken();
24017             return isStartOfExpression();
24018         }
24019         function nextTokenIsStartOfType() {
24020             nextToken();
24021             return isStartOfType();
24022         }
24023         function isListTerminator(kind) {
24024             if (token() === 1) {
24025                 return true;
24026             }
24027             switch (kind) {
24028                 case 1:
24029                 case 2:
24030                 case 4:
24031                 case 5:
24032                 case 6:
24033                 case 12:
24034                 case 9:
24035                 case 23:
24036                     return token() === 19;
24037                 case 3:
24038                     return token() === 19 || token() === 81 || token() === 87;
24039                 case 7:
24040                     return token() === 18 || token() === 93 || token() === 116;
24041                 case 8:
24042                     return isVariableDeclaratorListTerminator();
24043                 case 19:
24044                     return token() === 31 || token() === 20 || token() === 18 || token() === 93 || token() === 116;
24045                 case 11:
24046                     return token() === 21 || token() === 26;
24047                 case 15:
24048                 case 21:
24049                 case 10:
24050                     return token() === 23;
24051                 case 17:
24052                 case 16:
24053                 case 18:
24054                     return token() === 21 || token() === 23;
24055                 case 20:
24056                     return token() !== 27;
24057                 case 22:
24058                     return token() === 18 || token() === 19;
24059                 case 13:
24060                     return token() === 31 || token() === 43;
24061                 case 14:
24062                     return token() === 29 && lookAhead(nextTokenIsSlash);
24063                 default:
24064                     return false;
24065             }
24066         }
24067         function isVariableDeclaratorListTerminator() {
24068             if (canParseSemicolon()) {
24069                 return true;
24070             }
24071             if (isInOrOfKeyword(token())) {
24072                 return true;
24073             }
24074             if (token() === 38) {
24075                 return true;
24076             }
24077             return false;
24078         }
24079         function isInSomeParsingContext() {
24080             for (var kind = 0; kind < 24; kind++) {
24081                 if (parsingContext & (1 << kind)) {
24082                     if (isListElement(kind, true) || isListTerminator(kind)) {
24083                         return true;
24084                     }
24085                 }
24086             }
24087             return false;
24088         }
24089         function parseList(kind, parseElement) {
24090             var saveParsingContext = parsingContext;
24091             parsingContext |= 1 << kind;
24092             var list = [];
24093             var listPos = getNodePos();
24094             while (!isListTerminator(kind)) {
24095                 if (isListElement(kind, false)) {
24096                     var element = parseListElement(kind, parseElement);
24097                     list.push(element);
24098                     continue;
24099                 }
24100                 if (abortParsingListOrMoveToNextToken(kind)) {
24101                     break;
24102                 }
24103             }
24104             parsingContext = saveParsingContext;
24105             return createNodeArray(list, listPos);
24106         }
24107         function parseListElement(parsingContext, parseElement) {
24108             var node = currentNode(parsingContext);
24109             if (node) {
24110                 return consumeNode(node);
24111             }
24112             return parseElement();
24113         }
24114         function currentNode(parsingContext) {
24115             if (!syntaxCursor || !isReusableParsingContext(parsingContext) || parseErrorBeforeNextFinishedNode) {
24116                 return undefined;
24117             }
24118             var node = syntaxCursor.currentNode(scanner.getStartPos());
24119             if (ts.nodeIsMissing(node) || node.intersectsChange || ts.containsParseError(node)) {
24120                 return undefined;
24121             }
24122             var nodeContextFlags = node.flags & 25358336;
24123             if (nodeContextFlags !== contextFlags) {
24124                 return undefined;
24125             }
24126             if (!canReuseNode(node, parsingContext)) {
24127                 return undefined;
24128             }
24129             if (node.jsDocCache) {
24130                 node.jsDocCache = undefined;
24131             }
24132             return node;
24133         }
24134         function consumeNode(node) {
24135             scanner.setTextPos(node.end);
24136             nextToken();
24137             return node;
24138         }
24139         function isReusableParsingContext(parsingContext) {
24140             switch (parsingContext) {
24141                 case 5:
24142                 case 2:
24143                 case 0:
24144                 case 1:
24145                 case 3:
24146                 case 6:
24147                 case 4:
24148                 case 8:
24149                 case 17:
24150                 case 16:
24151                     return true;
24152             }
24153             return false;
24154         }
24155         function canReuseNode(node, parsingContext) {
24156             switch (parsingContext) {
24157                 case 5:
24158                     return isReusableClassMember(node);
24159                 case 2:
24160                     return isReusableSwitchClause(node);
24161                 case 0:
24162                 case 1:
24163                 case 3:
24164                     return isReusableStatement(node);
24165                 case 6:
24166                     return isReusableEnumMember(node);
24167                 case 4:
24168                     return isReusableTypeMember(node);
24169                 case 8:
24170                     return isReusableVariableDeclaration(node);
24171                 case 17:
24172                 case 16:
24173                     return isReusableParameter(node);
24174             }
24175             return false;
24176         }
24177         function isReusableClassMember(node) {
24178             if (node) {
24179                 switch (node.kind) {
24180                     case 166:
24181                     case 171:
24182                     case 167:
24183                     case 168:
24184                     case 163:
24185                     case 229:
24186                         return true;
24187                     case 165:
24188                         var methodDeclaration = node;
24189                         var nameIsConstructor = methodDeclaration.name.kind === 78 &&
24190                             methodDeclaration.name.originalKeywordKind === 132;
24191                         return !nameIsConstructor;
24192                 }
24193             }
24194             return false;
24195         }
24196         function isReusableSwitchClause(node) {
24197             if (node) {
24198                 switch (node.kind) {
24199                     case 284:
24200                     case 285:
24201                         return true;
24202                 }
24203             }
24204             return false;
24205         }
24206         function isReusableStatement(node) {
24207             if (node) {
24208                 switch (node.kind) {
24209                     case 251:
24210                     case 232:
24211                     case 230:
24212                     case 234:
24213                     case 233:
24214                     case 246:
24215                     case 242:
24216                     case 244:
24217                     case 241:
24218                     case 240:
24219                     case 238:
24220                     case 239:
24221                     case 237:
24222                     case 236:
24223                     case 243:
24224                     case 231:
24225                     case 247:
24226                     case 245:
24227                     case 235:
24228                     case 248:
24229                     case 261:
24230                     case 260:
24231                     case 267:
24232                     case 266:
24233                     case 256:
24234                     case 252:
24235                     case 253:
24236                     case 255:
24237                     case 254:
24238                         return true;
24239                 }
24240             }
24241             return false;
24242         }
24243         function isReusableEnumMember(node) {
24244             return node.kind === 291;
24245         }
24246         function isReusableTypeMember(node) {
24247             if (node) {
24248                 switch (node.kind) {
24249                     case 170:
24250                     case 164:
24251                     case 171:
24252                     case 162:
24253                     case 169:
24254                         return true;
24255                 }
24256             }
24257             return false;
24258         }
24259         function isReusableVariableDeclaration(node) {
24260             if (node.kind !== 249) {
24261                 return false;
24262             }
24263             var variableDeclarator = node;
24264             return variableDeclarator.initializer === undefined;
24265         }
24266         function isReusableParameter(node) {
24267             if (node.kind !== 160) {
24268                 return false;
24269             }
24270             var parameter = node;
24271             return parameter.initializer === undefined;
24272         }
24273         function abortParsingListOrMoveToNextToken(kind) {
24274             parsingContextErrors(kind);
24275             if (isInSomeParsingContext()) {
24276                 return true;
24277             }
24278             nextToken();
24279             return false;
24280         }
24281         function parsingContextErrors(context) {
24282             switch (context) {
24283                 case 0: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected);
24284                 case 1: return parseErrorAtCurrentToken(ts.Diagnostics.Declaration_or_statement_expected);
24285                 case 2: return parseErrorAtCurrentToken(ts.Diagnostics.case_or_default_expected);
24286                 case 3: return parseErrorAtCurrentToken(ts.Diagnostics.Statement_expected);
24287                 case 18:
24288                 case 4: return parseErrorAtCurrentToken(ts.Diagnostics.Property_or_signature_expected);
24289                 case 5: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_A_constructor_method_accessor_or_property_was_expected);
24290                 case 6: return parseErrorAtCurrentToken(ts.Diagnostics.Enum_member_expected);
24291                 case 7: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_expected);
24292                 case 8:
24293                     return ts.isKeyword(token())
24294                         ? parseErrorAtCurrentToken(ts.Diagnostics._0_is_not_allowed_as_a_variable_declaration_name, ts.tokenToString(token()))
24295                         : parseErrorAtCurrentToken(ts.Diagnostics.Variable_declaration_expected);
24296                 case 9: return parseErrorAtCurrentToken(ts.Diagnostics.Property_destructuring_pattern_expected);
24297                 case 10: return parseErrorAtCurrentToken(ts.Diagnostics.Array_element_destructuring_pattern_expected);
24298                 case 11: return parseErrorAtCurrentToken(ts.Diagnostics.Argument_expression_expected);
24299                 case 12: return parseErrorAtCurrentToken(ts.Diagnostics.Property_assignment_expected);
24300                 case 15: return parseErrorAtCurrentToken(ts.Diagnostics.Expression_or_comma_expected);
24301                 case 17: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected);
24302                 case 16: return parseErrorAtCurrentToken(ts.Diagnostics.Parameter_declaration_expected);
24303                 case 19: return parseErrorAtCurrentToken(ts.Diagnostics.Type_parameter_declaration_expected);
24304                 case 20: return parseErrorAtCurrentToken(ts.Diagnostics.Type_argument_expected);
24305                 case 21: return parseErrorAtCurrentToken(ts.Diagnostics.Type_expected);
24306                 case 22: return parseErrorAtCurrentToken(ts.Diagnostics.Unexpected_token_expected);
24307                 case 23: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
24308                 case 13: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
24309                 case 14: return parseErrorAtCurrentToken(ts.Diagnostics.Identifier_expected);
24310                 default: return [undefined];
24311             }
24312         }
24313         function parseDelimitedList(kind, parseElement, considerSemicolonAsDelimiter) {
24314             var saveParsingContext = parsingContext;
24315             parsingContext |= 1 << kind;
24316             var list = [];
24317             var listPos = getNodePos();
24318             var commaStart = -1;
24319             while (true) {
24320                 if (isListElement(kind, false)) {
24321                     var startPos = scanner.getStartPos();
24322                     list.push(parseListElement(kind, parseElement));
24323                     commaStart = scanner.getTokenPos();
24324                     if (parseOptional(27)) {
24325                         continue;
24326                     }
24327                     commaStart = -1;
24328                     if (isListTerminator(kind)) {
24329                         break;
24330                     }
24331                     parseExpected(27, getExpectedCommaDiagnostic(kind));
24332                     if (considerSemicolonAsDelimiter && token() === 26 && !scanner.hasPrecedingLineBreak()) {
24333                         nextToken();
24334                     }
24335                     if (startPos === scanner.getStartPos()) {
24336                         nextToken();
24337                     }
24338                     continue;
24339                 }
24340                 if (isListTerminator(kind)) {
24341                     break;
24342                 }
24343                 if (abortParsingListOrMoveToNextToken(kind)) {
24344                     break;
24345                 }
24346             }
24347             parsingContext = saveParsingContext;
24348             return createNodeArray(list, listPos, undefined, commaStart >= 0);
24349         }
24350         function getExpectedCommaDiagnostic(kind) {
24351             return kind === 6 ? ts.Diagnostics.An_enum_member_name_must_be_followed_by_a_or : undefined;
24352         }
24353         function createMissingList() {
24354             var list = createNodeArray([], getNodePos());
24355             list.isMissingList = true;
24356             return list;
24357         }
24358         function isMissingList(arr) {
24359             return !!arr.isMissingList;
24360         }
24361         function parseBracketedList(kind, parseElement, open, close) {
24362             if (parseExpected(open)) {
24363                 var result = parseDelimitedList(kind, parseElement);
24364                 parseExpected(close);
24365                 return result;
24366             }
24367             return createMissingList();
24368         }
24369         function parseEntityName(allowReservedWords, diagnosticMessage) {
24370             var pos = getNodePos();
24371             var entity = allowReservedWords ? parseIdentifierName(diagnosticMessage) : parseIdentifier(diagnosticMessage);
24372             var dotPos = getNodePos();
24373             while (parseOptional(24)) {
24374                 if (token() === 29) {
24375                     entity.jsdocDotPos = dotPos;
24376                     break;
24377                 }
24378                 dotPos = getNodePos();
24379                 entity = finishNode(factory.createQualifiedName(entity, parseRightSideOfDot(allowReservedWords, false)), pos);
24380             }
24381             return entity;
24382         }
24383         function createQualifiedName(entity, name) {
24384             return finishNode(factory.createQualifiedName(entity, name), entity.pos);
24385         }
24386         function parseRightSideOfDot(allowIdentifierNames, allowPrivateIdentifiers) {
24387             if (scanner.hasPrecedingLineBreak() && ts.tokenIsIdentifierOrKeyword(token())) {
24388                 var matchesPattern = lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
24389                 if (matchesPattern) {
24390                     return createMissingNode(78, true, ts.Diagnostics.Identifier_expected);
24391                 }
24392             }
24393             if (token() === 79) {
24394                 var node = parsePrivateIdentifier();
24395                 return allowPrivateIdentifiers ? node : createMissingNode(78, true, ts.Diagnostics.Identifier_expected);
24396             }
24397             return allowIdentifierNames ? parseIdentifierName() : parseIdentifier();
24398         }
24399         function parseTemplateSpans(isTaggedTemplate) {
24400             var pos = getNodePos();
24401             var list = [];
24402             var node;
24403             do {
24404                 node = parseTemplateSpan(isTaggedTemplate);
24405                 list.push(node);
24406             } while (node.literal.kind === 16);
24407             return createNodeArray(list, pos);
24408         }
24409         function parseTemplateExpression(isTaggedTemplate) {
24410             var pos = getNodePos();
24411             return finishNode(factory.createTemplateExpression(parseTemplateHead(isTaggedTemplate), parseTemplateSpans(isTaggedTemplate)), pos);
24412         }
24413         function parseTemplateType() {
24414             var pos = getNodePos();
24415             return finishNode(factory.createTemplateLiteralType(parseTemplateHead(false), parseTemplateTypeSpans()), pos);
24416         }
24417         function parseTemplateTypeSpans() {
24418             var pos = getNodePos();
24419             var list = [];
24420             var node;
24421             do {
24422                 node = parseTemplateTypeSpan();
24423                 list.push(node);
24424             } while (node.literal.kind === 16);
24425             return createNodeArray(list, pos);
24426         }
24427         function parseTemplateTypeSpan() {
24428             var pos = getNodePos();
24429             return finishNode(factory.createTemplateLiteralTypeSpan(parseType(), parseLiteralOfTemplateSpan(false)), pos);
24430         }
24431         function parseLiteralOfTemplateSpan(isTaggedTemplate) {
24432             if (token() === 19) {
24433                 reScanTemplateToken(isTaggedTemplate);
24434                 return parseTemplateMiddleOrTemplateTail();
24435             }
24436             else {
24437                 return parseExpectedToken(17, ts.Diagnostics._0_expected, ts.tokenToString(19));
24438             }
24439         }
24440         function parseTemplateSpan(isTaggedTemplate) {
24441             var pos = getNodePos();
24442             return finishNode(factory.createTemplateSpan(allowInAnd(parseExpression), parseLiteralOfTemplateSpan(isTaggedTemplate)), pos);
24443         }
24444         function parseLiteralNode() {
24445             return parseLiteralLikeNode(token());
24446         }
24447         function parseTemplateHead(isTaggedTemplate) {
24448             if (isTaggedTemplate) {
24449                 reScanTemplateHeadOrNoSubstitutionTemplate();
24450             }
24451             var fragment = parseLiteralLikeNode(token());
24452             ts.Debug.assert(fragment.kind === 15, "Template head has wrong token kind");
24453             return fragment;
24454         }
24455         function parseTemplateMiddleOrTemplateTail() {
24456             var fragment = parseLiteralLikeNode(token());
24457             ts.Debug.assert(fragment.kind === 16 || fragment.kind === 17, "Template fragment has wrong token kind");
24458             return fragment;
24459         }
24460         function getTemplateLiteralRawText(kind) {
24461             var isLast = kind === 14 || kind === 17;
24462             var tokenText = scanner.getTokenText();
24463             return tokenText.substring(1, tokenText.length - (scanner.isUnterminated() ? 0 : isLast ? 1 : 2));
24464         }
24465         function parseLiteralLikeNode(kind) {
24466             var pos = getNodePos();
24467             var node = ts.isTemplateLiteralKind(kind) ? factory.createTemplateLiteralLikeNode(kind, scanner.getTokenValue(), getTemplateLiteralRawText(kind), scanner.getTokenFlags() & 2048) :
24468                 kind === 8 ? factory.createNumericLiteral(scanner.getTokenValue(), scanner.getNumericLiteralFlags()) :
24469                     kind === 10 ? factory.createStringLiteral(scanner.getTokenValue(), undefined, scanner.hasExtendedUnicodeEscape()) :
24470                         ts.isLiteralKind(kind) ? factory.createLiteralLikeNode(kind, scanner.getTokenValue()) :
24471                             ts.Debug.fail();
24472             if (scanner.hasExtendedUnicodeEscape()) {
24473                 node.hasExtendedUnicodeEscape = true;
24474             }
24475             if (scanner.isUnterminated()) {
24476                 node.isUnterminated = true;
24477             }
24478             nextToken();
24479             return finishNode(node, pos);
24480         }
24481         function parseEntityNameOfTypeReference() {
24482             return parseEntityName(true, ts.Diagnostics.Type_expected);
24483         }
24484         function parseTypeArgumentsOfTypeReference() {
24485             if (!scanner.hasPrecedingLineBreak() && reScanLessThanToken() === 29) {
24486                 return parseBracketedList(20, parseType, 29, 31);
24487             }
24488         }
24489         function parseTypeReference() {
24490             var pos = getNodePos();
24491             return finishNode(factory.createTypeReferenceNode(parseEntityNameOfTypeReference(), parseTypeArgumentsOfTypeReference()), pos);
24492         }
24493         function typeHasArrowFunctionBlockingParseError(node) {
24494             switch (node.kind) {
24495                 case 173:
24496                     return ts.nodeIsMissing(node.typeName);
24497                 case 174:
24498                 case 175: {
24499                     var _a = node, parameters = _a.parameters, type = _a.type;
24500                     return isMissingList(parameters) || typeHasArrowFunctionBlockingParseError(type);
24501                 }
24502                 case 186:
24503                     return typeHasArrowFunctionBlockingParseError(node.type);
24504                 default:
24505                     return false;
24506             }
24507         }
24508         function parseThisTypePredicate(lhs) {
24509             nextToken();
24510             return finishNode(factory.createTypePredicateNode(undefined, lhs, parseType()), lhs.pos);
24511         }
24512         function parseThisTypeNode() {
24513             var pos = getNodePos();
24514             nextToken();
24515             return finishNode(factory.createThisTypeNode(), pos);
24516         }
24517         function parseJSDocAllType() {
24518             var pos = getNodePos();
24519             nextToken();
24520             return finishNode(factory.createJSDocAllType(), pos);
24521         }
24522         function parseJSDocNonNullableType() {
24523             var pos = getNodePos();
24524             nextToken();
24525             return finishNode(factory.createJSDocNonNullableType(parseNonArrayType()), pos);
24526         }
24527         function parseJSDocUnknownOrNullableType() {
24528             var pos = getNodePos();
24529             nextToken();
24530             if (token() === 27 ||
24531                 token() === 19 ||
24532                 token() === 21 ||
24533                 token() === 31 ||
24534                 token() === 62 ||
24535                 token() === 51) {
24536                 return finishNode(factory.createJSDocUnknownType(), pos);
24537             }
24538             else {
24539                 return finishNode(factory.createJSDocNullableType(parseType()), pos);
24540             }
24541         }
24542         function parseJSDocFunctionType() {
24543             var pos = getNodePos();
24544             var hasJSDoc = hasPrecedingJSDocComment();
24545             if (lookAhead(nextTokenIsOpenParen)) {
24546                 nextToken();
24547                 var parameters = parseParameters(4 | 32);
24548                 var type = parseReturnType(58, false);
24549                 return withJSDoc(finishNode(factory.createJSDocFunctionType(parameters, type), pos), hasJSDoc);
24550             }
24551             return finishNode(factory.createTypeReferenceNode(parseIdentifierName(), undefined), pos);
24552         }
24553         function parseJSDocParameter() {
24554             var pos = getNodePos();
24555             var name;
24556             if (token() === 107 || token() === 102) {
24557                 name = parseIdentifierName();
24558                 parseExpected(58);
24559             }
24560             return finishNode(factory.createParameterDeclaration(undefined, undefined, undefined, name, undefined, parseJSDocType(), undefined), pos);
24561         }
24562         function parseJSDocType() {
24563             scanner.setInJSDocType(true);
24564             var pos = getNodePos();
24565             if (parseOptional(139)) {
24566                 var moduleTag = factory.createJSDocNamepathType(undefined);
24567                 terminate: while (true) {
24568                     switch (token()) {
24569                         case 19:
24570                         case 1:
24571                         case 27:
24572                         case 5:
24573                             break terminate;
24574                         default:
24575                             nextTokenJSDoc();
24576                     }
24577                 }
24578                 scanner.setInJSDocType(false);
24579                 return finishNode(moduleTag, pos);
24580             }
24581             var hasDotDotDot = parseOptional(25);
24582             var type = parseTypeOrTypePredicate();
24583             scanner.setInJSDocType(false);
24584             if (hasDotDotDot) {
24585                 type = finishNode(factory.createJSDocVariadicType(type), pos);
24586             }
24587             if (token() === 62) {
24588                 nextToken();
24589                 return finishNode(factory.createJSDocOptionalType(type), pos);
24590             }
24591             return type;
24592         }
24593         function parseTypeQuery() {
24594             var pos = getNodePos();
24595             parseExpected(111);
24596             return finishNode(factory.createTypeQueryNode(parseEntityName(true)), pos);
24597         }
24598         function parseTypeParameter() {
24599             var pos = getNodePos();
24600             var name = parseIdentifier();
24601             var constraint;
24602             var expression;
24603             if (parseOptional(93)) {
24604                 if (isStartOfType() || !isStartOfExpression()) {
24605                     constraint = parseType();
24606                 }
24607                 else {
24608                     expression = parseUnaryExpressionOrHigher();
24609                 }
24610             }
24611             var defaultType = parseOptional(62) ? parseType() : undefined;
24612             var node = factory.createTypeParameterDeclaration(name, constraint, defaultType);
24613             node.expression = expression;
24614             return finishNode(node, pos);
24615         }
24616         function parseTypeParameters() {
24617             if (token() === 29) {
24618                 return parseBracketedList(19, parseTypeParameter, 29, 31);
24619             }
24620         }
24621         function isStartOfParameter(isJSDocParameter) {
24622             return token() === 25 ||
24623                 isBindingIdentifierOrPrivateIdentifierOrPattern() ||
24624                 ts.isModifierKind(token()) ||
24625                 token() === 59 ||
24626                 isStartOfType(!isJSDocParameter);
24627         }
24628         function parseNameOfParameter(modifiers) {
24629             var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_cannot_be_used_as_parameters);
24630             if (ts.getFullWidth(name) === 0 && !ts.some(modifiers) && ts.isModifierKind(token())) {
24631                 nextToken();
24632             }
24633             return name;
24634         }
24635         function parseParameterInOuterAwaitContext() {
24636             return parseParameterWorker(true);
24637         }
24638         function parseParameter() {
24639             return parseParameterWorker(false);
24640         }
24641         function parseParameterWorker(inOuterAwaitContext) {
24642             var pos = getNodePos();
24643             var hasJSDoc = hasPrecedingJSDocComment();
24644             if (token() === 107) {
24645                 var node_1 = factory.createParameterDeclaration(undefined, undefined, undefined, createIdentifier(true), undefined, parseTypeAnnotation(), undefined);
24646                 return withJSDoc(finishNode(node_1, pos), hasJSDoc);
24647             }
24648             var decorators = inOuterAwaitContext ? doInAwaitContext(parseDecorators) : parseDecorators();
24649             var savedTopLevel = topLevel;
24650             topLevel = false;
24651             var modifiers = parseModifiers();
24652             var node = withJSDoc(finishNode(factory.createParameterDeclaration(decorators, modifiers, parseOptionalToken(25), parseNameOfParameter(modifiers), parseOptionalToken(57), parseTypeAnnotation(), parseInitializer()), pos), hasJSDoc);
24653             topLevel = savedTopLevel;
24654             return node;
24655         }
24656         function parseReturnType(returnToken, isType) {
24657             if (shouldParseReturnType(returnToken, isType)) {
24658                 return parseTypeOrTypePredicate();
24659             }
24660         }
24661         function shouldParseReturnType(returnToken, isType) {
24662             if (returnToken === 38) {
24663                 parseExpected(returnToken);
24664                 return true;
24665             }
24666             else if (parseOptional(58)) {
24667                 return true;
24668             }
24669             else if (isType && token() === 38) {
24670                 parseErrorAtCurrentToken(ts.Diagnostics._0_expected, ts.tokenToString(58));
24671                 nextToken();
24672                 return true;
24673             }
24674             return false;
24675         }
24676         function parseParametersWorker(flags) {
24677             var savedYieldContext = inYieldContext();
24678             var savedAwaitContext = inAwaitContext();
24679             setYieldContext(!!(flags & 1));
24680             setAwaitContext(!!(flags & 2));
24681             var parameters = flags & 32 ?
24682                 parseDelimitedList(17, parseJSDocParameter) :
24683                 parseDelimitedList(16, savedAwaitContext ? parseParameterInOuterAwaitContext : parseParameter);
24684             setYieldContext(savedYieldContext);
24685             setAwaitContext(savedAwaitContext);
24686             return parameters;
24687         }
24688         function parseParameters(flags) {
24689             if (!parseExpected(20)) {
24690                 return createMissingList();
24691             }
24692             var parameters = parseParametersWorker(flags);
24693             parseExpected(21);
24694             return parameters;
24695         }
24696         function parseTypeMemberSemicolon() {
24697             if (parseOptional(27)) {
24698                 return;
24699             }
24700             parseSemicolon();
24701         }
24702         function parseSignatureMember(kind) {
24703             var pos = getNodePos();
24704             var hasJSDoc = hasPrecedingJSDocComment();
24705             if (kind === 170) {
24706                 parseExpected(102);
24707             }
24708             var typeParameters = parseTypeParameters();
24709             var parameters = parseParameters(4);
24710             var type = parseReturnType(58, true);
24711             parseTypeMemberSemicolon();
24712             var node = kind === 169
24713                 ? factory.createCallSignature(typeParameters, parameters, type)
24714                 : factory.createConstructSignature(typeParameters, parameters, type);
24715             return withJSDoc(finishNode(node, pos), hasJSDoc);
24716         }
24717         function isIndexSignature() {
24718             return token() === 22 && lookAhead(isUnambiguouslyIndexSignature);
24719         }
24720         function isUnambiguouslyIndexSignature() {
24721             nextToken();
24722             if (token() === 25 || token() === 23) {
24723                 return true;
24724             }
24725             if (ts.isModifierKind(token())) {
24726                 nextToken();
24727                 if (isIdentifier()) {
24728                     return true;
24729                 }
24730             }
24731             else if (!isIdentifier()) {
24732                 return false;
24733             }
24734             else {
24735                 nextToken();
24736             }
24737             if (token() === 58 || token() === 27) {
24738                 return true;
24739             }
24740             if (token() !== 57) {
24741                 return false;
24742             }
24743             nextToken();
24744             return token() === 58 || token() === 27 || token() === 23;
24745         }
24746         function parseIndexSignatureDeclaration(pos, hasJSDoc, decorators, modifiers) {
24747             var parameters = parseBracketedList(16, parseParameter, 22, 23);
24748             var type = parseTypeAnnotation();
24749             parseTypeMemberSemicolon();
24750             var node = factory.createIndexSignature(decorators, modifiers, parameters, type);
24751             return withJSDoc(finishNode(node, pos), hasJSDoc);
24752         }
24753         function parsePropertyOrMethodSignature(pos, hasJSDoc, modifiers) {
24754             var name = parsePropertyName();
24755             var questionToken = parseOptionalToken(57);
24756             var node;
24757             if (token() === 20 || token() === 29) {
24758                 var typeParameters = parseTypeParameters();
24759                 var parameters = parseParameters(4);
24760                 var type = parseReturnType(58, true);
24761                 node = factory.createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type);
24762             }
24763             else {
24764                 var type = parseTypeAnnotation();
24765                 node = factory.createPropertySignature(modifiers, name, questionToken, type);
24766                 if (token() === 62)
24767                     node.initializer = parseInitializer();
24768             }
24769             parseTypeMemberSemicolon();
24770             return withJSDoc(finishNode(node, pos), hasJSDoc);
24771         }
24772         function isTypeMemberStart() {
24773             if (token() === 20 || token() === 29) {
24774                 return true;
24775             }
24776             var idToken = false;
24777             while (ts.isModifierKind(token())) {
24778                 idToken = true;
24779                 nextToken();
24780             }
24781             if (token() === 22) {
24782                 return true;
24783             }
24784             if (isLiteralPropertyName()) {
24785                 idToken = true;
24786                 nextToken();
24787             }
24788             if (idToken) {
24789                 return token() === 20 ||
24790                     token() === 29 ||
24791                     token() === 57 ||
24792                     token() === 58 ||
24793                     token() === 27 ||
24794                     canParseSemicolon();
24795             }
24796             return false;
24797         }
24798         function parseTypeMember() {
24799             if (token() === 20 || token() === 29) {
24800                 return parseSignatureMember(169);
24801             }
24802             if (token() === 102 && lookAhead(nextTokenIsOpenParenOrLessThan)) {
24803                 return parseSignatureMember(170);
24804             }
24805             var pos = getNodePos();
24806             var hasJSDoc = hasPrecedingJSDocComment();
24807             var modifiers = parseModifiers();
24808             if (isIndexSignature()) {
24809                 return parseIndexSignatureDeclaration(pos, hasJSDoc, undefined, modifiers);
24810             }
24811             return parsePropertyOrMethodSignature(pos, hasJSDoc, modifiers);
24812         }
24813         function nextTokenIsOpenParenOrLessThan() {
24814             nextToken();
24815             return token() === 20 || token() === 29;
24816         }
24817         function nextTokenIsDot() {
24818             return nextToken() === 24;
24819         }
24820         function nextTokenIsOpenParenOrLessThanOrDot() {
24821             switch (nextToken()) {
24822                 case 20:
24823                 case 29:
24824                 case 24:
24825                     return true;
24826             }
24827             return false;
24828         }
24829         function parseTypeLiteral() {
24830             var pos = getNodePos();
24831             return finishNode(factory.createTypeLiteralNode(parseObjectTypeMembers()), pos);
24832         }
24833         function parseObjectTypeMembers() {
24834             var members;
24835             if (parseExpected(18)) {
24836                 members = parseList(4, parseTypeMember);
24837                 parseExpected(19);
24838             }
24839             else {
24840                 members = createMissingList();
24841             }
24842             return members;
24843         }
24844         function isStartOfMappedType() {
24845             nextToken();
24846             if (token() === 39 || token() === 40) {
24847                 return nextToken() === 142;
24848             }
24849             if (token() === 142) {
24850                 nextToken();
24851             }
24852             return token() === 22 && nextTokenIsIdentifier() && nextToken() === 100;
24853         }
24854         function parseMappedTypeParameter() {
24855             var pos = getNodePos();
24856             var name = parseIdentifierName();
24857             parseExpected(100);
24858             var type = parseType();
24859             return finishNode(factory.createTypeParameterDeclaration(name, type, undefined), pos);
24860         }
24861         function parseMappedType() {
24862             var pos = getNodePos();
24863             parseExpected(18);
24864             var readonlyToken;
24865             if (token() === 142 || token() === 39 || token() === 40) {
24866                 readonlyToken = parseTokenNode();
24867                 if (readonlyToken.kind !== 142) {
24868                     parseExpected(142);
24869                 }
24870             }
24871             parseExpected(22);
24872             var typeParameter = parseMappedTypeParameter();
24873             var nameType = parseOptional(126) ? parseType() : undefined;
24874             parseExpected(23);
24875             var questionToken;
24876             if (token() === 57 || token() === 39 || token() === 40) {
24877                 questionToken = parseTokenNode();
24878                 if (questionToken.kind !== 57) {
24879                     parseExpected(57);
24880                 }
24881             }
24882             var type = parseTypeAnnotation();
24883             parseSemicolon();
24884             parseExpected(19);
24885             return finishNode(factory.createMappedTypeNode(readonlyToken, typeParameter, nameType, questionToken, type), pos);
24886         }
24887         function parseTupleElementType() {
24888             var pos = getNodePos();
24889             if (parseOptional(25)) {
24890                 return finishNode(factory.createRestTypeNode(parseType()), pos);
24891             }
24892             var type = parseType();
24893             if (ts.isJSDocNullableType(type) && type.pos === type.type.pos) {
24894                 var node = factory.createOptionalTypeNode(type.type);
24895                 ts.setTextRange(node, type);
24896                 node.flags = type.flags;
24897                 return node;
24898             }
24899             return type;
24900         }
24901         function isNextTokenColonOrQuestionColon() {
24902             return nextToken() === 58 || (token() === 57 && nextToken() === 58);
24903         }
24904         function isTupleElementName() {
24905             if (token() === 25) {
24906                 return ts.tokenIsIdentifierOrKeyword(nextToken()) && isNextTokenColonOrQuestionColon();
24907             }
24908             return ts.tokenIsIdentifierOrKeyword(token()) && isNextTokenColonOrQuestionColon();
24909         }
24910         function parseTupleElementNameOrTupleElementType() {
24911             if (lookAhead(isTupleElementName)) {
24912                 var pos = getNodePos();
24913                 var hasJSDoc = hasPrecedingJSDocComment();
24914                 var dotDotDotToken = parseOptionalToken(25);
24915                 var name = parseIdentifierName();
24916                 var questionToken = parseOptionalToken(57);
24917                 parseExpected(58);
24918                 var type = parseTupleElementType();
24919                 var node = factory.createNamedTupleMember(dotDotDotToken, name, questionToken, type);
24920                 return withJSDoc(finishNode(node, pos), hasJSDoc);
24921             }
24922             return parseTupleElementType();
24923         }
24924         function parseTupleType() {
24925             var pos = getNodePos();
24926             return finishNode(factory.createTupleTypeNode(parseBracketedList(21, parseTupleElementNameOrTupleElementType, 22, 23)), pos);
24927         }
24928         function parseParenthesizedType() {
24929             var pos = getNodePos();
24930             parseExpected(20);
24931             var type = parseType();
24932             parseExpected(21);
24933             return finishNode(factory.createParenthesizedType(type), pos);
24934         }
24935         function parseModifiersForConstructorType() {
24936             var modifiers;
24937             if (token() === 125) {
24938                 var pos = getNodePos();
24939                 nextToken();
24940                 var modifier = finishNode(factory.createToken(125), pos);
24941                 modifiers = createNodeArray([modifier], pos);
24942             }
24943             return modifiers;
24944         }
24945         function parseFunctionOrConstructorType() {
24946             var pos = getNodePos();
24947             var hasJSDoc = hasPrecedingJSDocComment();
24948             var modifiers = parseModifiersForConstructorType();
24949             var isConstructorType = parseOptional(102);
24950             var typeParameters = parseTypeParameters();
24951             var parameters = parseParameters(4);
24952             var type = parseReturnType(38, false);
24953             var node = isConstructorType
24954                 ? factory.createConstructorTypeNode(modifiers, typeParameters, parameters, type)
24955                 : factory.createFunctionTypeNode(typeParameters, parameters, type);
24956             if (!isConstructorType)
24957                 node.modifiers = modifiers;
24958             return withJSDoc(finishNode(node, pos), hasJSDoc);
24959         }
24960         function parseKeywordAndNoDot() {
24961             var node = parseTokenNode();
24962             return token() === 24 ? undefined : node;
24963         }
24964         function parseLiteralTypeNode(negative) {
24965             var pos = getNodePos();
24966             if (negative) {
24967                 nextToken();
24968             }
24969             var expression = token() === 109 || token() === 94 || token() === 103 ?
24970                 parseTokenNode() :
24971                 parseLiteralLikeNode(token());
24972             if (negative) {
24973                 expression = finishNode(factory.createPrefixUnaryExpression(40, expression), pos);
24974             }
24975             return finishNode(factory.createLiteralTypeNode(expression), pos);
24976         }
24977         function isStartOfTypeOfImportType() {
24978             nextToken();
24979             return token() === 99;
24980         }
24981         function parseImportType() {
24982             sourceFlags |= 1048576;
24983             var pos = getNodePos();
24984             var isTypeOf = parseOptional(111);
24985             parseExpected(99);
24986             parseExpected(20);
24987             var type = parseType();
24988             parseExpected(21);
24989             var qualifier = parseOptional(24) ? parseEntityNameOfTypeReference() : undefined;
24990             var typeArguments = parseTypeArgumentsOfTypeReference();
24991             return finishNode(factory.createImportTypeNode(type, qualifier, typeArguments, isTypeOf), pos);
24992         }
24993         function nextTokenIsNumericOrBigIntLiteral() {
24994             nextToken();
24995             return token() === 8 || token() === 9;
24996         }
24997         function parseNonArrayType() {
24998             switch (token()) {
24999                 case 128:
25000                 case 152:
25001                 case 147:
25002                 case 144:
25003                 case 155:
25004                 case 148:
25005                 case 131:
25006                 case 150:
25007                 case 141:
25008                 case 145:
25009                     return tryParse(parseKeywordAndNoDot) || parseTypeReference();
25010                 case 65:
25011                     scanner.reScanAsteriskEqualsToken();
25012                 case 41:
25013                     return parseJSDocAllType();
25014                 case 60:
25015                     scanner.reScanQuestionToken();
25016                 case 57:
25017                     return parseJSDocUnknownOrNullableType();
25018                 case 97:
25019                     return parseJSDocFunctionType();
25020                 case 53:
25021                     return parseJSDocNonNullableType();
25022                 case 14:
25023                 case 10:
25024                 case 8:
25025                 case 9:
25026                 case 109:
25027                 case 94:
25028                 case 103:
25029                     return parseLiteralTypeNode();
25030                 case 40:
25031                     return lookAhead(nextTokenIsNumericOrBigIntLiteral) ? parseLiteralTypeNode(true) : parseTypeReference();
25032                 case 113:
25033                     return parseTokenNode();
25034                 case 107: {
25035                     var thisKeyword = parseThisTypeNode();
25036                     if (token() === 137 && !scanner.hasPrecedingLineBreak()) {
25037                         return parseThisTypePredicate(thisKeyword);
25038                     }
25039                     else {
25040                         return thisKeyword;
25041                     }
25042                 }
25043                 case 111:
25044                     return lookAhead(isStartOfTypeOfImportType) ? parseImportType() : parseTypeQuery();
25045                 case 18:
25046                     return lookAhead(isStartOfMappedType) ? parseMappedType() : parseTypeLiteral();
25047                 case 22:
25048                     return parseTupleType();
25049                 case 20:
25050                     return parseParenthesizedType();
25051                 case 99:
25052                     return parseImportType();
25053                 case 127:
25054                     return lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine) ? parseAssertsTypePredicate() : parseTypeReference();
25055                 case 15:
25056                     return parseTemplateType();
25057                 default:
25058                     return parseTypeReference();
25059             }
25060         }
25061         function isStartOfType(inStartOfParameter) {
25062             switch (token()) {
25063                 case 128:
25064                 case 152:
25065                 case 147:
25066                 case 144:
25067                 case 155:
25068                 case 131:
25069                 case 142:
25070                 case 148:
25071                 case 151:
25072                 case 113:
25073                 case 150:
25074                 case 103:
25075                 case 107:
25076                 case 111:
25077                 case 141:
25078                 case 18:
25079                 case 22:
25080                 case 29:
25081                 case 51:
25082                 case 50:
25083                 case 102:
25084                 case 10:
25085                 case 8:
25086                 case 9:
25087                 case 109:
25088                 case 94:
25089                 case 145:
25090                 case 41:
25091                 case 57:
25092                 case 53:
25093                 case 25:
25094                 case 135:
25095                 case 99:
25096                 case 127:
25097                 case 14:
25098                 case 15:
25099                     return true;
25100                 case 97:
25101                     return !inStartOfParameter;
25102                 case 40:
25103                     return !inStartOfParameter && lookAhead(nextTokenIsNumericOrBigIntLiteral);
25104                 case 20:
25105                     return !inStartOfParameter && lookAhead(isStartOfParenthesizedOrFunctionType);
25106                 default:
25107                     return isIdentifier();
25108             }
25109         }
25110         function isStartOfParenthesizedOrFunctionType() {
25111             nextToken();
25112             return token() === 21 || isStartOfParameter(false) || isStartOfType();
25113         }
25114         function parsePostfixTypeOrHigher() {
25115             var pos = getNodePos();
25116             var type = parseNonArrayType();
25117             while (!scanner.hasPrecedingLineBreak()) {
25118                 switch (token()) {
25119                     case 53:
25120                         nextToken();
25121                         type = finishNode(factory.createJSDocNonNullableType(type), pos);
25122                         break;
25123                     case 57:
25124                         if (lookAhead(nextTokenIsStartOfType)) {
25125                             return type;
25126                         }
25127                         nextToken();
25128                         type = finishNode(factory.createJSDocNullableType(type), pos);
25129                         break;
25130                     case 22:
25131                         parseExpected(22);
25132                         if (isStartOfType()) {
25133                             var indexType = parseType();
25134                             parseExpected(23);
25135                             type = finishNode(factory.createIndexedAccessTypeNode(type, indexType), pos);
25136                         }
25137                         else {
25138                             parseExpected(23);
25139                             type = finishNode(factory.createArrayTypeNode(type), pos);
25140                         }
25141                         break;
25142                     default:
25143                         return type;
25144                 }
25145             }
25146             return type;
25147         }
25148         function parseTypeOperator(operator) {
25149             var pos = getNodePos();
25150             parseExpected(operator);
25151             return finishNode(factory.createTypeOperatorNode(operator, parseTypeOperatorOrHigher()), pos);
25152         }
25153         function parseTypeParameterOfInferType() {
25154             var pos = getNodePos();
25155             return finishNode(factory.createTypeParameterDeclaration(parseIdentifier(), undefined, undefined), pos);
25156         }
25157         function parseInferType() {
25158             var pos = getNodePos();
25159             parseExpected(135);
25160             return finishNode(factory.createInferTypeNode(parseTypeParameterOfInferType()), pos);
25161         }
25162         function parseTypeOperatorOrHigher() {
25163             var operator = token();
25164             switch (operator) {
25165                 case 138:
25166                 case 151:
25167                 case 142:
25168                     return parseTypeOperator(operator);
25169                 case 135:
25170                     return parseInferType();
25171             }
25172             return parsePostfixTypeOrHigher();
25173         }
25174         function parseFunctionOrConstructorTypeToError(isInUnionType) {
25175             if (isStartOfFunctionTypeOrConstructorType()) {
25176                 var type = parseFunctionOrConstructorType();
25177                 var diagnostic = void 0;
25178                 if (ts.isFunctionTypeNode(type)) {
25179                     diagnostic = isInUnionType
25180                         ? ts.Diagnostics.Function_type_notation_must_be_parenthesized_when_used_in_a_union_type
25181                         : ts.Diagnostics.Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type;
25182                 }
25183                 else {
25184                     diagnostic = isInUnionType
25185                         ? ts.Diagnostics.Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type
25186                         : ts.Diagnostics.Constructor_type_notation_must_be_parenthesized_when_used_in_an_intersection_type;
25187                 }
25188                 parseErrorAtRange(type, diagnostic);
25189                 return type;
25190             }
25191             return undefined;
25192         }
25193         function parseUnionOrIntersectionType(operator, parseConstituentType, createTypeNode) {
25194             var pos = getNodePos();
25195             var isUnionType = operator === 51;
25196             var hasLeadingOperator = parseOptional(operator);
25197             var type = hasLeadingOperator && parseFunctionOrConstructorTypeToError(isUnionType)
25198                 || parseConstituentType();
25199             if (token() === operator || hasLeadingOperator) {
25200                 var types = [type];
25201                 while (parseOptional(operator)) {
25202                     types.push(parseFunctionOrConstructorTypeToError(isUnionType) || parseConstituentType());
25203                 }
25204                 type = finishNode(createTypeNode(createNodeArray(types, pos)), pos);
25205             }
25206             return type;
25207         }
25208         function parseIntersectionTypeOrHigher() {
25209             return parseUnionOrIntersectionType(50, parseTypeOperatorOrHigher, factory.createIntersectionTypeNode);
25210         }
25211         function parseUnionTypeOrHigher() {
25212             return parseUnionOrIntersectionType(51, parseIntersectionTypeOrHigher, factory.createUnionTypeNode);
25213         }
25214         function nextTokenIsNewKeyword() {
25215             nextToken();
25216             return token() === 102;
25217         }
25218         function isStartOfFunctionTypeOrConstructorType() {
25219             if (token() === 29) {
25220                 return true;
25221             }
25222             if (token() === 20 && lookAhead(isUnambiguouslyStartOfFunctionType)) {
25223                 return true;
25224             }
25225             return token() === 102 ||
25226                 token() === 125 && lookAhead(nextTokenIsNewKeyword);
25227         }
25228         function skipParameterStart() {
25229             if (ts.isModifierKind(token())) {
25230                 parseModifiers();
25231             }
25232             if (isIdentifier() || token() === 107) {
25233                 nextToken();
25234                 return true;
25235             }
25236             if (token() === 22 || token() === 18) {
25237                 var previousErrorCount = parseDiagnostics.length;
25238                 parseIdentifierOrPattern();
25239                 return previousErrorCount === parseDiagnostics.length;
25240             }
25241             return false;
25242         }
25243         function isUnambiguouslyStartOfFunctionType() {
25244             nextToken();
25245             if (token() === 21 || token() === 25) {
25246                 return true;
25247             }
25248             if (skipParameterStart()) {
25249                 if (token() === 58 || token() === 27 ||
25250                     token() === 57 || token() === 62) {
25251                     return true;
25252                 }
25253                 if (token() === 21) {
25254                     nextToken();
25255                     if (token() === 38) {
25256                         return true;
25257                     }
25258                 }
25259             }
25260             return false;
25261         }
25262         function parseTypeOrTypePredicate() {
25263             var pos = getNodePos();
25264             var typePredicateVariable = isIdentifier() && tryParse(parseTypePredicatePrefix);
25265             var type = parseType();
25266             if (typePredicateVariable) {
25267                 return finishNode(factory.createTypePredicateNode(undefined, typePredicateVariable, type), pos);
25268             }
25269             else {
25270                 return type;
25271             }
25272         }
25273         function parseTypePredicatePrefix() {
25274             var id = parseIdentifier();
25275             if (token() === 137 && !scanner.hasPrecedingLineBreak()) {
25276                 nextToken();
25277                 return id;
25278             }
25279         }
25280         function parseAssertsTypePredicate() {
25281             var pos = getNodePos();
25282             var assertsModifier = parseExpectedToken(127);
25283             var parameterName = token() === 107 ? parseThisTypeNode() : parseIdentifier();
25284             var type = parseOptional(137) ? parseType() : undefined;
25285             return finishNode(factory.createTypePredicateNode(assertsModifier, parameterName, type), pos);
25286         }
25287         function parseType() {
25288             return doOutsideOfContext(40960, parseTypeWorker);
25289         }
25290         function parseTypeWorker(noConditionalTypes) {
25291             if (isStartOfFunctionTypeOrConstructorType()) {
25292                 return parseFunctionOrConstructorType();
25293             }
25294             var pos = getNodePos();
25295             var type = parseUnionTypeOrHigher();
25296             if (!noConditionalTypes && !scanner.hasPrecedingLineBreak() && parseOptional(93)) {
25297                 var extendsType = parseTypeWorker(true);
25298                 parseExpected(57);
25299                 var trueType = parseTypeWorker();
25300                 parseExpected(58);
25301                 var falseType = parseTypeWorker();
25302                 return finishNode(factory.createConditionalTypeNode(type, extendsType, trueType, falseType), pos);
25303             }
25304             return type;
25305         }
25306         function parseTypeAnnotation() {
25307             return parseOptional(58) ? parseType() : undefined;
25308         }
25309         function isStartOfLeftHandSideExpression() {
25310             switch (token()) {
25311                 case 107:
25312                 case 105:
25313                 case 103:
25314                 case 109:
25315                 case 94:
25316                 case 8:
25317                 case 9:
25318                 case 10:
25319                 case 14:
25320                 case 15:
25321                 case 20:
25322                 case 22:
25323                 case 18:
25324                 case 97:
25325                 case 83:
25326                 case 102:
25327                 case 43:
25328                 case 67:
25329                 case 78:
25330                     return true;
25331                 case 99:
25332                     return lookAhead(nextTokenIsOpenParenOrLessThanOrDot);
25333                 default:
25334                     return isIdentifier();
25335             }
25336         }
25337         function isStartOfExpression() {
25338             if (isStartOfLeftHandSideExpression()) {
25339                 return true;
25340             }
25341             switch (token()) {
25342                 case 39:
25343                 case 40:
25344                 case 54:
25345                 case 53:
25346                 case 88:
25347                 case 111:
25348                 case 113:
25349                 case 45:
25350                 case 46:
25351                 case 29:
25352                 case 130:
25353                 case 124:
25354                 case 79:
25355                     return true;
25356                 default:
25357                     if (isBinaryOperator()) {
25358                         return true;
25359                     }
25360                     return isIdentifier();
25361             }
25362         }
25363         function isStartOfExpressionStatement() {
25364             return token() !== 18 &&
25365                 token() !== 97 &&
25366                 token() !== 83 &&
25367                 token() !== 59 &&
25368                 isStartOfExpression();
25369         }
25370         function parseExpression() {
25371             var saveDecoratorContext = inDecoratorContext();
25372             if (saveDecoratorContext) {
25373                 setDecoratorContext(false);
25374             }
25375             var pos = getNodePos();
25376             var expr = parseAssignmentExpressionOrHigher();
25377             var operatorToken;
25378             while ((operatorToken = parseOptionalToken(27))) {
25379                 expr = makeBinaryExpression(expr, operatorToken, parseAssignmentExpressionOrHigher(), pos);
25380             }
25381             if (saveDecoratorContext) {
25382                 setDecoratorContext(true);
25383             }
25384             return expr;
25385         }
25386         function parseInitializer() {
25387             return parseOptional(62) ? parseAssignmentExpressionOrHigher() : undefined;
25388         }
25389         function parseAssignmentExpressionOrHigher() {
25390             if (isYieldExpression()) {
25391                 return parseYieldExpression();
25392             }
25393             var arrowExpression = tryParseParenthesizedArrowFunctionExpression() || tryParseAsyncSimpleArrowFunctionExpression();
25394             if (arrowExpression) {
25395                 return arrowExpression;
25396             }
25397             var pos = getNodePos();
25398             var expr = parseBinaryExpressionOrHigher(0);
25399             if (expr.kind === 78 && token() === 38) {
25400                 return parseSimpleArrowFunctionExpression(pos, expr, undefined);
25401             }
25402             if (ts.isLeftHandSideExpression(expr) && ts.isAssignmentOperator(reScanGreaterToken())) {
25403                 return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(), pos);
25404             }
25405             return parseConditionalExpressionRest(expr, pos);
25406         }
25407         function isYieldExpression() {
25408             if (token() === 124) {
25409                 if (inYieldContext()) {
25410                     return true;
25411                 }
25412                 return lookAhead(nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine);
25413             }
25414             return false;
25415         }
25416         function nextTokenIsIdentifierOnSameLine() {
25417             nextToken();
25418             return !scanner.hasPrecedingLineBreak() && isIdentifier();
25419         }
25420         function parseYieldExpression() {
25421             var pos = getNodePos();
25422             nextToken();
25423             if (!scanner.hasPrecedingLineBreak() &&
25424                 (token() === 41 || isStartOfExpression())) {
25425                 return finishNode(factory.createYieldExpression(parseOptionalToken(41), parseAssignmentExpressionOrHigher()), pos);
25426             }
25427             else {
25428                 return finishNode(factory.createYieldExpression(undefined, undefined), pos);
25429             }
25430         }
25431         function parseSimpleArrowFunctionExpression(pos, identifier, asyncModifier) {
25432             ts.Debug.assert(token() === 38, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
25433             var parameter = factory.createParameterDeclaration(undefined, undefined, undefined, identifier, undefined, undefined, undefined);
25434             finishNode(parameter, identifier.pos);
25435             var parameters = createNodeArray([parameter], parameter.pos, parameter.end);
25436             var equalsGreaterThanToken = parseExpectedToken(38);
25437             var body = parseArrowFunctionExpressionBody(!!asyncModifier);
25438             var node = factory.createArrowFunction(asyncModifier, undefined, parameters, undefined, equalsGreaterThanToken, body);
25439             return addJSDocComment(finishNode(node, pos));
25440         }
25441         function tryParseParenthesizedArrowFunctionExpression() {
25442             var triState = isParenthesizedArrowFunctionExpression();
25443             if (triState === 0) {
25444                 return undefined;
25445             }
25446             return triState === 1 ?
25447                 parseParenthesizedArrowFunctionExpression(true) :
25448                 tryParse(parsePossibleParenthesizedArrowFunctionExpression);
25449         }
25450         function isParenthesizedArrowFunctionExpression() {
25451             if (token() === 20 || token() === 29 || token() === 129) {
25452                 return lookAhead(isParenthesizedArrowFunctionExpressionWorker);
25453             }
25454             if (token() === 38) {
25455                 return 1;
25456             }
25457             return 0;
25458         }
25459         function isParenthesizedArrowFunctionExpressionWorker() {
25460             if (token() === 129) {
25461                 nextToken();
25462                 if (scanner.hasPrecedingLineBreak()) {
25463                     return 0;
25464                 }
25465                 if (token() !== 20 && token() !== 29) {
25466                     return 0;
25467                 }
25468             }
25469             var first = token();
25470             var second = nextToken();
25471             if (first === 20) {
25472                 if (second === 21) {
25473                     var third = nextToken();
25474                     switch (third) {
25475                         case 38:
25476                         case 58:
25477                         case 18:
25478                             return 1;
25479                         default:
25480                             return 0;
25481                     }
25482                 }
25483                 if (second === 22 || second === 18) {
25484                     return 2;
25485                 }
25486                 if (second === 25) {
25487                     return 1;
25488                 }
25489                 if (ts.isModifierKind(second) && second !== 129 && lookAhead(nextTokenIsIdentifier)) {
25490                     return 1;
25491                 }
25492                 if (!isIdentifier() && second !== 107) {
25493                     return 0;
25494                 }
25495                 switch (nextToken()) {
25496                     case 58:
25497                         return 1;
25498                     case 57:
25499                         nextToken();
25500                         if (token() === 58 || token() === 27 || token() === 62 || token() === 21) {
25501                             return 1;
25502                         }
25503                         return 0;
25504                     case 27:
25505                     case 62:
25506                     case 21:
25507                         return 2;
25508                 }
25509                 return 0;
25510             }
25511             else {
25512                 ts.Debug.assert(first === 29);
25513                 if (!isIdentifier()) {
25514                     return 0;
25515                 }
25516                 if (languageVariant === 1) {
25517                     var isArrowFunctionInJsx = lookAhead(function () {
25518                         var third = nextToken();
25519                         if (third === 93) {
25520                             var fourth = nextToken();
25521                             switch (fourth) {
25522                                 case 62:
25523                                 case 31:
25524                                     return false;
25525                                 default:
25526                                     return true;
25527                             }
25528                         }
25529                         else if (third === 27) {
25530                             return true;
25531                         }
25532                         return false;
25533                     });
25534                     if (isArrowFunctionInJsx) {
25535                         return 1;
25536                     }
25537                     return 0;
25538                 }
25539                 return 2;
25540             }
25541         }
25542         function parsePossibleParenthesizedArrowFunctionExpression() {
25543             var tokenPos = scanner.getTokenPos();
25544             if (notParenthesizedArrow === null || notParenthesizedArrow === void 0 ? void 0 : notParenthesizedArrow.has(tokenPos)) {
25545                 return undefined;
25546             }
25547             var result = parseParenthesizedArrowFunctionExpression(false);
25548             if (!result) {
25549                 (notParenthesizedArrow || (notParenthesizedArrow = new ts.Set())).add(tokenPos);
25550             }
25551             return result;
25552         }
25553         function tryParseAsyncSimpleArrowFunctionExpression() {
25554             if (token() === 129) {
25555                 if (lookAhead(isUnParenthesizedAsyncArrowFunctionWorker) === 1) {
25556                     var pos = getNodePos();
25557                     var asyncModifier = parseModifiersForArrowFunction();
25558                     var expr = parseBinaryExpressionOrHigher(0);
25559                     return parseSimpleArrowFunctionExpression(pos, expr, asyncModifier);
25560                 }
25561             }
25562             return undefined;
25563         }
25564         function isUnParenthesizedAsyncArrowFunctionWorker() {
25565             if (token() === 129) {
25566                 nextToken();
25567                 if (scanner.hasPrecedingLineBreak() || token() === 38) {
25568                     return 0;
25569                 }
25570                 var expr = parseBinaryExpressionOrHigher(0);
25571                 if (!scanner.hasPrecedingLineBreak() && expr.kind === 78 && token() === 38) {
25572                     return 1;
25573                 }
25574             }
25575             return 0;
25576         }
25577         function parseParenthesizedArrowFunctionExpression(allowAmbiguity) {
25578             var pos = getNodePos();
25579             var hasJSDoc = hasPrecedingJSDocComment();
25580             var modifiers = parseModifiersForArrowFunction();
25581             var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 : 0;
25582             var typeParameters = parseTypeParameters();
25583             var parameters;
25584             if (!parseExpected(20)) {
25585                 if (!allowAmbiguity) {
25586                     return undefined;
25587                 }
25588                 parameters = createMissingList();
25589             }
25590             else {
25591                 parameters = parseParametersWorker(isAsync);
25592                 if (!parseExpected(21) && !allowAmbiguity) {
25593                     return undefined;
25594                 }
25595             }
25596             var type = parseReturnType(58, false);
25597             if (type && !allowAmbiguity && typeHasArrowFunctionBlockingParseError(type)) {
25598                 return undefined;
25599             }
25600             var hasJSDocFunctionType = type && ts.isJSDocFunctionType(type);
25601             if (!allowAmbiguity && token() !== 38 && (hasJSDocFunctionType || token() !== 18)) {
25602                 return undefined;
25603             }
25604             var lastToken = token();
25605             var equalsGreaterThanToken = parseExpectedToken(38);
25606             var body = (lastToken === 38 || lastToken === 18)
25607                 ? parseArrowFunctionExpressionBody(ts.some(modifiers, ts.isAsyncModifier))
25608                 : parseIdentifier();
25609             var node = factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body);
25610             return withJSDoc(finishNode(node, pos), hasJSDoc);
25611         }
25612         function parseArrowFunctionExpressionBody(isAsync) {
25613             if (token() === 18) {
25614                 return parseFunctionBlock(isAsync ? 2 : 0);
25615             }
25616             if (token() !== 26 &&
25617                 token() !== 97 &&
25618                 token() !== 83 &&
25619                 isStartOfStatement() &&
25620                 !isStartOfExpressionStatement()) {
25621                 return parseFunctionBlock(16 | (isAsync ? 2 : 0));
25622             }
25623             var savedTopLevel = topLevel;
25624             topLevel = false;
25625             var node = isAsync
25626                 ? doInAwaitContext(parseAssignmentExpressionOrHigher)
25627                 : doOutsideOfAwaitContext(parseAssignmentExpressionOrHigher);
25628             topLevel = savedTopLevel;
25629             return node;
25630         }
25631         function parseConditionalExpressionRest(leftOperand, pos) {
25632             var questionToken = parseOptionalToken(57);
25633             if (!questionToken) {
25634                 return leftOperand;
25635             }
25636             var colonToken;
25637             return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, parseAssignmentExpressionOrHigher), colonToken = parseExpectedToken(58), ts.nodeIsPresent(colonToken)
25638                 ? parseAssignmentExpressionOrHigher()
25639                 : createMissingNode(78, false, ts.Diagnostics._0_expected, ts.tokenToString(58))), pos);
25640         }
25641         function parseBinaryExpressionOrHigher(precedence) {
25642             var pos = getNodePos();
25643             var leftOperand = parseUnaryExpressionOrHigher();
25644             return parseBinaryExpressionRest(precedence, leftOperand, pos);
25645         }
25646         function isInOrOfKeyword(t) {
25647             return t === 100 || t === 156;
25648         }
25649         function parseBinaryExpressionRest(precedence, leftOperand, pos) {
25650             while (true) {
25651                 reScanGreaterToken();
25652                 var newPrecedence = ts.getBinaryOperatorPrecedence(token());
25653                 var consumeCurrentOperator = token() === 42 ?
25654                     newPrecedence >= precedence :
25655                     newPrecedence > precedence;
25656                 if (!consumeCurrentOperator) {
25657                     break;
25658                 }
25659                 if (token() === 100 && inDisallowInContext()) {
25660                     break;
25661                 }
25662                 if (token() === 126) {
25663                     if (scanner.hasPrecedingLineBreak()) {
25664                         break;
25665                     }
25666                     else {
25667                         nextToken();
25668                         leftOperand = makeAsExpression(leftOperand, parseType());
25669                     }
25670                 }
25671                 else {
25672                     leftOperand = makeBinaryExpression(leftOperand, parseTokenNode(), parseBinaryExpressionOrHigher(newPrecedence), pos);
25673                 }
25674             }
25675             return leftOperand;
25676         }
25677         function isBinaryOperator() {
25678             if (inDisallowInContext() && token() === 100) {
25679                 return false;
25680             }
25681             return ts.getBinaryOperatorPrecedence(token()) > 0;
25682         }
25683         function makeBinaryExpression(left, operatorToken, right, pos) {
25684             return finishNode(factory.createBinaryExpression(left, operatorToken, right), pos);
25685         }
25686         function makeAsExpression(left, right) {
25687             return finishNode(factory.createAsExpression(left, right), left.pos);
25688         }
25689         function parsePrefixUnaryExpression() {
25690             var pos = getNodePos();
25691             return finishNode(factory.createPrefixUnaryExpression(token(), nextTokenAnd(parseSimpleUnaryExpression)), pos);
25692         }
25693         function parseDeleteExpression() {
25694             var pos = getNodePos();
25695             return finishNode(factory.createDeleteExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos);
25696         }
25697         function parseTypeOfExpression() {
25698             var pos = getNodePos();
25699             return finishNode(factory.createTypeOfExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos);
25700         }
25701         function parseVoidExpression() {
25702             var pos = getNodePos();
25703             return finishNode(factory.createVoidExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos);
25704         }
25705         function isAwaitExpression() {
25706             if (token() === 130) {
25707                 if (inAwaitContext()) {
25708                     return true;
25709                 }
25710                 return lookAhead(nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine);
25711             }
25712             return false;
25713         }
25714         function parseAwaitExpression() {
25715             var pos = getNodePos();
25716             return finishNode(factory.createAwaitExpression(nextTokenAnd(parseSimpleUnaryExpression)), pos);
25717         }
25718         function parseUnaryExpressionOrHigher() {
25719             if (isUpdateExpression()) {
25720                 var pos = getNodePos();
25721                 var updateExpression = parseUpdateExpression();
25722                 return token() === 42 ?
25723                     parseBinaryExpressionRest(ts.getBinaryOperatorPrecedence(token()), updateExpression, pos) :
25724                     updateExpression;
25725             }
25726             var unaryOperator = token();
25727             var simpleUnaryExpression = parseSimpleUnaryExpression();
25728             if (token() === 42) {
25729                 var pos = ts.skipTrivia(sourceText, simpleUnaryExpression.pos);
25730                 var end = simpleUnaryExpression.end;
25731                 if (simpleUnaryExpression.kind === 206) {
25732                     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);
25733                 }
25734                 else {
25735                     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));
25736                 }
25737             }
25738             return simpleUnaryExpression;
25739         }
25740         function parseSimpleUnaryExpression() {
25741             switch (token()) {
25742                 case 39:
25743                 case 40:
25744                 case 54:
25745                 case 53:
25746                     return parsePrefixUnaryExpression();
25747                 case 88:
25748                     return parseDeleteExpression();
25749                 case 111:
25750                     return parseTypeOfExpression();
25751                 case 113:
25752                     return parseVoidExpression();
25753                 case 29:
25754                     return parseTypeAssertion();
25755                 case 130:
25756                     if (isAwaitExpression()) {
25757                         return parseAwaitExpression();
25758                     }
25759                 default:
25760                     return parseUpdateExpression();
25761             }
25762         }
25763         function isUpdateExpression() {
25764             switch (token()) {
25765                 case 39:
25766                 case 40:
25767                 case 54:
25768                 case 53:
25769                 case 88:
25770                 case 111:
25771                 case 113:
25772                 case 130:
25773                     return false;
25774                 case 29:
25775                     if (languageVariant !== 1) {
25776                         return false;
25777                     }
25778                 default:
25779                     return true;
25780             }
25781         }
25782         function parseUpdateExpression() {
25783             if (token() === 45 || token() === 46) {
25784                 var pos = getNodePos();
25785                 return finishNode(factory.createPrefixUnaryExpression(token(), nextTokenAnd(parseLeftHandSideExpressionOrHigher)), pos);
25786             }
25787             else if (languageVariant === 1 && token() === 29 && lookAhead(nextTokenIsIdentifierOrKeywordOrGreaterThan)) {
25788                 return parseJsxElementOrSelfClosingElementOrFragment(true);
25789             }
25790             var expression = parseLeftHandSideExpressionOrHigher();
25791             ts.Debug.assert(ts.isLeftHandSideExpression(expression));
25792             if ((token() === 45 || token() === 46) && !scanner.hasPrecedingLineBreak()) {
25793                 var operator = token();
25794                 nextToken();
25795                 return finishNode(factory.createPostfixUnaryExpression(expression, operator), expression.pos);
25796             }
25797             return expression;
25798         }
25799         function parseLeftHandSideExpressionOrHigher() {
25800             var pos = getNodePos();
25801             var expression;
25802             if (token() === 99) {
25803                 if (lookAhead(nextTokenIsOpenParenOrLessThan)) {
25804                     sourceFlags |= 1048576;
25805                     expression = parseTokenNode();
25806                 }
25807                 else if (lookAhead(nextTokenIsDot)) {
25808                     nextToken();
25809                     nextToken();
25810                     expression = finishNode(factory.createMetaProperty(99, parseIdentifierName()), pos);
25811                     sourceFlags |= 2097152;
25812                 }
25813                 else {
25814                     expression = parseMemberExpressionOrHigher();
25815                 }
25816             }
25817             else {
25818                 expression = token() === 105 ? parseSuperExpression() : parseMemberExpressionOrHigher();
25819             }
25820             return parseCallExpressionRest(pos, expression);
25821         }
25822         function parseMemberExpressionOrHigher() {
25823             var pos = getNodePos();
25824             var expression = parsePrimaryExpression();
25825             return parseMemberExpressionRest(pos, expression, true);
25826         }
25827         function parseSuperExpression() {
25828             var pos = getNodePos();
25829             var expression = parseTokenNode();
25830             if (token() === 29) {
25831                 var startPos = getNodePos();
25832                 var typeArguments = tryParse(parseTypeArgumentsInExpression);
25833                 if (typeArguments !== undefined) {
25834                     parseErrorAt(startPos, getNodePos(), ts.Diagnostics.super_may_not_use_type_arguments);
25835                 }
25836             }
25837             if (token() === 20 || token() === 24 || token() === 22) {
25838                 return expression;
25839             }
25840             parseExpectedToken(24, ts.Diagnostics.super_must_be_followed_by_an_argument_list_or_member_access);
25841             return finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(true, true)), pos);
25842         }
25843         function parseJsxElementOrSelfClosingElementOrFragment(inExpressionContext, topInvalidNodePosition) {
25844             var pos = getNodePos();
25845             var opening = parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext);
25846             var result;
25847             if (opening.kind === 275) {
25848                 var children = parseJsxChildren(opening);
25849                 var closingElement = parseJsxClosingElement(inExpressionContext);
25850                 if (!tagNamesAreEquivalent(opening.tagName, closingElement.tagName)) {
25851                     parseErrorAtRange(closingElement, ts.Diagnostics.Expected_corresponding_JSX_closing_tag_for_0, ts.getTextOfNodeFromSourceText(sourceText, opening.tagName));
25852                 }
25853                 result = finishNode(factory.createJsxElement(opening, children, closingElement), pos);
25854             }
25855             else if (opening.kind === 278) {
25856                 result = finishNode(factory.createJsxFragment(opening, parseJsxChildren(opening), parseJsxClosingFragment(inExpressionContext)), pos);
25857             }
25858             else {
25859                 ts.Debug.assert(opening.kind === 274);
25860                 result = opening;
25861             }
25862             if (inExpressionContext && token() === 29) {
25863                 var topBadPos_1 = typeof topInvalidNodePosition === "undefined" ? result.pos : topInvalidNodePosition;
25864                 var invalidElement = tryParse(function () { return parseJsxElementOrSelfClosingElementOrFragment(true, topBadPos_1); });
25865                 if (invalidElement) {
25866                     var operatorToken = createMissingNode(27, false);
25867                     ts.setTextRangePosWidth(operatorToken, invalidElement.pos, 0);
25868                     parseErrorAt(ts.skipTrivia(sourceText, topBadPos_1), invalidElement.end, ts.Diagnostics.JSX_expressions_must_have_one_parent_element);
25869                     return finishNode(factory.createBinaryExpression(result, operatorToken, invalidElement), pos);
25870                 }
25871             }
25872             return result;
25873         }
25874         function parseJsxText() {
25875             var pos = getNodePos();
25876             var node = factory.createJsxText(scanner.getTokenValue(), currentToken === 12);
25877             currentToken = scanner.scanJsxToken();
25878             return finishNode(node, pos);
25879         }
25880         function parseJsxChild(openingTag, token) {
25881             switch (token) {
25882                 case 1:
25883                     if (ts.isJsxOpeningFragment(openingTag)) {
25884                         parseErrorAtRange(openingTag, ts.Diagnostics.JSX_fragment_has_no_corresponding_closing_tag);
25885                     }
25886                     else {
25887                         var tag = openingTag.tagName;
25888                         var start = ts.skipTrivia(sourceText, tag.pos);
25889                         parseErrorAt(start, tag.end, ts.Diagnostics.JSX_element_0_has_no_corresponding_closing_tag, ts.getTextOfNodeFromSourceText(sourceText, openingTag.tagName));
25890                     }
25891                     return undefined;
25892                 case 30:
25893                 case 7:
25894                     return undefined;
25895                 case 11:
25896                 case 12:
25897                     return parseJsxText();
25898                 case 18:
25899                     return parseJsxExpression(false);
25900                 case 29:
25901                     return parseJsxElementOrSelfClosingElementOrFragment(false);
25902                 default:
25903                     return ts.Debug.assertNever(token);
25904             }
25905         }
25906         function parseJsxChildren(openingTag) {
25907             var list = [];
25908             var listPos = getNodePos();
25909             var saveParsingContext = parsingContext;
25910             parsingContext |= 1 << 14;
25911             while (true) {
25912                 var child = parseJsxChild(openingTag, currentToken = scanner.reScanJsxToken());
25913                 if (!child)
25914                     break;
25915                 list.push(child);
25916             }
25917             parsingContext = saveParsingContext;
25918             return createNodeArray(list, listPos);
25919         }
25920         function parseJsxAttributes() {
25921             var pos = getNodePos();
25922             return finishNode(factory.createJsxAttributes(parseList(13, parseJsxAttribute)), pos);
25923         }
25924         function parseJsxOpeningOrSelfClosingElementOrOpeningFragment(inExpressionContext) {
25925             var pos = getNodePos();
25926             parseExpected(29);
25927             if (token() === 31) {
25928                 scanJsxText();
25929                 return finishNode(factory.createJsxOpeningFragment(), pos);
25930             }
25931             var tagName = parseJsxElementName();
25932             var typeArguments = (contextFlags & 131072) === 0 ? tryParseTypeArguments() : undefined;
25933             var attributes = parseJsxAttributes();
25934             var node;
25935             if (token() === 31) {
25936                 scanJsxText();
25937                 node = factory.createJsxOpeningElement(tagName, typeArguments, attributes);
25938             }
25939             else {
25940                 parseExpected(43);
25941                 if (inExpressionContext) {
25942                     parseExpected(31);
25943                 }
25944                 else {
25945                     parseExpected(31, undefined, false);
25946                     scanJsxText();
25947                 }
25948                 node = factory.createJsxSelfClosingElement(tagName, typeArguments, attributes);
25949             }
25950             return finishNode(node, pos);
25951         }
25952         function parseJsxElementName() {
25953             var pos = getNodePos();
25954             scanJsxIdentifier();
25955             var expression = token() === 107 ?
25956                 parseTokenNode() : parseIdentifierName();
25957             while (parseOptional(24)) {
25958                 expression = finishNode(factory.createPropertyAccessExpression(expression, parseRightSideOfDot(true, false)), pos);
25959             }
25960             return expression;
25961         }
25962         function parseJsxExpression(inExpressionContext) {
25963             var pos = getNodePos();
25964             if (!parseExpected(18)) {
25965                 return undefined;
25966             }
25967             var dotDotDotToken;
25968             var expression;
25969             if (token() !== 19) {
25970                 dotDotDotToken = parseOptionalToken(25);
25971                 expression = parseExpression();
25972             }
25973             if (inExpressionContext) {
25974                 parseExpected(19);
25975             }
25976             else {
25977                 if (parseExpected(19, undefined, false)) {
25978                     scanJsxText();
25979                 }
25980             }
25981             return finishNode(factory.createJsxExpression(dotDotDotToken, expression), pos);
25982         }
25983         function parseJsxAttribute() {
25984             if (token() === 18) {
25985                 return parseJsxSpreadAttribute();
25986             }
25987             scanJsxIdentifier();
25988             var pos = getNodePos();
25989             return finishNode(factory.createJsxAttribute(parseIdentifierName(), token() !== 62 ? undefined :
25990                 scanJsxAttributeValue() === 10 ? parseLiteralNode() :
25991                     parseJsxExpression(true)), pos);
25992         }
25993         function parseJsxSpreadAttribute() {
25994             var pos = getNodePos();
25995             parseExpected(18);
25996             parseExpected(25);
25997             var expression = parseExpression();
25998             parseExpected(19);
25999             return finishNode(factory.createJsxSpreadAttribute(expression), pos);
26000         }
26001         function parseJsxClosingElement(inExpressionContext) {
26002             var pos = getNodePos();
26003             parseExpected(30);
26004             var tagName = parseJsxElementName();
26005             if (inExpressionContext) {
26006                 parseExpected(31);
26007             }
26008             else {
26009                 parseExpected(31, undefined, false);
26010                 scanJsxText();
26011             }
26012             return finishNode(factory.createJsxClosingElement(tagName), pos);
26013         }
26014         function parseJsxClosingFragment(inExpressionContext) {
26015             var pos = getNodePos();
26016             parseExpected(30);
26017             if (ts.tokenIsIdentifierOrKeyword(token())) {
26018                 parseErrorAtRange(parseJsxElementName(), ts.Diagnostics.Expected_corresponding_closing_tag_for_JSX_fragment);
26019             }
26020             if (inExpressionContext) {
26021                 parseExpected(31);
26022             }
26023             else {
26024                 parseExpected(31, undefined, false);
26025                 scanJsxText();
26026             }
26027             return finishNode(factory.createJsxJsxClosingFragment(), pos);
26028         }
26029         function parseTypeAssertion() {
26030             var pos = getNodePos();
26031             parseExpected(29);
26032             var type = parseType();
26033             parseExpected(31);
26034             var expression = parseSimpleUnaryExpression();
26035             return finishNode(factory.createTypeAssertion(type, expression), pos);
26036         }
26037         function nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate() {
26038             nextToken();
26039             return ts.tokenIsIdentifierOrKeyword(token())
26040                 || token() === 22
26041                 || isTemplateStartOfTaggedTemplate();
26042         }
26043         function isStartOfOptionalPropertyOrElementAccessChain() {
26044             return token() === 28
26045                 && lookAhead(nextTokenIsIdentifierOrKeywordOrOpenBracketOrTemplate);
26046         }
26047         function tryReparseOptionalChain(node) {
26048             if (node.flags & 32) {
26049                 return true;
26050             }
26051             if (ts.isNonNullExpression(node)) {
26052                 var expr = node.expression;
26053                 while (ts.isNonNullExpression(expr) && !(expr.flags & 32)) {
26054                     expr = expr.expression;
26055                 }
26056                 if (expr.flags & 32) {
26057                     while (ts.isNonNullExpression(node)) {
26058                         node.flags |= 32;
26059                         node = node.expression;
26060                     }
26061                     return true;
26062                 }
26063             }
26064             return false;
26065         }
26066         function parsePropertyAccessExpressionRest(pos, expression, questionDotToken) {
26067             var name = parseRightSideOfDot(true, true);
26068             var isOptionalChain = questionDotToken || tryReparseOptionalChain(expression);
26069             var propertyAccess = isOptionalChain ?
26070                 factory.createPropertyAccessChain(expression, questionDotToken, name) :
26071                 factory.createPropertyAccessExpression(expression, name);
26072             if (isOptionalChain && ts.isPrivateIdentifier(propertyAccess.name)) {
26073                 parseErrorAtRange(propertyAccess.name, ts.Diagnostics.An_optional_chain_cannot_contain_private_identifiers);
26074             }
26075             return finishNode(propertyAccess, pos);
26076         }
26077         function parseElementAccessExpressionRest(pos, expression, questionDotToken) {
26078             var argumentExpression;
26079             if (token() === 23) {
26080                 argumentExpression = createMissingNode(78, true, ts.Diagnostics.An_element_access_expression_should_take_an_argument);
26081             }
26082             else {
26083                 var argument = allowInAnd(parseExpression);
26084                 if (ts.isStringOrNumericLiteralLike(argument)) {
26085                     argument.text = internIdentifier(argument.text);
26086                 }
26087                 argumentExpression = argument;
26088             }
26089             parseExpected(23);
26090             var indexedAccess = questionDotToken || tryReparseOptionalChain(expression) ?
26091                 factory.createElementAccessChain(expression, questionDotToken, argumentExpression) :
26092                 factory.createElementAccessExpression(expression, argumentExpression);
26093             return finishNode(indexedAccess, pos);
26094         }
26095         function parseMemberExpressionRest(pos, expression, allowOptionalChain) {
26096             while (true) {
26097                 var questionDotToken = void 0;
26098                 var isPropertyAccess = false;
26099                 if (allowOptionalChain && isStartOfOptionalPropertyOrElementAccessChain()) {
26100                     questionDotToken = parseExpectedToken(28);
26101                     isPropertyAccess = ts.tokenIsIdentifierOrKeyword(token());
26102                 }
26103                 else {
26104                     isPropertyAccess = parseOptional(24);
26105                 }
26106                 if (isPropertyAccess) {
26107                     expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken);
26108                     continue;
26109                 }
26110                 if (!questionDotToken && token() === 53 && !scanner.hasPrecedingLineBreak()) {
26111                     nextToken();
26112                     expression = finishNode(factory.createNonNullExpression(expression), pos);
26113                     continue;
26114                 }
26115                 if ((questionDotToken || !inDecoratorContext()) && parseOptional(22)) {
26116                     expression = parseElementAccessExpressionRest(pos, expression, questionDotToken);
26117                     continue;
26118                 }
26119                 if (isTemplateStartOfTaggedTemplate()) {
26120                     expression = parseTaggedTemplateRest(pos, expression, questionDotToken, undefined);
26121                     continue;
26122                 }
26123                 return expression;
26124             }
26125         }
26126         function isTemplateStartOfTaggedTemplate() {
26127             return token() === 14 || token() === 15;
26128         }
26129         function parseTaggedTemplateRest(pos, tag, questionDotToken, typeArguments) {
26130             var tagExpression = factory.createTaggedTemplateExpression(tag, typeArguments, token() === 14 ?
26131                 (reScanTemplateHeadOrNoSubstitutionTemplate(), parseLiteralNode()) :
26132                 parseTemplateExpression(true));
26133             if (questionDotToken || tag.flags & 32) {
26134                 tagExpression.flags |= 32;
26135             }
26136             tagExpression.questionDotToken = questionDotToken;
26137             return finishNode(tagExpression, pos);
26138         }
26139         function parseCallExpressionRest(pos, expression) {
26140             while (true) {
26141                 expression = parseMemberExpressionRest(pos, expression, true);
26142                 var questionDotToken = parseOptionalToken(28);
26143                 if ((contextFlags & 131072) === 0 && (token() === 29 || token() === 47)) {
26144                     var typeArguments = tryParse(parseTypeArgumentsInExpression);
26145                     if (typeArguments) {
26146                         if (isTemplateStartOfTaggedTemplate()) {
26147                             expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
26148                             continue;
26149                         }
26150                         var argumentList = parseArgumentList();
26151                         var callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
26152                             factory.createCallChain(expression, questionDotToken, typeArguments, argumentList) :
26153                             factory.createCallExpression(expression, typeArguments, argumentList);
26154                         expression = finishNode(callExpr, pos);
26155                         continue;
26156                     }
26157                 }
26158                 else if (token() === 20) {
26159                     var argumentList = parseArgumentList();
26160                     var callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
26161                         factory.createCallChain(expression, questionDotToken, undefined, argumentList) :
26162                         factory.createCallExpression(expression, undefined, argumentList);
26163                     expression = finishNode(callExpr, pos);
26164                     continue;
26165                 }
26166                 if (questionDotToken) {
26167                     var name = createMissingNode(78, false, ts.Diagnostics.Identifier_expected);
26168                     expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos);
26169                 }
26170                 break;
26171             }
26172             return expression;
26173         }
26174         function parseArgumentList() {
26175             parseExpected(20);
26176             var result = parseDelimitedList(11, parseArgumentExpression);
26177             parseExpected(21);
26178             return result;
26179         }
26180         function parseTypeArgumentsInExpression() {
26181             if ((contextFlags & 131072) !== 0) {
26182                 return undefined;
26183             }
26184             if (reScanLessThanToken() !== 29) {
26185                 return undefined;
26186             }
26187             nextToken();
26188             var typeArguments = parseDelimitedList(20, parseType);
26189             if (!parseExpected(31)) {
26190                 return undefined;
26191             }
26192             return typeArguments && canFollowTypeArgumentsInExpression()
26193                 ? typeArguments
26194                 : undefined;
26195         }
26196         function canFollowTypeArgumentsInExpression() {
26197             switch (token()) {
26198                 case 20:
26199                 case 14:
26200                 case 15:
26201                 case 24:
26202                 case 21:
26203                 case 23:
26204                 case 58:
26205                 case 26:
26206                 case 57:
26207                 case 34:
26208                 case 36:
26209                 case 35:
26210                 case 37:
26211                 case 55:
26212                 case 56:
26213                 case 60:
26214                 case 52:
26215                 case 50:
26216                 case 51:
26217                 case 19:
26218                 case 1:
26219                     return true;
26220                 case 27:
26221                 case 18:
26222                 default:
26223                     return false;
26224             }
26225         }
26226         function parsePrimaryExpression() {
26227             switch (token()) {
26228                 case 8:
26229                 case 9:
26230                 case 10:
26231                 case 14:
26232                     return parseLiteralNode();
26233                 case 107:
26234                 case 105:
26235                 case 103:
26236                 case 109:
26237                 case 94:
26238                     return parseTokenNode();
26239                 case 20:
26240                     return parseParenthesizedExpression();
26241                 case 22:
26242                     return parseArrayLiteralExpression();
26243                 case 18:
26244                     return parseObjectLiteralExpression();
26245                 case 129:
26246                     if (!lookAhead(nextTokenIsFunctionKeywordOnSameLine)) {
26247                         break;
26248                     }
26249                     return parseFunctionExpression();
26250                 case 83:
26251                     return parseClassExpression();
26252                 case 97:
26253                     return parseFunctionExpression();
26254                 case 102:
26255                     return parseNewExpressionOrNewDotTarget();
26256                 case 43:
26257                 case 67:
26258                     if (reScanSlashToken() === 13) {
26259                         return parseLiteralNode();
26260                     }
26261                     break;
26262                 case 15:
26263                     return parseTemplateExpression(false);
26264             }
26265             return parseIdentifier(ts.Diagnostics.Expression_expected);
26266         }
26267         function parseParenthesizedExpression() {
26268             var pos = getNodePos();
26269             var hasJSDoc = hasPrecedingJSDocComment();
26270             parseExpected(20);
26271             var expression = allowInAnd(parseExpression);
26272             parseExpected(21);
26273             return withJSDoc(finishNode(factory.createParenthesizedExpression(expression), pos), hasJSDoc);
26274         }
26275         function parseSpreadElement() {
26276             var pos = getNodePos();
26277             parseExpected(25);
26278             var expression = parseAssignmentExpressionOrHigher();
26279             return finishNode(factory.createSpreadElement(expression), pos);
26280         }
26281         function parseArgumentOrArrayLiteralElement() {
26282             return token() === 25 ? parseSpreadElement() :
26283                 token() === 27 ? finishNode(factory.createOmittedExpression(), getNodePos()) :
26284                     parseAssignmentExpressionOrHigher();
26285         }
26286         function parseArgumentExpression() {
26287             return doOutsideOfContext(disallowInAndDecoratorContext, parseArgumentOrArrayLiteralElement);
26288         }
26289         function parseArrayLiteralExpression() {
26290             var pos = getNodePos();
26291             parseExpected(22);
26292             var multiLine = scanner.hasPrecedingLineBreak();
26293             var elements = parseDelimitedList(15, parseArgumentOrArrayLiteralElement);
26294             parseExpected(23);
26295             return finishNode(factory.createArrayLiteralExpression(elements, multiLine), pos);
26296         }
26297         function parseObjectLiteralElement() {
26298             var pos = getNodePos();
26299             var hasJSDoc = hasPrecedingJSDocComment();
26300             if (parseOptionalToken(25)) {
26301                 var expression = parseAssignmentExpressionOrHigher();
26302                 return withJSDoc(finishNode(factory.createSpreadAssignment(expression), pos), hasJSDoc);
26303             }
26304             var decorators = parseDecorators();
26305             var modifiers = parseModifiers();
26306             if (parseContextualModifier(134)) {
26307                 return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167);
26308             }
26309             if (parseContextualModifier(146)) {
26310                 return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168);
26311             }
26312             var asteriskToken = parseOptionalToken(41);
26313             var tokenIsIdentifier = isIdentifier();
26314             var name = parsePropertyName();
26315             var questionToken = parseOptionalToken(57);
26316             var exclamationToken = parseOptionalToken(53);
26317             if (asteriskToken || token() === 20 || token() === 29) {
26318                 return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken);
26319             }
26320             var node;
26321             var isShorthandPropertyAssignment = tokenIsIdentifier && (token() !== 58);
26322             if (isShorthandPropertyAssignment) {
26323                 var equalsToken = parseOptionalToken(62);
26324                 var objectAssignmentInitializer = equalsToken ? allowInAnd(parseAssignmentExpressionOrHigher) : undefined;
26325                 node = factory.createShorthandPropertyAssignment(name, objectAssignmentInitializer);
26326                 node.equalsToken = equalsToken;
26327             }
26328             else {
26329                 parseExpected(58);
26330                 var initializer = allowInAnd(parseAssignmentExpressionOrHigher);
26331                 node = factory.createPropertyAssignment(name, initializer);
26332             }
26333             node.decorators = decorators;
26334             node.modifiers = modifiers;
26335             node.questionToken = questionToken;
26336             node.exclamationToken = exclamationToken;
26337             return withJSDoc(finishNode(node, pos), hasJSDoc);
26338         }
26339         function parseObjectLiteralExpression() {
26340             var pos = getNodePos();
26341             var openBracePosition = scanner.getTokenPos();
26342             parseExpected(18);
26343             var multiLine = scanner.hasPrecedingLineBreak();
26344             var properties = parseDelimitedList(12, parseObjectLiteralElement, true);
26345             if (!parseExpected(19)) {
26346                 var lastError = ts.lastOrUndefined(parseDiagnostics);
26347                 if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
26348                     ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
26349                 }
26350             }
26351             return finishNode(factory.createObjectLiteralExpression(properties, multiLine), pos);
26352         }
26353         function parseFunctionExpression() {
26354             var saveDecoratorContext = inDecoratorContext();
26355             if (saveDecoratorContext) {
26356                 setDecoratorContext(false);
26357             }
26358             var pos = getNodePos();
26359             var hasJSDoc = hasPrecedingJSDocComment();
26360             var modifiers = parseModifiers();
26361             parseExpected(97);
26362             var asteriskToken = parseOptionalToken(41);
26363             var isGenerator = asteriskToken ? 1 : 0;
26364             var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 : 0;
26365             var name = isGenerator && isAsync ? doInYieldAndAwaitContext(parseOptionalBindingIdentifier) :
26366                 isGenerator ? doInYieldContext(parseOptionalBindingIdentifier) :
26367                     isAsync ? doInAwaitContext(parseOptionalBindingIdentifier) :
26368                         parseOptionalBindingIdentifier();
26369             var typeParameters = parseTypeParameters();
26370             var parameters = parseParameters(isGenerator | isAsync);
26371             var type = parseReturnType(58, false);
26372             var body = parseFunctionBlock(isGenerator | isAsync);
26373             if (saveDecoratorContext) {
26374                 setDecoratorContext(true);
26375             }
26376             var node = factory.createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body);
26377             return withJSDoc(finishNode(node, pos), hasJSDoc);
26378         }
26379         function parseOptionalBindingIdentifier() {
26380             return isBindingIdentifier() ? parseBindingIdentifier() : undefined;
26381         }
26382         function parseNewExpressionOrNewDotTarget() {
26383             var pos = getNodePos();
26384             parseExpected(102);
26385             if (parseOptional(24)) {
26386                 var name = parseIdentifierName();
26387                 return finishNode(factory.createMetaProperty(102, name), pos);
26388             }
26389             var expressionPos = getNodePos();
26390             var expression = parsePrimaryExpression();
26391             var typeArguments;
26392             while (true) {
26393                 expression = parseMemberExpressionRest(expressionPos, expression, false);
26394                 typeArguments = tryParse(parseTypeArgumentsInExpression);
26395                 if (isTemplateStartOfTaggedTemplate()) {
26396                     ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'");
26397                     expression = parseTaggedTemplateRest(expressionPos, expression, undefined, typeArguments);
26398                     typeArguments = undefined;
26399                 }
26400                 break;
26401             }
26402             var argumentsArray;
26403             if (token() === 20) {
26404                 argumentsArray = parseArgumentList();
26405             }
26406             else if (typeArguments) {
26407                 parseErrorAt(pos, scanner.getStartPos(), ts.Diagnostics.A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list);
26408             }
26409             return finishNode(factory.createNewExpression(expression, typeArguments, argumentsArray), pos);
26410         }
26411         function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) {
26412             var pos = getNodePos();
26413             var openBracePosition = scanner.getTokenPos();
26414             if (parseExpected(18, diagnosticMessage) || ignoreMissingOpenBrace) {
26415                 var multiLine = scanner.hasPrecedingLineBreak();
26416                 var statements = parseList(1, parseStatement);
26417                 if (!parseExpected(19)) {
26418                     var lastError = ts.lastOrUndefined(parseDiagnostics);
26419                     if (lastError && lastError.code === ts.Diagnostics._0_expected.code) {
26420                         ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, openBracePosition, 1, ts.Diagnostics.The_parser_expected_to_find_a_to_match_the_token_here));
26421                     }
26422                 }
26423                 return finishNode(factory.createBlock(statements, multiLine), pos);
26424             }
26425             else {
26426                 var statements = createMissingList();
26427                 return finishNode(factory.createBlock(statements, undefined), pos);
26428             }
26429         }
26430         function parseFunctionBlock(flags, diagnosticMessage) {
26431             var savedYieldContext = inYieldContext();
26432             setYieldContext(!!(flags & 1));
26433             var savedAwaitContext = inAwaitContext();
26434             setAwaitContext(!!(flags & 2));
26435             var savedTopLevel = topLevel;
26436             topLevel = false;
26437             var saveDecoratorContext = inDecoratorContext();
26438             if (saveDecoratorContext) {
26439                 setDecoratorContext(false);
26440             }
26441             var block = parseBlock(!!(flags & 16), diagnosticMessage);
26442             if (saveDecoratorContext) {
26443                 setDecoratorContext(true);
26444             }
26445             topLevel = savedTopLevel;
26446             setYieldContext(savedYieldContext);
26447             setAwaitContext(savedAwaitContext);
26448             return block;
26449         }
26450         function parseEmptyStatement() {
26451             var pos = getNodePos();
26452             parseExpected(26);
26453             return finishNode(factory.createEmptyStatement(), pos);
26454         }
26455         function parseIfStatement() {
26456             var pos = getNodePos();
26457             parseExpected(98);
26458             parseExpected(20);
26459             var expression = allowInAnd(parseExpression);
26460             parseExpected(21);
26461             var thenStatement = parseStatement();
26462             var elseStatement = parseOptional(90) ? parseStatement() : undefined;
26463             return finishNode(factory.createIfStatement(expression, thenStatement, elseStatement), pos);
26464         }
26465         function parseDoStatement() {
26466             var pos = getNodePos();
26467             parseExpected(89);
26468             var statement = parseStatement();
26469             parseExpected(114);
26470             parseExpected(20);
26471             var expression = allowInAnd(parseExpression);
26472             parseExpected(21);
26473             parseOptional(26);
26474             return finishNode(factory.createDoStatement(statement, expression), pos);
26475         }
26476         function parseWhileStatement() {
26477             var pos = getNodePos();
26478             parseExpected(114);
26479             parseExpected(20);
26480             var expression = allowInAnd(parseExpression);
26481             parseExpected(21);
26482             var statement = parseStatement();
26483             return finishNode(factory.createWhileStatement(expression, statement), pos);
26484         }
26485         function parseForOrForInOrForOfStatement() {
26486             var pos = getNodePos();
26487             parseExpected(96);
26488             var awaitToken = parseOptionalToken(130);
26489             parseExpected(20);
26490             var initializer;
26491             if (token() !== 26) {
26492                 if (token() === 112 || token() === 118 || token() === 84) {
26493                     initializer = parseVariableDeclarationList(true);
26494                 }
26495                 else {
26496                     initializer = disallowInAnd(parseExpression);
26497                 }
26498             }
26499             var node;
26500             if (awaitToken ? parseExpected(156) : parseOptional(156)) {
26501                 var expression = allowInAnd(parseAssignmentExpressionOrHigher);
26502                 parseExpected(21);
26503                 node = factory.createForOfStatement(awaitToken, initializer, expression, parseStatement());
26504             }
26505             else if (parseOptional(100)) {
26506                 var expression = allowInAnd(parseExpression);
26507                 parseExpected(21);
26508                 node = factory.createForInStatement(initializer, expression, parseStatement());
26509             }
26510             else {
26511                 parseExpected(26);
26512                 var condition = token() !== 26 && token() !== 21
26513                     ? allowInAnd(parseExpression)
26514                     : undefined;
26515                 parseExpected(26);
26516                 var incrementor = token() !== 21
26517                     ? allowInAnd(parseExpression)
26518                     : undefined;
26519                 parseExpected(21);
26520                 node = factory.createForStatement(initializer, condition, incrementor, parseStatement());
26521             }
26522             return finishNode(node, pos);
26523         }
26524         function parseBreakOrContinueStatement(kind) {
26525             var pos = getNodePos();
26526             parseExpected(kind === 241 ? 80 : 85);
26527             var label = canParseSemicolon() ? undefined : parseIdentifier();
26528             parseSemicolon();
26529             var node = kind === 241
26530                 ? factory.createBreakStatement(label)
26531                 : factory.createContinueStatement(label);
26532             return finishNode(node, pos);
26533         }
26534         function parseReturnStatement() {
26535             var pos = getNodePos();
26536             parseExpected(104);
26537             var expression = canParseSemicolon() ? undefined : allowInAnd(parseExpression);
26538             parseSemicolon();
26539             return finishNode(factory.createReturnStatement(expression), pos);
26540         }
26541         function parseWithStatement() {
26542             var pos = getNodePos();
26543             parseExpected(115);
26544             parseExpected(20);
26545             var expression = allowInAnd(parseExpression);
26546             parseExpected(21);
26547             var statement = doInsideOfContext(16777216, parseStatement);
26548             return finishNode(factory.createWithStatement(expression, statement), pos);
26549         }
26550         function parseCaseClause() {
26551             var pos = getNodePos();
26552             parseExpected(81);
26553             var expression = allowInAnd(parseExpression);
26554             parseExpected(58);
26555             var statements = parseList(3, parseStatement);
26556             return finishNode(factory.createCaseClause(expression, statements), pos);
26557         }
26558         function parseDefaultClause() {
26559             var pos = getNodePos();
26560             parseExpected(87);
26561             parseExpected(58);
26562             var statements = parseList(3, parseStatement);
26563             return finishNode(factory.createDefaultClause(statements), pos);
26564         }
26565         function parseCaseOrDefaultClause() {
26566             return token() === 81 ? parseCaseClause() : parseDefaultClause();
26567         }
26568         function parseCaseBlock() {
26569             var pos = getNodePos();
26570             parseExpected(18);
26571             var clauses = parseList(2, parseCaseOrDefaultClause);
26572             parseExpected(19);
26573             return finishNode(factory.createCaseBlock(clauses), pos);
26574         }
26575         function parseSwitchStatement() {
26576             var pos = getNodePos();
26577             parseExpected(106);
26578             parseExpected(20);
26579             var expression = allowInAnd(parseExpression);
26580             parseExpected(21);
26581             var caseBlock = parseCaseBlock();
26582             return finishNode(factory.createSwitchStatement(expression, caseBlock), pos);
26583         }
26584         function parseThrowStatement() {
26585             var pos = getNodePos();
26586             parseExpected(108);
26587             var expression = scanner.hasPrecedingLineBreak() ? undefined : allowInAnd(parseExpression);
26588             if (expression === undefined) {
26589                 identifierCount++;
26590                 expression = finishNode(factory.createIdentifier(""), getNodePos());
26591             }
26592             parseSemicolon();
26593             return finishNode(factory.createThrowStatement(expression), pos);
26594         }
26595         function parseTryStatement() {
26596             var pos = getNodePos();
26597             parseExpected(110);
26598             var tryBlock = parseBlock(false);
26599             var catchClause = token() === 82 ? parseCatchClause() : undefined;
26600             var finallyBlock;
26601             if (!catchClause || token() === 95) {
26602                 parseExpected(95);
26603                 finallyBlock = parseBlock(false);
26604             }
26605             return finishNode(factory.createTryStatement(tryBlock, catchClause, finallyBlock), pos);
26606         }
26607         function parseCatchClause() {
26608             var pos = getNodePos();
26609             parseExpected(82);
26610             var variableDeclaration;
26611             if (parseOptional(20)) {
26612                 variableDeclaration = parseVariableDeclaration();
26613                 parseExpected(21);
26614             }
26615             else {
26616                 variableDeclaration = undefined;
26617             }
26618             var block = parseBlock(false);
26619             return finishNode(factory.createCatchClause(variableDeclaration, block), pos);
26620         }
26621         function parseDebuggerStatement() {
26622             var pos = getNodePos();
26623             parseExpected(86);
26624             parseSemicolon();
26625             return finishNode(factory.createDebuggerStatement(), pos);
26626         }
26627         function parseExpressionOrLabeledStatement() {
26628             var pos = getNodePos();
26629             var hasJSDoc = hasPrecedingJSDocComment();
26630             var node;
26631             var hasParen = token() === 20;
26632             var expression = allowInAnd(parseExpression);
26633             if (ts.isIdentifier(expression) && parseOptional(58)) {
26634                 node = factory.createLabeledStatement(expression, parseStatement());
26635             }
26636             else {
26637                 parseSemicolon();
26638                 node = factory.createExpressionStatement(expression);
26639                 if (hasParen) {
26640                     hasJSDoc = false;
26641                 }
26642             }
26643             return withJSDoc(finishNode(node, pos), hasJSDoc);
26644         }
26645         function nextTokenIsIdentifierOrKeywordOnSameLine() {
26646             nextToken();
26647             return ts.tokenIsIdentifierOrKeyword(token()) && !scanner.hasPrecedingLineBreak();
26648         }
26649         function nextTokenIsClassKeywordOnSameLine() {
26650             nextToken();
26651             return token() === 83 && !scanner.hasPrecedingLineBreak();
26652         }
26653         function nextTokenIsFunctionKeywordOnSameLine() {
26654             nextToken();
26655             return token() === 97 && !scanner.hasPrecedingLineBreak();
26656         }
26657         function nextTokenIsIdentifierOrKeywordOrLiteralOnSameLine() {
26658             nextToken();
26659             return (ts.tokenIsIdentifierOrKeyword(token()) || token() === 8 || token() === 9 || token() === 10) && !scanner.hasPrecedingLineBreak();
26660         }
26661         function isDeclaration() {
26662             while (true) {
26663                 switch (token()) {
26664                     case 112:
26665                     case 118:
26666                     case 84:
26667                     case 97:
26668                     case 83:
26669                     case 91:
26670                         return true;
26671                     case 117:
26672                     case 149:
26673                         return nextTokenIsIdentifierOnSameLine();
26674                     case 139:
26675                     case 140:
26676                         return nextTokenIsIdentifierOrStringLiteralOnSameLine();
26677                     case 125:
26678                     case 129:
26679                     case 133:
26680                     case 120:
26681                     case 121:
26682                     case 122:
26683                     case 142:
26684                         nextToken();
26685                         if (scanner.hasPrecedingLineBreak()) {
26686                             return false;
26687                         }
26688                         continue;
26689                     case 154:
26690                         nextToken();
26691                         return token() === 18 || token() === 78 || token() === 92;
26692                     case 99:
26693                         nextToken();
26694                         return token() === 10 || token() === 41 ||
26695                             token() === 18 || ts.tokenIsIdentifierOrKeyword(token());
26696                     case 92:
26697                         var currentToken_1 = nextToken();
26698                         if (currentToken_1 === 149) {
26699                             currentToken_1 = lookAhead(nextToken);
26700                         }
26701                         if (currentToken_1 === 62 || currentToken_1 === 41 ||
26702                             currentToken_1 === 18 || currentToken_1 === 87 ||
26703                             currentToken_1 === 126) {
26704                             return true;
26705                         }
26706                         continue;
26707                     case 123:
26708                         nextToken();
26709                         continue;
26710                     default:
26711                         return false;
26712                 }
26713             }
26714         }
26715         function isStartOfDeclaration() {
26716             return lookAhead(isDeclaration);
26717         }
26718         function isStartOfStatement() {
26719             switch (token()) {
26720                 case 59:
26721                 case 26:
26722                 case 18:
26723                 case 112:
26724                 case 118:
26725                 case 97:
26726                 case 83:
26727                 case 91:
26728                 case 98:
26729                 case 89:
26730                 case 114:
26731                 case 96:
26732                 case 85:
26733                 case 80:
26734                 case 104:
26735                 case 115:
26736                 case 106:
26737                 case 108:
26738                 case 110:
26739                 case 86:
26740                 case 82:
26741                 case 95:
26742                     return true;
26743                 case 99:
26744                     return isStartOfDeclaration() || lookAhead(nextTokenIsOpenParenOrLessThanOrDot);
26745                 case 84:
26746                 case 92:
26747                     return isStartOfDeclaration();
26748                 case 129:
26749                 case 133:
26750                 case 117:
26751                 case 139:
26752                 case 140:
26753                 case 149:
26754                 case 154:
26755                     return true;
26756                 case 122:
26757                 case 120:
26758                 case 121:
26759                 case 123:
26760                 case 142:
26761                     return isStartOfDeclaration() || !lookAhead(nextTokenIsIdentifierOrKeywordOnSameLine);
26762                 default:
26763                     return isStartOfExpression();
26764             }
26765         }
26766         function nextTokenIsIdentifierOrStartOfDestructuring() {
26767             nextToken();
26768             return isIdentifier() || token() === 18 || token() === 22;
26769         }
26770         function isLetDeclaration() {
26771             return lookAhead(nextTokenIsIdentifierOrStartOfDestructuring);
26772         }
26773         function parseStatement() {
26774             switch (token()) {
26775                 case 26:
26776                     return parseEmptyStatement();
26777                 case 18:
26778                     return parseBlock(false);
26779                 case 112:
26780                     return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), undefined, undefined);
26781                 case 118:
26782                     if (isLetDeclaration()) {
26783                         return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), undefined, undefined);
26784                     }
26785                     break;
26786                 case 97:
26787                     return parseFunctionDeclaration(getNodePos(), hasPrecedingJSDocComment(), undefined, undefined);
26788                 case 83:
26789                     return parseClassDeclaration(getNodePos(), hasPrecedingJSDocComment(), undefined, undefined);
26790                 case 98:
26791                     return parseIfStatement();
26792                 case 89:
26793                     return parseDoStatement();
26794                 case 114:
26795                     return parseWhileStatement();
26796                 case 96:
26797                     return parseForOrForInOrForOfStatement();
26798                 case 85:
26799                     return parseBreakOrContinueStatement(240);
26800                 case 80:
26801                     return parseBreakOrContinueStatement(241);
26802                 case 104:
26803                     return parseReturnStatement();
26804                 case 115:
26805                     return parseWithStatement();
26806                 case 106:
26807                     return parseSwitchStatement();
26808                 case 108:
26809                     return parseThrowStatement();
26810                 case 110:
26811                 case 82:
26812                 case 95:
26813                     return parseTryStatement();
26814                 case 86:
26815                     return parseDebuggerStatement();
26816                 case 59:
26817                     return parseDeclaration();
26818                 case 129:
26819                 case 117:
26820                 case 149:
26821                 case 139:
26822                 case 140:
26823                 case 133:
26824                 case 84:
26825                 case 91:
26826                 case 92:
26827                 case 99:
26828                 case 120:
26829                 case 121:
26830                 case 122:
26831                 case 125:
26832                 case 123:
26833                 case 142:
26834                 case 154:
26835                     if (isStartOfDeclaration()) {
26836                         return parseDeclaration();
26837                     }
26838                     break;
26839             }
26840             return parseExpressionOrLabeledStatement();
26841         }
26842         function isDeclareModifier(modifier) {
26843             return modifier.kind === 133;
26844         }
26845         function parseDeclaration() {
26846             var isAmbient = ts.some(lookAhead(function () { return (parseDecorators(), parseModifiers()); }), isDeclareModifier);
26847             if (isAmbient) {
26848                 var node = tryReuseAmbientDeclaration();
26849                 if (node) {
26850                     return node;
26851                 }
26852             }
26853             var pos = getNodePos();
26854             var hasJSDoc = hasPrecedingJSDocComment();
26855             var decorators = parseDecorators();
26856             var modifiers = parseModifiers();
26857             if (isAmbient) {
26858                 for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
26859                     var m = _a[_i];
26860                     m.flags |= 8388608;
26861                 }
26862                 return doInsideOfContext(8388608, function () { return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers); });
26863             }
26864             else {
26865                 return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers);
26866             }
26867         }
26868         function tryReuseAmbientDeclaration() {
26869             return doInsideOfContext(8388608, function () {
26870                 var node = currentNode(parsingContext);
26871                 if (node) {
26872                     return consumeNode(node);
26873                 }
26874             });
26875         }
26876         function parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers) {
26877             switch (token()) {
26878                 case 112:
26879                 case 118:
26880                 case 84:
26881                     return parseVariableStatement(pos, hasJSDoc, decorators, modifiers);
26882                 case 97:
26883                     return parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers);
26884                 case 83:
26885                     return parseClassDeclaration(pos, hasJSDoc, decorators, modifiers);
26886                 case 117:
26887                     return parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers);
26888                 case 149:
26889                     return parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers);
26890                 case 91:
26891                     return parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers);
26892                 case 154:
26893                 case 139:
26894                 case 140:
26895                     return parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers);
26896                 case 99:
26897                     return parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers);
26898                 case 92:
26899                     nextToken();
26900                     switch (token()) {
26901                         case 87:
26902                         case 62:
26903                             return parseExportAssignment(pos, hasJSDoc, decorators, modifiers);
26904                         case 126:
26905                             return parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers);
26906                         default:
26907                             return parseExportDeclaration(pos, hasJSDoc, decorators, modifiers);
26908                     }
26909                 default:
26910                     if (decorators || modifiers) {
26911                         var missing = createMissingNode(271, true, ts.Diagnostics.Declaration_expected);
26912                         ts.setTextRangePos(missing, pos);
26913                         missing.decorators = decorators;
26914                         missing.modifiers = modifiers;
26915                         return missing;
26916                     }
26917                     return undefined;
26918             }
26919         }
26920         function nextTokenIsIdentifierOrStringLiteralOnSameLine() {
26921             nextToken();
26922             return !scanner.hasPrecedingLineBreak() && (isIdentifier() || token() === 10);
26923         }
26924         function parseFunctionBlockOrSemicolon(flags, diagnosticMessage) {
26925             if (token() !== 18 && canParseSemicolon()) {
26926                 parseSemicolon();
26927                 return;
26928             }
26929             return parseFunctionBlock(flags, diagnosticMessage);
26930         }
26931         function parseArrayBindingElement() {
26932             var pos = getNodePos();
26933             if (token() === 27) {
26934                 return finishNode(factory.createOmittedExpression(), pos);
26935             }
26936             var dotDotDotToken = parseOptionalToken(25);
26937             var name = parseIdentifierOrPattern();
26938             var initializer = parseInitializer();
26939             return finishNode(factory.createBindingElement(dotDotDotToken, undefined, name, initializer), pos);
26940         }
26941         function parseObjectBindingElement() {
26942             var pos = getNodePos();
26943             var dotDotDotToken = parseOptionalToken(25);
26944             var tokenIsIdentifier = isBindingIdentifier();
26945             var propertyName = parsePropertyName();
26946             var name;
26947             if (tokenIsIdentifier && token() !== 58) {
26948                 name = propertyName;
26949                 propertyName = undefined;
26950             }
26951             else {
26952                 parseExpected(58);
26953                 name = parseIdentifierOrPattern();
26954             }
26955             var initializer = parseInitializer();
26956             return finishNode(factory.createBindingElement(dotDotDotToken, propertyName, name, initializer), pos);
26957         }
26958         function parseObjectBindingPattern() {
26959             var pos = getNodePos();
26960             parseExpected(18);
26961             var elements = parseDelimitedList(9, parseObjectBindingElement);
26962             parseExpected(19);
26963             return finishNode(factory.createObjectBindingPattern(elements), pos);
26964         }
26965         function parseArrayBindingPattern() {
26966             var pos = getNodePos();
26967             parseExpected(22);
26968             var elements = parseDelimitedList(10, parseArrayBindingElement);
26969             parseExpected(23);
26970             return finishNode(factory.createArrayBindingPattern(elements), pos);
26971         }
26972         function isBindingIdentifierOrPrivateIdentifierOrPattern() {
26973             return token() === 18
26974                 || token() === 22
26975                 || token() === 79
26976                 || isBindingIdentifier();
26977         }
26978         function parseIdentifierOrPattern(privateIdentifierDiagnosticMessage) {
26979             if (token() === 22) {
26980                 return parseArrayBindingPattern();
26981             }
26982             if (token() === 18) {
26983                 return parseObjectBindingPattern();
26984             }
26985             return parseBindingIdentifier(privateIdentifierDiagnosticMessage);
26986         }
26987         function parseVariableDeclarationAllowExclamation() {
26988             return parseVariableDeclaration(true);
26989         }
26990         function parseVariableDeclaration(allowExclamation) {
26991             var pos = getNodePos();
26992             var name = parseIdentifierOrPattern(ts.Diagnostics.Private_identifiers_are_not_allowed_in_variable_declarations);
26993             var exclamationToken;
26994             if (allowExclamation && name.kind === 78 &&
26995                 token() === 53 && !scanner.hasPrecedingLineBreak()) {
26996                 exclamationToken = parseTokenNode();
26997             }
26998             var type = parseTypeAnnotation();
26999             var initializer = isInOrOfKeyword(token()) ? undefined : parseInitializer();
27000             var node = factory.createVariableDeclaration(name, exclamationToken, type, initializer);
27001             return finishNode(node, pos);
27002         }
27003         function parseVariableDeclarationList(inForStatementInitializer) {
27004             var pos = getNodePos();
27005             var flags = 0;
27006             switch (token()) {
27007                 case 112:
27008                     break;
27009                 case 118:
27010                     flags |= 1;
27011                     break;
27012                 case 84:
27013                     flags |= 2;
27014                     break;
27015                 default:
27016                     ts.Debug.fail();
27017             }
27018             nextToken();
27019             var declarations;
27020             if (token() === 156 && lookAhead(canFollowContextualOfKeyword)) {
27021                 declarations = createMissingList();
27022             }
27023             else {
27024                 var savedDisallowIn = inDisallowInContext();
27025                 setDisallowInContext(inForStatementInitializer);
27026                 declarations = parseDelimitedList(8, inForStatementInitializer ? parseVariableDeclaration : parseVariableDeclarationAllowExclamation);
27027                 setDisallowInContext(savedDisallowIn);
27028             }
27029             return finishNode(factory.createVariableDeclarationList(declarations, flags), pos);
27030         }
27031         function canFollowContextualOfKeyword() {
27032             return nextTokenIsIdentifier() && nextToken() === 21;
27033         }
27034         function parseVariableStatement(pos, hasJSDoc, decorators, modifiers) {
27035             var declarationList = parseVariableDeclarationList(false);
27036             parseSemicolon();
27037             var node = factory.createVariableStatement(modifiers, declarationList);
27038             node.decorators = decorators;
27039             return withJSDoc(finishNode(node, pos), hasJSDoc);
27040         }
27041         function parseFunctionDeclaration(pos, hasJSDoc, decorators, modifiers) {
27042             var savedAwaitContext = inAwaitContext();
27043             var modifierFlags = ts.modifiersToFlags(modifiers);
27044             parseExpected(97);
27045             var asteriskToken = parseOptionalToken(41);
27046             var name = modifierFlags & 512 ? parseOptionalBindingIdentifier() : parseBindingIdentifier();
27047             var isGenerator = asteriskToken ? 1 : 0;
27048             var isAsync = modifierFlags & 256 ? 2 : 0;
27049             var typeParameters = parseTypeParameters();
27050             if (modifierFlags & 1)
27051                 setAwaitContext(true);
27052             var parameters = parseParameters(isGenerator | isAsync);
27053             var type = parseReturnType(58, false);
27054             var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, ts.Diagnostics.or_expected);
27055             setAwaitContext(savedAwaitContext);
27056             var node = factory.createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body);
27057             return withJSDoc(finishNode(node, pos), hasJSDoc);
27058         }
27059         function parseConstructorName() {
27060             if (token() === 132) {
27061                 return parseExpected(132);
27062             }
27063             if (token() === 10 && lookAhead(nextToken) === 20) {
27064                 return tryParse(function () {
27065                     var literalNode = parseLiteralNode();
27066                     return literalNode.text === "constructor" ? literalNode : undefined;
27067                 });
27068             }
27069         }
27070         function tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers) {
27071             return tryParse(function () {
27072                 if (parseConstructorName()) {
27073                     var typeParameters = parseTypeParameters();
27074                     var parameters = parseParameters(0);
27075                     var type = parseReturnType(58, false);
27076                     var body = parseFunctionBlockOrSemicolon(0, ts.Diagnostics.or_expected);
27077                     var node = factory.createConstructorDeclaration(decorators, modifiers, parameters, body);
27078                     node.typeParameters = typeParameters;
27079                     node.type = type;
27080                     return withJSDoc(finishNode(node, pos), hasJSDoc);
27081                 }
27082             });
27083         }
27084         function parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, exclamationToken, diagnosticMessage) {
27085             var isGenerator = asteriskToken ? 1 : 0;
27086             var isAsync = ts.some(modifiers, ts.isAsyncModifier) ? 2 : 0;
27087             var typeParameters = parseTypeParameters();
27088             var parameters = parseParameters(isGenerator | isAsync);
27089             var type = parseReturnType(58, false);
27090             var body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage);
27091             var node = factory.createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body);
27092             node.exclamationToken = exclamationToken;
27093             return withJSDoc(finishNode(node, pos), hasJSDoc);
27094         }
27095         function parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken) {
27096             var exclamationToken = !questionToken && !scanner.hasPrecedingLineBreak() ? parseOptionalToken(53) : undefined;
27097             var type = parseTypeAnnotation();
27098             var initializer = doOutsideOfContext(8192 | 32768 | 4096, parseInitializer);
27099             parseSemicolon();
27100             var node = factory.createPropertyDeclaration(decorators, modifiers, name, questionToken || exclamationToken, type, initializer);
27101             return withJSDoc(finishNode(node, pos), hasJSDoc);
27102         }
27103         function parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers) {
27104             var asteriskToken = parseOptionalToken(41);
27105             var name = parsePropertyName();
27106             var questionToken = parseOptionalToken(57);
27107             if (asteriskToken || token() === 20 || token() === 29) {
27108                 return parseMethodDeclaration(pos, hasJSDoc, decorators, modifiers, asteriskToken, name, questionToken, undefined, ts.Diagnostics.or_expected);
27109             }
27110             return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, questionToken);
27111         }
27112         function parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, kind) {
27113             var name = parsePropertyName();
27114             var typeParameters = parseTypeParameters();
27115             var parameters = parseParameters(0);
27116             var type = parseReturnType(58, false);
27117             var body = parseFunctionBlockOrSemicolon(0);
27118             var node = kind === 167
27119                 ? factory.createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body)
27120                 : factory.createSetAccessorDeclaration(decorators, modifiers, name, parameters, body);
27121             node.typeParameters = typeParameters;
27122             if (type && node.kind === 168)
27123                 node.type = type;
27124             return withJSDoc(finishNode(node, pos), hasJSDoc);
27125         }
27126         function isClassMemberStart() {
27127             var idToken;
27128             if (token() === 59) {
27129                 return true;
27130             }
27131             while (ts.isModifierKind(token())) {
27132                 idToken = token();
27133                 if (ts.isClassMemberModifier(idToken)) {
27134                     return true;
27135                 }
27136                 nextToken();
27137             }
27138             if (token() === 41) {
27139                 return true;
27140             }
27141             if (isLiteralPropertyName()) {
27142                 idToken = token();
27143                 nextToken();
27144             }
27145             if (token() === 22) {
27146                 return true;
27147             }
27148             if (idToken !== undefined) {
27149                 if (!ts.isKeyword(idToken) || idToken === 146 || idToken === 134) {
27150                     return true;
27151                 }
27152                 switch (token()) {
27153                     case 20:
27154                     case 29:
27155                     case 53:
27156                     case 58:
27157                     case 62:
27158                     case 57:
27159                         return true;
27160                     default:
27161                         return canParseSemicolon();
27162                 }
27163             }
27164             return false;
27165         }
27166         function parseDecoratorExpression() {
27167             if (inAwaitContext() && token() === 130) {
27168                 var pos = getNodePos();
27169                 var awaitExpression = parseIdentifier(ts.Diagnostics.Expression_expected);
27170                 nextToken();
27171                 var memberExpression = parseMemberExpressionRest(pos, awaitExpression, true);
27172                 return parseCallExpressionRest(pos, memberExpression);
27173             }
27174             return parseLeftHandSideExpressionOrHigher();
27175         }
27176         function tryParseDecorator() {
27177             var pos = getNodePos();
27178             if (!parseOptional(59)) {
27179                 return undefined;
27180             }
27181             var expression = doInDecoratorContext(parseDecoratorExpression);
27182             return finishNode(factory.createDecorator(expression), pos);
27183         }
27184         function parseDecorators() {
27185             var pos = getNodePos();
27186             var list, decorator;
27187             while (decorator = tryParseDecorator()) {
27188                 list = ts.append(list, decorator);
27189             }
27190             return list && createNodeArray(list, pos);
27191         }
27192         function tryParseModifier(permitInvalidConstAsModifier) {
27193             var pos = getNodePos();
27194             var kind = token();
27195             if (token() === 84 && permitInvalidConstAsModifier) {
27196                 if (!tryParse(nextTokenIsOnSameLineAndCanFollowModifier)) {
27197                     return undefined;
27198                 }
27199             }
27200             else {
27201                 if (!parseAnyContextualModifier()) {
27202                     return undefined;
27203                 }
27204             }
27205             return finishNode(factory.createToken(kind), pos);
27206         }
27207         function parseModifiers(permitInvalidConstAsModifier) {
27208             var pos = getNodePos();
27209             var list, modifier;
27210             while (modifier = tryParseModifier(permitInvalidConstAsModifier)) {
27211                 list = ts.append(list, modifier);
27212             }
27213             return list && createNodeArray(list, pos);
27214         }
27215         function parseModifiersForArrowFunction() {
27216             var modifiers;
27217             if (token() === 129) {
27218                 var pos = getNodePos();
27219                 nextToken();
27220                 var modifier = finishNode(factory.createToken(129), pos);
27221                 modifiers = createNodeArray([modifier], pos);
27222             }
27223             return modifiers;
27224         }
27225         function parseClassElement() {
27226             var pos = getNodePos();
27227             if (token() === 26) {
27228                 nextToken();
27229                 return finishNode(factory.createSemicolonClassElement(), pos);
27230             }
27231             var hasJSDoc = hasPrecedingJSDocComment();
27232             var decorators = parseDecorators();
27233             var modifiers = parseModifiers(true);
27234             if (parseContextualModifier(134)) {
27235                 return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 167);
27236             }
27237             if (parseContextualModifier(146)) {
27238                 return parseAccessorDeclaration(pos, hasJSDoc, decorators, modifiers, 168);
27239             }
27240             if (token() === 132 || token() === 10) {
27241                 var constructorDeclaration = tryParseConstructorDeclaration(pos, hasJSDoc, decorators, modifiers);
27242                 if (constructorDeclaration) {
27243                     return constructorDeclaration;
27244                 }
27245             }
27246             if (isIndexSignature()) {
27247                 return parseIndexSignatureDeclaration(pos, hasJSDoc, decorators, modifiers);
27248             }
27249             if (ts.tokenIsIdentifierOrKeyword(token()) ||
27250                 token() === 10 ||
27251                 token() === 8 ||
27252                 token() === 41 ||
27253                 token() === 22) {
27254                 var isAmbient = ts.some(modifiers, isDeclareModifier);
27255                 if (isAmbient) {
27256                     for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
27257                         var m = _a[_i];
27258                         m.flags |= 8388608;
27259                     }
27260                     return doInsideOfContext(8388608, function () { return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers); });
27261                 }
27262                 else {
27263                     return parsePropertyOrMethodDeclaration(pos, hasJSDoc, decorators, modifiers);
27264                 }
27265             }
27266             if (decorators || modifiers) {
27267                 var name = createMissingNode(78, true, ts.Diagnostics.Declaration_expected);
27268                 return parsePropertyDeclaration(pos, hasJSDoc, decorators, modifiers, name, undefined);
27269             }
27270             return ts.Debug.fail("Should not have attempted to parse class member declaration.");
27271         }
27272         function parseClassExpression() {
27273             return parseClassDeclarationOrExpression(getNodePos(), hasPrecedingJSDocComment(), undefined, undefined, 221);
27274         }
27275         function parseClassDeclaration(pos, hasJSDoc, decorators, modifiers) {
27276             return parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, 252);
27277         }
27278         function parseClassDeclarationOrExpression(pos, hasJSDoc, decorators, modifiers, kind) {
27279             var savedAwaitContext = inAwaitContext();
27280             parseExpected(83);
27281             var name = parseNameOfClassDeclarationOrExpression();
27282             var typeParameters = parseTypeParameters();
27283             if (ts.some(modifiers, ts.isExportModifier))
27284                 setAwaitContext(true);
27285             var heritageClauses = parseHeritageClauses();
27286             var members;
27287             if (parseExpected(18)) {
27288                 members = parseClassMembers();
27289                 parseExpected(19);
27290             }
27291             else {
27292                 members = createMissingList();
27293             }
27294             setAwaitContext(savedAwaitContext);
27295             var node = kind === 252
27296                 ? factory.createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members)
27297                 : factory.createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members);
27298             return withJSDoc(finishNode(node, pos), hasJSDoc);
27299         }
27300         function parseNameOfClassDeclarationOrExpression() {
27301             return isBindingIdentifier() && !isImplementsClause()
27302                 ? createIdentifier(isBindingIdentifier())
27303                 : undefined;
27304         }
27305         function isImplementsClause() {
27306             return token() === 116 && lookAhead(nextTokenIsIdentifierOrKeyword);
27307         }
27308         function parseHeritageClauses() {
27309             if (isHeritageClause()) {
27310                 return parseList(22, parseHeritageClause);
27311             }
27312             return undefined;
27313         }
27314         function parseHeritageClause() {
27315             var pos = getNodePos();
27316             var tok = token();
27317             ts.Debug.assert(tok === 93 || tok === 116);
27318             nextToken();
27319             var types = parseDelimitedList(7, parseExpressionWithTypeArguments);
27320             return finishNode(factory.createHeritageClause(tok, types), pos);
27321         }
27322         function parseExpressionWithTypeArguments() {
27323             var pos = getNodePos();
27324             var expression = parseLeftHandSideExpressionOrHigher();
27325             var typeArguments = tryParseTypeArguments();
27326             return finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
27327         }
27328         function tryParseTypeArguments() {
27329             return token() === 29 ?
27330                 parseBracketedList(20, parseType, 29, 31) : undefined;
27331         }
27332         function isHeritageClause() {
27333             return token() === 93 || token() === 116;
27334         }
27335         function parseClassMembers() {
27336             return parseList(5, parseClassElement);
27337         }
27338         function parseInterfaceDeclaration(pos, hasJSDoc, decorators, modifiers) {
27339             parseExpected(117);
27340             var name = parseIdentifier();
27341             var typeParameters = parseTypeParameters();
27342             var heritageClauses = parseHeritageClauses();
27343             var members = parseObjectTypeMembers();
27344             var node = factory.createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members);
27345             return withJSDoc(finishNode(node, pos), hasJSDoc);
27346         }
27347         function parseTypeAliasDeclaration(pos, hasJSDoc, decorators, modifiers) {
27348             parseExpected(149);
27349             var name = parseIdentifier();
27350             var typeParameters = parseTypeParameters();
27351             parseExpected(62);
27352             var type = token() === 136 && tryParse(parseKeywordAndNoDot) || parseType();
27353             parseSemicolon();
27354             var node = factory.createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type);
27355             return withJSDoc(finishNode(node, pos), hasJSDoc);
27356         }
27357         function parseEnumMember() {
27358             var pos = getNodePos();
27359             var hasJSDoc = hasPrecedingJSDocComment();
27360             var name = parsePropertyName();
27361             var initializer = allowInAnd(parseInitializer);
27362             return withJSDoc(finishNode(factory.createEnumMember(name, initializer), pos), hasJSDoc);
27363         }
27364         function parseEnumDeclaration(pos, hasJSDoc, decorators, modifiers) {
27365             parseExpected(91);
27366             var name = parseIdentifier();
27367             var members;
27368             if (parseExpected(18)) {
27369                 members = doOutsideOfYieldAndAwaitContext(function () { return parseDelimitedList(6, parseEnumMember); });
27370                 parseExpected(19);
27371             }
27372             else {
27373                 members = createMissingList();
27374             }
27375             var node = factory.createEnumDeclaration(decorators, modifiers, name, members);
27376             return withJSDoc(finishNode(node, pos), hasJSDoc);
27377         }
27378         function parseModuleBlock() {
27379             var pos = getNodePos();
27380             var statements;
27381             if (parseExpected(18)) {
27382                 statements = parseList(1, parseStatement);
27383                 parseExpected(19);
27384             }
27385             else {
27386                 statements = createMissingList();
27387             }
27388             return finishNode(factory.createModuleBlock(statements), pos);
27389         }
27390         function parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags) {
27391             var namespaceFlag = flags & 16;
27392             var name = parseIdentifier();
27393             var body = parseOptional(24)
27394                 ? parseModuleOrNamespaceDeclaration(getNodePos(), false, undefined, undefined, 4 | namespaceFlag)
27395                 : parseModuleBlock();
27396             var node = factory.createModuleDeclaration(decorators, modifiers, name, body, flags);
27397             return withJSDoc(finishNode(node, pos), hasJSDoc);
27398         }
27399         function parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers) {
27400             var flags = 0;
27401             var name;
27402             if (token() === 154) {
27403                 name = parseIdentifier();
27404                 flags |= 1024;
27405             }
27406             else {
27407                 name = parseLiteralNode();
27408                 name.text = internIdentifier(name.text);
27409             }
27410             var body;
27411             if (token() === 18) {
27412                 body = parseModuleBlock();
27413             }
27414             else {
27415                 parseSemicolon();
27416             }
27417             var node = factory.createModuleDeclaration(decorators, modifiers, name, body, flags);
27418             return withJSDoc(finishNode(node, pos), hasJSDoc);
27419         }
27420         function parseModuleDeclaration(pos, hasJSDoc, decorators, modifiers) {
27421             var flags = 0;
27422             if (token() === 154) {
27423                 return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers);
27424             }
27425             else if (parseOptional(140)) {
27426                 flags |= 16;
27427             }
27428             else {
27429                 parseExpected(139);
27430                 if (token() === 10) {
27431                     return parseAmbientExternalModuleDeclaration(pos, hasJSDoc, decorators, modifiers);
27432                 }
27433             }
27434             return parseModuleOrNamespaceDeclaration(pos, hasJSDoc, decorators, modifiers, flags);
27435         }
27436         function isExternalModuleReference() {
27437             return token() === 143 &&
27438                 lookAhead(nextTokenIsOpenParen);
27439         }
27440         function nextTokenIsOpenParen() {
27441             return nextToken() === 20;
27442         }
27443         function nextTokenIsSlash() {
27444             return nextToken() === 43;
27445         }
27446         function parseNamespaceExportDeclaration(pos, hasJSDoc, decorators, modifiers) {
27447             parseExpected(126);
27448             parseExpected(140);
27449             var name = parseIdentifier();
27450             parseSemicolon();
27451             var node = factory.createNamespaceExportDeclaration(name);
27452             node.decorators = decorators;
27453             node.modifiers = modifiers;
27454             return withJSDoc(finishNode(node, pos), hasJSDoc);
27455         }
27456         function parseImportDeclarationOrImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers) {
27457             parseExpected(99);
27458             var afterImportPos = scanner.getStartPos();
27459             var identifier;
27460             if (isIdentifier()) {
27461                 identifier = parseIdentifier();
27462             }
27463             var isTypeOnly = false;
27464             if (token() !== 153 &&
27465                 (identifier === null || identifier === void 0 ? void 0 : identifier.escapedText) === "type" &&
27466                 (isIdentifier() || tokenAfterImportDefinitelyProducesImportDeclaration())) {
27467                 isTypeOnly = true;
27468                 identifier = isIdentifier() ? parseIdentifier() : undefined;
27469             }
27470             if (identifier && !tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration()) {
27471                 return parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly);
27472             }
27473             var importClause;
27474             if (identifier ||
27475                 token() === 41 ||
27476                 token() === 18) {
27477                 importClause = parseImportClause(identifier, afterImportPos, isTypeOnly);
27478                 parseExpected(153);
27479             }
27480             var moduleSpecifier = parseModuleSpecifier();
27481             parseSemicolon();
27482             var node = factory.createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier);
27483             return withJSDoc(finishNode(node, pos), hasJSDoc);
27484         }
27485         function tokenAfterImportDefinitelyProducesImportDeclaration() {
27486             return token() === 41 || token() === 18;
27487         }
27488         function tokenAfterImportedIdentifierDefinitelyProducesImportDeclaration() {
27489             return token() === 27 || token() === 153;
27490         }
27491         function parseImportEqualsDeclaration(pos, hasJSDoc, decorators, modifiers, identifier, isTypeOnly) {
27492             parseExpected(62);
27493             var moduleReference = parseModuleReference();
27494             parseSemicolon();
27495             var node = factory.createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, identifier, moduleReference);
27496             var finished = withJSDoc(finishNode(node, pos), hasJSDoc);
27497             return finished;
27498         }
27499         function parseImportClause(identifier, pos, isTypeOnly) {
27500             var namedBindings;
27501             if (!identifier ||
27502                 parseOptional(27)) {
27503                 namedBindings = token() === 41 ? parseNamespaceImport() : parseNamedImportsOrExports(264);
27504             }
27505             return finishNode(factory.createImportClause(isTypeOnly, identifier, namedBindings), pos);
27506         }
27507         function parseModuleReference() {
27508             return isExternalModuleReference()
27509                 ? parseExternalModuleReference()
27510                 : parseEntityName(false);
27511         }
27512         function parseExternalModuleReference() {
27513             var pos = getNodePos();
27514             parseExpected(143);
27515             parseExpected(20);
27516             var expression = parseModuleSpecifier();
27517             parseExpected(21);
27518             return finishNode(factory.createExternalModuleReference(expression), pos);
27519         }
27520         function parseModuleSpecifier() {
27521             if (token() === 10) {
27522                 var result = parseLiteralNode();
27523                 result.text = internIdentifier(result.text);
27524                 return result;
27525             }
27526             else {
27527                 return parseExpression();
27528             }
27529         }
27530         function parseNamespaceImport() {
27531             var pos = getNodePos();
27532             parseExpected(41);
27533             parseExpected(126);
27534             var name = parseIdentifier();
27535             return finishNode(factory.createNamespaceImport(name), pos);
27536         }
27537         function parseNamedImportsOrExports(kind) {
27538             var pos = getNodePos();
27539             var node = kind === 264
27540                 ? factory.createNamedImports(parseBracketedList(23, parseImportSpecifier, 18, 19))
27541                 : factory.createNamedExports(parseBracketedList(23, parseExportSpecifier, 18, 19));
27542             return finishNode(node, pos);
27543         }
27544         function parseExportSpecifier() {
27545             return parseImportOrExportSpecifier(270);
27546         }
27547         function parseImportSpecifier() {
27548             return parseImportOrExportSpecifier(265);
27549         }
27550         function parseImportOrExportSpecifier(kind) {
27551             var pos = getNodePos();
27552             var checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier();
27553             var checkIdentifierStart = scanner.getTokenPos();
27554             var checkIdentifierEnd = scanner.getTextPos();
27555             var identifierName = parseIdentifierName();
27556             var propertyName;
27557             var name;
27558             if (token() === 126) {
27559                 propertyName = identifierName;
27560                 parseExpected(126);
27561                 checkIdentifierIsKeyword = ts.isKeyword(token()) && !isIdentifier();
27562                 checkIdentifierStart = scanner.getTokenPos();
27563                 checkIdentifierEnd = scanner.getTextPos();
27564                 name = parseIdentifierName();
27565             }
27566             else {
27567                 name = identifierName;
27568             }
27569             if (kind === 265 && checkIdentifierIsKeyword) {
27570                 parseErrorAt(checkIdentifierStart, checkIdentifierEnd, ts.Diagnostics.Identifier_expected);
27571             }
27572             var node = kind === 265
27573                 ? factory.createImportSpecifier(propertyName, name)
27574                 : factory.createExportSpecifier(propertyName, name);
27575             return finishNode(node, pos);
27576         }
27577         function parseNamespaceExport(pos) {
27578             return finishNode(factory.createNamespaceExport(parseIdentifierName()), pos);
27579         }
27580         function parseExportDeclaration(pos, hasJSDoc, decorators, modifiers) {
27581             var savedAwaitContext = inAwaitContext();
27582             setAwaitContext(true);
27583             var exportClause;
27584             var moduleSpecifier;
27585             var isTypeOnly = parseOptional(149);
27586             var namespaceExportPos = getNodePos();
27587             if (parseOptional(41)) {
27588                 if (parseOptional(126)) {
27589                     exportClause = parseNamespaceExport(namespaceExportPos);
27590                 }
27591                 parseExpected(153);
27592                 moduleSpecifier = parseModuleSpecifier();
27593             }
27594             else {
27595                 exportClause = parseNamedImportsOrExports(268);
27596                 if (token() === 153 || (token() === 10 && !scanner.hasPrecedingLineBreak())) {
27597                     parseExpected(153);
27598                     moduleSpecifier = parseModuleSpecifier();
27599                 }
27600             }
27601             parseSemicolon();
27602             setAwaitContext(savedAwaitContext);
27603             var node = factory.createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier);
27604             return withJSDoc(finishNode(node, pos), hasJSDoc);
27605         }
27606         function parseExportAssignment(pos, hasJSDoc, decorators, modifiers) {
27607             var savedAwaitContext = inAwaitContext();
27608             setAwaitContext(true);
27609             var isExportEquals;
27610             if (parseOptional(62)) {
27611                 isExportEquals = true;
27612             }
27613             else {
27614                 parseExpected(87);
27615             }
27616             var expression = parseAssignmentExpressionOrHigher();
27617             parseSemicolon();
27618             setAwaitContext(savedAwaitContext);
27619             var node = factory.createExportAssignment(decorators, modifiers, isExportEquals, expression);
27620             return withJSDoc(finishNode(node, pos), hasJSDoc);
27621         }
27622         function setExternalModuleIndicator(sourceFile) {
27623             sourceFile.externalModuleIndicator =
27624                 ts.forEach(sourceFile.statements, isAnExternalModuleIndicatorNode) ||
27625                     getImportMetaIfNecessary(sourceFile);
27626         }
27627         function isAnExternalModuleIndicatorNode(node) {
27628             return hasModifierOfKind(node, 92)
27629                 || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference)
27630                 || ts.isImportDeclaration(node)
27631                 || ts.isExportAssignment(node)
27632                 || ts.isExportDeclaration(node) ? node : undefined;
27633         }
27634         function getImportMetaIfNecessary(sourceFile) {
27635             return sourceFile.flags & 2097152 ?
27636                 walkTreeForExternalModuleIndicators(sourceFile) :
27637                 undefined;
27638         }
27639         function walkTreeForExternalModuleIndicators(node) {
27640             return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators);
27641         }
27642         function hasModifierOfKind(node, kind) {
27643             return ts.some(node.modifiers, function (m) { return m.kind === kind; });
27644         }
27645         function isImportMeta(node) {
27646             return ts.isMetaProperty(node) && node.keywordToken === 99 && node.name.escapedText === "meta";
27647         }
27648         var JSDocParser;
27649         (function (JSDocParser) {
27650             function parseJSDocTypeExpressionForTests(content, start, length) {
27651                 initializeState("file.js", content, 99, undefined, 1);
27652                 scanner.setText(content, start, length);
27653                 currentToken = scanner.scan();
27654                 var jsDocTypeExpression = parseJSDocTypeExpression();
27655                 var sourceFile = createSourceFile("file.js", 99, 1, false, [], factory.createToken(1), 0);
27656                 var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
27657                 if (jsDocDiagnostics) {
27658                     sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile);
27659                 }
27660                 clearState();
27661                 return jsDocTypeExpression ? { jsDocTypeExpression: jsDocTypeExpression, diagnostics: diagnostics } : undefined;
27662             }
27663             JSDocParser.parseJSDocTypeExpressionForTests = parseJSDocTypeExpressionForTests;
27664             function parseJSDocTypeExpression(mayOmitBraces) {
27665                 var pos = getNodePos();
27666                 var hasBrace = (mayOmitBraces ? parseOptional : parseExpected)(18);
27667                 var type = doInsideOfContext(4194304, parseJSDocType);
27668                 if (!mayOmitBraces || hasBrace) {
27669                     parseExpectedJSDoc(19);
27670                 }
27671                 var result = factory.createJSDocTypeExpression(type);
27672                 fixupParentReferences(result);
27673                 return finishNode(result, pos);
27674             }
27675             JSDocParser.parseJSDocTypeExpression = parseJSDocTypeExpression;
27676             function parseJSDocNameReference() {
27677                 var pos = getNodePos();
27678                 var hasBrace = parseOptional(18);
27679                 var entityName = parseEntityName(false);
27680                 if (hasBrace) {
27681                     parseExpectedJSDoc(19);
27682                 }
27683                 var result = factory.createJSDocNameReference(entityName);
27684                 fixupParentReferences(result);
27685                 return finishNode(result, pos);
27686             }
27687             JSDocParser.parseJSDocNameReference = parseJSDocNameReference;
27688             function parseIsolatedJSDocComment(content, start, length) {
27689                 initializeState("", content, 99, undefined, 1);
27690                 var jsDoc = doInsideOfContext(4194304, function () { return parseJSDocCommentWorker(start, length); });
27691                 var sourceFile = { languageVariant: 0, text: content };
27692                 var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
27693                 clearState();
27694                 return jsDoc ? { jsDoc: jsDoc, diagnostics: diagnostics } : undefined;
27695             }
27696             JSDocParser.parseIsolatedJSDocComment = parseIsolatedJSDocComment;
27697             function parseJSDocComment(parent, start, length) {
27698                 var saveToken = currentToken;
27699                 var saveParseDiagnosticsLength = parseDiagnostics.length;
27700                 var saveParseErrorBeforeNextFinishedNode = parseErrorBeforeNextFinishedNode;
27701                 var comment = doInsideOfContext(4194304, function () { return parseJSDocCommentWorker(start, length); });
27702                 ts.setParent(comment, parent);
27703                 if (contextFlags & 131072) {
27704                     if (!jsDocDiagnostics) {
27705                         jsDocDiagnostics = [];
27706                     }
27707                     jsDocDiagnostics.push.apply(jsDocDiagnostics, parseDiagnostics);
27708                 }
27709                 currentToken = saveToken;
27710                 parseDiagnostics.length = saveParseDiagnosticsLength;
27711                 parseErrorBeforeNextFinishedNode = saveParseErrorBeforeNextFinishedNode;
27712                 return comment;
27713             }
27714             JSDocParser.parseJSDocComment = parseJSDocComment;
27715             function parseJSDocCommentWorker(start, length) {
27716                 if (start === void 0) { start = 0; }
27717                 var content = sourceText;
27718                 var end = length === undefined ? content.length : start + length;
27719                 length = end - start;
27720                 ts.Debug.assert(start >= 0);
27721                 ts.Debug.assert(start <= end);
27722                 ts.Debug.assert(end <= content.length);
27723                 if (!isJSDocLikeText(content, start)) {
27724                     return undefined;
27725                 }
27726                 var tags;
27727                 var tagsPos;
27728                 var tagsEnd;
27729                 var comments = [];
27730                 return scanner.scanRange(start + 3, length - 5, function () {
27731                     var state = 1;
27732                     var margin;
27733                     var indent = start - (content.lastIndexOf("\n", start) + 1) + 4;
27734                     function pushComment(text) {
27735                         if (!margin) {
27736                             margin = indent;
27737                         }
27738                         comments.push(text);
27739                         indent += text.length;
27740                     }
27741                     nextTokenJSDoc();
27742                     while (parseOptionalJsdoc(5))
27743                         ;
27744                     if (parseOptionalJsdoc(4)) {
27745                         state = 0;
27746                         indent = 0;
27747                     }
27748                     loop: while (true) {
27749                         switch (token()) {
27750                             case 59:
27751                                 if (state === 0 || state === 1) {
27752                                     removeTrailingWhitespace(comments);
27753                                     addTag(parseTag(indent));
27754                                     state = 0;
27755                                     margin = undefined;
27756                                 }
27757                                 else {
27758                                     pushComment(scanner.getTokenText());
27759                                 }
27760                                 break;
27761                             case 4:
27762                                 comments.push(scanner.getTokenText());
27763                                 state = 0;
27764                                 indent = 0;
27765                                 break;
27766                             case 41:
27767                                 var asterisk = scanner.getTokenText();
27768                                 if (state === 1 || state === 2) {
27769                                     state = 2;
27770                                     pushComment(asterisk);
27771                                 }
27772                                 else {
27773                                     state = 1;
27774                                     indent += asterisk.length;
27775                                 }
27776                                 break;
27777                             case 5:
27778                                 var whitespace = scanner.getTokenText();
27779                                 if (state === 2) {
27780                                     comments.push(whitespace);
27781                                 }
27782                                 else if (margin !== undefined && indent + whitespace.length > margin) {
27783                                     comments.push(whitespace.slice(margin - indent));
27784                                 }
27785                                 indent += whitespace.length;
27786                                 break;
27787                             case 1:
27788                                 break loop;
27789                             default:
27790                                 state = 2;
27791                                 pushComment(scanner.getTokenText());
27792                                 break;
27793                         }
27794                         nextTokenJSDoc();
27795                     }
27796                     removeLeadingNewlines(comments);
27797                     removeTrailingWhitespace(comments);
27798                     return createJSDocComment();
27799                 });
27800                 function removeLeadingNewlines(comments) {
27801                     while (comments.length && (comments[0] === "\n" || comments[0] === "\r")) {
27802                         comments.shift();
27803                     }
27804                 }
27805                 function removeTrailingWhitespace(comments) {
27806                     while (comments.length && comments[comments.length - 1].trim() === "") {
27807                         comments.pop();
27808                     }
27809                 }
27810                 function createJSDocComment() {
27811                     var comment = comments.length ? comments.join("") : undefined;
27812                     var tagsArray = tags && createNodeArray(tags, tagsPos, tagsEnd);
27813                     return finishNode(factory.createJSDocComment(comment, tagsArray), start, end);
27814                 }
27815                 function isNextNonwhitespaceTokenEndOfFile() {
27816                     while (true) {
27817                         nextTokenJSDoc();
27818                         if (token() === 1) {
27819                             return true;
27820                         }
27821                         if (!(token() === 5 || token() === 4)) {
27822                             return false;
27823                         }
27824                     }
27825                 }
27826                 function skipWhitespace() {
27827                     if (token() === 5 || token() === 4) {
27828                         if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
27829                             return;
27830                         }
27831                     }
27832                     while (token() === 5 || token() === 4) {
27833                         nextTokenJSDoc();
27834                     }
27835                 }
27836                 function skipWhitespaceOrAsterisk() {
27837                     if (token() === 5 || token() === 4) {
27838                         if (lookAhead(isNextNonwhitespaceTokenEndOfFile)) {
27839                             return "";
27840                         }
27841                     }
27842                     var precedingLineBreak = scanner.hasPrecedingLineBreak();
27843                     var seenLineBreak = false;
27844                     var indentText = "";
27845                     while ((precedingLineBreak && token() === 41) || token() === 5 || token() === 4) {
27846                         indentText += scanner.getTokenText();
27847                         if (token() === 4) {
27848                             precedingLineBreak = true;
27849                             seenLineBreak = true;
27850                             indentText = "";
27851                         }
27852                         else if (token() === 41) {
27853                             precedingLineBreak = false;
27854                         }
27855                         nextTokenJSDoc();
27856                     }
27857                     return seenLineBreak ? indentText : "";
27858                 }
27859                 function parseTag(margin) {
27860                     ts.Debug.assert(token() === 59);
27861                     var start = scanner.getTokenPos();
27862                     nextTokenJSDoc();
27863                     var tagName = parseJSDocIdentifierName(undefined);
27864                     var indentText = skipWhitespaceOrAsterisk();
27865                     var tag;
27866                     switch (tagName.escapedText) {
27867                         case "author":
27868                             tag = parseAuthorTag(start, tagName, margin, indentText);
27869                             break;
27870                         case "implements":
27871                             tag = parseImplementsTag(start, tagName, margin, indentText);
27872                             break;
27873                         case "augments":
27874                         case "extends":
27875                             tag = parseAugmentsTag(start, tagName, margin, indentText);
27876                             break;
27877                         case "class":
27878                         case "constructor":
27879                             tag = parseSimpleTag(start, factory.createJSDocClassTag, tagName, margin, indentText);
27880                             break;
27881                         case "public":
27882                             tag = parseSimpleTag(start, factory.createJSDocPublicTag, tagName, margin, indentText);
27883                             break;
27884                         case "private":
27885                             tag = parseSimpleTag(start, factory.createJSDocPrivateTag, tagName, margin, indentText);
27886                             break;
27887                         case "protected":
27888                             tag = parseSimpleTag(start, factory.createJSDocProtectedTag, tagName, margin, indentText);
27889                             break;
27890                         case "readonly":
27891                             tag = parseSimpleTag(start, factory.createJSDocReadonlyTag, tagName, margin, indentText);
27892                             break;
27893                         case "deprecated":
27894                             hasDeprecatedTag = true;
27895                             tag = parseSimpleTag(start, factory.createJSDocDeprecatedTag, tagName, margin, indentText);
27896                             break;
27897                         case "this":
27898                             tag = parseThisTag(start, tagName, margin, indentText);
27899                             break;
27900                         case "enum":
27901                             tag = parseEnumTag(start, tagName, margin, indentText);
27902                             break;
27903                         case "arg":
27904                         case "argument":
27905                         case "param":
27906                             return parseParameterOrPropertyTag(start, tagName, 2, margin);
27907                         case "return":
27908                         case "returns":
27909                             tag = parseReturnTag(start, tagName, margin, indentText);
27910                             break;
27911                         case "template":
27912                             tag = parseTemplateTag(start, tagName, margin, indentText);
27913                             break;
27914                         case "type":
27915                             tag = parseTypeTag(start, tagName, margin, indentText);
27916                             break;
27917                         case "typedef":
27918                             tag = parseTypedefTag(start, tagName, margin, indentText);
27919                             break;
27920                         case "callback":
27921                             tag = parseCallbackTag(start, tagName, margin, indentText);
27922                             break;
27923                         case "see":
27924                             tag = parseSeeTag(start, tagName, margin, indentText);
27925                             break;
27926                         default:
27927                             tag = parseUnknownTag(start, tagName, margin, indentText);
27928                             break;
27929                     }
27930                     return tag;
27931                 }
27932                 function parseTrailingTagComments(pos, end, margin, indentText) {
27933                     if (!indentText) {
27934                         margin += end - pos;
27935                     }
27936                     return parseTagComments(margin, indentText.slice(margin));
27937                 }
27938                 function parseTagComments(indent, initialMargin) {
27939                     var comments = [];
27940                     var state = 0;
27941                     var previousWhitespace = true;
27942                     var margin;
27943                     function pushComment(text) {
27944                         if (!margin) {
27945                             margin = indent;
27946                         }
27947                         comments.push(text);
27948                         indent += text.length;
27949                     }
27950                     if (initialMargin !== undefined) {
27951                         if (initialMargin !== "") {
27952                             pushComment(initialMargin);
27953                         }
27954                         state = 1;
27955                     }
27956                     var tok = token();
27957                     loop: while (true) {
27958                         switch (tok) {
27959                             case 4:
27960                                 state = 0;
27961                                 comments.push(scanner.getTokenText());
27962                                 indent = 0;
27963                                 break;
27964                             case 59:
27965                                 if (state === 3 || !previousWhitespace && state === 2) {
27966                                     comments.push(scanner.getTokenText());
27967                                     break;
27968                                 }
27969                                 scanner.setTextPos(scanner.getTextPos() - 1);
27970                             case 1:
27971                                 break loop;
27972                             case 5:
27973                                 if (state === 2 || state === 3) {
27974                                     pushComment(scanner.getTokenText());
27975                                 }
27976                                 else {
27977                                     var whitespace = scanner.getTokenText();
27978                                     if (margin !== undefined && indent + whitespace.length > margin) {
27979                                         comments.push(whitespace.slice(margin - indent));
27980                                     }
27981                                     indent += whitespace.length;
27982                                 }
27983                                 break;
27984                             case 18:
27985                                 state = 2;
27986                                 if (lookAhead(function () { return nextTokenJSDoc() === 59 && ts.tokenIsIdentifierOrKeyword(nextTokenJSDoc()) && scanner.getTokenText() === "link"; })) {
27987                                     pushComment(scanner.getTokenText());
27988                                     nextTokenJSDoc();
27989                                     pushComment(scanner.getTokenText());
27990                                     nextTokenJSDoc();
27991                                 }
27992                                 pushComment(scanner.getTokenText());
27993                                 break;
27994                             case 61:
27995                                 if (state === 3) {
27996                                     state = 2;
27997                                 }
27998                                 else {
27999                                     state = 3;
28000                                 }
28001                                 pushComment(scanner.getTokenText());
28002                                 break;
28003                             case 41:
28004                                 if (state === 0) {
28005                                     state = 1;
28006                                     indent += 1;
28007                                     break;
28008                                 }
28009                             default:
28010                                 if (state !== 3) {
28011                                     state = 2;
28012                                 }
28013                                 pushComment(scanner.getTokenText());
28014                                 break;
28015                         }
28016                         previousWhitespace = token() === 5;
28017                         tok = nextTokenJSDoc();
28018                     }
28019                     removeLeadingNewlines(comments);
28020                     removeTrailingWhitespace(comments);
28021                     return comments.length === 0 ? undefined : comments.join("");
28022                 }
28023                 function parseUnknownTag(start, tagName, indent, indentText) {
28024                     var end = getNodePos();
28025                     return finishNode(factory.createJSDocUnknownTag(tagName, parseTrailingTagComments(start, end, indent, indentText)), start, end);
28026                 }
28027                 function addTag(tag) {
28028                     if (!tag) {
28029                         return;
28030                     }
28031                     if (!tags) {
28032                         tags = [tag];
28033                         tagsPos = tag.pos;
28034                     }
28035                     else {
28036                         tags.push(tag);
28037                     }
28038                     tagsEnd = tag.end;
28039                 }
28040                 function tryParseTypeExpression() {
28041                     skipWhitespaceOrAsterisk();
28042                     return token() === 18 ? parseJSDocTypeExpression() : undefined;
28043                 }
28044                 function parseBracketNameInPropertyAndParamTag() {
28045                     var isBracketed = parseOptionalJsdoc(22);
28046                     if (isBracketed) {
28047                         skipWhitespace();
28048                     }
28049                     var isBackquoted = parseOptionalJsdoc(61);
28050                     var name = parseJSDocEntityName();
28051                     if (isBackquoted) {
28052                         parseExpectedTokenJSDoc(61);
28053                     }
28054                     if (isBracketed) {
28055                         skipWhitespace();
28056                         if (parseOptionalToken(62)) {
28057                             parseExpression();
28058                         }
28059                         parseExpected(23);
28060                     }
28061                     return { name: name, isBracketed: isBracketed };
28062                 }
28063                 function isObjectOrObjectArrayTypeReference(node) {
28064                     switch (node.kind) {
28065                         case 145:
28066                             return true;
28067                         case 178:
28068                             return isObjectOrObjectArrayTypeReference(node.elementType);
28069                         default:
28070                             return ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "Object" && !node.typeArguments;
28071                     }
28072                 }
28073                 function parseParameterOrPropertyTag(start, tagName, target, indent) {
28074                     var typeExpression = tryParseTypeExpression();
28075                     var isNameFirst = !typeExpression;
28076                     skipWhitespaceOrAsterisk();
28077                     var _a = parseBracketNameInPropertyAndParamTag(), name = _a.name, isBracketed = _a.isBracketed;
28078                     var indentText = skipWhitespaceOrAsterisk();
28079                     if (isNameFirst) {
28080                         typeExpression = tryParseTypeExpression();
28081                     }
28082                     var comment = parseTrailingTagComments(start, getNodePos(), indent, indentText);
28083                     var nestedTypeLiteral = target !== 4 && parseNestedTypeLiteral(typeExpression, name, target, indent);
28084                     if (nestedTypeLiteral) {
28085                         typeExpression = nestedTypeLiteral;
28086                         isNameFirst = true;
28087                     }
28088                     var result = target === 1
28089                         ? factory.createJSDocPropertyTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment)
28090                         : factory.createJSDocParameterTag(tagName, name, isBracketed, typeExpression, isNameFirst, comment);
28091                     return finishNode(result, start);
28092                 }
28093                 function parseNestedTypeLiteral(typeExpression, name, target, indent) {
28094                     if (typeExpression && isObjectOrObjectArrayTypeReference(typeExpression.type)) {
28095                         var pos = getNodePos();
28096                         var child = void 0;
28097                         var children = void 0;
28098                         while (child = tryParse(function () { return parseChildParameterOrPropertyTag(target, indent, name); })) {
28099                             if (child.kind === 326 || child.kind === 333) {
28100                                 children = ts.append(children, child);
28101                             }
28102                         }
28103                         if (children) {
28104                             var literal = finishNode(factory.createJSDocTypeLiteral(children, typeExpression.type.kind === 178), pos);
28105                             return finishNode(factory.createJSDocTypeExpression(literal), pos);
28106                         }
28107                     }
28108                 }
28109                 function parseReturnTag(start, tagName, indent, indentText) {
28110                     if (ts.some(tags, ts.isJSDocReturnTag)) {
28111                         parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
28112                     }
28113                     var typeExpression = tryParseTypeExpression();
28114                     var end = getNodePos();
28115                     return finishNode(factory.createJSDocReturnTag(tagName, typeExpression, parseTrailingTagComments(start, end, indent, indentText)), start, end);
28116                 }
28117                 function parseTypeTag(start, tagName, indent, indentText) {
28118                     if (ts.some(tags, ts.isJSDocTypeTag)) {
28119                         parseErrorAt(tagName.pos, scanner.getTokenPos(), ts.Diagnostics._0_tag_already_specified, tagName.escapedText);
28120                     }
28121                     var typeExpression = parseJSDocTypeExpression(true);
28122                     var end = getNodePos();
28123                     var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, end, indent, indentText) : undefined;
28124                     return finishNode(factory.createJSDocTypeTag(tagName, typeExpression, comments), start, end);
28125                 }
28126                 function parseSeeTag(start, tagName, indent, indentText) {
28127                     var nameExpression = parseJSDocNameReference();
28128                     var end = getNodePos();
28129                     var comments = indent !== undefined && indentText !== undefined ? parseTrailingTagComments(start, end, indent, indentText) : undefined;
28130                     return finishNode(factory.createJSDocSeeTag(tagName, nameExpression, comments), start, end);
28131                 }
28132                 function parseAuthorTag(start, tagName, indent, indentText) {
28133                     var comments = parseAuthorNameAndEmail() + (parseTrailingTagComments(start, end, indent, indentText) || "");
28134                     return finishNode(factory.createJSDocAuthorTag(tagName, comments || undefined), start);
28135                 }
28136                 function parseAuthorNameAndEmail() {
28137                     var comments = [];
28138                     var inEmail = false;
28139                     var token = scanner.getToken();
28140                     while (token !== 1 && token !== 4) {
28141                         if (token === 29) {
28142                             inEmail = true;
28143                         }
28144                         else if (token === 59 && !inEmail) {
28145                             break;
28146                         }
28147                         else if (token === 31 && inEmail) {
28148                             comments.push(scanner.getTokenText());
28149                             scanner.setTextPos(scanner.getTokenPos() + 1);
28150                             break;
28151                         }
28152                         comments.push(scanner.getTokenText());
28153                         token = nextTokenJSDoc();
28154                     }
28155                     return comments.join("");
28156                 }
28157                 function parseImplementsTag(start, tagName, margin, indentText) {
28158                     var className = parseExpressionWithTypeArgumentsForAugments();
28159                     var end = getNodePos();
28160                     return finishNode(factory.createJSDocImplementsTag(tagName, className, parseTrailingTagComments(start, end, margin, indentText)), start, end);
28161                 }
28162                 function parseAugmentsTag(start, tagName, margin, indentText) {
28163                     var className = parseExpressionWithTypeArgumentsForAugments();
28164                     var end = getNodePos();
28165                     return finishNode(factory.createJSDocAugmentsTag(tagName, className, parseTrailingTagComments(start, end, margin, indentText)), start, end);
28166                 }
28167                 function parseExpressionWithTypeArgumentsForAugments() {
28168                     var usedBrace = parseOptional(18);
28169                     var pos = getNodePos();
28170                     var expression = parsePropertyAccessEntityNameExpression();
28171                     var typeArguments = tryParseTypeArguments();
28172                     var node = factory.createExpressionWithTypeArguments(expression, typeArguments);
28173                     var res = finishNode(node, pos);
28174                     if (usedBrace) {
28175                         parseExpected(19);
28176                     }
28177                     return res;
28178                 }
28179                 function parsePropertyAccessEntityNameExpression() {
28180                     var pos = getNodePos();
28181                     var node = parseJSDocIdentifierName();
28182                     while (parseOptional(24)) {
28183                         var name = parseJSDocIdentifierName();
28184                         node = finishNode(factory.createPropertyAccessExpression(node, name), pos);
28185                     }
28186                     return node;
28187                 }
28188                 function parseSimpleTag(start, createTag, tagName, margin, indentText) {
28189                     var end = getNodePos();
28190                     return finishNode(createTag(tagName, parseTrailingTagComments(start, end, margin, indentText)), start, end);
28191                 }
28192                 function parseThisTag(start, tagName, margin, indentText) {
28193                     var typeExpression = parseJSDocTypeExpression(true);
28194                     skipWhitespace();
28195                     var end = getNodePos();
28196                     return finishNode(factory.createJSDocThisTag(tagName, typeExpression, parseTrailingTagComments(start, end, margin, indentText)), start, end);
28197                 }
28198                 function parseEnumTag(start, tagName, margin, indentText) {
28199                     var typeExpression = parseJSDocTypeExpression(true);
28200                     skipWhitespace();
28201                     var end = getNodePos();
28202                     return finishNode(factory.createJSDocEnumTag(tagName, typeExpression, parseTrailingTagComments(start, end, margin, indentText)), start, end);
28203                 }
28204                 function parseTypedefTag(start, tagName, indent, indentText) {
28205                     var _a;
28206                     var typeExpression = tryParseTypeExpression();
28207                     skipWhitespaceOrAsterisk();
28208                     var fullName = parseJSDocTypeNameWithNamespace();
28209                     skipWhitespace();
28210                     var comment = parseTagComments(indent);
28211                     var end;
28212                     if (!typeExpression || isObjectOrObjectArrayTypeReference(typeExpression.type)) {
28213                         var child = void 0;
28214                         var childTypeTag = void 0;
28215                         var jsDocPropertyTags = void 0;
28216                         var hasChildren = false;
28217                         while (child = tryParse(function () { return parseChildPropertyTag(indent); })) {
28218                             hasChildren = true;
28219                             if (child.kind === 329) {
28220                                 if (childTypeTag) {
28221                                     parseErrorAtCurrentToken(ts.Diagnostics.A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags);
28222                                     var lastError = ts.lastOrUndefined(parseDiagnostics);
28223                                     if (lastError) {
28224                                         ts.addRelatedInfo(lastError, ts.createDetachedDiagnostic(fileName, 0, 0, ts.Diagnostics.The_tag_was_first_specified_here));
28225                                     }
28226                                     break;
28227                                 }
28228                                 else {
28229                                     childTypeTag = child;
28230                                 }
28231                             }
28232                             else {
28233                                 jsDocPropertyTags = ts.append(jsDocPropertyTags, child);
28234                             }
28235                         }
28236                         if (hasChildren) {
28237                             var isArrayType = typeExpression && typeExpression.type.kind === 178;
28238                             var jsdocTypeLiteral = factory.createJSDocTypeLiteral(jsDocPropertyTags, isArrayType);
28239                             typeExpression = childTypeTag && childTypeTag.typeExpression && !isObjectOrObjectArrayTypeReference(childTypeTag.typeExpression.type) ?
28240                                 childTypeTag.typeExpression :
28241                                 finishNode(jsdocTypeLiteral, start);
28242                             end = typeExpression.end;
28243                         }
28244                     }
28245                     end = end || comment !== undefined ?
28246                         getNodePos() :
28247                         ((_a = fullName !== null && fullName !== void 0 ? fullName : typeExpression) !== null && _a !== void 0 ? _a : tagName).end;
28248                     if (!comment) {
28249                         comment = parseTrailingTagComments(start, end, indent, indentText);
28250                     }
28251                     var typedefTag = factory.createJSDocTypedefTag(tagName, typeExpression, fullName, comment);
28252                     return finishNode(typedefTag, start, end);
28253                 }
28254                 function parseJSDocTypeNameWithNamespace(nested) {
28255                     var pos = scanner.getTokenPos();
28256                     if (!ts.tokenIsIdentifierOrKeyword(token())) {
28257                         return undefined;
28258                     }
28259                     var typeNameOrNamespaceName = parseJSDocIdentifierName();
28260                     if (parseOptional(24)) {
28261                         var body = parseJSDocTypeNameWithNamespace(true);
28262                         var jsDocNamespaceNode = factory.createModuleDeclaration(undefined, undefined, typeNameOrNamespaceName, body, nested ? 4 : undefined);
28263                         return finishNode(jsDocNamespaceNode, pos);
28264                     }
28265                     if (nested) {
28266                         typeNameOrNamespaceName.isInJSDocNamespace = true;
28267                     }
28268                     return typeNameOrNamespaceName;
28269                 }
28270                 function parseCallbackTagParameters(indent) {
28271                     var pos = getNodePos();
28272                     var child;
28273                     var parameters;
28274                     while (child = tryParse(function () { return parseChildParameterOrPropertyTag(4, indent); })) {
28275                         parameters = ts.append(parameters, child);
28276                     }
28277                     return createNodeArray(parameters || [], pos);
28278                 }
28279                 function parseCallbackTag(start, tagName, indent, indentText) {
28280                     var fullName = parseJSDocTypeNameWithNamespace();
28281                     skipWhitespace();
28282                     var comment = parseTagComments(indent);
28283                     var parameters = parseCallbackTagParameters(indent);
28284                     var returnTag = tryParse(function () {
28285                         if (parseOptionalJsdoc(59)) {
28286                             var tag = parseTag(indent);
28287                             if (tag && tag.kind === 327) {
28288                                 return tag;
28289                             }
28290                         }
28291                     });
28292                     var typeExpression = finishNode(factory.createJSDocSignature(undefined, parameters, returnTag), start);
28293                     var end = getNodePos();
28294                     if (!comment) {
28295                         comment = parseTrailingTagComments(start, end, indent, indentText);
28296                     }
28297                     return finishNode(factory.createJSDocCallbackTag(tagName, typeExpression, fullName, comment), start, end);
28298                 }
28299                 function escapedTextsEqual(a, b) {
28300                     while (!ts.isIdentifier(a) || !ts.isIdentifier(b)) {
28301                         if (!ts.isIdentifier(a) && !ts.isIdentifier(b) && a.right.escapedText === b.right.escapedText) {
28302                             a = a.left;
28303                             b = b.left;
28304                         }
28305                         else {
28306                             return false;
28307                         }
28308                     }
28309                     return a.escapedText === b.escapedText;
28310                 }
28311                 function parseChildPropertyTag(indent) {
28312                     return parseChildParameterOrPropertyTag(1, indent);
28313                 }
28314                 function parseChildParameterOrPropertyTag(target, indent, name) {
28315                     var canParseTag = true;
28316                     var seenAsterisk = false;
28317                     while (true) {
28318                         switch (nextTokenJSDoc()) {
28319                             case 59:
28320                                 if (canParseTag) {
28321                                     var child = tryParseChildTag(target, indent);
28322                                     if (child && (child.kind === 326 || child.kind === 333) &&
28323                                         target !== 4 &&
28324                                         name && (ts.isIdentifier(child.name) || !escapedTextsEqual(name, child.name.left))) {
28325                                         return false;
28326                                     }
28327                                     return child;
28328                                 }
28329                                 seenAsterisk = false;
28330                                 break;
28331                             case 4:
28332                                 canParseTag = true;
28333                                 seenAsterisk = false;
28334                                 break;
28335                             case 41:
28336                                 if (seenAsterisk) {
28337                                     canParseTag = false;
28338                                 }
28339                                 seenAsterisk = true;
28340                                 break;
28341                             case 78:
28342                                 canParseTag = false;
28343                                 break;
28344                             case 1:
28345                                 return false;
28346                         }
28347                     }
28348                 }
28349                 function tryParseChildTag(target, indent) {
28350                     ts.Debug.assert(token() === 59);
28351                     var start = scanner.getStartPos();
28352                     nextTokenJSDoc();
28353                     var tagName = parseJSDocIdentifierName();
28354                     skipWhitespace();
28355                     var t;
28356                     switch (tagName.escapedText) {
28357                         case "type":
28358                             return target === 1 && parseTypeTag(start, tagName);
28359                         case "prop":
28360                         case "property":
28361                             t = 1;
28362                             break;
28363                         case "arg":
28364                         case "argument":
28365                         case "param":
28366                             t = 2 | 4;
28367                             break;
28368                         default:
28369                             return false;
28370                     }
28371                     if (!(target & t)) {
28372                         return false;
28373                     }
28374                     return parseParameterOrPropertyTag(start, tagName, target, indent);
28375                 }
28376                 function parseTemplateTagTypeParameter() {
28377                     var typeParameterPos = getNodePos();
28378                     var name = parseJSDocIdentifierName(ts.Diagnostics.Unexpected_token_A_type_parameter_name_was_expected_without_curly_braces);
28379                     return finishNode(factory.createTypeParameterDeclaration(name, undefined, undefined), typeParameterPos);
28380                 }
28381                 function parseTemplateTagTypeParameters() {
28382                     var pos = getNodePos();
28383                     var typeParameters = [];
28384                     do {
28385                         skipWhitespace();
28386                         typeParameters.push(parseTemplateTagTypeParameter());
28387                         skipWhitespaceOrAsterisk();
28388                     } while (parseOptionalJsdoc(27));
28389                     return createNodeArray(typeParameters, pos);
28390                 }
28391                 function parseTemplateTag(start, tagName, indent, indentText) {
28392                     var constraint = token() === 18 ? parseJSDocTypeExpression() : undefined;
28393                     var typeParameters = parseTemplateTagTypeParameters();
28394                     var end = getNodePos();
28395                     return finishNode(factory.createJSDocTemplateTag(tagName, constraint, typeParameters, parseTrailingTagComments(start, end, indent, indentText)), start, end);
28396                 }
28397                 function parseOptionalJsdoc(t) {
28398                     if (token() === t) {
28399                         nextTokenJSDoc();
28400                         return true;
28401                     }
28402                     return false;
28403                 }
28404                 function parseJSDocEntityName() {
28405                     var entity = parseJSDocIdentifierName();
28406                     if (parseOptional(22)) {
28407                         parseExpected(23);
28408                     }
28409                     while (parseOptional(24)) {
28410                         var name = parseJSDocIdentifierName();
28411                         if (parseOptional(22)) {
28412                             parseExpected(23);
28413                         }
28414                         entity = createQualifiedName(entity, name);
28415                     }
28416                     return entity;
28417                 }
28418                 function parseJSDocIdentifierName(message) {
28419                     if (!ts.tokenIsIdentifierOrKeyword(token())) {
28420                         return createMissingNode(78, !message, message || ts.Diagnostics.Identifier_expected);
28421                     }
28422                     identifierCount++;
28423                     var pos = scanner.getTokenPos();
28424                     var end = scanner.getTextPos();
28425                     var originalKeywordKind = token();
28426                     var text = internIdentifier(scanner.getTokenValue());
28427                     var result = finishNode(factory.createIdentifier(text, undefined, originalKeywordKind), pos, end);
28428                     nextTokenJSDoc();
28429                     return result;
28430                 }
28431             }
28432         })(JSDocParser = Parser.JSDocParser || (Parser.JSDocParser = {}));
28433     })(Parser || (Parser = {}));
28434     var IncrementalParser;
28435     (function (IncrementalParser) {
28436         function updateSourceFile(sourceFile, newText, textChangeRange, aggressiveChecks) {
28437             aggressiveChecks = aggressiveChecks || ts.Debug.shouldAssert(2);
28438             checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks);
28439             if (ts.textChangeRangeIsUnchanged(textChangeRange)) {
28440                 return sourceFile;
28441             }
28442             if (sourceFile.statements.length === 0) {
28443                 return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, undefined, true, sourceFile.scriptKind);
28444             }
28445             var incrementalSourceFile = sourceFile;
28446             ts.Debug.assert(!incrementalSourceFile.hasBeenIncrementallyParsed);
28447             incrementalSourceFile.hasBeenIncrementallyParsed = true;
28448             Parser.fixupParentReferences(incrementalSourceFile);
28449             var oldText = sourceFile.text;
28450             var syntaxCursor = createSyntaxCursor(sourceFile);
28451             var changeRange = extendToAffectedRange(sourceFile, textChangeRange);
28452             checkChangeRange(sourceFile, newText, changeRange, aggressiveChecks);
28453             ts.Debug.assert(changeRange.span.start <= textChangeRange.span.start);
28454             ts.Debug.assert(ts.textSpanEnd(changeRange.span) === ts.textSpanEnd(textChangeRange.span));
28455             ts.Debug.assert(ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)) === ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)));
28456             var delta = ts.textChangeRangeNewSpan(changeRange).length - changeRange.span.length;
28457             updateTokenPositionsAndMarkElements(incrementalSourceFile, changeRange.span.start, ts.textSpanEnd(changeRange.span), ts.textSpanEnd(ts.textChangeRangeNewSpan(changeRange)), delta, oldText, newText, aggressiveChecks);
28458             var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, true, sourceFile.scriptKind);
28459             result.commentDirectives = getNewCommentDirectives(sourceFile.commentDirectives, result.commentDirectives, changeRange.span.start, ts.textSpanEnd(changeRange.span), delta, oldText, newText, aggressiveChecks);
28460             return result;
28461         }
28462         IncrementalParser.updateSourceFile = updateSourceFile;
28463         function getNewCommentDirectives(oldDirectives, newDirectives, changeStart, changeRangeOldEnd, delta, oldText, newText, aggressiveChecks) {
28464             if (!oldDirectives)
28465                 return newDirectives;
28466             var commentDirectives;
28467             var addedNewlyScannedDirectives = false;
28468             for (var _i = 0, oldDirectives_1 = oldDirectives; _i < oldDirectives_1.length; _i++) {
28469                 var directive = oldDirectives_1[_i];
28470                 var range = directive.range, type = directive.type;
28471                 if (range.end < changeStart) {
28472                     commentDirectives = ts.append(commentDirectives, directive);
28473                 }
28474                 else if (range.pos > changeRangeOldEnd) {
28475                     addNewlyScannedDirectives();
28476                     var updatedDirective = {
28477                         range: { pos: range.pos + delta, end: range.end + delta },
28478                         type: type
28479                     };
28480                     commentDirectives = ts.append(commentDirectives, updatedDirective);
28481                     if (aggressiveChecks) {
28482                         ts.Debug.assert(oldText.substring(range.pos, range.end) === newText.substring(updatedDirective.range.pos, updatedDirective.range.end));
28483                     }
28484                 }
28485             }
28486             addNewlyScannedDirectives();
28487             return commentDirectives;
28488             function addNewlyScannedDirectives() {
28489                 if (addedNewlyScannedDirectives)
28490                     return;
28491                 addedNewlyScannedDirectives = true;
28492                 if (!commentDirectives) {
28493                     commentDirectives = newDirectives;
28494                 }
28495                 else if (newDirectives) {
28496                     commentDirectives.push.apply(commentDirectives, newDirectives);
28497                 }
28498             }
28499         }
28500         function moveElementEntirelyPastChangeRange(element, isArray, delta, oldText, newText, aggressiveChecks) {
28501             if (isArray) {
28502                 visitArray(element);
28503             }
28504             else {
28505                 visitNode(element);
28506             }
28507             return;
28508             function visitNode(node) {
28509                 var text = "";
28510                 if (aggressiveChecks && shouldCheckNode(node)) {
28511                     text = oldText.substring(node.pos, node.end);
28512                 }
28513                 if (node._children) {
28514                     node._children = undefined;
28515                 }
28516                 ts.setTextRangePosEnd(node, node.pos + delta, node.end + delta);
28517                 if (aggressiveChecks && shouldCheckNode(node)) {
28518                     ts.Debug.assert(text === newText.substring(node.pos, node.end));
28519                 }
28520                 forEachChild(node, visitNode, visitArray);
28521                 if (ts.hasJSDocNodes(node)) {
28522                     for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
28523                         var jsDocComment = _a[_i];
28524                         visitNode(jsDocComment);
28525                     }
28526                 }
28527                 checkNodePositions(node, aggressiveChecks);
28528             }
28529             function visitArray(array) {
28530                 array._children = undefined;
28531                 ts.setTextRangePosEnd(array, array.pos + delta, array.end + delta);
28532                 for (var _i = 0, array_8 = array; _i < array_8.length; _i++) {
28533                     var node = array_8[_i];
28534                     visitNode(node);
28535                 }
28536             }
28537         }
28538         function shouldCheckNode(node) {
28539             switch (node.kind) {
28540                 case 10:
28541                 case 8:
28542                 case 78:
28543                     return true;
28544             }
28545             return false;
28546         }
28547         function adjustIntersectingElement(element, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta) {
28548             ts.Debug.assert(element.end >= changeStart, "Adjusting an element that was entirely before the change range");
28549             ts.Debug.assert(element.pos <= changeRangeOldEnd, "Adjusting an element that was entirely after the change range");
28550             ts.Debug.assert(element.pos <= element.end);
28551             var pos = Math.min(element.pos, changeRangeNewEnd);
28552             var end = element.end >= changeRangeOldEnd ?
28553                 element.end + delta :
28554                 Math.min(element.end, changeRangeNewEnd);
28555             ts.Debug.assert(pos <= end);
28556             if (element.parent) {
28557                 ts.Debug.assertGreaterThanOrEqual(pos, element.parent.pos);
28558                 ts.Debug.assertLessThanOrEqual(end, element.parent.end);
28559             }
28560             ts.setTextRangePosEnd(element, pos, end);
28561         }
28562         function checkNodePositions(node, aggressiveChecks) {
28563             if (aggressiveChecks) {
28564                 var pos_2 = node.pos;
28565                 var visitNode_1 = function (child) {
28566                     ts.Debug.assert(child.pos >= pos_2);
28567                     pos_2 = child.end;
28568                 };
28569                 if (ts.hasJSDocNodes(node)) {
28570                     for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
28571                         var jsDocComment = _a[_i];
28572                         visitNode_1(jsDocComment);
28573                     }
28574                 }
28575                 forEachChild(node, visitNode_1);
28576                 ts.Debug.assert(pos_2 <= node.end);
28577             }
28578         }
28579         function updateTokenPositionsAndMarkElements(sourceFile, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta, oldText, newText, aggressiveChecks) {
28580             visitNode(sourceFile);
28581             return;
28582             function visitNode(child) {
28583                 ts.Debug.assert(child.pos <= child.end);
28584                 if (child.pos > changeRangeOldEnd) {
28585                     moveElementEntirelyPastChangeRange(child, false, delta, oldText, newText, aggressiveChecks);
28586                     return;
28587                 }
28588                 var fullEnd = child.end;
28589                 if (fullEnd >= changeStart) {
28590                     child.intersectsChange = true;
28591                     child._children = undefined;
28592                     adjustIntersectingElement(child, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
28593                     forEachChild(child, visitNode, visitArray);
28594                     if (ts.hasJSDocNodes(child)) {
28595                         for (var _i = 0, _a = child.jsDoc; _i < _a.length; _i++) {
28596                             var jsDocComment = _a[_i];
28597                             visitNode(jsDocComment);
28598                         }
28599                     }
28600                     checkNodePositions(child, aggressiveChecks);
28601                     return;
28602                 }
28603                 ts.Debug.assert(fullEnd < changeStart);
28604             }
28605             function visitArray(array) {
28606                 ts.Debug.assert(array.pos <= array.end);
28607                 if (array.pos > changeRangeOldEnd) {
28608                     moveElementEntirelyPastChangeRange(array, true, delta, oldText, newText, aggressiveChecks);
28609                     return;
28610                 }
28611                 var fullEnd = array.end;
28612                 if (fullEnd >= changeStart) {
28613                     array.intersectsChange = true;
28614                     array._children = undefined;
28615                     adjustIntersectingElement(array, changeStart, changeRangeOldEnd, changeRangeNewEnd, delta);
28616                     for (var _i = 0, array_9 = array; _i < array_9.length; _i++) {
28617                         var node = array_9[_i];
28618                         visitNode(node);
28619                     }
28620                     return;
28621                 }
28622                 ts.Debug.assert(fullEnd < changeStart);
28623             }
28624         }
28625         function extendToAffectedRange(sourceFile, changeRange) {
28626             var maxLookahead = 1;
28627             var start = changeRange.span.start;
28628             for (var i = 0; start > 0 && i <= maxLookahead; i++) {
28629                 var nearestNode = findNearestNodeStartingBeforeOrAtPosition(sourceFile, start);
28630                 ts.Debug.assert(nearestNode.pos <= start);
28631                 var position = nearestNode.pos;
28632                 start = Math.max(0, position - 1);
28633             }
28634             var finalSpan = ts.createTextSpanFromBounds(start, ts.textSpanEnd(changeRange.span));
28635             var finalLength = changeRange.newLength + (changeRange.span.start - start);
28636             return ts.createTextChangeRange(finalSpan, finalLength);
28637         }
28638         function findNearestNodeStartingBeforeOrAtPosition(sourceFile, position) {
28639             var bestResult = sourceFile;
28640             var lastNodeEntirelyBeforePosition;
28641             forEachChild(sourceFile, visit);
28642             if (lastNodeEntirelyBeforePosition) {
28643                 var lastChildOfLastEntireNodeBeforePosition = getLastDescendant(lastNodeEntirelyBeforePosition);
28644                 if (lastChildOfLastEntireNodeBeforePosition.pos > bestResult.pos) {
28645                     bestResult = lastChildOfLastEntireNodeBeforePosition;
28646                 }
28647             }
28648             return bestResult;
28649             function getLastDescendant(node) {
28650                 while (true) {
28651                     var lastChild = ts.getLastChild(node);
28652                     if (lastChild) {
28653                         node = lastChild;
28654                     }
28655                     else {
28656                         return node;
28657                     }
28658                 }
28659             }
28660             function visit(child) {
28661                 if (ts.nodeIsMissing(child)) {
28662                     return;
28663                 }
28664                 if (child.pos <= position) {
28665                     if (child.pos >= bestResult.pos) {
28666                         bestResult = child;
28667                     }
28668                     if (position < child.end) {
28669                         forEachChild(child, visit);
28670                         return true;
28671                     }
28672                     else {
28673                         ts.Debug.assert(child.end <= position);
28674                         lastNodeEntirelyBeforePosition = child;
28675                     }
28676                 }
28677                 else {
28678                     ts.Debug.assert(child.pos > position);
28679                     return true;
28680                 }
28681             }
28682         }
28683         function checkChangeRange(sourceFile, newText, textChangeRange, aggressiveChecks) {
28684             var oldText = sourceFile.text;
28685             if (textChangeRange) {
28686                 ts.Debug.assert((oldText.length - textChangeRange.span.length + textChangeRange.newLength) === newText.length);
28687                 if (aggressiveChecks || ts.Debug.shouldAssert(3)) {
28688                     var oldTextPrefix = oldText.substr(0, textChangeRange.span.start);
28689                     var newTextPrefix = newText.substr(0, textChangeRange.span.start);
28690                     ts.Debug.assert(oldTextPrefix === newTextPrefix);
28691                     var oldTextSuffix = oldText.substring(ts.textSpanEnd(textChangeRange.span), oldText.length);
28692                     var newTextSuffix = newText.substring(ts.textSpanEnd(ts.textChangeRangeNewSpan(textChangeRange)), newText.length);
28693                     ts.Debug.assert(oldTextSuffix === newTextSuffix);
28694                 }
28695             }
28696         }
28697         function createSyntaxCursor(sourceFile) {
28698             var currentArray = sourceFile.statements;
28699             var currentArrayIndex = 0;
28700             ts.Debug.assert(currentArrayIndex < currentArray.length);
28701             var current = currentArray[currentArrayIndex];
28702             var lastQueriedPosition = -1;
28703             return {
28704                 currentNode: function (position) {
28705                     if (position !== lastQueriedPosition) {
28706                         if (current && current.end === position && currentArrayIndex < (currentArray.length - 1)) {
28707                             currentArrayIndex++;
28708                             current = currentArray[currentArrayIndex];
28709                         }
28710                         if (!current || current.pos !== position) {
28711                             findHighestListElementThatStartsAtPosition(position);
28712                         }
28713                     }
28714                     lastQueriedPosition = position;
28715                     ts.Debug.assert(!current || current.pos === position);
28716                     return current;
28717                 }
28718             };
28719             function findHighestListElementThatStartsAtPosition(position) {
28720                 currentArray = undefined;
28721                 currentArrayIndex = -1;
28722                 current = undefined;
28723                 forEachChild(sourceFile, visitNode, visitArray);
28724                 return;
28725                 function visitNode(node) {
28726                     if (position >= node.pos && position < node.end) {
28727                         forEachChild(node, visitNode, visitArray);
28728                         return true;
28729                     }
28730                     return false;
28731                 }
28732                 function visitArray(array) {
28733                     if (position >= array.pos && position < array.end) {
28734                         for (var i = 0; i < array.length; i++) {
28735                             var child = array[i];
28736                             if (child) {
28737                                 if (child.pos === position) {
28738                                     currentArray = array;
28739                                     currentArrayIndex = i;
28740                                     current = child;
28741                                     return true;
28742                                 }
28743                                 else {
28744                                     if (child.pos < position && position < child.end) {
28745                                         forEachChild(child, visitNode, visitArray);
28746                                         return true;
28747                                     }
28748                                 }
28749                             }
28750                         }
28751                     }
28752                     return false;
28753                 }
28754             }
28755         }
28756         IncrementalParser.createSyntaxCursor = createSyntaxCursor;
28757     })(IncrementalParser || (IncrementalParser = {}));
28758     function isDeclarationFileName(fileName) {
28759         return ts.fileExtensionIs(fileName, ".d.ts");
28760     }
28761     ts.isDeclarationFileName = isDeclarationFileName;
28762     function processCommentPragmas(context, sourceText) {
28763         var pragmas = [];
28764         for (var _i = 0, _a = ts.getLeadingCommentRanges(sourceText, 0) || ts.emptyArray; _i < _a.length; _i++) {
28765             var range = _a[_i];
28766             var comment = sourceText.substring(range.pos, range.end);
28767             extractPragmas(pragmas, range, comment);
28768         }
28769         context.pragmas = new ts.Map();
28770         for (var _b = 0, pragmas_1 = pragmas; _b < pragmas_1.length; _b++) {
28771             var pragma = pragmas_1[_b];
28772             if (context.pragmas.has(pragma.name)) {
28773                 var currentValue = context.pragmas.get(pragma.name);
28774                 if (currentValue instanceof Array) {
28775                     currentValue.push(pragma.args);
28776                 }
28777                 else {
28778                     context.pragmas.set(pragma.name, [currentValue, pragma.args]);
28779                 }
28780                 continue;
28781             }
28782             context.pragmas.set(pragma.name, pragma.args);
28783         }
28784     }
28785     ts.processCommentPragmas = processCommentPragmas;
28786     function processPragmasIntoFields(context, reportDiagnostic) {
28787         context.checkJsDirective = undefined;
28788         context.referencedFiles = [];
28789         context.typeReferenceDirectives = [];
28790         context.libReferenceDirectives = [];
28791         context.amdDependencies = [];
28792         context.hasNoDefaultLib = false;
28793         context.pragmas.forEach(function (entryOrList, key) {
28794             switch (key) {
28795                 case "reference": {
28796                     var referencedFiles_1 = context.referencedFiles;
28797                     var typeReferenceDirectives_1 = context.typeReferenceDirectives;
28798                     var libReferenceDirectives_1 = context.libReferenceDirectives;
28799                     ts.forEach(ts.toArray(entryOrList), function (arg) {
28800                         var _a = arg.arguments, types = _a.types, lib = _a.lib, path = _a.path;
28801                         if (arg.arguments["no-default-lib"]) {
28802                             context.hasNoDefaultLib = true;
28803                         }
28804                         else if (types) {
28805                             typeReferenceDirectives_1.push({ pos: types.pos, end: types.end, fileName: types.value });
28806                         }
28807                         else if (lib) {
28808                             libReferenceDirectives_1.push({ pos: lib.pos, end: lib.end, fileName: lib.value });
28809                         }
28810                         else if (path) {
28811                             referencedFiles_1.push({ pos: path.pos, end: path.end, fileName: path.value });
28812                         }
28813                         else {
28814                             reportDiagnostic(arg.range.pos, arg.range.end - arg.range.pos, ts.Diagnostics.Invalid_reference_directive_syntax);
28815                         }
28816                     });
28817                     break;
28818                 }
28819                 case "amd-dependency": {
28820                     context.amdDependencies = ts.map(ts.toArray(entryOrList), function (x) { return ({ name: x.arguments.name, path: x.arguments.path }); });
28821                     break;
28822                 }
28823                 case "amd-module": {
28824                     if (entryOrList instanceof Array) {
28825                         for (var _i = 0, entryOrList_1 = entryOrList; _i < entryOrList_1.length; _i++) {
28826                             var entry = entryOrList_1[_i];
28827                             if (context.moduleName) {
28828                                 reportDiagnostic(entry.range.pos, entry.range.end - entry.range.pos, ts.Diagnostics.An_AMD_module_cannot_have_multiple_name_assignments);
28829                             }
28830                             context.moduleName = entry.arguments.name;
28831                         }
28832                     }
28833                     else {
28834                         context.moduleName = entryOrList.arguments.name;
28835                     }
28836                     break;
28837                 }
28838                 case "ts-nocheck":
28839                 case "ts-check": {
28840                     ts.forEach(ts.toArray(entryOrList), function (entry) {
28841                         if (!context.checkJsDirective || entry.range.pos > context.checkJsDirective.pos) {
28842                             context.checkJsDirective = {
28843                                 enabled: key === "ts-check",
28844                                 end: entry.range.end,
28845                                 pos: entry.range.pos
28846                             };
28847                         }
28848                     });
28849                     break;
28850                 }
28851                 case "jsx":
28852                 case "jsxfrag":
28853                 case "jsximportsource":
28854                 case "jsxruntime":
28855                     return;
28856                 default: ts.Debug.fail("Unhandled pragma kind");
28857             }
28858         });
28859     }
28860     ts.processPragmasIntoFields = processPragmasIntoFields;
28861     var namedArgRegExCache = new ts.Map();
28862     function getNamedArgRegEx(name) {
28863         if (namedArgRegExCache.has(name)) {
28864             return namedArgRegExCache.get(name);
28865         }
28866         var result = new RegExp("(\\s" + name + "\\s*=\\s*)('|\")(.+?)\\2", "im");
28867         namedArgRegExCache.set(name, result);
28868         return result;
28869     }
28870     var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im;
28871     var singleLinePragmaRegEx = /^\/\/\/?\s*@(\S+)\s*(.*)\s*$/im;
28872     function extractPragmas(pragmas, range, text) {
28873         var tripleSlash = range.kind === 2 && tripleSlashXMLCommentStartRegEx.exec(text);
28874         if (tripleSlash) {
28875             var name = tripleSlash[1].toLowerCase();
28876             var pragma = ts.commentPragmas[name];
28877             if (!pragma || !(pragma.kind & 1)) {
28878                 return;
28879             }
28880             if (pragma.args) {
28881                 var argument = {};
28882                 for (var _i = 0, _a = pragma.args; _i < _a.length; _i++) {
28883                     var arg = _a[_i];
28884                     var matcher = getNamedArgRegEx(arg.name);
28885                     var matchResult = matcher.exec(text);
28886                     if (!matchResult && !arg.optional) {
28887                         return;
28888                     }
28889                     else if (matchResult) {
28890                         if (arg.captureSpan) {
28891                             var startPos = range.pos + matchResult.index + matchResult[1].length + matchResult[2].length;
28892                             argument[arg.name] = {
28893                                 value: matchResult[3],
28894                                 pos: startPos,
28895                                 end: startPos + matchResult[3].length
28896                             };
28897                         }
28898                         else {
28899                             argument[arg.name] = matchResult[3];
28900                         }
28901                     }
28902                 }
28903                 pragmas.push({ name: name, args: { arguments: argument, range: range } });
28904             }
28905             else {
28906                 pragmas.push({ name: name, args: { arguments: {}, range: range } });
28907             }
28908             return;
28909         }
28910         var singleLine = range.kind === 2 && singleLinePragmaRegEx.exec(text);
28911         if (singleLine) {
28912             return addPragmaForMatch(pragmas, range, 2, singleLine);
28913         }
28914         if (range.kind === 3) {
28915             var multiLinePragmaRegEx = /\s*@(\S+)\s*(.*)\s*$/gim;
28916             var multiLineMatch = void 0;
28917             while (multiLineMatch = multiLinePragmaRegEx.exec(text)) {
28918                 addPragmaForMatch(pragmas, range, 4, multiLineMatch);
28919             }
28920         }
28921     }
28922     function addPragmaForMatch(pragmas, range, kind, match) {
28923         if (!match)
28924             return;
28925         var name = match[1].toLowerCase();
28926         var pragma = ts.commentPragmas[name];
28927         if (!pragma || !(pragma.kind & kind)) {
28928             return;
28929         }
28930         var args = match[2];
28931         var argument = getNamedPragmaArguments(pragma, args);
28932         if (argument === "fail")
28933             return;
28934         pragmas.push({ name: name, args: { arguments: argument, range: range } });
28935         return;
28936     }
28937     function getNamedPragmaArguments(pragma, text) {
28938         if (!text)
28939             return {};
28940         if (!pragma.args)
28941             return {};
28942         var args = text.split(/\s+/);
28943         var argMap = {};
28944         for (var i = 0; i < pragma.args.length; i++) {
28945             var argument = pragma.args[i];
28946             if (!args[i] && !argument.optional) {
28947                 return "fail";
28948             }
28949             if (argument.captureSpan) {
28950                 return ts.Debug.fail("Capture spans not yet implemented for non-xml pragmas");
28951             }
28952             argMap[argument.name] = args[i];
28953         }
28954         return argMap;
28955     }
28956     function tagNamesAreEquivalent(lhs, rhs) {
28957         if (lhs.kind !== rhs.kind) {
28958             return false;
28959         }
28960         if (lhs.kind === 78) {
28961             return lhs.escapedText === rhs.escapedText;
28962         }
28963         if (lhs.kind === 107) {
28964             return true;
28965         }
28966         return lhs.name.escapedText === rhs.name.escapedText &&
28967             tagNamesAreEquivalent(lhs.expression, rhs.expression);
28968     }
28969     ts.tagNamesAreEquivalent = tagNamesAreEquivalent;
28970 })(ts || (ts = {}));
28971 var ts;
28972 (function (ts) {
28973     ts.compileOnSaveCommandLineOption = { name: "compileOnSave", type: "boolean" };
28974     var jsxOptionMap = new ts.Map(ts.getEntries({
28975         "preserve": 1,
28976         "react-native": 3,
28977         "react": 2,
28978         "react-jsx": 4,
28979         "react-jsxdev": 5,
28980     }));
28981     ts.inverseJsxOptionMap = new ts.Map(ts.arrayFrom(ts.mapIterator(jsxOptionMap.entries(), function (_a) {
28982         var key = _a[0], value = _a[1];
28983         return ["" + value, key];
28984     })));
28985     var libEntries = [
28986         ["es5", "lib.es5.d.ts"],
28987         ["es6", "lib.es2015.d.ts"],
28988         ["es2015", "lib.es2015.d.ts"],
28989         ["es7", "lib.es2016.d.ts"],
28990         ["es2016", "lib.es2016.d.ts"],
28991         ["es2017", "lib.es2017.d.ts"],
28992         ["es2018", "lib.es2018.d.ts"],
28993         ["es2019", "lib.es2019.d.ts"],
28994         ["es2020", "lib.es2020.d.ts"],
28995         ["esnext", "lib.esnext.d.ts"],
28996         ["dom", "lib.dom.d.ts"],
28997         ["dom.iterable", "lib.dom.iterable.d.ts"],
28998         ["webworker", "lib.webworker.d.ts"],
28999         ["webworker.importscripts", "lib.webworker.importscripts.d.ts"],
29000         ["webworker.iterable", "lib.webworker.iterable.d.ts"],
29001         ["scripthost", "lib.scripthost.d.ts"],
29002         ["es2015.core", "lib.es2015.core.d.ts"],
29003         ["es2015.collection", "lib.es2015.collection.d.ts"],
29004         ["es2015.generator", "lib.es2015.generator.d.ts"],
29005         ["es2015.iterable", "lib.es2015.iterable.d.ts"],
29006         ["es2015.promise", "lib.es2015.promise.d.ts"],
29007         ["es2015.proxy", "lib.es2015.proxy.d.ts"],
29008         ["es2015.reflect", "lib.es2015.reflect.d.ts"],
29009         ["es2015.symbol", "lib.es2015.symbol.d.ts"],
29010         ["es2015.symbol.wellknown", "lib.es2015.symbol.wellknown.d.ts"],
29011         ["es2016.array.include", "lib.es2016.array.include.d.ts"],
29012         ["es2017.object", "lib.es2017.object.d.ts"],
29013         ["es2017.sharedmemory", "lib.es2017.sharedmemory.d.ts"],
29014         ["es2017.string", "lib.es2017.string.d.ts"],
29015         ["es2017.intl", "lib.es2017.intl.d.ts"],
29016         ["es2017.typedarrays", "lib.es2017.typedarrays.d.ts"],
29017         ["es2018.asyncgenerator", "lib.es2018.asyncgenerator.d.ts"],
29018         ["es2018.asynciterable", "lib.es2018.asynciterable.d.ts"],
29019         ["es2018.intl", "lib.es2018.intl.d.ts"],
29020         ["es2018.promise", "lib.es2018.promise.d.ts"],
29021         ["es2018.regexp", "lib.es2018.regexp.d.ts"],
29022         ["es2019.array", "lib.es2019.array.d.ts"],
29023         ["es2019.object", "lib.es2019.object.d.ts"],
29024         ["es2019.string", "lib.es2019.string.d.ts"],
29025         ["es2019.symbol", "lib.es2019.symbol.d.ts"],
29026         ["es2020.bigint", "lib.es2020.bigint.d.ts"],
29027         ["es2020.promise", "lib.es2020.promise.d.ts"],
29028         ["es2020.sharedmemory", "lib.es2020.sharedmemory.d.ts"],
29029         ["es2020.string", "lib.es2020.string.d.ts"],
29030         ["es2020.symbol.wellknown", "lib.es2020.symbol.wellknown.d.ts"],
29031         ["es2020.intl", "lib.es2020.intl.d.ts"],
29032         ["esnext.array", "lib.es2019.array.d.ts"],
29033         ["esnext.symbol", "lib.es2019.symbol.d.ts"],
29034         ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"],
29035         ["esnext.intl", "lib.esnext.intl.d.ts"],
29036         ["esnext.bigint", "lib.es2020.bigint.d.ts"],
29037         ["esnext.string", "lib.esnext.string.d.ts"],
29038         ["esnext.promise", "lib.esnext.promise.d.ts"],
29039         ["esnext.weakref", "lib.esnext.weakref.d.ts"]
29040     ];
29041     ts.libs = libEntries.map(function (entry) { return entry[0]; });
29042     ts.libMap = new ts.Map(libEntries);
29043     ts.optionsForWatch = [
29044         {
29045             name: "watchFile",
29046             type: new ts.Map(ts.getEntries({
29047                 fixedpollinginterval: ts.WatchFileKind.FixedPollingInterval,
29048                 prioritypollinginterval: ts.WatchFileKind.PriorityPollingInterval,
29049                 dynamicprioritypolling: ts.WatchFileKind.DynamicPriorityPolling,
29050                 usefsevents: ts.WatchFileKind.UseFsEvents,
29051                 usefseventsonparentdirectory: ts.WatchFileKind.UseFsEventsOnParentDirectory,
29052             })),
29053             category: ts.Diagnostics.Advanced_Options,
29054             description: ts.Diagnostics.Specify_strategy_for_watching_file_Colon_FixedPollingInterval_default_PriorityPollingInterval_DynamicPriorityPolling_UseFsEvents_UseFsEventsOnParentDirectory,
29055         },
29056         {
29057             name: "watchDirectory",
29058             type: new ts.Map(ts.getEntries({
29059                 usefsevents: ts.WatchDirectoryKind.UseFsEvents,
29060                 fixedpollinginterval: ts.WatchDirectoryKind.FixedPollingInterval,
29061                 dynamicprioritypolling: ts.WatchDirectoryKind.DynamicPriorityPolling,
29062             })),
29063             category: ts.Diagnostics.Advanced_Options,
29064             description: ts.Diagnostics.Specify_strategy_for_watching_directory_on_platforms_that_don_t_support_recursive_watching_natively_Colon_UseFsEvents_default_FixedPollingInterval_DynamicPriorityPolling,
29065         },
29066         {
29067             name: "fallbackPolling",
29068             type: new ts.Map(ts.getEntries({
29069                 fixedinterval: ts.PollingWatchKind.FixedInterval,
29070                 priorityinterval: ts.PollingWatchKind.PriorityInterval,
29071                 dynamicpriority: ts.PollingWatchKind.DynamicPriority,
29072             })),
29073             category: ts.Diagnostics.Advanced_Options,
29074             description: ts.Diagnostics.Specify_strategy_for_creating_a_polling_watch_when_it_fails_to_create_using_file_system_events_Colon_FixedInterval_default_PriorityInterval_DynamicPriority,
29075         },
29076         {
29077             name: "synchronousWatchDirectory",
29078             type: "boolean",
29079             category: ts.Diagnostics.Advanced_Options,
29080             description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively,
29081         },
29082         {
29083             name: "excludeDirectories",
29084             type: "list",
29085             element: {
29086                 name: "excludeDirectory",
29087                 type: "string",
29088                 isFilePath: true,
29089                 extraValidation: specToDiagnostic
29090             },
29091             category: ts.Diagnostics.Advanced_Options,
29092             description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively,
29093         },
29094         {
29095             name: "excludeFiles",
29096             type: "list",
29097             element: {
29098                 name: "excludeFile",
29099                 type: "string",
29100                 isFilePath: true,
29101                 extraValidation: specToDiagnostic
29102             },
29103             category: ts.Diagnostics.Advanced_Options,
29104             description: ts.Diagnostics.Synchronously_call_callbacks_and_update_the_state_of_directory_watchers_on_platforms_that_don_t_support_recursive_watching_natively,
29105         },
29106     ];
29107     ts.commonOptionsWithBuild = [
29108         {
29109             name: "help",
29110             shortName: "h",
29111             type: "boolean",
29112             showInSimplifiedHelpView: true,
29113             category: ts.Diagnostics.Command_line_Options,
29114             description: ts.Diagnostics.Print_this_message,
29115         },
29116         {
29117             name: "help",
29118             shortName: "?",
29119             type: "boolean"
29120         },
29121         {
29122             name: "watch",
29123             shortName: "w",
29124             type: "boolean",
29125             showInSimplifiedHelpView: true,
29126             category: ts.Diagnostics.Command_line_Options,
29127             description: ts.Diagnostics.Watch_input_files,
29128         },
29129         {
29130             name: "preserveWatchOutput",
29131             type: "boolean",
29132             showInSimplifiedHelpView: false,
29133             category: ts.Diagnostics.Command_line_Options,
29134             description: ts.Diagnostics.Whether_to_keep_outdated_console_output_in_watch_mode_instead_of_clearing_the_screen,
29135         },
29136         {
29137             name: "listFiles",
29138             type: "boolean",
29139             category: ts.Diagnostics.Advanced_Options,
29140             description: ts.Diagnostics.Print_names_of_files_part_of_the_compilation
29141         },
29142         {
29143             name: "explainFiles",
29144             type: "boolean",
29145             category: ts.Diagnostics.Advanced_Options,
29146             description: ts.Diagnostics.Print_names_of_files_and_the_reason_they_are_part_of_the_compilation
29147         }, {
29148             name: "listEmittedFiles",
29149             type: "boolean",
29150             category: ts.Diagnostics.Advanced_Options,
29151             description: ts.Diagnostics.Print_names_of_generated_files_part_of_the_compilation
29152         },
29153         {
29154             name: "pretty",
29155             type: "boolean",
29156             showInSimplifiedHelpView: true,
29157             category: ts.Diagnostics.Command_line_Options,
29158             description: ts.Diagnostics.Stylize_errors_and_messages_using_color_and_context_experimental
29159         },
29160         {
29161             name: "traceResolution",
29162             type: "boolean",
29163             category: ts.Diagnostics.Advanced_Options,
29164             description: ts.Diagnostics.Enable_tracing_of_the_name_resolution_process
29165         },
29166         {
29167             name: "diagnostics",
29168             type: "boolean",
29169             category: ts.Diagnostics.Advanced_Options,
29170             description: ts.Diagnostics.Show_diagnostic_information
29171         },
29172         {
29173             name: "extendedDiagnostics",
29174             type: "boolean",
29175             category: ts.Diagnostics.Advanced_Options,
29176             description: ts.Diagnostics.Show_verbose_diagnostic_information
29177         },
29178         {
29179             name: "generateCpuProfile",
29180             type: "string",
29181             isFilePath: true,
29182             paramType: ts.Diagnostics.FILE_OR_DIRECTORY,
29183             category: ts.Diagnostics.Advanced_Options,
29184             description: ts.Diagnostics.Generates_a_CPU_profile
29185         },
29186         {
29187             name: "generateTrace",
29188             type: "string",
29189             isFilePath: true,
29190             isCommandLineOnly: true,
29191             paramType: ts.Diagnostics.DIRECTORY,
29192             category: ts.Diagnostics.Advanced_Options,
29193             description: ts.Diagnostics.Generates_an_event_trace_and_a_list_of_types
29194         },
29195         {
29196             name: "incremental",
29197             shortName: "i",
29198             type: "boolean",
29199             category: ts.Diagnostics.Basic_Options,
29200             description: ts.Diagnostics.Enable_incremental_compilation,
29201             transpileOptionValue: undefined
29202         },
29203         {
29204             name: "assumeChangesOnlyAffectDirectDependencies",
29205             type: "boolean",
29206             affectsSemanticDiagnostics: true,
29207             affectsEmit: true,
29208             category: ts.Diagnostics.Advanced_Options,
29209             description: ts.Diagnostics.Have_recompiles_in_incremental_and_watch_assume_that_changes_within_a_file_will_only_affect_files_directly_depending_on_it
29210         },
29211         {
29212             name: "locale",
29213             type: "string",
29214             category: ts.Diagnostics.Advanced_Options,
29215             description: ts.Diagnostics.The_locale_used_when_displaying_messages_to_the_user_e_g_en_us
29216         },
29217     ];
29218     ts.targetOptionDeclaration = {
29219         name: "target",
29220         shortName: "t",
29221         type: new ts.Map(ts.getEntries({
29222             es3: 0,
29223             es5: 1,
29224             es6: 2,
29225             es2015: 2,
29226             es2016: 3,
29227             es2017: 4,
29228             es2018: 5,
29229             es2019: 6,
29230             es2020: 7,
29231             esnext: 99,
29232         })),
29233         affectsSourceFile: true,
29234         affectsModuleResolution: true,
29235         affectsEmit: true,
29236         paramType: ts.Diagnostics.VERSION,
29237         showInSimplifiedHelpView: true,
29238         category: ts.Diagnostics.Basic_Options,
29239         description: ts.Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_ES2015_ES2016_ES2017_ES2018_ES2019_ES2020_or_ESNEXT,
29240     };
29241     ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), [
29242         {
29243             name: "all",
29244             type: "boolean",
29245             showInSimplifiedHelpView: true,
29246             category: ts.Diagnostics.Command_line_Options,
29247             description: ts.Diagnostics.Show_all_compiler_options,
29248         },
29249         {
29250             name: "version",
29251             shortName: "v",
29252             type: "boolean",
29253             showInSimplifiedHelpView: true,
29254             category: ts.Diagnostics.Command_line_Options,
29255             description: ts.Diagnostics.Print_the_compiler_s_version,
29256         },
29257         {
29258             name: "init",
29259             type: "boolean",
29260             showInSimplifiedHelpView: true,
29261             category: ts.Diagnostics.Command_line_Options,
29262             description: ts.Diagnostics.Initializes_a_TypeScript_project_and_creates_a_tsconfig_json_file,
29263         },
29264         {
29265             name: "project",
29266             shortName: "p",
29267             type: "string",
29268             isFilePath: true,
29269             showInSimplifiedHelpView: true,
29270             category: ts.Diagnostics.Command_line_Options,
29271             paramType: ts.Diagnostics.FILE_OR_DIRECTORY,
29272             description: ts.Diagnostics.Compile_the_project_given_the_path_to_its_configuration_file_or_to_a_folder_with_a_tsconfig_json,
29273         },
29274         {
29275             name: "build",
29276             type: "boolean",
29277             shortName: "b",
29278             showInSimplifiedHelpView: true,
29279             category: ts.Diagnostics.Command_line_Options,
29280             description: ts.Diagnostics.Build_one_or_more_projects_and_their_dependencies_if_out_of_date
29281         },
29282         {
29283             name: "showConfig",
29284             type: "boolean",
29285             category: ts.Diagnostics.Command_line_Options,
29286             isCommandLineOnly: true,
29287             description: ts.Diagnostics.Print_the_final_configuration_instead_of_building
29288         },
29289         {
29290             name: "listFilesOnly",
29291             type: "boolean",
29292             category: ts.Diagnostics.Command_line_Options,
29293             affectsSemanticDiagnostics: true,
29294             affectsEmit: true,
29295             isCommandLineOnly: true,
29296             description: ts.Diagnostics.Print_names_of_files_that_are_part_of_the_compilation_and_then_stop_processing
29297         },
29298         ts.targetOptionDeclaration,
29299         {
29300             name: "module",
29301             shortName: "m",
29302             type: new ts.Map(ts.getEntries({
29303                 none: ts.ModuleKind.None,
29304                 commonjs: ts.ModuleKind.CommonJS,
29305                 amd: ts.ModuleKind.AMD,
29306                 system: ts.ModuleKind.System,
29307                 umd: ts.ModuleKind.UMD,
29308                 es6: ts.ModuleKind.ES2015,
29309                 es2015: ts.ModuleKind.ES2015,
29310                 es2020: ts.ModuleKind.ES2020,
29311                 esnext: ts.ModuleKind.ESNext
29312             })),
29313             affectsModuleResolution: true,
29314             affectsEmit: true,
29315             paramType: ts.Diagnostics.KIND,
29316             showInSimplifiedHelpView: true,
29317             category: ts.Diagnostics.Basic_Options,
29318             description: ts.Diagnostics.Specify_module_code_generation_Colon_none_commonjs_amd_system_umd_es2015_es2020_or_ESNext,
29319         },
29320         {
29321             name: "lib",
29322             type: "list",
29323             element: {
29324                 name: "lib",
29325                 type: ts.libMap
29326             },
29327             affectsModuleResolution: true,
29328             showInSimplifiedHelpView: true,
29329             category: ts.Diagnostics.Basic_Options,
29330             description: ts.Diagnostics.Specify_library_files_to_be_included_in_the_compilation,
29331             transpileOptionValue: undefined
29332         },
29333         {
29334             name: "allowJs",
29335             type: "boolean",
29336             affectsModuleResolution: true,
29337             showInSimplifiedHelpView: true,
29338             category: ts.Diagnostics.Basic_Options,
29339             description: ts.Diagnostics.Allow_javascript_files_to_be_compiled
29340         },
29341         {
29342             name: "checkJs",
29343             type: "boolean",
29344             category: ts.Diagnostics.Basic_Options,
29345             description: ts.Diagnostics.Report_errors_in_js_files
29346         },
29347         {
29348             name: "jsx",
29349             type: jsxOptionMap,
29350             affectsSourceFile: true,
29351             affectsEmit: true,
29352             affectsModuleResolution: true,
29353             paramType: ts.Diagnostics.KIND,
29354             showInSimplifiedHelpView: true,
29355             category: ts.Diagnostics.Basic_Options,
29356             description: ts.Diagnostics.Specify_JSX_code_generation_Colon_preserve_react_native_react_react_jsx_or_react_jsxdev,
29357         },
29358         {
29359             name: "declaration",
29360             shortName: "d",
29361             type: "boolean",
29362             affectsEmit: true,
29363             showInSimplifiedHelpView: true,
29364             category: ts.Diagnostics.Basic_Options,
29365             description: ts.Diagnostics.Generates_corresponding_d_ts_file,
29366             transpileOptionValue: undefined
29367         },
29368         {
29369             name: "declarationMap",
29370             type: "boolean",
29371             affectsEmit: true,
29372             showInSimplifiedHelpView: true,
29373             category: ts.Diagnostics.Basic_Options,
29374             description: ts.Diagnostics.Generates_a_sourcemap_for_each_corresponding_d_ts_file,
29375             transpileOptionValue: undefined
29376         },
29377         {
29378             name: "emitDeclarationOnly",
29379             type: "boolean",
29380             affectsEmit: true,
29381             category: ts.Diagnostics.Advanced_Options,
29382             description: ts.Diagnostics.Only_emit_d_ts_declaration_files,
29383             transpileOptionValue: undefined
29384         },
29385         {
29386             name: "sourceMap",
29387             type: "boolean",
29388             affectsEmit: true,
29389             showInSimplifiedHelpView: true,
29390             category: ts.Diagnostics.Basic_Options,
29391             description: ts.Diagnostics.Generates_corresponding_map_file,
29392         },
29393         {
29394             name: "outFile",
29395             type: "string",
29396             affectsEmit: true,
29397             isFilePath: true,
29398             paramType: ts.Diagnostics.FILE,
29399             showInSimplifiedHelpView: true,
29400             category: ts.Diagnostics.Basic_Options,
29401             description: ts.Diagnostics.Concatenate_and_emit_output_to_single_file,
29402             transpileOptionValue: undefined
29403         },
29404         {
29405             name: "outDir",
29406             type: "string",
29407             affectsEmit: true,
29408             isFilePath: true,
29409             paramType: ts.Diagnostics.DIRECTORY,
29410             showInSimplifiedHelpView: true,
29411             category: ts.Diagnostics.Basic_Options,
29412             description: ts.Diagnostics.Redirect_output_structure_to_the_directory,
29413         },
29414         {
29415             name: "rootDir",
29416             type: "string",
29417             affectsEmit: true,
29418             isFilePath: true,
29419             paramType: ts.Diagnostics.LOCATION,
29420             category: ts.Diagnostics.Basic_Options,
29421             description: ts.Diagnostics.Specify_the_root_directory_of_input_files_Use_to_control_the_output_directory_structure_with_outDir,
29422         },
29423         {
29424             name: "composite",
29425             type: "boolean",
29426             affectsEmit: true,
29427             isTSConfigOnly: true,
29428             category: ts.Diagnostics.Basic_Options,
29429             description: ts.Diagnostics.Enable_project_compilation,
29430             transpileOptionValue: undefined
29431         },
29432         {
29433             name: "tsBuildInfoFile",
29434             type: "string",
29435             affectsEmit: true,
29436             isFilePath: true,
29437             paramType: ts.Diagnostics.FILE,
29438             category: ts.Diagnostics.Basic_Options,
29439             description: ts.Diagnostics.Specify_file_to_store_incremental_compilation_information,
29440             transpileOptionValue: undefined
29441         },
29442         {
29443             name: "removeComments",
29444             type: "boolean",
29445             affectsEmit: true,
29446             showInSimplifiedHelpView: true,
29447             category: ts.Diagnostics.Basic_Options,
29448             description: ts.Diagnostics.Do_not_emit_comments_to_output,
29449         },
29450         {
29451             name: "noEmit",
29452             type: "boolean",
29453             showInSimplifiedHelpView: true,
29454             category: ts.Diagnostics.Basic_Options,
29455             description: ts.Diagnostics.Do_not_emit_outputs,
29456             transpileOptionValue: undefined
29457         },
29458         {
29459             name: "importHelpers",
29460             type: "boolean",
29461             affectsEmit: true,
29462             category: ts.Diagnostics.Basic_Options,
29463             description: ts.Diagnostics.Import_emit_helpers_from_tslib
29464         },
29465         {
29466             name: "importsNotUsedAsValues",
29467             type: new ts.Map(ts.getEntries({
29468                 remove: 0,
29469                 preserve: 1,
29470                 error: 2
29471             })),
29472             affectsEmit: true,
29473             affectsSemanticDiagnostics: true,
29474             category: ts.Diagnostics.Advanced_Options,
29475             description: ts.Diagnostics.Specify_emit_Slashchecking_behavior_for_imports_that_are_only_used_for_types
29476         },
29477         {
29478             name: "downlevelIteration",
29479             type: "boolean",
29480             affectsEmit: true,
29481             category: ts.Diagnostics.Basic_Options,
29482             description: ts.Diagnostics.Provide_full_support_for_iterables_in_for_of_spread_and_destructuring_when_targeting_ES5_or_ES3
29483         },
29484         {
29485             name: "isolatedModules",
29486             type: "boolean",
29487             category: ts.Diagnostics.Basic_Options,
29488             description: ts.Diagnostics.Transpile_each_file_as_a_separate_module_similar_to_ts_transpileModule,
29489             transpileOptionValue: true
29490         },
29491         {
29492             name: "strict",
29493             type: "boolean",
29494             showInSimplifiedHelpView: true,
29495             category: ts.Diagnostics.Strict_Type_Checking_Options,
29496             description: ts.Diagnostics.Enable_all_strict_type_checking_options
29497         },
29498         {
29499             name: "noImplicitAny",
29500             type: "boolean",
29501             affectsSemanticDiagnostics: true,
29502             strictFlag: true,
29503             showInSimplifiedHelpView: true,
29504             category: ts.Diagnostics.Strict_Type_Checking_Options,
29505             description: ts.Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type
29506         },
29507         {
29508             name: "strictNullChecks",
29509             type: "boolean",
29510             affectsSemanticDiagnostics: true,
29511             strictFlag: true,
29512             showInSimplifiedHelpView: true,
29513             category: ts.Diagnostics.Strict_Type_Checking_Options,
29514             description: ts.Diagnostics.Enable_strict_null_checks
29515         },
29516         {
29517             name: "strictFunctionTypes",
29518             type: "boolean",
29519             affectsSemanticDiagnostics: true,
29520             strictFlag: true,
29521             showInSimplifiedHelpView: true,
29522             category: ts.Diagnostics.Strict_Type_Checking_Options,
29523             description: ts.Diagnostics.Enable_strict_checking_of_function_types
29524         },
29525         {
29526             name: "strictBindCallApply",
29527             type: "boolean",
29528             strictFlag: true,
29529             showInSimplifiedHelpView: true,
29530             category: ts.Diagnostics.Strict_Type_Checking_Options,
29531             description: ts.Diagnostics.Enable_strict_bind_call_and_apply_methods_on_functions
29532         },
29533         {
29534             name: "strictPropertyInitialization",
29535             type: "boolean",
29536             affectsSemanticDiagnostics: true,
29537             strictFlag: true,
29538             showInSimplifiedHelpView: true,
29539             category: ts.Diagnostics.Strict_Type_Checking_Options,
29540             description: ts.Diagnostics.Enable_strict_checking_of_property_initialization_in_classes
29541         },
29542         {
29543             name: "noImplicitThis",
29544             type: "boolean",
29545             affectsSemanticDiagnostics: true,
29546             strictFlag: true,
29547             showInSimplifiedHelpView: true,
29548             category: ts.Diagnostics.Strict_Type_Checking_Options,
29549             description: ts.Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type,
29550         },
29551         {
29552             name: "alwaysStrict",
29553             type: "boolean",
29554             affectsSourceFile: true,
29555             strictFlag: true,
29556             showInSimplifiedHelpView: true,
29557             category: ts.Diagnostics.Strict_Type_Checking_Options,
29558             description: ts.Diagnostics.Parse_in_strict_mode_and_emit_use_strict_for_each_source_file
29559         },
29560         {
29561             name: "noUnusedLocals",
29562             type: "boolean",
29563             affectsSemanticDiagnostics: true,
29564             showInSimplifiedHelpView: true,
29565             category: ts.Diagnostics.Additional_Checks,
29566             description: ts.Diagnostics.Report_errors_on_unused_locals,
29567         },
29568         {
29569             name: "noUnusedParameters",
29570             type: "boolean",
29571             affectsSemanticDiagnostics: true,
29572             showInSimplifiedHelpView: true,
29573             category: ts.Diagnostics.Additional_Checks,
29574             description: ts.Diagnostics.Report_errors_on_unused_parameters,
29575         },
29576         {
29577             name: "noImplicitReturns",
29578             type: "boolean",
29579             affectsSemanticDiagnostics: true,
29580             showInSimplifiedHelpView: true,
29581             category: ts.Diagnostics.Additional_Checks,
29582             description: ts.Diagnostics.Report_error_when_not_all_code_paths_in_function_return_a_value
29583         },
29584         {
29585             name: "noFallthroughCasesInSwitch",
29586             type: "boolean",
29587             affectsBindDiagnostics: true,
29588             affectsSemanticDiagnostics: true,
29589             showInSimplifiedHelpView: true,
29590             category: ts.Diagnostics.Additional_Checks,
29591             description: ts.Diagnostics.Report_errors_for_fallthrough_cases_in_switch_statement
29592         },
29593         {
29594             name: "noUncheckedIndexedAccess",
29595             type: "boolean",
29596             affectsSemanticDiagnostics: true,
29597             showInSimplifiedHelpView: false,
29598             category: ts.Diagnostics.Additional_Checks,
29599             description: ts.Diagnostics.Include_undefined_in_index_signature_results
29600         },
29601         {
29602             name: "noPropertyAccessFromIndexSignature",
29603             type: "boolean",
29604             showInSimplifiedHelpView: false,
29605             category: ts.Diagnostics.Additional_Checks,
29606             description: ts.Diagnostics.Require_undeclared_properties_from_index_signatures_to_use_element_accesses
29607         },
29608         {
29609             name: "moduleResolution",
29610             type: new ts.Map(ts.getEntries({
29611                 node: ts.ModuleResolutionKind.NodeJs,
29612                 classic: ts.ModuleResolutionKind.Classic,
29613             })),
29614             affectsModuleResolution: true,
29615             paramType: ts.Diagnostics.STRATEGY,
29616             category: ts.Diagnostics.Module_Resolution_Options,
29617             description: ts.Diagnostics.Specify_module_resolution_strategy_Colon_node_Node_js_or_classic_TypeScript_pre_1_6,
29618         },
29619         {
29620             name: "baseUrl",
29621             type: "string",
29622             affectsModuleResolution: true,
29623             isFilePath: true,
29624             category: ts.Diagnostics.Module_Resolution_Options,
29625             description: ts.Diagnostics.Base_directory_to_resolve_non_absolute_module_names
29626         },
29627         {
29628             name: "paths",
29629             type: "object",
29630             affectsModuleResolution: true,
29631             isTSConfigOnly: true,
29632             category: ts.Diagnostics.Module_Resolution_Options,
29633             description: ts.Diagnostics.A_series_of_entries_which_re_map_imports_to_lookup_locations_relative_to_the_baseUrl,
29634             transpileOptionValue: undefined
29635         },
29636         {
29637             name: "rootDirs",
29638             type: "list",
29639             isTSConfigOnly: true,
29640             element: {
29641                 name: "rootDirs",
29642                 type: "string",
29643                 isFilePath: true
29644             },
29645             affectsModuleResolution: true,
29646             category: ts.Diagnostics.Module_Resolution_Options,
29647             description: ts.Diagnostics.List_of_root_folders_whose_combined_content_represents_the_structure_of_the_project_at_runtime,
29648             transpileOptionValue: undefined
29649         },
29650         {
29651             name: "typeRoots",
29652             type: "list",
29653             element: {
29654                 name: "typeRoots",
29655                 type: "string",
29656                 isFilePath: true
29657             },
29658             affectsModuleResolution: true,
29659             category: ts.Diagnostics.Module_Resolution_Options,
29660             description: ts.Diagnostics.List_of_folders_to_include_type_definitions_from
29661         },
29662         {
29663             name: "types",
29664             type: "list",
29665             element: {
29666                 name: "types",
29667                 type: "string"
29668             },
29669             affectsModuleResolution: true,
29670             showInSimplifiedHelpView: true,
29671             category: ts.Diagnostics.Module_Resolution_Options,
29672             description: ts.Diagnostics.Type_declaration_files_to_be_included_in_compilation,
29673             transpileOptionValue: undefined
29674         },
29675         {
29676             name: "allowSyntheticDefaultImports",
29677             type: "boolean",
29678             affectsSemanticDiagnostics: true,
29679             category: ts.Diagnostics.Module_Resolution_Options,
29680             description: ts.Diagnostics.Allow_default_imports_from_modules_with_no_default_export_This_does_not_affect_code_emit_just_typechecking
29681         },
29682         {
29683             name: "esModuleInterop",
29684             type: "boolean",
29685             affectsSemanticDiagnostics: true,
29686             affectsEmit: true,
29687             showInSimplifiedHelpView: true,
29688             category: ts.Diagnostics.Module_Resolution_Options,
29689             description: ts.Diagnostics.Enables_emit_interoperability_between_CommonJS_and_ES_Modules_via_creation_of_namespace_objects_for_all_imports_Implies_allowSyntheticDefaultImports
29690         },
29691         {
29692             name: "preserveSymlinks",
29693             type: "boolean",
29694             category: ts.Diagnostics.Module_Resolution_Options,
29695             description: ts.Diagnostics.Do_not_resolve_the_real_path_of_symlinks,
29696         },
29697         {
29698             name: "allowUmdGlobalAccess",
29699             type: "boolean",
29700             affectsSemanticDiagnostics: true,
29701             category: ts.Diagnostics.Module_Resolution_Options,
29702             description: ts.Diagnostics.Allow_accessing_UMD_globals_from_modules,
29703         },
29704         {
29705             name: "sourceRoot",
29706             type: "string",
29707             affectsEmit: true,
29708             paramType: ts.Diagnostics.LOCATION,
29709             category: ts.Diagnostics.Source_Map_Options,
29710             description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_TypeScript_files_instead_of_source_locations,
29711         },
29712         {
29713             name: "mapRoot",
29714             type: "string",
29715             affectsEmit: true,
29716             paramType: ts.Diagnostics.LOCATION,
29717             category: ts.Diagnostics.Source_Map_Options,
29718             description: ts.Diagnostics.Specify_the_location_where_debugger_should_locate_map_files_instead_of_generated_locations,
29719         },
29720         {
29721             name: "inlineSourceMap",
29722             type: "boolean",
29723             affectsEmit: true,
29724             category: ts.Diagnostics.Source_Map_Options,
29725             description: ts.Diagnostics.Emit_a_single_file_with_source_maps_instead_of_having_a_separate_file
29726         },
29727         {
29728             name: "inlineSources",
29729             type: "boolean",
29730             affectsEmit: true,
29731             category: ts.Diagnostics.Source_Map_Options,
29732             description: ts.Diagnostics.Emit_the_source_alongside_the_sourcemaps_within_a_single_file_requires_inlineSourceMap_or_sourceMap_to_be_set
29733         },
29734         {
29735             name: "experimentalDecorators",
29736             type: "boolean",
29737             affectsSemanticDiagnostics: true,
29738             category: ts.Diagnostics.Experimental_Options,
29739             description: ts.Diagnostics.Enables_experimental_support_for_ES7_decorators
29740         },
29741         {
29742             name: "emitDecoratorMetadata",
29743             type: "boolean",
29744             affectsSemanticDiagnostics: true,
29745             affectsEmit: true,
29746             category: ts.Diagnostics.Experimental_Options,
29747             description: ts.Diagnostics.Enables_experimental_support_for_emitting_type_metadata_for_decorators
29748         },
29749         {
29750             name: "jsxFactory",
29751             type: "string",
29752             category: ts.Diagnostics.Advanced_Options,
29753             description: ts.Diagnostics.Specify_the_JSX_factory_function_to_use_when_targeting_react_JSX_emit_e_g_React_createElement_or_h
29754         },
29755         {
29756             name: "jsxFragmentFactory",
29757             type: "string",
29758             category: ts.Diagnostics.Advanced_Options,
29759             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
29760         },
29761         {
29762             name: "jsxImportSource",
29763             type: "string",
29764             affectsSemanticDiagnostics: true,
29765             affectsEmit: true,
29766             affectsModuleResolution: true,
29767             category: ts.Diagnostics.Advanced_Options,
29768             description: ts.Diagnostics.Specify_the_module_specifier_to_be_used_to_import_the_jsx_and_jsxs_factory_functions_from_eg_react
29769         },
29770         {
29771             name: "resolveJsonModule",
29772             type: "boolean",
29773             affectsModuleResolution: true,
29774             category: ts.Diagnostics.Advanced_Options,
29775             description: ts.Diagnostics.Include_modules_imported_with_json_extension
29776         },
29777         {
29778             name: "out",
29779             type: "string",
29780             affectsEmit: true,
29781             isFilePath: false,
29782             category: ts.Diagnostics.Advanced_Options,
29783             paramType: ts.Diagnostics.FILE,
29784             description: ts.Diagnostics.Deprecated_Use_outFile_instead_Concatenate_and_emit_output_to_single_file,
29785             transpileOptionValue: undefined
29786         },
29787         {
29788             name: "reactNamespace",
29789             type: "string",
29790             affectsEmit: true,
29791             category: ts.Diagnostics.Advanced_Options,
29792             description: ts.Diagnostics.Deprecated_Use_jsxFactory_instead_Specify_the_object_invoked_for_createElement_when_targeting_react_JSX_emit
29793         },
29794         {
29795             name: "skipDefaultLibCheck",
29796             type: "boolean",
29797             category: ts.Diagnostics.Advanced_Options,
29798             description: ts.Diagnostics.Deprecated_Use_skipLibCheck_instead_Skip_type_checking_of_default_library_declaration_files
29799         },
29800         {
29801             name: "charset",
29802             type: "string",
29803             category: ts.Diagnostics.Advanced_Options,
29804             description: ts.Diagnostics.The_character_set_of_the_input_files
29805         },
29806         {
29807             name: "emitBOM",
29808             type: "boolean",
29809             affectsEmit: true,
29810             category: ts.Diagnostics.Advanced_Options,
29811             description: ts.Diagnostics.Emit_a_UTF_8_Byte_Order_Mark_BOM_in_the_beginning_of_output_files
29812         },
29813         {
29814             name: "newLine",
29815             type: new ts.Map(ts.getEntries({
29816                 crlf: 0,
29817                 lf: 1
29818             })),
29819             affectsEmit: true,
29820             paramType: ts.Diagnostics.NEWLINE,
29821             category: ts.Diagnostics.Advanced_Options,
29822             description: ts.Diagnostics.Specify_the_end_of_line_sequence_to_be_used_when_emitting_files_Colon_CRLF_dos_or_LF_unix,
29823         },
29824         {
29825             name: "noErrorTruncation",
29826             type: "boolean",
29827             affectsSemanticDiagnostics: true,
29828             category: ts.Diagnostics.Advanced_Options,
29829             description: ts.Diagnostics.Do_not_truncate_error_messages
29830         },
29831         {
29832             name: "noLib",
29833             type: "boolean",
29834             affectsModuleResolution: true,
29835             category: ts.Diagnostics.Advanced_Options,
29836             description: ts.Diagnostics.Do_not_include_the_default_library_file_lib_d_ts,
29837             transpileOptionValue: true
29838         },
29839         {
29840             name: "noResolve",
29841             type: "boolean",
29842             affectsModuleResolution: true,
29843             category: ts.Diagnostics.Advanced_Options,
29844             description: ts.Diagnostics.Do_not_add_triple_slash_references_or_imported_modules_to_the_list_of_compiled_files,
29845             transpileOptionValue: true
29846         },
29847         {
29848             name: "stripInternal",
29849             type: "boolean",
29850             affectsEmit: true,
29851             category: ts.Diagnostics.Advanced_Options,
29852             description: ts.Diagnostics.Do_not_emit_declarations_for_code_that_has_an_internal_annotation,
29853         },
29854         {
29855             name: "disableSizeLimit",
29856             type: "boolean",
29857             affectsSourceFile: true,
29858             category: ts.Diagnostics.Advanced_Options,
29859             description: ts.Diagnostics.Disable_size_limitations_on_JavaScript_projects
29860         },
29861         {
29862             name: "disableSourceOfProjectReferenceRedirect",
29863             type: "boolean",
29864             isTSConfigOnly: true,
29865             category: ts.Diagnostics.Advanced_Options,
29866             description: ts.Diagnostics.Disable_use_of_source_files_instead_of_declaration_files_from_referenced_projects
29867         },
29868         {
29869             name: "disableSolutionSearching",
29870             type: "boolean",
29871             isTSConfigOnly: true,
29872             category: ts.Diagnostics.Advanced_Options,
29873             description: ts.Diagnostics.Disable_solution_searching_for_this_project
29874         },
29875         {
29876             name: "disableReferencedProjectLoad",
29877             type: "boolean",
29878             isTSConfigOnly: true,
29879             category: ts.Diagnostics.Advanced_Options,
29880             description: ts.Diagnostics.Disable_loading_referenced_projects
29881         },
29882         {
29883             name: "noImplicitUseStrict",
29884             type: "boolean",
29885             affectsSemanticDiagnostics: true,
29886             category: ts.Diagnostics.Advanced_Options,
29887             description: ts.Diagnostics.Do_not_emit_use_strict_directives_in_module_output
29888         },
29889         {
29890             name: "noEmitHelpers",
29891             type: "boolean",
29892             affectsEmit: true,
29893             category: ts.Diagnostics.Advanced_Options,
29894             description: ts.Diagnostics.Do_not_generate_custom_helper_functions_like_extends_in_compiled_output
29895         },
29896         {
29897             name: "noEmitOnError",
29898             type: "boolean",
29899             affectsEmit: true,
29900             category: ts.Diagnostics.Advanced_Options,
29901             description: ts.Diagnostics.Do_not_emit_outputs_if_any_errors_were_reported,
29902             transpileOptionValue: undefined
29903         },
29904         {
29905             name: "preserveConstEnums",
29906             type: "boolean",
29907             affectsEmit: true,
29908             category: ts.Diagnostics.Advanced_Options,
29909             description: ts.Diagnostics.Do_not_erase_const_enum_declarations_in_generated_code
29910         },
29911         {
29912             name: "declarationDir",
29913             type: "string",
29914             affectsEmit: true,
29915             isFilePath: true,
29916             paramType: ts.Diagnostics.DIRECTORY,
29917             category: ts.Diagnostics.Advanced_Options,
29918             description: ts.Diagnostics.Output_directory_for_generated_declaration_files,
29919             transpileOptionValue: undefined
29920         },
29921         {
29922             name: "skipLibCheck",
29923             type: "boolean",
29924             category: ts.Diagnostics.Advanced_Options,
29925             description: ts.Diagnostics.Skip_type_checking_of_declaration_files,
29926         },
29927         {
29928             name: "allowUnusedLabels",
29929             type: "boolean",
29930             affectsBindDiagnostics: true,
29931             affectsSemanticDiagnostics: true,
29932             category: ts.Diagnostics.Advanced_Options,
29933             description: ts.Diagnostics.Do_not_report_errors_on_unused_labels
29934         },
29935         {
29936             name: "allowUnreachableCode",
29937             type: "boolean",
29938             affectsBindDiagnostics: true,
29939             affectsSemanticDiagnostics: true,
29940             category: ts.Diagnostics.Advanced_Options,
29941             description: ts.Diagnostics.Do_not_report_errors_on_unreachable_code
29942         },
29943         {
29944             name: "suppressExcessPropertyErrors",
29945             type: "boolean",
29946             affectsSemanticDiagnostics: true,
29947             category: ts.Diagnostics.Advanced_Options,
29948             description: ts.Diagnostics.Suppress_excess_property_checks_for_object_literals,
29949         },
29950         {
29951             name: "suppressImplicitAnyIndexErrors",
29952             type: "boolean",
29953             affectsSemanticDiagnostics: true,
29954             category: ts.Diagnostics.Advanced_Options,
29955             description: ts.Diagnostics.Suppress_noImplicitAny_errors_for_indexing_objects_lacking_index_signatures,
29956         },
29957         {
29958             name: "forceConsistentCasingInFileNames",
29959             type: "boolean",
29960             affectsModuleResolution: true,
29961             category: ts.Diagnostics.Advanced_Options,
29962             description: ts.Diagnostics.Disallow_inconsistently_cased_references_to_the_same_file
29963         },
29964         {
29965             name: "maxNodeModuleJsDepth",
29966             type: "number",
29967             affectsModuleResolution: true,
29968             category: ts.Diagnostics.Advanced_Options,
29969             description: ts.Diagnostics.The_maximum_dependency_depth_to_search_under_node_modules_and_load_JavaScript_files
29970         },
29971         {
29972             name: "noStrictGenericChecks",
29973             type: "boolean",
29974             affectsSemanticDiagnostics: true,
29975             category: ts.Diagnostics.Advanced_Options,
29976             description: ts.Diagnostics.Disable_strict_checking_of_generic_signatures_in_function_types,
29977         },
29978         {
29979             name: "useDefineForClassFields",
29980             type: "boolean",
29981             affectsSemanticDiagnostics: true,
29982             affectsEmit: true,
29983             category: ts.Diagnostics.Advanced_Options,
29984             description: ts.Diagnostics.Emit_class_fields_with_Define_instead_of_Set,
29985         },
29986         {
29987             name: "keyofStringsOnly",
29988             type: "boolean",
29989             category: ts.Diagnostics.Advanced_Options,
29990             description: ts.Diagnostics.Resolve_keyof_to_string_valued_property_names_only_no_numbers_or_symbols,
29991         },
29992         {
29993             name: "plugins",
29994             type: "list",
29995             isTSConfigOnly: true,
29996             element: {
29997                 name: "plugin",
29998                 type: "object"
29999             },
30000             description: ts.Diagnostics.List_of_language_service_plugins
30001         },
30002     ]);
30003     ts.semanticDiagnosticsOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsSemanticDiagnostics; });
30004     ts.affectsEmitOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsEmit; });
30005     ts.moduleResolutionOptionDeclarations = ts.optionDeclarations.filter(function (option) { return !!option.affectsModuleResolution; });
30006     ts.sourceFileAffectingCompilerOptions = ts.optionDeclarations.filter(function (option) {
30007         return !!option.affectsSourceFile || !!option.affectsModuleResolution || !!option.affectsBindDiagnostics;
30008     });
30009     ts.transpileOptionValueCompilerOptions = ts.optionDeclarations.filter(function (option) {
30010         return ts.hasProperty(option, "transpileOptionValue");
30011     });
30012     ts.buildOpts = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild), [
30013         {
30014             name: "verbose",
30015             shortName: "v",
30016             category: ts.Diagnostics.Command_line_Options,
30017             description: ts.Diagnostics.Enable_verbose_logging,
30018             type: "boolean"
30019         },
30020         {
30021             name: "dry",
30022             shortName: "d",
30023             category: ts.Diagnostics.Command_line_Options,
30024             description: ts.Diagnostics.Show_what_would_be_built_or_deleted_if_specified_with_clean,
30025             type: "boolean"
30026         },
30027         {
30028             name: "force",
30029             shortName: "f",
30030             category: ts.Diagnostics.Command_line_Options,
30031             description: ts.Diagnostics.Build_all_projects_including_those_that_appear_to_be_up_to_date,
30032             type: "boolean"
30033         },
30034         {
30035             name: "clean",
30036             category: ts.Diagnostics.Command_line_Options,
30037             description: ts.Diagnostics.Delete_the_outputs_of_all_projects,
30038             type: "boolean"
30039         }
30040     ]);
30041     ts.typeAcquisitionDeclarations = [
30042         {
30043             name: "enableAutoDiscovery",
30044             type: "boolean",
30045         },
30046         {
30047             name: "enable",
30048             type: "boolean",
30049         },
30050         {
30051             name: "include",
30052             type: "list",
30053             element: {
30054                 name: "include",
30055                 type: "string"
30056             }
30057         },
30058         {
30059             name: "exclude",
30060             type: "list",
30061             element: {
30062                 name: "exclude",
30063                 type: "string"
30064             }
30065         },
30066         {
30067             name: "disableFilenameBasedTypeAcquisition",
30068             type: "boolean",
30069         },
30070     ];
30071     function createOptionNameMap(optionDeclarations) {
30072         var optionsNameMap = new ts.Map();
30073         var shortOptionNames = new ts.Map();
30074         ts.forEach(optionDeclarations, function (option) {
30075             optionsNameMap.set(option.name.toLowerCase(), option);
30076             if (option.shortName) {
30077                 shortOptionNames.set(option.shortName, option.name);
30078             }
30079         });
30080         return { optionsNameMap: optionsNameMap, shortOptionNames: shortOptionNames };
30081     }
30082     ts.createOptionNameMap = createOptionNameMap;
30083     var optionsNameMapCache;
30084     function getOptionsNameMap() {
30085         return optionsNameMapCache || (optionsNameMapCache = createOptionNameMap(ts.optionDeclarations));
30086     }
30087     ts.getOptionsNameMap = getOptionsNameMap;
30088     ts.defaultInitCompilerOptions = {
30089         module: ts.ModuleKind.CommonJS,
30090         target: 1,
30091         strict: true,
30092         esModuleInterop: true,
30093         forceConsistentCasingInFileNames: true,
30094         skipLibCheck: true
30095     };
30096     function convertEnableAutoDiscoveryToEnable(typeAcquisition) {
30097         if (typeAcquisition && typeAcquisition.enableAutoDiscovery !== undefined && typeAcquisition.enable === undefined) {
30098             return {
30099                 enable: typeAcquisition.enableAutoDiscovery,
30100                 include: typeAcquisition.include || [],
30101                 exclude: typeAcquisition.exclude || []
30102             };
30103         }
30104         return typeAcquisition;
30105     }
30106     ts.convertEnableAutoDiscoveryToEnable = convertEnableAutoDiscoveryToEnable;
30107     function createCompilerDiagnosticForInvalidCustomType(opt) {
30108         return createDiagnosticForInvalidCustomType(opt, ts.createCompilerDiagnostic);
30109     }
30110     ts.createCompilerDiagnosticForInvalidCustomType = createCompilerDiagnosticForInvalidCustomType;
30111     function createDiagnosticForInvalidCustomType(opt, createDiagnostic) {
30112         var namesOfType = ts.arrayFrom(opt.type.keys()).map(function (key) { return "'" + key + "'"; }).join(", ");
30113         return createDiagnostic(ts.Diagnostics.Argument_for_0_option_must_be_Colon_1, "--" + opt.name, namesOfType);
30114     }
30115     function parseCustomTypeOption(opt, value, errors) {
30116         return convertJsonOptionOfCustomType(opt, trimString(value || ""), errors);
30117     }
30118     ts.parseCustomTypeOption = parseCustomTypeOption;
30119     function parseListTypeOption(opt, value, errors) {
30120         if (value === void 0) { value = ""; }
30121         value = trimString(value);
30122         if (ts.startsWith(value, "-")) {
30123             return undefined;
30124         }
30125         if (value === "") {
30126             return [];
30127         }
30128         var values = value.split(",");
30129         switch (opt.element.type) {
30130             case "number":
30131                 return ts.mapDefined(values, function (v) { return validateJsonOptionValue(opt.element, parseInt(v), errors); });
30132             case "string":
30133                 return ts.mapDefined(values, function (v) { return validateJsonOptionValue(opt.element, v || "", errors); });
30134             default:
30135                 return ts.mapDefined(values, function (v) { return parseCustomTypeOption(opt.element, v, errors); });
30136         }
30137     }
30138     ts.parseListTypeOption = parseListTypeOption;
30139     function getOptionName(option) {
30140         return option.name;
30141     }
30142     function createUnknownOptionError(unknownOption, diagnostics, createDiagnostics, unknownOptionErrorText) {
30143         var possibleOption = ts.getSpellingSuggestion(unknownOption, diagnostics.optionDeclarations, getOptionName);
30144         return possibleOption ?
30145             createDiagnostics(diagnostics.unknownDidYouMeanDiagnostic, unknownOptionErrorText || unknownOption, possibleOption.name) :
30146             createDiagnostics(diagnostics.unknownOptionDiagnostic, unknownOptionErrorText || unknownOption);
30147     }
30148     function parseCommandLineWorker(diagnostics, commandLine, readFile) {
30149         var options = {};
30150         var watchOptions;
30151         var fileNames = [];
30152         var errors = [];
30153         parseStrings(commandLine);
30154         return {
30155             options: options,
30156             watchOptions: watchOptions,
30157             fileNames: fileNames,
30158             errors: errors
30159         };
30160         function parseStrings(args) {
30161             var i = 0;
30162             while (i < args.length) {
30163                 var s = args[i];
30164                 i++;
30165                 if (s.charCodeAt(0) === 64) {
30166                     parseResponseFile(s.slice(1));
30167                 }
30168                 else if (s.charCodeAt(0) === 45) {
30169                     var inputOptionName = s.slice(s.charCodeAt(1) === 45 ? 2 : 1);
30170                     var opt = getOptionDeclarationFromName(diagnostics.getOptionsNameMap, inputOptionName, true);
30171                     if (opt) {
30172                         i = parseOptionValue(args, i, diagnostics, opt, options, errors);
30173                     }
30174                     else {
30175                         var watchOpt = getOptionDeclarationFromName(watchOptionsDidYouMeanDiagnostics.getOptionsNameMap, inputOptionName, true);
30176                         if (watchOpt) {
30177                             i = parseOptionValue(args, i, watchOptionsDidYouMeanDiagnostics, watchOpt, watchOptions || (watchOptions = {}), errors);
30178                         }
30179                         else {
30180                             errors.push(createUnknownOptionError(inputOptionName, diagnostics, ts.createCompilerDiagnostic, s));
30181                         }
30182                     }
30183                 }
30184                 else {
30185                     fileNames.push(s);
30186                 }
30187             }
30188         }
30189         function parseResponseFile(fileName) {
30190             var text = tryReadFile(fileName, readFile || (function (fileName) { return ts.sys.readFile(fileName); }));
30191             if (!ts.isString(text)) {
30192                 errors.push(text);
30193                 return;
30194             }
30195             var args = [];
30196             var pos = 0;
30197             while (true) {
30198                 while (pos < text.length && text.charCodeAt(pos) <= 32)
30199                     pos++;
30200                 if (pos >= text.length)
30201                     break;
30202                 var start = pos;
30203                 if (text.charCodeAt(start) === 34) {
30204                     pos++;
30205                     while (pos < text.length && text.charCodeAt(pos) !== 34)
30206                         pos++;
30207                     if (pos < text.length) {
30208                         args.push(text.substring(start + 1, pos));
30209                         pos++;
30210                     }
30211                     else {
30212                         errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unterminated_quoted_string_in_response_file_0, fileName));
30213                     }
30214                 }
30215                 else {
30216                     while (text.charCodeAt(pos) > 32)
30217                         pos++;
30218                     args.push(text.substring(start, pos));
30219                 }
30220             }
30221             parseStrings(args);
30222         }
30223     }
30224     ts.parseCommandLineWorker = parseCommandLineWorker;
30225     function parseOptionValue(args, i, diagnostics, opt, options, errors) {
30226         if (opt.isTSConfigOnly) {
30227             var optValue = args[i];
30228             if (optValue === "null") {
30229                 options[opt.name] = undefined;
30230                 i++;
30231             }
30232             else if (opt.type === "boolean") {
30233                 if (optValue === "false") {
30234                     options[opt.name] = validateJsonOptionValue(opt, false, errors);
30235                     i++;
30236                 }
30237                 else {
30238                     if (optValue === "true")
30239                         i++;
30240                     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));
30241                 }
30242             }
30243             else {
30244                 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));
30245                 if (optValue && !ts.startsWith(optValue, "-"))
30246                     i++;
30247             }
30248         }
30249         else {
30250             if (!args[i] && opt.type !== "boolean") {
30251                 errors.push(ts.createCompilerDiagnostic(diagnostics.optionTypeMismatchDiagnostic, opt.name, getCompilerOptionValueTypeString(opt)));
30252             }
30253             if (args[i] !== "null") {
30254                 switch (opt.type) {
30255                     case "number":
30256                         options[opt.name] = validateJsonOptionValue(opt, parseInt(args[i]), errors);
30257                         i++;
30258                         break;
30259                     case "boolean":
30260                         var optValue = args[i];
30261                         options[opt.name] = validateJsonOptionValue(opt, optValue !== "false", errors);
30262                         if (optValue === "false" || optValue === "true") {
30263                             i++;
30264                         }
30265                         break;
30266                     case "string":
30267                         options[opt.name] = validateJsonOptionValue(opt, args[i] || "", errors);
30268                         i++;
30269                         break;
30270                     case "list":
30271                         var result = parseListTypeOption(opt, args[i], errors);
30272                         options[opt.name] = result || [];
30273                         if (result) {
30274                             i++;
30275                         }
30276                         break;
30277                     default:
30278                         options[opt.name] = parseCustomTypeOption(opt, args[i], errors);
30279                         i++;
30280                         break;
30281                 }
30282             }
30283             else {
30284                 options[opt.name] = undefined;
30285                 i++;
30286             }
30287         }
30288         return i;
30289     }
30290     ts.compilerOptionsDidYouMeanDiagnostics = {
30291         getOptionsNameMap: getOptionsNameMap,
30292         optionDeclarations: ts.optionDeclarations,
30293         unknownOptionDiagnostic: ts.Diagnostics.Unknown_compiler_option_0,
30294         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_compiler_option_0_Did_you_mean_1,
30295         optionTypeMismatchDiagnostic: ts.Diagnostics.Compiler_option_0_expects_an_argument
30296     };
30297     function parseCommandLine(commandLine, readFile) {
30298         return parseCommandLineWorker(ts.compilerOptionsDidYouMeanDiagnostics, commandLine, readFile);
30299     }
30300     ts.parseCommandLine = parseCommandLine;
30301     function getOptionFromName(optionName, allowShort) {
30302         return getOptionDeclarationFromName(getOptionsNameMap, optionName, allowShort);
30303     }
30304     ts.getOptionFromName = getOptionFromName;
30305     function getOptionDeclarationFromName(getOptionNameMap, optionName, allowShort) {
30306         if (allowShort === void 0) { allowShort = false; }
30307         optionName = optionName.toLowerCase();
30308         var _a = getOptionNameMap(), optionsNameMap = _a.optionsNameMap, shortOptionNames = _a.shortOptionNames;
30309         if (allowShort) {
30310             var short = shortOptionNames.get(optionName);
30311             if (short !== undefined) {
30312                 optionName = short;
30313             }
30314         }
30315         return optionsNameMap.get(optionName);
30316     }
30317     var buildOptionsNameMapCache;
30318     function getBuildOptionsNameMap() {
30319         return buildOptionsNameMapCache || (buildOptionsNameMapCache = createOptionNameMap(ts.buildOpts));
30320     }
30321     var buildOptionsDidYouMeanDiagnostics = {
30322         getOptionsNameMap: getBuildOptionsNameMap,
30323         optionDeclarations: ts.buildOpts,
30324         unknownOptionDiagnostic: ts.Diagnostics.Unknown_build_option_0,
30325         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_build_option_0_Did_you_mean_1,
30326         optionTypeMismatchDiagnostic: ts.Diagnostics.Build_option_0_requires_a_value_of_type_1
30327     };
30328     function parseBuildCommand(args) {
30329         var _a = parseCommandLineWorker(buildOptionsDidYouMeanDiagnostics, args), options = _a.options, watchOptions = _a.watchOptions, projects = _a.fileNames, errors = _a.errors;
30330         var buildOptions = options;
30331         if (projects.length === 0) {
30332             projects.push(".");
30333         }
30334         if (buildOptions.clean && buildOptions.force) {
30335             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "force"));
30336         }
30337         if (buildOptions.clean && buildOptions.verbose) {
30338             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "verbose"));
30339         }
30340         if (buildOptions.clean && buildOptions.watch) {
30341             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "clean", "watch"));
30342         }
30343         if (buildOptions.watch && buildOptions.dry) {
30344             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "watch", "dry"));
30345         }
30346         return { buildOptions: buildOptions, watchOptions: watchOptions, projects: projects, errors: errors };
30347     }
30348     ts.parseBuildCommand = parseBuildCommand;
30349     function getDiagnosticText(_message) {
30350         var _args = [];
30351         for (var _i = 1; _i < arguments.length; _i++) {
30352             _args[_i - 1] = arguments[_i];
30353         }
30354         var diagnostic = ts.createCompilerDiagnostic.apply(undefined, arguments);
30355         return diagnostic.messageText;
30356     }
30357     ts.getDiagnosticText = getDiagnosticText;
30358     function getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, extendedConfigCache, watchOptionsToExtend, extraFileExtensions) {
30359         var configFileText = tryReadFile(configFileName, function (fileName) { return host.readFile(fileName); });
30360         if (!ts.isString(configFileText)) {
30361             host.onUnRecoverableConfigFileDiagnostic(configFileText);
30362             return undefined;
30363         }
30364         var result = ts.parseJsonText(configFileName, configFileText);
30365         var cwd = host.getCurrentDirectory();
30366         result.path = ts.toPath(configFileName, cwd, ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames));
30367         result.resolvedPath = result.path;
30368         result.originalFileName = result.fileName;
30369         return parseJsonSourceFileConfigFileContent(result, host, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), cwd), optionsToExtend, ts.getNormalizedAbsolutePath(configFileName, cwd), undefined, extraFileExtensions, extendedConfigCache, watchOptionsToExtend);
30370     }
30371     ts.getParsedCommandLineOfConfigFile = getParsedCommandLineOfConfigFile;
30372     function readConfigFile(fileName, readFile) {
30373         var textOrDiagnostic = tryReadFile(fileName, readFile);
30374         return ts.isString(textOrDiagnostic) ? parseConfigFileTextToJson(fileName, textOrDiagnostic) : { config: {}, error: textOrDiagnostic };
30375     }
30376     ts.readConfigFile = readConfigFile;
30377     function parseConfigFileTextToJson(fileName, jsonText) {
30378         var jsonSourceFile = ts.parseJsonText(fileName, jsonText);
30379         return {
30380             config: convertToObject(jsonSourceFile, jsonSourceFile.parseDiagnostics),
30381             error: jsonSourceFile.parseDiagnostics.length ? jsonSourceFile.parseDiagnostics[0] : undefined
30382         };
30383     }
30384     ts.parseConfigFileTextToJson = parseConfigFileTextToJson;
30385     function readJsonConfigFile(fileName, readFile) {
30386         var textOrDiagnostic = tryReadFile(fileName, readFile);
30387         return ts.isString(textOrDiagnostic) ? ts.parseJsonText(fileName, textOrDiagnostic) : { fileName: fileName, parseDiagnostics: [textOrDiagnostic] };
30388     }
30389     ts.readJsonConfigFile = readJsonConfigFile;
30390     function tryReadFile(fileName, readFile) {
30391         var text;
30392         try {
30393             text = readFile(fileName);
30394         }
30395         catch (e) {
30396             return ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0_Colon_1, fileName, e.message);
30397         }
30398         return text === undefined ? ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_read_file_0, fileName) : text;
30399     }
30400     ts.tryReadFile = tryReadFile;
30401     function commandLineOptionsToMap(options) {
30402         return ts.arrayToMap(options, getOptionName);
30403     }
30404     var typeAcquisitionDidYouMeanDiagnostics = {
30405         optionDeclarations: ts.typeAcquisitionDeclarations,
30406         unknownOptionDiagnostic: ts.Diagnostics.Unknown_type_acquisition_option_0,
30407         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_type_acquisition_option_0_Did_you_mean_1,
30408     };
30409     var watchOptionsNameMapCache;
30410     function getWatchOptionsNameMap() {
30411         return watchOptionsNameMapCache || (watchOptionsNameMapCache = createOptionNameMap(ts.optionsForWatch));
30412     }
30413     var watchOptionsDidYouMeanDiagnostics = {
30414         getOptionsNameMap: getWatchOptionsNameMap,
30415         optionDeclarations: ts.optionsForWatch,
30416         unknownOptionDiagnostic: ts.Diagnostics.Unknown_watch_option_0,
30417         unknownDidYouMeanDiagnostic: ts.Diagnostics.Unknown_watch_option_0_Did_you_mean_1,
30418         optionTypeMismatchDiagnostic: ts.Diagnostics.Watch_option_0_requires_a_value_of_type_1
30419     };
30420     var commandLineCompilerOptionsMapCache;
30421     function getCommandLineCompilerOptionsMap() {
30422         return commandLineCompilerOptionsMapCache || (commandLineCompilerOptionsMapCache = commandLineOptionsToMap(ts.optionDeclarations));
30423     }
30424     var commandLineWatchOptionsMapCache;
30425     function getCommandLineWatchOptionsMap() {
30426         return commandLineWatchOptionsMapCache || (commandLineWatchOptionsMapCache = commandLineOptionsToMap(ts.optionsForWatch));
30427     }
30428     var commandLineTypeAcquisitionMapCache;
30429     function getCommandLineTypeAcquisitionMap() {
30430         return commandLineTypeAcquisitionMapCache || (commandLineTypeAcquisitionMapCache = commandLineOptionsToMap(ts.typeAcquisitionDeclarations));
30431     }
30432     var _tsconfigRootOptions;
30433     function getTsconfigRootOptionsMap() {
30434         if (_tsconfigRootOptions === undefined) {
30435             _tsconfigRootOptions = {
30436                 name: undefined,
30437                 type: "object",
30438                 elementOptions: commandLineOptionsToMap([
30439                     {
30440                         name: "compilerOptions",
30441                         type: "object",
30442                         elementOptions: getCommandLineCompilerOptionsMap(),
30443                         extraKeyDiagnostics: ts.compilerOptionsDidYouMeanDiagnostics,
30444                     },
30445                     {
30446                         name: "watchOptions",
30447                         type: "object",
30448                         elementOptions: getCommandLineWatchOptionsMap(),
30449                         extraKeyDiagnostics: watchOptionsDidYouMeanDiagnostics,
30450                     },
30451                     {
30452                         name: "typingOptions",
30453                         type: "object",
30454                         elementOptions: getCommandLineTypeAcquisitionMap(),
30455                         extraKeyDiagnostics: typeAcquisitionDidYouMeanDiagnostics,
30456                     },
30457                     {
30458                         name: "typeAcquisition",
30459                         type: "object",
30460                         elementOptions: getCommandLineTypeAcquisitionMap(),
30461                         extraKeyDiagnostics: typeAcquisitionDidYouMeanDiagnostics
30462                     },
30463                     {
30464                         name: "extends",
30465                         type: "string"
30466                     },
30467                     {
30468                         name: "references",
30469                         type: "list",
30470                         element: {
30471                             name: "references",
30472                             type: "object"
30473                         }
30474                     },
30475                     {
30476                         name: "files",
30477                         type: "list",
30478                         element: {
30479                             name: "files",
30480                             type: "string"
30481                         }
30482                     },
30483                     {
30484                         name: "include",
30485                         type: "list",
30486                         element: {
30487                             name: "include",
30488                             type: "string"
30489                         }
30490                     },
30491                     {
30492                         name: "exclude",
30493                         type: "list",
30494                         element: {
30495                             name: "exclude",
30496                             type: "string"
30497                         }
30498                     },
30499                     ts.compileOnSaveCommandLineOption
30500                 ])
30501             };
30502         }
30503         return _tsconfigRootOptions;
30504     }
30505     function convertToObject(sourceFile, errors) {
30506         return convertToObjectWorker(sourceFile, errors, true, undefined, undefined);
30507     }
30508     ts.convertToObject = convertToObject;
30509     function convertToObjectWorker(sourceFile, errors, returnValue, knownRootOptions, jsonConversionNotifier) {
30510         if (!sourceFile.statements.length) {
30511             return returnValue ? {} : undefined;
30512         }
30513         return convertPropertyValueToJson(sourceFile.statements[0].expression, knownRootOptions);
30514         function isRootOptionMap(knownOptions) {
30515             return knownRootOptions && knownRootOptions.elementOptions === knownOptions;
30516         }
30517         function convertObjectLiteralExpressionToJson(node, knownOptions, extraKeyDiagnostics, parentOption) {
30518             var result = returnValue ? {} : undefined;
30519             var _loop_4 = function (element) {
30520                 if (element.kind !== 288) {
30521                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element, ts.Diagnostics.Property_assignment_expected));
30522                     return "continue";
30523                 }
30524                 if (element.questionToken) {
30525                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.questionToken, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?"));
30526                 }
30527                 if (!isDoubleQuotedString(element.name)) {
30528                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, ts.Diagnostics.String_literal_with_double_quotes_expected));
30529                 }
30530                 var textOfKey = ts.isComputedNonLiteralName(element.name) ? undefined : ts.getTextOfPropertyName(element.name);
30531                 var keyText = textOfKey && ts.unescapeLeadingUnderscores(textOfKey);
30532                 var option = keyText && knownOptions ? knownOptions.get(keyText) : undefined;
30533                 if (keyText && extraKeyDiagnostics && !option) {
30534                     if (knownOptions) {
30535                         errors.push(createUnknownOptionError(keyText, extraKeyDiagnostics, function (message, arg0, arg1) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, message, arg0, arg1); }));
30536                     }
30537                     else {
30538                         errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, element.name, extraKeyDiagnostics.unknownOptionDiagnostic, keyText));
30539                     }
30540                 }
30541                 var value = convertPropertyValueToJson(element.initializer, option);
30542                 if (typeof keyText !== "undefined") {
30543                     if (returnValue) {
30544                         result[keyText] = value;
30545                     }
30546                     if (jsonConversionNotifier &&
30547                         (parentOption || isRootOptionMap(knownOptions))) {
30548                         var isValidOptionValue = isCompilerOptionsValue(option, value);
30549                         if (parentOption) {
30550                             if (isValidOptionValue) {
30551                                 jsonConversionNotifier.onSetValidOptionKeyValueInParent(parentOption, option, value);
30552                             }
30553                         }
30554                         else if (isRootOptionMap(knownOptions)) {
30555                             if (isValidOptionValue) {
30556                                 jsonConversionNotifier.onSetValidOptionKeyValueInRoot(keyText, element.name, value, element.initializer);
30557                             }
30558                             else if (!option) {
30559                                 jsonConversionNotifier.onSetUnknownOptionKeyValueInRoot(keyText, element.name, value, element.initializer);
30560                             }
30561                         }
30562                     }
30563                 }
30564             };
30565             for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
30566                 var element = _a[_i];
30567                 _loop_4(element);
30568             }
30569             return result;
30570         }
30571         function convertArrayLiteralExpressionToJson(elements, elementOption) {
30572             if (!returnValue) {
30573                 elements.forEach(function (element) { return convertPropertyValueToJson(element, elementOption); });
30574                 return undefined;
30575             }
30576             return ts.filter(elements.map(function (element) { return convertPropertyValueToJson(element, elementOption); }), function (v) { return v !== undefined; });
30577         }
30578         function convertPropertyValueToJson(valueExpression, option) {
30579             var invalidReported;
30580             switch (valueExpression.kind) {
30581                 case 109:
30582                     reportInvalidOptionValue(option && option.type !== "boolean");
30583                     return validateValue(true);
30584                 case 94:
30585                     reportInvalidOptionValue(option && option.type !== "boolean");
30586                     return validateValue(false);
30587                 case 103:
30588                     reportInvalidOptionValue(option && option.name === "extends");
30589                     return validateValue(null);
30590                 case 10:
30591                     if (!isDoubleQuotedString(valueExpression)) {
30592                         errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.String_literal_with_double_quotes_expected));
30593                     }
30594                     reportInvalidOptionValue(option && (ts.isString(option.type) && option.type !== "string"));
30595                     var text = valueExpression.text;
30596                     if (option && !ts.isString(option.type)) {
30597                         var customOption = option;
30598                         if (!customOption.type.has(text.toLowerCase())) {
30599                             errors.push(createDiagnosticForInvalidCustomType(customOption, function (message, arg0, arg1) { return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, message, arg0, arg1); }));
30600                             invalidReported = true;
30601                         }
30602                     }
30603                     return validateValue(text);
30604                 case 8:
30605                     reportInvalidOptionValue(option && option.type !== "number");
30606                     return validateValue(Number(valueExpression.text));
30607                 case 214:
30608                     if (valueExpression.operator !== 40 || valueExpression.operand.kind !== 8) {
30609                         break;
30610                     }
30611                     reportInvalidOptionValue(option && option.type !== "number");
30612                     return validateValue(-Number(valueExpression.operand.text));
30613                 case 200:
30614                     reportInvalidOptionValue(option && option.type !== "object");
30615                     var objectLiteralExpression = valueExpression;
30616                     if (option) {
30617                         var _a = option, elementOptions = _a.elementOptions, extraKeyDiagnostics = _a.extraKeyDiagnostics, optionName = _a.name;
30618                         return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, elementOptions, extraKeyDiagnostics, optionName));
30619                     }
30620                     else {
30621                         return validateValue(convertObjectLiteralExpressionToJson(objectLiteralExpression, undefined, undefined, undefined));
30622                     }
30623                 case 199:
30624                     reportInvalidOptionValue(option && option.type !== "list");
30625                     return validateValue(convertArrayLiteralExpressionToJson(valueExpression.elements, option && option.element));
30626             }
30627             if (option) {
30628                 reportInvalidOptionValue(true);
30629             }
30630             else {
30631                 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));
30632             }
30633             return undefined;
30634             function validateValue(value) {
30635                 var _a;
30636                 if (!invalidReported) {
30637                     var diagnostic = (_a = option === null || option === void 0 ? void 0 : option.extraValidation) === null || _a === void 0 ? void 0 : _a.call(option, value);
30638                     if (diagnostic) {
30639                         errors.push(ts.createDiagnosticForNodeInSourceFile.apply(void 0, __spreadArray([sourceFile, valueExpression], diagnostic)));
30640                         return undefined;
30641                     }
30642                 }
30643                 return value;
30644             }
30645             function reportInvalidOptionValue(isError) {
30646                 if (isError) {
30647                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, valueExpression, ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, option.name, getCompilerOptionValueTypeString(option)));
30648                     invalidReported = true;
30649                 }
30650             }
30651         }
30652         function isDoubleQuotedString(node) {
30653             return ts.isStringLiteral(node) && ts.isStringDoubleQuoted(node, sourceFile);
30654         }
30655     }
30656     ts.convertToObjectWorker = convertToObjectWorker;
30657     function getCompilerOptionValueTypeString(option) {
30658         return option.type === "list" ?
30659             "Array" :
30660             ts.isString(option.type) ? option.type : "string";
30661     }
30662     function isCompilerOptionsValue(option, value) {
30663         if (option) {
30664             if (isNullOrUndefined(value))
30665                 return true;
30666             if (option.type === "list") {
30667                 return ts.isArray(value);
30668             }
30669             var expectedType = ts.isString(option.type) ? option.type : "string";
30670             return typeof value === expectedType;
30671         }
30672         return false;
30673     }
30674     function convertToTSConfig(configParseResult, configFileName, host) {
30675         var _a, _b, _c;
30676         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames);
30677         var files = ts.map(ts.filter(configParseResult.fileNames, !((_b = (_a = configParseResult.options.configFile) === null || _a === void 0 ? void 0 : _a.configFileSpecs) === null || _b === void 0 ? void 0 : _b.validatedIncludeSpecs) ? ts.returnTrue : matchesSpecs(configFileName, configParseResult.options.configFile.configFileSpecs.validatedIncludeSpecs, configParseResult.options.configFile.configFileSpecs.validatedExcludeSpecs, host)), function (f) { return ts.getRelativePathFromFile(ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), ts.getNormalizedAbsolutePath(f, host.getCurrentDirectory()), getCanonicalFileName); });
30678         var optionMap = serializeCompilerOptions(configParseResult.options, { configFilePath: ts.getNormalizedAbsolutePath(configFileName, host.getCurrentDirectory()), useCaseSensitiveFileNames: host.useCaseSensitiveFileNames });
30679         var watchOptionMap = configParseResult.watchOptions && serializeWatchOptions(configParseResult.watchOptions);
30680         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 }, (((_c = configParseResult.options.configFile) === null || _c === void 0 ? void 0 : _c.configFileSpecs) ? {
30681             include: filterSameAsDefaultInclude(configParseResult.options.configFile.configFileSpecs.validatedIncludeSpecs),
30682             exclude: configParseResult.options.configFile.configFileSpecs.validatedExcludeSpecs
30683         } : {})), { compileOnSave: !!configParseResult.compileOnSave ? true : undefined });
30684         return config;
30685     }
30686     ts.convertToTSConfig = convertToTSConfig;
30687     function optionMapToObject(optionMap) {
30688         return __assign({}, ts.arrayFrom(optionMap.entries()).reduce(function (prev, cur) {
30689             var _a;
30690             return (__assign(__assign({}, prev), (_a = {}, _a[cur[0]] = cur[1], _a)));
30691         }, {}));
30692     }
30693     function filterSameAsDefaultInclude(specs) {
30694         if (!ts.length(specs))
30695             return undefined;
30696         if (ts.length(specs) !== 1)
30697             return specs;
30698         if (specs[0] === "**/*")
30699             return undefined;
30700         return specs;
30701     }
30702     function matchesSpecs(path, includeSpecs, excludeSpecs, host) {
30703         if (!includeSpecs)
30704             return ts.returnTrue;
30705         var patterns = ts.getFileMatcherPatterns(path, excludeSpecs, includeSpecs, host.useCaseSensitiveFileNames, host.getCurrentDirectory());
30706         var excludeRe = patterns.excludePattern && ts.getRegexFromPattern(patterns.excludePattern, host.useCaseSensitiveFileNames);
30707         var includeRe = patterns.includeFilePattern && ts.getRegexFromPattern(patterns.includeFilePattern, host.useCaseSensitiveFileNames);
30708         if (includeRe) {
30709             if (excludeRe) {
30710                 return function (path) { return !(includeRe.test(path) && !excludeRe.test(path)); };
30711             }
30712             return function (path) { return !includeRe.test(path); };
30713         }
30714         if (excludeRe) {
30715             return function (path) { return excludeRe.test(path); };
30716         }
30717         return ts.returnTrue;
30718     }
30719     function getCustomTypeMapOfCommandLineOption(optionDefinition) {
30720         if (optionDefinition.type === "string" || optionDefinition.type === "number" || optionDefinition.type === "boolean" || optionDefinition.type === "object") {
30721             return undefined;
30722         }
30723         else if (optionDefinition.type === "list") {
30724             return getCustomTypeMapOfCommandLineOption(optionDefinition.element);
30725         }
30726         else {
30727             return optionDefinition.type;
30728         }
30729     }
30730     function getNameOfCompilerOptionValue(value, customTypeMap) {
30731         return ts.forEachEntry(customTypeMap, function (mapValue, key) {
30732             if (mapValue === value) {
30733                 return key;
30734             }
30735         });
30736     }
30737     function serializeCompilerOptions(options, pathOptions) {
30738         return serializeOptionBaseObject(options, getOptionsNameMap(), pathOptions);
30739     }
30740     function serializeWatchOptions(options) {
30741         return serializeOptionBaseObject(options, getWatchOptionsNameMap());
30742     }
30743     function serializeOptionBaseObject(options, _a, pathOptions) {
30744         var optionsNameMap = _a.optionsNameMap;
30745         var result = new ts.Map();
30746         var getCanonicalFileName = pathOptions && ts.createGetCanonicalFileName(pathOptions.useCaseSensitiveFileNames);
30747         var _loop_5 = function (name) {
30748             if (ts.hasProperty(options, name)) {
30749                 if (optionsNameMap.has(name) && optionsNameMap.get(name).category === ts.Diagnostics.Command_line_Options) {
30750                     return "continue";
30751                 }
30752                 var value = options[name];
30753                 var optionDefinition = optionsNameMap.get(name.toLowerCase());
30754                 if (optionDefinition) {
30755                     var customTypeMap_1 = getCustomTypeMapOfCommandLineOption(optionDefinition);
30756                     if (!customTypeMap_1) {
30757                         if (pathOptions && optionDefinition.isFilePath) {
30758                             result.set(name, ts.getRelativePathFromFile(pathOptions.configFilePath, ts.getNormalizedAbsolutePath(value, ts.getDirectoryPath(pathOptions.configFilePath)), getCanonicalFileName));
30759                         }
30760                         else {
30761                             result.set(name, value);
30762                         }
30763                     }
30764                     else {
30765                         if (optionDefinition.type === "list") {
30766                             result.set(name, value.map(function (element) { return getNameOfCompilerOptionValue(element, customTypeMap_1); }));
30767                         }
30768                         else {
30769                             result.set(name, getNameOfCompilerOptionValue(value, customTypeMap_1));
30770                         }
30771                     }
30772                 }
30773             }
30774         };
30775         for (var name in options) {
30776             _loop_5(name);
30777         }
30778         return result;
30779     }
30780     function generateTSConfig(options, fileNames, newLine) {
30781         var compilerOptions = ts.extend(options, ts.defaultInitCompilerOptions);
30782         var compilerOptionsMap = serializeCompilerOptions(compilerOptions);
30783         return writeConfigurations();
30784         function getDefaultValueForOption(option) {
30785             switch (option.type) {
30786                 case "number":
30787                     return 1;
30788                 case "boolean":
30789                     return true;
30790                 case "string":
30791                     return option.isFilePath ? "./" : "";
30792                 case "list":
30793                     return [];
30794                 case "object":
30795                     return {};
30796                 default:
30797                     var iterResult = option.type.keys().next();
30798                     if (!iterResult.done)
30799                         return iterResult.value;
30800                     return ts.Debug.fail("Expected 'option.type' to have entries.");
30801             }
30802         }
30803         function makePadding(paddingLength) {
30804             return Array(paddingLength + 1).join(" ");
30805         }
30806         function isAllowedOption(_a) {
30807             var category = _a.category, name = _a.name;
30808             return category !== undefined
30809                 && category !== ts.Diagnostics.Command_line_Options
30810                 && (category !== ts.Diagnostics.Advanced_Options || compilerOptionsMap.has(name));
30811         }
30812         function writeConfigurations() {
30813             var categorizedOptions = ts.createMultiMap();
30814             for (var _i = 0, optionDeclarations_1 = ts.optionDeclarations; _i < optionDeclarations_1.length; _i++) {
30815                 var option = optionDeclarations_1[_i];
30816                 var category = option.category;
30817                 if (isAllowedOption(option)) {
30818                     categorizedOptions.add(ts.getLocaleSpecificMessage(category), option);
30819                 }
30820             }
30821             var marginLength = 0;
30822             var seenKnownKeys = 0;
30823             var entries = [];
30824             categorizedOptions.forEach(function (options, category) {
30825                 if (entries.length !== 0) {
30826                     entries.push({ value: "" });
30827                 }
30828                 entries.push({ value: "/* " + category + " */" });
30829                 for (var _i = 0, options_1 = options; _i < options_1.length; _i++) {
30830                     var option = options_1[_i];
30831                     var optionName = void 0;
30832                     if (compilerOptionsMap.has(option.name)) {
30833                         optionName = "\"" + option.name + "\": " + JSON.stringify(compilerOptionsMap.get(option.name)) + ((seenKnownKeys += 1) === compilerOptionsMap.size ? "" : ",");
30834                     }
30835                     else {
30836                         optionName = "// \"" + option.name + "\": " + JSON.stringify(getDefaultValueForOption(option)) + ",";
30837                     }
30838                     entries.push({
30839                         value: optionName,
30840                         description: "/* " + (option.description && ts.getLocaleSpecificMessage(option.description) || option.name) + " */"
30841                     });
30842                     marginLength = Math.max(optionName.length, marginLength);
30843                 }
30844             });
30845             var tab = makePadding(2);
30846             var result = [];
30847             result.push("{");
30848             result.push(tab + "\"compilerOptions\": {");
30849             result.push("" + tab + tab + "/* " + ts.getLocaleSpecificMessage(ts.Diagnostics.Visit_https_Colon_Slash_Slashaka_ms_Slashtsconfig_json_to_read_more_about_this_file) + " */");
30850             result.push("");
30851             for (var _a = 0, entries_2 = entries; _a < entries_2.length; _a++) {
30852                 var entry = entries_2[_a];
30853                 var value = entry.value, _b = entry.description, description = _b === void 0 ? "" : _b;
30854                 result.push(value && "" + tab + tab + value + (description && (makePadding(marginLength - value.length + 2) + description)));
30855             }
30856             if (fileNames.length) {
30857                 result.push(tab + "},");
30858                 result.push(tab + "\"files\": [");
30859                 for (var i = 0; i < fileNames.length; i++) {
30860                     result.push("" + tab + tab + JSON.stringify(fileNames[i]) + (i === fileNames.length - 1 ? "" : ","));
30861                 }
30862                 result.push(tab + "]");
30863             }
30864             else {
30865                 result.push(tab + "}");
30866             }
30867             result.push("}");
30868             return result.join(newLine) + newLine;
30869         }
30870     }
30871     ts.generateTSConfig = generateTSConfig;
30872     function convertToOptionsWithAbsolutePaths(options, toAbsolutePath) {
30873         var result = {};
30874         var optionsNameMap = getOptionsNameMap().optionsNameMap;
30875         for (var name in options) {
30876             if (ts.hasProperty(options, name)) {
30877                 result[name] = convertToOptionValueWithAbsolutePaths(optionsNameMap.get(name.toLowerCase()), options[name], toAbsolutePath);
30878             }
30879         }
30880         if (result.configFilePath) {
30881             result.configFilePath = toAbsolutePath(result.configFilePath);
30882         }
30883         return result;
30884     }
30885     ts.convertToOptionsWithAbsolutePaths = convertToOptionsWithAbsolutePaths;
30886     function convertToOptionValueWithAbsolutePaths(option, value, toAbsolutePath) {
30887         if (option && !isNullOrUndefined(value)) {
30888             if (option.type === "list") {
30889                 var values = value;
30890                 if (option.element.isFilePath && values.length) {
30891                     return values.map(toAbsolutePath);
30892                 }
30893             }
30894             else if (option.isFilePath) {
30895                 return toAbsolutePath(value);
30896             }
30897         }
30898         return value;
30899     }
30900     function parseJsonConfigFileContent(json, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
30901         return parseJsonConfigFileContentWorker(json, undefined, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
30902     }
30903     ts.parseJsonConfigFileContent = parseJsonConfigFileContent;
30904     function parseJsonSourceFileConfigFileContent(sourceFile, host, basePath, existingOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache, existingWatchOptions) {
30905         return parseJsonConfigFileContentWorker(undefined, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache);
30906     }
30907     ts.parseJsonSourceFileConfigFileContent = parseJsonSourceFileConfigFileContent;
30908     function setConfigFileInOptions(options, configFile) {
30909         if (configFile) {
30910             Object.defineProperty(options, "configFile", { enumerable: false, writable: false, value: configFile });
30911         }
30912     }
30913     ts.setConfigFileInOptions = setConfigFileInOptions;
30914     function isNullOrUndefined(x) {
30915         return x === undefined || x === null;
30916     }
30917     function directoryOfCombinedPath(fileName, basePath) {
30918         return ts.getDirectoryPath(ts.getNormalizedAbsolutePath(fileName, basePath));
30919     }
30920     function parseJsonConfigFileContentWorker(json, sourceFile, host, basePath, existingOptions, existingWatchOptions, configFileName, resolutionStack, extraFileExtensions, extendedConfigCache) {
30921         if (existingOptions === void 0) { existingOptions = {}; }
30922         if (resolutionStack === void 0) { resolutionStack = []; }
30923         if (extraFileExtensions === void 0) { extraFileExtensions = []; }
30924         ts.Debug.assert((json === undefined && sourceFile !== undefined) || (json !== undefined && sourceFile === undefined));
30925         var errors = [];
30926         var parsedConfig = parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors, extendedConfigCache);
30927         var raw = parsedConfig.raw;
30928         var options = ts.extend(existingOptions, parsedConfig.options || {});
30929         var watchOptions = existingWatchOptions && parsedConfig.watchOptions ?
30930             ts.extend(existingWatchOptions, parsedConfig.watchOptions) :
30931             parsedConfig.watchOptions || existingWatchOptions;
30932         options.configFilePath = configFileName && ts.normalizeSlashes(configFileName);
30933         var configFileSpecs = getConfigFileSpecs();
30934         if (sourceFile)
30935             sourceFile.configFileSpecs = configFileSpecs;
30936         setConfigFileInOptions(options, sourceFile);
30937         var basePathForFileNames = ts.normalizePath(configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath);
30938         return {
30939             options: options,
30940             watchOptions: watchOptions,
30941             fileNames: getFileNames(basePathForFileNames),
30942             projectReferences: getProjectReferences(basePathForFileNames),
30943             typeAcquisition: parsedConfig.typeAcquisition || getDefaultTypeAcquisition(),
30944             raw: raw,
30945             errors: errors,
30946             wildcardDirectories: getWildcardDirectories(configFileSpecs, basePathForFileNames, host.useCaseSensitiveFileNames),
30947             compileOnSave: !!raw.compileOnSave,
30948         };
30949         function getConfigFileSpecs() {
30950             var referencesOfRaw = getPropFromRaw("references", function (element) { return typeof element === "object"; }, "object");
30951             var filesSpecs = toPropValue(getSpecsFromRaw("files"));
30952             if (filesSpecs) {
30953                 var hasZeroOrNoReferences = referencesOfRaw === "no-prop" || ts.isArray(referencesOfRaw) && referencesOfRaw.length === 0;
30954                 var hasExtends = ts.hasProperty(raw, "extends");
30955                 if (filesSpecs.length === 0 && hasZeroOrNoReferences && !hasExtends) {
30956                     if (sourceFile) {
30957                         var fileName = configFileName || "tsconfig.json";
30958                         var diagnosticMessage = ts.Diagnostics.The_files_list_in_config_file_0_is_empty;
30959                         var nodeValue = ts.firstDefined(ts.getTsConfigPropArray(sourceFile, "files"), function (property) { return property.initializer; });
30960                         var error = nodeValue
30961                             ? ts.createDiagnosticForNodeInSourceFile(sourceFile, nodeValue, diagnosticMessage, fileName)
30962                             : ts.createCompilerDiagnostic(diagnosticMessage, fileName);
30963                         errors.push(error);
30964                     }
30965                     else {
30966                         createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.The_files_list_in_config_file_0_is_empty, configFileName || "tsconfig.json");
30967                     }
30968                 }
30969             }
30970             var includeSpecs = toPropValue(getSpecsFromRaw("include"));
30971             var excludeOfRaw = getSpecsFromRaw("exclude");
30972             var excludeSpecs = toPropValue(excludeOfRaw);
30973             if (excludeOfRaw === "no-prop" && raw.compilerOptions) {
30974                 var outDir = raw.compilerOptions.outDir;
30975                 var declarationDir = raw.compilerOptions.declarationDir;
30976                 if (outDir || declarationDir) {
30977                     excludeSpecs = [outDir, declarationDir].filter(function (d) { return !!d; });
30978                 }
30979             }
30980             if (filesSpecs === undefined && includeSpecs === undefined) {
30981                 includeSpecs = ["**/*"];
30982             }
30983             var validatedIncludeSpecs, validatedExcludeSpecs;
30984             if (includeSpecs) {
30985                 validatedIncludeSpecs = validateSpecs(includeSpecs, errors, true, sourceFile, "include");
30986             }
30987             if (excludeSpecs) {
30988                 validatedExcludeSpecs = validateSpecs(excludeSpecs, errors, false, sourceFile, "exclude");
30989             }
30990             return {
30991                 filesSpecs: filesSpecs,
30992                 includeSpecs: includeSpecs,
30993                 excludeSpecs: excludeSpecs,
30994                 validatedFilesSpec: ts.filter(filesSpecs, ts.isString),
30995                 validatedIncludeSpecs: validatedIncludeSpecs,
30996                 validatedExcludeSpecs: validatedExcludeSpecs,
30997             };
30998         }
30999         function getFileNames(basePath) {
31000             var fileNames = getFileNamesFromConfigSpecs(configFileSpecs, basePath, options, host, extraFileExtensions);
31001             if (shouldReportNoInputFiles(fileNames, canJsonReportNoInputFiles(raw), resolutionStack)) {
31002                 errors.push(getErrorForNoInputFiles(configFileSpecs, configFileName));
31003             }
31004             return fileNames;
31005         }
31006         function getProjectReferences(basePath) {
31007             var projectReferences;
31008             var referencesOfRaw = getPropFromRaw("references", function (element) { return typeof element === "object"; }, "object");
31009             if (ts.isArray(referencesOfRaw)) {
31010                 for (var _i = 0, referencesOfRaw_1 = referencesOfRaw; _i < referencesOfRaw_1.length; _i++) {
31011                     var ref = referencesOfRaw_1[_i];
31012                     if (typeof ref.path !== "string") {
31013                         createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "reference.path", "string");
31014                     }
31015                     else {
31016                         (projectReferences || (projectReferences = [])).push({
31017                             path: ts.getNormalizedAbsolutePath(ref.path, basePath),
31018                             originalPath: ref.path,
31019                             prepend: ref.prepend,
31020                             circular: ref.circular
31021                         });
31022                     }
31023                 }
31024             }
31025             return projectReferences;
31026         }
31027         function toPropValue(specResult) {
31028             return ts.isArray(specResult) ? specResult : undefined;
31029         }
31030         function getSpecsFromRaw(prop) {
31031             return getPropFromRaw(prop, ts.isString, "string");
31032         }
31033         function getPropFromRaw(prop, validateElement, elementTypeName) {
31034             if (ts.hasProperty(raw, prop) && !isNullOrUndefined(raw[prop])) {
31035                 if (ts.isArray(raw[prop])) {
31036                     var result = raw[prop];
31037                     if (!sourceFile && !ts.every(result, validateElement)) {
31038                         errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, prop, elementTypeName));
31039                     }
31040                     return result;
31041                 }
31042                 else {
31043                     createCompilerDiagnosticOnlyIfJson(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, prop, "Array");
31044                     return "not-array";
31045                 }
31046             }
31047             return "no-prop";
31048         }
31049         function createCompilerDiagnosticOnlyIfJson(message, arg0, arg1) {
31050             if (!sourceFile) {
31051                 errors.push(ts.createCompilerDiagnostic(message, arg0, arg1));
31052             }
31053         }
31054     }
31055     function isErrorNoInputFiles(error) {
31056         return error.code === ts.Diagnostics.No_inputs_were_found_in_config_file_0_Specified_include_paths_were_1_and_exclude_paths_were_2.code;
31057     }
31058     function getErrorForNoInputFiles(_a, configFileName) {
31059         var includeSpecs = _a.includeSpecs, excludeSpecs = _a.excludeSpecs;
31060         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 || []));
31061     }
31062     function shouldReportNoInputFiles(fileNames, canJsonReportNoInutFiles, resolutionStack) {
31063         return fileNames.length === 0 && canJsonReportNoInutFiles && (!resolutionStack || resolutionStack.length === 0);
31064     }
31065     function canJsonReportNoInputFiles(raw) {
31066         return !ts.hasProperty(raw, "files") && !ts.hasProperty(raw, "references");
31067     }
31068     ts.canJsonReportNoInputFiles = canJsonReportNoInputFiles;
31069     function updateErrorForNoInputFiles(fileNames, configFileName, configFileSpecs, configParseDiagnostics, canJsonReportNoInutFiles) {
31070         var existingErrors = configParseDiagnostics.length;
31071         if (shouldReportNoInputFiles(fileNames, canJsonReportNoInutFiles)) {
31072             configParseDiagnostics.push(getErrorForNoInputFiles(configFileSpecs, configFileName));
31073         }
31074         else {
31075             ts.filterMutate(configParseDiagnostics, function (error) { return !isErrorNoInputFiles(error); });
31076         }
31077         return existingErrors !== configParseDiagnostics.length;
31078     }
31079     ts.updateErrorForNoInputFiles = updateErrorForNoInputFiles;
31080     function isSuccessfulParsedTsconfig(value) {
31081         return !!value.options;
31082     }
31083     function parseConfig(json, sourceFile, host, basePath, configFileName, resolutionStack, errors, extendedConfigCache) {
31084         var _a;
31085         basePath = ts.normalizeSlashes(basePath);
31086         var resolvedPath = ts.getNormalizedAbsolutePath(configFileName || "", basePath);
31087         if (resolutionStack.indexOf(resolvedPath) >= 0) {
31088             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Circularity_detected_while_resolving_configuration_Colon_0, __spreadArray(__spreadArray([], resolutionStack), [resolvedPath]).join(" -> ")));
31089             return { raw: json || convertToObject(sourceFile, errors) };
31090         }
31091         var ownConfig = json ?
31092             parseOwnConfigOfJson(json, host, basePath, configFileName, errors) :
31093             parseOwnConfigOfJsonSourceFile(sourceFile, host, basePath, configFileName, errors);
31094         if ((_a = ownConfig.options) === null || _a === void 0 ? void 0 : _a.paths) {
31095             ownConfig.options.pathsBasePath = basePath;
31096         }
31097         if (ownConfig.extendedConfigPath) {
31098             resolutionStack = resolutionStack.concat([resolvedPath]);
31099             var extendedConfig = getExtendedConfig(sourceFile, ownConfig.extendedConfigPath, host, resolutionStack, errors, extendedConfigCache);
31100             if (extendedConfig && isSuccessfulParsedTsconfig(extendedConfig)) {
31101                 var baseRaw_1 = extendedConfig.raw;
31102                 var raw_1 = ownConfig.raw;
31103                 var relativeDifference_1;
31104                 var setPropertyInRawIfNotUndefined = function (propertyName) {
31105                     if (!raw_1[propertyName] && baseRaw_1[propertyName]) {
31106                         raw_1[propertyName] = ts.map(baseRaw_1[propertyName], function (path) { return ts.isRootedDiskPath(path) ? path : ts.combinePaths(relativeDifference_1 || (relativeDifference_1 = ts.convertToRelativePath(ts.getDirectoryPath(ownConfig.extendedConfigPath), basePath, ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames))), path); });
31107                     }
31108                 };
31109                 setPropertyInRawIfNotUndefined("include");
31110                 setPropertyInRawIfNotUndefined("exclude");
31111                 setPropertyInRawIfNotUndefined("files");
31112                 if (raw_1.compileOnSave === undefined) {
31113                     raw_1.compileOnSave = baseRaw_1.compileOnSave;
31114                 }
31115                 ownConfig.options = ts.assign({}, extendedConfig.options, ownConfig.options);
31116                 ownConfig.watchOptions = ownConfig.watchOptions && extendedConfig.watchOptions ?
31117                     ts.assign({}, extendedConfig.watchOptions, ownConfig.watchOptions) :
31118                     ownConfig.watchOptions || extendedConfig.watchOptions;
31119             }
31120         }
31121         return ownConfig;
31122     }
31123     function parseOwnConfigOfJson(json, host, basePath, configFileName, errors) {
31124         if (ts.hasProperty(json, "excludes")) {
31125             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
31126         }
31127         var options = convertCompilerOptionsFromJsonWorker(json.compilerOptions, basePath, errors, configFileName);
31128         var typeAcquisition = convertTypeAcquisitionFromJsonWorker(json.typeAcquisition || json.typingOptions, basePath, errors, configFileName);
31129         var watchOptions = convertWatchOptionsFromJsonWorker(json.watchOptions, basePath, errors);
31130         json.compileOnSave = convertCompileOnSaveOptionFromJson(json, basePath, errors);
31131         var extendedConfigPath;
31132         if (json.extends) {
31133             if (!ts.isString(json.extends)) {
31134                 errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, "extends", "string"));
31135             }
31136             else {
31137                 var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath;
31138                 extendedConfigPath = getExtendsConfigPath(json.extends, host, newBase, errors, ts.createCompilerDiagnostic);
31139             }
31140         }
31141         return { raw: json, options: options, watchOptions: watchOptions, typeAcquisition: typeAcquisition, extendedConfigPath: extendedConfigPath };
31142     }
31143     function parseOwnConfigOfJsonSourceFile(sourceFile, host, basePath, configFileName, errors) {
31144         var options = getDefaultCompilerOptions(configFileName);
31145         var typeAcquisition, typingOptionstypeAcquisition;
31146         var watchOptions;
31147         var extendedConfigPath;
31148         var optionsIterator = {
31149             onSetValidOptionKeyValueInParent: function (parentOption, option, value) {
31150                 var currentOption;
31151                 switch (parentOption) {
31152                     case "compilerOptions":
31153                         currentOption = options;
31154                         break;
31155                     case "watchOptions":
31156                         currentOption = (watchOptions || (watchOptions = {}));
31157                         break;
31158                     case "typeAcquisition":
31159                         currentOption = (typeAcquisition || (typeAcquisition = getDefaultTypeAcquisition(configFileName)));
31160                         break;
31161                     case "typingOptions":
31162                         currentOption = (typingOptionstypeAcquisition || (typingOptionstypeAcquisition = getDefaultTypeAcquisition(configFileName)));
31163                         break;
31164                     default:
31165                         ts.Debug.fail("Unknown option");
31166                 }
31167                 currentOption[option.name] = normalizeOptionValue(option, basePath, value);
31168             },
31169             onSetValidOptionKeyValueInRoot: function (key, _keyNode, value, valueNode) {
31170                 switch (key) {
31171                     case "extends":
31172                         var newBase = configFileName ? directoryOfCombinedPath(configFileName, basePath) : basePath;
31173                         extendedConfigPath = getExtendsConfigPath(value, host, newBase, errors, function (message, arg0) {
31174                             return ts.createDiagnosticForNodeInSourceFile(sourceFile, valueNode, message, arg0);
31175                         });
31176                         return;
31177                 }
31178             },
31179             onSetUnknownOptionKeyValueInRoot: function (key, keyNode, _value, _valueNode) {
31180                 if (key === "excludes") {
31181                     errors.push(ts.createDiagnosticForNodeInSourceFile(sourceFile, keyNode, ts.Diagnostics.Unknown_option_excludes_Did_you_mean_exclude));
31182                 }
31183             }
31184         };
31185         var json = convertToObjectWorker(sourceFile, errors, true, getTsconfigRootOptionsMap(), optionsIterator);
31186         if (!typeAcquisition) {
31187             if (typingOptionstypeAcquisition) {
31188                 typeAcquisition = (typingOptionstypeAcquisition.enableAutoDiscovery !== undefined) ?
31189                     {
31190                         enable: typingOptionstypeAcquisition.enableAutoDiscovery,
31191                         include: typingOptionstypeAcquisition.include,
31192                         exclude: typingOptionstypeAcquisition.exclude
31193                     } :
31194                     typingOptionstypeAcquisition;
31195             }
31196             else {
31197                 typeAcquisition = getDefaultTypeAcquisition(configFileName);
31198             }
31199         }
31200         return { raw: json, options: options, watchOptions: watchOptions, typeAcquisition: typeAcquisition, extendedConfigPath: extendedConfigPath };
31201     }
31202     function getExtendsConfigPath(extendedConfig, host, basePath, errors, createDiagnostic) {
31203         extendedConfig = ts.normalizeSlashes(extendedConfig);
31204         if (ts.isRootedDiskPath(extendedConfig) || ts.startsWith(extendedConfig, "./") || ts.startsWith(extendedConfig, "../")) {
31205             var extendedConfigPath = ts.getNormalizedAbsolutePath(extendedConfig, basePath);
31206             if (!host.fileExists(extendedConfigPath) && !ts.endsWith(extendedConfigPath, ".json")) {
31207                 extendedConfigPath = extendedConfigPath + ".json";
31208                 if (!host.fileExists(extendedConfigPath)) {
31209                     errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
31210                     return undefined;
31211                 }
31212             }
31213             return extendedConfigPath;
31214         }
31215         var resolved = ts.nodeModuleNameResolver(extendedConfig, ts.combinePaths(basePath, "tsconfig.json"), { moduleResolution: ts.ModuleResolutionKind.NodeJs }, host, undefined, undefined, true);
31216         if (resolved.resolvedModule) {
31217             return resolved.resolvedModule.resolvedFileName;
31218         }
31219         errors.push(createDiagnostic(ts.Diagnostics.File_0_not_found, extendedConfig));
31220         return undefined;
31221     }
31222     function getExtendedConfig(sourceFile, extendedConfigPath, host, resolutionStack, errors, extendedConfigCache) {
31223         var _a;
31224         var path = host.useCaseSensitiveFileNames ? extendedConfigPath : ts.toFileNameLowerCase(extendedConfigPath);
31225         var value;
31226         var extendedResult;
31227         var extendedConfig;
31228         if (extendedConfigCache && (value = extendedConfigCache.get(path))) {
31229             (extendedResult = value.extendedResult, extendedConfig = value.extendedConfig);
31230         }
31231         else {
31232             extendedResult = readJsonConfigFile(extendedConfigPath, function (path) { return host.readFile(path); });
31233             if (!extendedResult.parseDiagnostics.length) {
31234                 extendedConfig = parseConfig(undefined, extendedResult, host, ts.getDirectoryPath(extendedConfigPath), ts.getBaseFileName(extendedConfigPath), resolutionStack, errors, extendedConfigCache);
31235             }
31236             if (extendedConfigCache) {
31237                 extendedConfigCache.set(path, { extendedResult: extendedResult, extendedConfig: extendedConfig });
31238             }
31239         }
31240         if (sourceFile) {
31241             sourceFile.extendedSourceFiles = [extendedResult.fileName];
31242             if (extendedResult.extendedSourceFiles) {
31243                 (_a = sourceFile.extendedSourceFiles).push.apply(_a, extendedResult.extendedSourceFiles);
31244             }
31245         }
31246         if (extendedResult.parseDiagnostics.length) {
31247             errors.push.apply(errors, extendedResult.parseDiagnostics);
31248             return undefined;
31249         }
31250         return extendedConfig;
31251     }
31252     function convertCompileOnSaveOptionFromJson(jsonOption, basePath, errors) {
31253         if (!ts.hasProperty(jsonOption, ts.compileOnSaveCommandLineOption.name)) {
31254             return false;
31255         }
31256         var result = convertJsonOption(ts.compileOnSaveCommandLineOption, jsonOption.compileOnSave, basePath, errors);
31257         return typeof result === "boolean" && result;
31258     }
31259     function convertCompilerOptionsFromJson(jsonOptions, basePath, configFileName) {
31260         var errors = [];
31261         var options = convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName);
31262         return { options: options, errors: errors };
31263     }
31264     ts.convertCompilerOptionsFromJson = convertCompilerOptionsFromJson;
31265     function convertTypeAcquisitionFromJson(jsonOptions, basePath, configFileName) {
31266         var errors = [];
31267         var options = convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName);
31268         return { options: options, errors: errors };
31269     }
31270     ts.convertTypeAcquisitionFromJson = convertTypeAcquisitionFromJson;
31271     function getDefaultCompilerOptions(configFileName) {
31272         var options = configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json"
31273             ? { allowJs: true, maxNodeModuleJsDepth: 2, allowSyntheticDefaultImports: true, skipLibCheck: true, noEmit: true }
31274             : {};
31275         return options;
31276     }
31277     function convertCompilerOptionsFromJsonWorker(jsonOptions, basePath, errors, configFileName) {
31278         var options = getDefaultCompilerOptions(configFileName);
31279         convertOptionsFromJson(getCommandLineCompilerOptionsMap(), jsonOptions, basePath, options, ts.compilerOptionsDidYouMeanDiagnostics, errors);
31280         if (configFileName) {
31281             options.configFilePath = ts.normalizeSlashes(configFileName);
31282         }
31283         return options;
31284     }
31285     function getDefaultTypeAcquisition(configFileName) {
31286         return { enable: !!configFileName && ts.getBaseFileName(configFileName) === "jsconfig.json", include: [], exclude: [] };
31287     }
31288     function convertTypeAcquisitionFromJsonWorker(jsonOptions, basePath, errors, configFileName) {
31289         var options = getDefaultTypeAcquisition(configFileName);
31290         var typeAcquisition = convertEnableAutoDiscoveryToEnable(jsonOptions);
31291         convertOptionsFromJson(getCommandLineTypeAcquisitionMap(), typeAcquisition, basePath, options, typeAcquisitionDidYouMeanDiagnostics, errors);
31292         return options;
31293     }
31294     function convertWatchOptionsFromJsonWorker(jsonOptions, basePath, errors) {
31295         return convertOptionsFromJson(getCommandLineWatchOptionsMap(), jsonOptions, basePath, undefined, watchOptionsDidYouMeanDiagnostics, errors);
31296     }
31297     function convertOptionsFromJson(optionsNameMap, jsonOptions, basePath, defaultOptions, diagnostics, errors) {
31298         if (!jsonOptions) {
31299             return;
31300         }
31301         for (var id in jsonOptions) {
31302             var opt = optionsNameMap.get(id);
31303             if (opt) {
31304                 (defaultOptions || (defaultOptions = {}))[opt.name] = convertJsonOption(opt, jsonOptions[id], basePath, errors);
31305             }
31306             else {
31307                 errors.push(createUnknownOptionError(id, diagnostics, ts.createCompilerDiagnostic));
31308             }
31309         }
31310         return defaultOptions;
31311     }
31312     function convertJsonOption(opt, value, basePath, errors) {
31313         if (isCompilerOptionsValue(opt, value)) {
31314             var optType = opt.type;
31315             if (optType === "list" && ts.isArray(value)) {
31316                 return convertJsonOptionOfListType(opt, value, basePath, errors);
31317             }
31318             else if (!ts.isString(optType)) {
31319                 return convertJsonOptionOfCustomType(opt, value, errors);
31320             }
31321             var validatedValue = validateJsonOptionValue(opt, value, errors);
31322             return isNullOrUndefined(validatedValue) ? validatedValue : normalizeNonListOptionValue(opt, basePath, validatedValue);
31323         }
31324         else {
31325             errors.push(ts.createCompilerDiagnostic(ts.Diagnostics.Compiler_option_0_requires_a_value_of_type_1, opt.name, getCompilerOptionValueTypeString(opt)));
31326         }
31327     }
31328     ts.convertJsonOption = convertJsonOption;
31329     function normalizeOptionValue(option, basePath, value) {
31330         if (isNullOrUndefined(value))
31331             return undefined;
31332         if (option.type === "list") {
31333             var listOption_1 = option;
31334             if (listOption_1.element.isFilePath || !ts.isString(listOption_1.element.type)) {
31335                 return ts.filter(ts.map(value, function (v) { return normalizeOptionValue(listOption_1.element, basePath, v); }), function (v) { return !!v; });
31336             }
31337             return value;
31338         }
31339         else if (!ts.isString(option.type)) {
31340             return option.type.get(ts.isString(value) ? value.toLowerCase() : value);
31341         }
31342         return normalizeNonListOptionValue(option, basePath, value);
31343     }
31344     function normalizeNonListOptionValue(option, basePath, value) {
31345         if (option.isFilePath) {
31346             value = ts.getNormalizedAbsolutePath(value, basePath);
31347             if (value === "") {
31348                 value = ".";
31349             }
31350         }
31351         return value;
31352     }
31353     function validateJsonOptionValue(opt, value, errors) {
31354         var _a;
31355         if (isNullOrUndefined(value))
31356             return undefined;
31357         var d = (_a = opt.extraValidation) === null || _a === void 0 ? void 0 : _a.call(opt, value);
31358         if (!d)
31359             return value;
31360         errors.push(ts.createCompilerDiagnostic.apply(void 0, d));
31361         return undefined;
31362     }
31363     function convertJsonOptionOfCustomType(opt, value, errors) {
31364         if (isNullOrUndefined(value))
31365             return undefined;
31366         var key = value.toLowerCase();
31367         var val = opt.type.get(key);
31368         if (val !== undefined) {
31369             return validateJsonOptionValue(opt, val, errors);
31370         }
31371         else {
31372             errors.push(createCompilerDiagnosticForInvalidCustomType(opt));
31373         }
31374     }
31375     function convertJsonOptionOfListType(option, values, basePath, errors) {
31376         return ts.filter(ts.map(values, function (v) { return convertJsonOption(option.element, v, basePath, errors); }), function (v) { return !!v; });
31377     }
31378     function trimString(s) {
31379         return typeof s.trim === "function" ? s.trim() : s.replace(/^[\s]+|[\s]+$/g, "");
31380     }
31381     var invalidTrailingRecursionPattern = /(^|\/)\*\*\/?$/;
31382     var invalidDotDotAfterRecursiveWildcardPattern = /(^|\/)\*\*\/(.*\/)?\.\.($|\/)/;
31383     var watchRecursivePattern = /\/[^/]*?[*?][^/]*\//;
31384     var wildcardDirectoryPattern = /^[^*?]*(?=\/[^/]*[*?])/;
31385     function getFileNamesFromConfigSpecs(configFileSpecs, basePath, options, host, extraFileExtensions) {
31386         if (extraFileExtensions === void 0) { extraFileExtensions = ts.emptyArray; }
31387         basePath = ts.normalizePath(basePath);
31388         var keyMapper = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames);
31389         var literalFileMap = new ts.Map();
31390         var wildcardFileMap = new ts.Map();
31391         var wildCardJsonFileMap = new ts.Map();
31392         var validatedFilesSpec = configFileSpecs.validatedFilesSpec, validatedIncludeSpecs = configFileSpecs.validatedIncludeSpecs, validatedExcludeSpecs = configFileSpecs.validatedExcludeSpecs;
31393         var supportedExtensions = ts.getSupportedExtensions(options, extraFileExtensions);
31394         var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
31395         if (validatedFilesSpec) {
31396             for (var _i = 0, validatedFilesSpec_1 = validatedFilesSpec; _i < validatedFilesSpec_1.length; _i++) {
31397                 var fileName = validatedFilesSpec_1[_i];
31398                 var file = ts.getNormalizedAbsolutePath(fileName, basePath);
31399                 literalFileMap.set(keyMapper(file), file);
31400             }
31401         }
31402         var jsonOnlyIncludeRegexes;
31403         if (validatedIncludeSpecs && validatedIncludeSpecs.length > 0) {
31404             var _loop_6 = function (file) {
31405                 if (ts.fileExtensionIs(file, ".json")) {
31406                     if (!jsonOnlyIncludeRegexes) {
31407                         var includes = validatedIncludeSpecs.filter(function (s) { return ts.endsWith(s, ".json"); });
31408                         var includeFilePatterns = ts.map(ts.getRegularExpressionsForWildcards(includes, basePath, "files"), function (pattern) { return "^" + pattern + "$"; });
31409                         jsonOnlyIncludeRegexes = includeFilePatterns ? includeFilePatterns.map(function (pattern) { return ts.getRegexFromPattern(pattern, host.useCaseSensitiveFileNames); }) : ts.emptyArray;
31410                     }
31411                     var includeIndex = ts.findIndex(jsonOnlyIncludeRegexes, function (re) { return re.test(file); });
31412                     if (includeIndex !== -1) {
31413                         var key_1 = keyMapper(file);
31414                         if (!literalFileMap.has(key_1) && !wildCardJsonFileMap.has(key_1)) {
31415                             wildCardJsonFileMap.set(key_1, file);
31416                         }
31417                     }
31418                     return "continue";
31419                 }
31420                 if (hasFileWithHigherPriorityExtension(file, literalFileMap, wildcardFileMap, supportedExtensions, keyMapper)) {
31421                     return "continue";
31422                 }
31423                 removeWildcardFilesWithLowerPriorityExtension(file, wildcardFileMap, supportedExtensions, keyMapper);
31424                 var key = keyMapper(file);
31425                 if (!literalFileMap.has(key) && !wildcardFileMap.has(key)) {
31426                     wildcardFileMap.set(key, file);
31427                 }
31428             };
31429             for (var _a = 0, _b = host.readDirectory(basePath, supportedExtensionsWithJsonIfResolveJsonModule, validatedExcludeSpecs, validatedIncludeSpecs, undefined); _a < _b.length; _a++) {
31430                 var file = _b[_a];
31431                 _loop_6(file);
31432             }
31433         }
31434         var literalFiles = ts.arrayFrom(literalFileMap.values());
31435         var wildcardFiles = ts.arrayFrom(wildcardFileMap.values());
31436         return literalFiles.concat(wildcardFiles, ts.arrayFrom(wildCardJsonFileMap.values()));
31437     }
31438     ts.getFileNamesFromConfigSpecs = getFileNamesFromConfigSpecs;
31439     function isExcludedFile(pathToCheck, spec, basePath, useCaseSensitiveFileNames, currentDirectory) {
31440         var validatedFilesSpec = spec.validatedFilesSpec, validatedIncludeSpecs = spec.validatedIncludeSpecs, validatedExcludeSpecs = spec.validatedExcludeSpecs;
31441         if (!ts.length(validatedIncludeSpecs) || !ts.length(validatedExcludeSpecs))
31442             return false;
31443         basePath = ts.normalizePath(basePath);
31444         var keyMapper = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
31445         if (validatedFilesSpec) {
31446             for (var _i = 0, validatedFilesSpec_2 = validatedFilesSpec; _i < validatedFilesSpec_2.length; _i++) {
31447                 var fileName = validatedFilesSpec_2[_i];
31448                 if (keyMapper(ts.getNormalizedAbsolutePath(fileName, basePath)) === pathToCheck)
31449                     return false;
31450             }
31451         }
31452         return matchesExcludeWorker(pathToCheck, validatedExcludeSpecs, useCaseSensitiveFileNames, currentDirectory, basePath);
31453     }
31454     ts.isExcludedFile = isExcludedFile;
31455     function matchesExclude(pathToCheck, excludeSpecs, useCaseSensitiveFileNames, currentDirectory) {
31456         return matchesExcludeWorker(pathToCheck, ts.filter(excludeSpecs, function (spec) { return !invalidDotDotAfterRecursiveWildcardPattern.test(spec); }), useCaseSensitiveFileNames, currentDirectory);
31457     }
31458     ts.matchesExclude = matchesExclude;
31459     function matchesExcludeWorker(pathToCheck, excludeSpecs, useCaseSensitiveFileNames, currentDirectory, basePath) {
31460         var excludePattern = ts.getRegularExpressionForWildcard(excludeSpecs, ts.combinePaths(ts.normalizePath(currentDirectory), basePath), "exclude");
31461         var excludeRegex = excludePattern && ts.getRegexFromPattern(excludePattern, useCaseSensitiveFileNames);
31462         if (!excludeRegex)
31463             return false;
31464         if (excludeRegex.test(pathToCheck))
31465             return true;
31466         return !ts.hasExtension(pathToCheck) && excludeRegex.test(ts.ensureTrailingDirectorySeparator(pathToCheck));
31467     }
31468     function validateSpecs(specs, errors, disallowTrailingRecursion, jsonSourceFile, specKey) {
31469         return specs.filter(function (spec) {
31470             if (!ts.isString(spec))
31471                 return false;
31472             var diag = specToDiagnostic(spec, disallowTrailingRecursion);
31473             if (diag !== undefined) {
31474                 errors.push(createDiagnostic.apply(void 0, diag));
31475             }
31476             return diag === undefined;
31477         });
31478         function createDiagnostic(message, spec) {
31479             var element = ts.getTsConfigPropArrayElementValue(jsonSourceFile, specKey, spec);
31480             return element ?
31481                 ts.createDiagnosticForNodeInSourceFile(jsonSourceFile, element, message, spec) :
31482                 ts.createCompilerDiagnostic(message, spec);
31483         }
31484     }
31485     function specToDiagnostic(spec, disallowTrailingRecursion) {
31486         if (disallowTrailingRecursion && invalidTrailingRecursionPattern.test(spec)) {
31487             return [ts.Diagnostics.File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec];
31488         }
31489         else if (invalidDotDotAfterRecursiveWildcardPattern.test(spec)) {
31490             return [ts.Diagnostics.File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0, spec];
31491         }
31492     }
31493     function getWildcardDirectories(_a, path, useCaseSensitiveFileNames) {
31494         var include = _a.validatedIncludeSpecs, exclude = _a.validatedExcludeSpecs;
31495         var rawExcludeRegex = ts.getRegularExpressionForWildcard(exclude, path, "exclude");
31496         var excludeRegex = rawExcludeRegex && new RegExp(rawExcludeRegex, useCaseSensitiveFileNames ? "" : "i");
31497         var wildcardDirectories = {};
31498         if (include !== undefined) {
31499             var recursiveKeys = [];
31500             for (var _i = 0, include_1 = include; _i < include_1.length; _i++) {
31501                 var file = include_1[_i];
31502                 var spec = ts.normalizePath(ts.combinePaths(path, file));
31503                 if (excludeRegex && excludeRegex.test(spec)) {
31504                     continue;
31505                 }
31506                 var match = getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames);
31507                 if (match) {
31508                     var key = match.key, flags = match.flags;
31509                     var existingFlags = wildcardDirectories[key];
31510                     if (existingFlags === undefined || existingFlags < flags) {
31511                         wildcardDirectories[key] = flags;
31512                         if (flags === 1) {
31513                             recursiveKeys.push(key);
31514                         }
31515                     }
31516                 }
31517             }
31518             for (var key in wildcardDirectories) {
31519                 if (ts.hasProperty(wildcardDirectories, key)) {
31520                     for (var _b = 0, recursiveKeys_1 = recursiveKeys; _b < recursiveKeys_1.length; _b++) {
31521                         var recursiveKey = recursiveKeys_1[_b];
31522                         if (key !== recursiveKey && ts.containsPath(recursiveKey, key, path, !useCaseSensitiveFileNames)) {
31523                             delete wildcardDirectories[key];
31524                         }
31525                     }
31526                 }
31527             }
31528         }
31529         return wildcardDirectories;
31530     }
31531     function getWildcardDirectoryFromSpec(spec, useCaseSensitiveFileNames) {
31532         var match = wildcardDirectoryPattern.exec(spec);
31533         if (match) {
31534             return {
31535                 key: useCaseSensitiveFileNames ? match[0] : ts.toFileNameLowerCase(match[0]),
31536                 flags: watchRecursivePattern.test(spec) ? 1 : 0
31537             };
31538         }
31539         if (ts.isImplicitGlob(spec)) {
31540             return {
31541                 key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
31542                 flags: 1
31543             };
31544         }
31545         return undefined;
31546     }
31547     function hasFileWithHigherPriorityExtension(file, literalFiles, wildcardFiles, extensions, keyMapper) {
31548         var extensionPriority = ts.getExtensionPriority(file, extensions);
31549         var adjustedExtensionPriority = ts.adjustExtensionPriority(extensionPriority, extensions);
31550         for (var i = 0; i < adjustedExtensionPriority; i++) {
31551             var higherPriorityExtension = extensions[i];
31552             var higherPriorityPath = keyMapper(ts.changeExtension(file, higherPriorityExtension));
31553             if (literalFiles.has(higherPriorityPath) || wildcardFiles.has(higherPriorityPath)) {
31554                 return true;
31555             }
31556         }
31557         return false;
31558     }
31559     function removeWildcardFilesWithLowerPriorityExtension(file, wildcardFiles, extensions, keyMapper) {
31560         var extensionPriority = ts.getExtensionPriority(file, extensions);
31561         var nextExtensionPriority = ts.getNextLowestExtensionPriority(extensionPriority, extensions);
31562         for (var i = nextExtensionPriority; i < extensions.length; i++) {
31563             var lowerPriorityExtension = extensions[i];
31564             var lowerPriorityPath = keyMapper(ts.changeExtension(file, lowerPriorityExtension));
31565             wildcardFiles.delete(lowerPriorityPath);
31566         }
31567     }
31568     function convertCompilerOptionsForTelemetry(opts) {
31569         var out = {};
31570         for (var key in opts) {
31571             if (opts.hasOwnProperty(key)) {
31572                 var type = getOptionFromName(key);
31573                 if (type !== undefined) {
31574                     out[key] = getOptionValueWithEmptyStrings(opts[key], type);
31575                 }
31576             }
31577         }
31578         return out;
31579     }
31580     ts.convertCompilerOptionsForTelemetry = convertCompilerOptionsForTelemetry;
31581     function getOptionValueWithEmptyStrings(value, option) {
31582         switch (option.type) {
31583             case "object":
31584                 return "";
31585             case "string":
31586                 return "";
31587             case "number":
31588                 return typeof value === "number" ? value : "";
31589             case "boolean":
31590                 return typeof value === "boolean" ? value : "";
31591             case "list":
31592                 var elementType_1 = option.element;
31593                 return ts.isArray(value) ? value.map(function (v) { return getOptionValueWithEmptyStrings(v, elementType_1); }) : "";
31594             default:
31595                 return ts.forEachEntry(option.type, function (optionEnumValue, optionStringValue) {
31596                     if (optionEnumValue === value) {
31597                         return optionStringValue;
31598                     }
31599                 });
31600         }
31601     }
31602 })(ts || (ts = {}));
31603 var ts;
31604 (function (ts) {
31605     function trace(host) {
31606         host.trace(ts.formatMessage.apply(undefined, arguments));
31607     }
31608     ts.trace = trace;
31609     function isTraceEnabled(compilerOptions, host) {
31610         return !!compilerOptions.traceResolution && host.trace !== undefined;
31611     }
31612     ts.isTraceEnabled = isTraceEnabled;
31613     function withPackageId(packageInfo, r) {
31614         var packageId;
31615         if (r && packageInfo) {
31616             var packageJsonContent = packageInfo.packageJsonContent;
31617             if (typeof packageJsonContent.name === "string" && typeof packageJsonContent.version === "string") {
31618                 packageId = {
31619                     name: packageJsonContent.name,
31620                     subModuleName: r.path.slice(packageInfo.packageDirectory.length + ts.directorySeparator.length),
31621                     version: packageJsonContent.version
31622                 };
31623             }
31624         }
31625         return r && { path: r.path, extension: r.ext, packageId: packageId };
31626     }
31627     function noPackageId(r) {
31628         return withPackageId(undefined, r);
31629     }
31630     function removeIgnoredPackageId(r) {
31631         if (r) {
31632             ts.Debug.assert(r.packageId === undefined);
31633             return { path: r.path, ext: r.extension };
31634         }
31635     }
31636     var Extensions;
31637     (function (Extensions) {
31638         Extensions[Extensions["TypeScript"] = 0] = "TypeScript";
31639         Extensions[Extensions["JavaScript"] = 1] = "JavaScript";
31640         Extensions[Extensions["Json"] = 2] = "Json";
31641         Extensions[Extensions["TSConfig"] = 3] = "TSConfig";
31642         Extensions[Extensions["DtsOnly"] = 4] = "DtsOnly";
31643     })(Extensions || (Extensions = {}));
31644     function resolvedTypeScriptOnly(resolved) {
31645         if (!resolved) {
31646             return undefined;
31647         }
31648         ts.Debug.assert(ts.extensionIsTS(resolved.extension));
31649         return { fileName: resolved.path, packageId: resolved.packageId };
31650     }
31651     function createResolvedModuleWithFailedLookupLocations(resolved, isExternalLibraryImport, failedLookupLocations, resultFromCache) {
31652         var _a;
31653         if (resultFromCache) {
31654             (_a = resultFromCache.failedLookupLocations).push.apply(_a, failedLookupLocations);
31655             return resultFromCache;
31656         }
31657         return {
31658             resolvedModule: resolved && { resolvedFileName: resolved.path, originalPath: resolved.originalPath === true ? undefined : resolved.originalPath, extension: resolved.extension, isExternalLibraryImport: isExternalLibraryImport, packageId: resolved.packageId },
31659             failedLookupLocations: failedLookupLocations
31660         };
31661     }
31662     function readPackageJsonField(jsonContent, fieldName, typeOfTag, state) {
31663         if (!ts.hasProperty(jsonContent, fieldName)) {
31664             if (state.traceEnabled) {
31665                 trace(state.host, ts.Diagnostics.package_json_does_not_have_a_0_field, fieldName);
31666             }
31667             return;
31668         }
31669         var value = jsonContent[fieldName];
31670         if (typeof value !== typeOfTag || value === null) {
31671             if (state.traceEnabled) {
31672                 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);
31673             }
31674             return;
31675         }
31676         return value;
31677     }
31678     function readPackageJsonPathField(jsonContent, fieldName, baseDirectory, state) {
31679         var fileName = readPackageJsonField(jsonContent, fieldName, "string", state);
31680         if (fileName === undefined) {
31681             return;
31682         }
31683         if (!fileName) {
31684             if (state.traceEnabled) {
31685                 trace(state.host, ts.Diagnostics.package_json_had_a_falsy_0_field, fieldName);
31686             }
31687             return;
31688         }
31689         var path = ts.normalizePath(ts.combinePaths(baseDirectory, fileName));
31690         if (state.traceEnabled) {
31691             trace(state.host, ts.Diagnostics.package_json_has_0_field_1_that_references_2, fieldName, fileName, path);
31692         }
31693         return path;
31694     }
31695     function readPackageJsonTypesFields(jsonContent, baseDirectory, state) {
31696         return readPackageJsonPathField(jsonContent, "typings", baseDirectory, state)
31697             || readPackageJsonPathField(jsonContent, "types", baseDirectory, state);
31698     }
31699     function readPackageJsonTSConfigField(jsonContent, baseDirectory, state) {
31700         return readPackageJsonPathField(jsonContent, "tsconfig", baseDirectory, state);
31701     }
31702     function readPackageJsonMainField(jsonContent, baseDirectory, state) {
31703         return readPackageJsonPathField(jsonContent, "main", baseDirectory, state);
31704     }
31705     function readPackageJsonTypesVersionsField(jsonContent, state) {
31706         var typesVersions = readPackageJsonField(jsonContent, "typesVersions", "object", state);
31707         if (typesVersions === undefined)
31708             return;
31709         if (state.traceEnabled) {
31710             trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_field_with_version_specific_path_mappings);
31711         }
31712         return typesVersions;
31713     }
31714     function readPackageJsonTypesVersionPaths(jsonContent, state) {
31715         var typesVersions = readPackageJsonTypesVersionsField(jsonContent, state);
31716         if (typesVersions === undefined)
31717             return;
31718         if (state.traceEnabled) {
31719             for (var key in typesVersions) {
31720                 if (ts.hasProperty(typesVersions, key) && !ts.VersionRange.tryParse(key)) {
31721                     trace(state.host, ts.Diagnostics.package_json_has_a_typesVersions_entry_0_that_is_not_a_valid_semver_range, key);
31722                 }
31723             }
31724         }
31725         var result = getPackageJsonTypesVersionsPaths(typesVersions);
31726         if (!result) {
31727             if (state.traceEnabled) {
31728                 trace(state.host, ts.Diagnostics.package_json_does_not_have_a_typesVersions_entry_that_matches_version_0, ts.versionMajorMinor);
31729             }
31730             return;
31731         }
31732         var bestVersionKey = result.version, bestVersionPaths = result.paths;
31733         if (typeof bestVersionPaths !== "object") {
31734             if (state.traceEnabled) {
31735                 trace(state.host, ts.Diagnostics.Expected_type_of_0_field_in_package_json_to_be_1_got_2, "typesVersions['" + bestVersionKey + "']", "object", typeof bestVersionPaths);
31736             }
31737             return;
31738         }
31739         return result;
31740     }
31741     var typeScriptVersion;
31742     function getPackageJsonTypesVersionsPaths(typesVersions) {
31743         if (!typeScriptVersion)
31744             typeScriptVersion = new ts.Version(ts.version);
31745         for (var key in typesVersions) {
31746             if (!ts.hasProperty(typesVersions, key))
31747                 continue;
31748             var keyRange = ts.VersionRange.tryParse(key);
31749             if (keyRange === undefined) {
31750                 continue;
31751             }
31752             if (keyRange.test(typeScriptVersion)) {
31753                 return { version: key, paths: typesVersions[key] };
31754             }
31755         }
31756     }
31757     ts.getPackageJsonTypesVersionsPaths = getPackageJsonTypesVersionsPaths;
31758     function getEffectiveTypeRoots(options, host) {
31759         if (options.typeRoots) {
31760             return options.typeRoots;
31761         }
31762         var currentDirectory;
31763         if (options.configFilePath) {
31764             currentDirectory = ts.getDirectoryPath(options.configFilePath);
31765         }
31766         else if (host.getCurrentDirectory) {
31767             currentDirectory = host.getCurrentDirectory();
31768         }
31769         if (currentDirectory !== undefined) {
31770             return getDefaultTypeRoots(currentDirectory, host);
31771         }
31772     }
31773     ts.getEffectiveTypeRoots = getEffectiveTypeRoots;
31774     function getDefaultTypeRoots(currentDirectory, host) {
31775         if (!host.directoryExists) {
31776             return [ts.combinePaths(currentDirectory, nodeModulesAtTypes)];
31777         }
31778         var typeRoots;
31779         ts.forEachAncestorDirectory(ts.normalizePath(currentDirectory), function (directory) {
31780             var atTypes = ts.combinePaths(directory, nodeModulesAtTypes);
31781             if (host.directoryExists(atTypes)) {
31782                 (typeRoots || (typeRoots = [])).push(atTypes);
31783             }
31784             return undefined;
31785         });
31786         return typeRoots;
31787     }
31788     var nodeModulesAtTypes = ts.combinePaths("node_modules", "@types");
31789     function resolveTypeReferenceDirective(typeReferenceDirectiveName, containingFile, options, host, redirectedReference) {
31790         var traceEnabled = isTraceEnabled(options, host);
31791         if (redirectedReference) {
31792             options = redirectedReference.commandLine.options;
31793         }
31794         var failedLookupLocations = [];
31795         var moduleResolutionState = { compilerOptions: options, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
31796         var typeRoots = getEffectiveTypeRoots(options, host);
31797         if (traceEnabled) {
31798             if (containingFile === undefined) {
31799                 if (typeRoots === undefined) {
31800                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_not_set, typeReferenceDirectiveName);
31801                 }
31802                 else {
31803                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_not_set_root_directory_1, typeReferenceDirectiveName, typeRoots);
31804                 }
31805             }
31806             else {
31807                 if (typeRoots === undefined) {
31808                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_not_set, typeReferenceDirectiveName, containingFile);
31809                 }
31810                 else {
31811                     trace(host, ts.Diagnostics.Resolving_type_reference_directive_0_containing_file_1_root_directory_2, typeReferenceDirectiveName, containingFile, typeRoots);
31812                 }
31813             }
31814             if (redirectedReference) {
31815                 trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName);
31816             }
31817         }
31818         var resolved = primaryLookup();
31819         var primary = true;
31820         if (!resolved) {
31821             resolved = secondaryLookup();
31822             primary = false;
31823         }
31824         var resolvedTypeReferenceDirective;
31825         if (resolved) {
31826             var fileName = resolved.fileName, packageId = resolved.packageId;
31827             var resolvedFileName = options.preserveSymlinks ? fileName : realPath(fileName, host, traceEnabled);
31828             if (traceEnabled) {
31829                 if (packageId) {
31830                     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);
31831                 }
31832                 else {
31833                     trace(host, ts.Diagnostics.Type_reference_directive_0_was_successfully_resolved_to_1_primary_Colon_2, typeReferenceDirectiveName, resolvedFileName, primary);
31834                 }
31835             }
31836             resolvedTypeReferenceDirective = { primary: primary, resolvedFileName: resolvedFileName, packageId: packageId, isExternalLibraryImport: pathContainsNodeModules(fileName) };
31837         }
31838         return { resolvedTypeReferenceDirective: resolvedTypeReferenceDirective, failedLookupLocations: failedLookupLocations };
31839         function primaryLookup() {
31840             if (typeRoots && typeRoots.length) {
31841                 if (traceEnabled) {
31842                     trace(host, ts.Diagnostics.Resolving_with_primary_search_path_0, typeRoots.join(", "));
31843                 }
31844                 return ts.firstDefined(typeRoots, function (typeRoot) {
31845                     var candidate = ts.combinePaths(typeRoot, typeReferenceDirectiveName);
31846                     var candidateDirectory = ts.getDirectoryPath(candidate);
31847                     var directoryExists = ts.directoryProbablyExists(candidateDirectory, host);
31848                     if (!directoryExists && traceEnabled) {
31849                         trace(host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidateDirectory);
31850                     }
31851                     return resolvedTypeScriptOnly(loadNodeModuleFromDirectory(Extensions.DtsOnly, candidate, !directoryExists, moduleResolutionState));
31852                 });
31853             }
31854             else {
31855                 if (traceEnabled) {
31856                     trace(host, ts.Diagnostics.Root_directory_cannot_be_determined_skipping_primary_search_paths);
31857                 }
31858             }
31859         }
31860         function secondaryLookup() {
31861             var initialLocationForSecondaryLookup = containingFile && ts.getDirectoryPath(containingFile);
31862             if (initialLocationForSecondaryLookup !== undefined) {
31863                 if (traceEnabled) {
31864                     trace(host, ts.Diagnostics.Looking_up_in_node_modules_folder_initial_location_0, initialLocationForSecondaryLookup);
31865                 }
31866                 var result = void 0;
31867                 if (!ts.isExternalModuleNameRelative(typeReferenceDirectiveName)) {
31868                     var searchResult = loadModuleFromNearestNodeModulesDirectory(Extensions.DtsOnly, typeReferenceDirectiveName, initialLocationForSecondaryLookup, moduleResolutionState, undefined, undefined);
31869                     result = searchResult && searchResult.value;
31870                 }
31871                 else {
31872                     var candidate = ts.normalizePathAndParts(ts.combinePaths(initialLocationForSecondaryLookup, typeReferenceDirectiveName)).path;
31873                     result = nodeLoadModuleByRelativeName(Extensions.DtsOnly, candidate, false, moduleResolutionState, true);
31874                 }
31875                 var resolvedFile = resolvedTypeScriptOnly(result);
31876                 if (!resolvedFile && traceEnabled) {
31877                     trace(host, ts.Diagnostics.Type_reference_directive_0_was_not_resolved, typeReferenceDirectiveName);
31878                 }
31879                 return resolvedFile;
31880             }
31881             else {
31882                 if (traceEnabled) {
31883                     trace(host, ts.Diagnostics.Containing_file_is_not_specified_and_root_directory_cannot_be_determined_skipping_lookup_in_node_modules_folder);
31884                 }
31885             }
31886         }
31887     }
31888     ts.resolveTypeReferenceDirective = resolveTypeReferenceDirective;
31889     function getAutomaticTypeDirectiveNames(options, host) {
31890         if (options.types) {
31891             return options.types;
31892         }
31893         var result = [];
31894         if (host.directoryExists && host.getDirectories) {
31895             var typeRoots = getEffectiveTypeRoots(options, host);
31896             if (typeRoots) {
31897                 for (var _i = 0, typeRoots_1 = typeRoots; _i < typeRoots_1.length; _i++) {
31898                     var root = typeRoots_1[_i];
31899                     if (host.directoryExists(root)) {
31900                         for (var _a = 0, _b = host.getDirectories(root); _a < _b.length; _a++) {
31901                             var typeDirectivePath = _b[_a];
31902                             var normalized = ts.normalizePath(typeDirectivePath);
31903                             var packageJsonPath = ts.combinePaths(root, normalized, "package.json");
31904                             var isNotNeededPackage = host.fileExists(packageJsonPath) && ts.readJson(packageJsonPath, host).typings === null;
31905                             if (!isNotNeededPackage) {
31906                                 var baseFileName = ts.getBaseFileName(normalized);
31907                                 if (baseFileName.charCodeAt(0) !== 46) {
31908                                     result.push(baseFileName);
31909                                 }
31910                             }
31911                         }
31912                     }
31913                 }
31914             }
31915         }
31916         return result;
31917     }
31918     ts.getAutomaticTypeDirectiveNames = getAutomaticTypeDirectiveNames;
31919     function createModuleResolutionCache(currentDirectory, getCanonicalFileName, options) {
31920         return createModuleResolutionCacheWithMaps(createCacheWithRedirects(options), createCacheWithRedirects(options), currentDirectory, getCanonicalFileName);
31921     }
31922     ts.createModuleResolutionCache = createModuleResolutionCache;
31923     function createCacheWithRedirects(options) {
31924         var ownMap = new ts.Map();
31925         var redirectsMap = new ts.Map();
31926         return {
31927             ownMap: ownMap,
31928             redirectsMap: redirectsMap,
31929             getOrCreateMapOfCacheRedirects: getOrCreateMapOfCacheRedirects,
31930             clear: clear,
31931             setOwnOptions: setOwnOptions,
31932             setOwnMap: setOwnMap
31933         };
31934         function setOwnOptions(newOptions) {
31935             options = newOptions;
31936         }
31937         function setOwnMap(newOwnMap) {
31938             ownMap = newOwnMap;
31939         }
31940         function getOrCreateMapOfCacheRedirects(redirectedReference) {
31941             if (!redirectedReference) {
31942                 return ownMap;
31943             }
31944             var path = redirectedReference.sourceFile.path;
31945             var redirects = redirectsMap.get(path);
31946             if (!redirects) {
31947                 redirects = !options || ts.optionsHaveModuleResolutionChanges(options, redirectedReference.commandLine.options) ? new ts.Map() : ownMap;
31948                 redirectsMap.set(path, redirects);
31949             }
31950             return redirects;
31951         }
31952         function clear() {
31953             ownMap.clear();
31954             redirectsMap.clear();
31955         }
31956     }
31957     ts.createCacheWithRedirects = createCacheWithRedirects;
31958     function createModuleResolutionCacheWithMaps(directoryToModuleNameMap, moduleNameToDirectoryMap, currentDirectory, getCanonicalFileName) {
31959         return { getOrCreateCacheForDirectory: getOrCreateCacheForDirectory, getOrCreateCacheForModuleName: getOrCreateCacheForModuleName, directoryToModuleNameMap: directoryToModuleNameMap, moduleNameToDirectoryMap: moduleNameToDirectoryMap };
31960         function getOrCreateCacheForDirectory(directoryName, redirectedReference) {
31961             var path = ts.toPath(directoryName, currentDirectory, getCanonicalFileName);
31962             return getOrCreateCache(directoryToModuleNameMap, redirectedReference, path, function () { return new ts.Map(); });
31963         }
31964         function getOrCreateCacheForModuleName(nonRelativeModuleName, redirectedReference) {
31965             ts.Debug.assert(!ts.isExternalModuleNameRelative(nonRelativeModuleName));
31966             return getOrCreateCache(moduleNameToDirectoryMap, redirectedReference, nonRelativeModuleName, createPerModuleNameCache);
31967         }
31968         function getOrCreateCache(cacheWithRedirects, redirectedReference, key, create) {
31969             var cache = cacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
31970             var result = cache.get(key);
31971             if (!result) {
31972                 result = create();
31973                 cache.set(key, result);
31974             }
31975             return result;
31976         }
31977         function createPerModuleNameCache() {
31978             var directoryPathMap = new ts.Map();
31979             return { get: get, set: set };
31980             function get(directory) {
31981                 return directoryPathMap.get(ts.toPath(directory, currentDirectory, getCanonicalFileName));
31982             }
31983             function set(directory, result) {
31984                 var path = ts.toPath(directory, currentDirectory, getCanonicalFileName);
31985                 if (directoryPathMap.has(path)) {
31986                     return;
31987                 }
31988                 directoryPathMap.set(path, result);
31989                 var resolvedFileName = result.resolvedModule &&
31990                     (result.resolvedModule.originalPath || result.resolvedModule.resolvedFileName);
31991                 var commonPrefix = resolvedFileName && getCommonPrefix(path, resolvedFileName);
31992                 var current = path;
31993                 while (current !== commonPrefix) {
31994                     var parent = ts.getDirectoryPath(current);
31995                     if (parent === current || directoryPathMap.has(parent)) {
31996                         break;
31997                     }
31998                     directoryPathMap.set(parent, result);
31999                     current = parent;
32000                 }
32001             }
32002             function getCommonPrefix(directory, resolution) {
32003                 var resolutionDirectory = ts.toPath(ts.getDirectoryPath(resolution), currentDirectory, getCanonicalFileName);
32004                 var i = 0;
32005                 var limit = Math.min(directory.length, resolutionDirectory.length);
32006                 while (i < limit && directory.charCodeAt(i) === resolutionDirectory.charCodeAt(i)) {
32007                     i++;
32008                 }
32009                 if (i === directory.length && (resolutionDirectory.length === i || resolutionDirectory[i] === ts.directorySeparator)) {
32010                     return directory;
32011                 }
32012                 var rootLength = ts.getRootLength(directory);
32013                 if (i < rootLength) {
32014                     return undefined;
32015                 }
32016                 var sep = directory.lastIndexOf(ts.directorySeparator, i - 1);
32017                 if (sep === -1) {
32018                     return undefined;
32019                 }
32020                 return directory.substr(0, Math.max(sep, rootLength));
32021             }
32022         }
32023     }
32024     ts.createModuleResolutionCacheWithMaps = createModuleResolutionCacheWithMaps;
32025     function resolveModuleNameFromCache(moduleName, containingFile, cache) {
32026         var containingDirectory = ts.getDirectoryPath(containingFile);
32027         var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory);
32028         return perFolderCache && perFolderCache.get(moduleName);
32029     }
32030     ts.resolveModuleNameFromCache = resolveModuleNameFromCache;
32031     function resolveModuleName(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
32032         var traceEnabled = isTraceEnabled(compilerOptions, host);
32033         if (redirectedReference) {
32034             compilerOptions = redirectedReference.commandLine.options;
32035         }
32036         if (traceEnabled) {
32037             trace(host, ts.Diagnostics.Resolving_module_0_from_1, moduleName, containingFile);
32038             if (redirectedReference) {
32039                 trace(host, ts.Diagnostics.Using_compiler_options_of_project_reference_redirect_0, redirectedReference.sourceFile.fileName);
32040             }
32041         }
32042         var containingDirectory = ts.getDirectoryPath(containingFile);
32043         var perFolderCache = cache && cache.getOrCreateCacheForDirectory(containingDirectory, redirectedReference);
32044         var result = perFolderCache && perFolderCache.get(moduleName);
32045         if (result) {
32046             if (traceEnabled) {
32047                 trace(host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
32048             }
32049         }
32050         else {
32051             var moduleResolution = compilerOptions.moduleResolution;
32052             if (moduleResolution === undefined) {
32053                 moduleResolution = ts.getEmitModuleKind(compilerOptions) === ts.ModuleKind.CommonJS ? ts.ModuleResolutionKind.NodeJs : ts.ModuleResolutionKind.Classic;
32054                 if (traceEnabled) {
32055                     trace(host, ts.Diagnostics.Module_resolution_kind_is_not_specified_using_0, ts.ModuleResolutionKind[moduleResolution]);
32056                 }
32057             }
32058             else {
32059                 if (traceEnabled) {
32060                     trace(host, ts.Diagnostics.Explicitly_specified_module_resolution_kind_Colon_0, ts.ModuleResolutionKind[moduleResolution]);
32061                 }
32062             }
32063             ts.perfLogger.logStartResolveModule(moduleName);
32064             switch (moduleResolution) {
32065                 case ts.ModuleResolutionKind.NodeJs:
32066                     result = nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
32067                     break;
32068                 case ts.ModuleResolutionKind.Classic:
32069                     result = classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference);
32070                     break;
32071                 default:
32072                     return ts.Debug.fail("Unexpected moduleResolution: " + moduleResolution);
32073             }
32074             if (result && result.resolvedModule)
32075                 ts.perfLogger.logInfoEvent("Module \"" + moduleName + "\" resolved to \"" + result.resolvedModule.resolvedFileName + "\"");
32076             ts.perfLogger.logStopResolveModule((result && result.resolvedModule) ? "" + result.resolvedModule.resolvedFileName : "null");
32077             if (perFolderCache) {
32078                 perFolderCache.set(moduleName, result);
32079                 if (!ts.isExternalModuleNameRelative(moduleName)) {
32080                     cache.getOrCreateCacheForModuleName(moduleName, redirectedReference).set(containingDirectory, result);
32081                 }
32082             }
32083         }
32084         if (traceEnabled) {
32085             if (result.resolvedModule) {
32086                 if (result.resolvedModule.packageId) {
32087                     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));
32088                 }
32089                 else {
32090                     trace(host, ts.Diagnostics.Module_name_0_was_successfully_resolved_to_1, moduleName, result.resolvedModule.resolvedFileName);
32091                 }
32092             }
32093             else {
32094                 trace(host, ts.Diagnostics.Module_name_0_was_not_resolved, moduleName);
32095             }
32096         }
32097         return result;
32098     }
32099     ts.resolveModuleName = resolveModuleName;
32100     function tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state) {
32101         var resolved = tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state);
32102         if (resolved)
32103             return resolved.value;
32104         if (!ts.isExternalModuleNameRelative(moduleName)) {
32105             return tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state);
32106         }
32107         else {
32108             return tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state);
32109         }
32110     }
32111     function tryLoadModuleUsingPathsIfEligible(extensions, moduleName, loader, state) {
32112         var _a = state.compilerOptions, baseUrl = _a.baseUrl, paths = _a.paths;
32113         if (paths && !ts.pathIsRelative(moduleName)) {
32114             if (state.traceEnabled) {
32115                 if (baseUrl) {
32116                     trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName);
32117                 }
32118                 trace(state.host, ts.Diagnostics.paths_option_is_specified_looking_for_a_pattern_to_match_module_name_0, moduleName);
32119             }
32120             var baseDirectory = ts.getPathsBasePath(state.compilerOptions, state.host);
32121             return tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, false, state);
32122         }
32123     }
32124     function tryLoadModuleUsingRootDirs(extensions, moduleName, containingDirectory, loader, state) {
32125         if (!state.compilerOptions.rootDirs) {
32126             return undefined;
32127         }
32128         if (state.traceEnabled) {
32129             trace(state.host, ts.Diagnostics.rootDirs_option_is_set_using_it_to_resolve_relative_module_name_0, moduleName);
32130         }
32131         var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
32132         var matchedRootDir;
32133         var matchedNormalizedPrefix;
32134         for (var _i = 0, _a = state.compilerOptions.rootDirs; _i < _a.length; _i++) {
32135             var rootDir = _a[_i];
32136             var normalizedRoot = ts.normalizePath(rootDir);
32137             if (!ts.endsWith(normalizedRoot, ts.directorySeparator)) {
32138                 normalizedRoot += ts.directorySeparator;
32139             }
32140             var isLongestMatchingPrefix = ts.startsWith(candidate, normalizedRoot) &&
32141                 (matchedNormalizedPrefix === undefined || matchedNormalizedPrefix.length < normalizedRoot.length);
32142             if (state.traceEnabled) {
32143                 trace(state.host, ts.Diagnostics.Checking_if_0_is_the_longest_matching_prefix_for_1_2, normalizedRoot, candidate, isLongestMatchingPrefix);
32144             }
32145             if (isLongestMatchingPrefix) {
32146                 matchedNormalizedPrefix = normalizedRoot;
32147                 matchedRootDir = rootDir;
32148             }
32149         }
32150         if (matchedNormalizedPrefix) {
32151             if (state.traceEnabled) {
32152                 trace(state.host, ts.Diagnostics.Longest_matching_prefix_for_0_is_1, candidate, matchedNormalizedPrefix);
32153             }
32154             var suffix = candidate.substr(matchedNormalizedPrefix.length);
32155             if (state.traceEnabled) {
32156                 trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, matchedNormalizedPrefix, candidate);
32157             }
32158             var resolvedFileName = loader(extensions, candidate, !ts.directoryProbablyExists(containingDirectory, state.host), state);
32159             if (resolvedFileName) {
32160                 return resolvedFileName;
32161             }
32162             if (state.traceEnabled) {
32163                 trace(state.host, ts.Diagnostics.Trying_other_entries_in_rootDirs);
32164             }
32165             for (var _b = 0, _c = state.compilerOptions.rootDirs; _b < _c.length; _b++) {
32166                 var rootDir = _c[_b];
32167                 if (rootDir === matchedRootDir) {
32168                     continue;
32169                 }
32170                 var candidate_1 = ts.combinePaths(ts.normalizePath(rootDir), suffix);
32171                 if (state.traceEnabled) {
32172                     trace(state.host, ts.Diagnostics.Loading_0_from_the_root_dir_1_candidate_location_2, suffix, rootDir, candidate_1);
32173                 }
32174                 var baseDirectory = ts.getDirectoryPath(candidate_1);
32175                 var resolvedFileName_1 = loader(extensions, candidate_1, !ts.directoryProbablyExists(baseDirectory, state.host), state);
32176                 if (resolvedFileName_1) {
32177                     return resolvedFileName_1;
32178                 }
32179             }
32180             if (state.traceEnabled) {
32181                 trace(state.host, ts.Diagnostics.Module_resolution_using_rootDirs_has_failed);
32182             }
32183         }
32184         return undefined;
32185     }
32186     function tryLoadModuleUsingBaseUrl(extensions, moduleName, loader, state) {
32187         var baseUrl = state.compilerOptions.baseUrl;
32188         if (!baseUrl) {
32189             return undefined;
32190         }
32191         if (state.traceEnabled) {
32192             trace(state.host, ts.Diagnostics.baseUrl_option_is_set_to_0_using_this_value_to_resolve_non_relative_module_name_1, baseUrl, moduleName);
32193         }
32194         var candidate = ts.normalizePath(ts.combinePaths(baseUrl, moduleName));
32195         if (state.traceEnabled) {
32196             trace(state.host, ts.Diagnostics.Resolving_module_name_0_relative_to_base_url_1_2, moduleName, baseUrl, candidate);
32197         }
32198         return loader(extensions, candidate, !ts.directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state);
32199     }
32200     function resolveJSModule(moduleName, initialDir, host) {
32201         var _a = tryResolveJSModuleWorker(moduleName, initialDir, host), resolvedModule = _a.resolvedModule, failedLookupLocations = _a.failedLookupLocations;
32202         if (!resolvedModule) {
32203             throw new Error("Could not resolve JS module '" + moduleName + "' starting at '" + initialDir + "'. Looked in: " + failedLookupLocations.join(", "));
32204         }
32205         return resolvedModule.resolvedFileName;
32206     }
32207     ts.resolveJSModule = resolveJSModule;
32208     function tryResolveJSModule(moduleName, initialDir, host) {
32209         var resolvedModule = tryResolveJSModuleWorker(moduleName, initialDir, host).resolvedModule;
32210         return resolvedModule && resolvedModule.resolvedFileName;
32211     }
32212     ts.tryResolveJSModule = tryResolveJSModule;
32213     var jsOnlyExtensions = [Extensions.JavaScript];
32214     var tsExtensions = [Extensions.TypeScript, Extensions.JavaScript];
32215     var tsPlusJsonExtensions = __spreadArray(__spreadArray([], tsExtensions), [Extensions.Json]);
32216     var tsconfigExtensions = [Extensions.TSConfig];
32217     function tryResolveJSModuleWorker(moduleName, initialDir, host) {
32218         return nodeModuleNameResolverWorker(moduleName, initialDir, { moduleResolution: ts.ModuleResolutionKind.NodeJs, allowJs: true }, host, undefined, jsOnlyExtensions, undefined);
32219     }
32220     function nodeModuleNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference, lookupConfig) {
32221         return nodeModuleNameResolverWorker(moduleName, ts.getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
32222     }
32223     ts.nodeModuleNameResolver = nodeModuleNameResolver;
32224     function nodeModuleNameResolverWorker(moduleName, containingDirectory, compilerOptions, host, cache, extensions, redirectedReference) {
32225         var _a, _b;
32226         var traceEnabled = isTraceEnabled(compilerOptions, host);
32227         var failedLookupLocations = [];
32228         var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
32229         var result = ts.forEach(extensions, function (ext) { return tryResolve(ext); });
32230         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);
32231         function tryResolve(extensions) {
32232             var loader = function (extensions, candidate, onlyRecordFailures, state) { return nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, true); };
32233             var resolved = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loader, state);
32234             if (resolved) {
32235                 return toSearchResult({ resolved: resolved, isExternalLibraryImport: pathContainsNodeModules(resolved.path) });
32236             }
32237             if (!ts.isExternalModuleNameRelative(moduleName)) {
32238                 if (traceEnabled) {
32239                     trace(host, ts.Diagnostics.Loading_module_0_from_node_modules_folder_target_file_type_1, moduleName, Extensions[extensions]);
32240                 }
32241                 var resolved_1 = loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, containingDirectory, state, cache, redirectedReference);
32242                 if (!resolved_1)
32243                     return undefined;
32244                 var resolvedValue = resolved_1.value;
32245                 if (!compilerOptions.preserveSymlinks && resolvedValue && !resolvedValue.originalPath) {
32246                     var path = realPath(resolvedValue.path, host, traceEnabled);
32247                     var originalPath = path === resolvedValue.path ? undefined : resolvedValue.path;
32248                     resolvedValue = __assign(__assign({}, resolvedValue), { path: path, originalPath: originalPath });
32249                 }
32250                 return { value: resolvedValue && { resolved: resolvedValue, isExternalLibraryImport: true } };
32251             }
32252             else {
32253                 var _a = ts.normalizePathAndParts(ts.combinePaths(containingDirectory, moduleName)), candidate = _a.path, parts = _a.parts;
32254                 var resolved_2 = nodeLoadModuleByRelativeName(extensions, candidate, false, state, true);
32255                 return resolved_2 && toSearchResult({ resolved: resolved_2, isExternalLibraryImport: ts.contains(parts, "node_modules") });
32256             }
32257         }
32258     }
32259     function realPath(path, host, traceEnabled) {
32260         if (!host.realpath) {
32261             return path;
32262         }
32263         var real = ts.normalizePath(host.realpath(path));
32264         if (traceEnabled) {
32265             trace(host, ts.Diagnostics.Resolving_real_path_for_0_result_1, path, real);
32266         }
32267         ts.Debug.assert(host.fileExists(real), path + " linked to nonexistent file " + real);
32268         return real;
32269     }
32270     function nodeLoadModuleByRelativeName(extensions, candidate, onlyRecordFailures, state, considerPackageJson) {
32271         if (state.traceEnabled) {
32272             trace(state.host, ts.Diagnostics.Loading_module_as_file_Slash_folder_candidate_module_location_0_target_file_type_1, candidate, Extensions[extensions]);
32273         }
32274         if (!ts.hasTrailingDirectorySeparator(candidate)) {
32275             if (!onlyRecordFailures) {
32276                 var parentOfCandidate = ts.getDirectoryPath(candidate);
32277                 if (!ts.directoryProbablyExists(parentOfCandidate, state.host)) {
32278                     if (state.traceEnabled) {
32279                         trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, parentOfCandidate);
32280                     }
32281                     onlyRecordFailures = true;
32282                 }
32283             }
32284             var resolvedFromFile = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state);
32285             if (resolvedFromFile) {
32286                 var packageDirectory = considerPackageJson ? parseNodeModuleFromPath(resolvedFromFile) : undefined;
32287                 var packageInfo = packageDirectory ? getPackageJsonInfo(packageDirectory, false, state) : undefined;
32288                 return withPackageId(packageInfo, resolvedFromFile);
32289             }
32290         }
32291         if (!onlyRecordFailures) {
32292             var candidateExists = ts.directoryProbablyExists(candidate, state.host);
32293             if (!candidateExists) {
32294                 if (state.traceEnabled) {
32295                     trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, candidate);
32296                 }
32297                 onlyRecordFailures = true;
32298             }
32299         }
32300         return loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson);
32301     }
32302     ts.nodeModulesPathPart = "/node_modules/";
32303     function pathContainsNodeModules(path) {
32304         return ts.stringContains(path, ts.nodeModulesPathPart);
32305     }
32306     ts.pathContainsNodeModules = pathContainsNodeModules;
32307     function parseNodeModuleFromPath(resolved) {
32308         var path = ts.normalizePath(resolved.path);
32309         var idx = path.lastIndexOf(ts.nodeModulesPathPart);
32310         if (idx === -1) {
32311             return undefined;
32312         }
32313         var indexAfterNodeModules = idx + ts.nodeModulesPathPart.length;
32314         var indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterNodeModules);
32315         if (path.charCodeAt(indexAfterNodeModules) === 64) {
32316             indexAfterPackageName = moveToNextDirectorySeparatorIfAvailable(path, indexAfterPackageName);
32317         }
32318         return path.slice(0, indexAfterPackageName);
32319     }
32320     function moveToNextDirectorySeparatorIfAvailable(path, prevSeparatorIndex) {
32321         var nextSeparatorIndex = path.indexOf(ts.directorySeparator, prevSeparatorIndex + 1);
32322         return nextSeparatorIndex === -1 ? prevSeparatorIndex : nextSeparatorIndex;
32323     }
32324     function loadModuleFromFileNoPackageId(extensions, candidate, onlyRecordFailures, state) {
32325         return noPackageId(loadModuleFromFile(extensions, candidate, onlyRecordFailures, state));
32326     }
32327     function loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) {
32328         if (extensions === Extensions.Json || extensions === Extensions.TSConfig) {
32329             var extensionLess = ts.tryRemoveExtension(candidate, ".json");
32330             return (extensionLess === undefined && extensions === Extensions.Json) ? undefined : tryAddingExtensions(extensionLess || candidate, extensions, onlyRecordFailures, state);
32331         }
32332         var resolvedByAddingExtension = tryAddingExtensions(candidate, extensions, onlyRecordFailures, state);
32333         if (resolvedByAddingExtension) {
32334             return resolvedByAddingExtension;
32335         }
32336         if (ts.hasJSFileExtension(candidate)) {
32337             var extensionless = ts.removeFileExtension(candidate);
32338             if (state.traceEnabled) {
32339                 var extension = candidate.substring(extensionless.length);
32340                 trace(state.host, ts.Diagnostics.File_name_0_has_a_1_extension_stripping_it, candidate, extension);
32341             }
32342             return tryAddingExtensions(extensionless, extensions, onlyRecordFailures, state);
32343         }
32344     }
32345     function tryAddingExtensions(candidate, extensions, onlyRecordFailures, state) {
32346         if (!onlyRecordFailures) {
32347             var directory = ts.getDirectoryPath(candidate);
32348             if (directory) {
32349                 onlyRecordFailures = !ts.directoryProbablyExists(directory, state.host);
32350             }
32351         }
32352         switch (extensions) {
32353             case Extensions.DtsOnly:
32354                 return tryExtension(".d.ts");
32355             case Extensions.TypeScript:
32356                 return tryExtension(".ts") || tryExtension(".tsx") || tryExtension(".d.ts");
32357             case Extensions.JavaScript:
32358                 return tryExtension(".js") || tryExtension(".jsx");
32359             case Extensions.TSConfig:
32360             case Extensions.Json:
32361                 return tryExtension(".json");
32362         }
32363         function tryExtension(ext) {
32364             var path = tryFile(candidate + ext, onlyRecordFailures, state);
32365             return path === undefined ? undefined : { path: path, ext: ext };
32366         }
32367     }
32368     function tryFile(fileName, onlyRecordFailures, state) {
32369         if (!onlyRecordFailures) {
32370             if (state.host.fileExists(fileName)) {
32371                 if (state.traceEnabled) {
32372                     trace(state.host, ts.Diagnostics.File_0_exist_use_it_as_a_name_resolution_result, fileName);
32373                 }
32374                 return fileName;
32375             }
32376             else {
32377                 if (state.traceEnabled) {
32378                     trace(state.host, ts.Diagnostics.File_0_does_not_exist, fileName);
32379                 }
32380             }
32381         }
32382         state.failedLookupLocations.push(fileName);
32383         return undefined;
32384     }
32385     function loadNodeModuleFromDirectory(extensions, candidate, onlyRecordFailures, state, considerPackageJson) {
32386         if (considerPackageJson === void 0) { considerPackageJson = true; }
32387         var packageInfo = considerPackageJson ? getPackageJsonInfo(candidate, onlyRecordFailures, state) : undefined;
32388         var packageJsonContent = packageInfo && packageInfo.packageJsonContent;
32389         var versionPaths = packageInfo && packageInfo.versionPaths;
32390         return withPackageId(packageInfo, loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageJsonContent, versionPaths));
32391     }
32392     function getPackageJsonInfo(packageDirectory, onlyRecordFailures, state) {
32393         var host = state.host, traceEnabled = state.traceEnabled;
32394         var directoryExists = !onlyRecordFailures && ts.directoryProbablyExists(packageDirectory, host);
32395         var packageJsonPath = ts.combinePaths(packageDirectory, "package.json");
32396         if (directoryExists && host.fileExists(packageJsonPath)) {
32397             var packageJsonContent = ts.readJson(packageJsonPath, host);
32398             if (traceEnabled) {
32399                 trace(host, ts.Diagnostics.Found_package_json_at_0, packageJsonPath);
32400             }
32401             var versionPaths = readPackageJsonTypesVersionPaths(packageJsonContent, state);
32402             return { packageDirectory: packageDirectory, packageJsonContent: packageJsonContent, versionPaths: versionPaths };
32403         }
32404         else {
32405             if (directoryExists && traceEnabled) {
32406                 trace(host, ts.Diagnostics.File_0_does_not_exist, packageJsonPath);
32407             }
32408             state.failedLookupLocations.push(packageJsonPath);
32409         }
32410     }
32411     function loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, jsonContent, versionPaths) {
32412         var packageFile;
32413         if (jsonContent) {
32414             switch (extensions) {
32415                 case Extensions.JavaScript:
32416                 case Extensions.Json:
32417                     packageFile = readPackageJsonMainField(jsonContent, candidate, state);
32418                     break;
32419                 case Extensions.TypeScript:
32420                     packageFile = readPackageJsonTypesFields(jsonContent, candidate, state) || readPackageJsonMainField(jsonContent, candidate, state);
32421                     break;
32422                 case Extensions.DtsOnly:
32423                     packageFile = readPackageJsonTypesFields(jsonContent, candidate, state);
32424                     break;
32425                 case Extensions.TSConfig:
32426                     packageFile = readPackageJsonTSConfigField(jsonContent, candidate, state);
32427                     break;
32428                 default:
32429                     return ts.Debug.assertNever(extensions);
32430             }
32431         }
32432         var loader = function (extensions, candidate, onlyRecordFailures, state) {
32433             var fromFile = tryFile(candidate, onlyRecordFailures, state);
32434             if (fromFile) {
32435                 var resolved = resolvedIfExtensionMatches(extensions, fromFile);
32436                 if (resolved) {
32437                     return noPackageId(resolved);
32438                 }
32439                 if (state.traceEnabled) {
32440                     trace(state.host, ts.Diagnostics.File_0_has_an_unsupported_extension_so_skipping_it, fromFile);
32441                 }
32442             }
32443             var nextExtensions = extensions === Extensions.DtsOnly ? Extensions.TypeScript : extensions;
32444             return nodeLoadModuleByRelativeName(nextExtensions, candidate, onlyRecordFailures, state, false);
32445         };
32446         var onlyRecordFailuresForPackageFile = packageFile ? !ts.directoryProbablyExists(ts.getDirectoryPath(packageFile), state.host) : undefined;
32447         var onlyRecordFailuresForIndex = onlyRecordFailures || !ts.directoryProbablyExists(candidate, state.host);
32448         var indexPath = ts.combinePaths(candidate, extensions === Extensions.TSConfig ? "tsconfig" : "index");
32449         if (versionPaths && (!packageFile || ts.containsPath(candidate, packageFile))) {
32450             var moduleName = ts.getRelativePathFromDirectory(candidate, packageFile || indexPath, false);
32451             if (state.traceEnabled) {
32452                 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);
32453             }
32454             var result = tryLoadModuleUsingPaths(extensions, moduleName, candidate, versionPaths.paths, loader, onlyRecordFailuresForPackageFile || onlyRecordFailuresForIndex, state);
32455             if (result) {
32456                 return removeIgnoredPackageId(result.value);
32457             }
32458         }
32459         var packageFileResult = packageFile && removeIgnoredPackageId(loader(extensions, packageFile, onlyRecordFailuresForPackageFile, state));
32460         if (packageFileResult)
32461             return packageFileResult;
32462         return loadModuleFromFile(extensions, indexPath, onlyRecordFailuresForIndex, state);
32463     }
32464     function resolvedIfExtensionMatches(extensions, path) {
32465         var ext = ts.tryGetExtensionFromPath(path);
32466         return ext !== undefined && extensionIsOk(extensions, ext) ? { path: path, ext: ext } : undefined;
32467     }
32468     function extensionIsOk(extensions, extension) {
32469         switch (extensions) {
32470             case Extensions.JavaScript:
32471                 return extension === ".js" || extension === ".jsx";
32472             case Extensions.TSConfig:
32473             case Extensions.Json:
32474                 return extension === ".json";
32475             case Extensions.TypeScript:
32476                 return extension === ".ts" || extension === ".tsx" || extension === ".d.ts";
32477             case Extensions.DtsOnly:
32478                 return extension === ".d.ts";
32479         }
32480     }
32481     function parsePackageName(moduleName) {
32482         var idx = moduleName.indexOf(ts.directorySeparator);
32483         if (moduleName[0] === "@") {
32484             idx = moduleName.indexOf(ts.directorySeparator, idx + 1);
32485         }
32486         return idx === -1 ? { packageName: moduleName, rest: "" } : { packageName: moduleName.slice(0, idx), rest: moduleName.slice(idx + 1) };
32487     }
32488     ts.parsePackageName = parsePackageName;
32489     function loadModuleFromNearestNodeModulesDirectory(extensions, moduleName, directory, state, cache, redirectedReference) {
32490         return loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, false, cache, redirectedReference);
32491     }
32492     function loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, directory, state) {
32493         return loadModuleFromNearestNodeModulesDirectoryWorker(Extensions.DtsOnly, moduleName, directory, state, true, undefined, undefined);
32494     }
32495     function loadModuleFromNearestNodeModulesDirectoryWorker(extensions, moduleName, directory, state, typesScopeOnly, cache, redirectedReference) {
32496         var perModuleNameCache = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
32497         return ts.forEachAncestorDirectory(ts.normalizeSlashes(directory), function (ancestorDirectory) {
32498             if (ts.getBaseFileName(ancestorDirectory) !== "node_modules") {
32499                 var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache, moduleName, ancestorDirectory, state);
32500                 if (resolutionFromCache) {
32501                     return resolutionFromCache;
32502                 }
32503                 return toSearchResult(loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, ancestorDirectory, state, typesScopeOnly));
32504             }
32505         });
32506     }
32507     function loadModuleFromImmediateNodeModulesDirectory(extensions, moduleName, directory, state, typesScopeOnly) {
32508         var nodeModulesFolder = ts.combinePaths(directory, "node_modules");
32509         var nodeModulesFolderExists = ts.directoryProbablyExists(nodeModulesFolder, state.host);
32510         if (!nodeModulesFolderExists && state.traceEnabled) {
32511             trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesFolder);
32512         }
32513         var packageResult = typesScopeOnly ? undefined : loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesFolder, nodeModulesFolderExists, state);
32514         if (packageResult) {
32515             return packageResult;
32516         }
32517         if (extensions === Extensions.TypeScript || extensions === Extensions.DtsOnly) {
32518             var nodeModulesAtTypes_1 = ts.combinePaths(nodeModulesFolder, "@types");
32519             var nodeModulesAtTypesExists = nodeModulesFolderExists;
32520             if (nodeModulesFolderExists && !ts.directoryProbablyExists(nodeModulesAtTypes_1, state.host)) {
32521                 if (state.traceEnabled) {
32522                     trace(state.host, ts.Diagnostics.Directory_0_does_not_exist_skipping_all_lookups_in_it, nodeModulesAtTypes_1);
32523                 }
32524                 nodeModulesAtTypesExists = false;
32525             }
32526             return loadModuleFromSpecificNodeModulesDirectory(Extensions.DtsOnly, mangleScopedPackageNameWithTrace(moduleName, state), nodeModulesAtTypes_1, nodeModulesAtTypesExists, state);
32527         }
32528     }
32529     function loadModuleFromSpecificNodeModulesDirectory(extensions, moduleName, nodeModulesDirectory, nodeModulesDirectoryExists, state) {
32530         var candidate = ts.normalizePath(ts.combinePaths(nodeModulesDirectory, moduleName));
32531         var packageInfo = getPackageJsonInfo(candidate, !nodeModulesDirectoryExists, state);
32532         if (packageInfo) {
32533             var fromFile = loadModuleFromFile(extensions, candidate, !nodeModulesDirectoryExists, state);
32534             if (fromFile) {
32535                 return noPackageId(fromFile);
32536             }
32537             var fromDirectory = loadNodeModuleFromDirectoryWorker(extensions, candidate, !nodeModulesDirectoryExists, state, packageInfo.packageJsonContent, packageInfo.versionPaths);
32538             return withPackageId(packageInfo, fromDirectory);
32539         }
32540         var loader = function (extensions, candidate, onlyRecordFailures, state) {
32541             var pathAndExtension = loadModuleFromFile(extensions, candidate, onlyRecordFailures, state) ||
32542                 loadNodeModuleFromDirectoryWorker(extensions, candidate, onlyRecordFailures, state, packageInfo && packageInfo.packageJsonContent, packageInfo && packageInfo.versionPaths);
32543             return withPackageId(packageInfo, pathAndExtension);
32544         };
32545         var _a = parsePackageName(moduleName), packageName = _a.packageName, rest = _a.rest;
32546         if (rest !== "") {
32547             var packageDirectory = ts.combinePaths(nodeModulesDirectory, packageName);
32548             packageInfo = getPackageJsonInfo(packageDirectory, !nodeModulesDirectoryExists, state);
32549             if (packageInfo && packageInfo.versionPaths) {
32550                 if (state.traceEnabled) {
32551                     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);
32552                 }
32553                 var packageDirectoryExists = nodeModulesDirectoryExists && ts.directoryProbablyExists(packageDirectory, state.host);
32554                 var fromPaths = tryLoadModuleUsingPaths(extensions, rest, packageDirectory, packageInfo.versionPaths.paths, loader, !packageDirectoryExists, state);
32555                 if (fromPaths) {
32556                     return fromPaths.value;
32557                 }
32558             }
32559         }
32560         return loader(extensions, candidate, !nodeModulesDirectoryExists, state);
32561     }
32562     function tryLoadModuleUsingPaths(extensions, moduleName, baseDirectory, paths, loader, onlyRecordFailures, state) {
32563         var matchedPattern = ts.matchPatternOrExact(ts.getOwnKeys(paths), moduleName);
32564         if (matchedPattern) {
32565             var matchedStar_1 = ts.isString(matchedPattern) ? undefined : ts.matchedText(matchedPattern, moduleName);
32566             var matchedPatternText = ts.isString(matchedPattern) ? matchedPattern : ts.patternText(matchedPattern);
32567             if (state.traceEnabled) {
32568                 trace(state.host, ts.Diagnostics.Module_name_0_matched_pattern_1, moduleName, matchedPatternText);
32569             }
32570             var resolved = ts.forEach(paths[matchedPatternText], function (subst) {
32571                 var path = matchedStar_1 ? subst.replace("*", matchedStar_1) : subst;
32572                 var candidate = ts.normalizePath(ts.combinePaths(baseDirectory, path));
32573                 if (state.traceEnabled) {
32574                     trace(state.host, ts.Diagnostics.Trying_substitution_0_candidate_module_location_Colon_1, subst, path);
32575                 }
32576                 var extension = ts.tryGetExtensionFromPath(subst);
32577                 if (extension !== undefined) {
32578                     var path_1 = tryFile(candidate, onlyRecordFailures, state);
32579                     if (path_1 !== undefined) {
32580                         return noPackageId({ path: path_1, ext: extension });
32581                     }
32582                 }
32583                 return loader(extensions, candidate, onlyRecordFailures || !ts.directoryProbablyExists(ts.getDirectoryPath(candidate), state.host), state);
32584             });
32585             return { value: resolved };
32586         }
32587     }
32588     var mangledScopedPackageSeparator = "__";
32589     function mangleScopedPackageNameWithTrace(packageName, state) {
32590         var mangled = mangleScopedPackageName(packageName);
32591         if (state.traceEnabled && mangled !== packageName) {
32592             trace(state.host, ts.Diagnostics.Scoped_package_detected_looking_in_0, mangled);
32593         }
32594         return mangled;
32595     }
32596     function getTypesPackageName(packageName) {
32597         return "@types/" + mangleScopedPackageName(packageName);
32598     }
32599     ts.getTypesPackageName = getTypesPackageName;
32600     function mangleScopedPackageName(packageName) {
32601         if (ts.startsWith(packageName, "@")) {
32602             var replaceSlash = packageName.replace(ts.directorySeparator, mangledScopedPackageSeparator);
32603             if (replaceSlash !== packageName) {
32604                 return replaceSlash.slice(1);
32605             }
32606         }
32607         return packageName;
32608     }
32609     ts.mangleScopedPackageName = mangleScopedPackageName;
32610     function getPackageNameFromTypesPackageName(mangledName) {
32611         var withoutAtTypePrefix = ts.removePrefix(mangledName, "@types/");
32612         if (withoutAtTypePrefix !== mangledName) {
32613             return unmangleScopedPackageName(withoutAtTypePrefix);
32614         }
32615         return mangledName;
32616     }
32617     ts.getPackageNameFromTypesPackageName = getPackageNameFromTypesPackageName;
32618     function unmangleScopedPackageName(typesPackageName) {
32619         return ts.stringContains(typesPackageName, mangledScopedPackageSeparator) ?
32620             "@" + typesPackageName.replace(mangledScopedPackageSeparator, ts.directorySeparator) :
32621             typesPackageName;
32622     }
32623     ts.unmangleScopedPackageName = unmangleScopedPackageName;
32624     function tryFindNonRelativeModuleNameInCache(cache, moduleName, containingDirectory, state) {
32625         var result = cache && cache.get(containingDirectory);
32626         if (result) {
32627             if (state.traceEnabled) {
32628                 trace(state.host, ts.Diagnostics.Resolution_for_module_0_was_found_in_cache_from_location_1, moduleName, containingDirectory);
32629             }
32630             state.resultFromCache = result;
32631             return { value: result.resolvedModule && { path: result.resolvedModule.resolvedFileName, originalPath: result.resolvedModule.originalPath || true, extension: result.resolvedModule.extension, packageId: result.resolvedModule.packageId } };
32632         }
32633     }
32634     function classicNameResolver(moduleName, containingFile, compilerOptions, host, cache, redirectedReference) {
32635         var traceEnabled = isTraceEnabled(compilerOptions, host);
32636         var failedLookupLocations = [];
32637         var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
32638         var containingDirectory = ts.getDirectoryPath(containingFile);
32639         var resolved = tryResolve(Extensions.TypeScript) || tryResolve(Extensions.JavaScript);
32640         return createResolvedModuleWithFailedLookupLocations(resolved && resolved.value, false, failedLookupLocations, state.resultFromCache);
32641         function tryResolve(extensions) {
32642             var resolvedUsingSettings = tryLoadModuleUsingOptionalResolutionSettings(extensions, moduleName, containingDirectory, loadModuleFromFileNoPackageId, state);
32643             if (resolvedUsingSettings) {
32644                 return { value: resolvedUsingSettings };
32645             }
32646             if (!ts.isExternalModuleNameRelative(moduleName)) {
32647                 var perModuleNameCache_1 = cache && cache.getOrCreateCacheForModuleName(moduleName, redirectedReference);
32648                 var resolved_3 = ts.forEachAncestorDirectory(containingDirectory, function (directory) {
32649                     var resolutionFromCache = tryFindNonRelativeModuleNameInCache(perModuleNameCache_1, moduleName, directory, state);
32650                     if (resolutionFromCache) {
32651                         return resolutionFromCache;
32652                     }
32653                     var searchName = ts.normalizePath(ts.combinePaths(directory, moduleName));
32654                     return toSearchResult(loadModuleFromFileNoPackageId(extensions, searchName, false, state));
32655                 });
32656                 if (resolved_3) {
32657                     return resolved_3;
32658                 }
32659                 if (extensions === Extensions.TypeScript) {
32660                     return loadModuleFromNearestNodeModulesDirectoryTypesScope(moduleName, containingDirectory, state);
32661                 }
32662             }
32663             else {
32664                 var candidate = ts.normalizePath(ts.combinePaths(containingDirectory, moduleName));
32665                 return toSearchResult(loadModuleFromFileNoPackageId(extensions, candidate, false, state));
32666             }
32667         }
32668     }
32669     ts.classicNameResolver = classicNameResolver;
32670     function loadModuleFromGlobalCache(moduleName, projectName, compilerOptions, host, globalCache) {
32671         var traceEnabled = isTraceEnabled(compilerOptions, host);
32672         if (traceEnabled) {
32673             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);
32674         }
32675         var failedLookupLocations = [];
32676         var state = { compilerOptions: compilerOptions, host: host, traceEnabled: traceEnabled, failedLookupLocations: failedLookupLocations };
32677         var resolved = loadModuleFromImmediateNodeModulesDirectory(Extensions.DtsOnly, moduleName, globalCache, state, false);
32678         return createResolvedModuleWithFailedLookupLocations(resolved, true, failedLookupLocations, state.resultFromCache);
32679     }
32680     ts.loadModuleFromGlobalCache = loadModuleFromGlobalCache;
32681     function toSearchResult(value) {
32682         return value !== undefined ? { value: value } : undefined;
32683     }
32684 })(ts || (ts = {}));
32685 var ts;
32686 (function (ts) {
32687     function getModuleInstanceState(node, visited) {
32688         if (node.body && !node.body.parent) {
32689             ts.setParent(node.body, node);
32690             ts.setParentRecursive(node.body, false);
32691         }
32692         return node.body ? getModuleInstanceStateCached(node.body, visited) : 1;
32693     }
32694     ts.getModuleInstanceState = getModuleInstanceState;
32695     function getModuleInstanceStateCached(node, visited) {
32696         if (visited === void 0) { visited = new ts.Map(); }
32697         var nodeId = ts.getNodeId(node);
32698         if (visited.has(nodeId)) {
32699             return visited.get(nodeId) || 0;
32700         }
32701         visited.set(nodeId, undefined);
32702         var result = getModuleInstanceStateWorker(node, visited);
32703         visited.set(nodeId, result);
32704         return result;
32705     }
32706     function getModuleInstanceStateWorker(node, visited) {
32707         switch (node.kind) {
32708             case 253:
32709             case 254:
32710                 return 0;
32711             case 255:
32712                 if (ts.isEnumConst(node)) {
32713                     return 2;
32714                 }
32715                 break;
32716             case 261:
32717             case 260:
32718                 if (!(ts.hasSyntacticModifier(node, 1))) {
32719                     return 0;
32720                 }
32721                 break;
32722             case 267:
32723                 var exportDeclaration = node;
32724                 if (!exportDeclaration.moduleSpecifier && exportDeclaration.exportClause && exportDeclaration.exportClause.kind === 268) {
32725                     var state = 0;
32726                     for (var _i = 0, _a = exportDeclaration.exportClause.elements; _i < _a.length; _i++) {
32727                         var specifier = _a[_i];
32728                         var specifierState = getModuleInstanceStateForAliasTarget(specifier, visited);
32729                         if (specifierState > state) {
32730                             state = specifierState;
32731                         }
32732                         if (state === 1) {
32733                             return state;
32734                         }
32735                     }
32736                     return state;
32737                 }
32738                 break;
32739             case 257: {
32740                 var state_1 = 0;
32741                 ts.forEachChild(node, function (n) {
32742                     var childState = getModuleInstanceStateCached(n, visited);
32743                     switch (childState) {
32744                         case 0:
32745                             return;
32746                         case 2:
32747                             state_1 = 2;
32748                             return;
32749                         case 1:
32750                             state_1 = 1;
32751                             return true;
32752                         default:
32753                             ts.Debug.assertNever(childState);
32754                     }
32755                 });
32756                 return state_1;
32757             }
32758             case 256:
32759                 return getModuleInstanceState(node, visited);
32760             case 78:
32761                 if (node.isInJSDocNamespace) {
32762                     return 0;
32763                 }
32764         }
32765         return 1;
32766     }
32767     function getModuleInstanceStateForAliasTarget(specifier, visited) {
32768         var name = specifier.propertyName || specifier.name;
32769         var p = specifier.parent;
32770         while (p) {
32771             if (ts.isBlock(p) || ts.isModuleBlock(p) || ts.isSourceFile(p)) {
32772                 var statements = p.statements;
32773                 var found = void 0;
32774                 for (var _i = 0, statements_2 = statements; _i < statements_2.length; _i++) {
32775                     var statement = statements_2[_i];
32776                     if (ts.nodeHasName(statement, name)) {
32777                         if (!statement.parent) {
32778                             ts.setParent(statement, p);
32779                             ts.setParentRecursive(statement, false);
32780                         }
32781                         var state = getModuleInstanceStateCached(statement, visited);
32782                         if (found === undefined || state > found) {
32783                             found = state;
32784                         }
32785                         if (found === 1) {
32786                             return found;
32787                         }
32788                     }
32789                 }
32790                 if (found !== undefined) {
32791                     return found;
32792                 }
32793             }
32794             p = p.parent;
32795         }
32796         return 1;
32797     }
32798     function initFlowNode(node) {
32799         ts.Debug.attachFlowNodeDebugInfo(node);
32800         return node;
32801     }
32802     var binder = createBinder();
32803     function bindSourceFile(file, options) {
32804         ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind", "bindSourceFile", { path: file.path }, true);
32805         ts.performance.mark("beforeBind");
32806         ts.perfLogger.logStartBindFile("" + file.fileName);
32807         binder(file, options);
32808         ts.perfLogger.logStopBindFile();
32809         ts.performance.mark("afterBind");
32810         ts.performance.measure("Bind", "beforeBind", "afterBind");
32811         ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
32812     }
32813     ts.bindSourceFile = bindSourceFile;
32814     function createBinder() {
32815         var file;
32816         var options;
32817         var languageVersion;
32818         var parent;
32819         var container;
32820         var thisParentContainer;
32821         var blockScopeContainer;
32822         var lastContainer;
32823         var delayedTypeAliases;
32824         var seenThisKeyword;
32825         var currentFlow;
32826         var currentBreakTarget;
32827         var currentContinueTarget;
32828         var currentReturnTarget;
32829         var currentTrueTarget;
32830         var currentFalseTarget;
32831         var currentExceptionTarget;
32832         var preSwitchCaseFlow;
32833         var activeLabelList;
32834         var hasExplicitReturn;
32835         var emitFlags;
32836         var inStrictMode;
32837         var inAssignmentPattern = false;
32838         var symbolCount = 0;
32839         var Symbol;
32840         var classifiableNames;
32841         var unreachableFlow = { flags: 1 };
32842         var reportedUnreachableFlow = { flags: 1 };
32843         function createDiagnosticForNode(node, message, arg0, arg1, arg2) {
32844             return ts.createDiagnosticForNodeInSourceFile(ts.getSourceFileOfNode(node) || file, node, message, arg0, arg1, arg2);
32845         }
32846         function bindSourceFile(f, opts) {
32847             file = f;
32848             options = opts;
32849             languageVersion = ts.getEmitScriptTarget(options);
32850             inStrictMode = bindInStrictMode(file, opts);
32851             classifiableNames = new ts.Set();
32852             symbolCount = 0;
32853             Symbol = ts.objectAllocator.getSymbolConstructor();
32854             ts.Debug.attachFlowNodeDebugInfo(unreachableFlow);
32855             ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow);
32856             if (!file.locals) {
32857                 bind(file);
32858                 file.symbolCount = symbolCount;
32859                 file.classifiableNames = classifiableNames;
32860                 delayedBindJSDocTypedefTag();
32861             }
32862             file = undefined;
32863             options = undefined;
32864             languageVersion = undefined;
32865             parent = undefined;
32866             container = undefined;
32867             thisParentContainer = undefined;
32868             blockScopeContainer = undefined;
32869             lastContainer = undefined;
32870             delayedTypeAliases = undefined;
32871             seenThisKeyword = false;
32872             currentFlow = undefined;
32873             currentBreakTarget = undefined;
32874             currentContinueTarget = undefined;
32875             currentReturnTarget = undefined;
32876             currentTrueTarget = undefined;
32877             currentFalseTarget = undefined;
32878             currentExceptionTarget = undefined;
32879             activeLabelList = undefined;
32880             hasExplicitReturn = false;
32881             inAssignmentPattern = false;
32882             emitFlags = 0;
32883         }
32884         return bindSourceFile;
32885         function bindInStrictMode(file, opts) {
32886             if (ts.getStrictOptionValue(opts, "alwaysStrict") && !file.isDeclarationFile) {
32887                 return true;
32888             }
32889             else {
32890                 return !!file.externalModuleIndicator;
32891             }
32892         }
32893         function createSymbol(flags, name) {
32894             symbolCount++;
32895             return new Symbol(flags, name);
32896         }
32897         function addDeclarationToSymbol(symbol, node, symbolFlags) {
32898             symbol.flags |= symbolFlags;
32899             node.symbol = symbol;
32900             symbol.declarations = ts.appendIfUnique(symbol.declarations, node);
32901             if (symbolFlags & (32 | 384 | 1536 | 3) && !symbol.exports) {
32902                 symbol.exports = ts.createSymbolTable();
32903             }
32904             if (symbolFlags & (32 | 64 | 2048 | 4096) && !symbol.members) {
32905                 symbol.members = ts.createSymbolTable();
32906             }
32907             if (symbol.constEnumOnlyModule && (symbol.flags & (16 | 32 | 256))) {
32908                 symbol.constEnumOnlyModule = false;
32909             }
32910             if (symbolFlags & 111551) {
32911                 ts.setValueDeclaration(symbol, node);
32912             }
32913         }
32914         function getDeclarationName(node) {
32915             if (node.kind === 266) {
32916                 return node.isExportEquals ? "export=" : "default";
32917             }
32918             var name = ts.getNameOfDeclaration(node);
32919             if (name) {
32920                 if (ts.isAmbientModule(node)) {
32921                     var moduleName = ts.getTextOfIdentifierOrLiteral(name);
32922                     return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\"");
32923                 }
32924                 if (name.kind === 158) {
32925                     var nameExpression = name.expression;
32926                     if (ts.isStringOrNumericLiteralLike(nameExpression)) {
32927                         return ts.escapeLeadingUnderscores(nameExpression.text);
32928                     }
32929                     if (ts.isSignedNumericLiteral(nameExpression)) {
32930                         return ts.tokenToString(nameExpression.operator) + nameExpression.operand.text;
32931                     }
32932                     ts.Debug.assert(ts.isWellKnownSymbolSyntactically(nameExpression));
32933                     return ts.getPropertyNameForKnownSymbolName(ts.idText(nameExpression.name));
32934                 }
32935                 if (ts.isWellKnownSymbolSyntactically(name)) {
32936                     return ts.getPropertyNameForKnownSymbolName(ts.idText(name.name));
32937                 }
32938                 if (ts.isPrivateIdentifier(name)) {
32939                     var containingClass = ts.getContainingClass(node);
32940                     if (!containingClass) {
32941                         return undefined;
32942                     }
32943                     var containingClassSymbol = containingClass.symbol;
32944                     return ts.getSymbolNameForPrivateIdentifier(containingClassSymbol, name.escapedText);
32945                 }
32946                 return ts.isPropertyNameLiteral(name) ? ts.getEscapedTextOfIdentifierOrLiteral(name) : undefined;
32947             }
32948             switch (node.kind) {
32949                 case 166:
32950                     return "__constructor";
32951                 case 174:
32952                 case 169:
32953                 case 313:
32954                     return "__call";
32955                 case 175:
32956                 case 170:
32957                     return "__new";
32958                 case 171:
32959                     return "__index";
32960                 case 267:
32961                     return "__export";
32962                 case 297:
32963                     return "export=";
32964                 case 216:
32965                     if (ts.getAssignmentDeclarationKind(node) === 2) {
32966                         return "export=";
32967                     }
32968                     ts.Debug.fail("Unknown binary declaration kind");
32969                     break;
32970                 case 308:
32971                     return (ts.isJSDocConstructSignature(node) ? "__new" : "__call");
32972                 case 160:
32973                     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"; });
32974                     var functionType = node.parent;
32975                     var index = functionType.parameters.indexOf(node);
32976                     return "arg" + index;
32977             }
32978         }
32979         function getDisplayName(node) {
32980             return ts.isNamedDeclaration(node) ? ts.declarationNameToString(node.name) : ts.unescapeLeadingUnderscores(ts.Debug.checkDefined(getDeclarationName(node)));
32981         }
32982         function declareSymbol(symbolTable, parent, node, includes, excludes, isReplaceableByMethod) {
32983             ts.Debug.assert(!ts.hasDynamicName(node));
32984             var isDefaultExport = ts.hasSyntacticModifier(node, 512) || ts.isExportSpecifier(node) && node.name.escapedText === "default";
32985             var name = isDefaultExport && parent ? "default" : getDeclarationName(node);
32986             var symbol;
32987             if (name === undefined) {
32988                 symbol = createSymbol(0, "__missing");
32989             }
32990             else {
32991                 symbol = symbolTable.get(name);
32992                 if (includes & 2885600) {
32993                     classifiableNames.add(name);
32994                 }
32995                 if (!symbol) {
32996                     symbolTable.set(name, symbol = createSymbol(0, name));
32997                     if (isReplaceableByMethod)
32998                         symbol.isReplaceableByMethod = true;
32999                 }
33000                 else if (isReplaceableByMethod && !symbol.isReplaceableByMethod) {
33001                     return symbol;
33002                 }
33003                 else if (symbol.flags & excludes) {
33004                     if (symbol.isReplaceableByMethod) {
33005                         symbolTable.set(name, symbol = createSymbol(0, name));
33006                     }
33007                     else if (!(includes & 3 && symbol.flags & 67108864)) {
33008                         if (ts.isNamedDeclaration(node)) {
33009                             ts.setParent(node.name, node);
33010                         }
33011                         var message_1 = symbol.flags & 2
33012                             ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
33013                             : ts.Diagnostics.Duplicate_identifier_0;
33014                         var messageNeedsName_1 = true;
33015                         if (symbol.flags & 384 || includes & 384) {
33016                             message_1 = ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations;
33017                             messageNeedsName_1 = false;
33018                         }
33019                         var multipleDefaultExports_1 = false;
33020                         if (ts.length(symbol.declarations)) {
33021                             if (isDefaultExport) {
33022                                 message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports;
33023                                 messageNeedsName_1 = false;
33024                                 multipleDefaultExports_1 = true;
33025                             }
33026                             else {
33027                                 if (symbol.declarations && symbol.declarations.length &&
33028                                     (node.kind === 266 && !node.isExportEquals)) {
33029                                     message_1 = ts.Diagnostics.A_module_cannot_have_multiple_default_exports;
33030                                     messageNeedsName_1 = false;
33031                                     multipleDefaultExports_1 = true;
33032                                 }
33033                             }
33034                         }
33035                         var relatedInformation_1 = [];
33036                         if (ts.isTypeAliasDeclaration(node) && ts.nodeIsMissing(node.type) && ts.hasSyntacticModifier(node, 1) && symbol.flags & (2097152 | 788968 | 1920)) {
33037                             relatedInformation_1.push(createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_0, "export type { " + ts.unescapeLeadingUnderscores(node.name.escapedText) + " }"));
33038                         }
33039                         var declarationName_1 = ts.getNameOfDeclaration(node) || node;
33040                         ts.forEach(symbol.declarations, function (declaration, index) {
33041                             var decl = ts.getNameOfDeclaration(declaration) || declaration;
33042                             var diag = createDiagnosticForNode(decl, message_1, messageNeedsName_1 ? getDisplayName(declaration) : undefined);
33043                             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);
33044                             if (multipleDefaultExports_1) {
33045                                 relatedInformation_1.push(createDiagnosticForNode(decl, ts.Diagnostics.The_first_export_default_is_here));
33046                             }
33047                         });
33048                         var diag = createDiagnosticForNode(declarationName_1, message_1, messageNeedsName_1 ? getDisplayName(node) : undefined);
33049                         file.bindDiagnostics.push(ts.addRelatedInfo.apply(void 0, __spreadArray([diag], relatedInformation_1)));
33050                         symbol = createSymbol(0, name);
33051                     }
33052                 }
33053             }
33054             addDeclarationToSymbol(symbol, node, includes);
33055             if (symbol.parent) {
33056                 ts.Debug.assert(symbol.parent === parent, "Existing symbol parent should match new one");
33057             }
33058             else {
33059                 symbol.parent = parent;
33060             }
33061             return symbol;
33062         }
33063         function declareModuleMember(node, symbolFlags, symbolExcludes) {
33064             var hasExportModifier = !!(ts.getCombinedModifierFlags(node) & 1) || jsdocTreatAsExported(node);
33065             if (symbolFlags & 2097152) {
33066                 if (node.kind === 270 || (node.kind === 260 && hasExportModifier)) {
33067                     return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
33068                 }
33069                 else {
33070                     return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
33071                 }
33072             }
33073             else {
33074                 if (ts.isJSDocTypeAlias(node))
33075                     ts.Debug.assert(ts.isInJSFile(node));
33076                 if (!ts.isAmbientModule(node) && (hasExportModifier || container.flags & 64)) {
33077                     if (!container.locals || (ts.hasSyntacticModifier(node, 512) && !getDeclarationName(node))) {
33078                         return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
33079                     }
33080                     var exportKind = symbolFlags & 111551 ? 1048576 : 0;
33081                     var local = declareSymbol(container.locals, undefined, node, exportKind, symbolExcludes);
33082                     local.exportSymbol = declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
33083                     node.localSymbol = local;
33084                     return local;
33085                 }
33086                 else {
33087                     return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
33088                 }
33089             }
33090         }
33091         function jsdocTreatAsExported(node) {
33092             if (node.parent && ts.isModuleDeclaration(node)) {
33093                 node = node.parent;
33094             }
33095             if (!ts.isJSDocTypeAlias(node))
33096                 return false;
33097             if (!ts.isJSDocEnumTag(node) && !!node.fullName)
33098                 return true;
33099             var declName = ts.getNameOfDeclaration(node);
33100             if (!declName)
33101                 return false;
33102             if (ts.isPropertyAccessEntityNameExpression(declName.parent) && isTopLevelNamespaceAssignment(declName.parent))
33103                 return true;
33104             if (ts.isDeclaration(declName.parent) && ts.getCombinedModifierFlags(declName.parent) & 1)
33105                 return true;
33106             return false;
33107         }
33108         function bindContainer(node, containerFlags) {
33109             var saveContainer = container;
33110             var saveThisParentContainer = thisParentContainer;
33111             var savedBlockScopeContainer = blockScopeContainer;
33112             if (containerFlags & 1) {
33113                 if (node.kind !== 209) {
33114                     thisParentContainer = container;
33115                 }
33116                 container = blockScopeContainer = node;
33117                 if (containerFlags & 32) {
33118                     container.locals = ts.createSymbolTable();
33119                 }
33120                 addToContainerChain(container);
33121             }
33122             else if (containerFlags & 2) {
33123                 blockScopeContainer = node;
33124                 blockScopeContainer.locals = undefined;
33125             }
33126             if (containerFlags & 4) {
33127                 var saveCurrentFlow = currentFlow;
33128                 var saveBreakTarget = currentBreakTarget;
33129                 var saveContinueTarget = currentContinueTarget;
33130                 var saveReturnTarget = currentReturnTarget;
33131                 var saveExceptionTarget = currentExceptionTarget;
33132                 var saveActiveLabelList = activeLabelList;
33133                 var saveHasExplicitReturn = hasExplicitReturn;
33134                 var isIIFE = containerFlags & 16 && !ts.hasSyntacticModifier(node, 256) &&
33135                     !node.asteriskToken && !!ts.getImmediatelyInvokedFunctionExpression(node);
33136                 if (!isIIFE) {
33137                     currentFlow = initFlowNode({ flags: 2 });
33138                     if (containerFlags & (16 | 128)) {
33139                         currentFlow.node = node;
33140                     }
33141                 }
33142                 currentReturnTarget = isIIFE || node.kind === 166 || (ts.isInJSFile(node) && (node.kind === 251 || node.kind === 208)) ? createBranchLabel() : undefined;
33143                 currentExceptionTarget = undefined;
33144                 currentBreakTarget = undefined;
33145                 currentContinueTarget = undefined;
33146                 activeLabelList = undefined;
33147                 hasExplicitReturn = false;
33148                 bindChildren(node);
33149                 node.flags &= ~2816;
33150                 if (!(currentFlow.flags & 1) && containerFlags & 8 && ts.nodeIsPresent(node.body)) {
33151                     node.flags |= 256;
33152                     if (hasExplicitReturn)
33153                         node.flags |= 512;
33154                     node.endFlowNode = currentFlow;
33155                 }
33156                 if (node.kind === 297) {
33157                     node.flags |= emitFlags;
33158                 }
33159                 if (currentReturnTarget) {
33160                     addAntecedent(currentReturnTarget, currentFlow);
33161                     currentFlow = finishFlowLabel(currentReturnTarget);
33162                     if (node.kind === 166 || (ts.isInJSFile(node) && (node.kind === 251 || node.kind === 208))) {
33163                         node.returnFlowNode = currentFlow;
33164                     }
33165                 }
33166                 if (!isIIFE) {
33167                     currentFlow = saveCurrentFlow;
33168                 }
33169                 currentBreakTarget = saveBreakTarget;
33170                 currentContinueTarget = saveContinueTarget;
33171                 currentReturnTarget = saveReturnTarget;
33172                 currentExceptionTarget = saveExceptionTarget;
33173                 activeLabelList = saveActiveLabelList;
33174                 hasExplicitReturn = saveHasExplicitReturn;
33175             }
33176             else if (containerFlags & 64) {
33177                 seenThisKeyword = false;
33178                 bindChildren(node);
33179                 node.flags = seenThisKeyword ? node.flags | 128 : node.flags & ~128;
33180             }
33181             else {
33182                 bindChildren(node);
33183             }
33184             container = saveContainer;
33185             thisParentContainer = saveThisParentContainer;
33186             blockScopeContainer = savedBlockScopeContainer;
33187         }
33188         function bindEachFunctionsFirst(nodes) {
33189             bindEach(nodes, function (n) { return n.kind === 251 ? bind(n) : undefined; });
33190             bindEach(nodes, function (n) { return n.kind !== 251 ? bind(n) : undefined; });
33191         }
33192         function bindEach(nodes, bindFunction) {
33193             if (bindFunction === void 0) { bindFunction = bind; }
33194             if (nodes === undefined) {
33195                 return;
33196             }
33197             ts.forEach(nodes, bindFunction);
33198         }
33199         function bindEachChild(node) {
33200             ts.forEachChild(node, bind, bindEach);
33201         }
33202         function bindChildren(node) {
33203             var saveInAssignmentPattern = inAssignmentPattern;
33204             inAssignmentPattern = false;
33205             if (checkUnreachable(node)) {
33206                 bindEachChild(node);
33207                 bindJSDoc(node);
33208                 inAssignmentPattern = saveInAssignmentPattern;
33209                 return;
33210             }
33211             if (node.kind >= 232 && node.kind <= 248 && !options.allowUnreachableCode) {
33212                 node.flowNode = currentFlow;
33213             }
33214             switch (node.kind) {
33215                 case 236:
33216                     bindWhileStatement(node);
33217                     break;
33218                 case 235:
33219                     bindDoStatement(node);
33220                     break;
33221                 case 237:
33222                     bindForStatement(node);
33223                     break;
33224                 case 238:
33225                 case 239:
33226                     bindForInOrForOfStatement(node);
33227                     break;
33228                 case 234:
33229                     bindIfStatement(node);
33230                     break;
33231                 case 242:
33232                 case 246:
33233                     bindReturnOrThrow(node);
33234                     break;
33235                 case 241:
33236                 case 240:
33237                     bindBreakOrContinueStatement(node);
33238                     break;
33239                 case 247:
33240                     bindTryStatement(node);
33241                     break;
33242                 case 244:
33243                     bindSwitchStatement(node);
33244                     break;
33245                 case 258:
33246                     bindCaseBlock(node);
33247                     break;
33248                 case 284:
33249                     bindCaseClause(node);
33250                     break;
33251                 case 233:
33252                     bindExpressionStatement(node);
33253                     break;
33254                 case 245:
33255                     bindLabeledStatement(node);
33256                     break;
33257                 case 214:
33258                     bindPrefixUnaryExpressionFlow(node);
33259                     break;
33260                 case 215:
33261                     bindPostfixUnaryExpressionFlow(node);
33262                     break;
33263                 case 216:
33264                     if (ts.isDestructuringAssignment(node)) {
33265                         inAssignmentPattern = saveInAssignmentPattern;
33266                         bindDestructuringAssignmentFlow(node);
33267                         return;
33268                     }
33269                     bindBinaryExpressionFlow(node);
33270                     break;
33271                 case 210:
33272                     bindDeleteExpressionFlow(node);
33273                     break;
33274                 case 217:
33275                     bindConditionalExpressionFlow(node);
33276                     break;
33277                 case 249:
33278                     bindVariableDeclarationFlow(node);
33279                     break;
33280                 case 201:
33281                 case 202:
33282                     bindAccessExpressionFlow(node);
33283                     break;
33284                 case 203:
33285                     bindCallExpressionFlow(node);
33286                     break;
33287                 case 225:
33288                     bindNonNullExpressionFlow(node);
33289                     break;
33290                 case 331:
33291                 case 324:
33292                 case 325:
33293                     bindJSDocTypeAlias(node);
33294                     break;
33295                 case 297: {
33296                     bindEachFunctionsFirst(node.statements);
33297                     bind(node.endOfFileToken);
33298                     break;
33299                 }
33300                 case 230:
33301                 case 257:
33302                     bindEachFunctionsFirst(node.statements);
33303                     break;
33304                 case 198:
33305                     bindBindingElementFlow(node);
33306                     break;
33307                 case 200:
33308                 case 199:
33309                 case 288:
33310                 case 220:
33311                     inAssignmentPattern = saveInAssignmentPattern;
33312                 default:
33313                     bindEachChild(node);
33314                     break;
33315             }
33316             bindJSDoc(node);
33317             inAssignmentPattern = saveInAssignmentPattern;
33318         }
33319         function isNarrowingExpression(expr) {
33320             switch (expr.kind) {
33321                 case 78:
33322                 case 79:
33323                 case 107:
33324                 case 201:
33325                 case 202:
33326                     return containsNarrowableReference(expr);
33327                 case 203:
33328                     return hasNarrowableArgument(expr);
33329                 case 207:
33330                 case 225:
33331                     return isNarrowingExpression(expr.expression);
33332                 case 216:
33333                     return isNarrowingBinaryExpression(expr);
33334                 case 214:
33335                     return expr.operator === 53 && isNarrowingExpression(expr.operand);
33336                 case 211:
33337                     return isNarrowingExpression(expr.expression);
33338             }
33339             return false;
33340         }
33341         function isNarrowableReference(expr) {
33342             return expr.kind === 78 || expr.kind === 79 || expr.kind === 107 || expr.kind === 105 ||
33343                 (ts.isPropertyAccessExpression(expr) || ts.isNonNullExpression(expr) || ts.isParenthesizedExpression(expr)) && isNarrowableReference(expr.expression) ||
33344                 ts.isBinaryExpression(expr) && expr.operatorToken.kind === 27 && isNarrowableReference(expr.right) ||
33345                 ts.isElementAccessExpression(expr) && ts.isStringOrNumericLiteralLike(expr.argumentExpression) && isNarrowableReference(expr.expression) ||
33346                 ts.isAssignmentExpression(expr) && isNarrowableReference(expr.left);
33347         }
33348         function containsNarrowableReference(expr) {
33349             return isNarrowableReference(expr) || ts.isOptionalChain(expr) && containsNarrowableReference(expr.expression);
33350         }
33351         function hasNarrowableArgument(expr) {
33352             if (expr.arguments) {
33353                 for (var _i = 0, _a = expr.arguments; _i < _a.length; _i++) {
33354                     var argument = _a[_i];
33355                     if (containsNarrowableReference(argument)) {
33356                         return true;
33357                     }
33358                 }
33359             }
33360             if (expr.expression.kind === 201 &&
33361                 containsNarrowableReference(expr.expression.expression)) {
33362                 return true;
33363             }
33364             return false;
33365         }
33366         function isNarrowingTypeofOperands(expr1, expr2) {
33367             return ts.isTypeOfExpression(expr1) && isNarrowableOperand(expr1.expression) && ts.isStringLiteralLike(expr2);
33368         }
33369         function isNarrowableInOperands(left, right) {
33370             return ts.isStringLiteralLike(left) && isNarrowingExpression(right);
33371         }
33372         function isNarrowingBinaryExpression(expr) {
33373             switch (expr.operatorToken.kind) {
33374                 case 62:
33375                 case 74:
33376                 case 75:
33377                 case 76:
33378                     return containsNarrowableReference(expr.left);
33379                 case 34:
33380                 case 35:
33381                 case 36:
33382                 case 37:
33383                     return isNarrowableOperand(expr.left) || isNarrowableOperand(expr.right) ||
33384                         isNarrowingTypeofOperands(expr.right, expr.left) || isNarrowingTypeofOperands(expr.left, expr.right);
33385                 case 101:
33386                     return isNarrowableOperand(expr.left);
33387                 case 100:
33388                     return isNarrowableInOperands(expr.left, expr.right);
33389                 case 27:
33390                     return isNarrowingExpression(expr.right);
33391             }
33392             return false;
33393         }
33394         function isNarrowableOperand(expr) {
33395             switch (expr.kind) {
33396                 case 207:
33397                     return isNarrowableOperand(expr.expression);
33398                 case 216:
33399                     switch (expr.operatorToken.kind) {
33400                         case 62:
33401                             return isNarrowableOperand(expr.left);
33402                         case 27:
33403                             return isNarrowableOperand(expr.right);
33404                     }
33405             }
33406             return containsNarrowableReference(expr);
33407         }
33408         function createBranchLabel() {
33409             return initFlowNode({ flags: 4, antecedents: undefined });
33410         }
33411         function createLoopLabel() {
33412             return initFlowNode({ flags: 8, antecedents: undefined });
33413         }
33414         function createReduceLabel(target, antecedents, antecedent) {
33415             return initFlowNode({ flags: 1024, target: target, antecedents: antecedents, antecedent: antecedent });
33416         }
33417         function setFlowNodeReferenced(flow) {
33418             flow.flags |= flow.flags & 2048 ? 4096 : 2048;
33419         }
33420         function addAntecedent(label, antecedent) {
33421             if (!(antecedent.flags & 1) && !ts.contains(label.antecedents, antecedent)) {
33422                 (label.antecedents || (label.antecedents = [])).push(antecedent);
33423                 setFlowNodeReferenced(antecedent);
33424             }
33425         }
33426         function createFlowCondition(flags, antecedent, expression) {
33427             if (antecedent.flags & 1) {
33428                 return antecedent;
33429             }
33430             if (!expression) {
33431                 return flags & 32 ? antecedent : unreachableFlow;
33432             }
33433             if ((expression.kind === 109 && flags & 64 ||
33434                 expression.kind === 94 && flags & 32) &&
33435                 !ts.isExpressionOfOptionalChainRoot(expression) && !ts.isNullishCoalesce(expression.parent)) {
33436                 return unreachableFlow;
33437             }
33438             if (!isNarrowingExpression(expression)) {
33439                 return antecedent;
33440             }
33441             setFlowNodeReferenced(antecedent);
33442             return initFlowNode({ flags: flags, antecedent: antecedent, node: expression });
33443         }
33444         function createFlowSwitchClause(antecedent, switchStatement, clauseStart, clauseEnd) {
33445             setFlowNodeReferenced(antecedent);
33446             return initFlowNode({ flags: 128, antecedent: antecedent, switchStatement: switchStatement, clauseStart: clauseStart, clauseEnd: clauseEnd });
33447         }
33448         function createFlowMutation(flags, antecedent, node) {
33449             setFlowNodeReferenced(antecedent);
33450             var result = initFlowNode({ flags: flags, antecedent: antecedent, node: node });
33451             if (currentExceptionTarget) {
33452                 addAntecedent(currentExceptionTarget, result);
33453             }
33454             return result;
33455         }
33456         function createFlowCall(antecedent, node) {
33457             setFlowNodeReferenced(antecedent);
33458             return initFlowNode({ flags: 512, antecedent: antecedent, node: node });
33459         }
33460         function finishFlowLabel(flow) {
33461             var antecedents = flow.antecedents;
33462             if (!antecedents) {
33463                 return unreachableFlow;
33464             }
33465             if (antecedents.length === 1) {
33466                 return antecedents[0];
33467             }
33468             return flow;
33469         }
33470         function isStatementCondition(node) {
33471             var parent = node.parent;
33472             switch (parent.kind) {
33473                 case 234:
33474                 case 236:
33475                 case 235:
33476                     return parent.expression === node;
33477                 case 237:
33478                 case 217:
33479                     return parent.condition === node;
33480             }
33481             return false;
33482         }
33483         function isLogicalExpression(node) {
33484             while (true) {
33485                 if (node.kind === 207) {
33486                     node = node.expression;
33487                 }
33488                 else if (node.kind === 214 && node.operator === 53) {
33489                     node = node.operand;
33490                 }
33491                 else {
33492                     return node.kind === 216 && (node.operatorToken.kind === 55 ||
33493                         node.operatorToken.kind === 56 ||
33494                         node.operatorToken.kind === 60);
33495                 }
33496             }
33497         }
33498         function isLogicalAssignmentExpression(node) {
33499             node = ts.skipParentheses(node);
33500             return ts.isBinaryExpression(node) && ts.isLogicalOrCoalescingAssignmentOperator(node.operatorToken.kind);
33501         }
33502         function isTopLevelLogicalExpression(node) {
33503             while (ts.isParenthesizedExpression(node.parent) ||
33504                 ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 53) {
33505                 node = node.parent;
33506             }
33507             return !isStatementCondition(node) &&
33508                 !isLogicalAssignmentExpression(node.parent) &&
33509                 !isLogicalExpression(node.parent) &&
33510                 !(ts.isOptionalChain(node.parent) && node.parent.expression === node);
33511         }
33512         function doWithConditionalBranches(action, value, trueTarget, falseTarget) {
33513             var savedTrueTarget = currentTrueTarget;
33514             var savedFalseTarget = currentFalseTarget;
33515             currentTrueTarget = trueTarget;
33516             currentFalseTarget = falseTarget;
33517             action(value);
33518             currentTrueTarget = savedTrueTarget;
33519             currentFalseTarget = savedFalseTarget;
33520         }
33521         function bindCondition(node, trueTarget, falseTarget) {
33522             doWithConditionalBranches(bind, node, trueTarget, falseTarget);
33523             if (!node || !isLogicalAssignmentExpression(node) && !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) {
33524                 addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
33525                 addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
33526             }
33527         }
33528         function bindIterativeStatement(node, breakTarget, continueTarget) {
33529             var saveBreakTarget = currentBreakTarget;
33530             var saveContinueTarget = currentContinueTarget;
33531             currentBreakTarget = breakTarget;
33532             currentContinueTarget = continueTarget;
33533             bind(node);
33534             currentBreakTarget = saveBreakTarget;
33535             currentContinueTarget = saveContinueTarget;
33536         }
33537         function setContinueTarget(node, target) {
33538             var label = activeLabelList;
33539             while (label && node.parent.kind === 245) {
33540                 label.continueTarget = target;
33541                 label = label.next;
33542                 node = node.parent;
33543             }
33544             return target;
33545         }
33546         function bindWhileStatement(node) {
33547             var preWhileLabel = setContinueTarget(node, createLoopLabel());
33548             var preBodyLabel = createBranchLabel();
33549             var postWhileLabel = createBranchLabel();
33550             addAntecedent(preWhileLabel, currentFlow);
33551             currentFlow = preWhileLabel;
33552             bindCondition(node.expression, preBodyLabel, postWhileLabel);
33553             currentFlow = finishFlowLabel(preBodyLabel);
33554             bindIterativeStatement(node.statement, postWhileLabel, preWhileLabel);
33555             addAntecedent(preWhileLabel, currentFlow);
33556             currentFlow = finishFlowLabel(postWhileLabel);
33557         }
33558         function bindDoStatement(node) {
33559             var preDoLabel = createLoopLabel();
33560             var preConditionLabel = setContinueTarget(node, createBranchLabel());
33561             var postDoLabel = createBranchLabel();
33562             addAntecedent(preDoLabel, currentFlow);
33563             currentFlow = preDoLabel;
33564             bindIterativeStatement(node.statement, postDoLabel, preConditionLabel);
33565             addAntecedent(preConditionLabel, currentFlow);
33566             currentFlow = finishFlowLabel(preConditionLabel);
33567             bindCondition(node.expression, preDoLabel, postDoLabel);
33568             currentFlow = finishFlowLabel(postDoLabel);
33569         }
33570         function bindForStatement(node) {
33571             var preLoopLabel = setContinueTarget(node, createLoopLabel());
33572             var preBodyLabel = createBranchLabel();
33573             var postLoopLabel = createBranchLabel();
33574             bind(node.initializer);
33575             addAntecedent(preLoopLabel, currentFlow);
33576             currentFlow = preLoopLabel;
33577             bindCondition(node.condition, preBodyLabel, postLoopLabel);
33578             currentFlow = finishFlowLabel(preBodyLabel);
33579             bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel);
33580             bind(node.incrementor);
33581             addAntecedent(preLoopLabel, currentFlow);
33582             currentFlow = finishFlowLabel(postLoopLabel);
33583         }
33584         function bindForInOrForOfStatement(node) {
33585             var preLoopLabel = setContinueTarget(node, createLoopLabel());
33586             var postLoopLabel = createBranchLabel();
33587             bind(node.expression);
33588             addAntecedent(preLoopLabel, currentFlow);
33589             currentFlow = preLoopLabel;
33590             if (node.kind === 239) {
33591                 bind(node.awaitModifier);
33592             }
33593             addAntecedent(postLoopLabel, currentFlow);
33594             bind(node.initializer);
33595             if (node.initializer.kind !== 250) {
33596                 bindAssignmentTargetFlow(node.initializer);
33597             }
33598             bindIterativeStatement(node.statement, postLoopLabel, preLoopLabel);
33599             addAntecedent(preLoopLabel, currentFlow);
33600             currentFlow = finishFlowLabel(postLoopLabel);
33601         }
33602         function bindIfStatement(node) {
33603             var thenLabel = createBranchLabel();
33604             var elseLabel = createBranchLabel();
33605             var postIfLabel = createBranchLabel();
33606             bindCondition(node.expression, thenLabel, elseLabel);
33607             currentFlow = finishFlowLabel(thenLabel);
33608             bind(node.thenStatement);
33609             addAntecedent(postIfLabel, currentFlow);
33610             currentFlow = finishFlowLabel(elseLabel);
33611             bind(node.elseStatement);
33612             addAntecedent(postIfLabel, currentFlow);
33613             currentFlow = finishFlowLabel(postIfLabel);
33614         }
33615         function bindReturnOrThrow(node) {
33616             bind(node.expression);
33617             if (node.kind === 242) {
33618                 hasExplicitReturn = true;
33619                 if (currentReturnTarget) {
33620                     addAntecedent(currentReturnTarget, currentFlow);
33621                 }
33622             }
33623             currentFlow = unreachableFlow;
33624         }
33625         function findActiveLabel(name) {
33626             for (var label = activeLabelList; label; label = label.next) {
33627                 if (label.name === name) {
33628                     return label;
33629                 }
33630             }
33631             return undefined;
33632         }
33633         function bindBreakOrContinueFlow(node, breakTarget, continueTarget) {
33634             var flowLabel = node.kind === 241 ? breakTarget : continueTarget;
33635             if (flowLabel) {
33636                 addAntecedent(flowLabel, currentFlow);
33637                 currentFlow = unreachableFlow;
33638             }
33639         }
33640         function bindBreakOrContinueStatement(node) {
33641             bind(node.label);
33642             if (node.label) {
33643                 var activeLabel = findActiveLabel(node.label.escapedText);
33644                 if (activeLabel) {
33645                     activeLabel.referenced = true;
33646                     bindBreakOrContinueFlow(node, activeLabel.breakTarget, activeLabel.continueTarget);
33647                 }
33648             }
33649             else {
33650                 bindBreakOrContinueFlow(node, currentBreakTarget, currentContinueTarget);
33651             }
33652         }
33653         function bindTryStatement(node) {
33654             var saveReturnTarget = currentReturnTarget;
33655             var saveExceptionTarget = currentExceptionTarget;
33656             var normalExitLabel = createBranchLabel();
33657             var returnLabel = createBranchLabel();
33658             var exceptionLabel = createBranchLabel();
33659             if (node.finallyBlock) {
33660                 currentReturnTarget = returnLabel;
33661             }
33662             addAntecedent(exceptionLabel, currentFlow);
33663             currentExceptionTarget = exceptionLabel;
33664             bind(node.tryBlock);
33665             addAntecedent(normalExitLabel, currentFlow);
33666             if (node.catchClause) {
33667                 currentFlow = finishFlowLabel(exceptionLabel);
33668                 exceptionLabel = createBranchLabel();
33669                 addAntecedent(exceptionLabel, currentFlow);
33670                 currentExceptionTarget = exceptionLabel;
33671                 bind(node.catchClause);
33672                 addAntecedent(normalExitLabel, currentFlow);
33673             }
33674             currentReturnTarget = saveReturnTarget;
33675             currentExceptionTarget = saveExceptionTarget;
33676             if (node.finallyBlock) {
33677                 var finallyLabel = createBranchLabel();
33678                 finallyLabel.antecedents = ts.concatenate(ts.concatenate(normalExitLabel.antecedents, exceptionLabel.antecedents), returnLabel.antecedents);
33679                 currentFlow = finallyLabel;
33680                 bind(node.finallyBlock);
33681                 if (currentFlow.flags & 1) {
33682                     currentFlow = unreachableFlow;
33683                 }
33684                 else {
33685                     if (currentReturnTarget && returnLabel.antecedents) {
33686                         addAntecedent(currentReturnTarget, createReduceLabel(finallyLabel, returnLabel.antecedents, currentFlow));
33687                     }
33688                     if (currentExceptionTarget && exceptionLabel.antecedents) {
33689                         addAntecedent(currentExceptionTarget, createReduceLabel(finallyLabel, exceptionLabel.antecedents, currentFlow));
33690                     }
33691                     currentFlow = normalExitLabel.antecedents ? createReduceLabel(finallyLabel, normalExitLabel.antecedents, currentFlow) : unreachableFlow;
33692                 }
33693             }
33694             else {
33695                 currentFlow = finishFlowLabel(normalExitLabel);
33696             }
33697         }
33698         function bindSwitchStatement(node) {
33699             var postSwitchLabel = createBranchLabel();
33700             bind(node.expression);
33701             var saveBreakTarget = currentBreakTarget;
33702             var savePreSwitchCaseFlow = preSwitchCaseFlow;
33703             currentBreakTarget = postSwitchLabel;
33704             preSwitchCaseFlow = currentFlow;
33705             bind(node.caseBlock);
33706             addAntecedent(postSwitchLabel, currentFlow);
33707             var hasDefault = ts.forEach(node.caseBlock.clauses, function (c) { return c.kind === 285; });
33708             node.possiblyExhaustive = !hasDefault && !postSwitchLabel.antecedents;
33709             if (!hasDefault) {
33710                 addAntecedent(postSwitchLabel, createFlowSwitchClause(preSwitchCaseFlow, node, 0, 0));
33711             }
33712             currentBreakTarget = saveBreakTarget;
33713             preSwitchCaseFlow = savePreSwitchCaseFlow;
33714             currentFlow = finishFlowLabel(postSwitchLabel);
33715         }
33716         function bindCaseBlock(node) {
33717             var clauses = node.clauses;
33718             var isNarrowingSwitch = isNarrowingExpression(node.parent.expression);
33719             var fallthroughFlow = unreachableFlow;
33720             for (var i = 0; i < clauses.length; i++) {
33721                 var clauseStart = i;
33722                 while (!clauses[i].statements.length && i + 1 < clauses.length) {
33723                     bind(clauses[i]);
33724                     i++;
33725                 }
33726                 var preCaseLabel = createBranchLabel();
33727                 addAntecedent(preCaseLabel, isNarrowingSwitch ? createFlowSwitchClause(preSwitchCaseFlow, node.parent, clauseStart, i + 1) : preSwitchCaseFlow);
33728                 addAntecedent(preCaseLabel, fallthroughFlow);
33729                 currentFlow = finishFlowLabel(preCaseLabel);
33730                 var clause = clauses[i];
33731                 bind(clause);
33732                 fallthroughFlow = currentFlow;
33733                 if (!(currentFlow.flags & 1) && i !== clauses.length - 1 && options.noFallthroughCasesInSwitch) {
33734                     clause.fallthroughFlowNode = currentFlow;
33735                 }
33736             }
33737         }
33738         function bindCaseClause(node) {
33739             var saveCurrentFlow = currentFlow;
33740             currentFlow = preSwitchCaseFlow;
33741             bind(node.expression);
33742             currentFlow = saveCurrentFlow;
33743             bindEach(node.statements);
33744         }
33745         function bindExpressionStatement(node) {
33746             bind(node.expression);
33747             maybeBindExpressionFlowIfCall(node.expression);
33748         }
33749         function maybeBindExpressionFlowIfCall(node) {
33750             if (node.kind === 203) {
33751                 var call = node;
33752                 if (ts.isDottedName(call.expression) && call.expression.kind !== 105) {
33753                     currentFlow = createFlowCall(currentFlow, call);
33754                 }
33755             }
33756         }
33757         function bindLabeledStatement(node) {
33758             var postStatementLabel = createBranchLabel();
33759             activeLabelList = {
33760                 next: activeLabelList,
33761                 name: node.label.escapedText,
33762                 breakTarget: postStatementLabel,
33763                 continueTarget: undefined,
33764                 referenced: false
33765             };
33766             bind(node.label);
33767             bind(node.statement);
33768             if (!activeLabelList.referenced && !options.allowUnusedLabels) {
33769                 errorOrSuggestionOnNode(ts.unusedLabelIsError(options), node.label, ts.Diagnostics.Unused_label);
33770             }
33771             activeLabelList = activeLabelList.next;
33772             addAntecedent(postStatementLabel, currentFlow);
33773             currentFlow = finishFlowLabel(postStatementLabel);
33774         }
33775         function bindDestructuringTargetFlow(node) {
33776             if (node.kind === 216 && node.operatorToken.kind === 62) {
33777                 bindAssignmentTargetFlow(node.left);
33778             }
33779             else {
33780                 bindAssignmentTargetFlow(node);
33781             }
33782         }
33783         function bindAssignmentTargetFlow(node) {
33784             if (isNarrowableReference(node)) {
33785                 currentFlow = createFlowMutation(16, currentFlow, node);
33786             }
33787             else if (node.kind === 199) {
33788                 for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
33789                     var e = _a[_i];
33790                     if (e.kind === 220) {
33791                         bindAssignmentTargetFlow(e.expression);
33792                     }
33793                     else {
33794                         bindDestructuringTargetFlow(e);
33795                     }
33796                 }
33797             }
33798             else if (node.kind === 200) {
33799                 for (var _b = 0, _c = node.properties; _b < _c.length; _b++) {
33800                     var p = _c[_b];
33801                     if (p.kind === 288) {
33802                         bindDestructuringTargetFlow(p.initializer);
33803                     }
33804                     else if (p.kind === 289) {
33805                         bindAssignmentTargetFlow(p.name);
33806                     }
33807                     else if (p.kind === 290) {
33808                         bindAssignmentTargetFlow(p.expression);
33809                     }
33810                 }
33811             }
33812         }
33813         function bindLogicalLikeExpression(node, trueTarget, falseTarget) {
33814             var preRightLabel = createBranchLabel();
33815             if (node.operatorToken.kind === 55 || node.operatorToken.kind === 75) {
33816                 bindCondition(node.left, preRightLabel, falseTarget);
33817             }
33818             else {
33819                 bindCondition(node.left, trueTarget, preRightLabel);
33820             }
33821             currentFlow = finishFlowLabel(preRightLabel);
33822             bind(node.operatorToken);
33823             if (ts.isLogicalOrCoalescingAssignmentOperator(node.operatorToken.kind)) {
33824                 doWithConditionalBranches(bind, node.right, trueTarget, falseTarget);
33825                 bindAssignmentTargetFlow(node.left);
33826                 addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
33827                 addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
33828             }
33829             else {
33830                 bindCondition(node.right, trueTarget, falseTarget);
33831             }
33832         }
33833         function bindPrefixUnaryExpressionFlow(node) {
33834             if (node.operator === 53) {
33835                 var saveTrueTarget = currentTrueTarget;
33836                 currentTrueTarget = currentFalseTarget;
33837                 currentFalseTarget = saveTrueTarget;
33838                 bindEachChild(node);
33839                 currentFalseTarget = currentTrueTarget;
33840                 currentTrueTarget = saveTrueTarget;
33841             }
33842             else {
33843                 bindEachChild(node);
33844                 if (node.operator === 45 || node.operator === 46) {
33845                     bindAssignmentTargetFlow(node.operand);
33846                 }
33847             }
33848         }
33849         function bindPostfixUnaryExpressionFlow(node) {
33850             bindEachChild(node);
33851             if (node.operator === 45 || node.operator === 46) {
33852                 bindAssignmentTargetFlow(node.operand);
33853             }
33854         }
33855         function bindDestructuringAssignmentFlow(node) {
33856             if (inAssignmentPattern) {
33857                 inAssignmentPattern = false;
33858                 bind(node.operatorToken);
33859                 bind(node.right);
33860                 inAssignmentPattern = true;
33861                 bind(node.left);
33862             }
33863             else {
33864                 inAssignmentPattern = true;
33865                 bind(node.left);
33866                 inAssignmentPattern = false;
33867                 bind(node.operatorToken);
33868                 bind(node.right);
33869             }
33870             bindAssignmentTargetFlow(node.left);
33871         }
33872         function bindBinaryExpressionFlow(node) {
33873             var workStacks = {
33874                 expr: [node],
33875                 state: [1],
33876                 inStrictMode: [undefined],
33877                 parent: [undefined],
33878             };
33879             var stackIndex = 0;
33880             while (stackIndex >= 0) {
33881                 node = workStacks.expr[stackIndex];
33882                 switch (workStacks.state[stackIndex]) {
33883                     case 0: {
33884                         ts.setParent(node, parent);
33885                         var saveInStrictMode = inStrictMode;
33886                         bindWorker(node);
33887                         var saveParent = parent;
33888                         parent = node;
33889                         advanceState(1, saveInStrictMode, saveParent);
33890                         break;
33891                     }
33892                     case 1: {
33893                         var operator = node.operatorToken.kind;
33894                         if (operator === 55 || operator === 56 || operator === 60 ||
33895                             ts.isLogicalOrCoalescingAssignmentOperator(operator)) {
33896                             if (isTopLevelLogicalExpression(node)) {
33897                                 var postExpressionLabel = createBranchLabel();
33898                                 bindLogicalLikeExpression(node, postExpressionLabel, postExpressionLabel);
33899                                 currentFlow = finishFlowLabel(postExpressionLabel);
33900                             }
33901                             else {
33902                                 bindLogicalLikeExpression(node, currentTrueTarget, currentFalseTarget);
33903                             }
33904                             completeNode();
33905                         }
33906                         else {
33907                             advanceState(2);
33908                             maybeBind(node.left);
33909                         }
33910                         break;
33911                     }
33912                     case 2: {
33913                         if (node.operatorToken.kind === 27) {
33914                             maybeBindExpressionFlowIfCall(node.left);
33915                         }
33916                         advanceState(3);
33917                         maybeBind(node.operatorToken);
33918                         break;
33919                     }
33920                     case 3: {
33921                         advanceState(4);
33922                         maybeBind(node.right);
33923                         break;
33924                     }
33925                     case 4: {
33926                         var operator = node.operatorToken.kind;
33927                         if (ts.isAssignmentOperator(operator) && !ts.isAssignmentTarget(node)) {
33928                             bindAssignmentTargetFlow(node.left);
33929                             if (operator === 62 && node.left.kind === 202) {
33930                                 var elementAccess = node.left;
33931                                 if (isNarrowableOperand(elementAccess.expression)) {
33932                                     currentFlow = createFlowMutation(256, currentFlow, node);
33933                                 }
33934                             }
33935                         }
33936                         completeNode();
33937                         break;
33938                     }
33939                     default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for bindBinaryExpressionFlow");
33940                 }
33941             }
33942             function advanceState(state, isInStrictMode, parent) {
33943                 workStacks.state[stackIndex] = state;
33944                 if (isInStrictMode !== undefined) {
33945                     workStacks.inStrictMode[stackIndex] = isInStrictMode;
33946                 }
33947                 if (parent !== undefined) {
33948                     workStacks.parent[stackIndex] = parent;
33949                 }
33950             }
33951             function completeNode() {
33952                 if (workStacks.inStrictMode[stackIndex] !== undefined) {
33953                     inStrictMode = workStacks.inStrictMode[stackIndex];
33954                     parent = workStacks.parent[stackIndex];
33955                 }
33956                 stackIndex--;
33957             }
33958             function maybeBind(node) {
33959                 if (node && ts.isBinaryExpression(node) && !ts.isDestructuringAssignment(node)) {
33960                     stackIndex++;
33961                     workStacks.expr[stackIndex] = node;
33962                     workStacks.state[stackIndex] = 0;
33963                     workStacks.inStrictMode[stackIndex] = undefined;
33964                     workStacks.parent[stackIndex] = undefined;
33965                 }
33966                 else {
33967                     bind(node);
33968                 }
33969             }
33970         }
33971         function bindDeleteExpressionFlow(node) {
33972             bindEachChild(node);
33973             if (node.expression.kind === 201) {
33974                 bindAssignmentTargetFlow(node.expression);
33975             }
33976         }
33977         function bindConditionalExpressionFlow(node) {
33978             var trueLabel = createBranchLabel();
33979             var falseLabel = createBranchLabel();
33980             var postExpressionLabel = createBranchLabel();
33981             bindCondition(node.condition, trueLabel, falseLabel);
33982             currentFlow = finishFlowLabel(trueLabel);
33983             bind(node.questionToken);
33984             bind(node.whenTrue);
33985             addAntecedent(postExpressionLabel, currentFlow);
33986             currentFlow = finishFlowLabel(falseLabel);
33987             bind(node.colonToken);
33988             bind(node.whenFalse);
33989             addAntecedent(postExpressionLabel, currentFlow);
33990             currentFlow = finishFlowLabel(postExpressionLabel);
33991         }
33992         function bindInitializedVariableFlow(node) {
33993             var name = !ts.isOmittedExpression(node) ? node.name : undefined;
33994             if (ts.isBindingPattern(name)) {
33995                 for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
33996                     var child = _a[_i];
33997                     bindInitializedVariableFlow(child);
33998                 }
33999             }
34000             else {
34001                 currentFlow = createFlowMutation(16, currentFlow, node);
34002             }
34003         }
34004         function bindVariableDeclarationFlow(node) {
34005             bindEachChild(node);
34006             if (node.initializer || ts.isForInOrOfStatement(node.parent.parent)) {
34007                 bindInitializedVariableFlow(node);
34008             }
34009         }
34010         function bindBindingElementFlow(node) {
34011             if (ts.isBindingPattern(node.name)) {
34012                 bindEach(node.decorators);
34013                 bindEach(node.modifiers);
34014                 bind(node.dotDotDotToken);
34015                 bind(node.propertyName);
34016                 bind(node.initializer);
34017                 bind(node.name);
34018             }
34019             else {
34020                 bindEachChild(node);
34021             }
34022         }
34023         function bindJSDocTypeAlias(node) {
34024             ts.setParent(node.tagName, node);
34025             if (node.kind !== 325 && node.fullName) {
34026                 ts.setParent(node.fullName, node);
34027                 ts.setParentRecursive(node.fullName, false);
34028             }
34029         }
34030         function bindJSDocClassTag(node) {
34031             bindEachChild(node);
34032             var host = ts.getHostSignatureFromJSDoc(node);
34033             if (host && host.kind !== 165) {
34034                 addDeclarationToSymbol(host.symbol, host, 32);
34035             }
34036         }
34037         function bindOptionalExpression(node, trueTarget, falseTarget) {
34038             doWithConditionalBranches(bind, node, trueTarget, falseTarget);
34039             if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) {
34040                 addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
34041                 addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
34042             }
34043         }
34044         function bindOptionalChainRest(node) {
34045             switch (node.kind) {
34046                 case 201:
34047                     bind(node.questionDotToken);
34048                     bind(node.name);
34049                     break;
34050                 case 202:
34051                     bind(node.questionDotToken);
34052                     bind(node.argumentExpression);
34053                     break;
34054                 case 203:
34055                     bind(node.questionDotToken);
34056                     bindEach(node.typeArguments);
34057                     bindEach(node.arguments);
34058                     break;
34059             }
34060         }
34061         function bindOptionalChain(node, trueTarget, falseTarget) {
34062             var preChainLabel = ts.isOptionalChainRoot(node) ? createBranchLabel() : undefined;
34063             bindOptionalExpression(node.expression, preChainLabel || trueTarget, falseTarget);
34064             if (preChainLabel) {
34065                 currentFlow = finishFlowLabel(preChainLabel);
34066             }
34067             doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget);
34068             if (ts.isOutermostOptionalChain(node)) {
34069                 addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
34070                 addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
34071             }
34072         }
34073         function bindOptionalChainFlow(node) {
34074             if (isTopLevelLogicalExpression(node)) {
34075                 var postExpressionLabel = createBranchLabel();
34076                 bindOptionalChain(node, postExpressionLabel, postExpressionLabel);
34077                 currentFlow = finishFlowLabel(postExpressionLabel);
34078             }
34079             else {
34080                 bindOptionalChain(node, currentTrueTarget, currentFalseTarget);
34081             }
34082         }
34083         function bindNonNullExpressionFlow(node) {
34084             if (ts.isOptionalChain(node)) {
34085                 bindOptionalChainFlow(node);
34086             }
34087             else {
34088                 bindEachChild(node);
34089             }
34090         }
34091         function bindAccessExpressionFlow(node) {
34092             if (ts.isOptionalChain(node)) {
34093                 bindOptionalChainFlow(node);
34094             }
34095             else {
34096                 bindEachChild(node);
34097             }
34098         }
34099         function bindCallExpressionFlow(node) {
34100             if (ts.isOptionalChain(node)) {
34101                 bindOptionalChainFlow(node);
34102             }
34103             else {
34104                 var expr = ts.skipParentheses(node.expression);
34105                 if (expr.kind === 208 || expr.kind === 209) {
34106                     bindEach(node.typeArguments);
34107                     bindEach(node.arguments);
34108                     bind(node.expression);
34109                 }
34110                 else {
34111                     bindEachChild(node);
34112                     if (node.expression.kind === 105) {
34113                         currentFlow = createFlowCall(currentFlow, node);
34114                     }
34115                 }
34116             }
34117             if (node.expression.kind === 201) {
34118                 var propertyAccess = node.expression;
34119                 if (ts.isIdentifier(propertyAccess.name) && isNarrowableOperand(propertyAccess.expression) && ts.isPushOrUnshiftIdentifier(propertyAccess.name)) {
34120                     currentFlow = createFlowMutation(256, currentFlow, node);
34121                 }
34122             }
34123         }
34124         function getContainerFlags(node) {
34125             switch (node.kind) {
34126                 case 221:
34127                 case 252:
34128                 case 255:
34129                 case 200:
34130                 case 177:
34131                 case 312:
34132                 case 281:
34133                     return 1;
34134                 case 253:
34135                     return 1 | 64;
34136                 case 256:
34137                 case 254:
34138                 case 190:
34139                     return 1 | 32;
34140                 case 297:
34141                     return 1 | 4 | 32;
34142                 case 165:
34143                     if (ts.isObjectLiteralOrClassExpressionMethod(node)) {
34144                         return 1 | 4 | 32 | 8 | 128;
34145                     }
34146                 case 166:
34147                 case 251:
34148                 case 164:
34149                 case 167:
34150                 case 168:
34151                 case 169:
34152                 case 313:
34153                 case 308:
34154                 case 174:
34155                 case 170:
34156                 case 171:
34157                 case 175:
34158                     return 1 | 4 | 32 | 8;
34159                 case 208:
34160                 case 209:
34161                     return 1 | 4 | 32 | 8 | 16;
34162                 case 257:
34163                     return 4;
34164                 case 163:
34165                     return node.initializer ? 4 : 0;
34166                 case 287:
34167                 case 237:
34168                 case 238:
34169                 case 239:
34170                 case 258:
34171                     return 2;
34172                 case 230:
34173                     return ts.isFunctionLike(node.parent) ? 0 : 2;
34174             }
34175             return 0;
34176         }
34177         function addToContainerChain(next) {
34178             if (lastContainer) {
34179                 lastContainer.nextContainer = next;
34180             }
34181             lastContainer = next;
34182         }
34183         function declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes) {
34184             switch (container.kind) {
34185                 case 256:
34186                     return declareModuleMember(node, symbolFlags, symbolExcludes);
34187                 case 297:
34188                     return declareSourceFileMember(node, symbolFlags, symbolExcludes);
34189                 case 221:
34190                 case 252:
34191                     return declareClassMember(node, symbolFlags, symbolExcludes);
34192                 case 255:
34193                     return declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes);
34194                 case 177:
34195                 case 312:
34196                 case 200:
34197                 case 253:
34198                 case 281:
34199                     return declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes);
34200                 case 174:
34201                 case 175:
34202                 case 169:
34203                 case 170:
34204                 case 313:
34205                 case 171:
34206                 case 165:
34207                 case 164:
34208                 case 166:
34209                 case 167:
34210                 case 168:
34211                 case 251:
34212                 case 208:
34213                 case 209:
34214                 case 308:
34215                 case 331:
34216                 case 324:
34217                 case 254:
34218                 case 190:
34219                     return declareSymbol(container.locals, undefined, node, symbolFlags, symbolExcludes);
34220             }
34221         }
34222         function declareClassMember(node, symbolFlags, symbolExcludes) {
34223             return ts.hasSyntacticModifier(node, 32)
34224                 ? declareSymbol(container.symbol.exports, container.symbol, node, symbolFlags, symbolExcludes)
34225                 : declareSymbol(container.symbol.members, container.symbol, node, symbolFlags, symbolExcludes);
34226         }
34227         function declareSourceFileMember(node, symbolFlags, symbolExcludes) {
34228             return ts.isExternalModule(file)
34229                 ? declareModuleMember(node, symbolFlags, symbolExcludes)
34230                 : declareSymbol(file.locals, undefined, node, symbolFlags, symbolExcludes);
34231         }
34232         function hasExportDeclarations(node) {
34233             var body = ts.isSourceFile(node) ? node : ts.tryCast(node.body, ts.isModuleBlock);
34234             return !!body && body.statements.some(function (s) { return ts.isExportDeclaration(s) || ts.isExportAssignment(s); });
34235         }
34236         function setExportContextFlag(node) {
34237             if (node.flags & 8388608 && !hasExportDeclarations(node)) {
34238                 node.flags |= 64;
34239             }
34240             else {
34241                 node.flags &= ~64;
34242             }
34243         }
34244         function bindModuleDeclaration(node) {
34245             setExportContextFlag(node);
34246             if (ts.isAmbientModule(node)) {
34247                 if (ts.hasSyntacticModifier(node, 1)) {
34248                     errorOnFirstToken(node, ts.Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible);
34249                 }
34250                 if (ts.isModuleAugmentationExternal(node)) {
34251                     declareModuleSymbol(node);
34252                 }
34253                 else {
34254                     var pattern = void 0;
34255                     if (node.name.kind === 10) {
34256                         var text = node.name.text;
34257                         if (ts.hasZeroOrOneAsteriskCharacter(text)) {
34258                             pattern = ts.tryParsePattern(text);
34259                         }
34260                         else {
34261                             errorOnFirstToken(node.name, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, text);
34262                         }
34263                     }
34264                     var symbol = declareSymbolAndAddToSymbolTable(node, 512, 110735);
34265                     file.patternAmbientModules = ts.append(file.patternAmbientModules, pattern && { pattern: pattern, symbol: symbol });
34266                 }
34267             }
34268             else {
34269                 var state = declareModuleSymbol(node);
34270                 if (state !== 0) {
34271                     var symbol = node.symbol;
34272                     symbol.constEnumOnlyModule = (!(symbol.flags & (16 | 32 | 256)))
34273                         && state === 2
34274                         && symbol.constEnumOnlyModule !== false;
34275                 }
34276             }
34277         }
34278         function declareModuleSymbol(node) {
34279             var state = getModuleInstanceState(node);
34280             var instantiated = state !== 0;
34281             declareSymbolAndAddToSymbolTable(node, instantiated ? 512 : 1024, instantiated ? 110735 : 0);
34282             return state;
34283         }
34284         function bindFunctionOrConstructorType(node) {
34285             var symbol = createSymbol(131072, getDeclarationName(node));
34286             addDeclarationToSymbol(symbol, node, 131072);
34287             var typeLiteralSymbol = createSymbol(2048, "__type");
34288             addDeclarationToSymbol(typeLiteralSymbol, node, 2048);
34289             typeLiteralSymbol.members = ts.createSymbolTable();
34290             typeLiteralSymbol.members.set(symbol.escapedName, symbol);
34291         }
34292         function bindObjectLiteralExpression(node) {
34293             if (inStrictMode && !ts.isAssignmentTarget(node)) {
34294                 var seen = new ts.Map();
34295                 for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
34296                     var prop = _a[_i];
34297                     if (prop.kind === 290 || prop.name.kind !== 78) {
34298                         continue;
34299                     }
34300                     var identifier = prop.name;
34301                     var currentKind = prop.kind === 288 || prop.kind === 289 || prop.kind === 165
34302                         ? 1
34303                         : 2;
34304                     var existingKind = seen.get(identifier.escapedText);
34305                     if (!existingKind) {
34306                         seen.set(identifier.escapedText, currentKind);
34307                         continue;
34308                     }
34309                     if (currentKind === 1 && existingKind === 1) {
34310                         var span = ts.getErrorSpanForNode(file, identifier);
34311                         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));
34312                     }
34313                 }
34314             }
34315             return bindAnonymousDeclaration(node, 4096, "__object");
34316         }
34317         function bindJsxAttributes(node) {
34318             return bindAnonymousDeclaration(node, 4096, "__jsxAttributes");
34319         }
34320         function bindJsxAttribute(node, symbolFlags, symbolExcludes) {
34321             return declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
34322         }
34323         function bindAnonymousDeclaration(node, symbolFlags, name) {
34324             var symbol = createSymbol(symbolFlags, name);
34325             if (symbolFlags & (8 | 106500)) {
34326                 symbol.parent = container.symbol;
34327             }
34328             addDeclarationToSymbol(symbol, node, symbolFlags);
34329             return symbol;
34330         }
34331         function bindBlockScopedDeclaration(node, symbolFlags, symbolExcludes) {
34332             switch (blockScopeContainer.kind) {
34333                 case 256:
34334                     declareModuleMember(node, symbolFlags, symbolExcludes);
34335                     break;
34336                 case 297:
34337                     if (ts.isExternalOrCommonJsModule(container)) {
34338                         declareModuleMember(node, symbolFlags, symbolExcludes);
34339                         break;
34340                     }
34341                 default:
34342                     if (!blockScopeContainer.locals) {
34343                         blockScopeContainer.locals = ts.createSymbolTable();
34344                         addToContainerChain(blockScopeContainer);
34345                     }
34346                     declareSymbol(blockScopeContainer.locals, undefined, node, symbolFlags, symbolExcludes);
34347             }
34348         }
34349         function delayedBindJSDocTypedefTag() {
34350             if (!delayedTypeAliases) {
34351                 return;
34352             }
34353             var saveContainer = container;
34354             var saveLastContainer = lastContainer;
34355             var saveBlockScopeContainer = blockScopeContainer;
34356             var saveParent = parent;
34357             var saveCurrentFlow = currentFlow;
34358             for (var _i = 0, delayedTypeAliases_1 = delayedTypeAliases; _i < delayedTypeAliases_1.length; _i++) {
34359                 var typeAlias = delayedTypeAliases_1[_i];
34360                 var host = ts.getJSDocHost(typeAlias);
34361                 container = (host && ts.findAncestor(host.parent, function (n) { return !!(getContainerFlags(n) & 1); })) || file;
34362                 blockScopeContainer = (host && ts.getEnclosingBlockScopeContainer(host)) || file;
34363                 currentFlow = initFlowNode({ flags: 2 });
34364                 parent = typeAlias;
34365                 bind(typeAlias.typeExpression);
34366                 var declName = ts.getNameOfDeclaration(typeAlias);
34367                 if ((ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName) && declName && ts.isPropertyAccessEntityNameExpression(declName.parent)) {
34368                     var isTopLevel = isTopLevelNamespaceAssignment(declName.parent);
34369                     if (isTopLevel) {
34370                         bindPotentiallyMissingNamespaces(file.symbol, declName.parent, isTopLevel, !!ts.findAncestor(declName, function (d) { return ts.isPropertyAccessExpression(d) && d.name.escapedText === "prototype"; }), false);
34371                         var oldContainer = container;
34372                         switch (ts.getAssignmentDeclarationPropertyAccessKind(declName.parent)) {
34373                             case 1:
34374                             case 2:
34375                                 if (!ts.isExternalOrCommonJsModule(file)) {
34376                                     container = undefined;
34377                                 }
34378                                 else {
34379                                     container = file;
34380                                 }
34381                                 break;
34382                             case 4:
34383                                 container = declName.parent.expression;
34384                                 break;
34385                             case 3:
34386                                 container = declName.parent.expression.name;
34387                                 break;
34388                             case 5:
34389                                 container = isExportsOrModuleExportsOrAlias(file, declName.parent.expression) ? file
34390                                     : ts.isPropertyAccessExpression(declName.parent.expression) ? declName.parent.expression.name
34391                                         : declName.parent.expression;
34392                                 break;
34393                             case 0:
34394                                 return ts.Debug.fail("Shouldn't have detected typedef or enum on non-assignment declaration");
34395                         }
34396                         if (container) {
34397                             declareModuleMember(typeAlias, 524288, 788968);
34398                         }
34399                         container = oldContainer;
34400                     }
34401                 }
34402                 else if (ts.isJSDocEnumTag(typeAlias) || !typeAlias.fullName || typeAlias.fullName.kind === 78) {
34403                     parent = typeAlias.parent;
34404                     bindBlockScopedDeclaration(typeAlias, 524288, 788968);
34405                 }
34406                 else {
34407                     bind(typeAlias.fullName);
34408                 }
34409             }
34410             container = saveContainer;
34411             lastContainer = saveLastContainer;
34412             blockScopeContainer = saveBlockScopeContainer;
34413             parent = saveParent;
34414             currentFlow = saveCurrentFlow;
34415         }
34416         function checkContextualIdentifier(node) {
34417             if (!file.parseDiagnostics.length &&
34418                 !(node.flags & 8388608) &&
34419                 !(node.flags & 4194304) &&
34420                 !ts.isIdentifierName(node)) {
34421                 if (inStrictMode &&
34422                     node.originalKeywordKind >= 116 &&
34423                     node.originalKeywordKind <= 124) {
34424                     file.bindDiagnostics.push(createDiagnosticForNode(node, getStrictModeIdentifierMessage(node), ts.declarationNameToString(node)));
34425                 }
34426                 else if (node.originalKeywordKind === 130) {
34427                     if (ts.isExternalModule(file) && ts.isInTopLevelContext(node)) {
34428                         file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_at_the_top_level_of_a_module, ts.declarationNameToString(node)));
34429                     }
34430                     else if (node.flags & 32768) {
34431                         file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node)));
34432                     }
34433                 }
34434                 else if (node.originalKeywordKind === 124 && node.flags & 8192) {
34435                     file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_that_cannot_be_used_here, ts.declarationNameToString(node)));
34436                 }
34437             }
34438         }
34439         function getStrictModeIdentifierMessage(node) {
34440             if (ts.getContainingClass(node)) {
34441                 return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Class_definitions_are_automatically_in_strict_mode;
34442             }
34443             if (file.externalModuleIndicator) {
34444                 return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode_Modules_are_automatically_in_strict_mode;
34445             }
34446             return ts.Diagnostics.Identifier_expected_0_is_a_reserved_word_in_strict_mode;
34447         }
34448         function checkPrivateIdentifier(node) {
34449             if (node.escapedText === "#constructor") {
34450                 if (!file.parseDiagnostics.length) {
34451                     file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.constructor_is_a_reserved_word, ts.declarationNameToString(node)));
34452                 }
34453             }
34454         }
34455         function checkStrictModeBinaryExpression(node) {
34456             if (inStrictMode && ts.isLeftHandSideExpression(node.left) && ts.isAssignmentOperator(node.operatorToken.kind)) {
34457                 checkStrictModeEvalOrArguments(node, node.left);
34458             }
34459         }
34460         function checkStrictModeCatchClause(node) {
34461             if (inStrictMode && node.variableDeclaration) {
34462                 checkStrictModeEvalOrArguments(node, node.variableDeclaration.name);
34463             }
34464         }
34465         function checkStrictModeDeleteExpression(node) {
34466             if (inStrictMode && node.expression.kind === 78) {
34467                 var span = ts.getErrorSpanForNode(file, node.expression);
34468                 file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, ts.Diagnostics.delete_cannot_be_called_on_an_identifier_in_strict_mode));
34469             }
34470         }
34471         function isEvalOrArgumentsIdentifier(node) {
34472             return ts.isIdentifier(node) && (node.escapedText === "eval" || node.escapedText === "arguments");
34473         }
34474         function checkStrictModeEvalOrArguments(contextNode, name) {
34475             if (name && name.kind === 78) {
34476                 var identifier = name;
34477                 if (isEvalOrArgumentsIdentifier(identifier)) {
34478                     var span = ts.getErrorSpanForNode(file, name);
34479                     file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, getStrictModeEvalOrArgumentsMessage(contextNode), ts.idText(identifier)));
34480                 }
34481             }
34482         }
34483         function getStrictModeEvalOrArgumentsMessage(node) {
34484             if (ts.getContainingClass(node)) {
34485                 return ts.Diagnostics.Invalid_use_of_0_Class_definitions_are_automatically_in_strict_mode;
34486             }
34487             if (file.externalModuleIndicator) {
34488                 return ts.Diagnostics.Invalid_use_of_0_Modules_are_automatically_in_strict_mode;
34489             }
34490             return ts.Diagnostics.Invalid_use_of_0_in_strict_mode;
34491         }
34492         function checkStrictModeFunctionName(node) {
34493             if (inStrictMode) {
34494                 checkStrictModeEvalOrArguments(node, node.name);
34495             }
34496         }
34497         function getStrictModeBlockScopeFunctionDeclarationMessage(node) {
34498             if (ts.getContainingClass(node)) {
34499                 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;
34500             }
34501             if (file.externalModuleIndicator) {
34502                 return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5_Modules_are_automatically_in_strict_mode;
34503             }
34504             return ts.Diagnostics.Function_declarations_are_not_allowed_inside_blocks_in_strict_mode_when_targeting_ES3_or_ES5;
34505         }
34506         function checkStrictModeFunctionDeclaration(node) {
34507             if (languageVersion < 2) {
34508                 if (blockScopeContainer.kind !== 297 &&
34509                     blockScopeContainer.kind !== 256 &&
34510                     !ts.isFunctionLike(blockScopeContainer)) {
34511                     var errorSpan = ts.getErrorSpanForNode(file, node);
34512                     file.bindDiagnostics.push(ts.createFileDiagnostic(file, errorSpan.start, errorSpan.length, getStrictModeBlockScopeFunctionDeclarationMessage(node)));
34513                 }
34514             }
34515         }
34516         function checkStrictModeNumericLiteral(node) {
34517             if (inStrictMode && node.numericLiteralFlags & 32) {
34518                 file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Octal_literals_are_not_allowed_in_strict_mode));
34519             }
34520         }
34521         function checkStrictModePostfixUnaryExpression(node) {
34522             if (inStrictMode) {
34523                 checkStrictModeEvalOrArguments(node, node.operand);
34524             }
34525         }
34526         function checkStrictModePrefixUnaryExpression(node) {
34527             if (inStrictMode) {
34528                 if (node.operator === 45 || node.operator === 46) {
34529                     checkStrictModeEvalOrArguments(node, node.operand);
34530                 }
34531             }
34532         }
34533         function checkStrictModeWithStatement(node) {
34534             if (inStrictMode) {
34535                 errorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_strict_mode);
34536             }
34537         }
34538         function checkStrictModeLabeledStatement(node) {
34539             if (inStrictMode && options.target >= 2) {
34540                 if (ts.isDeclarationStatement(node.statement) || ts.isVariableStatement(node.statement)) {
34541                     errorOnFirstToken(node.label, ts.Diagnostics.A_label_is_not_allowed_here);
34542                 }
34543             }
34544         }
34545         function errorOnFirstToken(node, message, arg0, arg1, arg2) {
34546             var span = ts.getSpanOfTokenAtPosition(file, node.pos);
34547             file.bindDiagnostics.push(ts.createFileDiagnostic(file, span.start, span.length, message, arg0, arg1, arg2));
34548         }
34549         function errorOrSuggestionOnNode(isError, node, message) {
34550             errorOrSuggestionOnRange(isError, node, node, message);
34551         }
34552         function errorOrSuggestionOnRange(isError, startNode, endNode, message) {
34553             addErrorOrSuggestionDiagnostic(isError, { pos: ts.getTokenPosOfNode(startNode, file), end: endNode.end }, message);
34554         }
34555         function addErrorOrSuggestionDiagnostic(isError, range, message) {
34556             var diag = ts.createFileDiagnostic(file, range.pos, range.end - range.pos, message);
34557             if (isError) {
34558                 file.bindDiagnostics.push(diag);
34559             }
34560             else {
34561                 file.bindSuggestionDiagnostics = ts.append(file.bindSuggestionDiagnostics, __assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion }));
34562             }
34563         }
34564         function bind(node) {
34565             if (!node) {
34566                 return;
34567             }
34568             ts.setParent(node, parent);
34569             var saveInStrictMode = inStrictMode;
34570             bindWorker(node);
34571             if (node.kind > 156) {
34572                 var saveParent = parent;
34573                 parent = node;
34574                 var containerFlags = getContainerFlags(node);
34575                 if (containerFlags === 0) {
34576                     bindChildren(node);
34577                 }
34578                 else {
34579                     bindContainer(node, containerFlags);
34580                 }
34581                 parent = saveParent;
34582             }
34583             else {
34584                 var saveParent = parent;
34585                 if (node.kind === 1)
34586                     parent = node;
34587                 bindJSDoc(node);
34588                 parent = saveParent;
34589             }
34590             inStrictMode = saveInStrictMode;
34591         }
34592         function bindJSDoc(node) {
34593             if (ts.hasJSDocNodes(node)) {
34594                 if (ts.isInJSFile(node)) {
34595                     for (var _i = 0, _a = node.jsDoc; _i < _a.length; _i++) {
34596                         var j = _a[_i];
34597                         bind(j);
34598                     }
34599                 }
34600                 else {
34601                     for (var _b = 0, _c = node.jsDoc; _b < _c.length; _b++) {
34602                         var j = _c[_b];
34603                         ts.setParent(j, node);
34604                         ts.setParentRecursive(j, false);
34605                     }
34606                 }
34607             }
34608         }
34609         function updateStrictModeStatementList(statements) {
34610             if (!inStrictMode) {
34611                 for (var _i = 0, statements_3 = statements; _i < statements_3.length; _i++) {
34612                     var statement = statements_3[_i];
34613                     if (!ts.isPrologueDirective(statement)) {
34614                         return;
34615                     }
34616                     if (isUseStrictPrologueDirective(statement)) {
34617                         inStrictMode = true;
34618                         return;
34619                     }
34620                 }
34621             }
34622         }
34623         function isUseStrictPrologueDirective(node) {
34624             var nodeText = ts.getSourceTextOfNodeFromSourceFile(file, node.expression);
34625             return nodeText === '"use strict"' || nodeText === "'use strict'";
34626         }
34627         function bindWorker(node) {
34628             switch (node.kind) {
34629                 case 78:
34630                     if (node.isInJSDocNamespace) {
34631                         var parentNode = node.parent;
34632                         while (parentNode && !ts.isJSDocTypeAlias(parentNode)) {
34633                             parentNode = parentNode.parent;
34634                         }
34635                         bindBlockScopedDeclaration(parentNode, 524288, 788968);
34636                         break;
34637                     }
34638                 case 107:
34639                     if (currentFlow && (ts.isExpression(node) || parent.kind === 289)) {
34640                         node.flowNode = currentFlow;
34641                     }
34642                     return checkContextualIdentifier(node);
34643                 case 157:
34644                     if (currentFlow && parent.kind === 176) {
34645                         node.flowNode = currentFlow;
34646                     }
34647                     break;
34648                 case 105:
34649                     node.flowNode = currentFlow;
34650                     break;
34651                 case 79:
34652                     return checkPrivateIdentifier(node);
34653                 case 201:
34654                 case 202:
34655                     var expr = node;
34656                     if (currentFlow && isNarrowableReference(expr)) {
34657                         expr.flowNode = currentFlow;
34658                     }
34659                     if (ts.isSpecialPropertyDeclaration(expr)) {
34660                         bindSpecialPropertyDeclaration(expr);
34661                     }
34662                     if (ts.isInJSFile(expr) &&
34663                         file.commonJsModuleIndicator &&
34664                         ts.isModuleExportsAccessExpression(expr) &&
34665                         !lookupSymbolForName(blockScopeContainer, "module")) {
34666                         declareSymbol(file.locals, undefined, expr.expression, 1 | 134217728, 111550);
34667                     }
34668                     break;
34669                 case 216:
34670                     var specialKind = ts.getAssignmentDeclarationKind(node);
34671                     switch (specialKind) {
34672                         case 1:
34673                             bindExportsPropertyAssignment(node);
34674                             break;
34675                         case 2:
34676                             bindModuleExportsAssignment(node);
34677                             break;
34678                         case 3:
34679                             bindPrototypePropertyAssignment(node.left, node);
34680                             break;
34681                         case 6:
34682                             bindPrototypeAssignment(node);
34683                             break;
34684                         case 4:
34685                             bindThisPropertyAssignment(node);
34686                             break;
34687                         case 5:
34688                             var expression = node.left.expression;
34689                             if (ts.isInJSFile(node) && ts.isIdentifier(expression)) {
34690                                 var symbol = lookupSymbolForName(blockScopeContainer, expression.escapedText);
34691                                 if (ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration)) {
34692                                     bindThisPropertyAssignment(node);
34693                                     break;
34694                                 }
34695                             }
34696                             bindSpecialPropertyAssignment(node);
34697                             break;
34698                         case 0:
34699                             break;
34700                         default:
34701                             ts.Debug.fail("Unknown binary expression special property assignment kind");
34702                     }
34703                     return checkStrictModeBinaryExpression(node);
34704                 case 287:
34705                     return checkStrictModeCatchClause(node);
34706                 case 210:
34707                     return checkStrictModeDeleteExpression(node);
34708                 case 8:
34709                     return checkStrictModeNumericLiteral(node);
34710                 case 215:
34711                     return checkStrictModePostfixUnaryExpression(node);
34712                 case 214:
34713                     return checkStrictModePrefixUnaryExpression(node);
34714                 case 243:
34715                     return checkStrictModeWithStatement(node);
34716                 case 245:
34717                     return checkStrictModeLabeledStatement(node);
34718                 case 187:
34719                     seenThisKeyword = true;
34720                     return;
34721                 case 172:
34722                     break;
34723                 case 159:
34724                     return bindTypeParameter(node);
34725                 case 160:
34726                     return bindParameter(node);
34727                 case 249:
34728                     return bindVariableDeclarationOrBindingElement(node);
34729                 case 198:
34730                     node.flowNode = currentFlow;
34731                     return bindVariableDeclarationOrBindingElement(node);
34732                 case 163:
34733                 case 162:
34734                     return bindPropertyWorker(node);
34735                 case 288:
34736                 case 289:
34737                     return bindPropertyOrMethodOrAccessor(node, 4, 0);
34738                 case 291:
34739                     return bindPropertyOrMethodOrAccessor(node, 8, 900095);
34740                 case 169:
34741                 case 170:
34742                 case 171:
34743                     return declareSymbolAndAddToSymbolTable(node, 131072, 0);
34744                 case 165:
34745                 case 164:
34746                     return bindPropertyOrMethodOrAccessor(node, 8192 | (node.questionToken ? 16777216 : 0), ts.isObjectLiteralMethod(node) ? 0 : 103359);
34747                 case 251:
34748                     return bindFunctionDeclaration(node);
34749                 case 166:
34750                     return declareSymbolAndAddToSymbolTable(node, 16384, 0);
34751                 case 167:
34752                     return bindPropertyOrMethodOrAccessor(node, 32768, 46015);
34753                 case 168:
34754                     return bindPropertyOrMethodOrAccessor(node, 65536, 78783);
34755                 case 174:
34756                 case 308:
34757                 case 313:
34758                 case 175:
34759                     return bindFunctionOrConstructorType(node);
34760                 case 177:
34761                 case 312:
34762                 case 190:
34763                     return bindAnonymousTypeWorker(node);
34764                 case 319:
34765                     return bindJSDocClassTag(node);
34766                 case 200:
34767                     return bindObjectLiteralExpression(node);
34768                 case 208:
34769                 case 209:
34770                     return bindFunctionExpression(node);
34771                 case 203:
34772                     var assignmentKind = ts.getAssignmentDeclarationKind(node);
34773                     switch (assignmentKind) {
34774                         case 7:
34775                             return bindObjectDefinePropertyAssignment(node);
34776                         case 8:
34777                             return bindObjectDefinePropertyExport(node);
34778                         case 9:
34779                             return bindObjectDefinePrototypeProperty(node);
34780                         case 0:
34781                             break;
34782                         default:
34783                             return ts.Debug.fail("Unknown call expression assignment declaration kind");
34784                     }
34785                     if (ts.isInJSFile(node)) {
34786                         bindCallExpression(node);
34787                     }
34788                     break;
34789                 case 221:
34790                 case 252:
34791                     inStrictMode = true;
34792                     return bindClassLikeDeclaration(node);
34793                 case 253:
34794                     return bindBlockScopedDeclaration(node, 64, 788872);
34795                 case 254:
34796                     return bindBlockScopedDeclaration(node, 524288, 788968);
34797                 case 255:
34798                     return bindEnumDeclaration(node);
34799                 case 256:
34800                     return bindModuleDeclaration(node);
34801                 case 281:
34802                     return bindJsxAttributes(node);
34803                 case 280:
34804                     return bindJsxAttribute(node, 4, 0);
34805                 case 260:
34806                 case 263:
34807                 case 265:
34808                 case 270:
34809                     return declareSymbolAndAddToSymbolTable(node, 2097152, 2097152);
34810                 case 259:
34811                     return bindNamespaceExportDeclaration(node);
34812                 case 262:
34813                     return bindImportClause(node);
34814                 case 267:
34815                     return bindExportDeclaration(node);
34816                 case 266:
34817                     return bindExportAssignment(node);
34818                 case 297:
34819                     updateStrictModeStatementList(node.statements);
34820                     return bindSourceFileIfExternalModule();
34821                 case 230:
34822                     if (!ts.isFunctionLike(node.parent)) {
34823                         return;
34824                     }
34825                 case 257:
34826                     return updateStrictModeStatementList(node.statements);
34827                 case 326:
34828                     if (node.parent.kind === 313) {
34829                         return bindParameter(node);
34830                     }
34831                     if (node.parent.kind !== 312) {
34832                         break;
34833                     }
34834                 case 333:
34835                     var propTag = node;
34836                     var flags = propTag.isBracketed || propTag.typeExpression && propTag.typeExpression.type.kind === 307 ?
34837                         4 | 16777216 :
34838                         4;
34839                     return declareSymbolAndAddToSymbolTable(propTag, flags, 0);
34840                 case 331:
34841                 case 324:
34842                 case 325:
34843                     return (delayedTypeAliases || (delayedTypeAliases = [])).push(node);
34844             }
34845         }
34846         function bindPropertyWorker(node) {
34847             return bindPropertyOrMethodOrAccessor(node, 4 | (node.questionToken ? 16777216 : 0), 0);
34848         }
34849         function bindAnonymousTypeWorker(node) {
34850             return bindAnonymousDeclaration(node, 2048, "__type");
34851         }
34852         function bindSourceFileIfExternalModule() {
34853             setExportContextFlag(file);
34854             if (ts.isExternalModule(file)) {
34855                 bindSourceFileAsExternalModule();
34856             }
34857             else if (ts.isJsonSourceFile(file)) {
34858                 bindSourceFileAsExternalModule();
34859                 var originalSymbol = file.symbol;
34860                 declareSymbol(file.symbol.exports, file.symbol, file, 4, 67108863);
34861                 file.symbol = originalSymbol;
34862             }
34863         }
34864         function bindSourceFileAsExternalModule() {
34865             bindAnonymousDeclaration(file, 512, "\"" + ts.removeFileExtension(file.fileName) + "\"");
34866         }
34867         function bindExportAssignment(node) {
34868             if (!container.symbol || !container.symbol.exports) {
34869                 bindAnonymousDeclaration(node, 2097152, getDeclarationName(node));
34870             }
34871             else {
34872                 var flags = ts.exportAssignmentIsAlias(node)
34873                     ? 2097152
34874                     : 4;
34875                 var symbol = declareSymbol(container.symbol.exports, container.symbol, node, flags, 67108863);
34876                 if (node.isExportEquals) {
34877                     ts.setValueDeclaration(symbol, node);
34878                 }
34879             }
34880         }
34881         function bindNamespaceExportDeclaration(node) {
34882             if (node.modifiers && node.modifiers.length) {
34883                 file.bindDiagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Modifiers_cannot_appear_here));
34884             }
34885             var diag = !ts.isSourceFile(node.parent) ? ts.Diagnostics.Global_module_exports_may_only_appear_at_top_level
34886                 : !ts.isExternalModule(node.parent) ? ts.Diagnostics.Global_module_exports_may_only_appear_in_module_files
34887                     : !node.parent.isDeclarationFile ? ts.Diagnostics.Global_module_exports_may_only_appear_in_declaration_files
34888                         : undefined;
34889             if (diag) {
34890                 file.bindDiagnostics.push(createDiagnosticForNode(node, diag));
34891             }
34892             else {
34893                 file.symbol.globalExports = file.symbol.globalExports || ts.createSymbolTable();
34894                 declareSymbol(file.symbol.globalExports, file.symbol, node, 2097152, 2097152);
34895             }
34896         }
34897         function bindExportDeclaration(node) {
34898             if (!container.symbol || !container.symbol.exports) {
34899                 bindAnonymousDeclaration(node, 8388608, getDeclarationName(node));
34900             }
34901             else if (!node.exportClause) {
34902                 declareSymbol(container.symbol.exports, container.symbol, node, 8388608, 0);
34903             }
34904             else if (ts.isNamespaceExport(node.exportClause)) {
34905                 ts.setParent(node.exportClause, node);
34906                 declareSymbol(container.symbol.exports, container.symbol, node.exportClause, 2097152, 2097152);
34907             }
34908         }
34909         function bindImportClause(node) {
34910             if (node.name) {
34911                 declareSymbolAndAddToSymbolTable(node, 2097152, 2097152);
34912             }
34913         }
34914         function setCommonJsModuleIndicator(node) {
34915             if (file.externalModuleIndicator) {
34916                 return false;
34917             }
34918             if (!file.commonJsModuleIndicator) {
34919                 file.commonJsModuleIndicator = node;
34920                 bindSourceFileAsExternalModule();
34921             }
34922             return true;
34923         }
34924         function bindObjectDefinePropertyExport(node) {
34925             if (!setCommonJsModuleIndicator(node)) {
34926                 return;
34927             }
34928             var symbol = forEachIdentifierInEntityName(node.arguments[0], undefined, function (id, symbol) {
34929                 if (symbol) {
34930                     addDeclarationToSymbol(symbol, id, 1536 | 67108864);
34931                 }
34932                 return symbol;
34933             });
34934             if (symbol) {
34935                 var flags = 4 | 1048576;
34936                 declareSymbol(symbol.exports, symbol, node, flags, 0);
34937             }
34938         }
34939         function bindExportsPropertyAssignment(node) {
34940             if (!setCommonJsModuleIndicator(node)) {
34941                 return;
34942             }
34943             var symbol = forEachIdentifierInEntityName(node.left.expression, undefined, function (id, symbol) {
34944                 if (symbol) {
34945                     addDeclarationToSymbol(symbol, id, 1536 | 67108864);
34946                 }
34947                 return symbol;
34948             });
34949             if (symbol) {
34950                 var isAlias = ts.isAliasableExpression(node.right) && (ts.isExportsIdentifier(node.left.expression) || ts.isModuleExportsAccessExpression(node.left.expression));
34951                 var flags = isAlias ? 2097152 : 4 | 1048576;
34952                 ts.setParent(node.left, node);
34953                 declareSymbol(symbol.exports, symbol, node.left, flags, 0);
34954             }
34955         }
34956         function bindModuleExportsAssignment(node) {
34957             if (!setCommonJsModuleIndicator(node)) {
34958                 return;
34959             }
34960             var assignedExpression = ts.getRightMostAssignedExpression(node.right);
34961             if (ts.isEmptyObjectLiteral(assignedExpression) || container === file && isExportsOrModuleExportsOrAlias(file, assignedExpression)) {
34962                 return;
34963             }
34964             if (ts.isObjectLiteralExpression(assignedExpression) && ts.every(assignedExpression.properties, ts.isShorthandPropertyAssignment)) {
34965                 ts.forEach(assignedExpression.properties, bindExportAssignedObjectMemberAlias);
34966                 return;
34967             }
34968             var flags = ts.exportAssignmentIsAlias(node)
34969                 ? 2097152
34970                 : 4 | 1048576 | 512;
34971             var symbol = declareSymbol(file.symbol.exports, file.symbol, node, flags | 67108864, 0);
34972             ts.setValueDeclaration(symbol, node);
34973         }
34974         function bindExportAssignedObjectMemberAlias(node) {
34975             declareSymbol(file.symbol.exports, file.symbol, node, 2097152 | 67108864, 0);
34976         }
34977         function bindThisPropertyAssignment(node) {
34978             ts.Debug.assert(ts.isInJSFile(node));
34979             var hasPrivateIdentifier = (ts.isBinaryExpression(node) && ts.isPropertyAccessExpression(node.left) && ts.isPrivateIdentifier(node.left.name))
34980                 || (ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name));
34981             if (hasPrivateIdentifier) {
34982                 return;
34983             }
34984             var thisContainer = ts.getThisContainer(node, false);
34985             switch (thisContainer.kind) {
34986                 case 251:
34987                 case 208:
34988                     var constructorSymbol = thisContainer.symbol;
34989                     if (ts.isBinaryExpression(thisContainer.parent) && thisContainer.parent.operatorToken.kind === 62) {
34990                         var l = thisContainer.parent.left;
34991                         if (ts.isBindableStaticAccessExpression(l) && ts.isPrototypeAccess(l.expression)) {
34992                             constructorSymbol = lookupSymbolForPropertyAccess(l.expression.expression, thisParentContainer);
34993                         }
34994                     }
34995                     if (constructorSymbol && constructorSymbol.valueDeclaration) {
34996                         constructorSymbol.members = constructorSymbol.members || ts.createSymbolTable();
34997                         if (ts.hasDynamicName(node)) {
34998                             bindDynamicallyNamedThisPropertyAssignment(node, constructorSymbol);
34999                         }
35000                         else {
35001                             declareSymbol(constructorSymbol.members, constructorSymbol, node, 4 | 67108864, 0 & ~4);
35002                         }
35003                         addDeclarationToSymbol(constructorSymbol, constructorSymbol.valueDeclaration, 32);
35004                     }
35005                     break;
35006                 case 166:
35007                 case 163:
35008                 case 165:
35009                 case 167:
35010                 case 168:
35011                     var containingClass = thisContainer.parent;
35012                     var symbolTable = ts.hasSyntacticModifier(thisContainer, 32) ? containingClass.symbol.exports : containingClass.symbol.members;
35013                     if (ts.hasDynamicName(node)) {
35014                         bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol);
35015                     }
35016                     else {
35017                         declareSymbol(symbolTable, containingClass.symbol, node, 4 | 67108864, 0, true);
35018                     }
35019                     break;
35020                 case 297:
35021                     if (ts.hasDynamicName(node)) {
35022                         break;
35023                     }
35024                     else if (thisContainer.commonJsModuleIndicator) {
35025                         declareSymbol(thisContainer.symbol.exports, thisContainer.symbol, node, 4 | 1048576, 0);
35026                     }
35027                     else {
35028                         declareSymbolAndAddToSymbolTable(node, 1, 111550);
35029                     }
35030                     break;
35031                 default:
35032                     ts.Debug.failBadSyntaxKind(thisContainer);
35033             }
35034         }
35035         function bindDynamicallyNamedThisPropertyAssignment(node, symbol) {
35036             bindAnonymousDeclaration(node, 4, "__computed");
35037             addLateBoundAssignmentDeclarationToSymbol(node, symbol);
35038         }
35039         function addLateBoundAssignmentDeclarationToSymbol(node, symbol) {
35040             if (symbol) {
35041                 (symbol.assignmentDeclarationMembers || (symbol.assignmentDeclarationMembers = new ts.Map())).set(ts.getNodeId(node), node);
35042             }
35043         }
35044         function bindSpecialPropertyDeclaration(node) {
35045             if (node.expression.kind === 107) {
35046                 bindThisPropertyAssignment(node);
35047             }
35048             else if (ts.isBindableStaticAccessExpression(node) && node.parent.parent.kind === 297) {
35049                 if (ts.isPrototypeAccess(node.expression)) {
35050                     bindPrototypePropertyAssignment(node, node.parent);
35051                 }
35052                 else {
35053                     bindStaticPropertyAssignment(node);
35054                 }
35055             }
35056         }
35057         function bindPrototypeAssignment(node) {
35058             ts.setParent(node.left, node);
35059             ts.setParent(node.right, node);
35060             bindPropertyAssignment(node.left.expression, node.left, false, true);
35061         }
35062         function bindObjectDefinePrototypeProperty(node) {
35063             var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression);
35064             if (namespaceSymbol && namespaceSymbol.valueDeclaration) {
35065                 addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32);
35066             }
35067             bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, true);
35068         }
35069         function bindPrototypePropertyAssignment(lhs, parent) {
35070             var classPrototype = lhs.expression;
35071             var constructorFunction = classPrototype.expression;
35072             ts.setParent(constructorFunction, classPrototype);
35073             ts.setParent(classPrototype, lhs);
35074             ts.setParent(lhs, parent);
35075             bindPropertyAssignment(constructorFunction, lhs, true, true);
35076         }
35077         function bindObjectDefinePropertyAssignment(node) {
35078             var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0]);
35079             var isToplevel = node.parent.parent.kind === 297;
35080             namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, node.arguments[0], isToplevel, false, false);
35081             bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, false);
35082         }
35083         function bindSpecialPropertyAssignment(node) {
35084             var _a;
35085             var parentSymbol = lookupSymbolForPropertyAccess(node.left.expression, container) || lookupSymbolForPropertyAccess(node.left.expression, blockScopeContainer);
35086             if (!ts.isInJSFile(node) && !ts.isFunctionSymbol(parentSymbol)) {
35087                 return;
35088             }
35089             var rootExpr = ts.getLeftmostAccessExpression(node.left);
35090             if (ts.isIdentifier(rootExpr) && ((_a = lookupSymbolForName(container, rootExpr.escapedText)) === null || _a === void 0 ? void 0 : _a.flags) & 2097152) {
35091                 return;
35092             }
35093             ts.setParent(node.left, node);
35094             ts.setParent(node.right, node);
35095             if (ts.isIdentifier(node.left.expression) && container === file && isExportsOrModuleExportsOrAlias(file, node.left.expression)) {
35096                 bindExportsPropertyAssignment(node);
35097             }
35098             else if (ts.hasDynamicName(node)) {
35099                 bindAnonymousDeclaration(node, 4 | 67108864, "__computed");
35100                 var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), false, false);
35101                 addLateBoundAssignmentDeclarationToSymbol(node, sym);
35102             }
35103             else {
35104                 bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticNameExpression));
35105             }
35106         }
35107         function bindStaticPropertyAssignment(node) {
35108             ts.Debug.assert(!ts.isIdentifier(node));
35109             ts.setParent(node.expression, node);
35110             bindPropertyAssignment(node.expression, node, false, false);
35111         }
35112         function bindPotentiallyMissingNamespaces(namespaceSymbol, entityName, isToplevel, isPrototypeProperty, containerIsClass) {
35113             if ((namespaceSymbol === null || namespaceSymbol === void 0 ? void 0 : namespaceSymbol.flags) & 2097152) {
35114                 return namespaceSymbol;
35115             }
35116             if (isToplevel && !isPrototypeProperty) {
35117                 var flags_2 = 1536 | 67108864;
35118                 var excludeFlags_1 = 110735 & ~67108864;
35119                 namespaceSymbol = forEachIdentifierInEntityName(entityName, namespaceSymbol, function (id, symbol, parent) {
35120                     if (symbol) {
35121                         addDeclarationToSymbol(symbol, id, flags_2);
35122                         return symbol;
35123                     }
35124                     else {
35125                         var table = parent ? parent.exports :
35126                             file.jsGlobalAugmentations || (file.jsGlobalAugmentations = ts.createSymbolTable());
35127                         return declareSymbol(table, parent, id, flags_2, excludeFlags_1);
35128                     }
35129                 });
35130             }
35131             if (containerIsClass && namespaceSymbol && namespaceSymbol.valueDeclaration) {
35132                 addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32);
35133             }
35134             return namespaceSymbol;
35135         }
35136         function bindPotentiallyNewExpandoMemberToNamespace(declaration, namespaceSymbol, isPrototypeProperty) {
35137             if (!namespaceSymbol || !isExpandoSymbol(namespaceSymbol)) {
35138                 return;
35139             }
35140             var symbolTable = isPrototypeProperty ?
35141                 (namespaceSymbol.members || (namespaceSymbol.members = ts.createSymbolTable())) :
35142                 (namespaceSymbol.exports || (namespaceSymbol.exports = ts.createSymbolTable()));
35143             var includes = 0;
35144             var excludes = 0;
35145             if (ts.isFunctionLikeDeclaration(ts.getAssignedExpandoInitializer(declaration))) {
35146                 includes = 8192;
35147                 excludes = 103359;
35148             }
35149             else if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) {
35150                 if (ts.some(declaration.arguments[2].properties, function (p) {
35151                     var id = ts.getNameOfDeclaration(p);
35152                     return !!id && ts.isIdentifier(id) && ts.idText(id) === "set";
35153                 })) {
35154                     includes |= 65536 | 4;
35155                     excludes |= 78783;
35156                 }
35157                 if (ts.some(declaration.arguments[2].properties, function (p) {
35158                     var id = ts.getNameOfDeclaration(p);
35159                     return !!id && ts.isIdentifier(id) && ts.idText(id) === "get";
35160                 })) {
35161                     includes |= 32768 | 4;
35162                     excludes |= 46015;
35163                 }
35164             }
35165             if (includes === 0) {
35166                 includes = 4;
35167                 excludes = 0;
35168             }
35169             declareSymbol(symbolTable, namespaceSymbol, declaration, includes | 67108864, excludes & ~67108864);
35170         }
35171         function isTopLevelNamespaceAssignment(propertyAccess) {
35172             return ts.isBinaryExpression(propertyAccess.parent)
35173                 ? getParentOfBinaryExpression(propertyAccess.parent).parent.kind === 297
35174                 : propertyAccess.parent.parent.kind === 297;
35175         }
35176         function bindPropertyAssignment(name, propertyAccess, isPrototypeProperty, containerIsClass) {
35177             var namespaceSymbol = lookupSymbolForPropertyAccess(name, container) || lookupSymbolForPropertyAccess(name, blockScopeContainer);
35178             var isToplevel = isTopLevelNamespaceAssignment(propertyAccess);
35179             namespaceSymbol = bindPotentiallyMissingNamespaces(namespaceSymbol, propertyAccess.expression, isToplevel, isPrototypeProperty, containerIsClass);
35180             bindPotentiallyNewExpandoMemberToNamespace(propertyAccess, namespaceSymbol, isPrototypeProperty);
35181         }
35182         function isExpandoSymbol(symbol) {
35183             if (symbol.flags & (16 | 32 | 1024)) {
35184                 return true;
35185             }
35186             var node = symbol.valueDeclaration;
35187             if (node && ts.isCallExpression(node)) {
35188                 return !!ts.getAssignedExpandoInitializer(node);
35189             }
35190             var init = !node ? undefined :
35191                 ts.isVariableDeclaration(node) ? node.initializer :
35192                     ts.isBinaryExpression(node) ? node.right :
35193                         ts.isPropertyAccessExpression(node) && ts.isBinaryExpression(node.parent) ? node.parent.right :
35194                             undefined;
35195             init = init && ts.getRightMostAssignedExpression(init);
35196             if (init) {
35197                 var isPrototypeAssignment = ts.isPrototypeAccess(ts.isVariableDeclaration(node) ? node.name : ts.isBinaryExpression(node) ? node.left : node);
35198                 return !!ts.getExpandoInitializer(ts.isBinaryExpression(init) && (init.operatorToken.kind === 56 || init.operatorToken.kind === 60) ? init.right : init, isPrototypeAssignment);
35199             }
35200             return false;
35201         }
35202         function getParentOfBinaryExpression(expr) {
35203             while (ts.isBinaryExpression(expr.parent)) {
35204                 expr = expr.parent;
35205             }
35206             return expr.parent;
35207         }
35208         function lookupSymbolForPropertyAccess(node, lookupContainer) {
35209             if (lookupContainer === void 0) { lookupContainer = container; }
35210             if (ts.isIdentifier(node)) {
35211                 return lookupSymbolForName(lookupContainer, node.escapedText);
35212             }
35213             else {
35214                 var symbol = lookupSymbolForPropertyAccess(node.expression);
35215                 return symbol && symbol.exports && symbol.exports.get(ts.getElementOrPropertyAccessName(node));
35216             }
35217         }
35218         function forEachIdentifierInEntityName(e, parent, action) {
35219             if (isExportsOrModuleExportsOrAlias(file, e)) {
35220                 return file.symbol;
35221             }
35222             else if (ts.isIdentifier(e)) {
35223                 return action(e, lookupSymbolForPropertyAccess(e), parent);
35224             }
35225             else {
35226                 var s = forEachIdentifierInEntityName(e.expression, parent, action);
35227                 var name = ts.getNameOrArgument(e);
35228                 if (ts.isPrivateIdentifier(name)) {
35229                     ts.Debug.fail("unexpected PrivateIdentifier");
35230                 }
35231                 return action(name, s && s.exports && s.exports.get(ts.getElementOrPropertyAccessName(e)), s);
35232             }
35233         }
35234         function bindCallExpression(node) {
35235             if (!file.commonJsModuleIndicator && ts.isRequireCall(node, false)) {
35236                 setCommonJsModuleIndicator(node);
35237             }
35238         }
35239         function bindClassLikeDeclaration(node) {
35240             if (node.kind === 252) {
35241                 bindBlockScopedDeclaration(node, 32, 899503);
35242             }
35243             else {
35244                 var bindingName = node.name ? node.name.escapedText : "__class";
35245                 bindAnonymousDeclaration(node, 32, bindingName);
35246                 if (node.name) {
35247                     classifiableNames.add(node.name.escapedText);
35248                 }
35249             }
35250             var symbol = node.symbol;
35251             var prototypeSymbol = createSymbol(4 | 4194304, "prototype");
35252             var symbolExport = symbol.exports.get(prototypeSymbol.escapedName);
35253             if (symbolExport) {
35254                 if (node.name) {
35255                     ts.setParent(node.name, node);
35256                 }
35257                 file.bindDiagnostics.push(createDiagnosticForNode(symbolExport.declarations[0], ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(prototypeSymbol)));
35258             }
35259             symbol.exports.set(prototypeSymbol.escapedName, prototypeSymbol);
35260             prototypeSymbol.parent = symbol;
35261         }
35262         function bindEnumDeclaration(node) {
35263             return ts.isEnumConst(node)
35264                 ? bindBlockScopedDeclaration(node, 128, 899967)
35265                 : bindBlockScopedDeclaration(node, 256, 899327);
35266         }
35267         function bindVariableDeclarationOrBindingElement(node) {
35268             if (inStrictMode) {
35269                 checkStrictModeEvalOrArguments(node, node.name);
35270             }
35271             if (!ts.isBindingPattern(node.name)) {
35272                 if (ts.isInJSFile(node) && ts.isRequireVariableDeclaration(node, true) && !ts.getJSDocTypeTag(node)) {
35273                     declareSymbolAndAddToSymbolTable(node, 2097152, 2097152);
35274                 }
35275                 else if (ts.isBlockOrCatchScoped(node)) {
35276                     bindBlockScopedDeclaration(node, 2, 111551);
35277                 }
35278                 else if (ts.isParameterDeclaration(node)) {
35279                     declareSymbolAndAddToSymbolTable(node, 1, 111551);
35280                 }
35281                 else {
35282                     declareSymbolAndAddToSymbolTable(node, 1, 111550);
35283                 }
35284             }
35285         }
35286         function bindParameter(node) {
35287             if (node.kind === 326 && container.kind !== 313) {
35288                 return;
35289             }
35290             if (inStrictMode && !(node.flags & 8388608)) {
35291                 checkStrictModeEvalOrArguments(node, node.name);
35292             }
35293             if (ts.isBindingPattern(node.name)) {
35294                 bindAnonymousDeclaration(node, 1, "__" + node.parent.parameters.indexOf(node));
35295             }
35296             else {
35297                 declareSymbolAndAddToSymbolTable(node, 1, 111551);
35298             }
35299             if (ts.isParameterPropertyDeclaration(node, node.parent)) {
35300                 var classDeclaration = node.parent.parent;
35301                 declareSymbol(classDeclaration.symbol.members, classDeclaration.symbol, node, 4 | (node.questionToken ? 16777216 : 0), 0);
35302             }
35303         }
35304         function bindFunctionDeclaration(node) {
35305             if (!file.isDeclarationFile && !(node.flags & 8388608)) {
35306                 if (ts.isAsyncFunction(node)) {
35307                     emitFlags |= 2048;
35308                 }
35309             }
35310             checkStrictModeFunctionName(node);
35311             if (inStrictMode) {
35312                 checkStrictModeFunctionDeclaration(node);
35313                 bindBlockScopedDeclaration(node, 16, 110991);
35314             }
35315             else {
35316                 declareSymbolAndAddToSymbolTable(node, 16, 110991);
35317             }
35318         }
35319         function bindFunctionExpression(node) {
35320             if (!file.isDeclarationFile && !(node.flags & 8388608)) {
35321                 if (ts.isAsyncFunction(node)) {
35322                     emitFlags |= 2048;
35323                 }
35324             }
35325             if (currentFlow) {
35326                 node.flowNode = currentFlow;
35327             }
35328             checkStrictModeFunctionName(node);
35329             var bindingName = node.name ? node.name.escapedText : "__function";
35330             return bindAnonymousDeclaration(node, 16, bindingName);
35331         }
35332         function bindPropertyOrMethodOrAccessor(node, symbolFlags, symbolExcludes) {
35333             if (!file.isDeclarationFile && !(node.flags & 8388608) && ts.isAsyncFunction(node)) {
35334                 emitFlags |= 2048;
35335             }
35336             if (currentFlow && ts.isObjectLiteralOrClassExpressionMethod(node)) {
35337                 node.flowNode = currentFlow;
35338             }
35339             return ts.hasDynamicName(node)
35340                 ? bindAnonymousDeclaration(node, symbolFlags, "__computed")
35341                 : declareSymbolAndAddToSymbolTable(node, symbolFlags, symbolExcludes);
35342         }
35343         function getInferTypeContainer(node) {
35344             var extendsType = ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && n.parent.extendsType === n; });
35345             return extendsType && extendsType.parent;
35346         }
35347         function bindTypeParameter(node) {
35348             if (ts.isJSDocTemplateTag(node.parent)) {
35349                 var container_1 = ts.find(node.parent.parent.tags, ts.isJSDocTypeAlias) || ts.getHostSignatureFromJSDoc(node.parent);
35350                 if (container_1) {
35351                     if (!container_1.locals) {
35352                         container_1.locals = ts.createSymbolTable();
35353                     }
35354                     declareSymbol(container_1.locals, undefined, node, 262144, 526824);
35355                 }
35356                 else {
35357                     declareSymbolAndAddToSymbolTable(node, 262144, 526824);
35358                 }
35359             }
35360             else if (node.parent.kind === 185) {
35361                 var container_2 = getInferTypeContainer(node.parent);
35362                 if (container_2) {
35363                     if (!container_2.locals) {
35364                         container_2.locals = ts.createSymbolTable();
35365                     }
35366                     declareSymbol(container_2.locals, undefined, node, 262144, 526824);
35367                 }
35368                 else {
35369                     bindAnonymousDeclaration(node, 262144, getDeclarationName(node));
35370                 }
35371             }
35372             else {
35373                 declareSymbolAndAddToSymbolTable(node, 262144, 526824);
35374             }
35375         }
35376         function shouldReportErrorOnModuleDeclaration(node) {
35377             var instanceState = getModuleInstanceState(node);
35378             return instanceState === 1 || (instanceState === 2 && ts.shouldPreserveConstEnums(options));
35379         }
35380         function checkUnreachable(node) {
35381             if (!(currentFlow.flags & 1)) {
35382                 return false;
35383             }
35384             if (currentFlow === unreachableFlow) {
35385                 var reportError = (ts.isStatementButNotDeclaration(node) && node.kind !== 231) ||
35386                     node.kind === 252 ||
35387                     (node.kind === 256 && shouldReportErrorOnModuleDeclaration(node));
35388                 if (reportError) {
35389                     currentFlow = reportedUnreachableFlow;
35390                     if (!options.allowUnreachableCode) {
35391                         var isError_1 = ts.unreachableCodeIsError(options) &&
35392                             !(node.flags & 8388608) &&
35393                             (!ts.isVariableStatement(node) ||
35394                                 !!(ts.getCombinedNodeFlags(node.declarationList) & 3) ||
35395                                 node.declarationList.declarations.some(function (d) { return !!d.initializer; }));
35396                         eachUnreachableRange(node, function (start, end) { return errorOrSuggestionOnRange(isError_1, start, end, ts.Diagnostics.Unreachable_code_detected); });
35397                     }
35398                 }
35399             }
35400             return true;
35401         }
35402     }
35403     function eachUnreachableRange(node, cb) {
35404         if (ts.isStatement(node) && isExecutableStatement(node) && ts.isBlock(node.parent)) {
35405             var statements = node.parent.statements;
35406             var slice_1 = ts.sliceAfter(statements, node);
35407             ts.getRangesWhere(slice_1, isExecutableStatement, function (start, afterEnd) { return cb(slice_1[start], slice_1[afterEnd - 1]); });
35408         }
35409         else {
35410             cb(node, node);
35411         }
35412     }
35413     function isExecutableStatement(s) {
35414         return !ts.isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !ts.isEnumDeclaration(s) &&
35415             !(ts.isVariableStatement(s) && !(ts.getCombinedNodeFlags(s) & (1 | 2)) && s.declarationList.declarations.some(function (d) { return !d.initializer; }));
35416     }
35417     function isPurelyTypeDeclaration(s) {
35418         switch (s.kind) {
35419             case 253:
35420             case 254:
35421                 return true;
35422             case 256:
35423                 return getModuleInstanceState(s) !== 1;
35424             case 255:
35425                 return ts.hasSyntacticModifier(s, 2048);
35426             default:
35427                 return false;
35428         }
35429     }
35430     function isExportsOrModuleExportsOrAlias(sourceFile, node) {
35431         var i = 0;
35432         var q = [node];
35433         while (q.length && i < 100) {
35434             i++;
35435             node = q.shift();
35436             if (ts.isExportsIdentifier(node) || ts.isModuleExportsAccessExpression(node)) {
35437                 return true;
35438             }
35439             else if (ts.isIdentifier(node)) {
35440                 var symbol = lookupSymbolForName(sourceFile, node.escapedText);
35441                 if (!!symbol && !!symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && !!symbol.valueDeclaration.initializer) {
35442                     var init = symbol.valueDeclaration.initializer;
35443                     q.push(init);
35444                     if (ts.isAssignmentExpression(init, true)) {
35445                         q.push(init.left);
35446                         q.push(init.right);
35447                     }
35448                 }
35449             }
35450         }
35451         return false;
35452     }
35453     ts.isExportsOrModuleExportsOrAlias = isExportsOrModuleExportsOrAlias;
35454     function lookupSymbolForName(container, name) {
35455         var local = container.locals && container.locals.get(name);
35456         if (local) {
35457             return local.exportSymbol || local;
35458         }
35459         if (ts.isSourceFile(container) && container.jsGlobalAugmentations && container.jsGlobalAugmentations.has(name)) {
35460             return container.jsGlobalAugmentations.get(name);
35461         }
35462         return container.symbol && container.symbol.exports && container.symbol.exports.get(name);
35463     }
35464 })(ts || (ts = {}));
35465 var ts;
35466 (function (ts) {
35467     function createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, getFirstIdentifier, getTypeArguments) {
35468         return getSymbolWalker;
35469         function getSymbolWalker(accept) {
35470             if (accept === void 0) { accept = function () { return true; }; }
35471             var visitedTypes = [];
35472             var visitedSymbols = [];
35473             return {
35474                 walkType: function (type) {
35475                     try {
35476                         visitType(type);
35477                         return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) };
35478                     }
35479                     finally {
35480                         ts.clear(visitedTypes);
35481                         ts.clear(visitedSymbols);
35482                     }
35483                 },
35484                 walkSymbol: function (symbol) {
35485                     try {
35486                         visitSymbol(symbol);
35487                         return { visitedTypes: ts.getOwnValues(visitedTypes), visitedSymbols: ts.getOwnValues(visitedSymbols) };
35488                     }
35489                     finally {
35490                         ts.clear(visitedTypes);
35491                         ts.clear(visitedSymbols);
35492                     }
35493                 },
35494             };
35495             function visitType(type) {
35496                 if (!type) {
35497                     return;
35498                 }
35499                 if (visitedTypes[type.id]) {
35500                     return;
35501                 }
35502                 visitedTypes[type.id] = type;
35503                 var shouldBail = visitSymbol(type.symbol);
35504                 if (shouldBail)
35505                     return;
35506                 if (type.flags & 524288) {
35507                     var objectType = type;
35508                     var objectFlags = objectType.objectFlags;
35509                     if (objectFlags & 4) {
35510                         visitTypeReference(type);
35511                     }
35512                     if (objectFlags & 32) {
35513                         visitMappedType(type);
35514                     }
35515                     if (objectFlags & (1 | 2)) {
35516                         visitInterfaceType(type);
35517                     }
35518                     if (objectFlags & (8 | 16)) {
35519                         visitObjectType(objectType);
35520                     }
35521                 }
35522                 if (type.flags & 262144) {
35523                     visitTypeParameter(type);
35524                 }
35525                 if (type.flags & 3145728) {
35526                     visitUnionOrIntersectionType(type);
35527                 }
35528                 if (type.flags & 4194304) {
35529                     visitIndexType(type);
35530                 }
35531                 if (type.flags & 8388608) {
35532                     visitIndexedAccessType(type);
35533                 }
35534             }
35535             function visitTypeReference(type) {
35536                 visitType(type.target);
35537                 ts.forEach(getTypeArguments(type), visitType);
35538             }
35539             function visitTypeParameter(type) {
35540                 visitType(getConstraintOfTypeParameter(type));
35541             }
35542             function visitUnionOrIntersectionType(type) {
35543                 ts.forEach(type.types, visitType);
35544             }
35545             function visitIndexType(type) {
35546                 visitType(type.type);
35547             }
35548             function visitIndexedAccessType(type) {
35549                 visitType(type.objectType);
35550                 visitType(type.indexType);
35551                 visitType(type.constraint);
35552             }
35553             function visitMappedType(type) {
35554                 visitType(type.typeParameter);
35555                 visitType(type.constraintType);
35556                 visitType(type.templateType);
35557                 visitType(type.modifiersType);
35558             }
35559             function visitSignature(signature) {
35560                 var typePredicate = getTypePredicateOfSignature(signature);
35561                 if (typePredicate) {
35562                     visitType(typePredicate.type);
35563                 }
35564                 ts.forEach(signature.typeParameters, visitType);
35565                 for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) {
35566                     var parameter = _a[_i];
35567                     visitSymbol(parameter);
35568                 }
35569                 visitType(getRestTypeOfSignature(signature));
35570                 visitType(getReturnTypeOfSignature(signature));
35571             }
35572             function visitInterfaceType(interfaceT) {
35573                 visitObjectType(interfaceT);
35574                 ts.forEach(interfaceT.typeParameters, visitType);
35575                 ts.forEach(getBaseTypes(interfaceT), visitType);
35576                 visitType(interfaceT.thisType);
35577             }
35578             function visitObjectType(type) {
35579                 var stringIndexType = getIndexTypeOfStructuredType(type, 0);
35580                 visitType(stringIndexType);
35581                 var numberIndexType = getIndexTypeOfStructuredType(type, 1);
35582                 visitType(numberIndexType);
35583                 var resolved = resolveStructuredTypeMembers(type);
35584                 for (var _i = 0, _a = resolved.callSignatures; _i < _a.length; _i++) {
35585                     var signature = _a[_i];
35586                     visitSignature(signature);
35587                 }
35588                 for (var _b = 0, _c = resolved.constructSignatures; _b < _c.length; _b++) {
35589                     var signature = _c[_b];
35590                     visitSignature(signature);
35591                 }
35592                 for (var _d = 0, _e = resolved.properties; _d < _e.length; _d++) {
35593                     var p = _e[_d];
35594                     visitSymbol(p);
35595                 }
35596             }
35597             function visitSymbol(symbol) {
35598                 if (!symbol) {
35599                     return false;
35600                 }
35601                 var symbolId = ts.getSymbolId(symbol);
35602                 if (visitedSymbols[symbolId]) {
35603                     return false;
35604                 }
35605                 visitedSymbols[symbolId] = symbol;
35606                 if (!accept(symbol)) {
35607                     return true;
35608                 }
35609                 var t = getTypeOfSymbol(symbol);
35610                 visitType(t);
35611                 if (symbol.exports) {
35612                     symbol.exports.forEach(visitSymbol);
35613                 }
35614                 ts.forEach(symbol.declarations, function (d) {
35615                     if (d.type && d.type.kind === 176) {
35616                         var query = d.type;
35617                         var entity = getResolvedSymbol(getFirstIdentifier(query.exprName));
35618                         visitSymbol(entity);
35619                     }
35620                 });
35621                 return false;
35622             }
35623         }
35624     }
35625     ts.createGetSymbolWalker = createGetSymbolWalker;
35626 })(ts || (ts = {}));
35627 var ts;
35628 (function (ts) {
35629     var ambientModuleSymbolRegex = /^".+"$/;
35630     var anon = "(anonymous)";
35631     var nextSymbolId = 1;
35632     var nextNodeId = 1;
35633     var nextMergeId = 1;
35634     var nextFlowId = 1;
35635     var typeofEQFacts = new ts.Map(ts.getEntries({
35636         string: 1,
35637         number: 2,
35638         bigint: 4,
35639         boolean: 8,
35640         symbol: 16,
35641         undefined: 65536,
35642         object: 32,
35643         function: 64
35644     }));
35645     var typeofNEFacts = new ts.Map(ts.getEntries({
35646         string: 256,
35647         number: 512,
35648         bigint: 1024,
35649         boolean: 2048,
35650         symbol: 4096,
35651         undefined: 524288,
35652         object: 8192,
35653         function: 16384
35654     }));
35655     var isNotOverloadAndNotAccessor = ts.and(isNotOverload, isNotAccessor);
35656     var intrinsicTypeKinds = new ts.Map(ts.getEntries({
35657         Uppercase: 0,
35658         Lowercase: 1,
35659         Capitalize: 2,
35660         Uncapitalize: 3
35661     }));
35662     function SymbolLinks() {
35663     }
35664     function NodeLinks() {
35665         this.flags = 0;
35666     }
35667     function getNodeId(node) {
35668         if (!node.id) {
35669             node.id = nextNodeId;
35670             nextNodeId++;
35671         }
35672         return node.id;
35673     }
35674     ts.getNodeId = getNodeId;
35675     function getSymbolId(symbol) {
35676         if (!symbol.id) {
35677             symbol.id = nextSymbolId;
35678             nextSymbolId++;
35679         }
35680         return symbol.id;
35681     }
35682     ts.getSymbolId = getSymbolId;
35683     function isInstantiatedModule(node, preserveConstEnums) {
35684         var moduleState = ts.getModuleInstanceState(node);
35685         return moduleState === 1 ||
35686             (preserveConstEnums && moduleState === 2);
35687     }
35688     ts.isInstantiatedModule = isInstantiatedModule;
35689     function createTypeChecker(host, produceDiagnostics) {
35690         var getPackagesSet = ts.memoize(function () {
35691             var set = new ts.Set();
35692             host.getSourceFiles().forEach(function (sf) {
35693                 if (!sf.resolvedModules)
35694                     return;
35695                 ts.forEachEntry(sf.resolvedModules, function (r) {
35696                     if (r && r.packageId)
35697                         set.add(r.packageId.name);
35698                 });
35699             });
35700             return set;
35701         });
35702         var cancellationToken;
35703         var requestedExternalEmitHelpers;
35704         var externalHelpersModule;
35705         var Symbol = ts.objectAllocator.getSymbolConstructor();
35706         var Type = ts.objectAllocator.getTypeConstructor();
35707         var Signature = ts.objectAllocator.getSignatureConstructor();
35708         var typeCount = 0;
35709         var symbolCount = 0;
35710         var enumCount = 0;
35711         var totalInstantiationCount = 0;
35712         var instantiationCount = 0;
35713         var instantiationDepth = 0;
35714         var currentNode;
35715         var typeCatalog = [];
35716         var emptySymbols = ts.createSymbolTable();
35717         var arrayVariances = [1];
35718         var compilerOptions = host.getCompilerOptions();
35719         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
35720         var moduleKind = ts.getEmitModuleKind(compilerOptions);
35721         var allowSyntheticDefaultImports = ts.getAllowSyntheticDefaultImports(compilerOptions);
35722         var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
35723         var strictFunctionTypes = ts.getStrictOptionValue(compilerOptions, "strictFunctionTypes");
35724         var strictBindCallApply = ts.getStrictOptionValue(compilerOptions, "strictBindCallApply");
35725         var strictPropertyInitialization = ts.getStrictOptionValue(compilerOptions, "strictPropertyInitialization");
35726         var noImplicitAny = ts.getStrictOptionValue(compilerOptions, "noImplicitAny");
35727         var noImplicitThis = ts.getStrictOptionValue(compilerOptions, "noImplicitThis");
35728         var keyofStringsOnly = !!compilerOptions.keyofStringsOnly;
35729         var freshObjectLiteralFlag = compilerOptions.suppressExcessPropertyErrors ? 0 : 32768;
35730         var emitResolver = createResolver();
35731         var nodeBuilder = createNodeBuilder();
35732         var globals = ts.createSymbolTable();
35733         var undefinedSymbol = createSymbol(4, "undefined");
35734         undefinedSymbol.declarations = [];
35735         var globalThisSymbol = createSymbol(1536, "globalThis", 8);
35736         globalThisSymbol.exports = globals;
35737         globalThisSymbol.declarations = [];
35738         globals.set(globalThisSymbol.escapedName, globalThisSymbol);
35739         var argumentsSymbol = createSymbol(4, "arguments");
35740         var requireSymbol = createSymbol(4, "require");
35741         var apparentArgumentCount;
35742         var checker = {
35743             getNodeCount: function () { return ts.sum(host.getSourceFiles(), "nodeCount"); },
35744             getIdentifierCount: function () { return ts.sum(host.getSourceFiles(), "identifierCount"); },
35745             getSymbolCount: function () { return ts.sum(host.getSourceFiles(), "symbolCount") + symbolCount; },
35746             getTypeCatalog: function () { return typeCatalog; },
35747             getTypeCount: function () { return typeCount; },
35748             getInstantiationCount: function () { return totalInstantiationCount; },
35749             getRelationCacheSizes: function () { return ({
35750                 assignable: assignableRelation.size,
35751                 identity: identityRelation.size,
35752                 subtype: subtypeRelation.size,
35753                 strictSubtype: strictSubtypeRelation.size,
35754             }); },
35755             isUndefinedSymbol: function (symbol) { return symbol === undefinedSymbol; },
35756             isArgumentsSymbol: function (symbol) { return symbol === argumentsSymbol; },
35757             isUnknownSymbol: function (symbol) { return symbol === unknownSymbol; },
35758             getMergedSymbol: getMergedSymbol,
35759             getDiagnostics: getDiagnostics,
35760             getGlobalDiagnostics: getGlobalDiagnostics,
35761             getRecursionIdentity: getRecursionIdentity,
35762             getTypeOfSymbolAtLocation: function (symbol, locationIn) {
35763                 var location = ts.getParseTreeNode(locationIn);
35764                 return location ? getTypeOfSymbolAtLocation(symbol, location) : errorType;
35765             },
35766             getSymbolsOfParameterPropertyDeclaration: function (parameterIn, parameterName) {
35767                 var parameter = ts.getParseTreeNode(parameterIn, ts.isParameter);
35768                 if (parameter === undefined)
35769                     return ts.Debug.fail("Cannot get symbols of a synthetic parameter that cannot be resolved to a parse-tree node.");
35770                 return getSymbolsOfParameterPropertyDeclaration(parameter, ts.escapeLeadingUnderscores(parameterName));
35771             },
35772             getDeclaredTypeOfSymbol: getDeclaredTypeOfSymbol,
35773             getPropertiesOfType: getPropertiesOfType,
35774             getPropertyOfType: function (type, name) { return getPropertyOfType(type, ts.escapeLeadingUnderscores(name)); },
35775             getPrivateIdentifierPropertyOfType: function (leftType, name, location) {
35776                 var node = ts.getParseTreeNode(location);
35777                 if (!node) {
35778                     return undefined;
35779                 }
35780                 var propName = ts.escapeLeadingUnderscores(name);
35781                 var lexicallyScopedIdentifier = lookupSymbolForPrivateIdentifierDeclaration(propName, node);
35782                 return lexicallyScopedIdentifier ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) : undefined;
35783             },
35784             getTypeOfPropertyOfType: function (type, name) { return getTypeOfPropertyOfType(type, ts.escapeLeadingUnderscores(name)); },
35785             getIndexInfoOfType: getIndexInfoOfType,
35786             getSignaturesOfType: getSignaturesOfType,
35787             getIndexTypeOfType: getIndexTypeOfType,
35788             getBaseTypes: getBaseTypes,
35789             getBaseTypeOfLiteralType: getBaseTypeOfLiteralType,
35790             getWidenedType: getWidenedType,
35791             getTypeFromTypeNode: function (nodeIn) {
35792                 var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
35793                 return node ? getTypeFromTypeNode(node) : errorType;
35794             },
35795             getParameterType: getTypeAtPosition,
35796             getPromisedTypeOfPromise: getPromisedTypeOfPromise,
35797             getAwaitedType: function (type) { return getAwaitedType(type); },
35798             getReturnTypeOfSignature: getReturnTypeOfSignature,
35799             isNullableType: isNullableType,
35800             getNullableType: getNullableType,
35801             getNonNullableType: getNonNullableType,
35802             getNonOptionalType: removeOptionalTypeMarker,
35803             getTypeArguments: getTypeArguments,
35804             typeToTypeNode: nodeBuilder.typeToTypeNode,
35805             indexInfoToIndexSignatureDeclaration: nodeBuilder.indexInfoToIndexSignatureDeclaration,
35806             signatureToSignatureDeclaration: nodeBuilder.signatureToSignatureDeclaration,
35807             symbolToEntityName: nodeBuilder.symbolToEntityName,
35808             symbolToExpression: nodeBuilder.symbolToExpression,
35809             symbolToTypeParameterDeclarations: nodeBuilder.symbolToTypeParameterDeclarations,
35810             symbolToParameterDeclaration: nodeBuilder.symbolToParameterDeclaration,
35811             typeParameterToDeclaration: nodeBuilder.typeParameterToDeclaration,
35812             getSymbolsInScope: function (locationIn, meaning) {
35813                 var location = ts.getParseTreeNode(locationIn);
35814                 return location ? getSymbolsInScope(location, meaning) : [];
35815             },
35816             getSymbolAtLocation: function (nodeIn) {
35817                 var node = ts.getParseTreeNode(nodeIn);
35818                 return node ? getSymbolAtLocation(node, true) : undefined;
35819             },
35820             getShorthandAssignmentValueSymbol: function (nodeIn) {
35821                 var node = ts.getParseTreeNode(nodeIn);
35822                 return node ? getShorthandAssignmentValueSymbol(node) : undefined;
35823             },
35824             getExportSpecifierLocalTargetSymbol: function (nodeIn) {
35825                 var node = ts.getParseTreeNode(nodeIn, ts.isExportSpecifier);
35826                 return node ? getExportSpecifierLocalTargetSymbol(node) : undefined;
35827             },
35828             getExportSymbolOfSymbol: function (symbol) {
35829                 return getMergedSymbol(symbol.exportSymbol || symbol);
35830             },
35831             getTypeAtLocation: function (nodeIn) {
35832                 var node = ts.getParseTreeNode(nodeIn);
35833                 return node ? getTypeOfNode(node) : errorType;
35834             },
35835             getTypeOfAssignmentPattern: function (nodeIn) {
35836                 var node = ts.getParseTreeNode(nodeIn, ts.isAssignmentPattern);
35837                 return node && getTypeOfAssignmentPattern(node) || errorType;
35838             },
35839             getPropertySymbolOfDestructuringAssignment: function (locationIn) {
35840                 var location = ts.getParseTreeNode(locationIn, ts.isIdentifier);
35841                 return location ? getPropertySymbolOfDestructuringAssignment(location) : undefined;
35842             },
35843             signatureToString: function (signature, enclosingDeclaration, flags, kind) {
35844                 return signatureToString(signature, ts.getParseTreeNode(enclosingDeclaration), flags, kind);
35845             },
35846             typeToString: function (type, enclosingDeclaration, flags) {
35847                 return typeToString(type, ts.getParseTreeNode(enclosingDeclaration), flags);
35848             },
35849             symbolToString: function (symbol, enclosingDeclaration, meaning, flags) {
35850                 return symbolToString(symbol, ts.getParseTreeNode(enclosingDeclaration), meaning, flags);
35851             },
35852             typePredicateToString: function (predicate, enclosingDeclaration, flags) {
35853                 return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags);
35854             },
35855             writeSignature: function (signature, enclosingDeclaration, flags, kind, writer) {
35856                 return signatureToString(signature, ts.getParseTreeNode(enclosingDeclaration), flags, kind, writer);
35857             },
35858             writeType: function (type, enclosingDeclaration, flags, writer) {
35859                 return typeToString(type, ts.getParseTreeNode(enclosingDeclaration), flags, writer);
35860             },
35861             writeSymbol: function (symbol, enclosingDeclaration, meaning, flags, writer) {
35862                 return symbolToString(symbol, ts.getParseTreeNode(enclosingDeclaration), meaning, flags, writer);
35863             },
35864             writeTypePredicate: function (predicate, enclosingDeclaration, flags, writer) {
35865                 return typePredicateToString(predicate, ts.getParseTreeNode(enclosingDeclaration), flags, writer);
35866             },
35867             getAugmentedPropertiesOfType: getAugmentedPropertiesOfType,
35868             getRootSymbols: getRootSymbols,
35869             getSymbolOfExpando: getSymbolOfExpando,
35870             getContextualType: function (nodeIn, contextFlags) {
35871                 var node = ts.getParseTreeNode(nodeIn, ts.isExpression);
35872                 if (!node) {
35873                     return undefined;
35874                 }
35875                 var containingCall = ts.findAncestor(node, ts.isCallLikeExpression);
35876                 var containingCallResolvedSignature = containingCall && getNodeLinks(containingCall).resolvedSignature;
35877                 if (contextFlags & 4 && containingCall) {
35878                     var toMarkSkip = node;
35879                     do {
35880                         getNodeLinks(toMarkSkip).skipDirectInference = true;
35881                         toMarkSkip = toMarkSkip.parent;
35882                     } while (toMarkSkip && toMarkSkip !== containingCall);
35883                     getNodeLinks(containingCall).resolvedSignature = undefined;
35884                 }
35885                 var result = getContextualType(node, contextFlags);
35886                 if (contextFlags & 4 && containingCall) {
35887                     var toMarkSkip = node;
35888                     do {
35889                         getNodeLinks(toMarkSkip).skipDirectInference = undefined;
35890                         toMarkSkip = toMarkSkip.parent;
35891                     } while (toMarkSkip && toMarkSkip !== containingCall);
35892                     getNodeLinks(containingCall).resolvedSignature = containingCallResolvedSignature;
35893                 }
35894                 return result;
35895             },
35896             getContextualTypeForObjectLiteralElement: function (nodeIn) {
35897                 var node = ts.getParseTreeNode(nodeIn, ts.isObjectLiteralElementLike);
35898                 return node ? getContextualTypeForObjectLiteralElement(node) : undefined;
35899             },
35900             getContextualTypeForArgumentAtIndex: function (nodeIn, argIndex) {
35901                 var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
35902                 return node && getContextualTypeForArgumentAtIndex(node, argIndex);
35903             },
35904             getContextualTypeForJsxAttribute: function (nodeIn) {
35905                 var node = ts.getParseTreeNode(nodeIn, ts.isJsxAttributeLike);
35906                 return node && getContextualTypeForJsxAttribute(node);
35907             },
35908             isContextSensitive: isContextSensitive,
35909             getFullyQualifiedName: getFullyQualifiedName,
35910             getResolvedSignature: function (node, candidatesOutArray, argumentCount) {
35911                 return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 0);
35912             },
35913             getResolvedSignatureForSignatureHelp: function (node, candidatesOutArray, argumentCount) {
35914                 return getResolvedSignatureWorker(node, candidatesOutArray, argumentCount, 16);
35915             },
35916             getExpandedParameters: getExpandedParameters,
35917             hasEffectiveRestParameter: hasEffectiveRestParameter,
35918             getConstantValue: function (nodeIn) {
35919                 var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue);
35920                 return node ? getConstantValue(node) : undefined;
35921             },
35922             isValidPropertyAccess: function (nodeIn, propertyName) {
35923                 var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessOrQualifiedNameOrImportTypeNode);
35924                 return !!node && isValidPropertyAccess(node, ts.escapeLeadingUnderscores(propertyName));
35925             },
35926             isValidPropertyAccessForCompletions: function (nodeIn, type, property) {
35927                 var node = ts.getParseTreeNode(nodeIn, ts.isPropertyAccessExpression);
35928                 return !!node && isValidPropertyAccessForCompletions(node, type, property);
35929             },
35930             getSignatureFromDeclaration: function (declarationIn) {
35931                 var declaration = ts.getParseTreeNode(declarationIn, ts.isFunctionLike);
35932                 return declaration ? getSignatureFromDeclaration(declaration) : undefined;
35933             },
35934             isImplementationOfOverload: function (nodeIn) {
35935                 var node = ts.getParseTreeNode(nodeIn, ts.isFunctionLike);
35936                 return node ? isImplementationOfOverload(node) : undefined;
35937             },
35938             getImmediateAliasedSymbol: getImmediateAliasedSymbol,
35939             getAliasedSymbol: resolveAlias,
35940             getEmitResolver: getEmitResolver,
35941             getExportsOfModule: getExportsOfModuleAsArray,
35942             getExportsAndPropertiesOfModule: getExportsAndPropertiesOfModule,
35943             getSymbolWalker: ts.createGetSymbolWalker(getRestTypeOfSignature, getTypePredicateOfSignature, getReturnTypeOfSignature, getBaseTypes, resolveStructuredTypeMembers, getTypeOfSymbol, getResolvedSymbol, getIndexTypeOfStructuredType, getConstraintOfTypeParameter, ts.getFirstIdentifier, getTypeArguments),
35944             getAmbientModules: getAmbientModules,
35945             getJsxIntrinsicTagNamesAt: getJsxIntrinsicTagNamesAt,
35946             isOptionalParameter: function (nodeIn) {
35947                 var node = ts.getParseTreeNode(nodeIn, ts.isParameter);
35948                 return node ? isOptionalParameter(node) : false;
35949             },
35950             tryGetMemberInModuleExports: function (name, symbol) { return tryGetMemberInModuleExports(ts.escapeLeadingUnderscores(name), symbol); },
35951             tryGetMemberInModuleExportsAndProperties: function (name, symbol) { return tryGetMemberInModuleExportsAndProperties(ts.escapeLeadingUnderscores(name), symbol); },
35952             tryFindAmbientModuleWithoutAugmentations: function (moduleName) {
35953                 return tryFindAmbientModule(moduleName, false);
35954             },
35955             getApparentType: getApparentType,
35956             getUnionType: getUnionType,
35957             isTypeAssignableTo: isTypeAssignableTo,
35958             createAnonymousType: createAnonymousType,
35959             createSignature: createSignature,
35960             createSymbol: createSymbol,
35961             createIndexInfo: createIndexInfo,
35962             getAnyType: function () { return anyType; },
35963             getStringType: function () { return stringType; },
35964             getNumberType: function () { return numberType; },
35965             createPromiseType: createPromiseType,
35966             createArrayType: createArrayType,
35967             getElementTypeOfArrayType: getElementTypeOfArrayType,
35968             getBooleanType: function () { return booleanType; },
35969             getFalseType: function (fresh) { return fresh ? falseType : regularFalseType; },
35970             getTrueType: function (fresh) { return fresh ? trueType : regularTrueType; },
35971             getVoidType: function () { return voidType; },
35972             getUndefinedType: function () { return undefinedType; },
35973             getNullType: function () { return nullType; },
35974             getESSymbolType: function () { return esSymbolType; },
35975             getNeverType: function () { return neverType; },
35976             getOptionalType: function () { return optionalType; },
35977             isSymbolAccessible: isSymbolAccessible,
35978             isArrayType: isArrayType,
35979             isTupleType: isTupleType,
35980             isArrayLikeType: isArrayLikeType,
35981             isTypeInvalidDueToUnionDiscriminant: isTypeInvalidDueToUnionDiscriminant,
35982             getAllPossiblePropertiesOfTypes: getAllPossiblePropertiesOfTypes,
35983             getSuggestedSymbolForNonexistentProperty: getSuggestedSymbolForNonexistentProperty,
35984             getSuggestionForNonexistentProperty: getSuggestionForNonexistentProperty,
35985             getSuggestedSymbolForNonexistentJSXAttribute: getSuggestedSymbolForNonexistentJSXAttribute,
35986             getSuggestedSymbolForNonexistentSymbol: function (location, name, meaning) { return getSuggestedSymbolForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); },
35987             getSuggestionForNonexistentSymbol: function (location, name, meaning) { return getSuggestionForNonexistentSymbol(location, ts.escapeLeadingUnderscores(name), meaning); },
35988             getSuggestedSymbolForNonexistentModule: getSuggestedSymbolForNonexistentModule,
35989             getSuggestionForNonexistentExport: getSuggestionForNonexistentExport,
35990             getBaseConstraintOfType: getBaseConstraintOfType,
35991             getDefaultFromTypeParameter: function (type) { return type && type.flags & 262144 ? getDefaultFromTypeParameter(type) : undefined; },
35992             resolveName: function (name, location, meaning, excludeGlobals) {
35993                 return resolveName(location, ts.escapeLeadingUnderscores(name), meaning, undefined, undefined, false, excludeGlobals);
35994             },
35995             getJsxNamespace: function (n) { return ts.unescapeLeadingUnderscores(getJsxNamespace(n)); },
35996             getJsxFragmentFactory: function (n) {
35997                 var jsxFragmentFactory = getJsxFragmentFactoryEntity(n);
35998                 return jsxFragmentFactory && ts.unescapeLeadingUnderscores(ts.getFirstIdentifier(jsxFragmentFactory).escapedText);
35999             },
36000             getAccessibleSymbolChain: getAccessibleSymbolChain,
36001             getTypePredicateOfSignature: getTypePredicateOfSignature,
36002             resolveExternalModuleName: function (moduleSpecifierIn) {
36003                 var moduleSpecifier = ts.getParseTreeNode(moduleSpecifierIn, ts.isExpression);
36004                 return moduleSpecifier && resolveExternalModuleName(moduleSpecifier, moduleSpecifier, true);
36005             },
36006             resolveExternalModuleSymbol: resolveExternalModuleSymbol,
36007             tryGetThisTypeAt: function (nodeIn, includeGlobalThis) {
36008                 var node = ts.getParseTreeNode(nodeIn);
36009                 return node && tryGetThisTypeAt(node, includeGlobalThis);
36010             },
36011             getTypeArgumentConstraint: function (nodeIn) {
36012                 var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
36013                 return node && getTypeArgumentConstraint(node);
36014             },
36015             getSuggestionDiagnostics: function (fileIn, ct) {
36016                 var file = ts.getParseTreeNode(fileIn, ts.isSourceFile) || ts.Debug.fail("Could not determine parsed source file.");
36017                 if (ts.skipTypeChecking(file, compilerOptions, host)) {
36018                     return ts.emptyArray;
36019                 }
36020                 var diagnostics;
36021                 try {
36022                     cancellationToken = ct;
36023                     checkSourceFile(file);
36024                     ts.Debug.assert(!!(getNodeLinks(file).flags & 1));
36025                     diagnostics = ts.addRange(diagnostics, suggestionDiagnostics.getDiagnostics(file.fileName));
36026                     checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(file), function (containingNode, kind, diag) {
36027                         if (!ts.containsParseError(containingNode) && !unusedIsError(kind, !!(containingNode.flags & 8388608))) {
36028                             (diagnostics || (diagnostics = [])).push(__assign(__assign({}, diag), { category: ts.DiagnosticCategory.Suggestion }));
36029                         }
36030                     });
36031                     return diagnostics || ts.emptyArray;
36032                 }
36033                 finally {
36034                     cancellationToken = undefined;
36035                 }
36036             },
36037             runWithCancellationToken: function (token, callback) {
36038                 try {
36039                     cancellationToken = token;
36040                     return callback(checker);
36041                 }
36042                 finally {
36043                     cancellationToken = undefined;
36044                 }
36045             },
36046             getLocalTypeParametersOfClassOrInterfaceOrTypeAlias: getLocalTypeParametersOfClassOrInterfaceOrTypeAlias,
36047             isDeclarationVisible: isDeclarationVisible,
36048         };
36049         function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode) {
36050             var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
36051             apparentArgumentCount = argumentCount;
36052             var res = node ? getResolvedSignature(node, candidatesOutArray, checkMode) : undefined;
36053             apparentArgumentCount = undefined;
36054             return res;
36055         }
36056         var tupleTypes = new ts.Map();
36057         var unionTypes = new ts.Map();
36058         var intersectionTypes = new ts.Map();
36059         var literalTypes = new ts.Map();
36060         var indexedAccessTypes = new ts.Map();
36061         var templateLiteralTypes = new ts.Map();
36062         var stringMappingTypes = new ts.Map();
36063         var substitutionTypes = new ts.Map();
36064         var evolvingArrayTypes = [];
36065         var undefinedProperties = new ts.Map();
36066         var unknownSymbol = createSymbol(4, "unknown");
36067         var resolvingSymbol = createSymbol(0, "__resolving__");
36068         var anyType = createIntrinsicType(1, "any");
36069         var autoType = createIntrinsicType(1, "any");
36070         var wildcardType = createIntrinsicType(1, "any");
36071         var errorType = createIntrinsicType(1, "error");
36072         var nonInferrableAnyType = createIntrinsicType(1, "any", 524288);
36073         var intrinsicMarkerType = createIntrinsicType(1, "intrinsic");
36074         var unknownType = createIntrinsicType(2, "unknown");
36075         var undefinedType = createIntrinsicType(32768, "undefined");
36076         var undefinedWideningType = strictNullChecks ? undefinedType : createIntrinsicType(32768, "undefined", 524288);
36077         var optionalType = createIntrinsicType(32768, "undefined");
36078         var nullType = createIntrinsicType(65536, "null");
36079         var nullWideningType = strictNullChecks ? nullType : createIntrinsicType(65536, "null", 524288);
36080         var stringType = createIntrinsicType(4, "string");
36081         var numberType = createIntrinsicType(8, "number");
36082         var bigintType = createIntrinsicType(64, "bigint");
36083         var falseType = createIntrinsicType(512, "false");
36084         var regularFalseType = createIntrinsicType(512, "false");
36085         var trueType = createIntrinsicType(512, "true");
36086         var regularTrueType = createIntrinsicType(512, "true");
36087         trueType.regularType = regularTrueType;
36088         trueType.freshType = trueType;
36089         regularTrueType.regularType = regularTrueType;
36090         regularTrueType.freshType = trueType;
36091         falseType.regularType = regularFalseType;
36092         falseType.freshType = falseType;
36093         regularFalseType.regularType = regularFalseType;
36094         regularFalseType.freshType = falseType;
36095         var booleanType = createBooleanType([regularFalseType, regularTrueType]);
36096         createBooleanType([regularFalseType, trueType]);
36097         createBooleanType([falseType, regularTrueType]);
36098         createBooleanType([falseType, trueType]);
36099         var esSymbolType = createIntrinsicType(4096, "symbol");
36100         var voidType = createIntrinsicType(16384, "void");
36101         var neverType = createIntrinsicType(131072, "never");
36102         var silentNeverType = createIntrinsicType(131072, "never");
36103         var nonInferrableType = createIntrinsicType(131072, "never", 2097152);
36104         var implicitNeverType = createIntrinsicType(131072, "never");
36105         var unreachableNeverType = createIntrinsicType(131072, "never");
36106         var nonPrimitiveType = createIntrinsicType(67108864, "object");
36107         var stringNumberSymbolType = getUnionType([stringType, numberType, esSymbolType]);
36108         var keyofConstraintType = keyofStringsOnly ? stringType : stringNumberSymbolType;
36109         var numberOrBigIntType = getUnionType([numberType, bigintType]);
36110         var templateConstraintType = getUnionType([stringType, numberType, booleanType, bigintType, nullType, undefinedType]);
36111         var restrictiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? getRestrictiveTypeParameter(t) : t; });
36112         var permissiveMapper = makeFunctionTypeMapper(function (t) { return t.flags & 262144 ? wildcardType : t; });
36113         var emptyObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
36114         var emptyJsxObjectType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
36115         emptyJsxObjectType.objectFlags |= 4096;
36116         var emptyTypeLiteralSymbol = createSymbol(2048, "__type");
36117         emptyTypeLiteralSymbol.members = ts.createSymbolTable();
36118         var emptyTypeLiteralType = createAnonymousType(emptyTypeLiteralSymbol, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
36119         var emptyGenericType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
36120         emptyGenericType.instantiations = new ts.Map();
36121         var anyFunctionType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
36122         anyFunctionType.objectFlags |= 2097152;
36123         var noConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
36124         var circularConstraintType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
36125         var resolvingDefaultType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
36126         var markerSuperType = createTypeParameter();
36127         var markerSubType = createTypeParameter();
36128         markerSubType.constraint = markerSuperType;
36129         var markerOtherType = createTypeParameter();
36130         var noTypePredicate = createTypePredicate(1, "<<unresolved>>", 0, anyType);
36131         var anySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, 0);
36132         var unknownSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, errorType, undefined, 0, 0);
36133         var resolvingSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, anyType, undefined, 0, 0);
36134         var silentNeverSignature = createSignature(undefined, undefined, undefined, ts.emptyArray, silentNeverType, undefined, 0, 0);
36135         var enumNumberIndexInfo = createIndexInfo(stringType, true);
36136         var iterationTypesCache = new ts.Map();
36137         var noIterationTypes = {
36138             get yieldType() { return ts.Debug.fail("Not supported"); },
36139             get returnType() { return ts.Debug.fail("Not supported"); },
36140             get nextType() { return ts.Debug.fail("Not supported"); },
36141         };
36142         var anyIterationTypes = createIterationTypes(anyType, anyType, anyType);
36143         var anyIterationTypesExceptNext = createIterationTypes(anyType, anyType, unknownType);
36144         var defaultIterationTypes = createIterationTypes(neverType, anyType, undefinedType);
36145         var asyncIterationTypesResolver = {
36146             iterableCacheKey: "iterationTypesOfAsyncIterable",
36147             iteratorCacheKey: "iterationTypesOfAsyncIterator",
36148             iteratorSymbolName: "asyncIterator",
36149             getGlobalIteratorType: getGlobalAsyncIteratorType,
36150             getGlobalIterableType: getGlobalAsyncIterableType,
36151             getGlobalIterableIteratorType: getGlobalAsyncIterableIteratorType,
36152             getGlobalGeneratorType: getGlobalAsyncGeneratorType,
36153             resolveIterationType: getAwaitedType,
36154             mustHaveANextMethodDiagnostic: ts.Diagnostics.An_async_iterator_must_have_a_next_method,
36155             mustBeAMethodDiagnostic: ts.Diagnostics.The_0_property_of_an_async_iterator_must_be_a_method,
36156             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,
36157         };
36158         var syncIterationTypesResolver = {
36159             iterableCacheKey: "iterationTypesOfIterable",
36160             iteratorCacheKey: "iterationTypesOfIterator",
36161             iteratorSymbolName: "iterator",
36162             getGlobalIteratorType: getGlobalIteratorType,
36163             getGlobalIterableType: getGlobalIterableType,
36164             getGlobalIterableIteratorType: getGlobalIterableIteratorType,
36165             getGlobalGeneratorType: getGlobalGeneratorType,
36166             resolveIterationType: function (type, _errorNode) { return type; },
36167             mustHaveANextMethodDiagnostic: ts.Diagnostics.An_iterator_must_have_a_next_method,
36168             mustBeAMethodDiagnostic: ts.Diagnostics.The_0_property_of_an_iterator_must_be_a_method,
36169             mustHaveAValueDiagnostic: ts.Diagnostics.The_type_returned_by_the_0_method_of_an_iterator_must_have_a_value_property,
36170         };
36171         var amalgamatedDuplicates;
36172         var reverseMappedCache = new ts.Map();
36173         var inInferTypeForHomomorphicMappedType = false;
36174         var ambientModulesCache;
36175         var patternAmbientModules;
36176         var patternAmbientModuleAugmentations;
36177         var globalObjectType;
36178         var globalFunctionType;
36179         var globalCallableFunctionType;
36180         var globalNewableFunctionType;
36181         var globalArrayType;
36182         var globalReadonlyArrayType;
36183         var globalStringType;
36184         var globalNumberType;
36185         var globalBooleanType;
36186         var globalRegExpType;
36187         var globalThisType;
36188         var anyArrayType;
36189         var autoArrayType;
36190         var anyReadonlyArrayType;
36191         var deferredGlobalNonNullableTypeAlias;
36192         var deferredGlobalESSymbolConstructorSymbol;
36193         var deferredGlobalESSymbolType;
36194         var deferredGlobalTypedPropertyDescriptorType;
36195         var deferredGlobalPromiseType;
36196         var deferredGlobalPromiseLikeType;
36197         var deferredGlobalPromiseConstructorSymbol;
36198         var deferredGlobalPromiseConstructorLikeType;
36199         var deferredGlobalIterableType;
36200         var deferredGlobalIteratorType;
36201         var deferredGlobalIterableIteratorType;
36202         var deferredGlobalGeneratorType;
36203         var deferredGlobalIteratorYieldResultType;
36204         var deferredGlobalIteratorReturnResultType;
36205         var deferredGlobalAsyncIterableType;
36206         var deferredGlobalAsyncIteratorType;
36207         var deferredGlobalAsyncIterableIteratorType;
36208         var deferredGlobalAsyncGeneratorType;
36209         var deferredGlobalTemplateStringsArrayType;
36210         var deferredGlobalImportMetaType;
36211         var deferredGlobalExtractSymbol;
36212         var deferredGlobalOmitSymbol;
36213         var deferredGlobalBigIntType;
36214         var allPotentiallyUnusedIdentifiers = new ts.Map();
36215         var flowLoopStart = 0;
36216         var flowLoopCount = 0;
36217         var sharedFlowCount = 0;
36218         var flowAnalysisDisabled = false;
36219         var flowInvocationCount = 0;
36220         var lastFlowNode;
36221         var lastFlowNodeReachable;
36222         var flowTypeCache;
36223         var emptyStringType = getLiteralType("");
36224         var zeroType = getLiteralType(0);
36225         var zeroBigIntType = getLiteralType({ negative: false, base10Value: "0" });
36226         var resolutionTargets = [];
36227         var resolutionResults = [];
36228         var resolutionPropertyNames = [];
36229         var suggestionCount = 0;
36230         var maximumSuggestionCount = 10;
36231         var mergedSymbols = [];
36232         var symbolLinks = [];
36233         var nodeLinks = [];
36234         var flowLoopCaches = [];
36235         var flowLoopNodes = [];
36236         var flowLoopKeys = [];
36237         var flowLoopTypes = [];
36238         var sharedFlowNodes = [];
36239         var sharedFlowTypes = [];
36240         var flowNodeReachable = [];
36241         var flowNodePostSuper = [];
36242         var potentialThisCollisions = [];
36243         var potentialNewTargetCollisions = [];
36244         var potentialWeakMapCollisions = [];
36245         var awaitedTypeStack = [];
36246         var diagnostics = ts.createDiagnosticCollection();
36247         var suggestionDiagnostics = ts.createDiagnosticCollection();
36248         var typeofTypesByName = new ts.Map(ts.getEntries({
36249             string: stringType,
36250             number: numberType,
36251             bigint: bigintType,
36252             boolean: booleanType,
36253             symbol: esSymbolType,
36254             undefined: undefinedType
36255         }));
36256         var typeofType = createTypeofType();
36257         var _jsxNamespace;
36258         var _jsxFactoryEntity;
36259         var outofbandVarianceMarkerHandler;
36260         var subtypeRelation = new ts.Map();
36261         var strictSubtypeRelation = new ts.Map();
36262         var assignableRelation = new ts.Map();
36263         var comparableRelation = new ts.Map();
36264         var identityRelation = new ts.Map();
36265         var enumRelation = new ts.Map();
36266         var builtinGlobals = ts.createSymbolTable();
36267         builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol);
36268         initializeTypeChecker();
36269         return checker;
36270         function getJsxNamespace(location) {
36271             if (location) {
36272                 var file = ts.getSourceFileOfNode(location);
36273                 if (file) {
36274                     if (ts.isJsxOpeningFragment(location)) {
36275                         if (file.localJsxFragmentNamespace) {
36276                             return file.localJsxFragmentNamespace;
36277                         }
36278                         var jsxFragmentPragma = file.pragmas.get("jsxfrag");
36279                         if (jsxFragmentPragma) {
36280                             var chosenPragma = ts.isArray(jsxFragmentPragma) ? jsxFragmentPragma[0] : jsxFragmentPragma;
36281                             file.localJsxFragmentFactory = ts.parseIsolatedEntityName(chosenPragma.arguments.factory, languageVersion);
36282                             ts.visitNode(file.localJsxFragmentFactory, markAsSynthetic);
36283                             if (file.localJsxFragmentFactory) {
36284                                 return file.localJsxFragmentNamespace = ts.getFirstIdentifier(file.localJsxFragmentFactory).escapedText;
36285                             }
36286                         }
36287                         var entity = getJsxFragmentFactoryEntity(location);
36288                         if (entity) {
36289                             file.localJsxFragmentFactory = entity;
36290                             return file.localJsxFragmentNamespace = ts.getFirstIdentifier(entity).escapedText;
36291                         }
36292                     }
36293                     else {
36294                         if (file.localJsxNamespace) {
36295                             return file.localJsxNamespace;
36296                         }
36297                         var jsxPragma = file.pragmas.get("jsx");
36298                         if (jsxPragma) {
36299                             var chosenPragma = ts.isArray(jsxPragma) ? jsxPragma[0] : jsxPragma;
36300                             file.localJsxFactory = ts.parseIsolatedEntityName(chosenPragma.arguments.factory, languageVersion);
36301                             ts.visitNode(file.localJsxFactory, markAsSynthetic);
36302                             if (file.localJsxFactory) {
36303                                 return file.localJsxNamespace = ts.getFirstIdentifier(file.localJsxFactory).escapedText;
36304                             }
36305                         }
36306                     }
36307                 }
36308             }
36309             if (!_jsxNamespace) {
36310                 _jsxNamespace = "React";
36311                 if (compilerOptions.jsxFactory) {
36312                     _jsxFactoryEntity = ts.parseIsolatedEntityName(compilerOptions.jsxFactory, languageVersion);
36313                     ts.visitNode(_jsxFactoryEntity, markAsSynthetic);
36314                     if (_jsxFactoryEntity) {
36315                         _jsxNamespace = ts.getFirstIdentifier(_jsxFactoryEntity).escapedText;
36316                     }
36317                 }
36318                 else if (compilerOptions.reactNamespace) {
36319                     _jsxNamespace = ts.escapeLeadingUnderscores(compilerOptions.reactNamespace);
36320                 }
36321             }
36322             if (!_jsxFactoryEntity) {
36323                 _jsxFactoryEntity = ts.factory.createQualifiedName(ts.factory.createIdentifier(ts.unescapeLeadingUnderscores(_jsxNamespace)), "createElement");
36324             }
36325             return _jsxNamespace;
36326             function markAsSynthetic(node) {
36327                 ts.setTextRangePosEnd(node, -1, -1);
36328                 return ts.visitEachChild(node, markAsSynthetic, ts.nullTransformationContext);
36329             }
36330         }
36331         function getEmitResolver(sourceFile, cancellationToken) {
36332             getDiagnostics(sourceFile, cancellationToken);
36333             return emitResolver;
36334         }
36335         function lookupOrIssueError(location, message, arg0, arg1, arg2, arg3) {
36336             var diagnostic = location
36337                 ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3)
36338                 : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3);
36339             var existing = diagnostics.lookup(diagnostic);
36340             if (existing) {
36341                 return existing;
36342             }
36343             else {
36344                 diagnostics.add(diagnostic);
36345                 return diagnostic;
36346             }
36347         }
36348         function errorSkippedOn(key, location, message, arg0, arg1, arg2, arg3) {
36349             var diagnostic = error(location, message, arg0, arg1, arg2, arg3);
36350             diagnostic.skippedOn = key;
36351             return diagnostic;
36352         }
36353         function error(location, message, arg0, arg1, arg2, arg3) {
36354             var diagnostic = location
36355                 ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3)
36356                 : ts.createCompilerDiagnostic(message, arg0, arg1, arg2, arg3);
36357             diagnostics.add(diagnostic);
36358             return diagnostic;
36359         }
36360         function addErrorOrSuggestion(isError, diagnostic) {
36361             if (isError) {
36362                 diagnostics.add(diagnostic);
36363             }
36364             else {
36365                 suggestionDiagnostics.add(__assign(__assign({}, diagnostic), { category: ts.DiagnosticCategory.Suggestion }));
36366             }
36367         }
36368         function errorOrSuggestion(isError, location, message, arg0, arg1, arg2, arg3) {
36369             if (location.pos < 0 || location.end < 0) {
36370                 if (!isError) {
36371                     return;
36372                 }
36373                 var file = ts.getSourceFileOfNode(location);
36374                 addErrorOrSuggestion(isError, "message" in message ? ts.createFileDiagnostic(file, 0, 0, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForFileFromMessageChain(file, message));
36375                 return;
36376             }
36377             addErrorOrSuggestion(isError, "message" in message ? ts.createDiagnosticForNode(location, message, arg0, arg1, arg2, arg3) : ts.createDiagnosticForNodeFromMessageChain(location, message));
36378         }
36379         function errorAndMaybeSuggestAwait(location, maybeMissingAwait, message, arg0, arg1, arg2, arg3) {
36380             var diagnostic = error(location, message, arg0, arg1, arg2, arg3);
36381             if (maybeMissingAwait) {
36382                 var related = ts.createDiagnosticForNode(location, ts.Diagnostics.Did_you_forget_to_use_await);
36383                 ts.addRelatedInfo(diagnostic, related);
36384             }
36385             return diagnostic;
36386         }
36387         function addDeprecatedSuggestionWorker(declarations, diagnostic) {
36388             var deprecatedTag = Array.isArray(declarations) ? ts.forEach(declarations, ts.getJSDocDeprecatedTag) : ts.getJSDocDeprecatedTag(declarations);
36389             if (deprecatedTag) {
36390                 ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(deprecatedTag, ts.Diagnostics.The_declaration_was_marked_as_deprecated_here));
36391             }
36392             suggestionDiagnostics.add(diagnostic);
36393             return diagnostic;
36394         }
36395         function addDeprecatedSuggestion(location, declarations, deprecatedEntity) {
36396             var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity);
36397             return addDeprecatedSuggestionWorker(declarations, diagnostic);
36398         }
36399         function addDeprecatedSuggestionWithSignature(location, declaration, deprecatedEntity, signatureString) {
36400             var diagnostic = deprecatedEntity
36401                 ? ts.createDiagnosticForNode(location, ts.Diagnostics.The_signature_0_of_1_is_deprecated, signatureString, deprecatedEntity)
36402                 : ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, signatureString);
36403             return addDeprecatedSuggestionWorker(declaration, diagnostic);
36404         }
36405         function createSymbol(flags, name, checkFlags) {
36406             symbolCount++;
36407             var symbol = (new Symbol(flags | 33554432, name));
36408             symbol.checkFlags = checkFlags || 0;
36409             return symbol;
36410         }
36411         function getExcludedSymbolFlags(flags) {
36412             var result = 0;
36413             if (flags & 2)
36414                 result |= 111551;
36415             if (flags & 1)
36416                 result |= 111550;
36417             if (flags & 4)
36418                 result |= 0;
36419             if (flags & 8)
36420                 result |= 900095;
36421             if (flags & 16)
36422                 result |= 110991;
36423             if (flags & 32)
36424                 result |= 899503;
36425             if (flags & 64)
36426                 result |= 788872;
36427             if (flags & 256)
36428                 result |= 899327;
36429             if (flags & 128)
36430                 result |= 899967;
36431             if (flags & 512)
36432                 result |= 110735;
36433             if (flags & 8192)
36434                 result |= 103359;
36435             if (flags & 32768)
36436                 result |= 46015;
36437             if (flags & 65536)
36438                 result |= 78783;
36439             if (flags & 262144)
36440                 result |= 526824;
36441             if (flags & 524288)
36442                 result |= 788968;
36443             if (flags & 2097152)
36444                 result |= 2097152;
36445             return result;
36446         }
36447         function recordMergedSymbol(target, source) {
36448             if (!source.mergeId) {
36449                 source.mergeId = nextMergeId;
36450                 nextMergeId++;
36451             }
36452             mergedSymbols[source.mergeId] = target;
36453         }
36454         function cloneSymbol(symbol) {
36455             var result = createSymbol(symbol.flags, symbol.escapedName);
36456             result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
36457             result.parent = symbol.parent;
36458             if (symbol.valueDeclaration)
36459                 result.valueDeclaration = symbol.valueDeclaration;
36460             if (symbol.constEnumOnlyModule)
36461                 result.constEnumOnlyModule = true;
36462             if (symbol.members)
36463                 result.members = new ts.Map(symbol.members);
36464             if (symbol.exports)
36465                 result.exports = new ts.Map(symbol.exports);
36466             recordMergedSymbol(result, symbol);
36467             return result;
36468         }
36469         function mergeSymbol(target, source, unidirectional) {
36470             if (unidirectional === void 0) { unidirectional = false; }
36471             if (!(target.flags & getExcludedSymbolFlags(source.flags)) ||
36472                 (source.flags | target.flags) & 67108864) {
36473                 if (source === target) {
36474                     return target;
36475                 }
36476                 if (!(target.flags & 33554432)) {
36477                     var resolvedTarget = resolveSymbol(target);
36478                     if (resolvedTarget === unknownSymbol) {
36479                         return source;
36480                     }
36481                     target = cloneSymbol(resolvedTarget);
36482                 }
36483                 if (source.flags & 512 && target.flags & 512 && target.constEnumOnlyModule && !source.constEnumOnlyModule) {
36484                     target.constEnumOnlyModule = false;
36485                 }
36486                 target.flags |= source.flags;
36487                 if (source.valueDeclaration) {
36488                     ts.setValueDeclaration(target, source.valueDeclaration);
36489                 }
36490                 ts.addRange(target.declarations, source.declarations);
36491                 if (source.members) {
36492                     if (!target.members)
36493                         target.members = ts.createSymbolTable();
36494                     mergeSymbolTable(target.members, source.members, unidirectional);
36495                 }
36496                 if (source.exports) {
36497                     if (!target.exports)
36498                         target.exports = ts.createSymbolTable();
36499                     mergeSymbolTable(target.exports, source.exports, unidirectional);
36500                 }
36501                 if (!unidirectional) {
36502                     recordMergedSymbol(target, source);
36503                 }
36504             }
36505             else if (target.flags & 1024) {
36506                 if (target !== globalThisSymbol) {
36507                     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));
36508                 }
36509             }
36510             else {
36511                 var isEitherEnum = !!(target.flags & 384 || source.flags & 384);
36512                 var isEitherBlockScoped_1 = !!(target.flags & 2 || source.flags & 2);
36513                 var message = isEitherEnum
36514                     ? ts.Diagnostics.Enum_declarations_can_only_merge_with_namespace_or_other_enum_declarations
36515                     : isEitherBlockScoped_1
36516                         ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0
36517                         : ts.Diagnostics.Duplicate_identifier_0;
36518                 var sourceSymbolFile = source.declarations && ts.getSourceFileOfNode(source.declarations[0]);
36519                 var targetSymbolFile = target.declarations && ts.getSourceFileOfNode(target.declarations[0]);
36520                 var symbolName_1 = symbolToString(source);
36521                 if (sourceSymbolFile && targetSymbolFile && amalgamatedDuplicates && !isEitherEnum && sourceSymbolFile !== targetSymbolFile) {
36522                     var firstFile_1 = ts.comparePaths(sourceSymbolFile.path, targetSymbolFile.path) === -1 ? sourceSymbolFile : targetSymbolFile;
36523                     var secondFile_1 = firstFile_1 === sourceSymbolFile ? targetSymbolFile : sourceSymbolFile;
36524                     var filesDuplicates = ts.getOrUpdate(amalgamatedDuplicates, firstFile_1.path + "|" + secondFile_1.path, function () {
36525                         return ({ firstFile: firstFile_1, secondFile: secondFile_1, conflictingSymbols: new ts.Map() });
36526                     });
36527                     var conflictingSymbolInfo = ts.getOrUpdate(filesDuplicates.conflictingSymbols, symbolName_1, function () {
36528                         return ({ isBlockScoped: isEitherBlockScoped_1, firstFileLocations: [], secondFileLocations: [] });
36529                     });
36530                     addDuplicateLocations(conflictingSymbolInfo.firstFileLocations, source);
36531                     addDuplicateLocations(conflictingSymbolInfo.secondFileLocations, target);
36532                 }
36533                 else {
36534                     addDuplicateDeclarationErrorsForSymbols(source, message, symbolName_1, target);
36535                     addDuplicateDeclarationErrorsForSymbols(target, message, symbolName_1, source);
36536                 }
36537             }
36538             return target;
36539             function addDuplicateLocations(locs, symbol) {
36540                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
36541                     var decl = _a[_i];
36542                     ts.pushIfUnique(locs, decl);
36543                 }
36544             }
36545         }
36546         function addDuplicateDeclarationErrorsForSymbols(target, message, symbolName, source) {
36547             ts.forEach(target.declarations, function (node) {
36548                 addDuplicateDeclarationError(node, message, symbolName, source.declarations);
36549             });
36550         }
36551         function addDuplicateDeclarationError(node, message, symbolName, relatedNodes) {
36552             var errorNode = (ts.getExpandoInitializer(node, false) ? ts.getNameOfExpando(node) : ts.getNameOfDeclaration(node)) || node;
36553             var err = lookupOrIssueError(errorNode, message, symbolName);
36554             var _loop_7 = function (relatedNode) {
36555                 var adjustedNode = (ts.getExpandoInitializer(relatedNode, false) ? ts.getNameOfExpando(relatedNode) : ts.getNameOfDeclaration(relatedNode)) || relatedNode;
36556                 if (adjustedNode === errorNode)
36557                     return "continue";
36558                 err.relatedInformation = err.relatedInformation || [];
36559                 var leadingMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics._0_was_also_declared_here, symbolName);
36560                 var followOnMessage = ts.createDiagnosticForNode(adjustedNode, ts.Diagnostics.and_here);
36561                 if (ts.length(err.relatedInformation) >= 5 || ts.some(err.relatedInformation, function (r) { return ts.compareDiagnostics(r, followOnMessage) === 0 || ts.compareDiagnostics(r, leadingMessage) === 0; }))
36562                     return "continue";
36563                 ts.addRelatedInfo(err, !ts.length(err.relatedInformation) ? leadingMessage : followOnMessage);
36564             };
36565             for (var _i = 0, _a = relatedNodes || ts.emptyArray; _i < _a.length; _i++) {
36566                 var relatedNode = _a[_i];
36567                 _loop_7(relatedNode);
36568             }
36569         }
36570         function combineSymbolTables(first, second) {
36571             if (!(first === null || first === void 0 ? void 0 : first.size))
36572                 return second;
36573             if (!(second === null || second === void 0 ? void 0 : second.size))
36574                 return first;
36575             var combined = ts.createSymbolTable();
36576             mergeSymbolTable(combined, first);
36577             mergeSymbolTable(combined, second);
36578             return combined;
36579         }
36580         function mergeSymbolTable(target, source, unidirectional) {
36581             if (unidirectional === void 0) { unidirectional = false; }
36582             source.forEach(function (sourceSymbol, id) {
36583                 var targetSymbol = target.get(id);
36584                 target.set(id, targetSymbol ? mergeSymbol(targetSymbol, sourceSymbol, unidirectional) : sourceSymbol);
36585             });
36586         }
36587         function mergeModuleAugmentation(moduleName) {
36588             var _a, _b;
36589             var moduleAugmentation = moduleName.parent;
36590             if (moduleAugmentation.symbol.declarations[0] !== moduleAugmentation) {
36591                 ts.Debug.assert(moduleAugmentation.symbol.declarations.length > 1);
36592                 return;
36593             }
36594             if (ts.isGlobalScopeAugmentation(moduleAugmentation)) {
36595                 mergeSymbolTable(globals, moduleAugmentation.symbol.exports);
36596             }
36597             else {
36598                 var moduleNotFoundError = !(moduleName.parent.parent.flags & 8388608)
36599                     ? ts.Diagnostics.Invalid_module_name_in_augmentation_module_0_cannot_be_found
36600                     : undefined;
36601                 var mainModule_1 = resolveExternalModuleNameWorker(moduleName, moduleName, moduleNotFoundError, true);
36602                 if (!mainModule_1) {
36603                     return;
36604                 }
36605                 mainModule_1 = resolveExternalModuleSymbol(mainModule_1);
36606                 if (mainModule_1.flags & 1920) {
36607                     if (ts.some(patternAmbientModules, function (module) { return mainModule_1 === module.symbol; })) {
36608                         var merged = mergeSymbol(moduleAugmentation.symbol, mainModule_1, true);
36609                         if (!patternAmbientModuleAugmentations) {
36610                             patternAmbientModuleAugmentations = new ts.Map();
36611                         }
36612                         patternAmbientModuleAugmentations.set(moduleName.text, merged);
36613                     }
36614                     else {
36615                         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)) {
36616                             var resolvedExports = getResolvedMembersOrExportsOfSymbol(mainModule_1, "resolvedExports");
36617                             for (var _i = 0, _c = ts.arrayFrom(moduleAugmentation.symbol.exports.entries()); _i < _c.length; _i++) {
36618                                 var _d = _c[_i], key = _d[0], value = _d[1];
36619                                 if (resolvedExports.has(key) && !mainModule_1.exports.has(key)) {
36620                                     mergeSymbol(resolvedExports.get(key), value);
36621                                 }
36622                             }
36623                         }
36624                         mergeSymbol(mainModule_1, moduleAugmentation.symbol);
36625                     }
36626                 }
36627                 else {
36628                     error(moduleName, ts.Diagnostics.Cannot_augment_module_0_because_it_resolves_to_a_non_module_entity, moduleName.text);
36629                 }
36630             }
36631         }
36632         function addToSymbolTable(target, source, message) {
36633             source.forEach(function (sourceSymbol, id) {
36634                 var targetSymbol = target.get(id);
36635                 if (targetSymbol) {
36636                     ts.forEach(targetSymbol.declarations, addDeclarationDiagnostic(ts.unescapeLeadingUnderscores(id), message));
36637                 }
36638                 else {
36639                     target.set(id, sourceSymbol);
36640                 }
36641             });
36642             function addDeclarationDiagnostic(id, message) {
36643                 return function (declaration) { return diagnostics.add(ts.createDiagnosticForNode(declaration, message, id)); };
36644             }
36645         }
36646         function getSymbolLinks(symbol) {
36647             if (symbol.flags & 33554432)
36648                 return symbol;
36649             var id = getSymbolId(symbol);
36650             return symbolLinks[id] || (symbolLinks[id] = new SymbolLinks());
36651         }
36652         function getNodeLinks(node) {
36653             var nodeId = getNodeId(node);
36654             return nodeLinks[nodeId] || (nodeLinks[nodeId] = new NodeLinks());
36655         }
36656         function isGlobalSourceFile(node) {
36657             return node.kind === 297 && !ts.isExternalOrCommonJsModule(node);
36658         }
36659         function getSymbol(symbols, name, meaning) {
36660             if (meaning) {
36661                 var symbol = getMergedSymbol(symbols.get(name));
36662                 if (symbol) {
36663                     ts.Debug.assert((ts.getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here.");
36664                     if (symbol.flags & meaning) {
36665                         return symbol;
36666                     }
36667                     if (symbol.flags & 2097152) {
36668                         var target = resolveAlias(symbol);
36669                         if (target === unknownSymbol || target.flags & meaning) {
36670                             return symbol;
36671                         }
36672                     }
36673                 }
36674             }
36675         }
36676         function getSymbolsOfParameterPropertyDeclaration(parameter, parameterName) {
36677             var constructorDeclaration = parameter.parent;
36678             var classDeclaration = parameter.parent.parent;
36679             var parameterSymbol = getSymbol(constructorDeclaration.locals, parameterName, 111551);
36680             var propertySymbol = getSymbol(getMembersOfSymbol(classDeclaration.symbol), parameterName, 111551);
36681             if (parameterSymbol && propertySymbol) {
36682                 return [parameterSymbol, propertySymbol];
36683             }
36684             return ts.Debug.fail("There should exist two symbols, one as property declaration and one as parameter declaration");
36685         }
36686         function isBlockScopedNameDeclaredBeforeUse(declaration, usage) {
36687             var declarationFile = ts.getSourceFileOfNode(declaration);
36688             var useFile = ts.getSourceFileOfNode(usage);
36689             var declContainer = ts.getEnclosingBlockScopeContainer(declaration);
36690             if (declarationFile !== useFile) {
36691                 if ((moduleKind && (declarationFile.externalModuleIndicator || useFile.externalModuleIndicator)) ||
36692                     (!ts.outFile(compilerOptions)) ||
36693                     isInTypeQuery(usage) ||
36694                     declaration.flags & 8388608) {
36695                     return true;
36696                 }
36697                 if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
36698                     return true;
36699                 }
36700                 var sourceFiles = host.getSourceFiles();
36701                 return sourceFiles.indexOf(declarationFile) <= sourceFiles.indexOf(useFile);
36702             }
36703             if (declaration.pos <= usage.pos && !(ts.isPropertyDeclaration(declaration) && ts.isThisProperty(usage.parent) && !declaration.initializer && !declaration.exclamationToken)) {
36704                 if (declaration.kind === 198) {
36705                     var errorBindingElement = ts.getAncestor(usage, 198);
36706                     if (errorBindingElement) {
36707                         return ts.findAncestor(errorBindingElement, ts.isBindingElement) !== ts.findAncestor(declaration, ts.isBindingElement) ||
36708                             declaration.pos < errorBindingElement.pos;
36709                     }
36710                     return isBlockScopedNameDeclaredBeforeUse(ts.getAncestor(declaration, 249), usage);
36711                 }
36712                 else if (declaration.kind === 249) {
36713                     return !isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage);
36714                 }
36715                 else if (ts.isClassDeclaration(declaration)) {
36716                     return !ts.findAncestor(usage, function (n) { return ts.isComputedPropertyName(n) && n.parent.parent === declaration; });
36717                 }
36718                 else if (ts.isPropertyDeclaration(declaration)) {
36719                     return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, false);
36720                 }
36721                 else if (ts.isParameterPropertyDeclaration(declaration, declaration.parent)) {
36722                     return !(compilerOptions.target === 99 && !!compilerOptions.useDefineForClassFields
36723                         && ts.getContainingClass(declaration) === ts.getContainingClass(usage)
36724                         && isUsedInFunctionOrInstanceProperty(usage, declaration));
36725                 }
36726                 return true;
36727             }
36728             if (usage.parent.kind === 270 || (usage.parent.kind === 266 && usage.parent.isExportEquals)) {
36729                 return true;
36730             }
36731             if (usage.kind === 266 && usage.isExportEquals) {
36732                 return true;
36733             }
36734             if (!!(usage.flags & 4194304) || isInTypeQuery(usage) || usageInTypeDeclaration()) {
36735                 return true;
36736             }
36737             if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
36738                 if (compilerOptions.target === 99 && !!compilerOptions.useDefineForClassFields
36739                     && ts.getContainingClass(declaration)
36740                     && (ts.isPropertyDeclaration(declaration) || ts.isParameterPropertyDeclaration(declaration, declaration.parent))) {
36741                     return !isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, true);
36742                 }
36743                 else {
36744                     return true;
36745                 }
36746             }
36747             return false;
36748             function usageInTypeDeclaration() {
36749                 return !!ts.findAncestor(usage, function (node) { return ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node); });
36750             }
36751             function isImmediatelyUsedInInitializerOfBlockScopedVariable(declaration, usage) {
36752                 switch (declaration.parent.parent.kind) {
36753                     case 232:
36754                     case 237:
36755                     case 239:
36756                         if (isSameScopeDescendentOf(usage, declaration, declContainer)) {
36757                             return true;
36758                         }
36759                         break;
36760                 }
36761                 var grandparent = declaration.parent.parent;
36762                 return ts.isForInOrOfStatement(grandparent) && isSameScopeDescendentOf(usage, grandparent.expression, declContainer);
36763             }
36764             function isUsedInFunctionOrInstanceProperty(usage, declaration) {
36765                 return !!ts.findAncestor(usage, function (current) {
36766                     if (current === declContainer) {
36767                         return "quit";
36768                     }
36769                     if (ts.isFunctionLike(current)) {
36770                         return true;
36771                     }
36772                     var initializerOfProperty = current.parent &&
36773                         current.parent.kind === 163 &&
36774                         current.parent.initializer === current;
36775                     if (initializerOfProperty) {
36776                         if (ts.hasSyntacticModifier(current.parent, 32)) {
36777                             if (declaration.kind === 165) {
36778                                 return true;
36779                             }
36780                         }
36781                         else {
36782                             var isDeclarationInstanceProperty = declaration.kind === 163 && !ts.hasSyntacticModifier(declaration, 32);
36783                             if (!isDeclarationInstanceProperty || ts.getContainingClass(usage) !== ts.getContainingClass(declaration)) {
36784                                 return true;
36785                             }
36786                         }
36787                     }
36788                     return false;
36789                 });
36790             }
36791             function isPropertyImmediatelyReferencedWithinDeclaration(declaration, usage, stopAtAnyPropertyDeclaration) {
36792                 if (usage.end > declaration.end) {
36793                     return false;
36794                 }
36795                 var ancestorChangingReferenceScope = ts.findAncestor(usage, function (node) {
36796                     if (node === declaration) {
36797                         return "quit";
36798                     }
36799                     switch (node.kind) {
36800                         case 209:
36801                             return true;
36802                         case 163:
36803                             return stopAtAnyPropertyDeclaration &&
36804                                 (ts.isPropertyDeclaration(declaration) && node.parent === declaration.parent
36805                                     || ts.isParameterPropertyDeclaration(declaration, declaration.parent) && node.parent === declaration.parent.parent)
36806                                 ? "quit" : true;
36807                         case 230:
36808                             switch (node.parent.kind) {
36809                                 case 167:
36810                                 case 165:
36811                                 case 168:
36812                                     return true;
36813                                 default:
36814                                     return false;
36815                             }
36816                         default:
36817                             return false;
36818                     }
36819                 });
36820                 return ancestorChangingReferenceScope === undefined;
36821             }
36822         }
36823         function useOuterVariableScopeInParameter(result, location, lastLocation) {
36824             var target = ts.getEmitScriptTarget(compilerOptions);
36825             var functionLocation = location;
36826             if (ts.isParameter(lastLocation) && functionLocation.body && result.valueDeclaration.pos >= functionLocation.body.pos && result.valueDeclaration.end <= functionLocation.body.end) {
36827                 if (target >= 2) {
36828                     var links = getNodeLinks(functionLocation);
36829                     if (links.declarationRequiresScopeChange === undefined) {
36830                         links.declarationRequiresScopeChange = ts.forEach(functionLocation.parameters, requiresScopeChange) || false;
36831                     }
36832                     return !links.declarationRequiresScopeChange;
36833                 }
36834             }
36835             return false;
36836             function requiresScopeChange(node) {
36837                 return requiresScopeChangeWorker(node.name)
36838                     || !!node.initializer && requiresScopeChangeWorker(node.initializer);
36839             }
36840             function requiresScopeChangeWorker(node) {
36841                 switch (node.kind) {
36842                     case 209:
36843                     case 208:
36844                     case 251:
36845                     case 166:
36846                         return false;
36847                     case 165:
36848                     case 167:
36849                     case 168:
36850                     case 288:
36851                         return requiresScopeChangeWorker(node.name);
36852                     case 163:
36853                         if (ts.hasStaticModifier(node)) {
36854                             return target < 99 || !compilerOptions.useDefineForClassFields;
36855                         }
36856                         return requiresScopeChangeWorker(node.name);
36857                     default:
36858                         if (ts.isNullishCoalesce(node) || ts.isOptionalChain(node)) {
36859                             return target < 7;
36860                         }
36861                         if (ts.isBindingElement(node) && node.dotDotDotToken && ts.isObjectBindingPattern(node.parent)) {
36862                             return target < 4;
36863                         }
36864                         if (ts.isTypeNode(node))
36865                             return false;
36866                         return ts.forEachChild(node, requiresScopeChangeWorker) || false;
36867                 }
36868             }
36869         }
36870         function resolveName(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, suggestedNameNotFoundMessage) {
36871             if (excludeGlobals === void 0) { excludeGlobals = false; }
36872             return resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, getSymbol, suggestedNameNotFoundMessage);
36873         }
36874         function resolveNameHelper(location, name, meaning, nameNotFoundMessage, nameArg, isUse, excludeGlobals, lookup, suggestedNameNotFoundMessage) {
36875             var originalLocation = location;
36876             var result;
36877             var lastLocation;
36878             var lastSelfReferenceLocation;
36879             var propertyWithInvalidInitializer;
36880             var associatedDeclarationForContainingInitializerOrBindingName;
36881             var withinDeferredContext = false;
36882             var errorLocation = location;
36883             var grandparent;
36884             var isInExternalModule = false;
36885             loop: while (location) {
36886                 if (location.locals && !isGlobalSourceFile(location)) {
36887                     if (result = lookup(location.locals, name, meaning)) {
36888                         var useResult = true;
36889                         if (ts.isFunctionLike(location) && lastLocation && lastLocation !== location.body) {
36890                             if (meaning & result.flags & 788968 && lastLocation.kind !== 311) {
36891                                 useResult = result.flags & 262144
36892                                     ? lastLocation === location.type ||
36893                                         lastLocation.kind === 160 ||
36894                                         lastLocation.kind === 159
36895                                     : false;
36896                             }
36897                             if (meaning & result.flags & 3) {
36898                                 if (useOuterVariableScopeInParameter(result, location, lastLocation)) {
36899                                     useResult = false;
36900                                 }
36901                                 else if (result.flags & 1) {
36902                                     useResult =
36903                                         lastLocation.kind === 160 ||
36904                                             (lastLocation === location.type &&
36905                                                 !!ts.findAncestor(result.valueDeclaration, ts.isParameter));
36906                                 }
36907                             }
36908                         }
36909                         else if (location.kind === 184) {
36910                             useResult = lastLocation === location.trueType;
36911                         }
36912                         if (useResult) {
36913                             break loop;
36914                         }
36915                         else {
36916                             result = undefined;
36917                         }
36918                     }
36919                 }
36920                 withinDeferredContext = withinDeferredContext || getIsDeferredContext(location, lastLocation);
36921                 switch (location.kind) {
36922                     case 297:
36923                         if (!ts.isExternalOrCommonJsModule(location))
36924                             break;
36925                         isInExternalModule = true;
36926                     case 256:
36927                         var moduleExports = getSymbolOfNode(location).exports || emptySymbols;
36928                         if (location.kind === 297 || (ts.isModuleDeclaration(location) && location.flags & 8388608 && !ts.isGlobalScopeAugmentation(location))) {
36929                             if (result = moduleExports.get("default")) {
36930                                 var localSymbol = ts.getLocalSymbolForExportDefault(result);
36931                                 if (localSymbol && (result.flags & meaning) && localSymbol.escapedName === name) {
36932                                     break loop;
36933                                 }
36934                                 result = undefined;
36935                             }
36936                             var moduleExport = moduleExports.get(name);
36937                             if (moduleExport &&
36938                                 moduleExport.flags === 2097152 &&
36939                                 (ts.getDeclarationOfKind(moduleExport, 270) || ts.getDeclarationOfKind(moduleExport, 269))) {
36940                                 break;
36941                             }
36942                         }
36943                         if (name !== "default" && (result = lookup(moduleExports, name, meaning & 2623475))) {
36944                             if (ts.isSourceFile(location) && location.commonJsModuleIndicator && !result.declarations.some(ts.isJSDocTypeAlias)) {
36945                                 result = undefined;
36946                             }
36947                             else {
36948                                 break loop;
36949                             }
36950                         }
36951                         break;
36952                     case 255:
36953                         if (result = lookup(getSymbolOfNode(location).exports, name, meaning & 8)) {
36954                             break loop;
36955                         }
36956                         break;
36957                     case 163:
36958                         if (!ts.hasSyntacticModifier(location, 32)) {
36959                             var ctor = findConstructorDeclaration(location.parent);
36960                             if (ctor && ctor.locals) {
36961                                 if (lookup(ctor.locals, name, meaning & 111551)) {
36962                                     propertyWithInvalidInitializer = location;
36963                                 }
36964                             }
36965                         }
36966                         break;
36967                     case 252:
36968                     case 221:
36969                     case 253:
36970                         if (result = lookup(getSymbolOfNode(location).members || emptySymbols, name, meaning & 788968)) {
36971                             if (!isTypeParameterSymbolDeclaredInContainer(result, location)) {
36972                                 result = undefined;
36973                                 break;
36974                             }
36975                             if (lastLocation && ts.hasSyntacticModifier(lastLocation, 32)) {
36976                                 error(errorLocation, ts.Diagnostics.Static_members_cannot_reference_class_type_parameters);
36977                                 return undefined;
36978                             }
36979                             break loop;
36980                         }
36981                         if (location.kind === 221 && meaning & 32) {
36982                             var className = location.name;
36983                             if (className && name === className.escapedText) {
36984                                 result = location.symbol;
36985                                 break loop;
36986                             }
36987                         }
36988                         break;
36989                     case 223:
36990                         if (lastLocation === location.expression && location.parent.token === 93) {
36991                             var container = location.parent.parent;
36992                             if (ts.isClassLike(container) && (result = lookup(getSymbolOfNode(container).members, name, meaning & 788968))) {
36993                                 if (nameNotFoundMessage) {
36994                                     error(errorLocation, ts.Diagnostics.Base_class_expressions_cannot_reference_class_type_parameters);
36995                                 }
36996                                 return undefined;
36997                             }
36998                         }
36999                         break;
37000                     case 158:
37001                         grandparent = location.parent.parent;
37002                         if (ts.isClassLike(grandparent) || grandparent.kind === 253) {
37003                             if (result = lookup(getSymbolOfNode(grandparent).members, name, meaning & 788968)) {
37004                                 error(errorLocation, ts.Diagnostics.A_computed_property_name_cannot_reference_a_type_parameter_from_its_containing_type);
37005                                 return undefined;
37006                             }
37007                         }
37008                         break;
37009                     case 209:
37010                         if (compilerOptions.target >= 2) {
37011                             break;
37012                         }
37013                     case 165:
37014                     case 166:
37015                     case 167:
37016                     case 168:
37017                     case 251:
37018                         if (meaning & 3 && name === "arguments") {
37019                             result = argumentsSymbol;
37020                             break loop;
37021                         }
37022                         break;
37023                     case 208:
37024                         if (meaning & 3 && name === "arguments") {
37025                             result = argumentsSymbol;
37026                             break loop;
37027                         }
37028                         if (meaning & 16) {
37029                             var functionName = location.name;
37030                             if (functionName && name === functionName.escapedText) {
37031                                 result = location.symbol;
37032                                 break loop;
37033                             }
37034                         }
37035                         break;
37036                     case 161:
37037                         if (location.parent && location.parent.kind === 160) {
37038                             location = location.parent;
37039                         }
37040                         if (location.parent && (ts.isClassElement(location.parent) || location.parent.kind === 252)) {
37041                             location = location.parent;
37042                         }
37043                         break;
37044                     case 331:
37045                     case 324:
37046                     case 325:
37047                         var root = ts.getJSDocRoot(location);
37048                         if (root) {
37049                             location = root.parent;
37050                         }
37051                         break;
37052                     case 160:
37053                         if (lastLocation && (lastLocation === location.initializer ||
37054                             lastLocation === location.name && ts.isBindingPattern(lastLocation))) {
37055                             if (!associatedDeclarationForContainingInitializerOrBindingName) {
37056                                 associatedDeclarationForContainingInitializerOrBindingName = location;
37057                             }
37058                         }
37059                         break;
37060                     case 198:
37061                         if (lastLocation && (lastLocation === location.initializer ||
37062                             lastLocation === location.name && ts.isBindingPattern(lastLocation))) {
37063                             if (ts.isParameterDeclaration(location) && !associatedDeclarationForContainingInitializerOrBindingName) {
37064                                 associatedDeclarationForContainingInitializerOrBindingName = location;
37065                             }
37066                         }
37067                         break;
37068                     case 185:
37069                         if (meaning & 262144) {
37070                             var parameterName = location.typeParameter.name;
37071                             if (parameterName && name === parameterName.escapedText) {
37072                                 result = location.typeParameter.symbol;
37073                                 break loop;
37074                             }
37075                         }
37076                         break;
37077                 }
37078                 if (isSelfReferenceLocation(location)) {
37079                     lastSelfReferenceLocation = location;
37080                 }
37081                 lastLocation = location;
37082                 location = location.parent;
37083             }
37084             if (isUse && result && (!lastSelfReferenceLocation || result !== lastSelfReferenceLocation.symbol)) {
37085                 result.isReferenced |= meaning;
37086             }
37087             if (!result) {
37088                 if (lastLocation) {
37089                     ts.Debug.assert(lastLocation.kind === 297);
37090                     if (lastLocation.commonJsModuleIndicator && name === "exports" && meaning & lastLocation.symbol.flags) {
37091                         return lastLocation.symbol;
37092                     }
37093                 }
37094                 if (!excludeGlobals) {
37095                     result = lookup(globals, name, meaning);
37096                 }
37097             }
37098             if (!result) {
37099                 if (originalLocation && ts.isInJSFile(originalLocation) && originalLocation.parent) {
37100                     if (ts.isRequireCall(originalLocation.parent, false)) {
37101                         return requireSymbol;
37102                     }
37103                 }
37104             }
37105             if (!result) {
37106                 if (nameNotFoundMessage) {
37107                     if (!errorLocation ||
37108                         !checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) &&
37109                             !checkAndReportErrorForExtendingInterface(errorLocation) &&
37110                             !checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) &&
37111                             !checkAndReportErrorForExportingPrimitiveType(errorLocation, name) &&
37112                             !checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) &&
37113                             !checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) &&
37114                             !checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning)) {
37115                         var suggestion = void 0;
37116                         if (suggestedNameNotFoundMessage && suggestionCount < maximumSuggestionCount) {
37117                             suggestion = getSuggestedSymbolForNonexistentSymbol(originalLocation, name, meaning);
37118                             var isGlobalScopeAugmentationDeclaration = suggestion && suggestion.valueDeclaration && ts.isAmbientModule(suggestion.valueDeclaration) && ts.isGlobalScopeAugmentation(suggestion.valueDeclaration);
37119                             if (isGlobalScopeAugmentationDeclaration) {
37120                                 suggestion = undefined;
37121                             }
37122                             if (suggestion) {
37123                                 var suggestionName = symbolToString(suggestion);
37124                                 var diagnostic = error(errorLocation, suggestedNameNotFoundMessage, diagnosticName(nameArg), suggestionName);
37125                                 if (suggestion.valueDeclaration) {
37126                                     ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
37127                                 }
37128                             }
37129                         }
37130                         if (!suggestion) {
37131                             if (nameArg) {
37132                                 var lib = getSuggestedLibForNonExistentName(nameArg);
37133                                 if (lib) {
37134                                     error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg), lib);
37135                                 }
37136                                 else {
37137                                     error(errorLocation, nameNotFoundMessage, diagnosticName(nameArg));
37138                                 }
37139                             }
37140                         }
37141                         suggestionCount++;
37142                     }
37143                 }
37144                 return undefined;
37145             }
37146             if (nameNotFoundMessage) {
37147                 if (propertyWithInvalidInitializer && !(compilerOptions.target === 99 && compilerOptions.useDefineForClassFields)) {
37148                     var propertyName = propertyWithInvalidInitializer.name;
37149                     error(errorLocation, ts.Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor, ts.declarationNameToString(propertyName), diagnosticName(nameArg));
37150                     return undefined;
37151                 }
37152                 if (errorLocation &&
37153                     (meaning & 2 ||
37154                         ((meaning & 32 || meaning & 384) && (meaning & 111551) === 111551))) {
37155                     var exportOrLocalSymbol = getExportSymbolOfValueSymbolIfExported(result);
37156                     if (exportOrLocalSymbol.flags & 2 || exportOrLocalSymbol.flags & 32 || exportOrLocalSymbol.flags & 384) {
37157                         checkResolvedBlockScopedVariable(exportOrLocalSymbol, errorLocation);
37158                     }
37159                 }
37160                 if (result && isInExternalModule && (meaning & 111551) === 111551 && !(originalLocation.flags & 4194304)) {
37161                     var merged = getMergedSymbol(result);
37162                     if (ts.length(merged.declarations) && ts.every(merged.declarations, function (d) { return ts.isNamespaceExportDeclaration(d) || ts.isSourceFile(d) && !!d.symbol.globalExports; })) {
37163                         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));
37164                     }
37165                 }
37166                 if (result && associatedDeclarationForContainingInitializerOrBindingName && !withinDeferredContext && (meaning & 111551) === 111551) {
37167                     var candidate = getMergedSymbol(getLateBoundSymbol(result));
37168                     var root = ts.getRootDeclaration(associatedDeclarationForContainingInitializerOrBindingName);
37169                     if (candidate === getSymbolOfNode(associatedDeclarationForContainingInitializerOrBindingName)) {
37170                         error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_itself, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name));
37171                     }
37172                     else if (candidate.valueDeclaration && candidate.valueDeclaration.pos > associatedDeclarationForContainingInitializerOrBindingName.pos && root.parent.locals && lookup(root.parent.locals, candidate.escapedName, meaning) === candidate) {
37173                         error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
37174                     }
37175                 }
37176                 if (result && errorLocation && meaning & 111551 && result.flags & 2097152) {
37177                     checkSymbolUsageInExpressionContext(result, name, errorLocation);
37178                 }
37179             }
37180             return result;
37181         }
37182         function checkSymbolUsageInExpressionContext(symbol, name, useSite) {
37183             if (!ts.isValidTypeOnlyAliasUseSite(useSite)) {
37184                 var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
37185                 if (typeOnlyDeclaration) {
37186                     var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration);
37187                     var message = isExport
37188                         ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
37189                         : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
37190                     var relatedMessage = isExport
37191                         ? ts.Diagnostics._0_was_exported_here
37192                         : ts.Diagnostics._0_was_imported_here;
37193                     var unescapedName = ts.unescapeLeadingUnderscores(name);
37194                     ts.addRelatedInfo(error(useSite, message, unescapedName), ts.createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, unescapedName));
37195                 }
37196             }
37197         }
37198         function getIsDeferredContext(location, lastLocation) {
37199             if (location.kind !== 209 && location.kind !== 208) {
37200                 return ts.isTypeQueryNode(location) || ((ts.isFunctionLikeDeclaration(location) ||
37201                     (location.kind === 163 && !ts.hasSyntacticModifier(location, 32))) && (!lastLocation || lastLocation !== location.name));
37202             }
37203             if (lastLocation && lastLocation === location.name) {
37204                 return false;
37205             }
37206             if (location.asteriskToken || ts.hasSyntacticModifier(location, 256)) {
37207                 return true;
37208             }
37209             return !ts.getImmediatelyInvokedFunctionExpression(location);
37210         }
37211         function isSelfReferenceLocation(node) {
37212             switch (node.kind) {
37213                 case 251:
37214                 case 252:
37215                 case 253:
37216                 case 255:
37217                 case 254:
37218                 case 256:
37219                     return true;
37220                 default:
37221                     return false;
37222             }
37223         }
37224         function diagnosticName(nameArg) {
37225             return ts.isString(nameArg) ? ts.unescapeLeadingUnderscores(nameArg) : ts.declarationNameToString(nameArg);
37226         }
37227         function isTypeParameterSymbolDeclaredInContainer(symbol, container) {
37228             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
37229                 var decl = _a[_i];
37230                 if (decl.kind === 159) {
37231                     var parent = ts.isJSDocTemplateTag(decl.parent) ? ts.getJSDocHost(decl.parent) : decl.parent;
37232                     if (parent === container) {
37233                         return !(ts.isJSDocTemplateTag(decl.parent) && ts.find(decl.parent.parent.tags, ts.isJSDocTypeAlias));
37234                     }
37235                 }
37236             }
37237             return false;
37238         }
37239         function checkAndReportErrorForMissingPrefix(errorLocation, name, nameArg) {
37240             if (!ts.isIdentifier(errorLocation) || errorLocation.escapedText !== name || isTypeReferenceIdentifier(errorLocation) || isInTypeQuery(errorLocation)) {
37241                 return false;
37242             }
37243             var container = ts.getThisContainer(errorLocation, false);
37244             var location = container;
37245             while (location) {
37246                 if (ts.isClassLike(location.parent)) {
37247                     var classSymbol = getSymbolOfNode(location.parent);
37248                     if (!classSymbol) {
37249                         break;
37250                     }
37251                     var constructorType = getTypeOfSymbol(classSymbol);
37252                     if (getPropertyOfType(constructorType, name)) {
37253                         error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_static_member_1_0, diagnosticName(nameArg), symbolToString(classSymbol));
37254                         return true;
37255                     }
37256                     if (location === container && !ts.hasSyntacticModifier(location, 32)) {
37257                         var instanceType = getDeclaredTypeOfSymbol(classSymbol).thisType;
37258                         if (getPropertyOfType(instanceType, name)) {
37259                             error(errorLocation, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_the_instance_member_this_0, diagnosticName(nameArg));
37260                             return true;
37261                         }
37262                     }
37263                 }
37264                 location = location.parent;
37265             }
37266             return false;
37267         }
37268         function checkAndReportErrorForExtendingInterface(errorLocation) {
37269             var expression = getEntityNameForExtendingInterface(errorLocation);
37270             if (expression && resolveEntityName(expression, 64, true)) {
37271                 error(errorLocation, ts.Diagnostics.Cannot_extend_an_interface_0_Did_you_mean_implements, ts.getTextOfNode(expression));
37272                 return true;
37273             }
37274             return false;
37275         }
37276         function getEntityNameForExtendingInterface(node) {
37277             switch (node.kind) {
37278                 case 78:
37279                 case 201:
37280                     return node.parent ? getEntityNameForExtendingInterface(node.parent) : undefined;
37281                 case 223:
37282                     if (ts.isEntityNameExpression(node.expression)) {
37283                         return node.expression;
37284                     }
37285                 default:
37286                     return undefined;
37287             }
37288         }
37289         function checkAndReportErrorForUsingTypeAsNamespace(errorLocation, name, meaning) {
37290             var namespaceMeaning = 1920 | (ts.isInJSFile(errorLocation) ? 111551 : 0);
37291             if (meaning === namespaceMeaning) {
37292                 var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 & ~namespaceMeaning, undefined, undefined, false));
37293                 var parent = errorLocation.parent;
37294                 if (symbol) {
37295                     if (ts.isQualifiedName(parent)) {
37296                         ts.Debug.assert(parent.left === errorLocation, "Should only be resolving left side of qualified name as a namespace");
37297                         var propName = parent.right.escapedText;
37298                         var propType = getPropertyOfType(getDeclaredTypeOfSymbol(symbol), propName);
37299                         if (propType) {
37300                             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));
37301                             return true;
37302                         }
37303                     }
37304                     error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_namespace_here, ts.unescapeLeadingUnderscores(name));
37305                     return true;
37306                 }
37307             }
37308             return false;
37309         }
37310         function checkAndReportErrorForUsingValueAsType(errorLocation, name, meaning) {
37311             if (meaning & (788968 & ~1920)) {
37312                 var symbol = resolveSymbol(resolveName(errorLocation, name, ~788968 & 111551, undefined, undefined, false));
37313                 if (symbol && !(symbol.flags & 1920)) {
37314                     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));
37315                     return true;
37316                 }
37317             }
37318             return false;
37319         }
37320         function isPrimitiveTypeName(name) {
37321             return name === "any" || name === "string" || name === "number" || name === "boolean" || name === "never" || name === "unknown";
37322         }
37323         function checkAndReportErrorForExportingPrimitiveType(errorLocation, name) {
37324             if (isPrimitiveTypeName(name) && errorLocation.parent.kind === 270) {
37325                 error(errorLocation, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, name);
37326                 return true;
37327             }
37328             return false;
37329         }
37330         function checkAndReportErrorForUsingTypeAsValue(errorLocation, name, meaning) {
37331             if (meaning & (111551 & ~1024)) {
37332                 if (isPrimitiveTypeName(name)) {
37333                     error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, ts.unescapeLeadingUnderscores(name));
37334                     return true;
37335                 }
37336                 var symbol = resolveSymbol(resolveName(errorLocation, name, 788968 & ~111551, undefined, undefined, false));
37337                 if (symbol && !(symbol.flags & 1024)) {
37338                     var rawName = ts.unescapeLeadingUnderscores(name);
37339                     if (isES2015OrLaterConstructorName(name)) {
37340                         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);
37341                     }
37342                     else if (maybeMappedType(errorLocation, symbol)) {
37343                         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");
37344                     }
37345                     else {
37346                         error(errorLocation, ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here, rawName);
37347                     }
37348                     return true;
37349                 }
37350             }
37351             return false;
37352         }
37353         function maybeMappedType(node, symbol) {
37354             var container = ts.findAncestor(node.parent, function (n) {
37355                 return ts.isComputedPropertyName(n) || ts.isPropertySignature(n) ? false : ts.isTypeLiteralNode(n) || "quit";
37356             });
37357             if (container && container.members.length === 1) {
37358                 var type = getDeclaredTypeOfSymbol(symbol);
37359                 return !!(type.flags & 1048576) && allTypesAssignableToKind(type, 384, true);
37360             }
37361             return false;
37362         }
37363         function isES2015OrLaterConstructorName(n) {
37364             switch (n) {
37365                 case "Promise":
37366                 case "Symbol":
37367                 case "Map":
37368                 case "WeakMap":
37369                 case "Set":
37370                 case "WeakSet":
37371                     return true;
37372             }
37373             return false;
37374         }
37375         function checkAndReportErrorForUsingNamespaceModuleAsValue(errorLocation, name, meaning) {
37376             if (meaning & (111551 & ~1024 & ~788968)) {
37377                 var symbol = resolveSymbol(resolveName(errorLocation, name, 1024 & ~111551, undefined, undefined, false));
37378                 if (symbol) {
37379                     error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_value, ts.unescapeLeadingUnderscores(name));
37380                     return true;
37381                 }
37382             }
37383             else if (meaning & (788968 & ~1024 & ~111551)) {
37384                 var symbol = resolveSymbol(resolveName(errorLocation, name, (512 | 1024) & ~788968, undefined, undefined, false));
37385                 if (symbol) {
37386                     error(errorLocation, ts.Diagnostics.Cannot_use_namespace_0_as_a_type, ts.unescapeLeadingUnderscores(name));
37387                     return true;
37388                 }
37389             }
37390             return false;
37391         }
37392         function checkResolvedBlockScopedVariable(result, errorLocation) {
37393             ts.Debug.assert(!!(result.flags & 2 || result.flags & 32 || result.flags & 384));
37394             if (result.flags & (16 | 1 | 67108864) && result.flags & 32) {
37395                 return;
37396             }
37397             var declaration = ts.find(result.declarations, function (d) { return ts.isBlockOrCatchScoped(d) || ts.isClassLike(d) || (d.kind === 255); });
37398             if (declaration === undefined)
37399                 return ts.Debug.fail("checkResolvedBlockScopedVariable could not find block-scoped declaration");
37400             if (!(declaration.flags & 8388608) && !isBlockScopedNameDeclaredBeforeUse(declaration, errorLocation)) {
37401                 var diagnosticMessage = void 0;
37402                 var declarationName = ts.declarationNameToString(ts.getNameOfDeclaration(declaration));
37403                 if (result.flags & 2) {
37404                     diagnosticMessage = error(errorLocation, ts.Diagnostics.Block_scoped_variable_0_used_before_its_declaration, declarationName);
37405                 }
37406                 else if (result.flags & 32) {
37407                     diagnosticMessage = error(errorLocation, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
37408                 }
37409                 else if (result.flags & 256) {
37410                     diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName);
37411                 }
37412                 else {
37413                     ts.Debug.assert(!!(result.flags & 128));
37414                     if (ts.shouldPreserveConstEnums(compilerOptions)) {
37415                         diagnosticMessage = error(errorLocation, ts.Diagnostics.Enum_0_used_before_its_declaration, declarationName);
37416                     }
37417                 }
37418                 if (diagnosticMessage) {
37419                     ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_is_declared_here, declarationName));
37420                 }
37421             }
37422         }
37423         function isSameScopeDescendentOf(initial, parent, stopAt) {
37424             return !!parent && !!ts.findAncestor(initial, function (n) { return n === stopAt || ts.isFunctionLike(n) ? "quit" : n === parent; });
37425         }
37426         function getAnyImportSyntax(node) {
37427             switch (node.kind) {
37428                 case 260:
37429                     return node;
37430                 case 262:
37431                     return node.parent;
37432                 case 263:
37433                     return node.parent.parent;
37434                 case 265:
37435                     return node.parent.parent.parent;
37436                 default:
37437                     return undefined;
37438             }
37439         }
37440         function getDeclarationOfAliasSymbol(symbol) {
37441             return ts.find(symbol.declarations, isAliasSymbolDeclaration);
37442         }
37443         function isAliasSymbolDeclaration(node) {
37444             return node.kind === 260
37445                 || node.kind === 259
37446                 || node.kind === 262 && !!node.name
37447                 || node.kind === 263
37448                 || node.kind === 269
37449                 || node.kind === 265
37450                 || node.kind === 270
37451                 || node.kind === 266 && ts.exportAssignmentIsAlias(node)
37452                 || ts.isBinaryExpression(node) && ts.getAssignmentDeclarationKind(node) === 2 && ts.exportAssignmentIsAlias(node)
37453                 || ts.isAccessExpression(node)
37454                     && ts.isBinaryExpression(node.parent)
37455                     && node.parent.left === node
37456                     && node.parent.operatorToken.kind === 62
37457                     && isAliasableOrJsExpression(node.parent.right)
37458                 || node.kind === 289
37459                 || node.kind === 288 && isAliasableOrJsExpression(node.initializer)
37460                 || ts.isRequireVariableDeclaration(node, true);
37461         }
37462         function isAliasableOrJsExpression(e) {
37463             return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
37464         }
37465         function getTargetOfImportEqualsDeclaration(node, dontResolveAlias) {
37466             var commonJSPropertyAccess = getCommonJSPropertyAccess(node);
37467             if (commonJSPropertyAccess) {
37468                 var name = ts.getLeftmostAccessExpression(commonJSPropertyAccess.expression).arguments[0];
37469                 return ts.isIdentifier(commonJSPropertyAccess.name)
37470                     ? resolveSymbol(getPropertyOfType(resolveExternalModuleTypeByLiteral(name), commonJSPropertyAccess.name.escapedText))
37471                     : undefined;
37472             }
37473             if (ts.isVariableDeclaration(node) || node.moduleReference.kind === 272) {
37474                 var immediate = resolveExternalModuleName(node, ts.getExternalModuleRequireArgument(node) || ts.getExternalModuleImportEqualsDeclarationExpression(node));
37475                 var resolved_4 = resolveExternalModuleSymbol(immediate);
37476                 markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved_4, false);
37477                 return resolved_4;
37478             }
37479             var resolved = getSymbolOfPartOfRightHandSideOfImportEquals(node.moduleReference, dontResolveAlias);
37480             checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved);
37481             return resolved;
37482         }
37483         function checkAndReportErrorForResolvingImportAliasToTypeOnlySymbol(node, resolved) {
37484             if (markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false) && !node.isTypeOnly) {
37485                 var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(getSymbolOfNode(node));
37486                 var isExport = ts.typeOnlyDeclarationIsExport(typeOnlyDeclaration);
37487                 var message = isExport
37488                     ? ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_exported_using_export_type
37489                     : ts.Diagnostics.An_import_alias_cannot_reference_a_declaration_that_was_imported_using_import_type;
37490                 var relatedMessage = isExport
37491                     ? ts.Diagnostics._0_was_exported_here
37492                     : ts.Diagnostics._0_was_imported_here;
37493                 var name = ts.unescapeLeadingUnderscores(typeOnlyDeclaration.name.escapedText);
37494                 ts.addRelatedInfo(error(node.moduleReference, message), ts.createDiagnosticForNode(typeOnlyDeclaration, relatedMessage, name));
37495             }
37496         }
37497         function resolveExportByName(moduleSymbol, name, sourceNode, dontResolveAlias) {
37498             var exportValue = moduleSymbol.exports.get("export=");
37499             var exportSymbol = exportValue ? getPropertyOfType(getTypeOfSymbol(exportValue), name) : moduleSymbol.exports.get(name);
37500             var resolved = resolveSymbol(exportSymbol, dontResolveAlias);
37501             markSymbolOfAliasDeclarationIfTypeOnly(sourceNode, exportSymbol, resolved, false);
37502             return resolved;
37503         }
37504         function isSyntacticDefault(node) {
37505             return ((ts.isExportAssignment(node) && !node.isExportEquals) || ts.hasSyntacticModifier(node, 512) || ts.isExportSpecifier(node));
37506         }
37507         function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias) {
37508             if (!allowSyntheticDefaultImports) {
37509                 return false;
37510             }
37511             if (!file || file.isDeclarationFile) {
37512                 var defaultExportSymbol = resolveExportByName(moduleSymbol, "default", undefined, true);
37513                 if (defaultExportSymbol && ts.some(defaultExportSymbol.declarations, isSyntacticDefault)) {
37514                     return false;
37515                 }
37516                 if (resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), undefined, dontResolveAlias)) {
37517                     return false;
37518                 }
37519                 return true;
37520             }
37521             if (!ts.isSourceFileJS(file)) {
37522                 return hasExportAssignmentSymbol(moduleSymbol);
37523             }
37524             return !file.externalModuleIndicator && !resolveExportByName(moduleSymbol, ts.escapeLeadingUnderscores("__esModule"), undefined, dontResolveAlias);
37525         }
37526         function getTargetOfImportClause(node, dontResolveAlias) {
37527             var moduleSymbol = resolveExternalModuleName(node, node.parent.moduleSpecifier);
37528             if (moduleSymbol) {
37529                 var exportDefaultSymbol = void 0;
37530                 if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) {
37531                     exportDefaultSymbol = moduleSymbol;
37532                 }
37533                 else {
37534                     exportDefaultSymbol = resolveExportByName(moduleSymbol, "default", node, dontResolveAlias);
37535                 }
37536                 var file = ts.find(moduleSymbol.declarations, ts.isSourceFile);
37537                 var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias);
37538                 if (!exportDefaultSymbol && !hasSyntheticDefault) {
37539                     if (hasExportAssignmentSymbol(moduleSymbol)) {
37540                         var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
37541                         var exportEqualsSymbol = moduleSymbol.exports.get("export=");
37542                         var exportAssignment = exportEqualsSymbol.valueDeclaration;
37543                         var err = error(node.name, ts.Diagnostics.Module_0_can_only_be_default_imported_using_the_1_flag, symbolToString(moduleSymbol), compilerOptionName);
37544                         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));
37545                     }
37546                     else {
37547                         reportNonDefaultExport(moduleSymbol, node);
37548                     }
37549                 }
37550                 else if (hasSyntheticDefault) {
37551                     var resolved = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
37552                     markSymbolOfAliasDeclarationIfTypeOnly(node, moduleSymbol, resolved, false);
37553                     return resolved;
37554                 }
37555                 markSymbolOfAliasDeclarationIfTypeOnly(node, exportDefaultSymbol, undefined, false);
37556                 return exportDefaultSymbol;
37557             }
37558         }
37559         function reportNonDefaultExport(moduleSymbol, node) {
37560             var _a, _b;
37561             if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has(node.symbol.escapedName)) {
37562                 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));
37563             }
37564             else {
37565                 var diagnostic = error(node.name, ts.Diagnostics.Module_0_has_no_default_export, symbolToString(moduleSymbol));
37566                 var exportStar = (_b = moduleSymbol.exports) === null || _b === void 0 ? void 0 : _b.get("__export");
37567                 if (exportStar) {
37568                     var defaultExport = ts.find(exportStar.declarations, function (decl) {
37569                         var _a, _b;
37570                         return !!(ts.isExportDeclaration(decl) && decl.moduleSpecifier &&
37571                             ((_b = (_a = resolveExternalModuleName(decl, decl.moduleSpecifier)) === null || _a === void 0 ? void 0 : _a.exports) === null || _b === void 0 ? void 0 : _b.has("default")));
37572                     });
37573                     if (defaultExport) {
37574                         ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(defaultExport, ts.Diagnostics.export_Asterisk_does_not_re_export_a_default));
37575                     }
37576                 }
37577             }
37578         }
37579         function getTargetOfNamespaceImport(node, dontResolveAlias) {
37580             var moduleSpecifier = node.parent.parent.moduleSpecifier;
37581             var immediate = resolveExternalModuleName(node, moduleSpecifier);
37582             var resolved = resolveESModuleSymbol(immediate, moduleSpecifier, dontResolveAlias, false);
37583             markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved, false);
37584             return resolved;
37585         }
37586         function getTargetOfNamespaceExport(node, dontResolveAlias) {
37587             var moduleSpecifier = node.parent.moduleSpecifier;
37588             var immediate = moduleSpecifier && resolveExternalModuleName(node, moduleSpecifier);
37589             var resolved = moduleSpecifier && resolveESModuleSymbol(immediate, moduleSpecifier, dontResolveAlias, false);
37590             markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved, false);
37591             return resolved;
37592         }
37593         function combineValueAndTypeSymbols(valueSymbol, typeSymbol) {
37594             if (valueSymbol === unknownSymbol && typeSymbol === unknownSymbol) {
37595                 return unknownSymbol;
37596             }
37597             if (valueSymbol.flags & (788968 | 1920)) {
37598                 return valueSymbol;
37599             }
37600             var result = createSymbol(valueSymbol.flags | typeSymbol.flags, valueSymbol.escapedName);
37601             result.declarations = ts.deduplicate(ts.concatenate(valueSymbol.declarations, typeSymbol.declarations), ts.equateValues);
37602             result.parent = valueSymbol.parent || typeSymbol.parent;
37603             if (valueSymbol.valueDeclaration)
37604                 result.valueDeclaration = valueSymbol.valueDeclaration;
37605             if (typeSymbol.members)
37606                 result.members = new ts.Map(typeSymbol.members);
37607             if (valueSymbol.exports)
37608                 result.exports = new ts.Map(valueSymbol.exports);
37609             return result;
37610         }
37611         function getExportOfModule(symbol, name, specifier, dontResolveAlias) {
37612             if (symbol.flags & 1536) {
37613                 var exportSymbol = getExportsOfSymbol(symbol).get(name.escapedText);
37614                 var resolved = resolveSymbol(exportSymbol, dontResolveAlias);
37615                 markSymbolOfAliasDeclarationIfTypeOnly(specifier, exportSymbol, resolved, false);
37616                 return resolved;
37617             }
37618         }
37619         function getPropertyOfVariable(symbol, name) {
37620             if (symbol.flags & 3) {
37621                 var typeAnnotation = symbol.valueDeclaration.type;
37622                 if (typeAnnotation) {
37623                     return resolveSymbol(getPropertyOfType(getTypeFromTypeNode(typeAnnotation), name));
37624                 }
37625             }
37626         }
37627         function getExternalModuleMember(node, specifier, dontResolveAlias) {
37628             var _a;
37629             if (dontResolveAlias === void 0) { dontResolveAlias = false; }
37630             var moduleSpecifier = ts.getExternalModuleRequireArgument(node) || node.moduleSpecifier;
37631             var moduleSymbol = resolveExternalModuleName(node, moduleSpecifier);
37632             var name = !ts.isPropertyAccessExpression(specifier) && specifier.propertyName || specifier.name;
37633             if (!ts.isIdentifier(name)) {
37634                 return undefined;
37635             }
37636             var suppressInteropError = name.escapedText === "default" && !!(compilerOptions.allowSyntheticDefaultImports || compilerOptions.esModuleInterop);
37637             var targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, dontResolveAlias, suppressInteropError);
37638             if (targetSymbol) {
37639                 if (name.escapedText) {
37640                     if (ts.isShorthandAmbientModuleSymbol(moduleSymbol)) {
37641                         return moduleSymbol;
37642                     }
37643                     var symbolFromVariable = void 0;
37644                     if (moduleSymbol && moduleSymbol.exports && moduleSymbol.exports.get("export=")) {
37645                         symbolFromVariable = getPropertyOfType(getTypeOfSymbol(targetSymbol), name.escapedText, true);
37646                     }
37647                     else {
37648                         symbolFromVariable = getPropertyOfVariable(targetSymbol, name.escapedText);
37649                     }
37650                     symbolFromVariable = resolveSymbol(symbolFromVariable, dontResolveAlias);
37651                     var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
37652                     if (symbolFromModule === undefined && name.escapedText === "default") {
37653                         var file = ts.find(moduleSymbol.declarations, ts.isSourceFile);
37654                         if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias)) {
37655                             symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
37656                         }
37657                     }
37658                     var symbol = symbolFromModule && symbolFromVariable && symbolFromModule !== symbolFromVariable ?
37659                         combineValueAndTypeSymbols(symbolFromVariable, symbolFromModule) :
37660                         symbolFromModule || symbolFromVariable;
37661                     if (!symbol) {
37662                         var moduleName = getFullyQualifiedName(moduleSymbol, node);
37663                         var declarationName = ts.declarationNameToString(name);
37664                         var suggestion = getSuggestedSymbolForNonexistentModule(name, targetSymbol);
37665                         if (suggestion !== undefined) {
37666                             var suggestionName = symbolToString(suggestion);
37667                             var diagnostic = error(name, ts.Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, moduleName, declarationName, suggestionName);
37668                             if (suggestion.valueDeclaration) {
37669                                 ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestionName));
37670                             }
37671                         }
37672                         else {
37673                             if ((_a = moduleSymbol.exports) === null || _a === void 0 ? void 0 : _a.has("default")) {
37674                                 error(name, ts.Diagnostics.Module_0_has_no_exported_member_1_Did_you_mean_to_use_import_1_from_0_instead, moduleName, declarationName);
37675                             }
37676                             else {
37677                                 reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName);
37678                             }
37679                         }
37680                     }
37681                     return symbol;
37682                 }
37683             }
37684         }
37685         function reportNonExportedMember(node, name, declarationName, moduleSymbol, moduleName) {
37686             var _a;
37687             var localSymbol = (_a = moduleSymbol.valueDeclaration.locals) === null || _a === void 0 ? void 0 : _a.get(name.escapedText);
37688             var exports = moduleSymbol.exports;
37689             if (localSymbol) {
37690                 var exportedEqualsSymbol = exports === null || exports === void 0 ? void 0 : exports.get("export=");
37691                 if (exportedEqualsSymbol) {
37692                     getSymbolIfSameReference(exportedEqualsSymbol, localSymbol) ? reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) :
37693                         error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName);
37694                 }
37695                 else {
37696                     var exportedSymbol = exports ? ts.find(symbolsToArray(exports), function (symbol) { return !!getSymbolIfSameReference(symbol, localSymbol); }) : undefined;
37697                     var diagnostic = exportedSymbol ? error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_exported_as_2, moduleName, declarationName, symbolToString(exportedSymbol)) :
37698                         error(name, ts.Diagnostics.Module_0_declares_1_locally_but_it_is_not_exported, moduleName, declarationName);
37699                     ts.addRelatedInfo.apply(void 0, __spreadArray([diagnostic], ts.map(localSymbol.declarations, function (decl, index) {
37700                         return ts.createDiagnosticForNode(decl, index === 0 ? ts.Diagnostics._0_is_declared_here : ts.Diagnostics.and_here, declarationName);
37701                     })));
37702                 }
37703             }
37704             else {
37705                 error(name, ts.Diagnostics.Module_0_has_no_exported_member_1, moduleName, declarationName);
37706             }
37707         }
37708         function reportInvalidImportEqualsExportMember(node, name, declarationName, moduleName) {
37709             if (moduleKind >= ts.ModuleKind.ES2015) {
37710                 var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_a_default_import :
37711                     ts.Diagnostics._0_can_only_be_imported_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
37712                 error(name, message, declarationName);
37713             }
37714             else {
37715                 if (ts.isInJSFile(node)) {
37716                     var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_using_a_default_import :
37717                         ts.Diagnostics._0_can_only_be_imported_by_using_a_require_call_or_by_turning_on_the_esModuleInterop_flag_and_using_a_default_import;
37718                     error(name, message, declarationName);
37719                 }
37720                 else {
37721                     var message = compilerOptions.esModuleInterop ? ts.Diagnostics._0_can_only_be_imported_by_using_import_1_require_2_or_a_default_import :
37722                         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;
37723                     error(name, message, declarationName, declarationName, moduleName);
37724                 }
37725             }
37726         }
37727         function getTargetOfImportSpecifier(node, dontResolveAlias) {
37728             var root = ts.isBindingElement(node) ? ts.getRootDeclaration(node) : node.parent.parent.parent;
37729             var commonJSPropertyAccess = getCommonJSPropertyAccess(root);
37730             var resolved = getExternalModuleMember(root, commonJSPropertyAccess || node, dontResolveAlias);
37731             var name = node.propertyName || node.name;
37732             if (commonJSPropertyAccess && resolved && ts.isIdentifier(name)) {
37733                 return resolveSymbol(getPropertyOfType(getTypeOfSymbol(resolved), name.escapedText), dontResolveAlias);
37734             }
37735             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
37736             return resolved;
37737         }
37738         function getCommonJSPropertyAccess(node) {
37739             if (ts.isVariableDeclaration(node) && node.initializer && ts.isPropertyAccessExpression(node.initializer)) {
37740                 return node.initializer;
37741             }
37742         }
37743         function getTargetOfNamespaceExportDeclaration(node, dontResolveAlias) {
37744             var resolved = resolveExternalModuleSymbol(node.parent.symbol, dontResolveAlias);
37745             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
37746             return resolved;
37747         }
37748         function getTargetOfExportSpecifier(node, meaning, dontResolveAlias) {
37749             var resolved = node.parent.parent.moduleSpecifier ?
37750                 getExternalModuleMember(node.parent.parent, node, dontResolveAlias) :
37751                 resolveEntityName(node.propertyName || node.name, meaning, false, dontResolveAlias);
37752             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
37753             return resolved;
37754         }
37755         function getTargetOfExportAssignment(node, dontResolveAlias) {
37756             var expression = ts.isExportAssignment(node) ? node.expression : node.right;
37757             var resolved = getTargetOfAliasLikeExpression(expression, dontResolveAlias);
37758             markSymbolOfAliasDeclarationIfTypeOnly(node, undefined, resolved, false);
37759             return resolved;
37760         }
37761         function getTargetOfAliasLikeExpression(expression, dontResolveAlias) {
37762             if (ts.isClassExpression(expression)) {
37763                 return checkExpressionCached(expression).symbol;
37764             }
37765             if (!ts.isEntityName(expression) && !ts.isEntityNameExpression(expression)) {
37766                 return undefined;
37767             }
37768             var aliasLike = resolveEntityName(expression, 111551 | 788968 | 1920, true, dontResolveAlias);
37769             if (aliasLike) {
37770                 return aliasLike;
37771             }
37772             checkExpressionCached(expression);
37773             return getNodeLinks(expression).resolvedSymbol;
37774         }
37775         function getTargetOfPropertyAssignment(node, dontRecursivelyResolve) {
37776             var expression = node.initializer;
37777             return getTargetOfAliasLikeExpression(expression, dontRecursivelyResolve);
37778         }
37779         function getTargetOfAccessExpression(node, dontRecursivelyResolve) {
37780             if (!(ts.isBinaryExpression(node.parent) && node.parent.left === node && node.parent.operatorToken.kind === 62)) {
37781                 return undefined;
37782             }
37783             return getTargetOfAliasLikeExpression(node.parent.right, dontRecursivelyResolve);
37784         }
37785         function getTargetOfAliasDeclaration(node, dontRecursivelyResolve) {
37786             if (dontRecursivelyResolve === void 0) { dontRecursivelyResolve = false; }
37787             switch (node.kind) {
37788                 case 260:
37789                 case 249:
37790                     return getTargetOfImportEqualsDeclaration(node, dontRecursivelyResolve);
37791                 case 262:
37792                     return getTargetOfImportClause(node, dontRecursivelyResolve);
37793                 case 263:
37794                     return getTargetOfNamespaceImport(node, dontRecursivelyResolve);
37795                 case 269:
37796                     return getTargetOfNamespaceExport(node, dontRecursivelyResolve);
37797                 case 265:
37798                 case 198:
37799                     return getTargetOfImportSpecifier(node, dontRecursivelyResolve);
37800                 case 270:
37801                     return getTargetOfExportSpecifier(node, 111551 | 788968 | 1920, dontRecursivelyResolve);
37802                 case 266:
37803                 case 216:
37804                     return getTargetOfExportAssignment(node, dontRecursivelyResolve);
37805                 case 259:
37806                     return getTargetOfNamespaceExportDeclaration(node, dontRecursivelyResolve);
37807                 case 289:
37808                     return resolveEntityName(node.name, 111551 | 788968 | 1920, true, dontRecursivelyResolve);
37809                 case 288:
37810                     return getTargetOfPropertyAssignment(node, dontRecursivelyResolve);
37811                 case 202:
37812                 case 201:
37813                     return getTargetOfAccessExpression(node, dontRecursivelyResolve);
37814                 default:
37815                     return ts.Debug.fail();
37816             }
37817         }
37818         function isNonLocalAlias(symbol, excludes) {
37819             if (excludes === void 0) { excludes = 111551 | 788968 | 1920; }
37820             if (!symbol)
37821                 return false;
37822             return (symbol.flags & (2097152 | excludes)) === 2097152 || !!(symbol.flags & 2097152 && symbol.flags & 67108864);
37823         }
37824         function resolveSymbol(symbol, dontResolveAlias) {
37825             return !dontResolveAlias && isNonLocalAlias(symbol) ? resolveAlias(symbol) : symbol;
37826         }
37827         function resolveAlias(symbol) {
37828             ts.Debug.assert((symbol.flags & 2097152) !== 0, "Should only get Alias here.");
37829             var links = getSymbolLinks(symbol);
37830             if (!links.target) {
37831                 links.target = resolvingSymbol;
37832                 var node = getDeclarationOfAliasSymbol(symbol);
37833                 if (!node)
37834                     return ts.Debug.fail();
37835                 var target = getTargetOfAliasDeclaration(node);
37836                 if (links.target === resolvingSymbol) {
37837                     links.target = target || unknownSymbol;
37838                 }
37839                 else {
37840                     error(node, ts.Diagnostics.Circular_definition_of_import_alias_0, symbolToString(symbol));
37841                 }
37842             }
37843             else if (links.target === resolvingSymbol) {
37844                 links.target = unknownSymbol;
37845             }
37846             return links.target;
37847         }
37848         function tryResolveAlias(symbol) {
37849             var links = getSymbolLinks(symbol);
37850             if (links.target !== resolvingSymbol) {
37851                 return resolveAlias(symbol);
37852             }
37853             return undefined;
37854         }
37855         function markSymbolOfAliasDeclarationIfTypeOnly(aliasDeclaration, immediateTarget, finalTarget, overwriteEmpty) {
37856             if (!aliasDeclaration || ts.isPropertyAccessExpression(aliasDeclaration))
37857                 return false;
37858             var sourceSymbol = getSymbolOfNode(aliasDeclaration);
37859             if (ts.isTypeOnlyImportOrExportDeclaration(aliasDeclaration)) {
37860                 var links_1 = getSymbolLinks(sourceSymbol);
37861                 links_1.typeOnlyDeclaration = aliasDeclaration;
37862                 return true;
37863             }
37864             var links = getSymbolLinks(sourceSymbol);
37865             return markSymbolOfAliasDeclarationIfTypeOnlyWorker(links, immediateTarget, overwriteEmpty)
37866                 || markSymbolOfAliasDeclarationIfTypeOnlyWorker(links, finalTarget, overwriteEmpty);
37867         }
37868         function markSymbolOfAliasDeclarationIfTypeOnlyWorker(aliasDeclarationLinks, target, overwriteEmpty) {
37869             var _a, _b, _c;
37870             if (target && (aliasDeclarationLinks.typeOnlyDeclaration === undefined || overwriteEmpty && aliasDeclarationLinks.typeOnlyDeclaration === false)) {
37871                 var exportSymbol = (_b = (_a = target.exports) === null || _a === void 0 ? void 0 : _a.get("export=")) !== null && _b !== void 0 ? _b : target;
37872                 var typeOnly = exportSymbol.declarations && ts.find(exportSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
37873                 aliasDeclarationLinks.typeOnlyDeclaration = (_c = typeOnly !== null && typeOnly !== void 0 ? typeOnly : getSymbolLinks(exportSymbol).typeOnlyDeclaration) !== null && _c !== void 0 ? _c : false;
37874             }
37875             return !!aliasDeclarationLinks.typeOnlyDeclaration;
37876         }
37877         function getTypeOnlyAliasDeclaration(symbol) {
37878             if (!(symbol.flags & 2097152)) {
37879                 return undefined;
37880             }
37881             var links = getSymbolLinks(symbol);
37882             return links.typeOnlyDeclaration || undefined;
37883         }
37884         function markExportAsReferenced(node) {
37885             var symbol = getSymbolOfNode(node);
37886             var target = resolveAlias(symbol);
37887             if (target) {
37888                 var markAlias = target === unknownSymbol ||
37889                     ((target.flags & 111551) && !isConstEnumOrConstEnumOnlyModule(target) && !getTypeOnlyAliasDeclaration(symbol));
37890                 if (markAlias) {
37891                     markAliasSymbolAsReferenced(symbol);
37892                 }
37893             }
37894         }
37895         function markAliasSymbolAsReferenced(symbol) {
37896             var links = getSymbolLinks(symbol);
37897             if (!links.referenced) {
37898                 links.referenced = true;
37899                 var node = getDeclarationOfAliasSymbol(symbol);
37900                 if (!node)
37901                     return ts.Debug.fail();
37902                 if (ts.isInternalModuleImportEqualsDeclaration(node)) {
37903                     var target = resolveSymbol(symbol);
37904                     if (target === unknownSymbol || target.flags & 111551) {
37905                         checkExpressionCached(node.moduleReference);
37906                     }
37907                 }
37908             }
37909         }
37910         function markConstEnumAliasAsReferenced(symbol) {
37911             var links = getSymbolLinks(symbol);
37912             if (!links.constEnumReferenced) {
37913                 links.constEnumReferenced = true;
37914             }
37915         }
37916         function getSymbolOfPartOfRightHandSideOfImportEquals(entityName, dontResolveAlias) {
37917             if (entityName.kind === 78 && ts.isRightSideOfQualifiedNameOrPropertyAccess(entityName)) {
37918                 entityName = entityName.parent;
37919             }
37920             if (entityName.kind === 78 || entityName.parent.kind === 157) {
37921                 return resolveEntityName(entityName, 1920, false, dontResolveAlias);
37922             }
37923             else {
37924                 ts.Debug.assert(entityName.parent.kind === 260);
37925                 return resolveEntityName(entityName, 111551 | 788968 | 1920, false, dontResolveAlias);
37926             }
37927         }
37928         function getFullyQualifiedName(symbol, containingLocation) {
37929             return symbol.parent ? getFullyQualifiedName(symbol.parent, containingLocation) + "." + symbolToString(symbol) : symbolToString(symbol, containingLocation, undefined, 16 | 4);
37930         }
37931         function resolveEntityName(name, meaning, ignoreErrors, dontResolveAlias, location) {
37932             if (ts.nodeIsMissing(name)) {
37933                 return undefined;
37934             }
37935             var namespaceMeaning = 1920 | (ts.isInJSFile(name) ? meaning & 111551 : 0);
37936             var symbol;
37937             if (name.kind === 78) {
37938                 var message = meaning === namespaceMeaning || ts.nodeIsSynthesized(name) ? ts.Diagnostics.Cannot_find_namespace_0 : getCannotFindNameDiagnosticForName(ts.getFirstIdentifier(name));
37939                 var symbolFromJSPrototype = ts.isInJSFile(name) && !ts.nodeIsSynthesized(name) ? resolveEntityNameFromAssignmentDeclaration(name, meaning) : undefined;
37940                 symbol = getMergedSymbol(resolveName(location || name, name.escapedText, meaning, ignoreErrors || symbolFromJSPrototype ? undefined : message, name, true));
37941                 if (!symbol) {
37942                     return getMergedSymbol(symbolFromJSPrototype);
37943                 }
37944             }
37945             else if (name.kind === 157 || name.kind === 201) {
37946                 var left = name.kind === 157 ? name.left : name.expression;
37947                 var right = name.kind === 157 ? name.right : name.name;
37948                 var namespace = resolveEntityName(left, namespaceMeaning, ignoreErrors, false, location);
37949                 if (!namespace || ts.nodeIsMissing(right)) {
37950                     return undefined;
37951                 }
37952                 else if (namespace === unknownSymbol) {
37953                     return namespace;
37954                 }
37955                 if (ts.isInJSFile(name)) {
37956                     if (namespace.valueDeclaration &&
37957                         ts.isVariableDeclaration(namespace.valueDeclaration) &&
37958                         namespace.valueDeclaration.initializer &&
37959                         isCommonJsRequire(namespace.valueDeclaration.initializer)) {
37960                         var moduleName = namespace.valueDeclaration.initializer.arguments[0];
37961                         var moduleSym = resolveExternalModuleName(moduleName, moduleName);
37962                         if (moduleSym) {
37963                             var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym);
37964                             if (resolvedModuleSymbol) {
37965                                 namespace = resolvedModuleSymbol;
37966                             }
37967                         }
37968                     }
37969                 }
37970                 symbol = getMergedSymbol(getSymbol(getExportsOfSymbol(namespace), right.escapedText, meaning));
37971                 if (!symbol) {
37972                     if (!ignoreErrors) {
37973                         var namespaceName = getFullyQualifiedName(namespace);
37974                         var declarationName = ts.declarationNameToString(right);
37975                         var suggestion = getSuggestedSymbolForNonexistentModule(right, namespace);
37976                         suggestion ?
37977                             error(right, ts.Diagnostics._0_has_no_exported_member_named_1_Did_you_mean_2, namespaceName, declarationName, symbolToString(suggestion)) :
37978                             error(right, ts.Diagnostics.Namespace_0_has_no_exported_member_1, namespaceName, declarationName);
37979                     }
37980                     return undefined;
37981                 }
37982             }
37983             else {
37984                 throw ts.Debug.assertNever(name, "Unknown entity name kind.");
37985             }
37986             ts.Debug.assert((ts.getCheckFlags(symbol) & 1) === 0, "Should never get an instantiated symbol here.");
37987             if (!ts.nodeIsSynthesized(name) && ts.isEntityName(name) && (symbol.flags & 2097152 || name.parent.kind === 266)) {
37988                 markSymbolOfAliasDeclarationIfTypeOnly(ts.getAliasDeclarationFromName(name), symbol, undefined, true);
37989             }
37990             return (symbol.flags & meaning) || dontResolveAlias ? symbol : resolveAlias(symbol);
37991         }
37992         function resolveEntityNameFromAssignmentDeclaration(name, meaning) {
37993             if (isJSDocTypeReference(name.parent)) {
37994                 var secondaryLocation = getAssignmentDeclarationLocation(name.parent);
37995                 if (secondaryLocation) {
37996                     return resolveName(secondaryLocation, name.escapedText, meaning, undefined, name, true);
37997                 }
37998             }
37999         }
38000         function getAssignmentDeclarationLocation(node) {
38001             var typeAlias = ts.findAncestor(node, function (node) { return !(ts.isJSDocNode(node) || node.flags & 4194304) ? "quit" : ts.isJSDocTypeAlias(node); });
38002             if (typeAlias) {
38003                 return;
38004             }
38005             var host = ts.getJSDocHost(node);
38006             if (host &&
38007                 ts.isExpressionStatement(host) &&
38008                 ts.isBinaryExpression(host.expression) &&
38009                 ts.getAssignmentDeclarationKind(host.expression) === 3) {
38010                 var symbol = getSymbolOfNode(host.expression.left);
38011                 if (symbol) {
38012                     return getDeclarationOfJSPrototypeContainer(symbol);
38013                 }
38014             }
38015             if (host && (ts.isObjectLiteralMethod(host) || ts.isPropertyAssignment(host)) &&
38016                 ts.isBinaryExpression(host.parent.parent) &&
38017                 ts.getAssignmentDeclarationKind(host.parent.parent) === 6) {
38018                 var symbol = getSymbolOfNode(host.parent.parent.left);
38019                 if (symbol) {
38020                     return getDeclarationOfJSPrototypeContainer(symbol);
38021                 }
38022             }
38023             var sig = ts.getEffectiveJSDocHost(node);
38024             if (sig && ts.isFunctionLike(sig)) {
38025                 var symbol = getSymbolOfNode(sig);
38026                 return symbol && symbol.valueDeclaration;
38027             }
38028         }
38029         function getDeclarationOfJSPrototypeContainer(symbol) {
38030             var decl = symbol.parent.valueDeclaration;
38031             if (!decl) {
38032                 return undefined;
38033             }
38034             var initializer = ts.isAssignmentDeclaration(decl) ? ts.getAssignedExpandoInitializer(decl) :
38035                 ts.hasOnlyExpressionInitializer(decl) ? ts.getDeclaredExpandoInitializer(decl) :
38036                     undefined;
38037             return initializer || decl;
38038         }
38039         function getExpandoSymbol(symbol) {
38040             var decl = symbol.valueDeclaration;
38041             if (!decl || !ts.isInJSFile(decl) || symbol.flags & 524288 || ts.getExpandoInitializer(decl, false)) {
38042                 return undefined;
38043             }
38044             var init = ts.isVariableDeclaration(decl) ? ts.getDeclaredExpandoInitializer(decl) : ts.getAssignedExpandoInitializer(decl);
38045             if (init) {
38046                 var initSymbol = getSymbolOfNode(init);
38047                 if (initSymbol) {
38048                     return mergeJSSymbols(initSymbol, symbol);
38049                 }
38050             }
38051         }
38052         function resolveExternalModuleName(location, moduleReferenceExpression, ignoreErrors) {
38053             var isClassic = ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Classic;
38054             var errorMessage = isClassic ?
38055                 ts.Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_node_or_to_add_aliases_to_the_paths_option
38056                 : ts.Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations;
38057             return resolveExternalModuleNameWorker(location, moduleReferenceExpression, ignoreErrors ? undefined : errorMessage);
38058         }
38059         function resolveExternalModuleNameWorker(location, moduleReferenceExpression, moduleNotFoundError, isForAugmentation) {
38060             if (isForAugmentation === void 0) { isForAugmentation = false; }
38061             return ts.isStringLiteralLike(moduleReferenceExpression)
38062                 ? resolveExternalModule(location, moduleReferenceExpression.text, moduleNotFoundError, moduleReferenceExpression, isForAugmentation)
38063                 : undefined;
38064         }
38065         function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
38066             if (isForAugmentation === void 0) { isForAugmentation = false; }
38067             if (ts.startsWith(moduleReference, "@types/")) {
38068                 var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
38069                 var withoutAtTypePrefix = ts.removePrefix(moduleReference, "@types/");
38070                 error(errorNode, diag, withoutAtTypePrefix, moduleReference);
38071             }
38072             var ambientModule = tryFindAmbientModule(moduleReference, true);
38073             if (ambientModule) {
38074                 return ambientModule;
38075             }
38076             var currentSourceFile = ts.getSourceFileOfNode(location);
38077             var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference);
38078             var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
38079             var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
38080             if (sourceFile) {
38081                 if (sourceFile.symbol) {
38082                     if (resolvedModule.isExternalLibraryImport && !ts.resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
38083                         errorOnImplicitAnyModule(false, errorNode, resolvedModule, moduleReference);
38084                     }
38085                     return getMergedSymbol(sourceFile.symbol);
38086                 }
38087                 if (moduleNotFoundError) {
38088                     error(errorNode, ts.Diagnostics.File_0_is_not_a_module, sourceFile.fileName);
38089                 }
38090                 return undefined;
38091             }
38092             if (patternAmbientModules) {
38093                 var pattern = ts.findBestPatternMatch(patternAmbientModules, function (_) { return _.pattern; }, moduleReference);
38094                 if (pattern) {
38095                     var augmentation = patternAmbientModuleAugmentations && patternAmbientModuleAugmentations.get(moduleReference);
38096                     if (augmentation) {
38097                         return getMergedSymbol(augmentation);
38098                     }
38099                     return getMergedSymbol(pattern.symbol);
38100                 }
38101             }
38102             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) {
38103                 if (isForAugmentation) {
38104                     var diag = ts.Diagnostics.Invalid_module_name_in_augmentation_Module_0_resolves_to_an_untyped_module_at_1_which_cannot_be_augmented;
38105                     error(errorNode, diag, moduleReference, resolvedModule.resolvedFileName);
38106                 }
38107                 else {
38108                     errorOnImplicitAnyModule(noImplicitAny && !!moduleNotFoundError, errorNode, resolvedModule, moduleReference);
38109                 }
38110                 return undefined;
38111             }
38112             if (moduleNotFoundError) {
38113                 if (resolvedModule) {
38114                     var redirect = host.getProjectReferenceRedirect(resolvedModule.resolvedFileName);
38115                     if (redirect) {
38116                         error(errorNode, ts.Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, redirect, resolvedModule.resolvedFileName);
38117                         return undefined;
38118                     }
38119                 }
38120                 if (resolutionDiagnostic) {
38121                     error(errorNode, resolutionDiagnostic, moduleReference, resolvedModule.resolvedFileName);
38122                 }
38123                 else {
38124                     var tsExtension = ts.tryExtractTSExtension(moduleReference);
38125                     if (tsExtension) {
38126                         var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead;
38127                         var importSourceWithoutExtension = ts.removeExtension(moduleReference, tsExtension);
38128                         var replacedImportSource = importSourceWithoutExtension;
38129                         var moduleKind_1 = ts.getEmitModuleKind(compilerOptions);
38130                         if (moduleKind_1 >= ts.ModuleKind.ES2015) {
38131                             replacedImportSource += ".js";
38132                         }
38133                         error(errorNode, diag, tsExtension, replacedImportSource);
38134                     }
38135                     else if (!compilerOptions.resolveJsonModule &&
38136                         ts.fileExtensionIs(moduleReference, ".json") &&
38137                         ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs &&
38138                         ts.hasJsonModuleEmitEnabled(compilerOptions)) {
38139                         error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
38140                     }
38141                     else {
38142                         error(errorNode, moduleNotFoundError, moduleReference);
38143                     }
38144                 }
38145             }
38146             return undefined;
38147         }
38148         function errorOnImplicitAnyModule(isError, errorNode, _a, moduleReference) {
38149             var packageId = _a.packageId, resolvedFileName = _a.resolvedFileName;
38150             var errorInfo = !ts.isExternalModuleNameRelative(moduleReference) && packageId
38151                 ? typesPackageExists(packageId.name)
38152                     ? 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))
38153                     : 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))
38154                 : undefined;
38155             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));
38156         }
38157         function typesPackageExists(packageName) {
38158             return getPackagesSet().has(ts.getTypesPackageName(packageName));
38159         }
38160         function resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) {
38161             if (moduleSymbol === null || moduleSymbol === void 0 ? void 0 : moduleSymbol.exports) {
38162                 var exportEquals = resolveSymbol(moduleSymbol.exports.get("export="), dontResolveAlias);
38163                 var exported = getCommonJsExportEquals(getMergedSymbol(exportEquals), getMergedSymbol(moduleSymbol));
38164                 return getMergedSymbol(exported) || moduleSymbol;
38165             }
38166             return undefined;
38167         }
38168         function getCommonJsExportEquals(exported, moduleSymbol) {
38169             if (!exported || exported === unknownSymbol || exported === moduleSymbol || moduleSymbol.exports.size === 1 || exported.flags & 2097152) {
38170                 return exported;
38171             }
38172             var links = getSymbolLinks(exported);
38173             if (links.cjsExportMerged) {
38174                 return links.cjsExportMerged;
38175             }
38176             var merged = exported.flags & 33554432 ? exported : cloneSymbol(exported);
38177             merged.flags = merged.flags | 512;
38178             if (merged.exports === undefined) {
38179                 merged.exports = ts.createSymbolTable();
38180             }
38181             moduleSymbol.exports.forEach(function (s, name) {
38182                 if (name === "export=")
38183                     return;
38184                 merged.exports.set(name, merged.exports.has(name) ? mergeSymbol(merged.exports.get(name), s) : s);
38185             });
38186             getSymbolLinks(merged).cjsExportMerged = merged;
38187             return links.cjsExportMerged = merged;
38188         }
38189         function resolveESModuleSymbol(moduleSymbol, referencingLocation, dontResolveAlias, suppressInteropError) {
38190             var symbol = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias);
38191             if (!dontResolveAlias && symbol) {
38192                 if (!suppressInteropError && !(symbol.flags & (1536 | 3)) && !ts.getDeclarationOfKind(symbol, 297)) {
38193                     var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015
38194                         ? "allowSyntheticDefaultImports"
38195                         : "esModuleInterop";
38196                     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);
38197                     return symbol;
38198                 }
38199                 if (compilerOptions.esModuleInterop) {
38200                     var referenceParent = referencingLocation.parent;
38201                     if ((ts.isImportDeclaration(referenceParent) && ts.getNamespaceDeclarationNode(referenceParent)) ||
38202                         ts.isImportCall(referenceParent)) {
38203                         var type = getTypeOfSymbol(symbol);
38204                         var sigs = getSignaturesOfStructuredType(type, 0);
38205                         if (!sigs || !sigs.length) {
38206                             sigs = getSignaturesOfStructuredType(type, 1);
38207                         }
38208                         if (sigs && sigs.length) {
38209                             var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol);
38210                             var result = createSymbol(symbol.flags, symbol.escapedName);
38211                             result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
38212                             result.parent = symbol.parent;
38213                             result.target = symbol;
38214                             result.originatingImport = referenceParent;
38215                             if (symbol.valueDeclaration)
38216                                 result.valueDeclaration = symbol.valueDeclaration;
38217                             if (symbol.constEnumOnlyModule)
38218                                 result.constEnumOnlyModule = true;
38219                             if (symbol.members)
38220                                 result.members = new ts.Map(symbol.members);
38221                             if (symbol.exports)
38222                                 result.exports = new ts.Map(symbol.exports);
38223                             var resolvedModuleType = resolveStructuredTypeMembers(moduleType);
38224                             result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.stringIndexInfo, resolvedModuleType.numberIndexInfo);
38225                             return result;
38226                         }
38227                     }
38228                 }
38229             }
38230             return symbol;
38231         }
38232         function hasExportAssignmentSymbol(moduleSymbol) {
38233             return moduleSymbol.exports.get("export=") !== undefined;
38234         }
38235         function getExportsOfModuleAsArray(moduleSymbol) {
38236             return symbolsToArray(getExportsOfModule(moduleSymbol));
38237         }
38238         function getExportsAndPropertiesOfModule(moduleSymbol) {
38239             var exports = getExportsOfModuleAsArray(moduleSymbol);
38240             var exportEquals = resolveExternalModuleSymbol(moduleSymbol);
38241             if (exportEquals !== moduleSymbol) {
38242                 ts.addRange(exports, getPropertiesOfType(getTypeOfSymbol(exportEquals)));
38243             }
38244             return exports;
38245         }
38246         function tryGetMemberInModuleExports(memberName, moduleSymbol) {
38247             var symbolTable = getExportsOfModule(moduleSymbol);
38248             if (symbolTable) {
38249                 return symbolTable.get(memberName);
38250             }
38251         }
38252         function tryGetMemberInModuleExportsAndProperties(memberName, moduleSymbol) {
38253             var symbol = tryGetMemberInModuleExports(memberName, moduleSymbol);
38254             if (symbol) {
38255                 return symbol;
38256             }
38257             var exportEquals = resolveExternalModuleSymbol(moduleSymbol);
38258             if (exportEquals === moduleSymbol) {
38259                 return undefined;
38260             }
38261             var type = getTypeOfSymbol(exportEquals);
38262             return type.flags & 131068 ||
38263                 ts.getObjectFlags(type) & 1 ||
38264                 isArrayOrTupleLikeType(type)
38265                 ? undefined
38266                 : getPropertyOfType(type, memberName);
38267         }
38268         function getExportsOfSymbol(symbol) {
38269             return symbol.flags & 6256 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedExports") :
38270                 symbol.flags & 1536 ? getExportsOfModule(symbol) :
38271                     symbol.exports || emptySymbols;
38272         }
38273         function getExportsOfModule(moduleSymbol) {
38274             var links = getSymbolLinks(moduleSymbol);
38275             return links.resolvedExports || (links.resolvedExports = getExportsOfModuleWorker(moduleSymbol));
38276         }
38277         function extendExportSymbols(target, source, lookupTable, exportNode) {
38278             if (!source)
38279                 return;
38280             source.forEach(function (sourceSymbol, id) {
38281                 if (id === "default")
38282                     return;
38283                 var targetSymbol = target.get(id);
38284                 if (!targetSymbol) {
38285                     target.set(id, sourceSymbol);
38286                     if (lookupTable && exportNode) {
38287                         lookupTable.set(id, {
38288                             specifierText: ts.getTextOfNode(exportNode.moduleSpecifier)
38289                         });
38290                     }
38291                 }
38292                 else if (lookupTable && exportNode && targetSymbol && resolveSymbol(targetSymbol) !== resolveSymbol(sourceSymbol)) {
38293                     var collisionTracker = lookupTable.get(id);
38294                     if (!collisionTracker.exportsWithDuplicate) {
38295                         collisionTracker.exportsWithDuplicate = [exportNode];
38296                     }
38297                     else {
38298                         collisionTracker.exportsWithDuplicate.push(exportNode);
38299                     }
38300                 }
38301             });
38302         }
38303         function getExportsOfModuleWorker(moduleSymbol) {
38304             var visitedSymbols = [];
38305             moduleSymbol = resolveExternalModuleSymbol(moduleSymbol);
38306             return visit(moduleSymbol) || emptySymbols;
38307             function visit(symbol) {
38308                 if (!(symbol && symbol.exports && ts.pushIfUnique(visitedSymbols, symbol))) {
38309                     return;
38310                 }
38311                 var symbols = new ts.Map(symbol.exports);
38312                 var exportStars = symbol.exports.get("__export");
38313                 if (exportStars) {
38314                     var nestedSymbols = ts.createSymbolTable();
38315                     var lookupTable_1 = new ts.Map();
38316                     for (var _i = 0, _a = exportStars.declarations; _i < _a.length; _i++) {
38317                         var node = _a[_i];
38318                         var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
38319                         var exportedSymbols = visit(resolvedModule);
38320                         extendExportSymbols(nestedSymbols, exportedSymbols, lookupTable_1, node);
38321                     }
38322                     lookupTable_1.forEach(function (_a, id) {
38323                         var exportsWithDuplicate = _a.exportsWithDuplicate;
38324                         if (id === "export=" || !(exportsWithDuplicate && exportsWithDuplicate.length) || symbols.has(id)) {
38325                             return;
38326                         }
38327                         for (var _i = 0, exportsWithDuplicate_1 = exportsWithDuplicate; _i < exportsWithDuplicate_1.length; _i++) {
38328                             var node = exportsWithDuplicate_1[_i];
38329                             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)));
38330                         }
38331                     });
38332                     extendExportSymbols(symbols, nestedSymbols);
38333                 }
38334                 return symbols;
38335             }
38336         }
38337         function getMergedSymbol(symbol) {
38338             var merged;
38339             return symbol && symbol.mergeId && (merged = mergedSymbols[symbol.mergeId]) ? merged : symbol;
38340         }
38341         function getSymbolOfNode(node) {
38342             return getMergedSymbol(node.symbol && getLateBoundSymbol(node.symbol));
38343         }
38344         function getParentOfSymbol(symbol) {
38345             return getMergedSymbol(symbol.parent && getLateBoundSymbol(symbol.parent));
38346         }
38347         function getAlternativeContainingModules(symbol, enclosingDeclaration) {
38348             var containingFile = ts.getSourceFileOfNode(enclosingDeclaration);
38349             var id = getNodeId(containingFile);
38350             var links = getSymbolLinks(symbol);
38351             var results;
38352             if (links.extendedContainersByFile && (results = links.extendedContainersByFile.get(id))) {
38353                 return results;
38354             }
38355             if (containingFile && containingFile.imports) {
38356                 for (var _i = 0, _a = containingFile.imports; _i < _a.length; _i++) {
38357                     var importRef = _a[_i];
38358                     if (ts.nodeIsSynthesized(importRef))
38359                         continue;
38360                     var resolvedModule = resolveExternalModuleName(enclosingDeclaration, importRef, true);
38361                     if (!resolvedModule)
38362                         continue;
38363                     var ref = getAliasForSymbolInContainer(resolvedModule, symbol);
38364                     if (!ref)
38365                         continue;
38366                     results = ts.append(results, resolvedModule);
38367                 }
38368                 if (ts.length(results)) {
38369                     (links.extendedContainersByFile || (links.extendedContainersByFile = new ts.Map())).set(id, results);
38370                     return results;
38371                 }
38372             }
38373             if (links.extendedContainers) {
38374                 return links.extendedContainers;
38375             }
38376             var otherFiles = host.getSourceFiles();
38377             for (var _b = 0, otherFiles_1 = otherFiles; _b < otherFiles_1.length; _b++) {
38378                 var file = otherFiles_1[_b];
38379                 if (!ts.isExternalModule(file))
38380                     continue;
38381                 var sym = getSymbolOfNode(file);
38382                 var ref = getAliasForSymbolInContainer(sym, symbol);
38383                 if (!ref)
38384                     continue;
38385                 results = ts.append(results, sym);
38386             }
38387             return links.extendedContainers = results || ts.emptyArray;
38388         }
38389         function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) {
38390             var container = getParentOfSymbol(symbol);
38391             if (container && !(symbol.flags & 262144)) {
38392                 var additionalContainers = ts.mapDefined(container.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
38393                 var reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
38394                 var objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning);
38395                 if (enclosingDeclaration && getAccessibleSymbolChain(container, enclosingDeclaration, 1920, false)) {
38396                     return ts.append(ts.concatenate(ts.concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer);
38397                 }
38398                 var res = ts.append(ts.append(additionalContainers, container), objectLiteralContainer);
38399                 return ts.concatenate(res, reexportContainers);
38400             }
38401             var candidates = ts.mapDefined(symbol.declarations, function (d) {
38402                 if (!ts.isAmbientModule(d) && d.parent && hasNonGlobalAugmentationExternalModuleSymbol(d.parent)) {
38403                     return getSymbolOfNode(d.parent);
38404                 }
38405                 if (ts.isClassExpression(d) && ts.isBinaryExpression(d.parent) && d.parent.operatorToken.kind === 62 && ts.isAccessExpression(d.parent.left) && ts.isEntityNameExpression(d.parent.left.expression)) {
38406                     if (ts.isModuleExportsAccessExpression(d.parent.left) || ts.isExportsIdentifier(d.parent.left.expression)) {
38407                         return getSymbolOfNode(ts.getSourceFileOfNode(d));
38408                     }
38409                     checkExpressionCached(d.parent.left.expression);
38410                     return getNodeLinks(d.parent.left.expression).resolvedSymbol;
38411                 }
38412             });
38413             if (!ts.length(candidates)) {
38414                 return undefined;
38415             }
38416             return ts.mapDefined(candidates, function (candidate) { return getAliasForSymbolInContainer(candidate, symbol) ? candidate : undefined; });
38417             function fileSymbolIfFileSymbolExportEqualsContainer(d) {
38418                 return container && getFileSymbolIfFileSymbolExportEqualsContainer(d, container);
38419             }
38420         }
38421         function getVariableDeclarationOfObjectLiteral(symbol, meaning) {
38422             var firstDecl = !!ts.length(symbol.declarations) && ts.first(symbol.declarations);
38423             if (meaning & 111551 && firstDecl && firstDecl.parent && ts.isVariableDeclaration(firstDecl.parent)) {
38424                 if (ts.isObjectLiteralExpression(firstDecl) && firstDecl === firstDecl.parent.initializer || ts.isTypeLiteralNode(firstDecl) && firstDecl === firstDecl.parent.type) {
38425                     return getSymbolOfNode(firstDecl.parent);
38426                 }
38427             }
38428         }
38429         function getFileSymbolIfFileSymbolExportEqualsContainer(d, container) {
38430             var fileSymbol = getExternalModuleContainer(d);
38431             var exported = fileSymbol && fileSymbol.exports && fileSymbol.exports.get("export=");
38432             return exported && getSymbolIfSameReference(exported, container) ? fileSymbol : undefined;
38433         }
38434         function getAliasForSymbolInContainer(container, symbol) {
38435             if (container === getParentOfSymbol(symbol)) {
38436                 return symbol;
38437             }
38438             var exportEquals = container.exports && container.exports.get("export=");
38439             if (exportEquals && getSymbolIfSameReference(exportEquals, symbol)) {
38440                 return container;
38441             }
38442             var exports = getExportsOfSymbol(container);
38443             var quick = exports.get(symbol.escapedName);
38444             if (quick && getSymbolIfSameReference(quick, symbol)) {
38445                 return quick;
38446             }
38447             return ts.forEachEntry(exports, function (exported) {
38448                 if (getSymbolIfSameReference(exported, symbol)) {
38449                     return exported;
38450                 }
38451             });
38452         }
38453         function getSymbolIfSameReference(s1, s2) {
38454             if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
38455                 return s1;
38456             }
38457         }
38458         function getExportSymbolOfValueSymbolIfExported(symbol) {
38459             return getMergedSymbol(symbol && (symbol.flags & 1048576) !== 0 ? symbol.exportSymbol : symbol);
38460         }
38461         function symbolIsValue(symbol) {
38462             return !!(symbol.flags & 111551 || symbol.flags & 2097152 && resolveAlias(symbol).flags & 111551 && !getTypeOnlyAliasDeclaration(symbol));
38463         }
38464         function findConstructorDeclaration(node) {
38465             var members = node.members;
38466             for (var _i = 0, members_3 = members; _i < members_3.length; _i++) {
38467                 var member = members_3[_i];
38468                 if (member.kind === 166 && ts.nodeIsPresent(member.body)) {
38469                     return member;
38470                 }
38471             }
38472         }
38473         function createType(flags) {
38474             var result = new Type(checker, flags);
38475             typeCount++;
38476             result.id = typeCount;
38477             typeCatalog.push(result);
38478             return result;
38479         }
38480         function createOriginType(flags) {
38481             return new Type(checker, flags);
38482         }
38483         function createIntrinsicType(kind, intrinsicName, objectFlags) {
38484             if (objectFlags === void 0) { objectFlags = 0; }
38485             var type = createType(kind);
38486             type.intrinsicName = intrinsicName;
38487             type.objectFlags = objectFlags;
38488             return type;
38489         }
38490         function createBooleanType(trueFalseTypes) {
38491             var type = getUnionType(trueFalseTypes);
38492             type.flags |= 16;
38493             type.intrinsicName = "boolean";
38494             return type;
38495         }
38496         function createObjectType(objectFlags, symbol) {
38497             var type = createType(524288);
38498             type.objectFlags = objectFlags;
38499             type.symbol = symbol;
38500             type.members = undefined;
38501             type.properties = undefined;
38502             type.callSignatures = undefined;
38503             type.constructSignatures = undefined;
38504             type.stringIndexInfo = undefined;
38505             type.numberIndexInfo = undefined;
38506             return type;
38507         }
38508         function createTypeofType() {
38509             return getUnionType(ts.arrayFrom(typeofEQFacts.keys(), getLiteralType));
38510         }
38511         function createTypeParameter(symbol) {
38512             var type = createType(262144);
38513             if (symbol)
38514                 type.symbol = symbol;
38515             return type;
38516         }
38517         function isReservedMemberName(name) {
38518             return name.charCodeAt(0) === 95 &&
38519                 name.charCodeAt(1) === 95 &&
38520                 name.charCodeAt(2) !== 95 &&
38521                 name.charCodeAt(2) !== 64 &&
38522                 name.charCodeAt(2) !== 35;
38523         }
38524         function getNamedMembers(members) {
38525             var result;
38526             members.forEach(function (symbol, id) {
38527                 if (!isReservedMemberName(id) && symbolIsValue(symbol)) {
38528                     (result || (result = [])).push(symbol);
38529                 }
38530             });
38531             return result || ts.emptyArray;
38532         }
38533         function setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) {
38534             var resolved = type;
38535             resolved.members = members;
38536             resolved.properties = ts.emptyArray;
38537             resolved.callSignatures = callSignatures;
38538             resolved.constructSignatures = constructSignatures;
38539             resolved.stringIndexInfo = stringIndexInfo;
38540             resolved.numberIndexInfo = numberIndexInfo;
38541             if (members !== emptySymbols)
38542                 resolved.properties = getNamedMembers(members);
38543             return resolved;
38544         }
38545         function createAnonymousType(symbol, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo) {
38546             return setStructuredTypeMembers(createObjectType(16, symbol), members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
38547         }
38548         function getResolvedTypeWithoutAbstractConstructSignatures(type) {
38549             if (type.constructSignatures.length === 0)
38550                 return type;
38551             if (type.objectTypeWithoutAbstractConstructSignatures)
38552                 return type.objectTypeWithoutAbstractConstructSignatures;
38553             var constructSignatures = ts.filter(type.constructSignatures, function (signature) { return !(signature.flags & 4); });
38554             if (type.constructSignatures === constructSignatures)
38555                 return type;
38556             var typeCopy = createAnonymousType(type.symbol, type.members, type.callSignatures, ts.some(constructSignatures) ? constructSignatures : ts.emptyArray, type.stringIndexInfo, type.numberIndexInfo);
38557             type.objectTypeWithoutAbstractConstructSignatures = typeCopy;
38558             typeCopy.objectTypeWithoutAbstractConstructSignatures = typeCopy;
38559             return typeCopy;
38560         }
38561         function forEachSymbolTableInScope(enclosingDeclaration, callback) {
38562             var result;
38563             var _loop_8 = function (location) {
38564                 if (location.locals && !isGlobalSourceFile(location)) {
38565                     if (result = callback(location.locals)) {
38566                         return { value: result };
38567                     }
38568                 }
38569                 switch (location.kind) {
38570                     case 297:
38571                         if (!ts.isExternalOrCommonJsModule(location)) {
38572                             break;
38573                         }
38574                     case 256:
38575                         var sym = getSymbolOfNode(location);
38576                         if (result = callback((sym === null || sym === void 0 ? void 0 : sym.exports) || emptySymbols)) {
38577                             return { value: result };
38578                         }
38579                         break;
38580                     case 252:
38581                     case 221:
38582                     case 253:
38583                         var table_1;
38584                         (getSymbolOfNode(location).members || emptySymbols).forEach(function (memberSymbol, key) {
38585                             if (memberSymbol.flags & (788968 & ~67108864)) {
38586                                 (table_1 || (table_1 = ts.createSymbolTable())).set(key, memberSymbol);
38587                             }
38588                         });
38589                         if (table_1 && (result = callback(table_1))) {
38590                             return { value: result };
38591                         }
38592                         break;
38593                 }
38594             };
38595             for (var location = enclosingDeclaration; location; location = location.parent) {
38596                 var state_2 = _loop_8(location);
38597                 if (typeof state_2 === "object")
38598                     return state_2.value;
38599             }
38600             return callback(globals);
38601         }
38602         function getQualifiedLeftMeaning(rightMeaning) {
38603             return rightMeaning === 111551 ? 111551 : 1920;
38604         }
38605         function getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, useOnlyExternalAliasing, visitedSymbolTablesMap) {
38606             if (visitedSymbolTablesMap === void 0) { visitedSymbolTablesMap = new ts.Map(); }
38607             if (!(symbol && !isPropertyOrMethodDeclarationSymbol(symbol))) {
38608                 return undefined;
38609             }
38610             var id = getSymbolId(symbol);
38611             var visitedSymbolTables = visitedSymbolTablesMap.get(id);
38612             if (!visitedSymbolTables) {
38613                 visitedSymbolTablesMap.set(id, visitedSymbolTables = []);
38614             }
38615             return forEachSymbolTableInScope(enclosingDeclaration, getAccessibleSymbolChainFromSymbolTable);
38616             function getAccessibleSymbolChainFromSymbolTable(symbols, ignoreQualification) {
38617                 if (!ts.pushIfUnique(visitedSymbolTables, symbols)) {
38618                     return undefined;
38619                 }
38620                 var result = trySymbolTable(symbols, ignoreQualification);
38621                 visitedSymbolTables.pop();
38622                 return result;
38623             }
38624             function canQualifySymbol(symbolFromSymbolTable, meaning) {
38625                 return !needsQualification(symbolFromSymbolTable, enclosingDeclaration, meaning) ||
38626                     !!getAccessibleSymbolChain(symbolFromSymbolTable.parent, enclosingDeclaration, getQualifiedLeftMeaning(meaning), useOnlyExternalAliasing, visitedSymbolTablesMap);
38627             }
38628             function isAccessible(symbolFromSymbolTable, resolvedAliasSymbol, ignoreQualification) {
38629                 return (symbol === (resolvedAliasSymbol || symbolFromSymbolTable) || getMergedSymbol(symbol) === getMergedSymbol(resolvedAliasSymbol || symbolFromSymbolTable)) &&
38630                     !ts.some(symbolFromSymbolTable.declarations, hasNonGlobalAugmentationExternalModuleSymbol) &&
38631                     (ignoreQualification || canQualifySymbol(getMergedSymbol(symbolFromSymbolTable), meaning));
38632             }
38633             function trySymbolTable(symbols, ignoreQualification) {
38634                 if (isAccessible(symbols.get(symbol.escapedName), undefined, ignoreQualification)) {
38635                     return [symbol];
38636                 }
38637                 var result = ts.forEachEntry(symbols, function (symbolFromSymbolTable) {
38638                     if (symbolFromSymbolTable.flags & 2097152
38639                         && symbolFromSymbolTable.escapedName !== "export="
38640                         && symbolFromSymbolTable.escapedName !== "default"
38641                         && !(ts.isUMDExportSymbol(symbolFromSymbolTable) && enclosingDeclaration && ts.isExternalModule(ts.getSourceFileOfNode(enclosingDeclaration)))
38642                         && (!useOnlyExternalAliasing || ts.some(symbolFromSymbolTable.declarations, ts.isExternalModuleImportEqualsDeclaration))
38643                         && (ignoreQualification || !ts.getDeclarationOfKind(symbolFromSymbolTable, 270))) {
38644                         var resolvedImportedSymbol = resolveAlias(symbolFromSymbolTable);
38645                         var candidate = getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification);
38646                         if (candidate) {
38647                             return candidate;
38648                         }
38649                     }
38650                     if (symbolFromSymbolTable.escapedName === symbol.escapedName && symbolFromSymbolTable.exportSymbol) {
38651                         if (isAccessible(getMergedSymbol(symbolFromSymbolTable.exportSymbol), undefined, ignoreQualification)) {
38652                             return [symbol];
38653                         }
38654                     }
38655                 });
38656                 return result || (symbols === globals ? getCandidateListForSymbol(globalThisSymbol, globalThisSymbol, ignoreQualification) : undefined);
38657             }
38658             function getCandidateListForSymbol(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification) {
38659                 if (isAccessible(symbolFromSymbolTable, resolvedImportedSymbol, ignoreQualification)) {
38660                     return [symbolFromSymbolTable];
38661                 }
38662                 var candidateTable = getExportsOfSymbol(resolvedImportedSymbol);
38663                 var accessibleSymbolsFromExports = candidateTable && getAccessibleSymbolChainFromSymbolTable(candidateTable, true);
38664                 if (accessibleSymbolsFromExports && canQualifySymbol(symbolFromSymbolTable, getQualifiedLeftMeaning(meaning))) {
38665                     return [symbolFromSymbolTable].concat(accessibleSymbolsFromExports);
38666                 }
38667             }
38668         }
38669         function needsQualification(symbol, enclosingDeclaration, meaning) {
38670             var qualify = false;
38671             forEachSymbolTableInScope(enclosingDeclaration, function (symbolTable) {
38672                 var symbolFromSymbolTable = getMergedSymbol(symbolTable.get(symbol.escapedName));
38673                 if (!symbolFromSymbolTable) {
38674                     return false;
38675                 }
38676                 if (symbolFromSymbolTable === symbol) {
38677                     return true;
38678                 }
38679                 symbolFromSymbolTable = (symbolFromSymbolTable.flags & 2097152 && !ts.getDeclarationOfKind(symbolFromSymbolTable, 270)) ? resolveAlias(symbolFromSymbolTable) : symbolFromSymbolTable;
38680                 if (symbolFromSymbolTable.flags & meaning) {
38681                     qualify = true;
38682                     return true;
38683                 }
38684                 return false;
38685             });
38686             return qualify;
38687         }
38688         function isPropertyOrMethodDeclarationSymbol(symbol) {
38689             if (symbol.declarations && symbol.declarations.length) {
38690                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
38691                     var declaration = _a[_i];
38692                     switch (declaration.kind) {
38693                         case 163:
38694                         case 165:
38695                         case 167:
38696                         case 168:
38697                             continue;
38698                         default:
38699                             return false;
38700                     }
38701                 }
38702                 return true;
38703             }
38704             return false;
38705         }
38706         function isTypeSymbolAccessible(typeSymbol, enclosingDeclaration) {
38707             var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 788968, false, true);
38708             return access.accessibility === 0;
38709         }
38710         function isValueSymbolAccessible(typeSymbol, enclosingDeclaration) {
38711             var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, 111551, false, true);
38712             return access.accessibility === 0;
38713         }
38714         function isSymbolAccessibleByFlags(typeSymbol, enclosingDeclaration, flags) {
38715             var access = isSymbolAccessibleWorker(typeSymbol, enclosingDeclaration, flags, false, false);
38716             return access.accessibility === 0;
38717         }
38718         function isAnySymbolAccessible(symbols, enclosingDeclaration, initialSymbol, meaning, shouldComputeAliasesToMakeVisible, allowModules) {
38719             if (!ts.length(symbols))
38720                 return;
38721             var hadAccessibleChain;
38722             var earlyModuleBail = false;
38723             for (var _i = 0, _a = symbols; _i < _a.length; _i++) {
38724                 var symbol = _a[_i];
38725                 var accessibleSymbolChain = getAccessibleSymbolChain(symbol, enclosingDeclaration, meaning, false);
38726                 if (accessibleSymbolChain) {
38727                     hadAccessibleChain = symbol;
38728                     var hasAccessibleDeclarations = hasVisibleDeclarations(accessibleSymbolChain[0], shouldComputeAliasesToMakeVisible);
38729                     if (hasAccessibleDeclarations) {
38730                         return hasAccessibleDeclarations;
38731                     }
38732                 }
38733                 else if (allowModules) {
38734                     if (ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
38735                         if (shouldComputeAliasesToMakeVisible) {
38736                             earlyModuleBail = true;
38737                             continue;
38738                         }
38739                         return {
38740                             accessibility: 0
38741                         };
38742                     }
38743                 }
38744                 var containers = getContainersOfSymbol(symbol, enclosingDeclaration, meaning);
38745                 var parentResult = isAnySymbolAccessible(containers, enclosingDeclaration, initialSymbol, initialSymbol === symbol ? getQualifiedLeftMeaning(meaning) : meaning, shouldComputeAliasesToMakeVisible, allowModules);
38746                 if (parentResult) {
38747                     return parentResult;
38748                 }
38749             }
38750             if (earlyModuleBail) {
38751                 return {
38752                     accessibility: 0
38753                 };
38754             }
38755             if (hadAccessibleChain) {
38756                 return {
38757                     accessibility: 1,
38758                     errorSymbolName: symbolToString(initialSymbol, enclosingDeclaration, meaning),
38759                     errorModuleName: hadAccessibleChain !== initialSymbol ? symbolToString(hadAccessibleChain, enclosingDeclaration, 1920) : undefined,
38760                 };
38761             }
38762         }
38763         function isSymbolAccessible(symbol, enclosingDeclaration, meaning, shouldComputeAliasesToMakeVisible) {
38764             return isSymbolAccessibleWorker(symbol, enclosingDeclaration, meaning, shouldComputeAliasesToMakeVisible, true);
38765         }
38766         function isSymbolAccessibleWorker(symbol, enclosingDeclaration, meaning, shouldComputeAliasesToMakeVisible, allowModules) {
38767             if (symbol && enclosingDeclaration) {
38768                 var result = isAnySymbolAccessible([symbol], enclosingDeclaration, symbol, meaning, shouldComputeAliasesToMakeVisible, allowModules);
38769                 if (result) {
38770                     return result;
38771                 }
38772                 var symbolExternalModule = ts.forEach(symbol.declarations, getExternalModuleContainer);
38773                 if (symbolExternalModule) {
38774                     var enclosingExternalModule = getExternalModuleContainer(enclosingDeclaration);
38775                     if (symbolExternalModule !== enclosingExternalModule) {
38776                         return {
38777                             accessibility: 2,
38778                             errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
38779                             errorModuleName: symbolToString(symbolExternalModule),
38780                             errorNode: ts.isInJSFile(enclosingDeclaration) ? enclosingDeclaration : undefined,
38781                         };
38782                     }
38783                 }
38784                 return {
38785                     accessibility: 1,
38786                     errorSymbolName: symbolToString(symbol, enclosingDeclaration, meaning),
38787                 };
38788             }
38789             return { accessibility: 0 };
38790         }
38791         function getExternalModuleContainer(declaration) {
38792             var node = ts.findAncestor(declaration, hasExternalModuleSymbol);
38793             return node && getSymbolOfNode(node);
38794         }
38795         function hasExternalModuleSymbol(declaration) {
38796             return ts.isAmbientModule(declaration) || (declaration.kind === 297 && ts.isExternalOrCommonJsModule(declaration));
38797         }
38798         function hasNonGlobalAugmentationExternalModuleSymbol(declaration) {
38799             return ts.isModuleWithStringLiteralName(declaration) || (declaration.kind === 297 && ts.isExternalOrCommonJsModule(declaration));
38800         }
38801         function hasVisibleDeclarations(symbol, shouldComputeAliasToMakeVisible) {
38802             var aliasesToMakeVisible;
38803             if (!ts.every(ts.filter(symbol.declarations, function (d) { return d.kind !== 78; }), getIsDeclarationVisible)) {
38804                 return undefined;
38805             }
38806             return { accessibility: 0, aliasesToMakeVisible: aliasesToMakeVisible };
38807             function getIsDeclarationVisible(declaration) {
38808                 var _a, _b;
38809                 if (!isDeclarationVisible(declaration)) {
38810                     var anyImportSyntax = getAnyImportSyntax(declaration);
38811                     if (anyImportSyntax &&
38812                         !ts.hasSyntacticModifier(anyImportSyntax, 1) &&
38813                         isDeclarationVisible(anyImportSyntax.parent)) {
38814                         return addVisibleAlias(declaration, anyImportSyntax);
38815                     }
38816                     else if (ts.isVariableDeclaration(declaration) && ts.isVariableStatement(declaration.parent.parent) &&
38817                         !ts.hasSyntacticModifier(declaration.parent.parent, 1) &&
38818                         isDeclarationVisible(declaration.parent.parent.parent)) {
38819                         return addVisibleAlias(declaration, declaration.parent.parent);
38820                     }
38821                     else if (ts.isLateVisibilityPaintedStatement(declaration)
38822                         && !ts.hasSyntacticModifier(declaration, 1)
38823                         && isDeclarationVisible(declaration.parent)) {
38824                         return addVisibleAlias(declaration, declaration);
38825                     }
38826                     else if (symbol.flags & 2097152 && ts.isBindingElement(declaration) && ts.isInJSFile(declaration) && ((_a = declaration.parent) === null || _a === void 0 ? void 0 : _a.parent)
38827                         && ts.isVariableDeclaration(declaration.parent.parent)
38828                         && ((_b = declaration.parent.parent.parent) === null || _b === void 0 ? void 0 : _b.parent) && ts.isVariableStatement(declaration.parent.parent.parent.parent)
38829                         && !ts.hasSyntacticModifier(declaration.parent.parent.parent.parent, 1)
38830                         && declaration.parent.parent.parent.parent.parent
38831                         && isDeclarationVisible(declaration.parent.parent.parent.parent.parent)) {
38832                         return addVisibleAlias(declaration, declaration.parent.parent.parent.parent);
38833                     }
38834                     return false;
38835                 }
38836                 return true;
38837             }
38838             function addVisibleAlias(declaration, aliasingStatement) {
38839                 if (shouldComputeAliasToMakeVisible) {
38840                     getNodeLinks(declaration).isVisible = true;
38841                     aliasesToMakeVisible = ts.appendIfUnique(aliasesToMakeVisible, aliasingStatement);
38842                 }
38843                 return true;
38844             }
38845         }
38846         function isEntityNameVisible(entityName, enclosingDeclaration) {
38847             var meaning;
38848             if (entityName.parent.kind === 176 ||
38849                 ts.isExpressionWithTypeArgumentsInClassExtendsClause(entityName.parent) ||
38850                 entityName.parent.kind === 158) {
38851                 meaning = 111551 | 1048576;
38852             }
38853             else if (entityName.kind === 157 || entityName.kind === 201 ||
38854                 entityName.parent.kind === 260) {
38855                 meaning = 1920;
38856             }
38857             else {
38858                 meaning = 788968;
38859             }
38860             var firstIdentifier = ts.getFirstIdentifier(entityName);
38861             var symbol = resolveName(enclosingDeclaration, firstIdentifier.escapedText, meaning, undefined, undefined, false);
38862             if (symbol && symbol.flags & 262144 && meaning & 788968) {
38863                 return { accessibility: 0 };
38864             }
38865             return (symbol && hasVisibleDeclarations(symbol, true)) || {
38866                 accessibility: 1,
38867                 errorSymbolName: ts.getTextOfNode(firstIdentifier),
38868                 errorNode: firstIdentifier
38869             };
38870         }
38871         function symbolToString(symbol, enclosingDeclaration, meaning, flags, writer) {
38872             if (flags === void 0) { flags = 4; }
38873             var nodeFlags = 70221824;
38874             if (flags & 2) {
38875                 nodeFlags |= 128;
38876             }
38877             if (flags & 1) {
38878                 nodeFlags |= 512;
38879             }
38880             if (flags & 8) {
38881                 nodeFlags |= 16384;
38882             }
38883             if (flags & 16) {
38884                 nodeFlags |= 134217728;
38885             }
38886             var builder = flags & 4 ? nodeBuilder.symbolToExpression : nodeBuilder.symbolToEntityName;
38887             return writer ? symbolToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(symbolToStringWorker);
38888             function symbolToStringWorker(writer) {
38889                 var entity = builder(symbol, meaning, enclosingDeclaration, nodeFlags);
38890                 var printer = (enclosingDeclaration === null || enclosingDeclaration === void 0 ? void 0 : enclosingDeclaration.kind) === 297 ? ts.createPrinter({ removeComments: true, neverAsciiEscape: true }) : ts.createPrinter({ removeComments: true });
38891                 var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
38892                 printer.writeNode(4, entity, sourceFile, writer);
38893                 return writer;
38894             }
38895         }
38896         function signatureToString(signature, enclosingDeclaration, flags, kind, writer) {
38897             if (flags === void 0) { flags = 0; }
38898             return writer ? signatureToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(signatureToStringWorker);
38899             function signatureToStringWorker(writer) {
38900                 var sigOutput;
38901                 if (flags & 262144) {
38902                     sigOutput = kind === 1 ? 175 : 174;
38903                 }
38904                 else {
38905                     sigOutput = kind === 1 ? 170 : 169;
38906                 }
38907                 var sig = nodeBuilder.signatureToSignatureDeclaration(signature, sigOutput, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | 512);
38908                 var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
38909                 var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
38910                 printer.writeNode(4, sig, sourceFile, ts.getTrailingSemicolonDeferringWriter(writer));
38911                 return writer;
38912             }
38913         }
38914         function typeToString(type, enclosingDeclaration, flags, writer) {
38915             if (flags === void 0) { flags = 1048576 | 16384; }
38916             if (writer === void 0) { writer = ts.createTextWriter(""); }
38917             var noTruncation = compilerOptions.noErrorTruncation || flags & 1;
38918             var typeNode = nodeBuilder.typeToTypeNode(type, enclosingDeclaration, toNodeBuilderFlags(flags) | 70221824 | (noTruncation ? 1 : 0), writer);
38919             if (typeNode === undefined)
38920                 return ts.Debug.fail("should always get typenode");
38921             var options = { removeComments: true };
38922             var printer = ts.createPrinter(options);
38923             var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
38924             printer.writeNode(4, typeNode, sourceFile, writer);
38925             var result = writer.getText();
38926             var maxLength = noTruncation ? ts.noTruncationMaximumTruncationLength * 2 : ts.defaultMaximumTruncationLength * 2;
38927             if (maxLength && result && result.length >= maxLength) {
38928                 return result.substr(0, maxLength - "...".length) + "...";
38929             }
38930             return result;
38931         }
38932         function getTypeNamesForErrorDisplay(left, right) {
38933             var leftStr = symbolValueDeclarationIsContextSensitive(left.symbol) ? typeToString(left, left.symbol.valueDeclaration) : typeToString(left);
38934             var rightStr = symbolValueDeclarationIsContextSensitive(right.symbol) ? typeToString(right, right.symbol.valueDeclaration) : typeToString(right);
38935             if (leftStr === rightStr) {
38936                 leftStr = getTypeNameForErrorDisplay(left);
38937                 rightStr = getTypeNameForErrorDisplay(right);
38938             }
38939             return [leftStr, rightStr];
38940         }
38941         function getTypeNameForErrorDisplay(type) {
38942             return typeToString(type, undefined, 64);
38943         }
38944         function symbolValueDeclarationIsContextSensitive(symbol) {
38945             return symbol && symbol.valueDeclaration && ts.isExpression(symbol.valueDeclaration) && !isContextSensitive(symbol.valueDeclaration);
38946         }
38947         function toNodeBuilderFlags(flags) {
38948             if (flags === void 0) { flags = 0; }
38949             return flags & 814775659;
38950         }
38951         function isClassInstanceSide(type) {
38952             return !!type.symbol && !!(type.symbol.flags & 32) && (type === getDeclaredTypeOfClassOrInterface(type.symbol) || !!(ts.getObjectFlags(type) & 1073741824));
38953         }
38954         function createNodeBuilder() {
38955             return {
38956                 typeToTypeNode: function (type, enclosingDeclaration, flags, tracker) {
38957                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeToTypeNodeHelper(type, context); });
38958                 },
38959                 indexInfoToIndexSignatureDeclaration: function (indexInfo, kind, enclosingDeclaration, flags, tracker) {
38960                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context, undefined); });
38961                 },
38962                 signatureToSignatureDeclaration: function (signature, kind, enclosingDeclaration, flags, tracker) {
38963                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return signatureToSignatureDeclarationHelper(signature, kind, context); });
38964                 },
38965                 symbolToEntityName: function (symbol, meaning, enclosingDeclaration, flags, tracker) {
38966                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToName(symbol, context, meaning, false); });
38967                 },
38968                 symbolToExpression: function (symbol, meaning, enclosingDeclaration, flags, tracker) {
38969                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToExpression(symbol, context, meaning); });
38970                 },
38971                 symbolToTypeParameterDeclarations: function (symbol, enclosingDeclaration, flags, tracker) {
38972                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParametersToTypeParameterDeclarations(symbol, context); });
38973                 },
38974                 symbolToParameterDeclaration: function (symbol, enclosingDeclaration, flags, tracker) {
38975                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolToParameterDeclaration(symbol, context); });
38976                 },
38977                 typeParameterToDeclaration: function (parameter, enclosingDeclaration, flags, tracker) {
38978                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return typeParameterToDeclaration(parameter, context); });
38979                 },
38980                 symbolTableToDeclarationStatements: function (symbolTable, enclosingDeclaration, flags, tracker, bundled) {
38981                     return withContext(enclosingDeclaration, flags, tracker, function (context) { return symbolTableToDeclarationStatements(symbolTable, context, bundled); });
38982                 },
38983             };
38984             function withContext(enclosingDeclaration, flags, tracker, cb) {
38985                 var _a, _b;
38986                 ts.Debug.assert(enclosingDeclaration === undefined || (enclosingDeclaration.flags & 8) === 0);
38987                 var context = {
38988                     enclosingDeclaration: enclosingDeclaration,
38989                     flags: flags || 0,
38990                     tracker: tracker && tracker.trackSymbol ? tracker : { trackSymbol: ts.noop, moduleResolverHost: flags & 134217728 ? {
38991                             getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; },
38992                             getSourceFiles: function () { return host.getSourceFiles(); },
38993                             getCurrentDirectory: function () { return host.getCurrentDirectory(); },
38994                             getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache),
38995                             useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames),
38996                             redirectTargetsMap: host.redirectTargetsMap,
38997                             getProjectReferenceRedirect: function (fileName) { return host.getProjectReferenceRedirect(fileName); },
38998                             isSourceOfProjectReferenceRedirect: function (fileName) { return host.isSourceOfProjectReferenceRedirect(fileName); },
38999                             fileExists: function (fileName) { return host.fileExists(fileName); },
39000                             getFileIncludeReasons: function () { return host.getFileIncludeReasons(); },
39001                         } : undefined },
39002                     encounteredError: false,
39003                     visitedTypes: undefined,
39004                     symbolDepth: undefined,
39005                     inferTypeParameters: undefined,
39006                     approximateLength: 0
39007                 };
39008                 var resultingNode = cb(context);
39009                 if (context.truncating && context.flags & 1) {
39010                     (_b = (_a = context.tracker) === null || _a === void 0 ? void 0 : _a.reportTruncationError) === null || _b === void 0 ? void 0 : _b.call(_a);
39011                 }
39012                 return context.encounteredError ? undefined : resultingNode;
39013             }
39014             function checkTruncationLength(context) {
39015                 if (context.truncating)
39016                     return context.truncating;
39017                 return context.truncating = context.approximateLength > ((context.flags & 1) ? ts.noTruncationMaximumTruncationLength : ts.defaultMaximumTruncationLength);
39018             }
39019             function typeToTypeNodeHelper(type, context) {
39020                 if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
39021                     cancellationToken.throwIfCancellationRequested();
39022                 }
39023                 var inTypeAlias = context.flags & 8388608;
39024                 context.flags &= ~8388608;
39025                 if (!type) {
39026                     if (!(context.flags & 262144)) {
39027                         context.encounteredError = true;
39028                         return undefined;
39029                     }
39030                     context.approximateLength += 3;
39031                     return ts.factory.createKeywordTypeNode(128);
39032                 }
39033                 if (!(context.flags & 536870912)) {
39034                     type = getReducedType(type);
39035                 }
39036                 if (type.flags & 1) {
39037                     context.approximateLength += 3;
39038                     return ts.factory.createKeywordTypeNode(type === intrinsicMarkerType ? 136 : 128);
39039                 }
39040                 if (type.flags & 2) {
39041                     return ts.factory.createKeywordTypeNode(152);
39042                 }
39043                 if (type.flags & 4) {
39044                     context.approximateLength += 6;
39045                     return ts.factory.createKeywordTypeNode(147);
39046                 }
39047                 if (type.flags & 8) {
39048                     context.approximateLength += 6;
39049                     return ts.factory.createKeywordTypeNode(144);
39050                 }
39051                 if (type.flags & 64) {
39052                     context.approximateLength += 6;
39053                     return ts.factory.createKeywordTypeNode(155);
39054                 }
39055                 if (type.flags & 16) {
39056                     context.approximateLength += 7;
39057                     return ts.factory.createKeywordTypeNode(131);
39058                 }
39059                 if (type.flags & 1024 && !(type.flags & 1048576)) {
39060                     var parentSymbol = getParentOfSymbol(type.symbol);
39061                     var parentName = symbolToTypeNode(parentSymbol, context, 788968);
39062                     if (getDeclaredTypeOfSymbol(parentSymbol) === type) {
39063                         return parentName;
39064                     }
39065                     var memberName = ts.symbolName(type.symbol);
39066                     if (ts.isIdentifierText(memberName, 0)) {
39067                         return appendReferenceToType(parentName, ts.factory.createTypeReferenceNode(memberName, undefined));
39068                     }
39069                     if (ts.isImportTypeNode(parentName)) {
39070                         parentName.isTypeOf = true;
39071                         return ts.factory.createIndexedAccessTypeNode(parentName, ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(memberName)));
39072                     }
39073                     else if (ts.isTypeReferenceNode(parentName)) {
39074                         return ts.factory.createIndexedAccessTypeNode(ts.factory.createTypeQueryNode(parentName.typeName), ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(memberName)));
39075                     }
39076                     else {
39077                         return ts.Debug.fail("Unhandled type node kind returned from `symbolToTypeNode`.");
39078                     }
39079                 }
39080                 if (type.flags & 1056) {
39081                     return symbolToTypeNode(type.symbol, context, 788968);
39082                 }
39083                 if (type.flags & 128) {
39084                     context.approximateLength += (type.value.length + 2);
39085                     return ts.factory.createLiteralTypeNode(ts.setEmitFlags(ts.factory.createStringLiteral(type.value, !!(context.flags & 268435456)), 16777216));
39086                 }
39087                 if (type.flags & 256) {
39088                     var value = type.value;
39089                     context.approximateLength += ("" + value).length;
39090                     return ts.factory.createLiteralTypeNode(value < 0 ? ts.factory.createPrefixUnaryExpression(40, ts.factory.createNumericLiteral(-value)) : ts.factory.createNumericLiteral(value));
39091                 }
39092                 if (type.flags & 2048) {
39093                     context.approximateLength += (ts.pseudoBigIntToString(type.value).length) + 1;
39094                     return ts.factory.createLiteralTypeNode((ts.factory.createBigIntLiteral(type.value)));
39095                 }
39096                 if (type.flags & 512) {
39097                     context.approximateLength += type.intrinsicName.length;
39098                     return ts.factory.createLiteralTypeNode(type.intrinsicName === "true" ? ts.factory.createTrue() : ts.factory.createFalse());
39099                 }
39100                 if (type.flags & 8192) {
39101                     if (!(context.flags & 1048576)) {
39102                         if (isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
39103                             context.approximateLength += 6;
39104                             return symbolToTypeNode(type.symbol, context, 111551);
39105                         }
39106                         if (context.tracker.reportInaccessibleUniqueSymbolError) {
39107                             context.tracker.reportInaccessibleUniqueSymbolError();
39108                         }
39109                     }
39110                     context.approximateLength += 13;
39111                     return ts.factory.createTypeOperatorNode(151, ts.factory.createKeywordTypeNode(148));
39112                 }
39113                 if (type.flags & 16384) {
39114                     context.approximateLength += 4;
39115                     return ts.factory.createKeywordTypeNode(113);
39116                 }
39117                 if (type.flags & 32768) {
39118                     context.approximateLength += 9;
39119                     return ts.factory.createKeywordTypeNode(150);
39120                 }
39121                 if (type.flags & 65536) {
39122                     context.approximateLength += 4;
39123                     return ts.factory.createLiteralTypeNode(ts.factory.createNull());
39124                 }
39125                 if (type.flags & 131072) {
39126                     context.approximateLength += 5;
39127                     return ts.factory.createKeywordTypeNode(141);
39128                 }
39129                 if (type.flags & 4096) {
39130                     context.approximateLength += 6;
39131                     return ts.factory.createKeywordTypeNode(148);
39132                 }
39133                 if (type.flags & 67108864) {
39134                     context.approximateLength += 6;
39135                     return ts.factory.createKeywordTypeNode(145);
39136                 }
39137                 if (isThisTypeParameter(type)) {
39138                     if (context.flags & 4194304) {
39139                         if (!context.encounteredError && !(context.flags & 32768)) {
39140                             context.encounteredError = true;
39141                         }
39142                         if (context.tracker.reportInaccessibleThisError) {
39143                             context.tracker.reportInaccessibleThisError();
39144                         }
39145                     }
39146                     context.approximateLength += 4;
39147                     return ts.factory.createThisTypeNode();
39148                 }
39149                 if (!inTypeAlias && type.aliasSymbol && (context.flags & 16384 || isTypeSymbolAccessible(type.aliasSymbol, context.enclosingDeclaration))) {
39150                     var typeArgumentNodes = mapToTypeNodes(type.aliasTypeArguments, context);
39151                     if (isReservedMemberName(type.aliasSymbol.escapedName) && !(type.aliasSymbol.flags & 32))
39152                         return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""), typeArgumentNodes);
39153                     return symbolToTypeNode(type.aliasSymbol, context, 788968, typeArgumentNodes);
39154                 }
39155                 var objectFlags = ts.getObjectFlags(type);
39156                 if (objectFlags & 4) {
39157                     ts.Debug.assert(!!(type.flags & 524288));
39158                     return type.node ? visitAndTransformType(type, typeReferenceToTypeNode) : typeReferenceToTypeNode(type);
39159                 }
39160                 if (type.flags & 262144 || objectFlags & 3) {
39161                     if (type.flags & 262144 && ts.contains(context.inferTypeParameters, type)) {
39162                         context.approximateLength += (ts.symbolName(type.symbol).length + 6);
39163                         return ts.factory.createInferTypeNode(typeParameterToDeclarationWithConstraint(type, context, undefined));
39164                     }
39165                     if (context.flags & 4 &&
39166                         type.flags & 262144 &&
39167                         !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
39168                         var name = typeParameterToName(type, context);
39169                         context.approximateLength += ts.idText(name).length;
39170                         return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(ts.idText(name)), undefined);
39171                     }
39172                     return type.symbol
39173                         ? symbolToTypeNode(type.symbol, context, 788968)
39174                         : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("?"), undefined);
39175                 }
39176                 if (type.flags & 1048576 && type.origin) {
39177                     type = type.origin;
39178                 }
39179                 if (type.flags & (1048576 | 2097152)) {
39180                     var types = type.flags & 1048576 ? formatUnionTypes(type.types) : type.types;
39181                     if (ts.length(types) === 1) {
39182                         return typeToTypeNodeHelper(types[0], context);
39183                     }
39184                     var typeNodes = mapToTypeNodes(types, context, true);
39185                     if (typeNodes && typeNodes.length > 0) {
39186                         return type.flags & 1048576 ? ts.factory.createUnionTypeNode(typeNodes) : ts.factory.createIntersectionTypeNode(typeNodes);
39187                     }
39188                     else {
39189                         if (!context.encounteredError && !(context.flags & 262144)) {
39190                             context.encounteredError = true;
39191                         }
39192                         return undefined;
39193                     }
39194                 }
39195                 if (objectFlags & (16 | 32)) {
39196                     ts.Debug.assert(!!(type.flags & 524288));
39197                     return createAnonymousTypeNode(type);
39198                 }
39199                 if (type.flags & 4194304) {
39200                     var indexedType = type.type;
39201                     context.approximateLength += 6;
39202                     var indexTypeNode = typeToTypeNodeHelper(indexedType, context);
39203                     return ts.factory.createTypeOperatorNode(138, indexTypeNode);
39204                 }
39205                 if (type.flags & 134217728) {
39206                     var texts_1 = type.texts;
39207                     var types_1 = type.types;
39208                     var templateHead = ts.factory.createTemplateHead(texts_1[0]);
39209                     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])); }));
39210                     context.approximateLength += 2;
39211                     return ts.factory.createTemplateLiteralType(templateHead, templateSpans);
39212                 }
39213                 if (type.flags & 268435456) {
39214                     var typeNode = typeToTypeNodeHelper(type.type, context);
39215                     return symbolToTypeNode(type.symbol, context, 788968, [typeNode]);
39216                 }
39217                 if (type.flags & 8388608) {
39218                     var objectTypeNode = typeToTypeNodeHelper(type.objectType, context);
39219                     var indexTypeNode = typeToTypeNodeHelper(type.indexType, context);
39220                     context.approximateLength += 2;
39221                     return ts.factory.createIndexedAccessTypeNode(objectTypeNode, indexTypeNode);
39222                 }
39223                 if (type.flags & 16777216) {
39224                     var checkTypeNode = typeToTypeNodeHelper(type.checkType, context);
39225                     var saveInferTypeParameters = context.inferTypeParameters;
39226                     context.inferTypeParameters = type.root.inferTypeParameters;
39227                     var extendsTypeNode = typeToTypeNodeHelper(type.extendsType, context);
39228                     context.inferTypeParameters = saveInferTypeParameters;
39229                     var trueTypeNode = typeToTypeNodeOrCircularityElision(getTrueTypeFromConditionalType(type));
39230                     var falseTypeNode = typeToTypeNodeOrCircularityElision(getFalseTypeFromConditionalType(type));
39231                     context.approximateLength += 15;
39232                     return ts.factory.createConditionalTypeNode(checkTypeNode, extendsTypeNode, trueTypeNode, falseTypeNode);
39233                 }
39234                 if (type.flags & 33554432) {
39235                     return typeToTypeNodeHelper(type.baseType, context);
39236                 }
39237                 return ts.Debug.fail("Should be unreachable.");
39238                 function typeToTypeNodeOrCircularityElision(type) {
39239                     var _a, _b, _c;
39240                     if (type.flags & 1048576) {
39241                         if ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(getTypeId(type))) {
39242                             if (!(context.flags & 131072)) {
39243                                 context.encounteredError = true;
39244                                 (_c = (_b = context.tracker) === null || _b === void 0 ? void 0 : _b.reportCyclicStructureError) === null || _c === void 0 ? void 0 : _c.call(_b);
39245                             }
39246                             return createElidedInformationPlaceholder(context);
39247                         }
39248                         return visitAndTransformType(type, function (type) { return typeToTypeNodeHelper(type, context); });
39249                     }
39250                     return typeToTypeNodeHelper(type, context);
39251                 }
39252                 function createMappedTypeNodeFromType(type) {
39253                     ts.Debug.assert(!!(type.flags & 524288));
39254                     var readonlyToken = type.declaration.readonlyToken ? ts.factory.createToken(type.declaration.readonlyToken.kind) : undefined;
39255                     var questionToken = type.declaration.questionToken ? ts.factory.createToken(type.declaration.questionToken.kind) : undefined;
39256                     var appropriateConstraintTypeNode;
39257                     if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
39258                         appropriateConstraintTypeNode = ts.factory.createTypeOperatorNode(138, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type), context));
39259                     }
39260                     else {
39261                         appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type), context);
39262                     }
39263                     var typeParameterNode = typeParameterToDeclarationWithConstraint(getTypeParameterFromMappedType(type), context, appropriateConstraintTypeNode);
39264                     var nameTypeNode = type.declaration.nameType ? typeToTypeNodeHelper(getNameTypeFromMappedType(type), context) : undefined;
39265                     var templateTypeNode = typeToTypeNodeHelper(getTemplateTypeFromMappedType(type), context);
39266                     var mappedTypeNode = ts.factory.createMappedTypeNode(readonlyToken, typeParameterNode, nameTypeNode, questionToken, templateTypeNode);
39267                     context.approximateLength += 10;
39268                     return ts.setEmitFlags(mappedTypeNode, 1);
39269                 }
39270                 function createAnonymousTypeNode(type) {
39271                     var _a;
39272                     var typeId = type.id;
39273                     var symbol = type.symbol;
39274                     if (symbol) {
39275                         var isInstanceType = isClassInstanceSide(type) ? 788968 : 111551;
39276                         if (isJSConstructor(symbol.valueDeclaration)) {
39277                             return symbolToTypeNode(symbol, context, isInstanceType);
39278                         }
39279                         else if (symbol.flags & 32 && !getBaseTypeVariableOfClass(symbol) && !(symbol.valueDeclaration.kind === 221 && context.flags & 2048) ||
39280                             symbol.flags & (384 | 512) ||
39281                             shouldWriteTypeOfFunctionSymbol()) {
39282                             return symbolToTypeNode(symbol, context, isInstanceType);
39283                         }
39284                         else if ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId)) {
39285                             var typeAlias = getTypeAliasForTypeLiteral(type);
39286                             if (typeAlias) {
39287                                 return symbolToTypeNode(typeAlias, context, 788968);
39288                             }
39289                             else {
39290                                 return createElidedInformationPlaceholder(context);
39291                             }
39292                         }
39293                         else {
39294                             return visitAndTransformType(type, createTypeNodeFromObjectType);
39295                         }
39296                     }
39297                     else {
39298                         return createTypeNodeFromObjectType(type);
39299                     }
39300                     function shouldWriteTypeOfFunctionSymbol() {
39301                         var _a;
39302                         var isStaticMethodSymbol = !!(symbol.flags & 8192) &&
39303                             ts.some(symbol.declarations, function (declaration) { return ts.hasSyntacticModifier(declaration, 32); });
39304                         var isNonLocalFunctionSymbol = !!(symbol.flags & 16) &&
39305                             (symbol.parent ||
39306                                 ts.forEach(symbol.declarations, function (declaration) {
39307                                     return declaration.parent.kind === 297 || declaration.parent.kind === 257;
39308                                 }));
39309                         if (isStaticMethodSymbol || isNonLocalFunctionSymbol) {
39310                             return (!!(context.flags & 4096) || ((_a = context.visitedTypes) === null || _a === void 0 ? void 0 : _a.has(typeId))) &&
39311                                 (!(context.flags & 8) || isValueSymbolAccessible(symbol, context.enclosingDeclaration));
39312                         }
39313                     }
39314                 }
39315                 function visitAndTransformType(type, transform) {
39316                     var typeId = type.id;
39317                     var isConstructorObject = ts.getObjectFlags(type) & 16 && type.symbol && type.symbol.flags & 32;
39318                     var id = ts.getObjectFlags(type) & 4 && type.node ? "N" + getNodeId(type.node) :
39319                         type.symbol ? (isConstructorObject ? "+" : "") + getSymbolId(type.symbol) :
39320                             undefined;
39321                     if (!context.visitedTypes) {
39322                         context.visitedTypes = new ts.Set();
39323                     }
39324                     if (id && !context.symbolDepth) {
39325                         context.symbolDepth = new ts.Map();
39326                     }
39327                     var depth;
39328                     if (id) {
39329                         depth = context.symbolDepth.get(id) || 0;
39330                         if (depth > 10) {
39331                             return createElidedInformationPlaceholder(context);
39332                         }
39333                         context.symbolDepth.set(id, depth + 1);
39334                     }
39335                     context.visitedTypes.add(typeId);
39336                     var result = transform(type);
39337                     context.visitedTypes.delete(typeId);
39338                     if (id) {
39339                         context.symbolDepth.set(id, depth);
39340                     }
39341                     return result;
39342                 }
39343                 function createTypeNodeFromObjectType(type) {
39344                     if (isGenericMappedType(type) || type.containsError) {
39345                         return createMappedTypeNodeFromType(type);
39346                     }
39347                     var resolved = resolveStructuredTypeMembers(type);
39348                     if (!resolved.properties.length && !resolved.stringIndexInfo && !resolved.numberIndexInfo) {
39349                         if (!resolved.callSignatures.length && !resolved.constructSignatures.length) {
39350                             context.approximateLength += 2;
39351                             return ts.setEmitFlags(ts.factory.createTypeLiteralNode(undefined), 1);
39352                         }
39353                         if (resolved.callSignatures.length === 1 && !resolved.constructSignatures.length) {
39354                             var signature = resolved.callSignatures[0];
39355                             var signatureNode = signatureToSignatureDeclarationHelper(signature, 174, context);
39356                             return signatureNode;
39357                         }
39358                         if (resolved.constructSignatures.length === 1 && !resolved.callSignatures.length) {
39359                             var signature = resolved.constructSignatures[0];
39360                             var signatureNode = signatureToSignatureDeclarationHelper(signature, 175, context);
39361                             return signatureNode;
39362                         }
39363                     }
39364                     var abstractSignatures = ts.filter(resolved.constructSignatures, function (signature) { return !!(signature.flags & 4); });
39365                     if (ts.some(abstractSignatures)) {
39366                         var types = ts.map(abstractSignatures, getOrCreateTypeFromSignature);
39367                         var typeElementCount = resolved.callSignatures.length +
39368                             (resolved.constructSignatures.length - abstractSignatures.length) +
39369                             (resolved.stringIndexInfo ? 1 : 0) +
39370                             (resolved.numberIndexInfo ? 1 : 0) +
39371                             (context.flags & 2048 ?
39372                                 ts.countWhere(resolved.properties, function (p) { return !(p.flags & 4194304); }) :
39373                                 ts.length(resolved.properties));
39374                         if (typeElementCount) {
39375                             types.push(getResolvedTypeWithoutAbstractConstructSignatures(resolved));
39376                         }
39377                         return typeToTypeNodeHelper(getIntersectionType(types), context);
39378                     }
39379                     var savedFlags = context.flags;
39380                     context.flags |= 4194304;
39381                     var members = createTypeNodesFromResolvedType(resolved);
39382                     context.flags = savedFlags;
39383                     var typeLiteralNode = ts.factory.createTypeLiteralNode(members);
39384                     context.approximateLength += 2;
39385                     ts.setEmitFlags(typeLiteralNode, (context.flags & 1024) ? 0 : 1);
39386                     return typeLiteralNode;
39387                 }
39388                 function typeReferenceToTypeNode(type) {
39389                     var typeArguments = getTypeArguments(type);
39390                     if (type.target === globalArrayType || type.target === globalReadonlyArrayType) {
39391                         if (context.flags & 2) {
39392                             var typeArgumentNode = typeToTypeNodeHelper(typeArguments[0], context);
39393                             return ts.factory.createTypeReferenceNode(type.target === globalArrayType ? "Array" : "ReadonlyArray", [typeArgumentNode]);
39394                         }
39395                         var elementType = typeToTypeNodeHelper(typeArguments[0], context);
39396                         var arrayType = ts.factory.createArrayTypeNode(elementType);
39397                         return type.target === globalArrayType ? arrayType : ts.factory.createTypeOperatorNode(142, arrayType);
39398                     }
39399                     else if (type.target.objectFlags & 8) {
39400                         if (typeArguments.length > 0) {
39401                             var arity = getTypeReferenceArity(type);
39402                             var tupleConstituentNodes = mapToTypeNodes(typeArguments.slice(0, arity), context);
39403                             if (tupleConstituentNodes) {
39404                                 if (type.target.labeledElementDeclarations) {
39405                                     for (var i = 0; i < tupleConstituentNodes.length; i++) {
39406                                         var flags = type.target.elementFlags[i];
39407                                         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]) :
39408                                             tupleConstituentNodes[i]);
39409                                     }
39410                                 }
39411                                 else {
39412                                     for (var i = 0; i < Math.min(arity, tupleConstituentNodes.length); i++) {
39413                                         var flags = type.target.elementFlags[i];
39414                                         tupleConstituentNodes[i] =
39415                                             flags & 12 ? ts.factory.createRestTypeNode(flags & 4 ? ts.factory.createArrayTypeNode(tupleConstituentNodes[i]) : tupleConstituentNodes[i]) :
39416                                                 flags & 2 ? ts.factory.createOptionalTypeNode(tupleConstituentNodes[i]) :
39417                                                     tupleConstituentNodes[i];
39418                                     }
39419                                 }
39420                                 var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode(tupleConstituentNodes), 1);
39421                                 return type.target.readonly ? ts.factory.createTypeOperatorNode(142, tupleTypeNode) : tupleTypeNode;
39422                             }
39423                         }
39424                         if (context.encounteredError || (context.flags & 524288)) {
39425                             var tupleTypeNode = ts.setEmitFlags(ts.factory.createTupleTypeNode([]), 1);
39426                             return type.target.readonly ? ts.factory.createTypeOperatorNode(142, tupleTypeNode) : tupleTypeNode;
39427                         }
39428                         context.encounteredError = true;
39429                         return undefined;
39430                     }
39431                     else if (context.flags & 2048 &&
39432                         type.symbol.valueDeclaration &&
39433                         ts.isClassLike(type.symbol.valueDeclaration) &&
39434                         !isValueSymbolAccessible(type.symbol, context.enclosingDeclaration)) {
39435                         return createAnonymousTypeNode(type);
39436                     }
39437                     else {
39438                         var outerTypeParameters = type.target.outerTypeParameters;
39439                         var i = 0;
39440                         var resultType = void 0;
39441                         if (outerTypeParameters) {
39442                             var length_2 = outerTypeParameters.length;
39443                             while (i < length_2) {
39444                                 var start = i;
39445                                 var parent = getParentSymbolOfTypeParameter(outerTypeParameters[i]);
39446                                 do {
39447                                     i++;
39448                                 } while (i < length_2 && getParentSymbolOfTypeParameter(outerTypeParameters[i]) === parent);
39449                                 if (!ts.rangeEquals(outerTypeParameters, typeArguments, start, i)) {
39450                                     var typeArgumentSlice = mapToTypeNodes(typeArguments.slice(start, i), context);
39451                                     var flags_3 = context.flags;
39452                                     context.flags |= 16;
39453                                     var ref = symbolToTypeNode(parent, context, 788968, typeArgumentSlice);
39454                                     context.flags = flags_3;
39455                                     resultType = !resultType ? ref : appendReferenceToType(resultType, ref);
39456                                 }
39457                             }
39458                         }
39459                         var typeArgumentNodes = void 0;
39460                         if (typeArguments.length > 0) {
39461                             var typeParameterCount = (type.target.typeParameters || ts.emptyArray).length;
39462                             typeArgumentNodes = mapToTypeNodes(typeArguments.slice(i, typeParameterCount), context);
39463                         }
39464                         var flags = context.flags;
39465                         context.flags |= 16;
39466                         var finalRef = symbolToTypeNode(type.symbol, context, 788968, typeArgumentNodes);
39467                         context.flags = flags;
39468                         return !resultType ? finalRef : appendReferenceToType(resultType, finalRef);
39469                     }
39470                 }
39471                 function appendReferenceToType(root, ref) {
39472                     if (ts.isImportTypeNode(root)) {
39473                         var typeArguments = root.typeArguments;
39474                         var qualifier = root.qualifier;
39475                         if (qualifier) {
39476                             if (ts.isIdentifier(qualifier)) {
39477                                 qualifier = ts.factory.updateIdentifier(qualifier, typeArguments);
39478                             }
39479                             else {
39480                                 qualifier = ts.factory.updateQualifiedName(qualifier, qualifier.left, ts.factory.updateIdentifier(qualifier.right, typeArguments));
39481                             }
39482                         }
39483                         typeArguments = ref.typeArguments;
39484                         var ids = getAccessStack(ref);
39485                         for (var _i = 0, ids_1 = ids; _i < ids_1.length; _i++) {
39486                             var id = ids_1[_i];
39487                             qualifier = qualifier ? ts.factory.createQualifiedName(qualifier, id) : id;
39488                         }
39489                         return ts.factory.updateImportTypeNode(root, root.argument, qualifier, typeArguments, root.isTypeOf);
39490                     }
39491                     else {
39492                         var typeArguments = root.typeArguments;
39493                         var typeName = root.typeName;
39494                         if (ts.isIdentifier(typeName)) {
39495                             typeName = ts.factory.updateIdentifier(typeName, typeArguments);
39496                         }
39497                         else {
39498                             typeName = ts.factory.updateQualifiedName(typeName, typeName.left, ts.factory.updateIdentifier(typeName.right, typeArguments));
39499                         }
39500                         typeArguments = ref.typeArguments;
39501                         var ids = getAccessStack(ref);
39502                         for (var _a = 0, ids_2 = ids; _a < ids_2.length; _a++) {
39503                             var id = ids_2[_a];
39504                             typeName = ts.factory.createQualifiedName(typeName, id);
39505                         }
39506                         return ts.factory.updateTypeReferenceNode(root, typeName, typeArguments);
39507                     }
39508                 }
39509                 function getAccessStack(ref) {
39510                     var state = ref.typeName;
39511                     var ids = [];
39512                     while (!ts.isIdentifier(state)) {
39513                         ids.unshift(state.right);
39514                         state = state.left;
39515                     }
39516                     ids.unshift(state);
39517                     return ids;
39518                 }
39519                 function createTypeNodesFromResolvedType(resolvedType) {
39520                     if (checkTruncationLength(context)) {
39521                         return [ts.factory.createPropertySignature(undefined, "...", undefined, undefined)];
39522                     }
39523                     var typeElements = [];
39524                     for (var _i = 0, _a = resolvedType.callSignatures; _i < _a.length; _i++) {
39525                         var signature = _a[_i];
39526                         typeElements.push(signatureToSignatureDeclarationHelper(signature, 169, context));
39527                     }
39528                     for (var _b = 0, _c = resolvedType.constructSignatures; _b < _c.length; _b++) {
39529                         var signature = _c[_b];
39530                         if (signature.flags & 4)
39531                             continue;
39532                         typeElements.push(signatureToSignatureDeclarationHelper(signature, 170, context));
39533                     }
39534                     if (resolvedType.stringIndexInfo) {
39535                         var indexSignature = void 0;
39536                         if (resolvedType.objectFlags & 2048) {
39537                             indexSignature = indexInfoToIndexSignatureDeclarationHelper(createIndexInfo(anyType, resolvedType.stringIndexInfo.isReadonly, resolvedType.stringIndexInfo.declaration), 0, context, createElidedInformationPlaceholder(context));
39538                         }
39539                         else {
39540                             indexSignature = indexInfoToIndexSignatureDeclarationHelper(resolvedType.stringIndexInfo, 0, context, undefined);
39541                         }
39542                         typeElements.push(indexSignature);
39543                     }
39544                     if (resolvedType.numberIndexInfo) {
39545                         typeElements.push(indexInfoToIndexSignatureDeclarationHelper(resolvedType.numberIndexInfo, 1, context, undefined));
39546                     }
39547                     var properties = resolvedType.properties;
39548                     if (!properties) {
39549                         return typeElements;
39550                     }
39551                     var i = 0;
39552                     for (var _d = 0, properties_1 = properties; _d < properties_1.length; _d++) {
39553                         var propertySymbol = properties_1[_d];
39554                         i++;
39555                         if (context.flags & 2048) {
39556                             if (propertySymbol.flags & 4194304) {
39557                                 continue;
39558                             }
39559                             if (ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & (8 | 16) && context.tracker.reportPrivateInBaseOfClassExpression) {
39560                                 context.tracker.reportPrivateInBaseOfClassExpression(ts.unescapeLeadingUnderscores(propertySymbol.escapedName));
39561                             }
39562                         }
39563                         if (checkTruncationLength(context) && (i + 2 < properties.length - 1)) {
39564                             typeElements.push(ts.factory.createPropertySignature(undefined, "... " + (properties.length - i) + " more ...", undefined, undefined));
39565                             addPropertyToElementList(properties[properties.length - 1], context, typeElements);
39566                             break;
39567                         }
39568                         addPropertyToElementList(propertySymbol, context, typeElements);
39569                     }
39570                     return typeElements.length ? typeElements : undefined;
39571                 }
39572             }
39573             function createElidedInformationPlaceholder(context) {
39574                 context.approximateLength += 3;
39575                 if (!(context.flags & 1)) {
39576                     return ts.factory.createTypeReferenceNode(ts.factory.createIdentifier("..."), undefined);
39577                 }
39578                 return ts.factory.createKeywordTypeNode(128);
39579             }
39580             function addPropertyToElementList(propertySymbol, context, typeElements) {
39581                 var propertyIsReverseMapped = !!(ts.getCheckFlags(propertySymbol) & 8192);
39582                 var propertyType = propertyIsReverseMapped && context.flags & 33554432 ?
39583                     anyType : getTypeOfSymbol(propertySymbol);
39584                 var saveEnclosingDeclaration = context.enclosingDeclaration;
39585                 context.enclosingDeclaration = undefined;
39586                 if (context.tracker.trackSymbol && ts.getCheckFlags(propertySymbol) & 4096 && isLateBoundName(propertySymbol.escapedName)) {
39587                     var decl = ts.first(propertySymbol.declarations);
39588                     if (hasLateBindableName(decl)) {
39589                         if (ts.isBinaryExpression(decl)) {
39590                             var name = ts.getNameOfDeclaration(decl);
39591                             if (name && ts.isElementAccessExpression(name) && ts.isPropertyAccessEntityNameExpression(name.argumentExpression)) {
39592                                 trackComputedName(name.argumentExpression, saveEnclosingDeclaration, context);
39593                             }
39594                         }
39595                         else {
39596                             trackComputedName(decl.name.expression, saveEnclosingDeclaration, context);
39597                         }
39598                     }
39599                 }
39600                 context.enclosingDeclaration = saveEnclosingDeclaration;
39601                 var propertyName = getPropertyNameNodeForSymbol(propertySymbol, context);
39602                 context.approximateLength += (ts.symbolName(propertySymbol).length + 1);
39603                 var optionalToken = propertySymbol.flags & 16777216 ? ts.factory.createToken(57) : undefined;
39604                 if (propertySymbol.flags & (16 | 8192) && !getPropertiesOfObjectType(propertyType).length && !isReadonlySymbol(propertySymbol)) {
39605                     var signatures = getSignaturesOfType(filterType(propertyType, function (t) { return !(t.flags & 32768); }), 0);
39606                     for (var _i = 0, signatures_1 = signatures; _i < signatures_1.length; _i++) {
39607                         var signature = signatures_1[_i];
39608                         var methodDeclaration = signatureToSignatureDeclarationHelper(signature, 164, context, { name: propertyName, questionToken: optionalToken });
39609                         typeElements.push(preserveCommentsOn(methodDeclaration));
39610                     }
39611                 }
39612                 else {
39613                     var savedFlags = context.flags;
39614                     context.flags |= propertyIsReverseMapped ? 33554432 : 0;
39615                     var propertyTypeNode = void 0;
39616                     if (propertyIsReverseMapped && !!(savedFlags & 33554432)) {
39617                         propertyTypeNode = createElidedInformationPlaceholder(context);
39618                     }
39619                     else {
39620                         propertyTypeNode = propertyType ? serializeTypeForDeclaration(context, propertyType, propertySymbol, saveEnclosingDeclaration) : ts.factory.createKeywordTypeNode(128);
39621                     }
39622                     context.flags = savedFlags;
39623                     var modifiers = isReadonlySymbol(propertySymbol) ? [ts.factory.createToken(142)] : undefined;
39624                     if (modifiers) {
39625                         context.approximateLength += 9;
39626                     }
39627                     var propertySignature = ts.factory.createPropertySignature(modifiers, propertyName, optionalToken, propertyTypeNode);
39628                     typeElements.push(preserveCommentsOn(propertySignature));
39629                 }
39630                 function preserveCommentsOn(node) {
39631                     if (ts.some(propertySymbol.declarations, function (d) { return d.kind === 333; })) {
39632                         var d = ts.find(propertySymbol.declarations, function (d) { return d.kind === 333; });
39633                         var commentText = d.comment;
39634                         if (commentText) {
39635                             ts.setSyntheticLeadingComments(node, [{ kind: 3, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]);
39636                         }
39637                     }
39638                     else if (propertySymbol.valueDeclaration) {
39639                         ts.setCommentRange(node, propertySymbol.valueDeclaration);
39640                     }
39641                     return node;
39642                 }
39643             }
39644             function mapToTypeNodes(types, context, isBareList) {
39645                 if (ts.some(types)) {
39646                     if (checkTruncationLength(context)) {
39647                         if (!isBareList) {
39648                             return [ts.factory.createTypeReferenceNode("...", undefined)];
39649                         }
39650                         else if (types.length > 2) {
39651                             return [
39652                                 typeToTypeNodeHelper(types[0], context),
39653                                 ts.factory.createTypeReferenceNode("... " + (types.length - 2) + " more ...", undefined),
39654                                 typeToTypeNodeHelper(types[types.length - 1], context)
39655                             ];
39656                         }
39657                     }
39658                     var mayHaveNameCollisions = !(context.flags & 64);
39659                     var seenNames = mayHaveNameCollisions ? ts.createUnderscoreEscapedMultiMap() : undefined;
39660                     var result_4 = [];
39661                     var i = 0;
39662                     for (var _i = 0, types_2 = types; _i < types_2.length; _i++) {
39663                         var type = types_2[_i];
39664                         i++;
39665                         if (checkTruncationLength(context) && (i + 2 < types.length - 1)) {
39666                             result_4.push(ts.factory.createTypeReferenceNode("... " + (types.length - i) + " more ...", undefined));
39667                             var typeNode_1 = typeToTypeNodeHelper(types[types.length - 1], context);
39668                             if (typeNode_1) {
39669                                 result_4.push(typeNode_1);
39670                             }
39671                             break;
39672                         }
39673                         context.approximateLength += 2;
39674                         var typeNode = typeToTypeNodeHelper(type, context);
39675                         if (typeNode) {
39676                             result_4.push(typeNode);
39677                             if (seenNames && ts.isIdentifierTypeReference(typeNode)) {
39678                                 seenNames.add(typeNode.typeName.escapedText, [type, result_4.length - 1]);
39679                             }
39680                         }
39681                     }
39682                     if (seenNames) {
39683                         var saveContextFlags = context.flags;
39684                         context.flags |= 64;
39685                         seenNames.forEach(function (types) {
39686                             if (!ts.arrayIsHomogeneous(types, function (_a, _b) {
39687                                 var a = _a[0];
39688                                 var b = _b[0];
39689                                 return typesAreSameReference(a, b);
39690                             })) {
39691                                 for (var _i = 0, types_3 = types; _i < types_3.length; _i++) {
39692                                     var _a = types_3[_i], type = _a[0], resultIndex = _a[1];
39693                                     result_4[resultIndex] = typeToTypeNodeHelper(type, context);
39694                                 }
39695                             }
39696                         });
39697                         context.flags = saveContextFlags;
39698                     }
39699                     return result_4;
39700                 }
39701             }
39702             function typesAreSameReference(a, b) {
39703                 return a === b
39704                     || !!a.symbol && a.symbol === b.symbol
39705                     || !!a.aliasSymbol && a.aliasSymbol === b.aliasSymbol;
39706             }
39707             function indexInfoToIndexSignatureDeclarationHelper(indexInfo, kind, context, typeNode) {
39708                 var name = ts.getNameFromIndexInfo(indexInfo) || "x";
39709                 var indexerTypeNode = ts.factory.createKeywordTypeNode(kind === 0 ? 147 : 144);
39710                 var indexingParameter = ts.factory.createParameterDeclaration(undefined, undefined, undefined, name, undefined, indexerTypeNode, undefined);
39711                 if (!typeNode) {
39712                     typeNode = typeToTypeNodeHelper(indexInfo.type || anyType, context);
39713                 }
39714                 if (!indexInfo.type && !(context.flags & 2097152)) {
39715                     context.encounteredError = true;
39716                 }
39717                 context.approximateLength += (name.length + 4);
39718                 return ts.factory.createIndexSignature(undefined, indexInfo.isReadonly ? [ts.factory.createToken(142)] : undefined, [indexingParameter], typeNode);
39719             }
39720             function signatureToSignatureDeclarationHelper(signature, kind, context, options) {
39721                 var _a, _b, _c, _d;
39722                 var suppressAny = context.flags & 256;
39723                 if (suppressAny)
39724                     context.flags &= ~256;
39725                 var typeParameters;
39726                 var typeArguments;
39727                 if (context.flags & 32 && signature.target && signature.mapper && signature.target.typeParameters) {
39728                     typeArguments = signature.target.typeParameters.map(function (parameter) { return typeToTypeNodeHelper(instantiateType(parameter, signature.mapper), context); });
39729                 }
39730                 else {
39731                     typeParameters = signature.typeParameters && signature.typeParameters.map(function (parameter) { return typeParameterToDeclaration(parameter, context); });
39732                 }
39733                 var expandedParams = getExpandedParameters(signature, true)[0];
39734                 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); });
39735                 if (signature.thisParameter) {
39736                     var thisParameter = symbolToParameterDeclaration(signature.thisParameter, context);
39737                     parameters.unshift(thisParameter);
39738                 }
39739                 var returnTypeNode;
39740                 var typePredicate = getTypePredicateOfSignature(signature);
39741                 if (typePredicate) {
39742                     var assertsModifier = typePredicate.kind === 2 || typePredicate.kind === 3 ?
39743                         ts.factory.createToken(127) :
39744                         undefined;
39745                     var parameterName = typePredicate.kind === 1 || typePredicate.kind === 3 ?
39746                         ts.setEmitFlags(ts.factory.createIdentifier(typePredicate.parameterName), 16777216) :
39747                         ts.factory.createThisTypeNode();
39748                     var typeNode = typePredicate.type && typeToTypeNodeHelper(typePredicate.type, context);
39749                     returnTypeNode = ts.factory.createTypePredicateNode(assertsModifier, parameterName, typeNode);
39750                 }
39751                 else {
39752                     var returnType = getReturnTypeOfSignature(signature);
39753                     if (returnType && !(suppressAny && isTypeAny(returnType))) {
39754                         returnTypeNode = serializeReturnTypeForSignature(context, returnType, signature, options === null || options === void 0 ? void 0 : options.privateSymbolVisitor, options === null || options === void 0 ? void 0 : options.bundledImports);
39755                     }
39756                     else if (!suppressAny) {
39757                         returnTypeNode = ts.factory.createKeywordTypeNode(128);
39758                     }
39759                 }
39760                 var modifiers = options === null || options === void 0 ? void 0 : options.modifiers;
39761                 if ((kind === 175) && signature.flags & 4) {
39762                     var flags = ts.modifiersToFlags(modifiers);
39763                     modifiers = ts.factory.createModifiersFromModifierFlags(flags | 128);
39764                 }
39765                 context.approximateLength += 3;
39766                 var node = kind === 169 ? ts.factory.createCallSignature(typeParameters, parameters, returnTypeNode) :
39767                     kind === 170 ? ts.factory.createConstructSignature(typeParameters, parameters, returnTypeNode) :
39768                         kind === 164 ? ts.factory.createMethodSignature(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) :
39769                             kind === 165 ? ts.factory.createMethodDeclaration(undefined, 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) :
39770                                 kind === 166 ? ts.factory.createConstructorDeclaration(undefined, modifiers, parameters, undefined) :
39771                                     kind === 167 ? ts.factory.createGetAccessorDeclaration(undefined, modifiers, (_c = options === null || options === void 0 ? void 0 : options.name) !== null && _c !== void 0 ? _c : ts.factory.createIdentifier(""), parameters, returnTypeNode, undefined) :
39772                                         kind === 168 ? ts.factory.createSetAccessorDeclaration(undefined, modifiers, (_d = options === null || options === void 0 ? void 0 : options.name) !== null && _d !== void 0 ? _d : ts.factory.createIdentifier(""), parameters, undefined) :
39773                                             kind === 171 ? ts.factory.createIndexSignature(undefined, modifiers, parameters, returnTypeNode) :
39774                                                 kind === 308 ? ts.factory.createJSDocFunctionType(parameters, returnTypeNode) :
39775                                                     kind === 174 ? ts.factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) :
39776                                                         kind === 175 ? ts.factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode !== null && returnTypeNode !== void 0 ? returnTypeNode : ts.factory.createTypeReferenceNode(ts.factory.createIdentifier(""))) :
39777                                                             kind === 251 ? ts.factory.createFunctionDeclaration(undefined, modifiers, undefined, (options === null || options === void 0 ? void 0 : options.name) ? ts.cast(options.name, ts.isIdentifier) : ts.factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, undefined) :
39778                                                                 kind === 208 ? ts.factory.createFunctionExpression(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([])) :
39779                                                                     kind === 209 ? ts.factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, undefined, ts.factory.createBlock([])) :
39780                                                                         ts.Debug.assertNever(kind);
39781                 if (typeArguments) {
39782                     node.typeArguments = ts.factory.createNodeArray(typeArguments);
39783                 }
39784                 return node;
39785             }
39786             function typeParameterToDeclarationWithConstraint(type, context, constraintNode) {
39787                 var savedContextFlags = context.flags;
39788                 context.flags &= ~512;
39789                 var name = typeParameterToName(type, context);
39790                 var defaultParameter = getDefaultFromTypeParameter(type);
39791                 var defaultParameterNode = defaultParameter && typeToTypeNodeHelper(defaultParameter, context);
39792                 context.flags = savedContextFlags;
39793                 return ts.factory.createTypeParameterDeclaration(name, constraintNode, defaultParameterNode);
39794             }
39795             function typeParameterToDeclaration(type, context, constraint) {
39796                 if (constraint === void 0) { constraint = getConstraintOfTypeParameter(type); }
39797                 var constraintNode = constraint && typeToTypeNodeHelper(constraint, context);
39798                 return typeParameterToDeclarationWithConstraint(type, context, constraintNode);
39799             }
39800             function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) {
39801                 var parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 160);
39802                 if (!parameterDeclaration && !ts.isTransientSymbol(parameterSymbol)) {
39803                     parameterDeclaration = ts.getDeclarationOfKind(parameterSymbol, 326);
39804                 }
39805                 var parameterType = getTypeOfSymbol(parameterSymbol);
39806                 if (parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration)) {
39807                     parameterType = getOptionalType(parameterType);
39808                 }
39809                 if ((context.flags & 1073741824) && parameterDeclaration && !ts.isJSDocParameterTag(parameterDeclaration) && isOptionalUninitializedParameter(parameterDeclaration)) {
39810                     parameterType = getTypeWithFacts(parameterType, 524288);
39811                 }
39812                 var parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports);
39813                 var modifiers = !(context.flags & 8192) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(ts.factory.cloneNode) : undefined;
39814                 var isRest = parameterDeclaration && ts.isRestParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 32768;
39815                 var dotDotDotToken = isRest ? ts.factory.createToken(25) : undefined;
39816                 var name = parameterDeclaration ? parameterDeclaration.name ?
39817                     parameterDeclaration.name.kind === 78 ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name), 16777216) :
39818                         parameterDeclaration.name.kind === 157 ? ts.setEmitFlags(ts.factory.cloneNode(parameterDeclaration.name.right), 16777216) :
39819                             cloneBindingName(parameterDeclaration.name) :
39820                     ts.symbolName(parameterSymbol) :
39821                     ts.symbolName(parameterSymbol);
39822                 var isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || ts.getCheckFlags(parameterSymbol) & 16384;
39823                 var questionToken = isOptional ? ts.factory.createToken(57) : undefined;
39824                 var parameterNode = ts.factory.createParameterDeclaration(undefined, modifiers, dotDotDotToken, name, questionToken, parameterTypeNode, undefined);
39825                 context.approximateLength += ts.symbolName(parameterSymbol).length + 3;
39826                 return parameterNode;
39827                 function cloneBindingName(node) {
39828                     return elideInitializerAndSetEmitFlags(node);
39829                     function elideInitializerAndSetEmitFlags(node) {
39830                         if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) {
39831                             trackComputedName(node.expression, context.enclosingDeclaration, context);
39832                         }
39833                         var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, undefined, elideInitializerAndSetEmitFlags);
39834                         if (ts.isBindingElement(visited)) {
39835                             visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name, undefined);
39836                         }
39837                         if (!ts.nodeIsSynthesized(visited)) {
39838                             visited = ts.factory.cloneNode(visited);
39839                         }
39840                         return ts.setEmitFlags(visited, 1 | 16777216);
39841                     }
39842                 }
39843             }
39844             function trackComputedName(accessExpression, enclosingDeclaration, context) {
39845                 if (!context.tracker.trackSymbol)
39846                     return;
39847                 var firstIdentifier = ts.getFirstIdentifier(accessExpression);
39848                 var name = resolveName(firstIdentifier, firstIdentifier.escapedText, 111551 | 1048576, undefined, undefined, true);
39849                 if (name) {
39850                     context.tracker.trackSymbol(name, enclosingDeclaration, 111551);
39851                 }
39852             }
39853             function lookupSymbolChain(symbol, context, meaning, yieldModuleSymbol) {
39854                 context.tracker.trackSymbol(symbol, context.enclosingDeclaration, meaning);
39855                 return lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol);
39856             }
39857             function lookupSymbolChainWorker(symbol, context, meaning, yieldModuleSymbol) {
39858                 var chain;
39859                 var isTypeParameter = symbol.flags & 262144;
39860                 if (!isTypeParameter && (context.enclosingDeclaration || context.flags & 64) && !(context.flags & 134217728)) {
39861                     chain = ts.Debug.checkDefined(getSymbolChain(symbol, meaning, true));
39862                     ts.Debug.assert(chain && chain.length > 0);
39863                 }
39864                 else {
39865                     chain = [symbol];
39866                 }
39867                 return chain;
39868                 function getSymbolChain(symbol, meaning, endOfChain) {
39869                     var accessibleSymbolChain = getAccessibleSymbolChain(symbol, context.enclosingDeclaration, meaning, !!(context.flags & 128));
39870                     var parentSpecifiers;
39871                     if (!accessibleSymbolChain ||
39872                         needsQualification(accessibleSymbolChain[0], context.enclosingDeclaration, accessibleSymbolChain.length === 1 ? meaning : getQualifiedLeftMeaning(meaning))) {
39873                         var parents_1 = getContainersOfSymbol(accessibleSymbolChain ? accessibleSymbolChain[0] : symbol, context.enclosingDeclaration, meaning);
39874                         if (ts.length(parents_1)) {
39875                             parentSpecifiers = parents_1.map(function (symbol) {
39876                                 return ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)
39877                                     ? getSpecifierForModuleSymbol(symbol, context)
39878                                     : undefined;
39879                             });
39880                             var indices = parents_1.map(function (_, i) { return i; });
39881                             indices.sort(sortByBestName);
39882                             var sortedParents = indices.map(function (i) { return parents_1[i]; });
39883                             for (var _i = 0, sortedParents_1 = sortedParents; _i < sortedParents_1.length; _i++) {
39884                                 var parent = sortedParents_1[_i];
39885                                 var parentChain = getSymbolChain(parent, getQualifiedLeftMeaning(meaning), false);
39886                                 if (parentChain) {
39887                                     if (parent.exports && parent.exports.get("export=") &&
39888                                         getSymbolIfSameReference(parent.exports.get("export="), symbol)) {
39889                                         accessibleSymbolChain = parentChain;
39890                                         break;
39891                                     }
39892                                     accessibleSymbolChain = parentChain.concat(accessibleSymbolChain || [getAliasForSymbolInContainer(parent, symbol) || symbol]);
39893                                     break;
39894                                 }
39895                             }
39896                         }
39897                     }
39898                     if (accessibleSymbolChain) {
39899                         return accessibleSymbolChain;
39900                     }
39901                     if (endOfChain ||
39902                         !(symbol.flags & (2048 | 4096))) {
39903                         if (!endOfChain && !yieldModuleSymbol && !!ts.forEach(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
39904                             return;
39905                         }
39906                         return [symbol];
39907                     }
39908                     function sortByBestName(a, b) {
39909                         var specifierA = parentSpecifiers[a];
39910                         var specifierB = parentSpecifiers[b];
39911                         if (specifierA && specifierB) {
39912                             var isBRelative = ts.pathIsRelative(specifierB);
39913                             if (ts.pathIsRelative(specifierA) === isBRelative) {
39914                                 return ts.moduleSpecifiers.countPathComponents(specifierA) - ts.moduleSpecifiers.countPathComponents(specifierB);
39915                             }
39916                             if (isBRelative) {
39917                                 return -1;
39918                             }
39919                             return 1;
39920                         }
39921                         return 0;
39922                     }
39923                 }
39924             }
39925             function typeParametersToTypeParameterDeclarations(symbol, context) {
39926                 var typeParameterNodes;
39927                 var targetSymbol = getTargetSymbol(symbol);
39928                 if (targetSymbol.flags & (32 | 64 | 524288)) {
39929                     typeParameterNodes = ts.factory.createNodeArray(ts.map(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol), function (tp) { return typeParameterToDeclaration(tp, context); }));
39930                 }
39931                 return typeParameterNodes;
39932             }
39933             function lookupTypeParameterNodes(chain, index, context) {
39934                 var _a;
39935                 ts.Debug.assert(chain && 0 <= index && index < chain.length);
39936                 var symbol = chain[index];
39937                 var symbolId = getSymbolId(symbol);
39938                 if ((_a = context.typeParameterSymbolList) === null || _a === void 0 ? void 0 : _a.has(symbolId)) {
39939                     return undefined;
39940                 }
39941                 (context.typeParameterSymbolList || (context.typeParameterSymbolList = new ts.Set())).add(symbolId);
39942                 var typeParameterNodes;
39943                 if (context.flags & 512 && index < (chain.length - 1)) {
39944                     var parentSymbol = symbol;
39945                     var nextSymbol_1 = chain[index + 1];
39946                     if (ts.getCheckFlags(nextSymbol_1) & 1) {
39947                         var params = getTypeParametersOfClassOrInterface(parentSymbol.flags & 2097152 ? resolveAlias(parentSymbol) : parentSymbol);
39948                         typeParameterNodes = mapToTypeNodes(ts.map(params, function (t) { return getMappedType(t, nextSymbol_1.mapper); }), context);
39949                     }
39950                     else {
39951                         typeParameterNodes = typeParametersToTypeParameterDeclarations(symbol, context);
39952                     }
39953                 }
39954                 return typeParameterNodes;
39955             }
39956             function getTopmostIndexedAccessType(top) {
39957                 if (ts.isIndexedAccessTypeNode(top.objectType)) {
39958                     return getTopmostIndexedAccessType(top.objectType);
39959                 }
39960                 return top;
39961             }
39962             function getSpecifierForModuleSymbol(symbol, context) {
39963                 var _a;
39964                 var file = ts.getDeclarationOfKind(symbol, 297);
39965                 if (!file) {
39966                     var equivalentFileSymbol = ts.firstDefined(symbol.declarations, function (d) { return getFileSymbolIfFileSymbolExportEqualsContainer(d, symbol); });
39967                     if (equivalentFileSymbol) {
39968                         file = ts.getDeclarationOfKind(equivalentFileSymbol, 297);
39969                     }
39970                 }
39971                 if (file && file.moduleName !== undefined) {
39972                     return file.moduleName;
39973                 }
39974                 if (!file) {
39975                     if (context.tracker.trackReferencedAmbientModule) {
39976                         var ambientDecls = ts.filter(symbol.declarations, ts.isAmbientModule);
39977                         if (ts.length(ambientDecls)) {
39978                             for (var _i = 0, ambientDecls_1 = ambientDecls; _i < ambientDecls_1.length; _i++) {
39979                                 var decl = ambientDecls_1[_i];
39980                                 context.tracker.trackReferencedAmbientModule(decl, symbol);
39981                             }
39982                         }
39983                     }
39984                     if (ambientModuleSymbolRegex.test(symbol.escapedName)) {
39985                         return symbol.escapedName.substring(1, symbol.escapedName.length - 1);
39986                     }
39987                 }
39988                 if (!context.enclosingDeclaration || !context.tracker.moduleResolverHost) {
39989                     if (ambientModuleSymbolRegex.test(symbol.escapedName)) {
39990                         return symbol.escapedName.substring(1, symbol.escapedName.length - 1);
39991                     }
39992                     return ts.getSourceFileOfNode(ts.getNonAugmentationDeclaration(symbol)).fileName;
39993                 }
39994                 var contextFile = ts.getSourceFileOfNode(ts.getOriginalNode(context.enclosingDeclaration));
39995                 var links = getSymbolLinks(symbol);
39996                 var specifier = links.specifierCache && links.specifierCache.get(contextFile.path);
39997                 if (!specifier) {
39998                     var isBundle_1 = !!ts.outFile(compilerOptions);
39999                     var moduleResolverHost = context.tracker.moduleResolverHost;
40000                     var specifierCompilerOptions = isBundle_1 ? __assign(__assign({}, compilerOptions), { baseUrl: moduleResolverHost.getCommonSourceDirectory() }) : compilerOptions;
40001                     specifier = ts.first(ts.moduleSpecifiers.getModuleSpecifiers(symbol, checker, specifierCompilerOptions, contextFile, moduleResolverHost, { importModuleSpecifierPreference: isBundle_1 ? "non-relative" : "relative", importModuleSpecifierEnding: isBundle_1 ? "minimal" : undefined }));
40002                     (_a = links.specifierCache) !== null && _a !== void 0 ? _a : (links.specifierCache = new ts.Map());
40003                     links.specifierCache.set(contextFile.path, specifier);
40004                 }
40005                 return specifier;
40006             }
40007             function symbolToTypeNode(symbol, context, meaning, overrideTypeArguments) {
40008                 var chain = lookupSymbolChain(symbol, context, meaning, !(context.flags & 16384));
40009                 var isTypeOf = meaning === 111551;
40010                 if (ts.some(chain[0].declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
40011                     var nonRootParts = chain.length > 1 ? createAccessFromSymbolChain(chain, chain.length - 1, 1) : undefined;
40012                     var typeParameterNodes = overrideTypeArguments || lookupTypeParameterNodes(chain, 0, context);
40013                     var specifier = getSpecifierForModuleSymbol(chain[0], context);
40014                     if (!(context.flags & 67108864) && ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs && specifier.indexOf("/node_modules/") >= 0) {
40015                         context.encounteredError = true;
40016                         if (context.tracker.reportLikelyUnsafeImportRequiredError) {
40017                             context.tracker.reportLikelyUnsafeImportRequiredError(specifier);
40018                         }
40019                     }
40020                     var lit = ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(specifier));
40021                     if (context.tracker.trackExternalModuleSymbolOfImportTypeNode)
40022                         context.tracker.trackExternalModuleSymbolOfImportTypeNode(chain[0]);
40023                     context.approximateLength += specifier.length + 10;
40024                     if (!nonRootParts || ts.isEntityName(nonRootParts)) {
40025                         if (nonRootParts) {
40026                             var lastId = ts.isIdentifier(nonRootParts) ? nonRootParts : nonRootParts.right;
40027                             lastId.typeArguments = undefined;
40028                         }
40029                         return ts.factory.createImportTypeNode(lit, nonRootParts, typeParameterNodes, isTypeOf);
40030                     }
40031                     else {
40032                         var splitNode = getTopmostIndexedAccessType(nonRootParts);
40033                         var qualifier = splitNode.objectType.typeName;
40034                         return ts.factory.createIndexedAccessTypeNode(ts.factory.createImportTypeNode(lit, qualifier, typeParameterNodes, isTypeOf), splitNode.indexType);
40035                     }
40036                 }
40037                 var entityName = createAccessFromSymbolChain(chain, chain.length - 1, 0);
40038                 if (ts.isIndexedAccessTypeNode(entityName)) {
40039                     return entityName;
40040                 }
40041                 if (isTypeOf) {
40042                     return ts.factory.createTypeQueryNode(entityName);
40043                 }
40044                 else {
40045                     var lastId = ts.isIdentifier(entityName) ? entityName : entityName.right;
40046                     var lastTypeArgs = lastId.typeArguments;
40047                     lastId.typeArguments = undefined;
40048                     return ts.factory.createTypeReferenceNode(entityName, lastTypeArgs);
40049                 }
40050                 function createAccessFromSymbolChain(chain, index, stopper) {
40051                     var typeParameterNodes = index === (chain.length - 1) ? overrideTypeArguments : lookupTypeParameterNodes(chain, index, context);
40052                     var symbol = chain[index];
40053                     var parent = chain[index - 1];
40054                     var symbolName;
40055                     if (index === 0) {
40056                         context.flags |= 16777216;
40057                         symbolName = getNameOfSymbolAsWritten(symbol, context);
40058                         context.approximateLength += (symbolName ? symbolName.length : 0) + 1;
40059                         context.flags ^= 16777216;
40060                     }
40061                     else {
40062                         if (parent && getExportsOfSymbol(parent)) {
40063                             var exports_1 = getExportsOfSymbol(parent);
40064                             ts.forEachEntry(exports_1, function (ex, name) {
40065                                 if (getSymbolIfSameReference(ex, symbol) && !isLateBoundName(name) && name !== "export=") {
40066                                     symbolName = ts.unescapeLeadingUnderscores(name);
40067                                     return true;
40068                                 }
40069                             });
40070                         }
40071                     }
40072                     if (!symbolName) {
40073                         symbolName = getNameOfSymbolAsWritten(symbol, context);
40074                     }
40075                     context.approximateLength += symbolName.length + 1;
40076                     if (!(context.flags & 16) && parent &&
40077                         getMembersOfSymbol(parent) && getMembersOfSymbol(parent).get(symbol.escapedName) &&
40078                         getSymbolIfSameReference(getMembersOfSymbol(parent).get(symbol.escapedName), symbol)) {
40079                         var LHS = createAccessFromSymbolChain(chain, index - 1, stopper);
40080                         if (ts.isIndexedAccessTypeNode(LHS)) {
40081                             return ts.factory.createIndexedAccessTypeNode(LHS, ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(symbolName)));
40082                         }
40083                         else {
40084                             return ts.factory.createIndexedAccessTypeNode(ts.factory.createTypeReferenceNode(LHS, typeParameterNodes), ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(symbolName)));
40085                         }
40086                     }
40087                     var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216);
40088                     identifier.symbol = symbol;
40089                     if (index > stopper) {
40090                         var LHS = createAccessFromSymbolChain(chain, index - 1, stopper);
40091                         if (!ts.isEntityName(LHS)) {
40092                             return ts.Debug.fail("Impossible construct - an export of an indexed access cannot be reachable");
40093                         }
40094                         return ts.factory.createQualifiedName(LHS, identifier);
40095                     }
40096                     return identifier;
40097                 }
40098             }
40099             function typeParameterShadowsNameInScope(escapedName, context, type) {
40100                 var result = resolveName(context.enclosingDeclaration, escapedName, 788968, undefined, escapedName, false);
40101                 if (result) {
40102                     if (result.flags & 262144 && result === type.symbol) {
40103                         return false;
40104                     }
40105                     return true;
40106                 }
40107                 return false;
40108             }
40109             function typeParameterToName(type, context) {
40110                 var _a;
40111                 if (context.flags & 4 && context.typeParameterNames) {
40112                     var cached = context.typeParameterNames.get(getTypeId(type));
40113                     if (cached) {
40114                         return cached;
40115                     }
40116                 }
40117                 var result = symbolToName(type.symbol, context, 788968, true);
40118                 if (!(result.kind & 78)) {
40119                     return ts.factory.createIdentifier("(Missing type parameter)");
40120                 }
40121                 if (context.flags & 4) {
40122                     var rawtext = result.escapedText;
40123                     var i = 0;
40124                     var text = rawtext;
40125                     while (((_a = context.typeParameterNamesByText) === null || _a === void 0 ? void 0 : _a.has(text)) || typeParameterShadowsNameInScope(text, context, type)) {
40126                         i++;
40127                         text = rawtext + "_" + i;
40128                     }
40129                     if (text !== rawtext) {
40130                         result = ts.factory.createIdentifier(text, result.typeArguments);
40131                     }
40132                     (context.typeParameterNames || (context.typeParameterNames = new ts.Map())).set(getTypeId(type), result);
40133                     (context.typeParameterNamesByText || (context.typeParameterNamesByText = new ts.Set())).add(result.escapedText);
40134                 }
40135                 return result;
40136             }
40137             function symbolToName(symbol, context, meaning, expectsIdentifier) {
40138                 var chain = lookupSymbolChain(symbol, context, meaning);
40139                 if (expectsIdentifier && chain.length !== 1
40140                     && !context.encounteredError
40141                     && !(context.flags & 65536)) {
40142                     context.encounteredError = true;
40143                 }
40144                 return createEntityNameFromSymbolChain(chain, chain.length - 1);
40145                 function createEntityNameFromSymbolChain(chain, index) {
40146                     var typeParameterNodes = lookupTypeParameterNodes(chain, index, context);
40147                     var symbol = chain[index];
40148                     if (index === 0) {
40149                         context.flags |= 16777216;
40150                     }
40151                     var symbolName = getNameOfSymbolAsWritten(symbol, context);
40152                     if (index === 0) {
40153                         context.flags ^= 16777216;
40154                     }
40155                     var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216);
40156                     identifier.symbol = symbol;
40157                     return index > 0 ? ts.factory.createQualifiedName(createEntityNameFromSymbolChain(chain, index - 1), identifier) : identifier;
40158                 }
40159             }
40160             function symbolToExpression(symbol, context, meaning) {
40161                 var chain = lookupSymbolChain(symbol, context, meaning);
40162                 return createExpressionFromSymbolChain(chain, chain.length - 1);
40163                 function createExpressionFromSymbolChain(chain, index) {
40164                     var typeParameterNodes = lookupTypeParameterNodes(chain, index, context);
40165                     var symbol = chain[index];
40166                     if (index === 0) {
40167                         context.flags |= 16777216;
40168                     }
40169                     var symbolName = getNameOfSymbolAsWritten(symbol, context);
40170                     if (index === 0) {
40171                         context.flags ^= 16777216;
40172                     }
40173                     var firstChar = symbolName.charCodeAt(0);
40174                     if (ts.isSingleOrDoubleQuote(firstChar) && ts.some(symbol.declarations, hasNonGlobalAugmentationExternalModuleSymbol)) {
40175                         return ts.factory.createStringLiteral(getSpecifierForModuleSymbol(symbol, context));
40176                     }
40177                     var canUsePropertyAccess = firstChar === 35 ?
40178                         symbolName.length > 1 && ts.isIdentifierStart(symbolName.charCodeAt(1), languageVersion) :
40179                         ts.isIdentifierStart(firstChar, languageVersion);
40180                     if (index === 0 || canUsePropertyAccess) {
40181                         var identifier = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216);
40182                         identifier.symbol = symbol;
40183                         return index > 0 ? ts.factory.createPropertyAccessExpression(createExpressionFromSymbolChain(chain, index - 1), identifier) : identifier;
40184                     }
40185                     else {
40186                         if (firstChar === 91) {
40187                             symbolName = symbolName.substring(1, symbolName.length - 1);
40188                             firstChar = symbolName.charCodeAt(0);
40189                         }
40190                         var expression = void 0;
40191                         if (ts.isSingleOrDoubleQuote(firstChar)) {
40192                             expression = ts.factory.createStringLiteral(symbolName
40193                                 .substring(1, symbolName.length - 1)
40194                                 .replace(/\\./g, function (s) { return s.substring(1); }), firstChar === 39);
40195                         }
40196                         else if (("" + +symbolName) === symbolName) {
40197                             expression = ts.factory.createNumericLiteral(+symbolName);
40198                         }
40199                         if (!expression) {
40200                             expression = ts.setEmitFlags(ts.factory.createIdentifier(symbolName, typeParameterNodes), 16777216);
40201                             expression.symbol = symbol;
40202                         }
40203                         return ts.factory.createElementAccessExpression(createExpressionFromSymbolChain(chain, index - 1), expression);
40204                     }
40205                 }
40206             }
40207             function isStringNamed(d) {
40208                 var name = ts.getNameOfDeclaration(d);
40209                 return !!name && ts.isStringLiteral(name);
40210             }
40211             function isSingleQuotedStringNamed(d) {
40212                 var name = ts.getNameOfDeclaration(d);
40213                 return !!(name && ts.isStringLiteral(name) && (name.singleQuote || !ts.nodeIsSynthesized(name) && ts.startsWith(ts.getTextOfNode(name, false), "'")));
40214             }
40215             function getPropertyNameNodeForSymbol(symbol, context) {
40216                 var singleQuote = !!ts.length(symbol.declarations) && ts.every(symbol.declarations, isSingleQuotedStringNamed);
40217                 var fromNameType = getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote);
40218                 if (fromNameType) {
40219                     return fromNameType;
40220                 }
40221                 if (ts.isKnownSymbol(symbol)) {
40222                     return ts.factory.createComputedPropertyName(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier("Symbol"), symbol.escapedName.substr(3)));
40223                 }
40224                 var rawName = ts.unescapeLeadingUnderscores(symbol.escapedName);
40225                 var stringNamed = !!ts.length(symbol.declarations) && ts.every(symbol.declarations, isStringNamed);
40226                 return createPropertyNameNodeForIdentifierOrLiteral(rawName, stringNamed, singleQuote);
40227             }
40228             function getPropertyNameNodeForSymbolFromNameType(symbol, context, singleQuote) {
40229                 var nameType = getSymbolLinks(symbol).nameType;
40230                 if (nameType) {
40231                     if (nameType.flags & 384) {
40232                         var name = "" + nameType.value;
40233                         if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) {
40234                             return ts.factory.createStringLiteral(name, !!singleQuote);
40235                         }
40236                         if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
40237                             return ts.factory.createComputedPropertyName(ts.factory.createNumericLiteral(+name));
40238                         }
40239                         return createPropertyNameNodeForIdentifierOrLiteral(name);
40240                     }
40241                     if (nameType.flags & 8192) {
40242                         return ts.factory.createComputedPropertyName(symbolToExpression(nameType.symbol, context, 111551));
40243                     }
40244                 }
40245             }
40246             function createPropertyNameNodeForIdentifierOrLiteral(name, stringNamed, singleQuote) {
40247                 return ts.isIdentifierText(name, compilerOptions.target) ? ts.factory.createIdentifier(name) :
40248                     !stringNamed && isNumericLiteralName(name) && +name >= 0 ? ts.factory.createNumericLiteral(+name) :
40249                         ts.factory.createStringLiteral(name, !!singleQuote);
40250             }
40251             function cloneNodeBuilderContext(context) {
40252                 var initial = __assign({}, context);
40253                 if (initial.typeParameterNames) {
40254                     initial.typeParameterNames = new ts.Map(initial.typeParameterNames);
40255                 }
40256                 if (initial.typeParameterNamesByText) {
40257                     initial.typeParameterNamesByText = new ts.Set(initial.typeParameterNamesByText);
40258                 }
40259                 if (initial.typeParameterSymbolList) {
40260                     initial.typeParameterSymbolList = new ts.Set(initial.typeParameterSymbolList);
40261                 }
40262                 return initial;
40263             }
40264             function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) {
40265                 return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); });
40266             }
40267             function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) {
40268                 return !(ts.getObjectFlags(type) & 4) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
40269             }
40270             function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) {
40271                 if (type !== errorType && enclosingDeclaration) {
40272                     var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration);
40273                     if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) {
40274                         var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation);
40275                         if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
40276                             var result_5 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
40277                             if (result_5) {
40278                                 return result_5;
40279                             }
40280                         }
40281                     }
40282                 }
40283                 var oldFlags = context.flags;
40284                 if (type.flags & 8192 &&
40285                     type.symbol === symbol && (!context.enclosingDeclaration || ts.some(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration); }))) {
40286                     context.flags |= 1048576;
40287                 }
40288                 var result = typeToTypeNodeHelper(type, context);
40289                 context.flags = oldFlags;
40290                 return result;
40291             }
40292             function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) {
40293                 if (type !== errorType && context.enclosingDeclaration) {
40294                     var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
40295                     if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) {
40296                         var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled);
40297                         if (result) {
40298                             return result;
40299                         }
40300                     }
40301                 }
40302                 return typeToTypeNodeHelper(type, context);
40303             }
40304             function trackExistingEntityName(node, context, includePrivateSymbol) {
40305                 var _a, _b;
40306                 var introducesError = false;
40307                 var leftmost = ts.getFirstIdentifier(node);
40308                 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)))) {
40309                     introducesError = true;
40310                     return { introducesError: introducesError, node: node };
40311                 }
40312                 var sym = resolveEntityName(leftmost, 67108863, true, true);
40313                 if (sym) {
40314                     if (isSymbolAccessible(sym, context.enclosingDeclaration, 67108863, false).accessibility !== 0) {
40315                         introducesError = true;
40316                     }
40317                     else {
40318                         (_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);
40319                         includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym);
40320                     }
40321                     if (ts.isIdentifier(node)) {
40322                         var name = sym.flags & 262144 ? typeParameterToName(getDeclaredTypeOfSymbol(sym), context) : ts.factory.cloneNode(node);
40323                         name.symbol = sym;
40324                         return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216) };
40325                     }
40326                 }
40327                 return { introducesError: introducesError, node: node };
40328             }
40329             function serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled) {
40330                 if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
40331                     cancellationToken.throwIfCancellationRequested();
40332                 }
40333                 var hadError = false;
40334                 var file = ts.getSourceFileOfNode(existing);
40335                 var transformed = ts.visitNode(existing, visitExistingNodeTreeSymbols);
40336                 if (hadError) {
40337                     return undefined;
40338                 }
40339                 return transformed === existing ? ts.setTextRange(ts.factory.cloneNode(existing), existing) : transformed;
40340                 function visitExistingNodeTreeSymbols(node) {
40341                     if (ts.isJSDocAllType(node) || node.kind === 310) {
40342                         return ts.factory.createKeywordTypeNode(128);
40343                     }
40344                     if (ts.isJSDocUnknownType(node)) {
40345                         return ts.factory.createKeywordTypeNode(152);
40346                     }
40347                     if (ts.isJSDocNullableType(node)) {
40348                         return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createLiteralTypeNode(ts.factory.createNull())]);
40349                     }
40350                     if (ts.isJSDocOptionalType(node)) {
40351                         return ts.factory.createUnionTypeNode([ts.visitNode(node.type, visitExistingNodeTreeSymbols), ts.factory.createKeywordTypeNode(150)]);
40352                     }
40353                     if (ts.isJSDocNonNullableType(node)) {
40354                         return ts.visitNode(node.type, visitExistingNodeTreeSymbols);
40355                     }
40356                     if (ts.isJSDocVariadicType(node)) {
40357                         return ts.factory.createArrayTypeNode(ts.visitNode(node.type, visitExistingNodeTreeSymbols));
40358                     }
40359                     if (ts.isJSDocTypeLiteral(node)) {
40360                         return ts.factory.createTypeLiteralNode(ts.map(node.jsDocPropertyTags, function (t) {
40361                             var name = ts.isIdentifier(t.name) ? t.name : t.name.right;
40362                             var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText);
40363                             var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined;
40364                             return ts.factory.createPropertySignature(undefined, name, t.isBracketed || 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));
40365                         }));
40366                     }
40367                     if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") {
40368                         return ts.setOriginalNode(ts.factory.createKeywordTypeNode(128), node);
40369                     }
40370                     if ((ts.isExpressionWithTypeArguments(node) || ts.isTypeReferenceNode(node)) && ts.isJSDocIndexSignature(node)) {
40371                         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))]);
40372                     }
40373                     if (ts.isJSDocFunctionType(node)) {
40374                         if (ts.isJSDocConstructSignature(node)) {
40375                             var newTypeNode_1;
40376                             return ts.factory.createConstructorTypeNode(node.modifiers, 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));
40377                         }
40378                         else {
40379                             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));
40380                         }
40381                     }
40382                     if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (!existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(node, getTypeFromTypeNode(node)) || getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968, true))) {
40383                         return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
40384                     }
40385                     if (ts.isLiteralImportTypeNode(node)) {
40386                         var nodeSymbol = getNodeLinks(node).resolvedSymbol;
40387                         if (ts.isInJSDoc(node) &&
40388                             nodeSymbol &&
40389                             ((!node.isTypeOf && !(nodeSymbol.flags & 788968)) ||
40390                                 !(ts.length(node.typeArguments) >= getMinTypeArgumentCount(getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(nodeSymbol))))) {
40391                             return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node);
40392                         }
40393                         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);
40394                     }
40395                     if (ts.isEntityName(node) || ts.isEntityNameExpression(node)) {
40396                         var _a = trackExistingEntityName(node, context, includePrivateSymbol), introducesError = _a.introducesError, result = _a.node;
40397                         hadError = hadError || introducesError;
40398                         if (result !== node) {
40399                             return result;
40400                         }
40401                     }
40402                     if (file && ts.isTupleTypeNode(node) && (ts.getLineAndCharacterOfPosition(file, node.pos).line === ts.getLineAndCharacterOfPosition(file, node.end).line)) {
40403                         ts.setEmitFlags(node, 1);
40404                     }
40405                     return ts.visitEachChild(node, visitExistingNodeTreeSymbols, ts.nullTransformationContext);
40406                     function getEffectiveDotDotDotForParameter(p) {
40407                         return p.dotDotDotToken || (p.type && ts.isJSDocVariadicType(p.type) ? ts.factory.createToken(25) : undefined);
40408                     }
40409                     function getNameForJSDocFunctionParameter(p, index) {
40410                         return p.name && ts.isIdentifier(p.name) && p.name.escapedText === "this" ? "this"
40411                             : getEffectiveDotDotDotForParameter(p) ? "args"
40412                                 : "arg" + index;
40413                     }
40414                     function rewriteModuleSpecifier(parent, lit) {
40415                         if (bundled) {
40416                             if (context.tracker && context.tracker.moduleResolverHost) {
40417                                 var targetFile = getExternalModuleFileFromDeclaration(parent);
40418                                 if (targetFile) {
40419                                     var getCanonicalFileName = ts.createGetCanonicalFileName(!!host.useCaseSensitiveFileNames);
40420                                     var resolverHost = {
40421                                         getCanonicalFileName: getCanonicalFileName,
40422                                         getCurrentDirectory: function () { return context.tracker.moduleResolverHost.getCurrentDirectory(); },
40423                                         getCommonSourceDirectory: function () { return context.tracker.moduleResolverHost.getCommonSourceDirectory(); }
40424                                     };
40425                                     var newName = ts.getResolvedExternalModuleName(resolverHost, targetFile);
40426                                     return ts.factory.createStringLiteral(newName);
40427                                 }
40428                             }
40429                         }
40430                         else {
40431                             if (context.tracker && context.tracker.trackExternalModuleSymbolOfImportTypeNode) {
40432                                 var moduleSym = resolveExternalModuleNameWorker(lit, lit, undefined);
40433                                 if (moduleSym) {
40434                                     context.tracker.trackExternalModuleSymbolOfImportTypeNode(moduleSym);
40435                                 }
40436                             }
40437                         }
40438                         return lit;
40439                     }
40440                 }
40441             }
40442             function symbolTableToDeclarationStatements(symbolTable, context, bundled) {
40443                 var serializePropertySymbolForClass = makeSerializePropertySymbol(ts.factory.createPropertyDeclaration, 165, true);
40444                 var serializePropertySymbolForInterfaceWorker = makeSerializePropertySymbol(function (_decorators, mods, name, question, type) { return ts.factory.createPropertySignature(mods, name, question, type); }, 164, false);
40445                 var enclosingDeclaration = context.enclosingDeclaration;
40446                 var results = [];
40447                 var visitedSymbols = new ts.Set();
40448                 var deferredPrivatesStack = [];
40449                 var oldcontext = context;
40450                 context = __assign(__assign({}, oldcontext), { usedSymbolNames: new ts.Set(oldcontext.usedSymbolNames), remappedSymbolNames: new ts.Map(), tracker: __assign(__assign({}, oldcontext.tracker), { trackSymbol: function (sym, decl, meaning) {
40451                             var accessibleResult = isSymbolAccessible(sym, decl, meaning, false);
40452                             if (accessibleResult.accessibility === 0) {
40453                                 var chain = lookupSymbolChainWorker(sym, context, meaning);
40454                                 if (!(sym.flags & 4)) {
40455                                     includePrivateSymbol(chain[0]);
40456                                 }
40457                             }
40458                             else if (oldcontext.tracker && oldcontext.tracker.trackSymbol) {
40459                                 oldcontext.tracker.trackSymbol(sym, decl, meaning);
40460                             }
40461                         } }) });
40462                 ts.forEachEntry(symbolTable, function (symbol, name) {
40463                     var baseName = ts.unescapeLeadingUnderscores(name);
40464                     void getInternalSymbolName(symbol, baseName);
40465                 });
40466                 var addingDeclare = !bundled;
40467                 var exportEquals = symbolTable.get("export=");
40468                 if (exportEquals && symbolTable.size > 1 && exportEquals.flags & 2097152) {
40469                     symbolTable = ts.createSymbolTable();
40470                     symbolTable.set("export=", exportEquals);
40471                 }
40472                 visitSymbolTable(symbolTable);
40473                 return mergeRedundantStatements(results);
40474                 function isIdentifierAndNotUndefined(node) {
40475                     return !!node && node.kind === 78;
40476                 }
40477                 function getNamesOfDeclaration(statement) {
40478                     if (ts.isVariableStatement(statement)) {
40479                         return ts.filter(ts.map(statement.declarationList.declarations, ts.getNameOfDeclaration), isIdentifierAndNotUndefined);
40480                     }
40481                     return ts.filter([ts.getNameOfDeclaration(statement)], isIdentifierAndNotUndefined);
40482                 }
40483                 function flattenExportAssignedNamespace(statements) {
40484                     var exportAssignment = ts.find(statements, ts.isExportAssignment);
40485                     var nsIndex = ts.findIndex(statements, ts.isModuleDeclaration);
40486                     var ns = nsIndex !== -1 ? statements[nsIndex] : undefined;
40487                     if (ns && exportAssignment && exportAssignment.isExportEquals &&
40488                         ts.isIdentifier(exportAssignment.expression) && ts.isIdentifier(ns.name) && ts.idText(ns.name) === ts.idText(exportAssignment.expression) &&
40489                         ns.body && ts.isModuleBlock(ns.body)) {
40490                         var excessExports = ts.filter(statements, function (s) { return !!(ts.getEffectiveModifierFlags(s) & 1); });
40491                         var name_2 = ns.name;
40492                         var body = ns.body;
40493                         if (ts.length(excessExports)) {
40494                             ns = ts.factory.updateModuleDeclaration(ns, ns.decorators, ns.modifiers, ns.name, body = ts.factory.updateModuleBlock(body, ts.factory.createNodeArray(__spreadArray(__spreadArray([], 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)]))));
40495                             statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, nsIndex)), [ns]), statements.slice(nsIndex + 1));
40496                         }
40497                         if (!ts.find(statements, function (s) { return s !== ns && ts.nodeHasName(s, name_2); })) {
40498                             results = [];
40499                             var mixinExportFlag_1 = !ts.some(body.statements, function (s) { return ts.hasSyntacticModifier(s, 1) || ts.isExportAssignment(s) || ts.isExportDeclaration(s); });
40500                             ts.forEach(body.statements, function (s) {
40501                                 addResult(s, mixinExportFlag_1 ? 1 : 0);
40502                             });
40503                             statements = __spreadArray(__spreadArray([], ts.filter(statements, function (s) { return s !== ns && s !== exportAssignment; })), results);
40504                         }
40505                     }
40506                     return statements;
40507                 }
40508                 function mergeExportDeclarations(statements) {
40509                     var exports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause && ts.isNamedExports(d.exportClause); });
40510                     if (ts.length(exports) > 1) {
40511                         var nonExports = ts.filter(statements, function (d) { return !ts.isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause; });
40512                         statements = __spreadArray(__spreadArray([], nonExports), [ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports(ts.flatMap(exports, function (e) { return ts.cast(e.exportClause, ts.isNamedExports).elements; })), undefined)]);
40513                     }
40514                     var reexports = ts.filter(statements, function (d) { return ts.isExportDeclaration(d) && !!d.moduleSpecifier && !!d.exportClause && ts.isNamedExports(d.exportClause); });
40515                     if (ts.length(reexports) > 1) {
40516                         var groups = ts.group(reexports, function (decl) { return ts.isStringLiteral(decl.moduleSpecifier) ? ">" + decl.moduleSpecifier.text : ">"; });
40517                         if (groups.length !== reexports.length) {
40518                             var _loop_9 = function (group_1) {
40519                                 if (group_1.length > 1) {
40520                                     statements = __spreadArray(__spreadArray([], ts.filter(statements, function (s) { return group_1.indexOf(s) === -1; })), [
40521                                         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)
40522                                     ]);
40523                                 }
40524                             };
40525                             for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
40526                                 var group_1 = groups_1[_i];
40527                                 _loop_9(group_1);
40528                             }
40529                         }
40530                     }
40531                     return statements;
40532                 }
40533                 function inlineExportModifiers(statements) {
40534                     var index = ts.findIndex(statements, function (d) { return ts.isExportDeclaration(d) && !d.moduleSpecifier && !!d.exportClause && ts.isNamedExports(d.exportClause); });
40535                     if (index >= 0) {
40536                         var exportDecl = statements[index];
40537                         var replacements = ts.mapDefined(exportDecl.exportClause.elements, function (e) {
40538                             if (!e.propertyName) {
40539                                 var indices = ts.indicesOf(statements);
40540                                 var associatedIndices = ts.filter(indices, function (i) { return ts.nodeHasName(statements[i], e.name); });
40541                                 if (ts.length(associatedIndices) && ts.every(associatedIndices, function (i) { return canHaveExportModifier(statements[i]); })) {
40542                                     for (var _i = 0, associatedIndices_1 = associatedIndices; _i < associatedIndices_1.length; _i++) {
40543                                         var index_1 = associatedIndices_1[_i];
40544                                         statements[index_1] = addExportModifier(statements[index_1]);
40545                                     }
40546                                     return undefined;
40547                                 }
40548                             }
40549                             return e;
40550                         });
40551                         if (!ts.length(replacements)) {
40552                             ts.orderedRemoveItemAt(statements, index);
40553                         }
40554                         else {
40555                             statements[index] = ts.factory.updateExportDeclaration(exportDecl, exportDecl.decorators, exportDecl.modifiers, exportDecl.isTypeOnly, ts.factory.updateNamedExports(exportDecl.exportClause, replacements), exportDecl.moduleSpecifier);
40556                         }
40557                     }
40558                     return statements;
40559                 }
40560                 function mergeRedundantStatements(statements) {
40561                     statements = flattenExportAssignedNamespace(statements);
40562                     statements = mergeExportDeclarations(statements);
40563                     statements = inlineExportModifiers(statements);
40564                     if (enclosingDeclaration &&
40565                         ((ts.isSourceFile(enclosingDeclaration) && ts.isExternalOrCommonJsModule(enclosingDeclaration)) || ts.isModuleDeclaration(enclosingDeclaration)) &&
40566                         (!ts.some(statements, ts.isExternalModuleIndicator) || (!ts.hasScopeMarker(statements) && ts.some(statements, ts.needsScopeMarker)))) {
40567                         statements.push(ts.createEmptyExports(ts.factory));
40568                     }
40569                     return statements;
40570                 }
40571                 function canHaveExportModifier(node) {
40572                     return ts.isEnumDeclaration(node) ||
40573                         ts.isVariableStatement(node) ||
40574                         ts.isFunctionDeclaration(node) ||
40575                         ts.isClassDeclaration(node) ||
40576                         (ts.isModuleDeclaration(node) && !ts.isExternalModuleAugmentation(node) && !ts.isGlobalScopeAugmentation(node)) ||
40577                         ts.isInterfaceDeclaration(node) ||
40578                         isTypeDeclaration(node);
40579                 }
40580                 function addExportModifier(node) {
40581                     var flags = (ts.getEffectiveModifierFlags(node) | 1) & ~2;
40582                     return ts.factory.updateModifiers(node, flags);
40583                 }
40584                 function removeExportModifier(node) {
40585                     var flags = ts.getEffectiveModifierFlags(node) & ~1;
40586                     return ts.factory.updateModifiers(node, flags);
40587                 }
40588                 function visitSymbolTable(symbolTable, suppressNewPrivateContext, propertyAsAlias) {
40589                     if (!suppressNewPrivateContext) {
40590                         deferredPrivatesStack.push(new ts.Map());
40591                     }
40592                     symbolTable.forEach(function (symbol) {
40593                         serializeSymbol(symbol, false, !!propertyAsAlias);
40594                     });
40595                     if (!suppressNewPrivateContext) {
40596                         deferredPrivatesStack[deferredPrivatesStack.length - 1].forEach(function (symbol) {
40597                             serializeSymbol(symbol, true, !!propertyAsAlias);
40598                         });
40599                         deferredPrivatesStack.pop();
40600                     }
40601                 }
40602                 function serializeSymbol(symbol, isPrivate, propertyAsAlias) {
40603                     var visitedSym = getMergedSymbol(symbol);
40604                     if (visitedSymbols.has(getSymbolId(visitedSym))) {
40605                         return;
40606                     }
40607                     visitedSymbols.add(getSymbolId(visitedSym));
40608                     var skipMembershipCheck = !isPrivate;
40609                     if (skipMembershipCheck || (!!ts.length(symbol.declarations) && ts.some(symbol.declarations, function (d) { return !!ts.findAncestor(d, function (n) { return n === enclosingDeclaration; }); }))) {
40610                         var oldContext = context;
40611                         context = cloneNodeBuilderContext(context);
40612                         var result = serializeSymbolWorker(symbol, isPrivate, propertyAsAlias);
40613                         context = oldContext;
40614                         return result;
40615                     }
40616                 }
40617                 function serializeSymbolWorker(symbol, isPrivate, propertyAsAlias) {
40618                     var symbolName = ts.unescapeLeadingUnderscores(symbol.escapedName);
40619                     var isDefault = symbol.escapedName === "default";
40620                     if (isPrivate && !(context.flags & 131072) && ts.isStringANonContextualKeyword(symbolName) && !isDefault) {
40621                         context.encounteredError = true;
40622                         return;
40623                     }
40624                     var needsPostExportDefault = isDefault && !!(symbol.flags & -113
40625                         || (symbol.flags & 16 && ts.length(getPropertiesOfType(getTypeOfSymbol(symbol))))) && !(symbol.flags & 2097152);
40626                     var needsExportDeclaration = !needsPostExportDefault && !isPrivate && ts.isStringANonContextualKeyword(symbolName) && !isDefault;
40627                     if (needsPostExportDefault || needsExportDeclaration) {
40628                         isPrivate = true;
40629                     }
40630                     var modifierFlags = (!isPrivate ? 1 : 0) | (isDefault && !needsPostExportDefault ? 512 : 0);
40631                     var isConstMergedWithNS = symbol.flags & 1536 &&
40632                         symbol.flags & (2 | 1 | 4) &&
40633                         symbol.escapedName !== "export=";
40634                     var isConstMergedWithNSPrintableAsSignatureMerge = isConstMergedWithNS && isTypeRepresentableAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol);
40635                     if (symbol.flags & (16 | 8192) || isConstMergedWithNSPrintableAsSignatureMerge) {
40636                         serializeAsFunctionNamespaceMerge(getTypeOfSymbol(symbol), symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
40637                     }
40638                     if (symbol.flags & 524288) {
40639                         serializeTypeAlias(symbol, symbolName, modifierFlags);
40640                     }
40641                     if (symbol.flags & (2 | 1 | 4)
40642                         && symbol.escapedName !== "export="
40643                         && !(symbol.flags & 4194304)
40644                         && !(symbol.flags & 32)
40645                         && !isConstMergedWithNSPrintableAsSignatureMerge) {
40646                         if (propertyAsAlias) {
40647                             var createdExport = serializeMaybeAliasAssignment(symbol);
40648                             if (createdExport) {
40649                                 needsExportDeclaration = false;
40650                                 needsPostExportDefault = false;
40651                             }
40652                         }
40653                         else {
40654                             var type = getTypeOfSymbol(symbol);
40655                             var localName = getInternalSymbolName(symbol, symbolName);
40656                             if (!(symbol.flags & 16) && isTypeRepresentableAsFunctionNamespaceMerge(type, symbol)) {
40657                                 serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags);
40658                             }
40659                             else {
40660                                 var flags = !(symbol.flags & 2) ? undefined
40661                                     : isConstVariable(symbol) ? 2
40662                                         : 1;
40663                                 var name = (needsPostExportDefault || !(symbol.flags & 4)) ? localName : getUnusedName(localName, symbol);
40664                                 var textRange = symbol.declarations && ts.find(symbol.declarations, function (d) { return ts.isVariableDeclaration(d); });
40665                                 if (textRange && ts.isVariableDeclarationList(textRange.parent) && textRange.parent.declarations.length === 1) {
40666                                     textRange = textRange.parent.parent;
40667                                 }
40668                                 var propertyAccessRequire = ts.find(symbol.declarations, ts.isPropertyAccessExpression);
40669                                 if (propertyAccessRequire && ts.isBinaryExpression(propertyAccessRequire.parent) && ts.isIdentifier(propertyAccessRequire.parent.right)
40670                                     && type.symbol && ts.isSourceFile(type.symbol.valueDeclaration)) {
40671                                     var alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right;
40672                                     addResult(ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(alias, localName)])), 0);
40673                                     context.tracker.trackSymbol(type.symbol, context.enclosingDeclaration, 111551);
40674                                 }
40675                                 else {
40676                                     var statement = ts.setTextRange(ts.factory.createVariableStatement(undefined, ts.factory.createVariableDeclarationList([
40677                                         ts.factory.createVariableDeclaration(name, undefined, serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled))
40678                                     ], flags)), textRange);
40679                                     addResult(statement, name !== localName ? modifierFlags & ~1 : modifierFlags);
40680                                     if (name !== localName && !isPrivate) {
40681                                         addResult(ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(name, localName)])), 0);
40682                                         needsExportDeclaration = false;
40683                                         needsPostExportDefault = false;
40684                                     }
40685                                 }
40686                             }
40687                         }
40688                     }
40689                     if (symbol.flags & 384) {
40690                         serializeEnum(symbol, symbolName, modifierFlags);
40691                     }
40692                     if (symbol.flags & 32) {
40693                         if (symbol.flags & 4 && ts.isBinaryExpression(symbol.valueDeclaration.parent) && ts.isClassExpression(symbol.valueDeclaration.parent.right)) {
40694                             serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
40695                         }
40696                         else {
40697                             serializeAsClass(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
40698                         }
40699                     }
40700                     if ((symbol.flags & (512 | 1024) && (!isConstMergedWithNS || isTypeOnlyNamespace(symbol))) || isConstMergedWithNSPrintableAsSignatureMerge) {
40701                         serializeModule(symbol, symbolName, modifierFlags);
40702                     }
40703                     if (symbol.flags & 64 && !(symbol.flags & 32)) {
40704                         serializeInterface(symbol, symbolName, modifierFlags);
40705                     }
40706                     if (symbol.flags & 2097152) {
40707                         serializeAsAlias(symbol, getInternalSymbolName(symbol, symbolName), modifierFlags);
40708                     }
40709                     if (symbol.flags & 4 && symbol.escapedName === "export=") {
40710                         serializeMaybeAliasAssignment(symbol);
40711                     }
40712                     if (symbol.flags & 8388608) {
40713                         for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
40714                             var node = _a[_i];
40715                             var resolvedModule = resolveExternalModuleName(node, node.moduleSpecifier);
40716                             if (!resolvedModule)
40717                                 continue;
40718                             addResult(ts.factory.createExportDeclaration(undefined, undefined, false, undefined, ts.factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), 0);
40719                         }
40720                     }
40721                     if (needsPostExportDefault) {
40722                         addResult(ts.factory.createExportAssignment(undefined, undefined, false, ts.factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), 0);
40723                     }
40724                     else if (needsExportDeclaration) {
40725                         addResult(ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(getInternalSymbolName(symbol, symbolName), symbolName)])), 0);
40726                     }
40727                 }
40728                 function includePrivateSymbol(symbol) {
40729                     if (ts.some(symbol.declarations, ts.isParameterDeclaration))
40730                         return;
40731                     ts.Debug.assertIsDefined(deferredPrivatesStack[deferredPrivatesStack.length - 1]);
40732                     getUnusedName(ts.unescapeLeadingUnderscores(symbol.escapedName), symbol);
40733                     var isExternalImportAlias = !!(symbol.flags & 2097152) && !ts.some(symbol.declarations, function (d) {
40734                         return !!ts.findAncestor(d, ts.isExportDeclaration) ||
40735                             ts.isNamespaceExport(d) ||
40736                             (ts.isImportEqualsDeclaration(d) && !ts.isExternalModuleReference(d.moduleReference));
40737                     });
40738                     deferredPrivatesStack[isExternalImportAlias ? 0 : (deferredPrivatesStack.length - 1)].set(getSymbolId(symbol), symbol);
40739                 }
40740                 function isExportingScope(enclosingDeclaration) {
40741                     return ((ts.isSourceFile(enclosingDeclaration) && (ts.isExternalOrCommonJsModule(enclosingDeclaration) || ts.isJsonSourceFile(enclosingDeclaration))) ||
40742                         (ts.isAmbientModule(enclosingDeclaration) && !ts.isGlobalScopeAugmentation(enclosingDeclaration)));
40743                 }
40744                 function addResult(node, additionalModifierFlags) {
40745                     if (ts.canHaveModifiers(node)) {
40746                         var newModifierFlags = 0;
40747                         var enclosingDeclaration_1 = context.enclosingDeclaration &&
40748                             (ts.isJSDocTypeAlias(context.enclosingDeclaration) ? ts.getSourceFileOfNode(context.enclosingDeclaration) : context.enclosingDeclaration);
40749                         if (additionalModifierFlags & 1 &&
40750                             enclosingDeclaration_1 && (isExportingScope(enclosingDeclaration_1) || ts.isModuleDeclaration(enclosingDeclaration_1)) &&
40751                             canHaveExportModifier(node)) {
40752                             newModifierFlags |= 1;
40753                         }
40754                         if (addingDeclare && !(newModifierFlags & 1) &&
40755                             (!enclosingDeclaration_1 || !(enclosingDeclaration_1.flags & 8388608)) &&
40756                             (ts.isEnumDeclaration(node) || ts.isVariableStatement(node) || ts.isFunctionDeclaration(node) || ts.isClassDeclaration(node) || ts.isModuleDeclaration(node))) {
40757                             newModifierFlags |= 2;
40758                         }
40759                         if ((additionalModifierFlags & 512) && (ts.isClassDeclaration(node) || ts.isInterfaceDeclaration(node) || ts.isFunctionDeclaration(node))) {
40760                             newModifierFlags |= 512;
40761                         }
40762                         if (newModifierFlags) {
40763                             node = ts.factory.updateModifiers(node, newModifierFlags | ts.getEffectiveModifierFlags(node));
40764                         }
40765                     }
40766                     results.push(node);
40767                 }
40768                 function serializeTypeAlias(symbol, symbolName, modifierFlags) {
40769                     var aliasType = getDeclaredTypeOfTypeAlias(symbol);
40770                     var typeParams = getSymbolLinks(symbol).typeParameters;
40771                     var typeParamDecls = ts.map(typeParams, function (p) { return typeParameterToDeclaration(p, context); });
40772                     var jsdocAliasDecl = ts.find(symbol.declarations, ts.isJSDocTypeAlias);
40773                     var commentText = jsdocAliasDecl ? jsdocAliasDecl.comment || jsdocAliasDecl.parent.comment : undefined;
40774                     var oldFlags = context.flags;
40775                     context.flags |= 8388608;
40776                     var oldEnclosingDecl = context.enclosingDeclaration;
40777                     context.enclosingDeclaration = jsdocAliasDecl;
40778                     var typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression
40779                         && ts.isJSDocTypeExpression(jsdocAliasDecl.typeExpression)
40780                         && serializeExistingTypeNode(context, jsdocAliasDecl.typeExpression.type, includePrivateSymbol, bundled)
40781                         || typeToTypeNodeHelper(aliasType, context);
40782                     addResult(ts.setSyntheticLeadingComments(ts.factory.createTypeAliasDeclaration(undefined, undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: 3, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }]), modifierFlags);
40783                     context.flags = oldFlags;
40784                     context.enclosingDeclaration = oldEnclosingDecl;
40785                 }
40786                 function serializeInterface(symbol, symbolName, modifierFlags) {
40787                     var interfaceType = getDeclaredTypeOfClassOrInterface(symbol);
40788                     var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
40789                     var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); });
40790                     var baseTypes = getBaseTypes(interfaceType);
40791                     var baseType = ts.length(baseTypes) ? getIntersectionType(baseTypes) : undefined;
40792                     var members = ts.flatMap(getPropertiesOfType(interfaceType), function (p) { return serializePropertySymbolForInterface(p, baseType); });
40793                     var callSignatures = serializeSignatures(0, interfaceType, baseType, 169);
40794                     var constructSignatures = serializeSignatures(1, interfaceType, baseType, 170);
40795                     var indexSignatures = serializeIndexSignatures(interfaceType, baseType);
40796                     var heritageClauses = !ts.length(baseTypes) ? undefined : [ts.factory.createHeritageClause(93, ts.mapDefined(baseTypes, function (b) { return trySerializeAsTypeReference(b, 111551); }))];
40797                     addResult(ts.factory.createInterfaceDeclaration(undefined, undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures), constructSignatures), callSignatures), members)), modifierFlags);
40798                 }
40799                 function getNamespaceMembersForSerialization(symbol) {
40800                     return !symbol.exports ? [] : ts.filter(ts.arrayFrom(symbol.exports.values()), isNamespaceMember);
40801                 }
40802                 function isTypeOnlyNamespace(symbol) {
40803                     return ts.every(getNamespaceMembersForSerialization(symbol), function (m) { return !(resolveSymbol(m).flags & 111551); });
40804                 }
40805                 function serializeModule(symbol, symbolName, modifierFlags) {
40806                     var members = getNamespaceMembersForSerialization(symbol);
40807                     var locationMap = ts.arrayToMultiMap(members, function (m) { return m.parent && m.parent === symbol ? "real" : "merged"; });
40808                     var realMembers = locationMap.get("real") || ts.emptyArray;
40809                     var mergedMembers = locationMap.get("merged") || ts.emptyArray;
40810                     if (ts.length(realMembers)) {
40811                         var localName = getInternalSymbolName(symbol, symbolName);
40812                         serializeAsNamespaceDeclaration(realMembers, localName, modifierFlags, !!(symbol.flags & (16 | 67108864)));
40813                     }
40814                     if (ts.length(mergedMembers)) {
40815                         var containingFile_1 = ts.getSourceFileOfNode(context.enclosingDeclaration);
40816                         var localName = getInternalSymbolName(symbol, symbolName);
40817                         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) {
40818                                 var _a, _b;
40819                                 var name = ts.unescapeLeadingUnderscores(s.escapedName);
40820                                 var localName = getInternalSymbolName(s, name);
40821                                 var aliasDecl = s.declarations && getDeclarationOfAliasSymbol(s);
40822                                 if (containingFile_1 && (aliasDecl ? containingFile_1 !== ts.getSourceFileOfNode(aliasDecl) : !ts.some(s.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile_1; }))) {
40823                                     (_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);
40824                                     return undefined;
40825                                 }
40826                                 var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, true);
40827                                 includePrivateSymbol(target || s);
40828                                 var targetName = target ? getInternalSymbolName(target, ts.unescapeLeadingUnderscores(target.escapedName)) : localName;
40829                                 return ts.factory.createExportSpecifier(name === targetName ? undefined : targetName, name);
40830                             })))]);
40831                         addResult(ts.factory.createModuleDeclaration(undefined, undefined, ts.factory.createIdentifier(localName), nsBody, 16), 0);
40832                     }
40833                 }
40834                 function serializeEnum(symbol, symbolName, modifierFlags) {
40835                     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) {
40836                         var initializedValue = p.declarations && p.declarations[0] && ts.isEnumMember(p.declarations[0]) ? getConstantValue(p.declarations[0]) : undefined;
40837                         return ts.factory.createEnumMember(ts.unescapeLeadingUnderscores(p.escapedName), initializedValue === undefined ? undefined :
40838                             typeof initializedValue === "string" ? ts.factory.createStringLiteral(initializedValue) :
40839                                 ts.factory.createNumericLiteral(initializedValue));
40840                     })), modifierFlags);
40841                 }
40842                 function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) {
40843                     var signatures = getSignaturesOfType(type, 0);
40844                     for (var _i = 0, signatures_2 = signatures; _i < signatures_2.length; _i++) {
40845                         var sig = signatures_2[_i];
40846                         var decl = signatureToSignatureDeclarationHelper(sig, 251, context, { name: ts.factory.createIdentifier(localName), privateSymbolVisitor: includePrivateSymbol, bundledImports: bundled });
40847                         addResult(ts.setTextRange(decl, sig.declaration && ts.isVariableDeclaration(sig.declaration.parent) && sig.declaration.parent.parent || sig.declaration), modifierFlags);
40848                     }
40849                     if (!(symbol.flags & (512 | 1024) && !!symbol.exports && !!symbol.exports.size)) {
40850                         var props = ts.filter(getPropertiesOfType(type), isNamespaceMember);
40851                         serializeAsNamespaceDeclaration(props, localName, modifierFlags, true);
40852                     }
40853                 }
40854                 function serializeAsNamespaceDeclaration(props, localName, modifierFlags, suppressNewPrivateContext) {
40855                     if (ts.length(props)) {
40856                         var localVsRemoteMap = ts.arrayToMultiMap(props, function (p) {
40857                             return !ts.length(p.declarations) || ts.some(p.declarations, function (d) {
40858                                 return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(context.enclosingDeclaration);
40859                             }) ? "local" : "remote";
40860                         });
40861                         var localProps = localVsRemoteMap.get("local") || ts.emptyArray;
40862                         var fakespace = ts.parseNodeFactory.createModuleDeclaration(undefined, undefined, ts.factory.createIdentifier(localName), ts.factory.createModuleBlock([]), 16);
40863                         ts.setParent(fakespace, enclosingDeclaration);
40864                         fakespace.locals = ts.createSymbolTable(props);
40865                         fakespace.symbol = props[0].parent;
40866                         var oldResults = results;
40867                         results = [];
40868                         var oldAddingDeclare = addingDeclare;
40869                         addingDeclare = false;
40870                         var subcontext = __assign(__assign({}, context), { enclosingDeclaration: fakespace });
40871                         var oldContext = context;
40872                         context = subcontext;
40873                         visitSymbolTable(ts.createSymbolTable(localProps), suppressNewPrivateContext, true);
40874                         context = oldContext;
40875                         addingDeclare = oldAddingDeclare;
40876                         var declarations = results;
40877                         results = oldResults;
40878                         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; });
40879                         var exportModifierStripped = ts.every(defaultReplaced, function (d) { return ts.hasSyntacticModifier(d, 1); }) ? ts.map(defaultReplaced, removeExportModifier) : defaultReplaced;
40880                         fakespace = ts.factory.updateModuleDeclaration(fakespace, fakespace.decorators, fakespace.modifiers, fakespace.name, ts.factory.createModuleBlock(exportModifierStripped));
40881                         addResult(fakespace, modifierFlags);
40882                     }
40883                 }
40884                 function isNamespaceMember(p) {
40885                     return !!(p.flags & (788968 | 1920 | 2097152)) ||
40886                         !(p.flags & 4194304 || p.escapedName === "prototype" || p.valueDeclaration && ts.getEffectiveModifierFlags(p.valueDeclaration) & 32 && ts.isClassLike(p.valueDeclaration.parent));
40887                 }
40888                 function sanitizeJSDocImplements(clauses) {
40889                     var result = ts.mapDefined(clauses, function (e) {
40890                         var _a;
40891                         var oldEnclosing = context.enclosingDeclaration;
40892                         context.enclosingDeclaration = e;
40893                         var expr = e.expression;
40894                         if (ts.isEntityNameExpression(expr)) {
40895                             if (ts.isIdentifier(expr) && ts.idText(expr) === "") {
40896                                 return cleanup(undefined);
40897                             }
40898                             var introducesError = void 0;
40899                             (_a = trackExistingEntityName(expr, context, includePrivateSymbol), introducesError = _a.introducesError, expr = _a.node);
40900                             if (introducesError) {
40901                                 return cleanup(undefined);
40902                             }
40903                         }
40904                         return cleanup(ts.factory.createExpressionWithTypeArguments(expr, ts.map(e.typeArguments, function (a) {
40905                             return serializeExistingTypeNode(context, a, includePrivateSymbol, bundled)
40906                                 || typeToTypeNodeHelper(getTypeFromTypeNode(a), context);
40907                         })));
40908                         function cleanup(result) {
40909                             context.enclosingDeclaration = oldEnclosing;
40910                             return result;
40911                         }
40912                     });
40913                     if (result.length === clauses.length) {
40914                         return result;
40915                     }
40916                     return undefined;
40917                 }
40918                 function serializeAsClass(symbol, localName, modifierFlags) {
40919                     var _a;
40920                     var originalDecl = ts.find(symbol.declarations, ts.isClassLike);
40921                     var oldEnclosing = context.enclosingDeclaration;
40922                     context.enclosingDeclaration = originalDecl || oldEnclosing;
40923                     var localParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
40924                     var typeParamDecls = ts.map(localParams, function (p) { return typeParameterToDeclaration(p, context); });
40925                     var classType = getDeclaredTypeOfClassOrInterface(symbol);
40926                     var baseTypes = getBaseTypes(classType);
40927                     var originalImplements = originalDecl && ts.getEffectiveImplementsTypeNodes(originalDecl);
40928                     var implementsExpressions = originalImplements && sanitizeJSDocImplements(originalImplements)
40929                         || ts.mapDefined(getImplementsTypes(classType), serializeImplementedType);
40930                     var staticType = getTypeOfSymbol(symbol);
40931                     var isClass = !!((_a = staticType.symbol) === null || _a === void 0 ? void 0 : _a.valueDeclaration) && ts.isClassLike(staticType.symbol.valueDeclaration);
40932                     var staticBaseType = isClass
40933                         ? getBaseConstructorTypeOfClass(staticType)
40934                         : anyType;
40935                     var heritageClauses = __spreadArray(__spreadArray([], !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)]);
40936                     var symbolProps = getNonInterhitedProperties(classType, baseTypes, getPropertiesOfType(classType));
40937                     var publicSymbolProps = ts.filter(symbolProps, function (s) {
40938                         var valueDecl = s.valueDeclaration;
40939                         return valueDecl && !(ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name));
40940                     });
40941                     var hasPrivateIdentifier = ts.some(symbolProps, function (s) {
40942                         var valueDecl = s.valueDeclaration;
40943                         return valueDecl && ts.isNamedDeclaration(valueDecl) && ts.isPrivateIdentifier(valueDecl.name);
40944                     });
40945                     var privateProperties = hasPrivateIdentifier ?
40946                         [ts.factory.createPropertyDeclaration(undefined, undefined, ts.factory.createPrivateIdentifier("#private"), undefined, undefined, undefined)] :
40947                         ts.emptyArray;
40948                     var publicProperties = ts.flatMap(publicSymbolProps, function (p) { return serializePropertySymbolForClass(p, false, baseTypes[0]); });
40949                     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); });
40950                     var isNonConstructableClassLikeInJsFile = !isClass &&
40951                         !!symbol.valueDeclaration &&
40952                         ts.isInJSFile(symbol.valueDeclaration) &&
40953                         !ts.some(getSignaturesOfType(staticType, 1));
40954                     var constructors = isNonConstructableClassLikeInJsFile ?
40955                         [ts.factory.createConstructorDeclaration(undefined, ts.factory.createModifiersFromModifierFlags(8), [], undefined)] :
40956                         serializeSignatures(1, staticType, staticBaseType, 166);
40957                     var indexSignatures = serializeIndexSignatures(classType, baseTypes[0]);
40958                     context.enclosingDeclaration = oldEnclosing;
40959                     addResult(ts.setTextRange(ts.factory.createClassDeclaration(undefined, undefined, localName, typeParamDecls, heritageClauses, __spreadArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], indexSignatures), staticMembers), constructors), publicProperties), privateProperties)), symbol.declarations && ts.filter(symbol.declarations, function (d) { return ts.isClassDeclaration(d) || ts.isClassExpression(d); })[0]), modifierFlags);
40960                 }
40961                 function serializeAsAlias(symbol, localName, modifierFlags) {
40962                     var _a, _b, _c, _d, _e;
40963                     var node = getDeclarationOfAliasSymbol(symbol);
40964                     if (!node)
40965                         return ts.Debug.fail();
40966                     var target = getMergedSymbol(getTargetOfAliasDeclaration(node, true));
40967                     if (!target) {
40968                         return;
40969                     }
40970                     var verbatimTargetName = ts.unescapeLeadingUnderscores(target.escapedName);
40971                     if (verbatimTargetName === "export=" && (compilerOptions.esModuleInterop || compilerOptions.allowSyntheticDefaultImports)) {
40972                         verbatimTargetName = "default";
40973                     }
40974                     var targetName = getInternalSymbolName(target, verbatimTargetName);
40975                     includePrivateSymbol(target);
40976                     switch (node.kind) {
40977                         case 198:
40978                             if (((_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.kind) === 249) {
40979                                 var specifier_1 = getSpecifierForModuleSymbol(target.parent || target, context);
40980                                 var propertyName = node.propertyName;
40981                                 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);
40982                                 break;
40983                             }
40984                             ts.Debug.failBadSyntaxKind(((_c = node.parent) === null || _c === void 0 ? void 0 : _c.parent) || node, "Unhandled binding element grandparent kind in declaration serialization");
40985                             break;
40986                         case 289:
40987                             if (((_e = (_d = node.parent) === null || _d === void 0 ? void 0 : _d.parent) === null || _e === void 0 ? void 0 : _e.kind) === 216) {
40988                                 serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), targetName);
40989                             }
40990                             break;
40991                         case 249:
40992                             if (ts.isPropertyAccessExpression(node.initializer)) {
40993                                 var initializer = node.initializer;
40994                                 var uniqueName = ts.factory.createUniqueName(localName);
40995                                 var specifier_2 = getSpecifierForModuleSymbol(target.parent || target, context);
40996                                 addResult(ts.factory.createImportEqualsDeclaration(undefined, undefined, false, uniqueName, ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(specifier_2))), 0);
40997                                 addResult(ts.factory.createImportEqualsDeclaration(undefined, undefined, false, ts.factory.createIdentifier(localName), ts.factory.createQualifiedName(uniqueName, initializer.name)), modifierFlags);
40998                                 break;
40999                             }
41000                         case 260:
41001                             if (target.escapedName === "export=" && ts.some(target.declarations, ts.isJsonSourceFile)) {
41002                                 serializeMaybeAliasAssignment(symbol);
41003                                 break;
41004                             }
41005                             var isLocalImport = !(target.flags & 512) && !ts.isVariableDeclaration(node);
41006                             addResult(ts.factory.createImportEqualsDeclaration(undefined, undefined, false, ts.factory.createIdentifier(localName), isLocalImport
41007                                 ? symbolToName(target, context, 67108863, false)
41008                                 : ts.factory.createExternalModuleReference(ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)))), isLocalImport ? modifierFlags : 0);
41009                             break;
41010                         case 259:
41011                             addResult(ts.factory.createNamespaceExportDeclaration(ts.idText(node.name)), 0);
41012                             break;
41013                         case 262:
41014                             addResult(ts.factory.createImportDeclaration(undefined, undefined, ts.factory.createImportClause(false, ts.factory.createIdentifier(localName), undefined), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0);
41015                             break;
41016                         case 263:
41017                             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);
41018                             break;
41019                         case 269:
41020                             addResult(ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamespaceExport(ts.factory.createIdentifier(localName)), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target, context))), 0);
41021                             break;
41022                         case 265:
41023                             addResult(ts.factory.createImportDeclaration(undefined, undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports([
41024                                 ts.factory.createImportSpecifier(localName !== verbatimTargetName ? ts.factory.createIdentifier(verbatimTargetName) : undefined, ts.factory.createIdentifier(localName))
41025                             ])), ts.factory.createStringLiteral(getSpecifierForModuleSymbol(target.parent || target, context))), 0);
41026                             break;
41027                         case 270:
41028                             var specifier = node.parent.parent.moduleSpecifier;
41029                             serializeExportSpecifier(ts.unescapeLeadingUnderscores(symbol.escapedName), specifier ? verbatimTargetName : targetName, specifier && ts.isStringLiteralLike(specifier) ? ts.factory.createStringLiteral(specifier.text) : undefined);
41030                             break;
41031                         case 266:
41032                             serializeMaybeAliasAssignment(symbol);
41033                             break;
41034                         case 216:
41035                         case 201:
41036                         case 202:
41037                             if (symbol.escapedName === "default" || symbol.escapedName === "export=") {
41038                                 serializeMaybeAliasAssignment(symbol);
41039                             }
41040                             else {
41041                                 serializeExportSpecifier(localName, targetName);
41042                             }
41043                             break;
41044                         default:
41045                             return ts.Debug.failBadSyntaxKind(node, "Unhandled alias declaration kind in symbol serializer!");
41046                     }
41047                 }
41048                 function serializeExportSpecifier(localName, targetName, specifier) {
41049                     addResult(ts.factory.createExportDeclaration(undefined, undefined, false, ts.factory.createNamedExports([ts.factory.createExportSpecifier(localName !== targetName ? targetName : undefined, localName)]), specifier), 0);
41050                 }
41051                 function serializeMaybeAliasAssignment(symbol) {
41052                     if (symbol.flags & 4194304) {
41053                         return false;
41054                     }
41055                     var name = ts.unescapeLeadingUnderscores(symbol.escapedName);
41056                     var isExportEquals = name === "export=";
41057                     var isDefault = name === "default";
41058                     var isExportAssignmentCompatibleSymbolName = isExportEquals || isDefault;
41059                     var aliasDecl = symbol.declarations && getDeclarationOfAliasSymbol(symbol);
41060                     var target = aliasDecl && getTargetOfAliasDeclaration(aliasDecl, true);
41061                     if (target && ts.length(target.declarations) && ts.some(target.declarations, function (d) { return ts.getSourceFileOfNode(d) === ts.getSourceFileOfNode(enclosingDeclaration); })) {
41062                         var expr = aliasDecl && ((ts.isExportAssignment(aliasDecl) || ts.isBinaryExpression(aliasDecl)) ? ts.getExportAssignmentExpression(aliasDecl) : ts.getPropertyAssignmentAliasLikeExpression(aliasDecl));
41063                         var first_1 = expr && ts.isEntityNameExpression(expr) ? getFirstNonModuleExportsIdentifier(expr) : undefined;
41064                         var referenced = first_1 && resolveEntityName(first_1, 67108863, true, true, enclosingDeclaration);
41065                         if (referenced || target) {
41066                             includePrivateSymbol(referenced || target);
41067                         }
41068                         var oldTrack = context.tracker.trackSymbol;
41069                         context.tracker.trackSymbol = ts.noop;
41070                         if (isExportAssignmentCompatibleSymbolName) {
41071                             results.push(ts.factory.createExportAssignment(undefined, undefined, isExportEquals, symbolToExpression(target, context, 67108863)));
41072                         }
41073                         else {
41074                             if (first_1 === expr && first_1) {
41075                                 serializeExportSpecifier(name, ts.idText(first_1));
41076                             }
41077                             else if (expr && ts.isClassExpression(expr)) {
41078                                 serializeExportSpecifier(name, getInternalSymbolName(target, ts.symbolName(target)));
41079                             }
41080                             else {
41081                                 var varName = getUnusedName(name, symbol);
41082                                 addResult(ts.factory.createImportEqualsDeclaration(undefined, undefined, false, ts.factory.createIdentifier(varName), symbolToName(target, context, 67108863, false)), 0);
41083                                 serializeExportSpecifier(name, varName);
41084                             }
41085                         }
41086                         context.tracker.trackSymbol = oldTrack;
41087                         return true;
41088                     }
41089                     else {
41090                         var varName = getUnusedName(name, symbol);
41091                         var typeToSerialize = getWidenedType(getTypeOfSymbol(getMergedSymbol(symbol)));
41092                         if (isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, symbol)) {
41093                             serializeAsFunctionNamespaceMerge(typeToSerialize, symbol, varName, isExportAssignmentCompatibleSymbolName ? 0 : 1);
41094                         }
41095                         else {
41096                             var statement = ts.factory.createVariableStatement(undefined, ts.factory.createVariableDeclarationList([
41097                                 ts.factory.createVariableDeclaration(varName, undefined, serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration, includePrivateSymbol, bundled))
41098                             ], 2));
41099                             addResult(statement, target && target.flags & 4 && target.escapedName === "export=" ? 2
41100                                 : name === varName ? 1
41101                                     : 0);
41102                         }
41103                         if (isExportAssignmentCompatibleSymbolName) {
41104                             results.push(ts.factory.createExportAssignment(undefined, undefined, isExportEquals, ts.factory.createIdentifier(varName)));
41105                             return true;
41106                         }
41107                         else if (name !== varName) {
41108                             serializeExportSpecifier(name, varName);
41109                             return true;
41110                         }
41111                         return false;
41112                     }
41113                 }
41114                 function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, hostSymbol) {
41115                     var ctxSrc = ts.getSourceFileOfNode(context.enclosingDeclaration);
41116                     return ts.getObjectFlags(typeToSerialize) & (16 | 32) &&
41117                         !getIndexInfoOfType(typeToSerialize, 0) &&
41118                         !getIndexInfoOfType(typeToSerialize, 1) &&
41119                         !isClassInstanceSide(typeToSerialize) &&
41120                         !!(ts.length(ts.filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || ts.length(getSignaturesOfType(typeToSerialize, 0))) &&
41121                         !ts.length(getSignaturesOfType(typeToSerialize, 1)) &&
41122                         !getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) &&
41123                         !(typeToSerialize.symbol && ts.some(typeToSerialize.symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; })) &&
41124                         !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return isLateBoundName(p.escapedName); }) &&
41125                         !ts.some(getPropertiesOfType(typeToSerialize), function (p) { return ts.some(p.declarations, function (d) { return ts.getSourceFileOfNode(d) !== ctxSrc; }); }) &&
41126                         ts.every(getPropertiesOfType(typeToSerialize), function (p) { return ts.isIdentifierText(ts.symbolName(p), languageVersion); });
41127                 }
41128                 function makeSerializePropertySymbol(createProperty, methodKind, useAccessors) {
41129                     return function serializePropertySymbol(p, isStatic, baseType) {
41130                         var modifierFlags = ts.getDeclarationModifierFlagsFromSymbol(p);
41131                         var isPrivate = !!(modifierFlags & 8);
41132                         if (isStatic && (p.flags & (788968 | 1920 | 2097152))) {
41133                             return [];
41134                         }
41135                         if (p.flags & 4194304 ||
41136                             (baseType && getPropertyOfType(baseType, p.escapedName)
41137                                 && isReadonlySymbol(getPropertyOfType(baseType, p.escapedName)) === isReadonlySymbol(p)
41138                                 && (p.flags & 16777216) === (getPropertyOfType(baseType, p.escapedName).flags & 16777216)
41139                                 && isTypeIdenticalTo(getTypeOfSymbol(p), getTypeOfPropertyOfType(baseType, p.escapedName)))) {
41140                             return [];
41141                         }
41142                         var flag = (modifierFlags & ~256) | (isStatic ? 32 : 0);
41143                         var name = getPropertyNameNodeForSymbol(p, context);
41144                         var firstPropertyLikeDecl = ts.find(p.declarations, ts.or(ts.isPropertyDeclaration, ts.isAccessor, ts.isVariableDeclaration, ts.isPropertySignature, ts.isBinaryExpression, ts.isPropertyAccessExpression));
41145                         if (p.flags & 98304 && useAccessors) {
41146                             var result = [];
41147                             if (p.flags & 65536) {
41148                                 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));
41149                             }
41150                             if (p.flags & 32768) {
41151                                 var isPrivate_1 = modifierFlags & 8;
41152                                 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));
41153                             }
41154                             return result;
41155                         }
41156                         else if (p.flags & (4 | 3 | 98304)) {
41157                             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);
41158                         }
41159                         if (p.flags & (8192 | 16)) {
41160                             var type = getTypeOfSymbol(p);
41161                             var signatures = getSignaturesOfType(type, 0);
41162                             if (flag & 8) {
41163                                 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]);
41164                             }
41165                             var results_1 = [];
41166                             for (var _i = 0, signatures_3 = signatures; _i < signatures_3.length; _i++) {
41167                                 var sig = signatures_3[_i];
41168                                 var decl = signatureToSignatureDeclarationHelper(sig, methodKind, context, {
41169                                     name: name,
41170                                     questionToken: p.flags & 16777216 ? ts.factory.createToken(57) : undefined,
41171                                     modifiers: flag ? ts.factory.createModifiersFromModifierFlags(flag) : undefined
41172                                 });
41173                                 results_1.push(ts.setTextRange(decl, sig.declaration));
41174                             }
41175                             return results_1;
41176                         }
41177                         return ts.Debug.fail("Unhandled class member kind! " + (p.__debugFlags || p.flags));
41178                     };
41179                 }
41180                 function serializePropertySymbolForInterface(p, baseType) {
41181                     return serializePropertySymbolForInterfaceWorker(p, false, baseType);
41182                 }
41183                 function serializeSignatures(kind, input, baseType, outputKind) {
41184                     var signatures = getSignaturesOfType(input, kind);
41185                     if (kind === 1) {
41186                         if (!baseType && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) {
41187                             return [];
41188                         }
41189                         if (baseType) {
41190                             var baseSigs = getSignaturesOfType(baseType, 1);
41191                             if (!ts.length(baseSigs) && ts.every(signatures, function (s) { return ts.length(s.parameters) === 0; })) {
41192                                 return [];
41193                             }
41194                             if (baseSigs.length === signatures.length) {
41195                                 var failed = false;
41196                                 for (var i = 0; i < baseSigs.length; i++) {
41197                                     if (!compareSignaturesIdentical(signatures[i], baseSigs[i], false, false, true, compareTypesIdentical)) {
41198                                         failed = true;
41199                                         break;
41200                                     }
41201                                 }
41202                                 if (!failed) {
41203                                     return [];
41204                                 }
41205                             }
41206                         }
41207                         var privateProtected = 0;
41208                         for (var _i = 0, signatures_4 = signatures; _i < signatures_4.length; _i++) {
41209                             var s = signatures_4[_i];
41210                             if (s.declaration) {
41211                                 privateProtected |= ts.getSelectedEffectiveModifierFlags(s.declaration, 8 | 16);
41212                             }
41213                         }
41214                         if (privateProtected) {
41215                             return [ts.setTextRange(ts.factory.createConstructorDeclaration(undefined, ts.factory.createModifiersFromModifierFlags(privateProtected), [], undefined), signatures[0].declaration)];
41216                         }
41217                     }
41218                     var results = [];
41219                     for (var _a = 0, signatures_5 = signatures; _a < signatures_5.length; _a++) {
41220                         var sig = signatures_5[_a];
41221                         var decl = signatureToSignatureDeclarationHelper(sig, outputKind, context);
41222                         results.push(ts.setTextRange(decl, sig.declaration));
41223                     }
41224                     return results;
41225                 }
41226                 function serializeIndexSignatures(input, baseType) {
41227                     var results = [];
41228                     for (var _i = 0, _a = [0, 1]; _i < _a.length; _i++) {
41229                         var type = _a[_i];
41230                         var info = getIndexInfoOfType(input, type);
41231                         if (info) {
41232                             if (baseType) {
41233                                 var baseInfo = getIndexInfoOfType(baseType, type);
41234                                 if (baseInfo) {
41235                                     if (isTypeIdenticalTo(info.type, baseInfo.type)) {
41236                                         continue;
41237                                     }
41238                                 }
41239                             }
41240                             results.push(indexInfoToIndexSignatureDeclarationHelper(info, type, context, undefined));
41241                         }
41242                     }
41243                     return results;
41244                 }
41245                 function serializeBaseType(t, staticType, rootName) {
41246                     var ref = trySerializeAsTypeReference(t, 111551);
41247                     if (ref) {
41248                         return ref;
41249                     }
41250                     var tempName = getUnusedName(rootName + "_base");
41251                     var statement = ts.factory.createVariableStatement(undefined, ts.factory.createVariableDeclarationList([
41252                         ts.factory.createVariableDeclaration(tempName, undefined, typeToTypeNodeHelper(staticType, context))
41253                     ], 2));
41254                     addResult(statement, 0);
41255                     return ts.factory.createExpressionWithTypeArguments(ts.factory.createIdentifier(tempName), undefined);
41256                 }
41257                 function trySerializeAsTypeReference(t, flags) {
41258                     var typeArgs;
41259                     var reference;
41260                     if (t.target && isSymbolAccessibleByFlags(t.target.symbol, enclosingDeclaration, flags)) {
41261                         typeArgs = ts.map(getTypeArguments(t), function (t) { return typeToTypeNodeHelper(t, context); });
41262                         reference = symbolToExpression(t.target.symbol, context, 788968);
41263                     }
41264                     else if (t.symbol && isSymbolAccessibleByFlags(t.symbol, enclosingDeclaration, flags)) {
41265                         reference = symbolToExpression(t.symbol, context, 788968);
41266                     }
41267                     if (reference) {
41268                         return ts.factory.createExpressionWithTypeArguments(reference, typeArgs);
41269                     }
41270                 }
41271                 function serializeImplementedType(t) {
41272                     var ref = trySerializeAsTypeReference(t, 788968);
41273                     if (ref) {
41274                         return ref;
41275                     }
41276                     if (t.symbol) {
41277                         return ts.factory.createExpressionWithTypeArguments(symbolToExpression(t.symbol, context, 788968), undefined);
41278                     }
41279                 }
41280                 function getUnusedName(input, symbol) {
41281                     var _a, _b;
41282                     var id = symbol ? getSymbolId(symbol) : undefined;
41283                     if (id) {
41284                         if (context.remappedSymbolNames.has(id)) {
41285                             return context.remappedSymbolNames.get(id);
41286                         }
41287                     }
41288                     if (symbol) {
41289                         input = getNameCandidateWorker(symbol, input);
41290                     }
41291                     var i = 0;
41292                     var original = input;
41293                     while ((_a = context.usedSymbolNames) === null || _a === void 0 ? void 0 : _a.has(input)) {
41294                         i++;
41295                         input = original + "_" + i;
41296                     }
41297                     (_b = context.usedSymbolNames) === null || _b === void 0 ? void 0 : _b.add(input);
41298                     if (id) {
41299                         context.remappedSymbolNames.set(id, input);
41300                     }
41301                     return input;
41302                 }
41303                 function getNameCandidateWorker(symbol, localName) {
41304                     if (localName === "default" || localName === "__class" || localName === "__function") {
41305                         var flags = context.flags;
41306                         context.flags |= 16777216;
41307                         var nameCandidate = getNameOfSymbolAsWritten(symbol, context);
41308                         context.flags = flags;
41309                         localName = nameCandidate.length > 0 && ts.isSingleOrDoubleQuote(nameCandidate.charCodeAt(0)) ? ts.stripQuotes(nameCandidate) : nameCandidate;
41310                     }
41311                     if (localName === "default") {
41312                         localName = "_default";
41313                     }
41314                     else if (localName === "export=") {
41315                         localName = "_exports";
41316                     }
41317                     localName = ts.isIdentifierText(localName, languageVersion) && !ts.isStringANonContextualKeyword(localName) ? localName : "_" + localName.replace(/[^a-zA-Z0-9]/g, "_");
41318                     return localName;
41319                 }
41320                 function getInternalSymbolName(symbol, localName) {
41321                     var id = getSymbolId(symbol);
41322                     if (context.remappedSymbolNames.has(id)) {
41323                         return context.remappedSymbolNames.get(id);
41324                     }
41325                     localName = getNameCandidateWorker(symbol, localName);
41326                     context.remappedSymbolNames.set(id, localName);
41327                     return localName;
41328                 }
41329             }
41330         }
41331         function typePredicateToString(typePredicate, enclosingDeclaration, flags, writer) {
41332             if (flags === void 0) { flags = 16384; }
41333             return writer ? typePredicateToStringWorker(writer).getText() : ts.usingSingleLineStringWriter(typePredicateToStringWorker);
41334             function typePredicateToStringWorker(writer) {
41335                 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));
41336                 var printer = ts.createPrinter({ removeComments: true });
41337                 var sourceFile = enclosingDeclaration && ts.getSourceFileOfNode(enclosingDeclaration);
41338                 printer.writeNode(4, predicate, sourceFile, writer);
41339                 return writer;
41340             }
41341         }
41342         function formatUnionTypes(types) {
41343             var result = [];
41344             var flags = 0;
41345             for (var i = 0; i < types.length; i++) {
41346                 var t = types[i];
41347                 flags |= t.flags;
41348                 if (!(t.flags & 98304)) {
41349                     if (t.flags & (512 | 1024)) {
41350                         var baseType = t.flags & 512 ? booleanType : getBaseTypeOfEnumLiteralType(t);
41351                         if (baseType.flags & 1048576) {
41352                             var count = baseType.types.length;
41353                             if (i + count <= types.length && getRegularTypeOfLiteralType(types[i + count - 1]) === getRegularTypeOfLiteralType(baseType.types[count - 1])) {
41354                                 result.push(baseType);
41355                                 i += count - 1;
41356                                 continue;
41357                             }
41358                         }
41359                     }
41360                     result.push(t);
41361                 }
41362             }
41363             if (flags & 65536)
41364                 result.push(nullType);
41365             if (flags & 32768)
41366                 result.push(undefinedType);
41367             return result || types;
41368         }
41369         function visibilityToString(flags) {
41370             if (flags === 8) {
41371                 return "private";
41372             }
41373             if (flags === 16) {
41374                 return "protected";
41375             }
41376             return "public";
41377         }
41378         function getTypeAliasForTypeLiteral(type) {
41379             if (type.symbol && type.symbol.flags & 2048) {
41380                 var node = ts.walkUpParenthesizedTypes(type.symbol.declarations[0].parent);
41381                 if (node.kind === 254) {
41382                     return getSymbolOfNode(node);
41383                 }
41384             }
41385             return undefined;
41386         }
41387         function isTopLevelInExternalModuleAugmentation(node) {
41388             return node && node.parent &&
41389                 node.parent.kind === 257 &&
41390                 ts.isExternalModuleAugmentation(node.parent.parent);
41391         }
41392         function isDefaultBindingContext(location) {
41393             return location.kind === 297 || ts.isAmbientModule(location);
41394         }
41395         function getNameOfSymbolFromNameType(symbol, context) {
41396             var nameType = getSymbolLinks(symbol).nameType;
41397             if (nameType) {
41398                 if (nameType.flags & 384) {
41399                     var name = "" + nameType.value;
41400                     if (!ts.isIdentifierText(name, compilerOptions.target) && !isNumericLiteralName(name)) {
41401                         return "\"" + ts.escapeString(name, 34) + "\"";
41402                     }
41403                     if (isNumericLiteralName(name) && ts.startsWith(name, "-")) {
41404                         return "[" + name + "]";
41405                     }
41406                     return name;
41407                 }
41408                 if (nameType.flags & 8192) {
41409                     return "[" + getNameOfSymbolAsWritten(nameType.symbol, context) + "]";
41410                 }
41411             }
41412         }
41413         function getNameOfSymbolAsWritten(symbol, context) {
41414             if (context && symbol.escapedName === "default" && !(context.flags & 16384) &&
41415                 (!(context.flags & 16777216) ||
41416                     !symbol.declarations ||
41417                     (context.enclosingDeclaration && ts.findAncestor(symbol.declarations[0], isDefaultBindingContext) !== ts.findAncestor(context.enclosingDeclaration, isDefaultBindingContext)))) {
41418                 return "default";
41419             }
41420             if (symbol.declarations && symbol.declarations.length) {
41421                 var declaration = ts.firstDefined(symbol.declarations, function (d) { return ts.getNameOfDeclaration(d) ? d : undefined; });
41422                 var name_3 = declaration && ts.getNameOfDeclaration(declaration);
41423                 if (declaration && name_3) {
41424                     if (ts.isCallExpression(declaration) && ts.isBindableObjectDefinePropertyCall(declaration)) {
41425                         return ts.symbolName(symbol);
41426                     }
41427                     if (ts.isComputedPropertyName(name_3) && !(ts.getCheckFlags(symbol) & 4096)) {
41428                         var nameType = getSymbolLinks(symbol).nameType;
41429                         if (nameType && nameType.flags & 384) {
41430                             var result = getNameOfSymbolFromNameType(symbol, context);
41431                             if (result !== undefined) {
41432                                 return result;
41433                             }
41434                         }
41435                     }
41436                     return ts.declarationNameToString(name_3);
41437                 }
41438                 if (!declaration) {
41439                     declaration = symbol.declarations[0];
41440                 }
41441                 if (declaration.parent && declaration.parent.kind === 249) {
41442                     return ts.declarationNameToString(declaration.parent.name);
41443                 }
41444                 switch (declaration.kind) {
41445                     case 221:
41446                     case 208:
41447                     case 209:
41448                         if (context && !context.encounteredError && !(context.flags & 131072)) {
41449                             context.encounteredError = true;
41450                         }
41451                         return declaration.kind === 221 ? "(Anonymous class)" : "(Anonymous function)";
41452                 }
41453             }
41454             var name = getNameOfSymbolFromNameType(symbol, context);
41455             return name !== undefined ? name : ts.symbolName(symbol);
41456         }
41457         function isDeclarationVisible(node) {
41458             if (node) {
41459                 var links = getNodeLinks(node);
41460                 if (links.isVisible === undefined) {
41461                     links.isVisible = !!determineIfDeclarationIsVisible();
41462                 }
41463                 return links.isVisible;
41464             }
41465             return false;
41466             function determineIfDeclarationIsVisible() {
41467                 switch (node.kind) {
41468                     case 324:
41469                     case 331:
41470                     case 325:
41471                         return !!(node.parent && node.parent.parent && node.parent.parent.parent && ts.isSourceFile(node.parent.parent.parent));
41472                     case 198:
41473                         return isDeclarationVisible(node.parent.parent);
41474                     case 249:
41475                         if (ts.isBindingPattern(node.name) &&
41476                             !node.name.elements.length) {
41477                             return false;
41478                         }
41479                     case 256:
41480                     case 252:
41481                     case 253:
41482                     case 254:
41483                     case 251:
41484                     case 255:
41485                     case 260:
41486                         if (ts.isExternalModuleAugmentation(node)) {
41487                             return true;
41488                         }
41489                         var parent = getDeclarationContainer(node);
41490                         if (!(ts.getCombinedModifierFlags(node) & 1) &&
41491                             !(node.kind !== 260 && parent.kind !== 297 && parent.flags & 8388608)) {
41492                             return isGlobalSourceFile(parent);
41493                         }
41494                         return isDeclarationVisible(parent);
41495                     case 163:
41496                     case 162:
41497                     case 167:
41498                     case 168:
41499                     case 165:
41500                     case 164:
41501                         if (ts.hasEffectiveModifier(node, 8 | 16)) {
41502                             return false;
41503                         }
41504                     case 166:
41505                     case 170:
41506                     case 169:
41507                     case 171:
41508                     case 160:
41509                     case 257:
41510                     case 174:
41511                     case 175:
41512                     case 177:
41513                     case 173:
41514                     case 178:
41515                     case 179:
41516                     case 182:
41517                     case 183:
41518                     case 186:
41519                     case 192:
41520                         return isDeclarationVisible(node.parent);
41521                     case 262:
41522                     case 263:
41523                     case 265:
41524                         return false;
41525                     case 159:
41526                     case 297:
41527                     case 259:
41528                         return true;
41529                     case 266:
41530                         return false;
41531                     default:
41532                         return false;
41533                 }
41534             }
41535         }
41536         function collectLinkedAliases(node, setVisibility) {
41537             var exportSymbol;
41538             if (node.parent && node.parent.kind === 266) {
41539                 exportSymbol = resolveName(node, node.escapedText, 111551 | 788968 | 1920 | 2097152, undefined, node, false);
41540             }
41541             else if (node.parent.kind === 270) {
41542                 exportSymbol = getTargetOfExportSpecifier(node.parent, 111551 | 788968 | 1920 | 2097152);
41543             }
41544             var result;
41545             var visited;
41546             if (exportSymbol) {
41547                 visited = new ts.Set();
41548                 visited.add(getSymbolId(exportSymbol));
41549                 buildVisibleNodeList(exportSymbol.declarations);
41550             }
41551             return result;
41552             function buildVisibleNodeList(declarations) {
41553                 ts.forEach(declarations, function (declaration) {
41554                     var resultNode = getAnyImportSyntax(declaration) || declaration;
41555                     if (setVisibility) {
41556                         getNodeLinks(declaration).isVisible = true;
41557                     }
41558                     else {
41559                         result = result || [];
41560                         ts.pushIfUnique(result, resultNode);
41561                     }
41562                     if (ts.isInternalModuleImportEqualsDeclaration(declaration)) {
41563                         var internalModuleReference = declaration.moduleReference;
41564                         var firstIdentifier = ts.getFirstIdentifier(internalModuleReference);
41565                         var importSymbol = resolveName(declaration, firstIdentifier.escapedText, 111551 | 788968 | 1920, undefined, undefined, false);
41566                         if (importSymbol && visited) {
41567                             if (ts.tryAddToSet(visited, getSymbolId(importSymbol))) {
41568                                 buildVisibleNodeList(importSymbol.declarations);
41569                             }
41570                         }
41571                     }
41572                 });
41573             }
41574         }
41575         function pushTypeResolution(target, propertyName) {
41576             var resolutionCycleStartIndex = findResolutionCycleStartIndex(target, propertyName);
41577             if (resolutionCycleStartIndex >= 0) {
41578                 var length_3 = resolutionTargets.length;
41579                 for (var i = resolutionCycleStartIndex; i < length_3; i++) {
41580                     resolutionResults[i] = false;
41581                 }
41582                 return false;
41583             }
41584             resolutionTargets.push(target);
41585             resolutionResults.push(true);
41586             resolutionPropertyNames.push(propertyName);
41587             return true;
41588         }
41589         function findResolutionCycleStartIndex(target, propertyName) {
41590             for (var i = resolutionTargets.length - 1; i >= 0; i--) {
41591                 if (hasType(resolutionTargets[i], resolutionPropertyNames[i])) {
41592                     return -1;
41593                 }
41594                 if (resolutionTargets[i] === target && resolutionPropertyNames[i] === propertyName) {
41595                     return i;
41596                 }
41597             }
41598             return -1;
41599         }
41600         function hasType(target, propertyName) {
41601             switch (propertyName) {
41602                 case 0:
41603                     return !!getSymbolLinks(target).type;
41604                 case 5:
41605                     return !!(getNodeLinks(target).resolvedEnumType);
41606                 case 2:
41607                     return !!getSymbolLinks(target).declaredType;
41608                 case 1:
41609                     return !!target.resolvedBaseConstructorType;
41610                 case 3:
41611                     return !!target.resolvedReturnType;
41612                 case 4:
41613                     return !!target.immediateBaseConstraint;
41614                 case 6:
41615                     return !!target.resolvedTypeArguments;
41616                 case 7:
41617                     return !!target.baseTypesResolved;
41618             }
41619             return ts.Debug.assertNever(propertyName);
41620         }
41621         function popTypeResolution() {
41622             resolutionTargets.pop();
41623             resolutionPropertyNames.pop();
41624             return resolutionResults.pop();
41625         }
41626         function getDeclarationContainer(node) {
41627             return ts.findAncestor(ts.getRootDeclaration(node), function (node) {
41628                 switch (node.kind) {
41629                     case 249:
41630                     case 250:
41631                     case 265:
41632                     case 264:
41633                     case 263:
41634                     case 262:
41635                         return false;
41636                     default:
41637                         return true;
41638                 }
41639             }).parent;
41640         }
41641         function getTypeOfPrototypeProperty(prototype) {
41642             var classType = getDeclaredTypeOfSymbol(getParentOfSymbol(prototype));
41643             return classType.typeParameters ? createTypeReference(classType, ts.map(classType.typeParameters, function (_) { return anyType; })) : classType;
41644         }
41645         function getTypeOfPropertyOfType(type, name) {
41646             var prop = getPropertyOfType(type, name);
41647             return prop ? getTypeOfSymbol(prop) : undefined;
41648         }
41649         function getTypeOfPropertyOrIndexSignature(type, name) {
41650             return getTypeOfPropertyOfType(type, name) || isNumericLiteralName(name) && getIndexTypeOfType(type, 1) || getIndexTypeOfType(type, 0) || unknownType;
41651         }
41652         function isTypeAny(type) {
41653             return type && (type.flags & 1) !== 0;
41654         }
41655         function getTypeForBindingElementParent(node) {
41656             var symbol = getSymbolOfNode(node);
41657             return symbol && getSymbolLinks(symbol).type || getTypeForVariableLikeDeclaration(node, false);
41658         }
41659         function getRestType(source, properties, symbol) {
41660             source = filterType(source, function (t) { return !(t.flags & 98304); });
41661             if (source.flags & 131072) {
41662                 return emptyObjectType;
41663             }
41664             if (source.flags & 1048576) {
41665                 return mapType(source, function (t) { return getRestType(t, properties, symbol); });
41666             }
41667             var omitKeyType = getUnionType(ts.map(properties, getLiteralTypeFromPropertyName));
41668             if (isGenericObjectType(source) || isGenericIndexType(omitKeyType)) {
41669                 if (omitKeyType.flags & 131072) {
41670                     return source;
41671                 }
41672                 var omitTypeAlias = getGlobalOmitSymbol();
41673                 if (!omitTypeAlias) {
41674                     return errorType;
41675                 }
41676                 return getTypeAliasInstantiation(omitTypeAlias, [source, omitKeyType]);
41677             }
41678             var members = ts.createSymbolTable();
41679             for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
41680                 var prop = _a[_i];
41681                 if (!isTypeAssignableTo(getLiteralTypeFromProperty(prop, 8576), omitKeyType)
41682                     && !(ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16))
41683                     && isSpreadableProperty(prop)) {
41684                     members.set(prop.escapedName, getSpreadSymbol(prop, false));
41685                 }
41686             }
41687             var stringIndexInfo = getIndexInfoOfType(source, 0);
41688             var numberIndexInfo = getIndexInfoOfType(source, 1);
41689             var result = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
41690             result.objectFlags |= 131072;
41691             return result;
41692         }
41693         function getFlowTypeOfDestructuring(node, declaredType) {
41694             var reference = getSyntheticElementAccess(node);
41695             return reference ? getFlowTypeOfReference(reference, declaredType) : declaredType;
41696         }
41697         function getSyntheticElementAccess(node) {
41698             var parentAccess = getParentElementAccess(node);
41699             if (parentAccess && parentAccess.flowNode) {
41700                 var propName = getDestructuringPropertyName(node);
41701                 if (propName) {
41702                     var literal = ts.setTextRange(ts.parseNodeFactory.createStringLiteral(propName), node);
41703                     var lhsExpr = ts.isLeftHandSideExpression(parentAccess) ? parentAccess : ts.parseNodeFactory.createParenthesizedExpression(parentAccess);
41704                     var result = ts.setTextRange(ts.parseNodeFactory.createElementAccessExpression(lhsExpr, literal), node);
41705                     ts.setParent(literal, result);
41706                     ts.setParent(result, node);
41707                     if (lhsExpr !== parentAccess) {
41708                         ts.setParent(lhsExpr, result);
41709                     }
41710                     result.flowNode = parentAccess.flowNode;
41711                     return result;
41712                 }
41713             }
41714         }
41715         function getParentElementAccess(node) {
41716             var ancestor = node.parent.parent;
41717             switch (ancestor.kind) {
41718                 case 198:
41719                 case 288:
41720                     return getSyntheticElementAccess(ancestor);
41721                 case 199:
41722                     return getSyntheticElementAccess(node.parent);
41723                 case 249:
41724                     return ancestor.initializer;
41725                 case 216:
41726                     return ancestor.right;
41727             }
41728         }
41729         function getDestructuringPropertyName(node) {
41730             var parent = node.parent;
41731             if (node.kind === 198 && parent.kind === 196) {
41732                 return getLiteralPropertyNameText(node.propertyName || node.name);
41733             }
41734             if (node.kind === 288 || node.kind === 289) {
41735                 return getLiteralPropertyNameText(node.name);
41736             }
41737             return "" + parent.elements.indexOf(node);
41738         }
41739         function getLiteralPropertyNameText(name) {
41740             var type = getLiteralTypeFromPropertyName(name);
41741             return type.flags & (128 | 256) ? "" + type.value : undefined;
41742         }
41743         function getTypeForBindingElement(declaration) {
41744             var pattern = declaration.parent;
41745             var parentType = getTypeForBindingElementParent(pattern.parent);
41746             if (!parentType || isTypeAny(parentType)) {
41747                 return parentType;
41748             }
41749             if (strictNullChecks && declaration.flags & 8388608 && ts.isParameterDeclaration(declaration)) {
41750                 parentType = getNonNullableType(parentType);
41751             }
41752             else if (strictNullChecks && pattern.parent.initializer && !(getTypeFacts(getTypeOfInitializer(pattern.parent.initializer)) & 65536)) {
41753                 parentType = getTypeWithFacts(parentType, 524288);
41754             }
41755             var type;
41756             if (pattern.kind === 196) {
41757                 if (declaration.dotDotDotToken) {
41758                     parentType = getReducedType(parentType);
41759                     if (parentType.flags & 2 || !isValidSpreadType(parentType)) {
41760                         error(declaration, ts.Diagnostics.Rest_types_may_only_be_created_from_object_types);
41761                         return errorType;
41762                     }
41763                     var literalMembers = [];
41764                     for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
41765                         var element = _a[_i];
41766                         if (!element.dotDotDotToken) {
41767                             literalMembers.push(element.propertyName || element.name);
41768                         }
41769                     }
41770                     type = getRestType(parentType, literalMembers, declaration.symbol);
41771                 }
41772                 else {
41773                     var name = declaration.propertyName || declaration.name;
41774                     var indexType = getLiteralTypeFromPropertyName(name);
41775                     var declaredType = getConstraintForLocation(getIndexedAccessType(parentType, indexType, undefined, name, undefined, undefined, 16), declaration.name);
41776                     type = getFlowTypeOfDestructuring(declaration, declaredType);
41777                 }
41778             }
41779             else {
41780                 var elementType = checkIteratedTypeOrElementType(65 | (declaration.dotDotDotToken ? 0 : 128), parentType, undefinedType, pattern);
41781                 var index_2 = pattern.elements.indexOf(declaration);
41782                 if (declaration.dotDotDotToken) {
41783                     type = everyType(parentType, isTupleType) ?
41784                         mapType(parentType, function (t) { return sliceTupleType(t, index_2); }) :
41785                         createArrayType(elementType);
41786                 }
41787                 else if (isArrayLikeType(parentType)) {
41788                     var indexType = getLiteralType(index_2);
41789                     var accessFlags = hasDefaultValue(declaration) ? 8 : 0;
41790                     var declaredType = getConstraintForLocation(getIndexedAccessTypeOrUndefined(parentType, indexType, undefined, declaration.name, accessFlags | 16) || errorType, declaration.name);
41791                     type = getFlowTypeOfDestructuring(declaration, declaredType);
41792                 }
41793                 else {
41794                     type = elementType;
41795                 }
41796             }
41797             if (!declaration.initializer) {
41798                 return type;
41799             }
41800             if (ts.getEffectiveTypeAnnotationNode(ts.walkUpBindingElementsAndPatterns(declaration))) {
41801                 return strictNullChecks && !(getFalsyFlags(checkDeclarationInitializer(declaration)) & 32768) ?
41802                     getTypeWithFacts(type, 524288) :
41803                     type;
41804             }
41805             return widenTypeInferredFromInitializer(declaration, getUnionType([getTypeWithFacts(type, 524288), checkDeclarationInitializer(declaration)], 2));
41806         }
41807         function getTypeForDeclarationFromJSDocComment(declaration) {
41808             var jsdocType = ts.getJSDocType(declaration);
41809             if (jsdocType) {
41810                 return getTypeFromTypeNode(jsdocType);
41811             }
41812             return undefined;
41813         }
41814         function isNullOrUndefined(node) {
41815             var expr = ts.skipParentheses(node);
41816             return expr.kind === 103 || expr.kind === 78 && getResolvedSymbol(expr) === undefinedSymbol;
41817         }
41818         function isEmptyArrayLiteral(node) {
41819             var expr = ts.skipParentheses(node);
41820             return expr.kind === 199 && expr.elements.length === 0;
41821         }
41822         function addOptionality(type, optional) {
41823             if (optional === void 0) { optional = true; }
41824             return strictNullChecks && optional ? getOptionalType(type) : type;
41825         }
41826         function getTypeForVariableLikeDeclaration(declaration, includeOptionality) {
41827             if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 238) {
41828                 var indexType = getIndexType(getNonNullableTypeIfNeeded(checkExpression(declaration.parent.parent.expression)));
41829                 return indexType.flags & (262144 | 4194304) ? getExtractStringType(indexType) : stringType;
41830             }
41831             if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 239) {
41832                 var forOfStatement = declaration.parent.parent;
41833                 return checkRightHandSideOfForOf(forOfStatement) || anyType;
41834             }
41835             if (ts.isBindingPattern(declaration.parent)) {
41836                 return getTypeForBindingElement(declaration);
41837             }
41838             var isOptional = includeOptionality && (ts.isParameter(declaration) && isJSDocOptionalParameter(declaration)
41839                 || isOptionalJSDocPropertyLikeTag(declaration)
41840                 || !ts.isBindingElement(declaration) && !ts.isVariableDeclaration(declaration) && !!declaration.questionToken);
41841             var declaredType = tryGetTypeFromEffectiveTypeNode(declaration);
41842             if (declaredType) {
41843                 return addOptionality(declaredType, isOptional);
41844             }
41845             if ((noImplicitAny || ts.isInJSFile(declaration)) &&
41846                 ts.isVariableDeclaration(declaration) && !ts.isBindingPattern(declaration.name) &&
41847                 !(ts.getCombinedModifierFlags(declaration) & 1) && !(declaration.flags & 8388608)) {
41848                 if (!(ts.getCombinedNodeFlags(declaration) & 2) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) {
41849                     return autoType;
41850                 }
41851                 if (declaration.initializer && isEmptyArrayLiteral(declaration.initializer)) {
41852                     return autoArrayType;
41853                 }
41854             }
41855             if (ts.isParameter(declaration)) {
41856                 var func = declaration.parent;
41857                 if (func.kind === 168 && hasBindableName(func)) {
41858                     var getter = ts.getDeclarationOfKind(getSymbolOfNode(declaration.parent), 167);
41859                     if (getter) {
41860                         var getterSignature = getSignatureFromDeclaration(getter);
41861                         var thisParameter = getAccessorThisParameter(func);
41862                         if (thisParameter && declaration === thisParameter) {
41863                             ts.Debug.assert(!thisParameter.type);
41864                             return getTypeOfSymbol(getterSignature.thisParameter);
41865                         }
41866                         return getReturnTypeOfSignature(getterSignature);
41867                     }
41868                 }
41869                 if (ts.isInJSFile(declaration)) {
41870                     var typeTag = ts.getJSDocType(func);
41871                     if (typeTag && ts.isFunctionTypeNode(typeTag)) {
41872                         var signature = getSignatureFromDeclaration(typeTag);
41873                         var pos = func.parameters.indexOf(declaration);
41874                         return declaration.dotDotDotToken ? getRestTypeAtPosition(signature, pos) : getTypeAtPosition(signature, pos);
41875                     }
41876                 }
41877                 var type = declaration.symbol.escapedName === "this" ? getContextualThisParameterType(func) : getContextuallyTypedParameterType(declaration);
41878                 if (type) {
41879                     return addOptionality(type, isOptional);
41880                 }
41881             }
41882             if (ts.hasOnlyExpressionInitializer(declaration) && !!declaration.initializer) {
41883                 if (ts.isInJSFile(declaration) && !ts.isParameter(declaration)) {
41884                     var containerObjectType = getJSContainerObjectType(declaration, getSymbolOfNode(declaration), ts.getDeclaredExpandoInitializer(declaration));
41885                     if (containerObjectType) {
41886                         return containerObjectType;
41887                     }
41888                 }
41889                 var type = widenTypeInferredFromInitializer(declaration, checkDeclarationInitializer(declaration));
41890                 return addOptionality(type, isOptional);
41891             }
41892             if (ts.isPropertyDeclaration(declaration) && !ts.hasStaticModifier(declaration) && (noImplicitAny || ts.isInJSFile(declaration))) {
41893                 var constructor = findConstructorDeclaration(declaration.parent);
41894                 var type = constructor ? getFlowTypeInConstructor(declaration.symbol, constructor) :
41895                     ts.getEffectiveModifierFlags(declaration) & 2 ? getTypeOfPropertyInBaseClass(declaration.symbol) :
41896                         undefined;
41897                 return type && addOptionality(type, isOptional);
41898             }
41899             if (ts.isJsxAttribute(declaration)) {
41900                 return trueType;
41901             }
41902             if (ts.isBindingPattern(declaration.name)) {
41903                 return getTypeFromBindingPattern(declaration.name, false, true);
41904             }
41905             return undefined;
41906         }
41907         function isConstructorDeclaredProperty(symbol) {
41908             if (symbol.valueDeclaration && ts.isBinaryExpression(symbol.valueDeclaration)) {
41909                 var links = getSymbolLinks(symbol);
41910                 if (links.isConstructorDeclaredProperty === undefined) {
41911                     links.isConstructorDeclaredProperty = false;
41912                     links.isConstructorDeclaredProperty = !!getDeclaringConstructor(symbol) && ts.every(symbol.declarations, function (declaration) {
41913                         return ts.isBinaryExpression(declaration) &&
41914                             isPossiblyAliasedThisProperty(declaration) &&
41915                             (declaration.left.kind !== 202 || ts.isStringOrNumericLiteralLike(declaration.left.argumentExpression)) &&
41916                             !getAnnotatedTypeForAssignmentDeclaration(undefined, declaration, symbol, declaration);
41917                     });
41918                 }
41919                 return links.isConstructorDeclaredProperty;
41920             }
41921             return false;
41922         }
41923         function isAutoTypedProperty(symbol) {
41924             var declaration = symbol.valueDeclaration;
41925             return declaration && ts.isPropertyDeclaration(declaration) && !ts.getEffectiveTypeAnnotationNode(declaration) &&
41926                 !declaration.initializer && (noImplicitAny || ts.isInJSFile(declaration));
41927         }
41928         function getDeclaringConstructor(symbol) {
41929             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
41930                 var declaration = _a[_i];
41931                 var container = ts.getThisContainer(declaration, false);
41932                 if (container && (container.kind === 166 || isJSConstructor(container))) {
41933                     return container;
41934                 }
41935             }
41936         }
41937         function getFlowTypeInConstructor(symbol, constructor) {
41938             var accessName = ts.startsWith(symbol.escapedName, "__#")
41939                 ? ts.factory.createPrivateIdentifier(symbol.escapedName.split("@")[1])
41940                 : ts.unescapeLeadingUnderscores(symbol.escapedName);
41941             var reference = ts.factory.createPropertyAccessExpression(ts.factory.createThis(), accessName);
41942             ts.setParent(reference.expression, reference);
41943             ts.setParent(reference, constructor);
41944             reference.flowNode = constructor.returnFlowNode;
41945             var flowType = getFlowTypeOfProperty(reference, symbol);
41946             if (noImplicitAny && (flowType === autoType || flowType === autoArrayType)) {
41947                 error(symbol.valueDeclaration, ts.Diagnostics.Member_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType));
41948             }
41949             return everyType(flowType, isNullableType) ? undefined : convertAutoToAny(flowType);
41950         }
41951         function getFlowTypeOfProperty(reference, prop) {
41952             var initialType = prop && (!isAutoTypedProperty(prop) || ts.getEffectiveModifierFlags(prop.valueDeclaration) & 2) && getTypeOfPropertyInBaseClass(prop) || undefinedType;
41953             return getFlowTypeOfReference(reference, autoType, initialType);
41954         }
41955         function getWidenedTypeForAssignmentDeclaration(symbol, resolvedSymbol) {
41956             var container = ts.getAssignedExpandoInitializer(symbol.valueDeclaration);
41957             if (container) {
41958                 var tag = ts.getJSDocTypeTag(container);
41959                 if (tag && tag.typeExpression) {
41960                     return getTypeFromTypeNode(tag.typeExpression);
41961                 }
41962                 var containerObjectType = getJSContainerObjectType(symbol.valueDeclaration, symbol, container);
41963                 return containerObjectType || getWidenedLiteralType(checkExpressionCached(container));
41964             }
41965             var type;
41966             var definedInConstructor = false;
41967             var definedInMethod = false;
41968             if (isConstructorDeclaredProperty(symbol)) {
41969                 type = getFlowTypeInConstructor(symbol, getDeclaringConstructor(symbol));
41970             }
41971             if (!type) {
41972                 var jsdocType = void 0;
41973                 var types = void 0;
41974                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
41975                     var declaration = _a[_i];
41976                     var expression = (ts.isBinaryExpression(declaration) || ts.isCallExpression(declaration)) ? declaration :
41977                         ts.isAccessExpression(declaration) ? ts.isBinaryExpression(declaration.parent) ? declaration.parent : declaration :
41978                             undefined;
41979                     if (!expression) {
41980                         continue;
41981                     }
41982                     var kind = ts.isAccessExpression(expression)
41983                         ? ts.getAssignmentDeclarationPropertyAccessKind(expression)
41984                         : ts.getAssignmentDeclarationKind(expression);
41985                     if (kind === 4 || ts.isBinaryExpression(expression) && isPossiblyAliasedThisProperty(expression, kind)) {
41986                         if (isDeclarationInConstructor(expression)) {
41987                             definedInConstructor = true;
41988                         }
41989                         else {
41990                             definedInMethod = true;
41991                         }
41992                     }
41993                     if (!ts.isCallExpression(expression)) {
41994                         jsdocType = getAnnotatedTypeForAssignmentDeclaration(jsdocType, expression, symbol, declaration);
41995                     }
41996                     if (!jsdocType) {
41997                         (types || (types = [])).push((ts.isBinaryExpression(expression) || ts.isCallExpression(expression)) ? getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) : neverType);
41998                     }
41999                 }
42000                 type = jsdocType;
42001                 if (!type) {
42002                     if (!ts.length(types)) {
42003                         return errorType;
42004                     }
42005                     var constructorTypes = definedInConstructor ? getConstructorDefinedThisAssignmentTypes(types, symbol.declarations) : undefined;
42006                     if (definedInMethod) {
42007                         var propType = getTypeOfPropertyInBaseClass(symbol);
42008                         if (propType) {
42009                             (constructorTypes || (constructorTypes = [])).push(propType);
42010                             definedInConstructor = true;
42011                         }
42012                     }
42013                     var sourceTypes = ts.some(constructorTypes, function (t) { return !!(t.flags & ~98304); }) ? constructorTypes : types;
42014                     type = getUnionType(sourceTypes, 2);
42015                 }
42016             }
42017             var widened = getWidenedType(addOptionality(type, definedInMethod && !definedInConstructor));
42018             if (filterType(widened, function (t) { return !!(t.flags & ~98304); }) === neverType) {
42019                 reportImplicitAny(symbol.valueDeclaration, anyType);
42020                 return anyType;
42021             }
42022             return widened;
42023         }
42024         function getJSContainerObjectType(decl, symbol, init) {
42025             var _a, _b;
42026             if (!ts.isInJSFile(decl) || !init || !ts.isObjectLiteralExpression(init) || init.properties.length) {
42027                 return undefined;
42028             }
42029             var exports = ts.createSymbolTable();
42030             while (ts.isBinaryExpression(decl) || ts.isPropertyAccessExpression(decl)) {
42031                 var s_2 = getSymbolOfNode(decl);
42032                 if ((_a = s_2 === null || s_2 === void 0 ? void 0 : s_2.exports) === null || _a === void 0 ? void 0 : _a.size) {
42033                     mergeSymbolTable(exports, s_2.exports);
42034                 }
42035                 decl = ts.isBinaryExpression(decl) ? decl.parent : decl.parent.parent;
42036             }
42037             var s = getSymbolOfNode(decl);
42038             if ((_b = s === null || s === void 0 ? void 0 : s.exports) === null || _b === void 0 ? void 0 : _b.size) {
42039                 mergeSymbolTable(exports, s.exports);
42040             }
42041             var type = createAnonymousType(symbol, exports, ts.emptyArray, ts.emptyArray, undefined, undefined);
42042             type.objectFlags |= 16384;
42043             return type;
42044         }
42045         function getAnnotatedTypeForAssignmentDeclaration(declaredType, expression, symbol, declaration) {
42046             var typeNode = ts.getEffectiveTypeAnnotationNode(expression.parent);
42047             if (typeNode) {
42048                 var type = getWidenedType(getTypeFromTypeNode(typeNode));
42049                 if (!declaredType) {
42050                     return type;
42051                 }
42052                 else if (declaredType !== errorType && type !== errorType && !isTypeIdenticalTo(declaredType, type)) {
42053                     errorNextVariableOrPropertyDeclarationMustHaveSameType(undefined, declaredType, declaration, type);
42054                 }
42055             }
42056             if (symbol.parent) {
42057                 var typeNode_2 = ts.getEffectiveTypeAnnotationNode(symbol.parent.valueDeclaration);
42058                 if (typeNode_2) {
42059                     return getTypeOfPropertyOfType(getTypeFromTypeNode(typeNode_2), symbol.escapedName);
42060                 }
42061             }
42062             return declaredType;
42063         }
42064         function getInitializerTypeFromAssignmentDeclaration(symbol, resolvedSymbol, expression, kind) {
42065             if (ts.isCallExpression(expression)) {
42066                 if (resolvedSymbol) {
42067                     return getTypeOfSymbol(resolvedSymbol);
42068                 }
42069                 var objectLitType = checkExpressionCached(expression.arguments[2]);
42070                 var valueType = getTypeOfPropertyOfType(objectLitType, "value");
42071                 if (valueType) {
42072                     return valueType;
42073                 }
42074                 var getFunc = getTypeOfPropertyOfType(objectLitType, "get");
42075                 if (getFunc) {
42076                     var getSig = getSingleCallSignature(getFunc);
42077                     if (getSig) {
42078                         return getReturnTypeOfSignature(getSig);
42079                     }
42080                 }
42081                 var setFunc = getTypeOfPropertyOfType(objectLitType, "set");
42082                 if (setFunc) {
42083                     var setSig = getSingleCallSignature(setFunc);
42084                     if (setSig) {
42085                         return getTypeOfFirstParameterOfSignature(setSig);
42086                     }
42087                 }
42088                 return anyType;
42089             }
42090             if (containsSameNamedThisProperty(expression.left, expression.right)) {
42091                 return anyType;
42092             }
42093             var type = resolvedSymbol ? getTypeOfSymbol(resolvedSymbol) : getWidenedLiteralType(checkExpressionCached(expression.right));
42094             if (type.flags & 524288 &&
42095                 kind === 2 &&
42096                 symbol.escapedName === "export=") {
42097                 var exportedType = resolveStructuredTypeMembers(type);
42098                 var members_4 = ts.createSymbolTable();
42099                 ts.copyEntries(exportedType.members, members_4);
42100                 var initialSize = members_4.size;
42101                 if (resolvedSymbol && !resolvedSymbol.exports) {
42102                     resolvedSymbol.exports = ts.createSymbolTable();
42103                 }
42104                 (resolvedSymbol || symbol).exports.forEach(function (s, name) {
42105                     var _a;
42106                     var exportedMember = members_4.get(name);
42107                     if (exportedMember && exportedMember !== s) {
42108                         if (s.flags & 111551 && exportedMember.flags & 111551) {
42109                             if (ts.getSourceFileOfNode(s.valueDeclaration) !== ts.getSourceFileOfNode(exportedMember.valueDeclaration)) {
42110                                 var unescapedName = ts.unescapeLeadingUnderscores(s.escapedName);
42111                                 var exportedMemberName = ((_a = ts.tryCast(exportedMember.valueDeclaration, ts.isNamedDeclaration)) === null || _a === void 0 ? void 0 : _a.name) || exportedMember.valueDeclaration;
42112                                 ts.addRelatedInfo(error(s.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(exportedMemberName, ts.Diagnostics._0_was_also_declared_here, unescapedName));
42113                                 ts.addRelatedInfo(error(exportedMemberName, ts.Diagnostics.Duplicate_identifier_0, unescapedName), ts.createDiagnosticForNode(s.valueDeclaration, ts.Diagnostics._0_was_also_declared_here, unescapedName));
42114                             }
42115                             var union = createSymbol(s.flags | exportedMember.flags, name);
42116                             union.type = getUnionType([getTypeOfSymbol(s), getTypeOfSymbol(exportedMember)]);
42117                             union.valueDeclaration = exportedMember.valueDeclaration;
42118                             union.declarations = ts.concatenate(exportedMember.declarations, s.declarations);
42119                             members_4.set(name, union);
42120                         }
42121                         else {
42122                             members_4.set(name, mergeSymbol(s, exportedMember));
42123                         }
42124                     }
42125                     else {
42126                         members_4.set(name, s);
42127                     }
42128                 });
42129                 var result = createAnonymousType(initialSize !== members_4.size ? undefined : exportedType.symbol, members_4, exportedType.callSignatures, exportedType.constructSignatures, exportedType.stringIndexInfo, exportedType.numberIndexInfo);
42130                 result.objectFlags |= (ts.getObjectFlags(type) & 16384);
42131                 if (result.symbol && result.symbol.flags & 32 && type === getDeclaredTypeOfClassOrInterface(result.symbol)) {
42132                     result.objectFlags |= 1073741824;
42133                 }
42134                 return result;
42135             }
42136             if (isEmptyArrayLiteralType(type)) {
42137                 reportImplicitAny(expression, anyArrayType);
42138                 return anyArrayType;
42139             }
42140             return type;
42141         }
42142         function containsSameNamedThisProperty(thisProperty, expression) {
42143             return ts.isPropertyAccessExpression(thisProperty)
42144                 && thisProperty.expression.kind === 107
42145                 && ts.forEachChildRecursively(expression, function (n) { return isMatchingReference(thisProperty, n); });
42146         }
42147         function isDeclarationInConstructor(expression) {
42148             var thisContainer = ts.getThisContainer(expression, false);
42149             return thisContainer.kind === 166 ||
42150                 thisContainer.kind === 251 ||
42151                 (thisContainer.kind === 208 && !ts.isPrototypePropertyAssignment(thisContainer.parent));
42152         }
42153         function getConstructorDefinedThisAssignmentTypes(types, declarations) {
42154             ts.Debug.assert(types.length === declarations.length);
42155             return types.filter(function (_, i) {
42156                 var declaration = declarations[i];
42157                 var expression = ts.isBinaryExpression(declaration) ? declaration :
42158                     ts.isBinaryExpression(declaration.parent) ? declaration.parent : undefined;
42159                 return expression && isDeclarationInConstructor(expression);
42160             });
42161         }
42162         function getTypeFromBindingElement(element, includePatternInType, reportErrors) {
42163             if (element.initializer) {
42164                 var contextualType = ts.isBindingPattern(element.name) ? getTypeFromBindingPattern(element.name, true, false) : unknownType;
42165                 return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, contextualType)));
42166             }
42167             if (ts.isBindingPattern(element.name)) {
42168                 return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors);
42169             }
42170             if (reportErrors && !declarationBelongsToPrivateAmbientMember(element)) {
42171                 reportImplicitAny(element, anyType);
42172             }
42173             return includePatternInType ? nonInferrableAnyType : anyType;
42174         }
42175         function getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors) {
42176             var members = ts.createSymbolTable();
42177             var stringIndexInfo;
42178             var objectFlags = 128 | 1048576;
42179             ts.forEach(pattern.elements, function (e) {
42180                 var name = e.propertyName || e.name;
42181                 if (e.dotDotDotToken) {
42182                     stringIndexInfo = createIndexInfo(anyType, false);
42183                     return;
42184                 }
42185                 var exprType = getLiteralTypeFromPropertyName(name);
42186                 if (!isTypeUsableAsPropertyName(exprType)) {
42187                     objectFlags |= 512;
42188                     return;
42189                 }
42190                 var text = getPropertyNameFromType(exprType);
42191                 var flags = 4 | (e.initializer ? 16777216 : 0);
42192                 var symbol = createSymbol(flags, text);
42193                 symbol.type = getTypeFromBindingElement(e, includePatternInType, reportErrors);
42194                 symbol.bindingElement = e;
42195                 members.set(symbol.escapedName, symbol);
42196             });
42197             var result = createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined);
42198             result.objectFlags |= objectFlags;
42199             if (includePatternInType) {
42200                 result.pattern = pattern;
42201                 result.objectFlags |= 1048576;
42202             }
42203             return result;
42204         }
42205         function getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors) {
42206             var elements = pattern.elements;
42207             var lastElement = ts.lastOrUndefined(elements);
42208             var restElement = lastElement && lastElement.kind === 198 && lastElement.dotDotDotToken ? lastElement : undefined;
42209             if (elements.length === 0 || elements.length === 1 && restElement) {
42210                 return languageVersion >= 2 ? createIterableType(anyType) : anyArrayType;
42211             }
42212             var elementTypes = ts.map(elements, function (e) { return ts.isOmittedExpression(e) ? anyType : getTypeFromBindingElement(e, includePatternInType, reportErrors); });
42213             var minLength = ts.findLastIndex(elements, function (e) { return !(e === restElement || ts.isOmittedExpression(e) || hasDefaultValue(e)); }, elements.length - 1) + 1;
42214             var elementFlags = ts.map(elements, function (e, i) { return e === restElement ? 4 : i >= minLength ? 2 : 1; });
42215             var result = createTupleType(elementTypes, elementFlags);
42216             if (includePatternInType) {
42217                 result = cloneTypeReference(result);
42218                 result.pattern = pattern;
42219                 result.objectFlags |= 1048576;
42220             }
42221             return result;
42222         }
42223         function getTypeFromBindingPattern(pattern, includePatternInType, reportErrors) {
42224             if (includePatternInType === void 0) { includePatternInType = false; }
42225             if (reportErrors === void 0) { reportErrors = false; }
42226             return pattern.kind === 196
42227                 ? getTypeFromObjectBindingPattern(pattern, includePatternInType, reportErrors)
42228                 : getTypeFromArrayBindingPattern(pattern, includePatternInType, reportErrors);
42229         }
42230         function getWidenedTypeForVariableLikeDeclaration(declaration, reportErrors) {
42231             return widenTypeForVariableLikeDeclaration(getTypeForVariableLikeDeclaration(declaration, true), declaration, reportErrors);
42232         }
42233         function widenTypeForVariableLikeDeclaration(type, declaration, reportErrors) {
42234             if (type) {
42235                 if (reportErrors) {
42236                     reportErrorsFromWidening(declaration, type);
42237                 }
42238                 if (type.flags & 8192 && (ts.isBindingElement(declaration) || !declaration.type) && type.symbol !== getSymbolOfNode(declaration)) {
42239                     type = esSymbolType;
42240                 }
42241                 return getWidenedType(type);
42242             }
42243             type = ts.isParameter(declaration) && declaration.dotDotDotToken ? anyArrayType : anyType;
42244             if (reportErrors) {
42245                 if (!declarationBelongsToPrivateAmbientMember(declaration)) {
42246                     reportImplicitAny(declaration, type);
42247                 }
42248             }
42249             return type;
42250         }
42251         function declarationBelongsToPrivateAmbientMember(declaration) {
42252             var root = ts.getRootDeclaration(declaration);
42253             var memberDeclaration = root.kind === 160 ? root.parent : root;
42254             return isPrivateWithinAmbient(memberDeclaration);
42255         }
42256         function tryGetTypeFromEffectiveTypeNode(declaration) {
42257             var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
42258             if (typeNode) {
42259                 return getTypeFromTypeNode(typeNode);
42260             }
42261         }
42262         function getTypeOfVariableOrParameterOrProperty(symbol) {
42263             var links = getSymbolLinks(symbol);
42264             if (!links.type) {
42265                 var type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
42266                 if (!links.type) {
42267                     links.type = type;
42268                 }
42269             }
42270             return links.type;
42271         }
42272         function getTypeOfVariableOrParameterOrPropertyWorker(symbol) {
42273             if (symbol.flags & 4194304) {
42274                 return getTypeOfPrototypeProperty(symbol);
42275             }
42276             if (symbol === requireSymbol) {
42277                 return anyType;
42278             }
42279             if (symbol.flags & 134217728) {
42280                 var fileSymbol = getSymbolOfNode(ts.getSourceFileOfNode(symbol.valueDeclaration));
42281                 var result = createSymbol(fileSymbol.flags, "exports");
42282                 result.declarations = fileSymbol.declarations ? fileSymbol.declarations.slice() : [];
42283                 result.parent = symbol;
42284                 result.target = fileSymbol;
42285                 if (fileSymbol.valueDeclaration)
42286                     result.valueDeclaration = fileSymbol.valueDeclaration;
42287                 if (fileSymbol.members)
42288                     result.members = new ts.Map(fileSymbol.members);
42289                 if (fileSymbol.exports)
42290                     result.exports = new ts.Map(fileSymbol.exports);
42291                 var members = ts.createSymbolTable();
42292                 members.set("exports", result);
42293                 return createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, undefined, undefined);
42294             }
42295             var declaration = symbol.valueDeclaration;
42296             if (ts.isCatchClauseVariableDeclarationOrBindingElement(declaration)) {
42297                 var decl = declaration;
42298                 if (!decl.type)
42299                     return anyType;
42300                 var type_1 = getTypeOfNode(decl.type);
42301                 return isTypeAny(type_1) || type_1 === unknownType ? type_1 : errorType;
42302             }
42303             if (ts.isSourceFile(declaration) && ts.isJsonSourceFile(declaration)) {
42304                 if (!declaration.statements.length) {
42305                     return emptyObjectType;
42306                 }
42307                 return getWidenedType(getWidenedLiteralType(checkExpression(declaration.statements[0].expression)));
42308             }
42309             if (!pushTypeResolution(symbol, 0)) {
42310                 if (symbol.flags & 512 && !(symbol.flags & 67108864)) {
42311                     return getTypeOfFuncClassEnumModule(symbol);
42312                 }
42313                 return reportCircularityError(symbol);
42314             }
42315             var type;
42316             if (declaration.kind === 266) {
42317                 type = widenTypeForVariableLikeDeclaration(checkExpressionCached(declaration.expression), declaration);
42318             }
42319             else if (ts.isBinaryExpression(declaration) ||
42320                 (ts.isInJSFile(declaration) &&
42321                     (ts.isCallExpression(declaration) || (ts.isPropertyAccessExpression(declaration) || ts.isBindableStaticElementAccessExpression(declaration)) && ts.isBinaryExpression(declaration.parent)))) {
42322                 type = getWidenedTypeForAssignmentDeclaration(symbol);
42323             }
42324             else if (ts.isPropertyAccessExpression(declaration)
42325                 || ts.isElementAccessExpression(declaration)
42326                 || ts.isIdentifier(declaration)
42327                 || ts.isStringLiteralLike(declaration)
42328                 || ts.isNumericLiteral(declaration)
42329                 || ts.isClassDeclaration(declaration)
42330                 || ts.isFunctionDeclaration(declaration)
42331                 || (ts.isMethodDeclaration(declaration) && !ts.isObjectLiteralMethod(declaration))
42332                 || ts.isMethodSignature(declaration)
42333                 || ts.isSourceFile(declaration)) {
42334                 if (symbol.flags & (16 | 8192 | 32 | 384 | 512)) {
42335                     return getTypeOfFuncClassEnumModule(symbol);
42336                 }
42337                 type = ts.isBinaryExpression(declaration.parent) ?
42338                     getWidenedTypeForAssignmentDeclaration(symbol) :
42339                     tryGetTypeFromEffectiveTypeNode(declaration) || anyType;
42340             }
42341             else if (ts.isPropertyAssignment(declaration)) {
42342                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkPropertyAssignment(declaration);
42343             }
42344             else if (ts.isJsxAttribute(declaration)) {
42345                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkJsxAttribute(declaration);
42346             }
42347             else if (ts.isShorthandPropertyAssignment(declaration)) {
42348                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkExpressionForMutableLocation(declaration.name, 0);
42349             }
42350             else if (ts.isObjectLiteralMethod(declaration)) {
42351                 type = tryGetTypeFromEffectiveTypeNode(declaration) || checkObjectLiteralMethod(declaration, 0);
42352             }
42353             else if (ts.isParameter(declaration)
42354                 || ts.isPropertyDeclaration(declaration)
42355                 || ts.isPropertySignature(declaration)
42356                 || ts.isVariableDeclaration(declaration)
42357                 || ts.isBindingElement(declaration)
42358                 || ts.isJSDocPropertyLikeTag(declaration)) {
42359                 type = getWidenedTypeForVariableLikeDeclaration(declaration, true);
42360             }
42361             else if (ts.isEnumDeclaration(declaration)) {
42362                 type = getTypeOfFuncClassEnumModule(symbol);
42363             }
42364             else if (ts.isEnumMember(declaration)) {
42365                 type = getTypeOfEnumMember(symbol);
42366             }
42367             else if (ts.isAccessor(declaration)) {
42368                 type = resolveTypeOfAccessors(symbol);
42369             }
42370             else {
42371                 return ts.Debug.fail("Unhandled declaration kind! " + ts.Debug.formatSyntaxKind(declaration.kind) + " for " + ts.Debug.formatSymbol(symbol));
42372             }
42373             if (!popTypeResolution()) {
42374                 if (symbol.flags & 512 && !(symbol.flags & 67108864)) {
42375                     return getTypeOfFuncClassEnumModule(symbol);
42376                 }
42377                 return reportCircularityError(symbol);
42378             }
42379             return type;
42380         }
42381         function getAnnotatedAccessorTypeNode(accessor) {
42382             if (accessor) {
42383                 if (accessor.kind === 167) {
42384                     var getterTypeAnnotation = ts.getEffectiveReturnTypeNode(accessor);
42385                     return getterTypeAnnotation;
42386                 }
42387                 else {
42388                     var setterTypeAnnotation = ts.getEffectiveSetAccessorTypeAnnotationNode(accessor);
42389                     return setterTypeAnnotation;
42390                 }
42391             }
42392             return undefined;
42393         }
42394         function getAnnotatedAccessorType(accessor) {
42395             var node = getAnnotatedAccessorTypeNode(accessor);
42396             return node && getTypeFromTypeNode(node);
42397         }
42398         function getAnnotatedAccessorThisParameter(accessor) {
42399             var parameter = getAccessorThisParameter(accessor);
42400             return parameter && parameter.symbol;
42401         }
42402         function getThisTypeOfDeclaration(declaration) {
42403             return getThisTypeOfSignature(getSignatureFromDeclaration(declaration));
42404         }
42405         function getTypeOfAccessors(symbol) {
42406             var links = getSymbolLinks(symbol);
42407             return links.type || (links.type = getTypeOfAccessorsWorker(symbol));
42408         }
42409         function getTypeOfAccessorsWorker(symbol) {
42410             if (!pushTypeResolution(symbol, 0)) {
42411                 return errorType;
42412             }
42413             var type = resolveTypeOfAccessors(symbol);
42414             if (!popTypeResolution()) {
42415                 type = anyType;
42416                 if (noImplicitAny) {
42417                     var getter = ts.getDeclarationOfKind(symbol, 167);
42418                     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));
42419                 }
42420             }
42421             return type;
42422         }
42423         function resolveTypeOfAccessors(symbol) {
42424             var getter = ts.getDeclarationOfKind(symbol, 167);
42425             var setter = ts.getDeclarationOfKind(symbol, 168);
42426             if (getter && ts.isInJSFile(getter)) {
42427                 var jsDocType = getTypeForDeclarationFromJSDocComment(getter);
42428                 if (jsDocType) {
42429                     return jsDocType;
42430                 }
42431             }
42432             var getterReturnType = getAnnotatedAccessorType(getter);
42433             if (getterReturnType) {
42434                 return getterReturnType;
42435             }
42436             else {
42437                 var setterParameterType = getAnnotatedAccessorType(setter);
42438                 if (setterParameterType) {
42439                     return setterParameterType;
42440                 }
42441                 else {
42442                     if (getter && getter.body) {
42443                         return getReturnTypeFromBody(getter);
42444                     }
42445                     else {
42446                         if (setter) {
42447                             if (!isPrivateWithinAmbient(setter)) {
42448                                 errorOrSuggestion(noImplicitAny, setter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_set_accessor_lacks_a_parameter_type_annotation, symbolToString(symbol));
42449                             }
42450                         }
42451                         else {
42452                             ts.Debug.assert(!!getter, "there must exist a getter as we are current checking either setter or getter in this function");
42453                             if (!isPrivateWithinAmbient(getter)) {
42454                                 errorOrSuggestion(noImplicitAny, getter, ts.Diagnostics.Property_0_implicitly_has_type_any_because_its_get_accessor_lacks_a_return_type_annotation, symbolToString(symbol));
42455                             }
42456                         }
42457                         return anyType;
42458                     }
42459                 }
42460             }
42461         }
42462         function getBaseTypeVariableOfClass(symbol) {
42463             var baseConstructorType = getBaseConstructorTypeOfClass(getDeclaredTypeOfClassOrInterface(symbol));
42464             return baseConstructorType.flags & 8650752 ? baseConstructorType :
42465                 baseConstructorType.flags & 2097152 ? ts.find(baseConstructorType.types, function (t) { return !!(t.flags & 8650752); }) :
42466                     undefined;
42467         }
42468         function getTypeOfFuncClassEnumModule(symbol) {
42469             var links = getSymbolLinks(symbol);
42470             var originalLinks = links;
42471             if (!links.type) {
42472                 var expando = symbol.valueDeclaration && getSymbolOfExpando(symbol.valueDeclaration, false);
42473                 if (expando) {
42474                     var merged = mergeJSSymbols(symbol, expando);
42475                     if (merged) {
42476                         symbol = links = merged;
42477                     }
42478                 }
42479                 originalLinks.type = links.type = getTypeOfFuncClassEnumModuleWorker(symbol);
42480             }
42481             return links.type;
42482         }
42483         function getTypeOfFuncClassEnumModuleWorker(symbol) {
42484             var declaration = symbol.valueDeclaration;
42485             if (symbol.flags & 1536 && ts.isShorthandAmbientModuleSymbol(symbol)) {
42486                 return anyType;
42487             }
42488             else if (declaration && (declaration.kind === 216 ||
42489                 ts.isAccessExpression(declaration) &&
42490                     declaration.parent.kind === 216)) {
42491                 return getWidenedTypeForAssignmentDeclaration(symbol);
42492             }
42493             else if (symbol.flags & 512 && declaration && ts.isSourceFile(declaration) && declaration.commonJsModuleIndicator) {
42494                 var resolvedModule = resolveExternalModuleSymbol(symbol);
42495                 if (resolvedModule !== symbol) {
42496                     if (!pushTypeResolution(symbol, 0)) {
42497                         return errorType;
42498                     }
42499                     var exportEquals = getMergedSymbol(symbol.exports.get("export="));
42500                     var type_2 = getWidenedTypeForAssignmentDeclaration(exportEquals, exportEquals === resolvedModule ? undefined : resolvedModule);
42501                     if (!popTypeResolution()) {
42502                         return reportCircularityError(symbol);
42503                     }
42504                     return type_2;
42505                 }
42506             }
42507             var type = createObjectType(16, symbol);
42508             if (symbol.flags & 32) {
42509                 var baseTypeVariable = getBaseTypeVariableOfClass(symbol);
42510                 return baseTypeVariable ? getIntersectionType([type, baseTypeVariable]) : type;
42511             }
42512             else {
42513                 return strictNullChecks && symbol.flags & 16777216 ? getOptionalType(type) : type;
42514             }
42515         }
42516         function getTypeOfEnumMember(symbol) {
42517             var links = getSymbolLinks(symbol);
42518             return links.type || (links.type = getDeclaredTypeOfEnumMember(symbol));
42519         }
42520         function getTypeOfAlias(symbol) {
42521             var links = getSymbolLinks(symbol);
42522             if (!links.type) {
42523                 var targetSymbol = resolveAlias(symbol);
42524                 links.type = targetSymbol.flags & 111551
42525                     ? getTypeOfSymbol(targetSymbol)
42526                     : errorType;
42527             }
42528             return links.type;
42529         }
42530         function getTypeOfInstantiatedSymbol(symbol) {
42531             var links = getSymbolLinks(symbol);
42532             if (!links.type) {
42533                 if (!pushTypeResolution(symbol, 0)) {
42534                     return links.type = errorType;
42535                 }
42536                 var type = instantiateType(getTypeOfSymbol(links.target), links.mapper);
42537                 if (!popTypeResolution()) {
42538                     type = reportCircularityError(symbol);
42539                 }
42540                 links.type = type;
42541             }
42542             return links.type;
42543         }
42544         function reportCircularityError(symbol) {
42545             var declaration = symbol.valueDeclaration;
42546             if (ts.getEffectiveTypeAnnotationNode(declaration)) {
42547                 error(symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_type_annotation, symbolToString(symbol));
42548                 return errorType;
42549             }
42550             if (noImplicitAny && (declaration.kind !== 160 || declaration.initializer)) {
42551                 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));
42552             }
42553             return anyType;
42554         }
42555         function getTypeOfSymbolWithDeferredType(symbol) {
42556             var links = getSymbolLinks(symbol);
42557             if (!links.type) {
42558                 ts.Debug.assertIsDefined(links.deferralParent);
42559                 ts.Debug.assertIsDefined(links.deferralConstituents);
42560                 links.type = links.deferralParent.flags & 1048576 ? getUnionType(links.deferralConstituents) : getIntersectionType(links.deferralConstituents);
42561             }
42562             return links.type;
42563         }
42564         function getTypeOfSymbol(symbol) {
42565             var checkFlags = ts.getCheckFlags(symbol);
42566             if (checkFlags & 65536) {
42567                 return getTypeOfSymbolWithDeferredType(symbol);
42568             }
42569             if (checkFlags & 1) {
42570                 return getTypeOfInstantiatedSymbol(symbol);
42571             }
42572             if (checkFlags & 262144) {
42573                 return getTypeOfMappedSymbol(symbol);
42574             }
42575             if (checkFlags & 8192) {
42576                 return getTypeOfReverseMappedSymbol(symbol);
42577             }
42578             if (symbol.flags & (3 | 4)) {
42579                 return getTypeOfVariableOrParameterOrProperty(symbol);
42580             }
42581             if (symbol.flags & (16 | 8192 | 32 | 384 | 512)) {
42582                 return getTypeOfFuncClassEnumModule(symbol);
42583             }
42584             if (symbol.flags & 8) {
42585                 return getTypeOfEnumMember(symbol);
42586             }
42587             if (symbol.flags & 98304) {
42588                 return getTypeOfAccessors(symbol);
42589             }
42590             if (symbol.flags & 2097152) {
42591                 return getTypeOfAlias(symbol);
42592             }
42593             return errorType;
42594         }
42595         function isReferenceToType(type, target) {
42596             return type !== undefined
42597                 && target !== undefined
42598                 && (ts.getObjectFlags(type) & 4) !== 0
42599                 && type.target === target;
42600         }
42601         function getTargetType(type) {
42602             return ts.getObjectFlags(type) & 4 ? type.target : type;
42603         }
42604         function hasBaseType(type, checkBase) {
42605             return check(type);
42606             function check(type) {
42607                 if (ts.getObjectFlags(type) & (3 | 4)) {
42608                     var target = getTargetType(type);
42609                     return target === checkBase || ts.some(getBaseTypes(target), check);
42610                 }
42611                 else if (type.flags & 2097152) {
42612                     return ts.some(type.types, check);
42613                 }
42614                 return false;
42615             }
42616         }
42617         function appendTypeParameters(typeParameters, declarations) {
42618             for (var _i = 0, declarations_2 = declarations; _i < declarations_2.length; _i++) {
42619                 var declaration = declarations_2[_i];
42620                 typeParameters = ts.appendIfUnique(typeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(declaration)));
42621             }
42622             return typeParameters;
42623         }
42624         function getOuterTypeParameters(node, includeThisTypes) {
42625             while (true) {
42626                 node = node.parent;
42627                 if (node && ts.isBinaryExpression(node)) {
42628                     var assignmentKind = ts.getAssignmentDeclarationKind(node);
42629                     if (assignmentKind === 6 || assignmentKind === 3) {
42630                         var symbol = getSymbolOfNode(node.left);
42631                         if (symbol && symbol.parent && !ts.findAncestor(symbol.parent.valueDeclaration, function (d) { return node === d; })) {
42632                             node = symbol.parent.valueDeclaration;
42633                         }
42634                     }
42635                 }
42636                 if (!node) {
42637                     return undefined;
42638                 }
42639                 switch (node.kind) {
42640                     case 232:
42641                     case 252:
42642                     case 221:
42643                     case 253:
42644                     case 169:
42645                     case 170:
42646                     case 164:
42647                     case 174:
42648                     case 175:
42649                     case 308:
42650                     case 251:
42651                     case 165:
42652                     case 208:
42653                     case 209:
42654                     case 254:
42655                     case 330:
42656                     case 331:
42657                     case 325:
42658                     case 324:
42659                     case 190:
42660                     case 184:
42661                         var outerTypeParameters = getOuterTypeParameters(node, includeThisTypes);
42662                         if (node.kind === 190) {
42663                             return ts.append(outerTypeParameters, getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter)));
42664                         }
42665                         else if (node.kind === 184) {
42666                             return ts.concatenate(outerTypeParameters, getInferTypeParameters(node));
42667                         }
42668                         else if (node.kind === 232 && !ts.isInJSFile(node)) {
42669                             break;
42670                         }
42671                         var outerAndOwnTypeParameters = appendTypeParameters(outerTypeParameters, ts.getEffectiveTypeParameterDeclarations(node));
42672                         var thisType = includeThisTypes &&
42673                             (node.kind === 252 || node.kind === 221 || node.kind === 253 || isJSConstructor(node)) &&
42674                             getDeclaredTypeOfClassOrInterface(getSymbolOfNode(node)).thisType;
42675                         return thisType ? ts.append(outerAndOwnTypeParameters, thisType) : outerAndOwnTypeParameters;
42676                     case 326:
42677                         var paramSymbol = ts.getParameterSymbolFromJSDoc(node);
42678                         if (paramSymbol) {
42679                             node = paramSymbol.valueDeclaration;
42680                         }
42681                         break;
42682                 }
42683             }
42684         }
42685         function getOuterTypeParametersOfClassOrInterface(symbol) {
42686             var declaration = symbol.flags & 32 ? symbol.valueDeclaration : ts.getDeclarationOfKind(symbol, 253);
42687             ts.Debug.assert(!!declaration, "Class was missing valueDeclaration -OR- non-class had no interface declarations");
42688             return getOuterTypeParameters(declaration);
42689         }
42690         function getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) {
42691             var result;
42692             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
42693                 var node = _a[_i];
42694                 if (node.kind === 253 ||
42695                     node.kind === 252 ||
42696                     node.kind === 221 ||
42697                     isJSConstructor(node) ||
42698                     ts.isTypeAlias(node)) {
42699                     var declaration = node;
42700                     result = appendTypeParameters(result, ts.getEffectiveTypeParameterDeclarations(declaration));
42701                 }
42702             }
42703             return result;
42704         }
42705         function getTypeParametersOfClassOrInterface(symbol) {
42706             return ts.concatenate(getOuterTypeParametersOfClassOrInterface(symbol), getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol));
42707         }
42708         function isMixinConstructorType(type) {
42709             var signatures = getSignaturesOfType(type, 1);
42710             if (signatures.length === 1) {
42711                 var s = signatures[0];
42712                 if (!s.typeParameters && s.parameters.length === 1 && signatureHasRestParameter(s)) {
42713                     var paramType = getTypeOfParameter(s.parameters[0]);
42714                     return isTypeAny(paramType) || getElementTypeOfArrayType(paramType) === anyType;
42715                 }
42716             }
42717             return false;
42718         }
42719         function isConstructorType(type) {
42720             if (getSignaturesOfType(type, 1).length > 0) {
42721                 return true;
42722             }
42723             if (type.flags & 8650752) {
42724                 var constraint = getBaseConstraintOfType(type);
42725                 return !!constraint && isMixinConstructorType(constraint);
42726             }
42727             return false;
42728         }
42729         function getBaseTypeNodeOfClass(type) {
42730             return ts.getEffectiveBaseTypeNode(type.symbol.valueDeclaration);
42731         }
42732         function getConstructorsForTypeArguments(type, typeArgumentNodes, location) {
42733             var typeArgCount = ts.length(typeArgumentNodes);
42734             var isJavascript = ts.isInJSFile(location);
42735             return ts.filter(getSignaturesOfType(type, 1), function (sig) { return (isJavascript || typeArgCount >= getMinTypeArgumentCount(sig.typeParameters)) && typeArgCount <= ts.length(sig.typeParameters); });
42736         }
42737         function getInstantiatedConstructorsForTypeArguments(type, typeArgumentNodes, location) {
42738             var signatures = getConstructorsForTypeArguments(type, typeArgumentNodes, location);
42739             var typeArguments = ts.map(typeArgumentNodes, getTypeFromTypeNode);
42740             return ts.sameMap(signatures, function (sig) { return ts.some(sig.typeParameters) ? getSignatureInstantiation(sig, typeArguments, ts.isInJSFile(location)) : sig; });
42741         }
42742         function getBaseConstructorTypeOfClass(type) {
42743             if (!type.resolvedBaseConstructorType) {
42744                 var decl = type.symbol.valueDeclaration;
42745                 var extended = ts.getEffectiveBaseTypeNode(decl);
42746                 var baseTypeNode = getBaseTypeNodeOfClass(type);
42747                 if (!baseTypeNode) {
42748                     return type.resolvedBaseConstructorType = undefinedType;
42749                 }
42750                 if (!pushTypeResolution(type, 1)) {
42751                     return errorType;
42752                 }
42753                 var baseConstructorType = checkExpression(baseTypeNode.expression);
42754                 if (extended && baseTypeNode !== extended) {
42755                     ts.Debug.assert(!extended.typeArguments);
42756                     checkExpression(extended.expression);
42757                 }
42758                 if (baseConstructorType.flags & (524288 | 2097152)) {
42759                     resolveStructuredTypeMembers(baseConstructorType);
42760                 }
42761                 if (!popTypeResolution()) {
42762                     error(type.symbol.valueDeclaration, ts.Diagnostics._0_is_referenced_directly_or_indirectly_in_its_own_base_expression, symbolToString(type.symbol));
42763                     return type.resolvedBaseConstructorType = errorType;
42764                 }
42765                 if (!(baseConstructorType.flags & 1) && baseConstructorType !== nullWideningType && !isConstructorType(baseConstructorType)) {
42766                     var err = error(baseTypeNode.expression, ts.Diagnostics.Type_0_is_not_a_constructor_function_type, typeToString(baseConstructorType));
42767                     if (baseConstructorType.flags & 262144) {
42768                         var constraint = getConstraintFromTypeParameter(baseConstructorType);
42769                         var ctorReturn = unknownType;
42770                         if (constraint) {
42771                             var ctorSig = getSignaturesOfType(constraint, 1);
42772                             if (ctorSig[0]) {
42773                                 ctorReturn = getReturnTypeOfSignature(ctorSig[0]);
42774                             }
42775                         }
42776                         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)));
42777                     }
42778                     return type.resolvedBaseConstructorType = errorType;
42779                 }
42780                 type.resolvedBaseConstructorType = baseConstructorType;
42781             }
42782             return type.resolvedBaseConstructorType;
42783         }
42784         function getImplementsTypes(type) {
42785             var resolvedImplementsTypes = ts.emptyArray;
42786             for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) {
42787                 var declaration = _a[_i];
42788                 var implementsTypeNodes = ts.getEffectiveImplementsTypeNodes(declaration);
42789                 if (!implementsTypeNodes)
42790                     continue;
42791                 for (var _b = 0, implementsTypeNodes_1 = implementsTypeNodes; _b < implementsTypeNodes_1.length; _b++) {
42792                     var node = implementsTypeNodes_1[_b];
42793                     var implementsType = getTypeFromTypeNode(node);
42794                     if (implementsType !== errorType) {
42795                         if (resolvedImplementsTypes === ts.emptyArray) {
42796                             resolvedImplementsTypes = [implementsType];
42797                         }
42798                         else {
42799                             resolvedImplementsTypes.push(implementsType);
42800                         }
42801                     }
42802                 }
42803             }
42804             return resolvedImplementsTypes;
42805         }
42806         function reportCircularBaseType(node, type) {
42807             error(node, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 2));
42808         }
42809         function getBaseTypes(type) {
42810             if (!type.baseTypesResolved) {
42811                 if (pushTypeResolution(type, 7)) {
42812                     if (type.objectFlags & 8) {
42813                         type.resolvedBaseTypes = [getTupleBaseType(type)];
42814                     }
42815                     else if (type.symbol.flags & (32 | 64)) {
42816                         if (type.symbol.flags & 32) {
42817                             resolveBaseTypesOfClass(type);
42818                         }
42819                         if (type.symbol.flags & 64) {
42820                             resolveBaseTypesOfInterface(type);
42821                         }
42822                     }
42823                     else {
42824                         ts.Debug.fail("type must be class or interface");
42825                     }
42826                     if (!popTypeResolution()) {
42827                         for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) {
42828                             var declaration = _a[_i];
42829                             if (declaration.kind === 252 || declaration.kind === 253) {
42830                                 reportCircularBaseType(declaration, type);
42831                             }
42832                         }
42833                     }
42834                 }
42835                 type.baseTypesResolved = true;
42836             }
42837             return type.resolvedBaseTypes;
42838         }
42839         function getTupleBaseType(type) {
42840             var elementTypes = ts.sameMap(type.typeParameters, function (t, i) { return type.elementFlags[i] & 8 ? getIndexedAccessType(t, numberType) : t; });
42841             return createArrayType(getUnionType(elementTypes || ts.emptyArray), type.readonly);
42842         }
42843         function resolveBaseTypesOfClass(type) {
42844             type.resolvedBaseTypes = ts.resolvingEmptyArray;
42845             var baseConstructorType = getApparentType(getBaseConstructorTypeOfClass(type));
42846             if (!(baseConstructorType.flags & (524288 | 2097152 | 1))) {
42847                 return type.resolvedBaseTypes = ts.emptyArray;
42848             }
42849             var baseTypeNode = getBaseTypeNodeOfClass(type);
42850             var baseType;
42851             var originalBaseType = baseConstructorType.symbol ? getDeclaredTypeOfSymbol(baseConstructorType.symbol) : undefined;
42852             if (baseConstructorType.symbol && baseConstructorType.symbol.flags & 32 &&
42853                 areAllOuterTypeParametersApplied(originalBaseType)) {
42854                 baseType = getTypeFromClassOrInterfaceReference(baseTypeNode, baseConstructorType.symbol);
42855             }
42856             else if (baseConstructorType.flags & 1) {
42857                 baseType = baseConstructorType;
42858             }
42859             else {
42860                 var constructors = getInstantiatedConstructorsForTypeArguments(baseConstructorType, baseTypeNode.typeArguments, baseTypeNode);
42861                 if (!constructors.length) {
42862                     error(baseTypeNode.expression, ts.Diagnostics.No_base_constructor_has_the_specified_number_of_type_arguments);
42863                     return type.resolvedBaseTypes = ts.emptyArray;
42864                 }
42865                 baseType = getReturnTypeOfSignature(constructors[0]);
42866             }
42867             if (baseType === errorType) {
42868                 return type.resolvedBaseTypes = ts.emptyArray;
42869             }
42870             var reducedBaseType = getReducedType(baseType);
42871             if (!isValidBaseType(reducedBaseType)) {
42872                 var elaboration = elaborateNeverIntersection(undefined, baseType);
42873                 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));
42874                 diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(baseTypeNode.expression, diagnostic));
42875                 return type.resolvedBaseTypes = ts.emptyArray;
42876             }
42877             if (type === reducedBaseType || hasBaseType(reducedBaseType, type)) {
42878                 error(type.symbol.valueDeclaration, ts.Diagnostics.Type_0_recursively_references_itself_as_a_base_type, typeToString(type, undefined, 2));
42879                 return type.resolvedBaseTypes = ts.emptyArray;
42880             }
42881             if (type.resolvedBaseTypes === ts.resolvingEmptyArray) {
42882                 type.members = undefined;
42883             }
42884             return type.resolvedBaseTypes = [reducedBaseType];
42885         }
42886         function areAllOuterTypeParametersApplied(type) {
42887             var outerTypeParameters = type.outerTypeParameters;
42888             if (outerTypeParameters) {
42889                 var last_1 = outerTypeParameters.length - 1;
42890                 var typeArguments = getTypeArguments(type);
42891                 return outerTypeParameters[last_1].symbol !== typeArguments[last_1].symbol;
42892             }
42893             return true;
42894         }
42895         function isValidBaseType(type) {
42896             if (type.flags & 262144) {
42897                 var constraint = getBaseConstraintOfType(type);
42898                 if (constraint) {
42899                     return isValidBaseType(constraint);
42900                 }
42901             }
42902             return !!(type.flags & (524288 | 67108864 | 1) && !isGenericMappedType(type) ||
42903                 type.flags & 2097152 && ts.every(type.types, isValidBaseType));
42904         }
42905         function resolveBaseTypesOfInterface(type) {
42906             type.resolvedBaseTypes = type.resolvedBaseTypes || ts.emptyArray;
42907             for (var _i = 0, _a = type.symbol.declarations; _i < _a.length; _i++) {
42908                 var declaration = _a[_i];
42909                 if (declaration.kind === 253 && ts.getInterfaceBaseTypeNodes(declaration)) {
42910                     for (var _b = 0, _c = ts.getInterfaceBaseTypeNodes(declaration); _b < _c.length; _b++) {
42911                         var node = _c[_b];
42912                         var baseType = getReducedType(getTypeFromTypeNode(node));
42913                         if (baseType !== errorType) {
42914                             if (isValidBaseType(baseType)) {
42915                                 if (type !== baseType && !hasBaseType(baseType, type)) {
42916                                     if (type.resolvedBaseTypes === ts.emptyArray) {
42917                                         type.resolvedBaseTypes = [baseType];
42918                                     }
42919                                     else {
42920                                         type.resolvedBaseTypes.push(baseType);
42921                                     }
42922                                 }
42923                                 else {
42924                                     reportCircularBaseType(declaration, type);
42925                                 }
42926                             }
42927                             else {
42928                                 error(node, ts.Diagnostics.An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_members);
42929                             }
42930                         }
42931                     }
42932                 }
42933             }
42934         }
42935         function isThislessInterface(symbol) {
42936             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
42937                 var declaration = _a[_i];
42938                 if (declaration.kind === 253) {
42939                     if (declaration.flags & 128) {
42940                         return false;
42941                     }
42942                     var baseTypeNodes = ts.getInterfaceBaseTypeNodes(declaration);
42943                     if (baseTypeNodes) {
42944                         for (var _b = 0, baseTypeNodes_1 = baseTypeNodes; _b < baseTypeNodes_1.length; _b++) {
42945                             var node = baseTypeNodes_1[_b];
42946                             if (ts.isEntityNameExpression(node.expression)) {
42947                                 var baseSymbol = resolveEntityName(node.expression, 788968, true);
42948                                 if (!baseSymbol || !(baseSymbol.flags & 64) || getDeclaredTypeOfClassOrInterface(baseSymbol).thisType) {
42949                                     return false;
42950                                 }
42951                             }
42952                         }
42953                     }
42954                 }
42955             }
42956             return true;
42957         }
42958         function getDeclaredTypeOfClassOrInterface(symbol) {
42959             var links = getSymbolLinks(symbol);
42960             var originalLinks = links;
42961             if (!links.declaredType) {
42962                 var kind = symbol.flags & 32 ? 1 : 2;
42963                 var merged = mergeJSSymbols(symbol, getAssignedClassSymbol(symbol.valueDeclaration));
42964                 if (merged) {
42965                     symbol = links = merged;
42966                 }
42967                 var type = originalLinks.declaredType = links.declaredType = createObjectType(kind, symbol);
42968                 var outerTypeParameters = getOuterTypeParametersOfClassOrInterface(symbol);
42969                 var localTypeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
42970                 if (outerTypeParameters || localTypeParameters || kind === 1 || !isThislessInterface(symbol)) {
42971                     type.objectFlags |= 4;
42972                     type.typeParameters = ts.concatenate(outerTypeParameters, localTypeParameters);
42973                     type.outerTypeParameters = outerTypeParameters;
42974                     type.localTypeParameters = localTypeParameters;
42975                     type.instantiations = new ts.Map();
42976                     type.instantiations.set(getTypeListId(type.typeParameters), type);
42977                     type.target = type;
42978                     type.resolvedTypeArguments = type.typeParameters;
42979                     type.thisType = createTypeParameter(symbol);
42980                     type.thisType.isThisType = true;
42981                     type.thisType.constraint = type;
42982                 }
42983             }
42984             return links.declaredType;
42985         }
42986         function getDeclaredTypeOfTypeAlias(symbol) {
42987             var links = getSymbolLinks(symbol);
42988             if (!links.declaredType) {
42989                 if (!pushTypeResolution(symbol, 2)) {
42990                     return errorType;
42991                 }
42992                 var declaration = ts.Debug.checkDefined(ts.find(symbol.declarations, ts.isTypeAlias), "Type alias symbol with no valid declaration found");
42993                 var typeNode = ts.isJSDocTypeAlias(declaration) ? declaration.typeExpression : declaration.type;
42994                 var type = typeNode ? getTypeFromTypeNode(typeNode) : errorType;
42995                 if (popTypeResolution()) {
42996                     var typeParameters = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol);
42997                     if (typeParameters) {
42998                         links.typeParameters = typeParameters;
42999                         links.instantiations = new ts.Map();
43000                         links.instantiations.set(getTypeListId(typeParameters), type);
43001                     }
43002                 }
43003                 else {
43004                     type = errorType;
43005                     error(ts.isNamedDeclaration(declaration) ? declaration.name : declaration || declaration, ts.Diagnostics.Type_alias_0_circularly_references_itself, symbolToString(symbol));
43006                 }
43007                 links.declaredType = type;
43008             }
43009             return links.declaredType;
43010         }
43011         function isStringConcatExpression(expr) {
43012             if (ts.isStringLiteralLike(expr)) {
43013                 return true;
43014             }
43015             else if (expr.kind === 216) {
43016                 return isStringConcatExpression(expr.left) && isStringConcatExpression(expr.right);
43017             }
43018             return false;
43019         }
43020         function isLiteralEnumMember(member) {
43021             var expr = member.initializer;
43022             if (!expr) {
43023                 return !(member.flags & 8388608);
43024             }
43025             switch (expr.kind) {
43026                 case 10:
43027                 case 8:
43028                 case 14:
43029                     return true;
43030                 case 214:
43031                     return expr.operator === 40 &&
43032                         expr.operand.kind === 8;
43033                 case 78:
43034                     return ts.nodeIsMissing(expr) || !!getSymbolOfNode(member.parent).exports.get(expr.escapedText);
43035                 case 216:
43036                     return isStringConcatExpression(expr);
43037                 default:
43038                     return false;
43039             }
43040         }
43041         function getEnumKind(symbol) {
43042             var links = getSymbolLinks(symbol);
43043             if (links.enumKind !== undefined) {
43044                 return links.enumKind;
43045             }
43046             var hasNonLiteralMember = false;
43047             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
43048                 var declaration = _a[_i];
43049                 if (declaration.kind === 255) {
43050                     for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) {
43051                         var member = _c[_b];
43052                         if (member.initializer && ts.isStringLiteralLike(member.initializer)) {
43053                             return links.enumKind = 1;
43054                         }
43055                         if (!isLiteralEnumMember(member)) {
43056                             hasNonLiteralMember = true;
43057                         }
43058                     }
43059                 }
43060             }
43061             return links.enumKind = hasNonLiteralMember ? 0 : 1;
43062         }
43063         function getBaseTypeOfEnumLiteralType(type) {
43064             return type.flags & 1024 && !(type.flags & 1048576) ? getDeclaredTypeOfSymbol(getParentOfSymbol(type.symbol)) : type;
43065         }
43066         function getDeclaredTypeOfEnum(symbol) {
43067             var links = getSymbolLinks(symbol);
43068             if (links.declaredType) {
43069                 return links.declaredType;
43070             }
43071             if (getEnumKind(symbol) === 1) {
43072                 enumCount++;
43073                 var memberTypeList = [];
43074                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
43075                     var declaration = _a[_i];
43076                     if (declaration.kind === 255) {
43077                         for (var _b = 0, _c = declaration.members; _b < _c.length; _b++) {
43078                             var member = _c[_b];
43079                             var value = getEnumMemberValue(member);
43080                             var memberType = getFreshTypeOfLiteralType(getLiteralType(value !== undefined ? value : 0, enumCount, getSymbolOfNode(member)));
43081                             getSymbolLinks(getSymbolOfNode(member)).declaredType = memberType;
43082                             memberTypeList.push(getRegularTypeOfLiteralType(memberType));
43083                         }
43084                     }
43085                 }
43086                 if (memberTypeList.length) {
43087                     var enumType_1 = getUnionType(memberTypeList, 1, symbol, undefined);
43088                     if (enumType_1.flags & 1048576) {
43089                         enumType_1.flags |= 1024;
43090                         enumType_1.symbol = symbol;
43091                     }
43092                     return links.declaredType = enumType_1;
43093                 }
43094             }
43095             var enumType = createType(32);
43096             enumType.symbol = symbol;
43097             return links.declaredType = enumType;
43098         }
43099         function getDeclaredTypeOfEnumMember(symbol) {
43100             var links = getSymbolLinks(symbol);
43101             if (!links.declaredType) {
43102                 var enumType = getDeclaredTypeOfEnum(getParentOfSymbol(symbol));
43103                 if (!links.declaredType) {
43104                     links.declaredType = enumType;
43105                 }
43106             }
43107             return links.declaredType;
43108         }
43109         function getDeclaredTypeOfTypeParameter(symbol) {
43110             var links = getSymbolLinks(symbol);
43111             return links.declaredType || (links.declaredType = createTypeParameter(symbol));
43112         }
43113         function getDeclaredTypeOfAlias(symbol) {
43114             var links = getSymbolLinks(symbol);
43115             return links.declaredType || (links.declaredType = getDeclaredTypeOfSymbol(resolveAlias(symbol)));
43116         }
43117         function getDeclaredTypeOfSymbol(symbol) {
43118             return tryGetDeclaredTypeOfSymbol(symbol) || errorType;
43119         }
43120         function tryGetDeclaredTypeOfSymbol(symbol) {
43121             if (symbol.flags & (32 | 64)) {
43122                 return getDeclaredTypeOfClassOrInterface(symbol);
43123             }
43124             if (symbol.flags & 524288) {
43125                 return getDeclaredTypeOfTypeAlias(symbol);
43126             }
43127             if (symbol.flags & 262144) {
43128                 return getDeclaredTypeOfTypeParameter(symbol);
43129             }
43130             if (symbol.flags & 384) {
43131                 return getDeclaredTypeOfEnum(symbol);
43132             }
43133             if (symbol.flags & 8) {
43134                 return getDeclaredTypeOfEnumMember(symbol);
43135             }
43136             if (symbol.flags & 2097152) {
43137                 return getDeclaredTypeOfAlias(symbol);
43138             }
43139             return undefined;
43140         }
43141         function isThislessType(node) {
43142             switch (node.kind) {
43143                 case 128:
43144                 case 152:
43145                 case 147:
43146                 case 144:
43147                 case 155:
43148                 case 131:
43149                 case 148:
43150                 case 145:
43151                 case 113:
43152                 case 150:
43153                 case 141:
43154                 case 191:
43155                     return true;
43156                 case 178:
43157                     return isThislessType(node.elementType);
43158                 case 173:
43159                     return !node.typeArguments || node.typeArguments.every(isThislessType);
43160             }
43161             return false;
43162         }
43163         function isThislessTypeParameter(node) {
43164             var constraint = ts.getEffectiveConstraintOfTypeParameter(node);
43165             return !constraint || isThislessType(constraint);
43166         }
43167         function isThislessVariableLikeDeclaration(node) {
43168             var typeNode = ts.getEffectiveTypeAnnotationNode(node);
43169             return typeNode ? isThislessType(typeNode) : !ts.hasInitializer(node);
43170         }
43171         function isThislessFunctionLikeDeclaration(node) {
43172             var returnType = ts.getEffectiveReturnTypeNode(node);
43173             var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
43174             return (node.kind === 166 || (!!returnType && isThislessType(returnType))) &&
43175                 node.parameters.every(isThislessVariableLikeDeclaration) &&
43176                 typeParameters.every(isThislessTypeParameter);
43177         }
43178         function isThisless(symbol) {
43179             if (symbol.declarations && symbol.declarations.length === 1) {
43180                 var declaration = symbol.declarations[0];
43181                 if (declaration) {
43182                     switch (declaration.kind) {
43183                         case 163:
43184                         case 162:
43185                             return isThislessVariableLikeDeclaration(declaration);
43186                         case 165:
43187                         case 164:
43188                         case 166:
43189                         case 167:
43190                         case 168:
43191                             return isThislessFunctionLikeDeclaration(declaration);
43192                     }
43193                 }
43194             }
43195             return false;
43196         }
43197         function createInstantiatedSymbolTable(symbols, mapper, mappingThisOnly) {
43198             var result = ts.createSymbolTable();
43199             for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
43200                 var symbol = symbols_2[_i];
43201                 result.set(symbol.escapedName, mappingThisOnly && isThisless(symbol) ? symbol : instantiateSymbol(symbol, mapper));
43202             }
43203             return result;
43204         }
43205         function addInheritedMembers(symbols, baseSymbols) {
43206             for (var _i = 0, baseSymbols_1 = baseSymbols; _i < baseSymbols_1.length; _i++) {
43207                 var s = baseSymbols_1[_i];
43208                 if (!symbols.has(s.escapedName) && !isStaticPrivateIdentifierProperty(s)) {
43209                     symbols.set(s.escapedName, s);
43210                 }
43211             }
43212         }
43213         function isStaticPrivateIdentifierProperty(s) {
43214             return !!s.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(s.valueDeclaration) && ts.hasSyntacticModifier(s.valueDeclaration, 32);
43215         }
43216         function resolveDeclaredMembers(type) {
43217             if (!type.declaredProperties) {
43218                 var symbol = type.symbol;
43219                 var members = getMembersOfSymbol(symbol);
43220                 type.declaredProperties = getNamedMembers(members);
43221                 type.declaredCallSignatures = ts.emptyArray;
43222                 type.declaredConstructSignatures = ts.emptyArray;
43223                 type.declaredCallSignatures = getSignaturesOfSymbol(members.get("__call"));
43224                 type.declaredConstructSignatures = getSignaturesOfSymbol(members.get("__new"));
43225                 type.declaredStringIndexInfo = getIndexInfoOfSymbol(symbol, 0);
43226                 type.declaredNumberIndexInfo = getIndexInfoOfSymbol(symbol, 1);
43227             }
43228             return type;
43229         }
43230         function isTypeUsableAsPropertyName(type) {
43231             return !!(type.flags & 8576);
43232         }
43233         function isLateBindableName(node) {
43234             if (!ts.isComputedPropertyName(node) && !ts.isElementAccessExpression(node)) {
43235                 return false;
43236             }
43237             var expr = ts.isComputedPropertyName(node) ? node.expression : node.argumentExpression;
43238             return ts.isEntityNameExpression(expr)
43239                 && isTypeUsableAsPropertyName(ts.isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(expr));
43240         }
43241         function isLateBoundName(name) {
43242             return name.charCodeAt(0) === 95 &&
43243                 name.charCodeAt(1) === 95 &&
43244                 name.charCodeAt(2) === 64;
43245         }
43246         function hasLateBindableName(node) {
43247             var name = ts.getNameOfDeclaration(node);
43248             return !!name && isLateBindableName(name);
43249         }
43250         function hasBindableName(node) {
43251             return !ts.hasDynamicName(node) || hasLateBindableName(node);
43252         }
43253         function isNonBindableDynamicName(node) {
43254             return ts.isDynamicName(node) && !isLateBindableName(node);
43255         }
43256         function getPropertyNameFromType(type) {
43257             if (type.flags & 8192) {
43258                 return type.escapedName;
43259             }
43260             if (type.flags & (128 | 256)) {
43261                 return ts.escapeLeadingUnderscores("" + type.value);
43262             }
43263             return ts.Debug.fail();
43264         }
43265         function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) {
43266             ts.Debug.assert(!!(ts.getCheckFlags(symbol) & 4096), "Expected a late-bound symbol.");
43267             symbol.flags |= symbolFlags;
43268             getSymbolLinks(member.symbol).lateSymbol = symbol;
43269             if (!symbol.declarations) {
43270                 symbol.declarations = [member];
43271             }
43272             else {
43273                 symbol.declarations.push(member);
43274             }
43275             if (symbolFlags & 111551) {
43276                 if (!symbol.valueDeclaration || symbol.valueDeclaration.kind !== member.kind) {
43277                     symbol.valueDeclaration = member;
43278                 }
43279             }
43280         }
43281         function lateBindMember(parent, earlySymbols, lateSymbols, decl) {
43282             ts.Debug.assert(!!decl.symbol, "The member is expected to have a symbol.");
43283             var links = getNodeLinks(decl);
43284             if (!links.resolvedSymbol) {
43285                 links.resolvedSymbol = decl.symbol;
43286                 var declName = ts.isBinaryExpression(decl) ? decl.left : decl.name;
43287                 var type = ts.isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName);
43288                 if (isTypeUsableAsPropertyName(type)) {
43289                     var memberName = getPropertyNameFromType(type);
43290                     var symbolFlags = decl.symbol.flags;
43291                     var lateSymbol = lateSymbols.get(memberName);
43292                     if (!lateSymbol)
43293                         lateSymbols.set(memberName, lateSymbol = createSymbol(0, memberName, 4096));
43294                     var earlySymbol = earlySymbols && earlySymbols.get(memberName);
43295                     if (lateSymbol.flags & getExcludedSymbolFlags(symbolFlags) || earlySymbol) {
43296                         var declarations = earlySymbol ? ts.concatenate(earlySymbol.declarations, lateSymbol.declarations) : lateSymbol.declarations;
43297                         var name_4 = !(type.flags & 8192) && ts.unescapeLeadingUnderscores(memberName) || ts.declarationNameToString(declName);
43298                         ts.forEach(declarations, function (declaration) { return error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Property_0_was_also_declared_here, name_4); });
43299                         error(declName || decl, ts.Diagnostics.Duplicate_property_0, name_4);
43300                         lateSymbol = createSymbol(0, memberName, 4096);
43301                     }
43302                     lateSymbol.nameType = type;
43303                     addDeclarationToLateBoundSymbol(lateSymbol, decl, symbolFlags);
43304                     if (lateSymbol.parent) {
43305                         ts.Debug.assert(lateSymbol.parent === parent, "Existing symbol parent should match new one");
43306                     }
43307                     else {
43308                         lateSymbol.parent = parent;
43309                     }
43310                     return links.resolvedSymbol = lateSymbol;
43311                 }
43312             }
43313             return links.resolvedSymbol;
43314         }
43315         function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) {
43316             var links = getSymbolLinks(symbol);
43317             if (!links[resolutionKind]) {
43318                 var isStatic = resolutionKind === "resolvedExports";
43319                 var earlySymbols = !isStatic ? symbol.members :
43320                     symbol.flags & 1536 ? getExportsOfModuleWorker(symbol) :
43321                         symbol.exports;
43322                 links[resolutionKind] = earlySymbols || emptySymbols;
43323                 var lateSymbols = ts.createSymbolTable();
43324                 for (var _i = 0, _a = symbol.declarations || ts.emptyArray; _i < _a.length; _i++) {
43325                     var decl = _a[_i];
43326                     var members = ts.getMembersOfDeclaration(decl);
43327                     if (members) {
43328                         for (var _b = 0, members_5 = members; _b < members_5.length; _b++) {
43329                             var member = members_5[_b];
43330                             if (isStatic === ts.hasStaticModifier(member) && hasLateBindableName(member)) {
43331                                 lateBindMember(symbol, earlySymbols, lateSymbols, member);
43332                             }
43333                         }
43334                     }
43335                 }
43336                 var assignments = symbol.assignmentDeclarationMembers;
43337                 if (assignments) {
43338                     var decls = ts.arrayFrom(assignments.values());
43339                     for (var _c = 0, decls_1 = decls; _c < decls_1.length; _c++) {
43340                         var member = decls_1[_c];
43341                         var assignmentKind = ts.getAssignmentDeclarationKind(member);
43342                         var isInstanceMember = assignmentKind === 3
43343                             || ts.isBinaryExpression(member) && isPossiblyAliasedThisProperty(member, assignmentKind)
43344                             || assignmentKind === 9
43345                             || assignmentKind === 6;
43346                         if (isStatic === !isInstanceMember && hasLateBindableName(member)) {
43347                             lateBindMember(symbol, earlySymbols, lateSymbols, member);
43348                         }
43349                     }
43350                 }
43351                 links[resolutionKind] = combineSymbolTables(earlySymbols, lateSymbols) || emptySymbols;
43352             }
43353             return links[resolutionKind];
43354         }
43355         function getMembersOfSymbol(symbol) {
43356             return symbol.flags & 6256
43357                 ? getResolvedMembersOrExportsOfSymbol(symbol, "resolvedMembers")
43358                 : symbol.members || emptySymbols;
43359         }
43360         function getLateBoundSymbol(symbol) {
43361             if (symbol.flags & 106500 && symbol.escapedName === "__computed") {
43362                 var links = getSymbolLinks(symbol);
43363                 if (!links.lateSymbol && ts.some(symbol.declarations, hasLateBindableName)) {
43364                     var parent = getMergedSymbol(symbol.parent);
43365                     if (ts.some(symbol.declarations, ts.hasStaticModifier)) {
43366                         getExportsOfSymbol(parent);
43367                     }
43368                     else {
43369                         getMembersOfSymbol(parent);
43370                     }
43371                 }
43372                 return links.lateSymbol || (links.lateSymbol = symbol);
43373             }
43374             return symbol;
43375         }
43376         function getTypeWithThisArgument(type, thisArgument, needApparentType) {
43377             if (ts.getObjectFlags(type) & 4) {
43378                 var target = type.target;
43379                 var typeArguments = getTypeArguments(type);
43380                 if (ts.length(target.typeParameters) === ts.length(typeArguments)) {
43381                     var ref = createTypeReference(target, ts.concatenate(typeArguments, [thisArgument || target.thisType]));
43382                     return needApparentType ? getApparentType(ref) : ref;
43383                 }
43384             }
43385             else if (type.flags & 2097152) {
43386                 var types = ts.sameMap(type.types, function (t) { return getTypeWithThisArgument(t, thisArgument, needApparentType); });
43387                 return types !== type.types ? getIntersectionType(types) : type;
43388             }
43389             return needApparentType ? getApparentType(type) : type;
43390         }
43391         function resolveObjectTypeMembers(type, source, typeParameters, typeArguments) {
43392             var mapper;
43393             var members;
43394             var callSignatures;
43395             var constructSignatures;
43396             var stringIndexInfo;
43397             var numberIndexInfo;
43398             if (ts.rangeEquals(typeParameters, typeArguments, 0, typeParameters.length)) {
43399                 members = source.symbol ? getMembersOfSymbol(source.symbol) : ts.createSymbolTable(source.declaredProperties);
43400                 callSignatures = source.declaredCallSignatures;
43401                 constructSignatures = source.declaredConstructSignatures;
43402                 stringIndexInfo = source.declaredStringIndexInfo;
43403                 numberIndexInfo = source.declaredNumberIndexInfo;
43404             }
43405             else {
43406                 mapper = createTypeMapper(typeParameters, typeArguments);
43407                 members = createInstantiatedSymbolTable(source.declaredProperties, mapper, typeParameters.length === 1);
43408                 callSignatures = instantiateSignatures(source.declaredCallSignatures, mapper);
43409                 constructSignatures = instantiateSignatures(source.declaredConstructSignatures, mapper);
43410                 stringIndexInfo = instantiateIndexInfo(source.declaredStringIndexInfo, mapper);
43411                 numberIndexInfo = instantiateIndexInfo(source.declaredNumberIndexInfo, mapper);
43412             }
43413             var baseTypes = getBaseTypes(source);
43414             if (baseTypes.length) {
43415                 if (source.symbol && members === getMembersOfSymbol(source.symbol)) {
43416                     members = ts.createSymbolTable(source.declaredProperties);
43417                 }
43418                 setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
43419                 var thisArgument = ts.lastOrUndefined(typeArguments);
43420                 for (var _i = 0, baseTypes_1 = baseTypes; _i < baseTypes_1.length; _i++) {
43421                     var baseType = baseTypes_1[_i];
43422                     var instantiatedBaseType = thisArgument ? getTypeWithThisArgument(instantiateType(baseType, mapper), thisArgument) : baseType;
43423                     addInheritedMembers(members, getPropertiesOfType(instantiatedBaseType));
43424                     callSignatures = ts.concatenate(callSignatures, getSignaturesOfType(instantiatedBaseType, 0));
43425                     constructSignatures = ts.concatenate(constructSignatures, getSignaturesOfType(instantiatedBaseType, 1));
43426                     if (!stringIndexInfo) {
43427                         stringIndexInfo = instantiatedBaseType === anyType ?
43428                             createIndexInfo(anyType, false) :
43429                             getIndexInfoOfType(instantiatedBaseType, 0);
43430                     }
43431                     numberIndexInfo = numberIndexInfo || getIndexInfoOfType(instantiatedBaseType, 1);
43432                 }
43433             }
43434             setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
43435         }
43436         function resolveClassOrInterfaceMembers(type) {
43437             resolveObjectTypeMembers(type, resolveDeclaredMembers(type), ts.emptyArray, ts.emptyArray);
43438         }
43439         function resolveTypeReferenceMembers(type) {
43440             var source = resolveDeclaredMembers(type.target);
43441             var typeParameters = ts.concatenate(source.typeParameters, [source.thisType]);
43442             var typeArguments = getTypeArguments(type);
43443             var paddedTypeArguments = typeArguments.length === typeParameters.length ? typeArguments : ts.concatenate(typeArguments, [type]);
43444             resolveObjectTypeMembers(type, source, typeParameters, paddedTypeArguments);
43445         }
43446         function createSignature(declaration, typeParameters, thisParameter, parameters, resolvedReturnType, resolvedTypePredicate, minArgumentCount, flags) {
43447             var sig = new Signature(checker, flags);
43448             sig.declaration = declaration;
43449             sig.typeParameters = typeParameters;
43450             sig.parameters = parameters;
43451             sig.thisParameter = thisParameter;
43452             sig.resolvedReturnType = resolvedReturnType;
43453             sig.resolvedTypePredicate = resolvedTypePredicate;
43454             sig.minArgumentCount = minArgumentCount;
43455             sig.resolvedMinArgumentCount = undefined;
43456             sig.target = undefined;
43457             sig.mapper = undefined;
43458             sig.unionSignatures = undefined;
43459             return sig;
43460         }
43461         function cloneSignature(sig) {
43462             var result = createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, undefined, undefined, sig.minArgumentCount, sig.flags & 39);
43463             result.target = sig.target;
43464             result.mapper = sig.mapper;
43465             result.unionSignatures = sig.unionSignatures;
43466             return result;
43467         }
43468         function createUnionSignature(signature, unionSignatures) {
43469             var result = cloneSignature(signature);
43470             result.unionSignatures = unionSignatures;
43471             result.target = undefined;
43472             result.mapper = undefined;
43473             return result;
43474         }
43475         function getOptionalCallSignature(signature, callChainFlags) {
43476             if ((signature.flags & 24) === callChainFlags) {
43477                 return signature;
43478             }
43479             if (!signature.optionalCallSignatureCache) {
43480                 signature.optionalCallSignatureCache = {};
43481             }
43482             var key = callChainFlags === 8 ? "inner" : "outer";
43483             return signature.optionalCallSignatureCache[key]
43484                 || (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags));
43485         }
43486         function createOptionalCallSignature(signature, callChainFlags) {
43487             ts.Debug.assert(callChainFlags === 8 || callChainFlags === 16, "An optional call signature can either be for an inner call chain or an outer call chain, but not both.");
43488             var result = cloneSignature(signature);
43489             result.flags |= callChainFlags;
43490             return result;
43491         }
43492         function getExpandedParameters(sig, skipUnionExpanding) {
43493             if (signatureHasRestParameter(sig)) {
43494                 var restIndex_1 = sig.parameters.length - 1;
43495                 var restType = getTypeOfSymbol(sig.parameters[restIndex_1]);
43496                 if (isTupleType(restType)) {
43497                     return [expandSignatureParametersWithTupleMembers(restType, restIndex_1)];
43498                 }
43499                 else if (!skipUnionExpanding && restType.flags & 1048576 && ts.every(restType.types, isTupleType)) {
43500                     return ts.map(restType.types, function (t) { return expandSignatureParametersWithTupleMembers(t, restIndex_1); });
43501                 }
43502             }
43503             return [sig.parameters];
43504             function expandSignatureParametersWithTupleMembers(restType, restIndex) {
43505                 var elementTypes = getTypeArguments(restType);
43506                 var associatedNames = restType.target.labeledElementDeclarations;
43507                 var restParams = ts.map(elementTypes, function (t, i) {
43508                     var tupleLabelName = !!associatedNames && getTupleElementLabel(associatedNames[i]);
43509                     var name = tupleLabelName || getParameterNameAtPosition(sig, restIndex + i, restType);
43510                     var flags = restType.target.elementFlags[i];
43511                     var checkFlags = flags & 12 ? 32768 :
43512                         flags & 2 ? 16384 : 0;
43513                     var symbol = createSymbol(1, name, checkFlags);
43514                     symbol.type = flags & 4 ? createArrayType(t) : t;
43515                     return symbol;
43516                 });
43517                 return ts.concatenate(sig.parameters.slice(0, restIndex), restParams);
43518             }
43519         }
43520         function getDefaultConstructSignatures(classType) {
43521             var baseConstructorType = getBaseConstructorTypeOfClass(classType);
43522             var baseSignatures = getSignaturesOfType(baseConstructorType, 1);
43523             var declaration = ts.getClassLikeDeclarationOfSymbol(classType.symbol);
43524             var isAbstract = !!declaration && ts.hasSyntacticModifier(declaration, 128);
43525             if (baseSignatures.length === 0) {
43526                 return [createSignature(undefined, classType.localTypeParameters, undefined, ts.emptyArray, classType, undefined, 0, isAbstract ? 4 : 0)];
43527             }
43528             var baseTypeNode = getBaseTypeNodeOfClass(classType);
43529             var isJavaScript = ts.isInJSFile(baseTypeNode);
43530             var typeArguments = typeArgumentsFromTypeReferenceNode(baseTypeNode);
43531             var typeArgCount = ts.length(typeArguments);
43532             var result = [];
43533             for (var _i = 0, baseSignatures_1 = baseSignatures; _i < baseSignatures_1.length; _i++) {
43534                 var baseSig = baseSignatures_1[_i];
43535                 var minTypeArgumentCount = getMinTypeArgumentCount(baseSig.typeParameters);
43536                 var typeParamCount = ts.length(baseSig.typeParameters);
43537                 if (isJavaScript || typeArgCount >= minTypeArgumentCount && typeArgCount <= typeParamCount) {
43538                     var sig = typeParamCount ? createSignatureInstantiation(baseSig, fillMissingTypeArguments(typeArguments, baseSig.typeParameters, minTypeArgumentCount, isJavaScript)) : cloneSignature(baseSig);
43539                     sig.typeParameters = classType.localTypeParameters;
43540                     sig.resolvedReturnType = classType;
43541                     sig.flags = isAbstract ? sig.flags | 4 : sig.flags & ~4;
43542                     result.push(sig);
43543                 }
43544             }
43545             return result;
43546         }
43547         function findMatchingSignature(signatureList, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes) {
43548             for (var _i = 0, signatureList_1 = signatureList; _i < signatureList_1.length; _i++) {
43549                 var s = signatureList_1[_i];
43550                 if (compareSignaturesIdentical(s, signature, partialMatch, ignoreThisTypes, ignoreReturnTypes, partialMatch ? compareTypesSubtypeOf : compareTypesIdentical)) {
43551                     return s;
43552                 }
43553             }
43554         }
43555         function findMatchingSignatures(signatureLists, signature, listIndex) {
43556             if (signature.typeParameters) {
43557                 if (listIndex > 0) {
43558                     return undefined;
43559                 }
43560                 for (var i = 1; i < signatureLists.length; i++) {
43561                     if (!findMatchingSignature(signatureLists[i], signature, false, false, false)) {
43562                         return undefined;
43563                     }
43564                 }
43565                 return [signature];
43566             }
43567             var result;
43568             for (var i = 0; i < signatureLists.length; i++) {
43569                 var match = i === listIndex ? signature : findMatchingSignature(signatureLists[i], signature, true, false, true);
43570                 if (!match) {
43571                     return undefined;
43572                 }
43573                 result = ts.appendIfUnique(result, match);
43574             }
43575             return result;
43576         }
43577         function getUnionSignatures(signatureLists) {
43578             var result;
43579             var indexWithLengthOverOne;
43580             for (var i = 0; i < signatureLists.length; i++) {
43581                 if (signatureLists[i].length === 0)
43582                     return ts.emptyArray;
43583                 if (signatureLists[i].length > 1) {
43584                     indexWithLengthOverOne = indexWithLengthOverOne === undefined ? i : -1;
43585                 }
43586                 for (var _i = 0, _a = signatureLists[i]; _i < _a.length; _i++) {
43587                     var signature = _a[_i];
43588                     if (!result || !findMatchingSignature(result, signature, false, false, true)) {
43589                         var unionSignatures = findMatchingSignatures(signatureLists, signature, i);
43590                         if (unionSignatures) {
43591                             var s = signature;
43592                             if (unionSignatures.length > 1) {
43593                                 var thisParameter = signature.thisParameter;
43594                                 var firstThisParameterOfUnionSignatures = ts.forEach(unionSignatures, function (sig) { return sig.thisParameter; });
43595                                 if (firstThisParameterOfUnionSignatures) {
43596                                     var thisType = getIntersectionType(ts.mapDefined(unionSignatures, function (sig) { return sig.thisParameter && getTypeOfSymbol(sig.thisParameter); }));
43597                                     thisParameter = createSymbolWithType(firstThisParameterOfUnionSignatures, thisType);
43598                                 }
43599                                 s = createUnionSignature(signature, unionSignatures);
43600                                 s.thisParameter = thisParameter;
43601                             }
43602                             (result || (result = [])).push(s);
43603                         }
43604                     }
43605                 }
43606             }
43607             if (!ts.length(result) && indexWithLengthOverOne !== -1) {
43608                 var masterList = signatureLists[indexWithLengthOverOne !== undefined ? indexWithLengthOverOne : 0];
43609                 var results = masterList.slice();
43610                 var _loop_10 = function (signatures) {
43611                     if (signatures !== masterList) {
43612                         var signature_1 = signatures[0];
43613                         ts.Debug.assert(!!signature_1, "getUnionSignatures bails early on empty signature lists and should not have empty lists on second pass");
43614                         results = signature_1.typeParameters && ts.some(results, function (s) { return !!s.typeParameters && !compareTypeParametersIdentical(signature_1.typeParameters, s.typeParameters); }) ? undefined : ts.map(results, function (sig) { return combineSignaturesOfUnionMembers(sig, signature_1); });
43615                         if (!results) {
43616                             return "break";
43617                         }
43618                     }
43619                 };
43620                 for (var _b = 0, signatureLists_1 = signatureLists; _b < signatureLists_1.length; _b++) {
43621                     var signatures = signatureLists_1[_b];
43622                     var state_3 = _loop_10(signatures);
43623                     if (state_3 === "break")
43624                         break;
43625                 }
43626                 result = results;
43627             }
43628             return result || ts.emptyArray;
43629         }
43630         function compareTypeParametersIdentical(sourceParams, targetParams) {
43631             if (sourceParams.length !== targetParams.length) {
43632                 return false;
43633             }
43634             var mapper = createTypeMapper(targetParams, sourceParams);
43635             for (var i = 0; i < sourceParams.length; i++) {
43636                 var source = sourceParams[i];
43637                 var target = targetParams[i];
43638                 if (source === target)
43639                     continue;
43640                 if (!isTypeIdenticalTo(getConstraintFromTypeParameter(source) || unknownType, instantiateType(getConstraintFromTypeParameter(target) || unknownType, mapper)))
43641                     return false;
43642             }
43643             return true;
43644         }
43645         function combineUnionThisParam(left, right, mapper) {
43646             if (!left || !right) {
43647                 return left || right;
43648             }
43649             var thisType = getIntersectionType([getTypeOfSymbol(left), instantiateType(getTypeOfSymbol(right), mapper)]);
43650             return createSymbolWithType(left, thisType);
43651         }
43652         function combineUnionParameters(left, right, mapper) {
43653             var leftCount = getParameterCount(left);
43654             var rightCount = getParameterCount(right);
43655             var longest = leftCount >= rightCount ? left : right;
43656             var shorter = longest === left ? right : left;
43657             var longestCount = longest === left ? leftCount : rightCount;
43658             var eitherHasEffectiveRest = (hasEffectiveRestParameter(left) || hasEffectiveRestParameter(right));
43659             var needsExtraRestElement = eitherHasEffectiveRest && !hasEffectiveRestParameter(longest);
43660             var params = new Array(longestCount + (needsExtraRestElement ? 1 : 0));
43661             for (var i = 0; i < longestCount; i++) {
43662                 var longestParamType = tryGetTypeAtPosition(longest, i);
43663                 if (longest === right) {
43664                     longestParamType = instantiateType(longestParamType, mapper);
43665                 }
43666                 var shorterParamType = tryGetTypeAtPosition(shorter, i) || unknownType;
43667                 if (shorter === right) {
43668                     shorterParamType = instantiateType(shorterParamType, mapper);
43669                 }
43670                 var unionParamType = getIntersectionType([longestParamType, shorterParamType]);
43671                 var isRestParam = eitherHasEffectiveRest && !needsExtraRestElement && i === (longestCount - 1);
43672                 var isOptional = i >= getMinArgumentCount(longest) && i >= getMinArgumentCount(shorter);
43673                 var leftName = i >= leftCount ? undefined : getParameterNameAtPosition(left, i);
43674                 var rightName = i >= rightCount ? undefined : getParameterNameAtPosition(right, i);
43675                 var paramName = leftName === rightName ? leftName :
43676                     !leftName ? rightName :
43677                         !rightName ? leftName :
43678                             undefined;
43679                 var paramSymbol = createSymbol(1 | (isOptional && !isRestParam ? 16777216 : 0), paramName || "arg" + i);
43680                 paramSymbol.type = isRestParam ? createArrayType(unionParamType) : unionParamType;
43681                 params[i] = paramSymbol;
43682             }
43683             if (needsExtraRestElement) {
43684                 var restParamSymbol = createSymbol(1, "args");
43685                 restParamSymbol.type = createArrayType(getTypeAtPosition(shorter, longestCount));
43686                 if (shorter === right) {
43687                     restParamSymbol.type = instantiateType(restParamSymbol.type, mapper);
43688                 }
43689                 params[longestCount] = restParamSymbol;
43690             }
43691             return params;
43692         }
43693         function combineSignaturesOfUnionMembers(left, right) {
43694             var typeParams = left.typeParameters || right.typeParameters;
43695             var paramMapper;
43696             if (left.typeParameters && right.typeParameters) {
43697                 paramMapper = createTypeMapper(right.typeParameters, left.typeParameters);
43698             }
43699             var declaration = left.declaration;
43700             var params = combineUnionParameters(left, right, paramMapper);
43701             var thisParam = combineUnionThisParam(left.thisParameter, right.thisParameter, paramMapper);
43702             var minArgCount = Math.max(left.minArgumentCount, right.minArgumentCount);
43703             var result = createSignature(declaration, typeParams, thisParam, params, undefined, undefined, minArgCount, (left.flags | right.flags) & 39);
43704             result.unionSignatures = ts.concatenate(left.unionSignatures || [left], [right]);
43705             if (paramMapper) {
43706                 result.mapper = left.mapper && left.unionSignatures ? combineTypeMappers(left.mapper, paramMapper) : paramMapper;
43707             }
43708             return result;
43709         }
43710         function getUnionIndexInfo(types, kind) {
43711             var indexTypes = [];
43712             var isAnyReadonly = false;
43713             for (var _i = 0, types_4 = types; _i < types_4.length; _i++) {
43714                 var type = types_4[_i];
43715                 var indexInfo = getIndexInfoOfType(getApparentType(type), kind);
43716                 if (!indexInfo) {
43717                     return undefined;
43718                 }
43719                 indexTypes.push(indexInfo.type);
43720                 isAnyReadonly = isAnyReadonly || indexInfo.isReadonly;
43721             }
43722             return createIndexInfo(getUnionType(indexTypes, 2), isAnyReadonly);
43723         }
43724         function resolveUnionTypeMembers(type) {
43725             var callSignatures = getUnionSignatures(ts.map(type.types, function (t) { return t === globalFunctionType ? [unknownSignature] : getSignaturesOfType(t, 0); }));
43726             var constructSignatures = getUnionSignatures(ts.map(type.types, function (t) { return getSignaturesOfType(t, 1); }));
43727             var stringIndexInfo = getUnionIndexInfo(type.types, 0);
43728             var numberIndexInfo = getUnionIndexInfo(type.types, 1);
43729             setStructuredTypeMembers(type, emptySymbols, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
43730         }
43731         function intersectTypes(type1, type2) {
43732             return !type1 ? type2 : !type2 ? type1 : getIntersectionType([type1, type2]);
43733         }
43734         function intersectIndexInfos(info1, info2) {
43735             return !info1 ? info2 : !info2 ? info1 : createIndexInfo(getIntersectionType([info1.type, info2.type]), info1.isReadonly && info2.isReadonly);
43736         }
43737         function unionSpreadIndexInfos(info1, info2) {
43738             return info1 && info2 && createIndexInfo(getUnionType([info1.type, info2.type]), info1.isReadonly || info2.isReadonly);
43739         }
43740         function findMixins(types) {
43741             var constructorTypeCount = ts.countWhere(types, function (t) { return getSignaturesOfType(t, 1).length > 0; });
43742             var mixinFlags = ts.map(types, isMixinConstructorType);
43743             if (constructorTypeCount > 0 && constructorTypeCount === ts.countWhere(mixinFlags, function (b) { return b; })) {
43744                 var firstMixinIndex = mixinFlags.indexOf(true);
43745                 mixinFlags[firstMixinIndex] = false;
43746             }
43747             return mixinFlags;
43748         }
43749         function includeMixinType(type, types, mixinFlags, index) {
43750             var mixedTypes = [];
43751             for (var i = 0; i < types.length; i++) {
43752                 if (i === index) {
43753                     mixedTypes.push(type);
43754                 }
43755                 else if (mixinFlags[i]) {
43756                     mixedTypes.push(getReturnTypeOfSignature(getSignaturesOfType(types[i], 1)[0]));
43757                 }
43758             }
43759             return getIntersectionType(mixedTypes);
43760         }
43761         function resolveIntersectionTypeMembers(type) {
43762             var callSignatures;
43763             var constructSignatures;
43764             var stringIndexInfo;
43765             var numberIndexInfo;
43766             var types = type.types;
43767             var mixinFlags = findMixins(types);
43768             var mixinCount = ts.countWhere(mixinFlags, function (b) { return b; });
43769             var _loop_11 = function (i) {
43770                 var t = type.types[i];
43771                 if (!mixinFlags[i]) {
43772                     var signatures = getSignaturesOfType(t, 1);
43773                     if (signatures.length && mixinCount > 0) {
43774                         signatures = ts.map(signatures, function (s) {
43775                             var clone = cloneSignature(s);
43776                             clone.resolvedReturnType = includeMixinType(getReturnTypeOfSignature(s), types, mixinFlags, i);
43777                             return clone;
43778                         });
43779                     }
43780                     constructSignatures = appendSignatures(constructSignatures, signatures);
43781                 }
43782                 callSignatures = appendSignatures(callSignatures, getSignaturesOfType(t, 0));
43783                 stringIndexInfo = intersectIndexInfos(stringIndexInfo, getIndexInfoOfType(t, 0));
43784                 numberIndexInfo = intersectIndexInfos(numberIndexInfo, getIndexInfoOfType(t, 1));
43785             };
43786             for (var i = 0; i < types.length; i++) {
43787                 _loop_11(i);
43788             }
43789             setStructuredTypeMembers(type, emptySymbols, callSignatures || ts.emptyArray, constructSignatures || ts.emptyArray, stringIndexInfo, numberIndexInfo);
43790         }
43791         function appendSignatures(signatures, newSignatures) {
43792             var _loop_12 = function (sig) {
43793                 if (!signatures || ts.every(signatures, function (s) { return !compareSignaturesIdentical(s, sig, false, false, false, compareTypesIdentical); })) {
43794                     signatures = ts.append(signatures, sig);
43795                 }
43796             };
43797             for (var _i = 0, newSignatures_1 = newSignatures; _i < newSignatures_1.length; _i++) {
43798                 var sig = newSignatures_1[_i];
43799                 _loop_12(sig);
43800             }
43801             return signatures;
43802         }
43803         function resolveAnonymousTypeMembers(type) {
43804             var symbol = getMergedSymbol(type.symbol);
43805             if (type.target) {
43806                 setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
43807                 var members = createInstantiatedSymbolTable(getPropertiesOfObjectType(type.target), type.mapper, false);
43808                 var callSignatures = instantiateSignatures(getSignaturesOfType(type.target, 0), type.mapper);
43809                 var constructSignatures = instantiateSignatures(getSignaturesOfType(type.target, 1), type.mapper);
43810                 var stringIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 0), type.mapper);
43811                 var numberIndexInfo = instantiateIndexInfo(getIndexInfoOfType(type.target, 1), type.mapper);
43812                 setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
43813             }
43814             else if (symbol.flags & 2048) {
43815                 setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
43816                 var members = getMembersOfSymbol(symbol);
43817                 var callSignatures = getSignaturesOfSymbol(members.get("__call"));
43818                 var constructSignatures = getSignaturesOfSymbol(members.get("__new"));
43819                 var stringIndexInfo = getIndexInfoOfSymbol(symbol, 0);
43820                 var numberIndexInfo = getIndexInfoOfSymbol(symbol, 1);
43821                 setStructuredTypeMembers(type, members, callSignatures, constructSignatures, stringIndexInfo, numberIndexInfo);
43822             }
43823             else {
43824                 var members = emptySymbols;
43825                 var stringIndexInfo = void 0;
43826                 if (symbol.exports) {
43827                     members = getExportsOfSymbol(symbol);
43828                     if (symbol === globalThisSymbol) {
43829                         var varsOnly_1 = new ts.Map();
43830                         members.forEach(function (p) {
43831                             if (!(p.flags & 418)) {
43832                                 varsOnly_1.set(p.escapedName, p);
43833                             }
43834                         });
43835                         members = varsOnly_1;
43836                     }
43837                 }
43838                 setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, undefined, undefined);
43839                 if (symbol.flags & 32) {
43840                     var classType = getDeclaredTypeOfClassOrInterface(symbol);
43841                     var baseConstructorType = getBaseConstructorTypeOfClass(classType);
43842                     if (baseConstructorType.flags & (524288 | 2097152 | 8650752)) {
43843                         members = ts.createSymbolTable(getNamedMembers(members));
43844                         addInheritedMembers(members, getPropertiesOfType(baseConstructorType));
43845                     }
43846                     else if (baseConstructorType === anyType) {
43847                         stringIndexInfo = createIndexInfo(anyType, false);
43848                     }
43849                 }
43850                 var numberIndexInfo = symbol.flags & 384 && (getDeclaredTypeOfSymbol(symbol).flags & 32 ||
43851                     ts.some(type.properties, function (prop) { return !!(getTypeOfSymbol(prop).flags & 296); })) ? enumNumberIndexInfo : undefined;
43852                 setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
43853                 if (symbol.flags & (16 | 8192)) {
43854                     type.callSignatures = getSignaturesOfSymbol(symbol);
43855                 }
43856                 if (symbol.flags & 32) {
43857                     var classType_1 = getDeclaredTypeOfClassOrInterface(symbol);
43858                     var constructSignatures = symbol.members ? getSignaturesOfSymbol(symbol.members.get("__constructor")) : ts.emptyArray;
43859                     if (symbol.flags & 16) {
43860                         constructSignatures = ts.addRange(constructSignatures.slice(), ts.mapDefined(type.callSignatures, function (sig) { return isJSConstructor(sig.declaration) ?
43861                             createSignature(sig.declaration, sig.typeParameters, sig.thisParameter, sig.parameters, classType_1, undefined, sig.minArgumentCount, sig.flags & 39) :
43862                             undefined; }));
43863                     }
43864                     if (!constructSignatures.length) {
43865                         constructSignatures = getDefaultConstructSignatures(classType_1);
43866                     }
43867                     type.constructSignatures = constructSignatures;
43868                 }
43869             }
43870         }
43871         function resolveReverseMappedTypeMembers(type) {
43872             var indexInfo = getIndexInfoOfType(type.source, 0);
43873             var modifiers = getMappedTypeModifiers(type.mappedType);
43874             var readonlyMask = modifiers & 1 ? false : true;
43875             var optionalMask = modifiers & 4 ? 0 : 16777216;
43876             var stringIndexInfo = indexInfo && createIndexInfo(inferReverseMappedType(indexInfo.type, type.mappedType, type.constraintType), readonlyMask && indexInfo.isReadonly);
43877             var members = ts.createSymbolTable();
43878             for (var _i = 0, _a = getPropertiesOfType(type.source); _i < _a.length; _i++) {
43879                 var prop = _a[_i];
43880                 var checkFlags = 8192 | (readonlyMask && isReadonlySymbol(prop) ? 8 : 0);
43881                 var inferredProp = createSymbol(4 | prop.flags & optionalMask, prop.escapedName, checkFlags);
43882                 inferredProp.declarations = prop.declarations;
43883                 inferredProp.nameType = getSymbolLinks(prop).nameType;
43884                 inferredProp.propertyType = getTypeOfSymbol(prop);
43885                 inferredProp.mappedType = type.mappedType;
43886                 inferredProp.constraintType = type.constraintType;
43887                 members.set(prop.escapedName, inferredProp);
43888             }
43889             setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, undefined);
43890         }
43891         function getLowerBoundOfKeyType(type) {
43892             if (type.flags & 4194304) {
43893                 var t = getApparentType(type.type);
43894                 return isGenericTupleType(t) ? getKnownKeysOfTupleType(t) : getIndexType(t);
43895             }
43896             if (type.flags & 16777216) {
43897                 if (type.root.isDistributive) {
43898                     var checkType = type.checkType;
43899                     var constraint = getLowerBoundOfKeyType(checkType);
43900                     if (constraint !== checkType) {
43901                         return getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
43902                     }
43903                 }
43904                 return type;
43905             }
43906             if (type.flags & 1048576) {
43907                 return mapType(type, getLowerBoundOfKeyType);
43908             }
43909             if (type.flags & 2097152) {
43910                 return getIntersectionType(ts.sameMap(type.types, getLowerBoundOfKeyType));
43911             }
43912             return type;
43913         }
43914         function getIsLateCheckFlag(s) {
43915             return ts.getCheckFlags(s) & 4096;
43916         }
43917         function resolveMappedTypeMembers(type) {
43918             var members = ts.createSymbolTable();
43919             var stringIndexInfo;
43920             var numberIndexInfo;
43921             setStructuredTypeMembers(type, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
43922             var typeParameter = getTypeParameterFromMappedType(type);
43923             var constraintType = getConstraintTypeFromMappedType(type);
43924             var nameType = getNameTypeFromMappedType(type.target || type);
43925             var templateType = getTemplateTypeFromMappedType(type.target || type);
43926             var modifiersType = getApparentType(getModifiersTypeFromMappedType(type));
43927             var templateModifiers = getMappedTypeModifiers(type);
43928             var include = keyofStringsOnly ? 128 : 8576;
43929             if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
43930                 for (var _i = 0, _a = getPropertiesOfType(modifiersType); _i < _a.length; _i++) {
43931                     var prop = _a[_i];
43932                     addMemberForKeyType(getLiteralTypeFromProperty(prop, include));
43933                 }
43934                 if (modifiersType.flags & 1 || getIndexInfoOfType(modifiersType, 0)) {
43935                     addMemberForKeyType(stringType);
43936                 }
43937                 if (!keyofStringsOnly && getIndexInfoOfType(modifiersType, 1)) {
43938                     addMemberForKeyType(numberType);
43939                 }
43940             }
43941             else {
43942                 forEachType(getLowerBoundOfKeyType(constraintType), addMemberForKeyType);
43943             }
43944             setStructuredTypeMembers(type, members, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
43945             function addMemberForKeyType(keyType) {
43946                 var propNameType = nameType ? instantiateType(nameType, appendTypeMapping(type.mapper, typeParameter, keyType)) : keyType;
43947                 forEachType(propNameType, function (t) { return addMemberForKeyTypeWorker(keyType, t); });
43948             }
43949             function addMemberForKeyTypeWorker(keyType, propNameType) {
43950                 if (isTypeUsableAsPropertyName(propNameType)) {
43951                     var propName = getPropertyNameFromType(propNameType);
43952                     var existingProp = members.get(propName);
43953                     if (existingProp) {
43954                         existingProp.nameType = getUnionType([existingProp.nameType, propNameType]);
43955                         existingProp.keyType = getUnionType([existingProp.keyType, keyType]);
43956                     }
43957                     else {
43958                         var modifiersProp = isTypeUsableAsPropertyName(keyType) ? getPropertyOfType(modifiersType, getPropertyNameFromType(keyType)) : undefined;
43959                         var isOptional = !!(templateModifiers & 4 ||
43960                             !(templateModifiers & 8) && modifiersProp && modifiersProp.flags & 16777216);
43961                         var isReadonly = !!(templateModifiers & 1 ||
43962                             !(templateModifiers & 2) && modifiersProp && isReadonlySymbol(modifiersProp));
43963                         var stripOptional = strictNullChecks && !isOptional && modifiersProp && modifiersProp.flags & 16777216;
43964                         var lateFlag = modifiersProp ? getIsLateCheckFlag(modifiersProp) : 0;
43965                         var prop = createSymbol(4 | (isOptional ? 16777216 : 0), propName, lateFlag | 262144 | (isReadonly ? 8 : 0) | (stripOptional ? 524288 : 0));
43966                         prop.mappedType = type;
43967                         prop.nameType = propNameType;
43968                         prop.keyType = keyType;
43969                         if (modifiersProp) {
43970                             prop.syntheticOrigin = modifiersProp;
43971                             prop.declarations = modifiersProp.declarations;
43972                         }
43973                         members.set(propName, prop);
43974                     }
43975                 }
43976                 else if (propNameType.flags & (1 | 4 | 8 | 32)) {
43977                     var propType = instantiateType(templateType, appendTypeMapping(type.mapper, typeParameter, keyType));
43978                     if (propNameType.flags & (1 | 4)) {
43979                         stringIndexInfo = createIndexInfo(stringIndexInfo ? getUnionType([stringIndexInfo.type, propType]) : propType, !!(templateModifiers & 1));
43980                     }
43981                     else {
43982                         numberIndexInfo = createIndexInfo(numberIndexInfo ? getUnionType([numberIndexInfo.type, propType]) : propType, !!(templateModifiers & 1));
43983                     }
43984                 }
43985             }
43986         }
43987         function getTypeOfMappedSymbol(symbol) {
43988             if (!symbol.type) {
43989                 var mappedType = symbol.mappedType;
43990                 if (!pushTypeResolution(symbol, 0)) {
43991                     mappedType.containsError = true;
43992                     return errorType;
43993                 }
43994                 var templateType = getTemplateTypeFromMappedType(mappedType.target || mappedType);
43995                 var mapper = appendTypeMapping(mappedType.mapper, getTypeParameterFromMappedType(mappedType), symbol.keyType);
43996                 var propType = instantiateType(templateType, mapper);
43997                 var type = strictNullChecks && symbol.flags & 16777216 && !maybeTypeOfKind(propType, 32768 | 16384) ? getOptionalType(propType) :
43998                     symbol.checkFlags & 524288 ? getTypeWithFacts(propType, 524288) :
43999                         propType;
44000                 if (!popTypeResolution()) {
44001                     error(currentNode, ts.Diagnostics.Type_of_property_0_circularly_references_itself_in_mapped_type_1, symbolToString(symbol), typeToString(mappedType));
44002                     type = errorType;
44003                 }
44004                 symbol.type = type;
44005             }
44006             return symbol.type;
44007         }
44008         function getTypeParameterFromMappedType(type) {
44009             return type.typeParameter ||
44010                 (type.typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(type.declaration.typeParameter)));
44011         }
44012         function getConstraintTypeFromMappedType(type) {
44013             return type.constraintType ||
44014                 (type.constraintType = getConstraintOfTypeParameter(getTypeParameterFromMappedType(type)) || errorType);
44015         }
44016         function getNameTypeFromMappedType(type) {
44017             return type.declaration.nameType ?
44018                 type.nameType || (type.nameType = instantiateType(getTypeFromTypeNode(type.declaration.nameType), type.mapper)) :
44019                 undefined;
44020         }
44021         function getTemplateTypeFromMappedType(type) {
44022             return type.templateType ||
44023                 (type.templateType = type.declaration.type ?
44024                     instantiateType(addOptionality(getTypeFromTypeNode(type.declaration.type), !!(getMappedTypeModifiers(type) & 4)), type.mapper) :
44025                     errorType);
44026         }
44027         function getConstraintDeclarationForMappedType(type) {
44028             return ts.getEffectiveConstraintOfTypeParameter(type.declaration.typeParameter);
44029         }
44030         function isMappedTypeWithKeyofConstraintDeclaration(type) {
44031             var constraintDeclaration = getConstraintDeclarationForMappedType(type);
44032             return constraintDeclaration.kind === 188 &&
44033                 constraintDeclaration.operator === 138;
44034         }
44035         function getModifiersTypeFromMappedType(type) {
44036             if (!type.modifiersType) {
44037                 if (isMappedTypeWithKeyofConstraintDeclaration(type)) {
44038                     type.modifiersType = instantiateType(getTypeFromTypeNode(getConstraintDeclarationForMappedType(type).type), type.mapper);
44039                 }
44040                 else {
44041                     var declaredType = getTypeFromMappedTypeNode(type.declaration);
44042                     var constraint = getConstraintTypeFromMappedType(declaredType);
44043                     var extendedConstraint = constraint && constraint.flags & 262144 ? getConstraintOfTypeParameter(constraint) : constraint;
44044                     type.modifiersType = extendedConstraint && extendedConstraint.flags & 4194304 ? instantiateType(extendedConstraint.type, type.mapper) : unknownType;
44045                 }
44046             }
44047             return type.modifiersType;
44048         }
44049         function getMappedTypeModifiers(type) {
44050             var declaration = type.declaration;
44051             return (declaration.readonlyToken ? declaration.readonlyToken.kind === 40 ? 2 : 1 : 0) |
44052                 (declaration.questionToken ? declaration.questionToken.kind === 40 ? 8 : 4 : 0);
44053         }
44054         function getMappedTypeOptionality(type) {
44055             var modifiers = getMappedTypeModifiers(type);
44056             return modifiers & 8 ? -1 : modifiers & 4 ? 1 : 0;
44057         }
44058         function getCombinedMappedTypeOptionality(type) {
44059             var optionality = getMappedTypeOptionality(type);
44060             var modifiersType = getModifiersTypeFromMappedType(type);
44061             return optionality || (isGenericMappedType(modifiersType) ? getMappedTypeOptionality(modifiersType) : 0);
44062         }
44063         function isPartialMappedType(type) {
44064             return !!(ts.getObjectFlags(type) & 32 && getMappedTypeModifiers(type) & 4);
44065         }
44066         function isGenericMappedType(type) {
44067             return !!(ts.getObjectFlags(type) & 32) && isGenericIndexType(getConstraintTypeFromMappedType(type));
44068         }
44069         function resolveStructuredTypeMembers(type) {
44070             if (!type.members) {
44071                 if (type.flags & 524288) {
44072                     if (type.objectFlags & 4) {
44073                         resolveTypeReferenceMembers(type);
44074                     }
44075                     else if (type.objectFlags & 3) {
44076                         resolveClassOrInterfaceMembers(type);
44077                     }
44078                     else if (type.objectFlags & 2048) {
44079                         resolveReverseMappedTypeMembers(type);
44080                     }
44081                     else if (type.objectFlags & 16) {
44082                         resolveAnonymousTypeMembers(type);
44083                     }
44084                     else if (type.objectFlags & 32) {
44085                         resolveMappedTypeMembers(type);
44086                     }
44087                 }
44088                 else if (type.flags & 1048576) {
44089                     resolveUnionTypeMembers(type);
44090                 }
44091                 else if (type.flags & 2097152) {
44092                     resolveIntersectionTypeMembers(type);
44093                 }
44094             }
44095             return type;
44096         }
44097         function getPropertiesOfObjectType(type) {
44098             if (type.flags & 524288) {
44099                 return resolveStructuredTypeMembers(type).properties;
44100             }
44101             return ts.emptyArray;
44102         }
44103         function getPropertyOfObjectType(type, name) {
44104             if (type.flags & 524288) {
44105                 var resolved = resolveStructuredTypeMembers(type);
44106                 var symbol = resolved.members.get(name);
44107                 if (symbol && symbolIsValue(symbol)) {
44108                     return symbol;
44109                 }
44110             }
44111         }
44112         function getPropertiesOfUnionOrIntersectionType(type) {
44113             if (!type.resolvedProperties) {
44114                 var members = ts.createSymbolTable();
44115                 for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
44116                     var current = _a[_i];
44117                     for (var _b = 0, _c = getPropertiesOfType(current); _b < _c.length; _b++) {
44118                         var prop = _c[_b];
44119                         if (!members.has(prop.escapedName)) {
44120                             var combinedProp = getPropertyOfUnionOrIntersectionType(type, prop.escapedName);
44121                             if (combinedProp) {
44122                                 members.set(prop.escapedName, combinedProp);
44123                             }
44124                         }
44125                     }
44126                     if (type.flags & 1048576 && !getIndexInfoOfType(current, 0) && !getIndexInfoOfType(current, 1)) {
44127                         break;
44128                     }
44129                 }
44130                 type.resolvedProperties = getNamedMembers(members);
44131             }
44132             return type.resolvedProperties;
44133         }
44134         function getPropertiesOfType(type) {
44135             type = getReducedApparentType(type);
44136             return type.flags & 3145728 ?
44137                 getPropertiesOfUnionOrIntersectionType(type) :
44138                 getPropertiesOfObjectType(type);
44139         }
44140         function isTypeInvalidDueToUnionDiscriminant(contextualType, obj) {
44141             var list = obj.properties;
44142             return list.some(function (property) {
44143                 var nameType = property.name && getLiteralTypeFromPropertyName(property.name);
44144                 var name = nameType && isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined;
44145                 var expected = name === undefined ? undefined : getTypeOfPropertyOfType(contextualType, name);
44146                 return !!expected && isLiteralType(expected) && !isTypeAssignableTo(getTypeOfNode(property), expected);
44147             });
44148         }
44149         function getAllPossiblePropertiesOfTypes(types) {
44150             var unionType = getUnionType(types);
44151             if (!(unionType.flags & 1048576)) {
44152                 return getAugmentedPropertiesOfType(unionType);
44153             }
44154             var props = ts.createSymbolTable();
44155             for (var _i = 0, types_5 = types; _i < types_5.length; _i++) {
44156                 var memberType = types_5[_i];
44157                 for (var _a = 0, _b = getAugmentedPropertiesOfType(memberType); _a < _b.length; _a++) {
44158                     var escapedName = _b[_a].escapedName;
44159                     if (!props.has(escapedName)) {
44160                         var prop = createUnionOrIntersectionProperty(unionType, escapedName);
44161                         if (prop)
44162                             props.set(escapedName, prop);
44163                     }
44164                 }
44165             }
44166             return ts.arrayFrom(props.values());
44167         }
44168         function getConstraintOfType(type) {
44169             return type.flags & 262144 ? getConstraintOfTypeParameter(type) :
44170                 type.flags & 8388608 ? getConstraintOfIndexedAccess(type) :
44171                     type.flags & 16777216 ? getConstraintOfConditionalType(type) :
44172                         getBaseConstraintOfType(type);
44173         }
44174         function getConstraintOfTypeParameter(typeParameter) {
44175             return hasNonCircularBaseConstraint(typeParameter) ? getConstraintFromTypeParameter(typeParameter) : undefined;
44176         }
44177         function getConstraintOfIndexedAccess(type) {
44178             return hasNonCircularBaseConstraint(type) ? getConstraintFromIndexedAccess(type) : undefined;
44179         }
44180         function getSimplifiedTypeOrConstraint(type) {
44181             var simplified = getSimplifiedType(type, false);
44182             return simplified !== type ? simplified : getConstraintOfType(type);
44183         }
44184         function getConstraintFromIndexedAccess(type) {
44185             var indexConstraint = getSimplifiedTypeOrConstraint(type.indexType);
44186             if (indexConstraint && indexConstraint !== type.indexType) {
44187                 var indexedAccess = getIndexedAccessTypeOrUndefined(type.objectType, indexConstraint, type.noUncheckedIndexedAccessCandidate);
44188                 if (indexedAccess) {
44189                     return indexedAccess;
44190                 }
44191             }
44192             var objectConstraint = getSimplifiedTypeOrConstraint(type.objectType);
44193             if (objectConstraint && objectConstraint !== type.objectType) {
44194                 return getIndexedAccessTypeOrUndefined(objectConstraint, type.indexType, type.noUncheckedIndexedAccessCandidate);
44195             }
44196             return undefined;
44197         }
44198         function getDefaultConstraintOfConditionalType(type) {
44199             if (!type.resolvedDefaultConstraint) {
44200                 var trueConstraint = getInferredTrueTypeFromConditionalType(type);
44201                 var falseConstraint = getFalseTypeFromConditionalType(type);
44202                 type.resolvedDefaultConstraint = isTypeAny(trueConstraint) ? falseConstraint : isTypeAny(falseConstraint) ? trueConstraint : getUnionType([trueConstraint, falseConstraint]);
44203             }
44204             return type.resolvedDefaultConstraint;
44205         }
44206         function getConstraintOfDistributiveConditionalType(type) {
44207             if (type.root.isDistributive && type.restrictiveInstantiation !== type) {
44208                 var simplified = getSimplifiedType(type.checkType, false);
44209                 var constraint = simplified === type.checkType ? getConstraintOfType(simplified) : simplified;
44210                 if (constraint && constraint !== type.checkType) {
44211                     var instantiated = getConditionalTypeInstantiation(type, prependTypeMapping(type.root.checkType, constraint, type.mapper));
44212                     if (!(instantiated.flags & 131072)) {
44213                         return instantiated;
44214                     }
44215                 }
44216             }
44217             return undefined;
44218         }
44219         function getConstraintFromConditionalType(type) {
44220             return getConstraintOfDistributiveConditionalType(type) || getDefaultConstraintOfConditionalType(type);
44221         }
44222         function getConstraintOfConditionalType(type) {
44223             return hasNonCircularBaseConstraint(type) ? getConstraintFromConditionalType(type) : undefined;
44224         }
44225         function getEffectiveConstraintOfIntersection(types, targetIsUnion) {
44226             var constraints;
44227             var hasDisjointDomainType = false;
44228             for (var _i = 0, types_6 = types; _i < types_6.length; _i++) {
44229                 var t = types_6[_i];
44230                 if (t.flags & 465829888) {
44231                     var constraint = getConstraintOfType(t);
44232                     while (constraint && constraint.flags & (262144 | 4194304 | 16777216)) {
44233                         constraint = getConstraintOfType(constraint);
44234                     }
44235                     if (constraint) {
44236                         constraints = ts.append(constraints, constraint);
44237                         if (targetIsUnion) {
44238                             constraints = ts.append(constraints, t);
44239                         }
44240                     }
44241                 }
44242                 else if (t.flags & 469892092) {
44243                     hasDisjointDomainType = true;
44244                 }
44245             }
44246             if (constraints && (targetIsUnion || hasDisjointDomainType)) {
44247                 if (hasDisjointDomainType) {
44248                     for (var _a = 0, types_7 = types; _a < types_7.length; _a++) {
44249                         var t = types_7[_a];
44250                         if (t.flags & 469892092) {
44251                             constraints = ts.append(constraints, t);
44252                         }
44253                     }
44254                 }
44255                 return getIntersectionType(constraints);
44256             }
44257             return undefined;
44258         }
44259         function getBaseConstraintOfType(type) {
44260             if (type.flags & (58982400 | 3145728 | 134217728 | 268435456)) {
44261                 var constraint = getResolvedBaseConstraint(type);
44262                 return constraint !== noConstraintType && constraint !== circularConstraintType ? constraint : undefined;
44263             }
44264             return type.flags & 4194304 ? keyofConstraintType : undefined;
44265         }
44266         function getBaseConstraintOrType(type) {
44267             return getBaseConstraintOfType(type) || type;
44268         }
44269         function hasNonCircularBaseConstraint(type) {
44270             return getResolvedBaseConstraint(type) !== circularConstraintType;
44271         }
44272         function getResolvedBaseConstraint(type) {
44273             if (type.resolvedBaseConstraint) {
44274                 return type.resolvedBaseConstraint;
44275             }
44276             var stack = [];
44277             return type.resolvedBaseConstraint = getTypeWithThisArgument(getImmediateBaseConstraint(type), type);
44278             function getImmediateBaseConstraint(t) {
44279                 if (!t.immediateBaseConstraint) {
44280                     if (!pushTypeResolution(t, 4)) {
44281                         return circularConstraintType;
44282                     }
44283                     var result = void 0;
44284                     if (stack.length < 10 || stack.length < 50 && !isDeeplyNestedType(t, stack, stack.length)) {
44285                         stack.push(t);
44286                         result = computeBaseConstraint(getSimplifiedType(t, false));
44287                         stack.pop();
44288                     }
44289                     if (!popTypeResolution()) {
44290                         if (t.flags & 262144) {
44291                             var errorNode = getConstraintDeclaration(t);
44292                             if (errorNode) {
44293                                 var diagnostic = error(errorNode, ts.Diagnostics.Type_parameter_0_has_a_circular_constraint, typeToString(t));
44294                                 if (currentNode && !ts.isNodeDescendantOf(errorNode, currentNode) && !ts.isNodeDescendantOf(currentNode, errorNode)) {
44295                                     ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(currentNode, ts.Diagnostics.Circularity_originates_in_type_at_this_location));
44296                                 }
44297                             }
44298                         }
44299                         result = circularConstraintType;
44300                     }
44301                     t.immediateBaseConstraint = result || noConstraintType;
44302                 }
44303                 return t.immediateBaseConstraint;
44304             }
44305             function getBaseConstraint(t) {
44306                 var c = getImmediateBaseConstraint(t);
44307                 return c !== noConstraintType && c !== circularConstraintType ? c : undefined;
44308             }
44309             function computeBaseConstraint(t) {
44310                 if (t.flags & 262144) {
44311                     var constraint = getConstraintFromTypeParameter(t);
44312                     return t.isThisType || !constraint ?
44313                         constraint :
44314                         getBaseConstraint(constraint);
44315                 }
44316                 if (t.flags & 3145728) {
44317                     var types = t.types;
44318                     var baseTypes = [];
44319                     var different = false;
44320                     for (var _i = 0, types_8 = types; _i < types_8.length; _i++) {
44321                         var type_3 = types_8[_i];
44322                         var baseType = getBaseConstraint(type_3);
44323                         if (baseType) {
44324                             if (baseType !== type_3) {
44325                                 different = true;
44326                             }
44327                             baseTypes.push(baseType);
44328                         }
44329                         else {
44330                             different = true;
44331                         }
44332                     }
44333                     if (!different) {
44334                         return t;
44335                     }
44336                     return t.flags & 1048576 && baseTypes.length === types.length ? getUnionType(baseTypes) :
44337                         t.flags & 2097152 && baseTypes.length ? getIntersectionType(baseTypes) :
44338                             undefined;
44339                 }
44340                 if (t.flags & 4194304) {
44341                     return keyofConstraintType;
44342                 }
44343                 if (t.flags & 134217728) {
44344                     var types = t.types;
44345                     var constraints = ts.mapDefined(types, getBaseConstraint);
44346                     return constraints.length === types.length ? getTemplateLiteralType(t.texts, constraints) : stringType;
44347                 }
44348                 if (t.flags & 268435456) {
44349                     var constraint = getBaseConstraint(t.type);
44350                     return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
44351                 }
44352                 if (t.flags & 8388608) {
44353                     var baseObjectType = getBaseConstraint(t.objectType);
44354                     var baseIndexType = getBaseConstraint(t.indexType);
44355                     var baseIndexedAccess = baseObjectType && baseIndexType && getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, t.noUncheckedIndexedAccessCandidate);
44356                     return baseIndexedAccess && getBaseConstraint(baseIndexedAccess);
44357                 }
44358                 if (t.flags & 16777216) {
44359                     var constraint = getConstraintFromConditionalType(t);
44360                     return constraint && getBaseConstraint(constraint);
44361                 }
44362                 if (t.flags & 33554432) {
44363                     return getBaseConstraint(t.substitute);
44364                 }
44365                 return t;
44366             }
44367         }
44368         function getApparentTypeOfIntersectionType(type) {
44369             return type.resolvedApparentType || (type.resolvedApparentType = getTypeWithThisArgument(type, type, true));
44370         }
44371         function getResolvedTypeParameterDefault(typeParameter) {
44372             if (!typeParameter.default) {
44373                 if (typeParameter.target) {
44374                     var targetDefault = getResolvedTypeParameterDefault(typeParameter.target);
44375                     typeParameter.default = targetDefault ? instantiateType(targetDefault, typeParameter.mapper) : noConstraintType;
44376                 }
44377                 else {
44378                     typeParameter.default = resolvingDefaultType;
44379                     var defaultDeclaration = typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameterDeclaration(decl) && decl.default; });
44380                     var defaultType = defaultDeclaration ? getTypeFromTypeNode(defaultDeclaration) : noConstraintType;
44381                     if (typeParameter.default === resolvingDefaultType) {
44382                         typeParameter.default = defaultType;
44383                     }
44384                 }
44385             }
44386             else if (typeParameter.default === resolvingDefaultType) {
44387                 typeParameter.default = circularConstraintType;
44388             }
44389             return typeParameter.default;
44390         }
44391         function getDefaultFromTypeParameter(typeParameter) {
44392             var defaultType = getResolvedTypeParameterDefault(typeParameter);
44393             return defaultType !== noConstraintType && defaultType !== circularConstraintType ? defaultType : undefined;
44394         }
44395         function hasNonCircularTypeParameterDefault(typeParameter) {
44396             return getResolvedTypeParameterDefault(typeParameter) !== circularConstraintType;
44397         }
44398         function hasTypeParameterDefault(typeParameter) {
44399             return !!(typeParameter.symbol && ts.forEach(typeParameter.symbol.declarations, function (decl) { return ts.isTypeParameterDeclaration(decl) && decl.default; }));
44400         }
44401         function getApparentTypeOfMappedType(type) {
44402             return type.resolvedApparentType || (type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type));
44403         }
44404         function getResolvedApparentTypeOfMappedType(type) {
44405             var typeVariable = getHomomorphicTypeVariable(type);
44406             if (typeVariable && !type.declaration.nameType) {
44407                 var constraint = getConstraintOfTypeParameter(typeVariable);
44408                 if (constraint && (isArrayType(constraint) || isTupleType(constraint))) {
44409                     return instantiateType(type, prependTypeMapping(typeVariable, constraint, type.mapper));
44410                 }
44411             }
44412             return type;
44413         }
44414         function getApparentType(type) {
44415             var t = type.flags & 465829888 ? getBaseConstraintOfType(type) || unknownType : type;
44416             return ts.getObjectFlags(t) & 32 ? getApparentTypeOfMappedType(t) :
44417                 t.flags & 2097152 ? getApparentTypeOfIntersectionType(t) :
44418                     t.flags & 402653316 ? globalStringType :
44419                         t.flags & 296 ? globalNumberType :
44420                             t.flags & 2112 ? getGlobalBigIntType(languageVersion >= 7) :
44421                                 t.flags & 528 ? globalBooleanType :
44422                                     t.flags & 12288 ? getGlobalESSymbolType(languageVersion >= 2) :
44423                                         t.flags & 67108864 ? emptyObjectType :
44424                                             t.flags & 4194304 ? keyofConstraintType :
44425                                                 t.flags & 2 && !strictNullChecks ? emptyObjectType :
44426                                                     t;
44427         }
44428         function getReducedApparentType(type) {
44429             return getReducedType(getApparentType(getReducedType(type)));
44430         }
44431         function createUnionOrIntersectionProperty(containingType, name, skipObjectFunctionPropertyAugment) {
44432             var singleProp;
44433             var propSet;
44434             var indexTypes;
44435             var isUnion = containingType.flags & 1048576;
44436             var optionalFlag = isUnion ? 0 : 16777216;
44437             var syntheticFlag = 4;
44438             var checkFlags = 0;
44439             for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) {
44440                 var current = _a[_i];
44441                 var type = getApparentType(current);
44442                 if (!(type === errorType || type.flags & 131072)) {
44443                     var prop = getPropertyOfType(type, name, skipObjectFunctionPropertyAugment);
44444                     var modifiers = prop ? ts.getDeclarationModifierFlagsFromSymbol(prop) : 0;
44445                     if (prop) {
44446                         if (isUnion) {
44447                             optionalFlag |= (prop.flags & 16777216);
44448                         }
44449                         else {
44450                             optionalFlag &= prop.flags;
44451                         }
44452                         if (!singleProp) {
44453                             singleProp = prop;
44454                         }
44455                         else if (prop !== singleProp) {
44456                             if (!propSet) {
44457                                 propSet = new ts.Map();
44458                                 propSet.set(getSymbolId(singleProp), singleProp);
44459                             }
44460                             var id = getSymbolId(prop);
44461                             if (!propSet.has(id)) {
44462                                 propSet.set(id, prop);
44463                             }
44464                         }
44465                         checkFlags |= (isReadonlySymbol(prop) ? 8 : 0) |
44466                             (!(modifiers & 24) ? 256 : 0) |
44467                             (modifiers & 16 ? 512 : 0) |
44468                             (modifiers & 8 ? 1024 : 0) |
44469                             (modifiers & 32 ? 2048 : 0);
44470                         if (!isPrototypeProperty(prop)) {
44471                             syntheticFlag = 2;
44472                         }
44473                     }
44474                     else if (isUnion) {
44475                         var indexInfo = !isLateBoundName(name) && (isNumericLiteralName(name) && getIndexInfoOfType(type, 1) || getIndexInfoOfType(type, 0));
44476                         if (indexInfo) {
44477                             checkFlags |= 32 | (indexInfo.isReadonly ? 8 : 0);
44478                             indexTypes = ts.append(indexTypes, isTupleType(type) ? getRestTypeOfTupleType(type) || undefinedType : indexInfo.type);
44479                         }
44480                         else if (isObjectLiteralType(type)) {
44481                             checkFlags |= 32;
44482                             indexTypes = ts.append(indexTypes, undefinedType);
44483                         }
44484                         else {
44485                             checkFlags |= 16;
44486                         }
44487                     }
44488                 }
44489             }
44490             if (!singleProp || isUnion && (propSet || checkFlags & 48) && checkFlags & (1024 | 512)) {
44491                 return undefined;
44492             }
44493             if (!propSet && !(checkFlags & 16) && !indexTypes) {
44494                 return singleProp;
44495             }
44496             var props = propSet ? ts.arrayFrom(propSet.values()) : [singleProp];
44497             var declarations;
44498             var firstType;
44499             var nameType;
44500             var propTypes = [];
44501             var firstValueDeclaration;
44502             var hasNonUniformValueDeclaration = false;
44503             for (var _b = 0, props_1 = props; _b < props_1.length; _b++) {
44504                 var prop = props_1[_b];
44505                 if (!firstValueDeclaration) {
44506                     firstValueDeclaration = prop.valueDeclaration;
44507                 }
44508                 else if (prop.valueDeclaration && prop.valueDeclaration !== firstValueDeclaration) {
44509                     hasNonUniformValueDeclaration = true;
44510                 }
44511                 declarations = ts.addRange(declarations, prop.declarations);
44512                 var type = getTypeOfSymbol(prop);
44513                 if (!firstType) {
44514                     firstType = type;
44515                     nameType = getSymbolLinks(prop).nameType;
44516                 }
44517                 else if (type !== firstType) {
44518                     checkFlags |= 64;
44519                 }
44520                 if (isLiteralType(type)) {
44521                     checkFlags |= 128;
44522                 }
44523                 if (type.flags & 131072) {
44524                     checkFlags |= 131072;
44525                 }
44526                 propTypes.push(type);
44527             }
44528             ts.addRange(propTypes, indexTypes);
44529             var result = createSymbol(4 | optionalFlag, name, syntheticFlag | checkFlags);
44530             result.containingType = containingType;
44531             if (!hasNonUniformValueDeclaration && firstValueDeclaration) {
44532                 result.valueDeclaration = firstValueDeclaration;
44533                 if (firstValueDeclaration.symbol.parent) {
44534                     result.parent = firstValueDeclaration.symbol.parent;
44535                 }
44536             }
44537             result.declarations = declarations;
44538             result.nameType = nameType;
44539             if (propTypes.length > 2) {
44540                 result.checkFlags |= 65536;
44541                 result.deferralParent = containingType;
44542                 result.deferralConstituents = propTypes;
44543             }
44544             else {
44545                 result.type = isUnion ? getUnionType(propTypes) : getIntersectionType(propTypes);
44546             }
44547             return result;
44548         }
44549         function getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment) {
44550             var _a, _b;
44551             var property = ((_a = type.propertyCacheWithoutObjectFunctionPropertyAugment) === null || _a === void 0 ? void 0 : _a.get(name)) ||
44552                 !skipObjectFunctionPropertyAugment ? (_b = type.propertyCache) === null || _b === void 0 ? void 0 : _b.get(name) : undefined;
44553             if (!property) {
44554                 property = createUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
44555                 if (property) {
44556                     var properties = skipObjectFunctionPropertyAugment ? type.propertyCacheWithoutObjectFunctionPropertyAugment || (type.propertyCacheWithoutObjectFunctionPropertyAugment = ts.createSymbolTable()) : type.propertyCache || (type.propertyCache = ts.createSymbolTable());
44557                     properties.set(name, property);
44558                 }
44559             }
44560             return property;
44561         }
44562         function getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment) {
44563             var property = getUnionOrIntersectionProperty(type, name, skipObjectFunctionPropertyAugment);
44564             return property && !(ts.getCheckFlags(property) & 16) ? property : undefined;
44565         }
44566         function getReducedType(type) {
44567             if (type.flags & 1048576 && type.objectFlags & 268435456) {
44568                 return type.resolvedReducedType || (type.resolvedReducedType = getReducedUnionType(type));
44569             }
44570             else if (type.flags & 2097152) {
44571                 if (!(type.objectFlags & 268435456)) {
44572                     type.objectFlags |= 268435456 |
44573                         (ts.some(getPropertiesOfUnionOrIntersectionType(type), isNeverReducedProperty) ? 536870912 : 0);
44574                 }
44575                 return type.objectFlags & 536870912 ? neverType : type;
44576             }
44577             return type;
44578         }
44579         function getReducedUnionType(unionType) {
44580             var reducedTypes = ts.sameMap(unionType.types, getReducedType);
44581             if (reducedTypes === unionType.types) {
44582                 return unionType;
44583             }
44584             var reduced = getUnionType(reducedTypes);
44585             if (reduced.flags & 1048576) {
44586                 reduced.resolvedReducedType = reduced;
44587             }
44588             return reduced;
44589         }
44590         function isNeverReducedProperty(prop) {
44591             return isDiscriminantWithNeverType(prop) || isConflictingPrivateProperty(prop);
44592         }
44593         function isDiscriminantWithNeverType(prop) {
44594             return !(prop.flags & 16777216) &&
44595                 (ts.getCheckFlags(prop) & (192 | 131072)) === 192 &&
44596                 !!(getTypeOfSymbol(prop).flags & 131072);
44597         }
44598         function isConflictingPrivateProperty(prop) {
44599             return !prop.valueDeclaration && !!(ts.getCheckFlags(prop) & 1024);
44600         }
44601         function elaborateNeverIntersection(errorInfo, type) {
44602             if (ts.getObjectFlags(type) & 536870912) {
44603                 var neverProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isDiscriminantWithNeverType);
44604                 if (neverProp) {
44605                     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));
44606                 }
44607                 var privateProp = ts.find(getPropertiesOfUnionOrIntersectionType(type), isConflictingPrivateProperty);
44608                 if (privateProp) {
44609                     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));
44610                 }
44611             }
44612             return errorInfo;
44613         }
44614         function getPropertyOfType(type, name, skipObjectFunctionPropertyAugment) {
44615             type = getReducedApparentType(type);
44616             if (type.flags & 524288) {
44617                 var resolved = resolveStructuredTypeMembers(type);
44618                 var symbol = resolved.members.get(name);
44619                 if (symbol && symbolIsValue(symbol)) {
44620                     return symbol;
44621                 }
44622                 if (skipObjectFunctionPropertyAugment)
44623                     return undefined;
44624                 var functionType = resolved === anyFunctionType ? globalFunctionType :
44625                     resolved.callSignatures.length ? globalCallableFunctionType :
44626                         resolved.constructSignatures.length ? globalNewableFunctionType :
44627                             undefined;
44628                 if (functionType) {
44629                     var symbol_1 = getPropertyOfObjectType(functionType, name);
44630                     if (symbol_1) {
44631                         return symbol_1;
44632                     }
44633                 }
44634                 return getPropertyOfObjectType(globalObjectType, name);
44635             }
44636             if (type.flags & 3145728) {
44637                 return getPropertyOfUnionOrIntersectionType(type, name, skipObjectFunctionPropertyAugment);
44638             }
44639             return undefined;
44640         }
44641         function getSignaturesOfStructuredType(type, kind) {
44642             if (type.flags & 3670016) {
44643                 var resolved = resolveStructuredTypeMembers(type);
44644                 return kind === 0 ? resolved.callSignatures : resolved.constructSignatures;
44645             }
44646             return ts.emptyArray;
44647         }
44648         function getSignaturesOfType(type, kind) {
44649             return getSignaturesOfStructuredType(getReducedApparentType(type), kind);
44650         }
44651         function getIndexInfoOfStructuredType(type, kind) {
44652             if (type.flags & 3670016) {
44653                 var resolved = resolveStructuredTypeMembers(type);
44654                 return kind === 0 ? resolved.stringIndexInfo : resolved.numberIndexInfo;
44655             }
44656         }
44657         function getIndexTypeOfStructuredType(type, kind) {
44658             var info = getIndexInfoOfStructuredType(type, kind);
44659             return info && info.type;
44660         }
44661         function getIndexInfoOfType(type, kind) {
44662             return getIndexInfoOfStructuredType(getReducedApparentType(type), kind);
44663         }
44664         function getIndexTypeOfType(type, kind) {
44665             return getIndexTypeOfStructuredType(getReducedApparentType(type), kind);
44666         }
44667         function getImplicitIndexTypeOfType(type, kind) {
44668             if (isObjectTypeWithInferableIndex(type)) {
44669                 var propTypes = [];
44670                 for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
44671                     var prop = _a[_i];
44672                     if (kind === 0 || isNumericLiteralName(prop.escapedName)) {
44673                         propTypes.push(getTypeOfSymbol(prop));
44674                     }
44675                 }
44676                 if (kind === 0) {
44677                     ts.append(propTypes, getIndexTypeOfType(type, 1));
44678                 }
44679                 if (propTypes.length) {
44680                     return getUnionType(propTypes);
44681                 }
44682             }
44683             return undefined;
44684         }
44685         function getTypeParametersFromDeclaration(declaration) {
44686             var result;
44687             for (var _i = 0, _a = ts.getEffectiveTypeParameterDeclarations(declaration); _i < _a.length; _i++) {
44688                 var node = _a[_i];
44689                 result = ts.appendIfUnique(result, getDeclaredTypeOfTypeParameter(node.symbol));
44690             }
44691             return result;
44692         }
44693         function symbolsToArray(symbols) {
44694             var result = [];
44695             symbols.forEach(function (symbol, id) {
44696                 if (!isReservedMemberName(id)) {
44697                     result.push(symbol);
44698                 }
44699             });
44700             return result;
44701         }
44702         function isJSDocOptionalParameter(node) {
44703             return ts.isInJSFile(node) && (node.type && node.type.kind === 307
44704                 || ts.getJSDocParameterTags(node).some(function (_a) {
44705                     var isBracketed = _a.isBracketed, typeExpression = _a.typeExpression;
44706                     return isBracketed || !!typeExpression && typeExpression.type.kind === 307;
44707                 }));
44708         }
44709         function tryFindAmbientModule(moduleName, withAugmentations) {
44710             if (ts.isExternalModuleNameRelative(moduleName)) {
44711                 return undefined;
44712             }
44713             var symbol = getSymbol(globals, '"' + moduleName + '"', 512);
44714             return symbol && withAugmentations ? getMergedSymbol(symbol) : symbol;
44715         }
44716         function isOptionalParameter(node) {
44717             if (ts.hasQuestionToken(node) || isOptionalJSDocPropertyLikeTag(node) || isJSDocOptionalParameter(node)) {
44718                 return true;
44719             }
44720             if (node.initializer) {
44721                 var signature = getSignatureFromDeclaration(node.parent);
44722                 var parameterIndex = node.parent.parameters.indexOf(node);
44723                 ts.Debug.assert(parameterIndex >= 0);
44724                 return parameterIndex >= getMinArgumentCount(signature, 1 | 2);
44725             }
44726             var iife = ts.getImmediatelyInvokedFunctionExpression(node.parent);
44727             if (iife) {
44728                 return !node.type &&
44729                     !node.dotDotDotToken &&
44730                     node.parent.parameters.indexOf(node) >= iife.arguments.length;
44731             }
44732             return false;
44733         }
44734         function isOptionalJSDocPropertyLikeTag(node) {
44735             if (!ts.isJSDocPropertyLikeTag(node)) {
44736                 return false;
44737             }
44738             var isBracketed = node.isBracketed, typeExpression = node.typeExpression;
44739             return isBracketed || !!typeExpression && typeExpression.type.kind === 307;
44740         }
44741         function createTypePredicate(kind, parameterName, parameterIndex, type) {
44742             return { kind: kind, parameterName: parameterName, parameterIndex: parameterIndex, type: type };
44743         }
44744         function getMinTypeArgumentCount(typeParameters) {
44745             var minTypeArgumentCount = 0;
44746             if (typeParameters) {
44747                 for (var i = 0; i < typeParameters.length; i++) {
44748                     if (!hasTypeParameterDefault(typeParameters[i])) {
44749                         minTypeArgumentCount = i + 1;
44750                     }
44751                 }
44752             }
44753             return minTypeArgumentCount;
44754         }
44755         function fillMissingTypeArguments(typeArguments, typeParameters, minTypeArgumentCount, isJavaScriptImplicitAny) {
44756             var numTypeParameters = ts.length(typeParameters);
44757             if (!numTypeParameters) {
44758                 return [];
44759             }
44760             var numTypeArguments = ts.length(typeArguments);
44761             if (isJavaScriptImplicitAny || (numTypeArguments >= minTypeArgumentCount && numTypeArguments <= numTypeParameters)) {
44762                 var result = typeArguments ? typeArguments.slice() : [];
44763                 for (var i = numTypeArguments; i < numTypeParameters; i++) {
44764                     result[i] = errorType;
44765                 }
44766                 var baseDefaultType = getDefaultTypeArgumentType(isJavaScriptImplicitAny);
44767                 for (var i = numTypeArguments; i < numTypeParameters; i++) {
44768                     var defaultType = getDefaultFromTypeParameter(typeParameters[i]);
44769                     if (isJavaScriptImplicitAny && defaultType && (isTypeIdenticalTo(defaultType, unknownType) || isTypeIdenticalTo(defaultType, emptyObjectType))) {
44770                         defaultType = anyType;
44771                     }
44772                     result[i] = defaultType ? instantiateType(defaultType, createTypeMapper(typeParameters, result)) : baseDefaultType;
44773                 }
44774                 result.length = typeParameters.length;
44775                 return result;
44776             }
44777             return typeArguments && typeArguments.slice();
44778         }
44779         function getSignatureFromDeclaration(declaration) {
44780             var links = getNodeLinks(declaration);
44781             if (!links.resolvedSignature) {
44782                 var parameters = [];
44783                 var flags = 0;
44784                 var minArgumentCount = 0;
44785                 var thisParameter = void 0;
44786                 var hasThisParameter = false;
44787                 var iife = ts.getImmediatelyInvokedFunctionExpression(declaration);
44788                 var isJSConstructSignature = ts.isJSDocConstructSignature(declaration);
44789                 var isUntypedSignatureInJSFile = !iife &&
44790                     ts.isInJSFile(declaration) &&
44791                     ts.isValueSignatureDeclaration(declaration) &&
44792                     !ts.hasJSDocParameterTags(declaration) &&
44793                     !ts.getJSDocType(declaration);
44794                 if (isUntypedSignatureInJSFile) {
44795                     flags |= 32;
44796                 }
44797                 for (var i = isJSConstructSignature ? 1 : 0; i < declaration.parameters.length; i++) {
44798                     var param = declaration.parameters[i];
44799                     var paramSymbol = param.symbol;
44800                     var type = ts.isJSDocParameterTag(param) ? (param.typeExpression && param.typeExpression.type) : param.type;
44801                     if (paramSymbol && !!(paramSymbol.flags & 4) && !ts.isBindingPattern(param.name)) {
44802                         var resolvedSymbol = resolveName(param, paramSymbol.escapedName, 111551, undefined, undefined, false);
44803                         paramSymbol = resolvedSymbol;
44804                     }
44805                     if (i === 0 && paramSymbol.escapedName === "this") {
44806                         hasThisParameter = true;
44807                         thisParameter = param.symbol;
44808                     }
44809                     else {
44810                         parameters.push(paramSymbol);
44811                     }
44812                     if (type && type.kind === 191) {
44813                         flags |= 2;
44814                     }
44815                     var isOptionalParameter_1 = isOptionalJSDocPropertyLikeTag(param) ||
44816                         param.initializer || param.questionToken || param.dotDotDotToken ||
44817                         iife && parameters.length > iife.arguments.length && !type ||
44818                         isJSDocOptionalParameter(param);
44819                     if (!isOptionalParameter_1) {
44820                         minArgumentCount = parameters.length;
44821                     }
44822                 }
44823                 if ((declaration.kind === 167 || declaration.kind === 168) &&
44824                     hasBindableName(declaration) &&
44825                     (!hasThisParameter || !thisParameter)) {
44826                     var otherKind = declaration.kind === 167 ? 168 : 167;
44827                     var other = ts.getDeclarationOfKind(getSymbolOfNode(declaration), otherKind);
44828                     if (other) {
44829                         thisParameter = getAnnotatedAccessorThisParameter(other);
44830                     }
44831                 }
44832                 var classType = declaration.kind === 166 ?
44833                     getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol))
44834                     : undefined;
44835                 var typeParameters = classType ? classType.localTypeParameters : getTypeParametersFromDeclaration(declaration);
44836                 if (ts.hasRestParameter(declaration) || ts.isInJSFile(declaration) && maybeAddJsSyntheticRestParameter(declaration, parameters)) {
44837                     flags |= 1;
44838                 }
44839                 if (ts.isConstructorTypeNode(declaration) && ts.hasSyntacticModifier(declaration, 128) ||
44840                     ts.isConstructorDeclaration(declaration) && ts.hasSyntacticModifier(declaration.parent, 128)) {
44841                     flags |= 4;
44842                 }
44843                 links.resolvedSignature = createSignature(declaration, typeParameters, thisParameter, parameters, undefined, undefined, minArgumentCount, flags);
44844             }
44845             return links.resolvedSignature;
44846         }
44847         function maybeAddJsSyntheticRestParameter(declaration, parameters) {
44848             if (ts.isJSDocSignature(declaration) || !containsArgumentsReference(declaration)) {
44849                 return false;
44850             }
44851             var lastParam = ts.lastOrUndefined(declaration.parameters);
44852             var lastParamTags = lastParam ? ts.getJSDocParameterTags(lastParam) : ts.getJSDocTags(declaration).filter(ts.isJSDocParameterTag);
44853             var lastParamVariadicType = ts.firstDefined(lastParamTags, function (p) {
44854                 return p.typeExpression && ts.isJSDocVariadicType(p.typeExpression.type) ? p.typeExpression.type : undefined;
44855             });
44856             var syntheticArgsSymbol = createSymbol(3, "args", 32768);
44857             syntheticArgsSymbol.type = lastParamVariadicType ? createArrayType(getTypeFromTypeNode(lastParamVariadicType.type)) : anyArrayType;
44858             if (lastParamVariadicType) {
44859                 parameters.pop();
44860             }
44861             parameters.push(syntheticArgsSymbol);
44862             return true;
44863         }
44864         function getSignatureOfTypeTag(node) {
44865             if (!(ts.isInJSFile(node) && ts.isFunctionLikeDeclaration(node)))
44866                 return undefined;
44867             var typeTag = ts.getJSDocTypeTag(node);
44868             var signature = typeTag && typeTag.typeExpression && getSingleCallSignature(getTypeFromTypeNode(typeTag.typeExpression));
44869             return signature && getErasedSignature(signature);
44870         }
44871         function getReturnTypeOfTypeTag(node) {
44872             var signature = getSignatureOfTypeTag(node);
44873             return signature && getReturnTypeOfSignature(signature);
44874         }
44875         function containsArgumentsReference(declaration) {
44876             var links = getNodeLinks(declaration);
44877             if (links.containsArgumentsReference === undefined) {
44878                 if (links.flags & 8192) {
44879                     links.containsArgumentsReference = true;
44880                 }
44881                 else {
44882                     links.containsArgumentsReference = traverse(declaration.body);
44883                 }
44884             }
44885             return links.containsArgumentsReference;
44886             function traverse(node) {
44887                 if (!node)
44888                     return false;
44889                 switch (node.kind) {
44890                     case 78:
44891                         return node.escapedText === argumentsSymbol.escapedName && getResolvedSymbol(node) === argumentsSymbol;
44892                     case 163:
44893                     case 165:
44894                     case 167:
44895                     case 168:
44896                         return node.name.kind === 158
44897                             && traverse(node.name);
44898                     case 201:
44899                     case 202:
44900                         return traverse(node.expression);
44901                     default:
44902                         return !ts.nodeStartsNewLexicalEnvironment(node) && !ts.isPartOfTypeNode(node) && !!ts.forEachChild(node, traverse);
44903                 }
44904             }
44905         }
44906         function getSignaturesOfSymbol(symbol) {
44907             if (!symbol)
44908                 return ts.emptyArray;
44909             var result = [];
44910             for (var i = 0; i < symbol.declarations.length; i++) {
44911                 var decl = symbol.declarations[i];
44912                 if (!ts.isFunctionLike(decl))
44913                     continue;
44914                 if (i > 0 && decl.body) {
44915                     var previous = symbol.declarations[i - 1];
44916                     if (decl.parent === previous.parent && decl.kind === previous.kind && decl.pos === previous.end) {
44917                         continue;
44918                     }
44919                 }
44920                 result.push(getSignatureFromDeclaration(decl));
44921             }
44922             return result;
44923         }
44924         function resolveExternalModuleTypeByLiteral(name) {
44925             var moduleSym = resolveExternalModuleName(name, name);
44926             if (moduleSym) {
44927                 var resolvedModuleSymbol = resolveExternalModuleSymbol(moduleSym);
44928                 if (resolvedModuleSymbol) {
44929                     return getTypeOfSymbol(resolvedModuleSymbol);
44930                 }
44931             }
44932             return anyType;
44933         }
44934         function getThisTypeOfSignature(signature) {
44935             if (signature.thisParameter) {
44936                 return getTypeOfSymbol(signature.thisParameter);
44937             }
44938         }
44939         function getTypePredicateOfSignature(signature) {
44940             if (!signature.resolvedTypePredicate) {
44941                 if (signature.target) {
44942                     var targetTypePredicate = getTypePredicateOfSignature(signature.target);
44943                     signature.resolvedTypePredicate = targetTypePredicate ? instantiateTypePredicate(targetTypePredicate, signature.mapper) : noTypePredicate;
44944                 }
44945                 else if (signature.unionSignatures) {
44946                     signature.resolvedTypePredicate = getUnionTypePredicate(signature.unionSignatures) || noTypePredicate;
44947                 }
44948                 else {
44949                     var type = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration);
44950                     var jsdocPredicate = void 0;
44951                     if (!type && ts.isInJSFile(signature.declaration)) {
44952                         var jsdocSignature = getSignatureOfTypeTag(signature.declaration);
44953                         if (jsdocSignature && signature !== jsdocSignature) {
44954                             jsdocPredicate = getTypePredicateOfSignature(jsdocSignature);
44955                         }
44956                     }
44957                     signature.resolvedTypePredicate = type && ts.isTypePredicateNode(type) ?
44958                         createTypePredicateFromTypePredicateNode(type, signature) :
44959                         jsdocPredicate || noTypePredicate;
44960                 }
44961                 ts.Debug.assert(!!signature.resolvedTypePredicate);
44962             }
44963             return signature.resolvedTypePredicate === noTypePredicate ? undefined : signature.resolvedTypePredicate;
44964         }
44965         function createTypePredicateFromTypePredicateNode(node, signature) {
44966             var parameterName = node.parameterName;
44967             var type = node.type && getTypeFromTypeNode(node.type);
44968             return parameterName.kind === 187 ?
44969                 createTypePredicate(node.assertsModifier ? 2 : 0, undefined, undefined, type) :
44970                 createTypePredicate(node.assertsModifier ? 3 : 1, parameterName.escapedText, ts.findIndex(signature.parameters, function (p) { return p.escapedName === parameterName.escapedText; }), type);
44971         }
44972         function getReturnTypeOfSignature(signature) {
44973             if (!signature.resolvedReturnType) {
44974                 if (!pushTypeResolution(signature, 3)) {
44975                     return errorType;
44976                 }
44977                 var type = signature.target ? instantiateType(getReturnTypeOfSignature(signature.target), signature.mapper) :
44978                     signature.unionSignatures ? instantiateType(getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2), signature.mapper) :
44979                         getReturnTypeFromAnnotation(signature.declaration) ||
44980                             (ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration));
44981                 if (signature.flags & 8) {
44982                     type = addOptionalTypeMarker(type);
44983                 }
44984                 else if (signature.flags & 16) {
44985                     type = getOptionalType(type);
44986                 }
44987                 if (!popTypeResolution()) {
44988                     if (signature.declaration) {
44989                         var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration);
44990                         if (typeNode) {
44991                             error(typeNode, ts.Diagnostics.Return_type_annotation_circularly_references_itself);
44992                         }
44993                         else if (noImplicitAny) {
44994                             var declaration = signature.declaration;
44995                             var name = ts.getNameOfDeclaration(declaration);
44996                             if (name) {
44997                                 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));
44998                             }
44999                             else {
45000                                 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);
45001                             }
45002                         }
45003                     }
45004                     type = anyType;
45005                 }
45006                 signature.resolvedReturnType = type;
45007             }
45008             return signature.resolvedReturnType;
45009         }
45010         function getReturnTypeFromAnnotation(declaration) {
45011             if (declaration.kind === 166) {
45012                 return getDeclaredTypeOfClassOrInterface(getMergedSymbol(declaration.parent.symbol));
45013             }
45014             if (ts.isJSDocConstructSignature(declaration)) {
45015                 return getTypeFromTypeNode(declaration.parameters[0].type);
45016             }
45017             var typeNode = ts.getEffectiveReturnTypeNode(declaration);
45018             if (typeNode) {
45019                 return getTypeFromTypeNode(typeNode);
45020             }
45021             if (declaration.kind === 167 && hasBindableName(declaration)) {
45022                 var jsDocType = ts.isInJSFile(declaration) && getTypeForDeclarationFromJSDocComment(declaration);
45023                 if (jsDocType) {
45024                     return jsDocType;
45025                 }
45026                 var setter = ts.getDeclarationOfKind(getSymbolOfNode(declaration), 168);
45027                 var setterType = getAnnotatedAccessorType(setter);
45028                 if (setterType) {
45029                     return setterType;
45030                 }
45031             }
45032             return getReturnTypeOfTypeTag(declaration);
45033         }
45034         function isResolvingReturnTypeOfSignature(signature) {
45035             return !signature.resolvedReturnType && findResolutionCycleStartIndex(signature, 3) >= 0;
45036         }
45037         function getRestTypeOfSignature(signature) {
45038             return tryGetRestTypeOfSignature(signature) || anyType;
45039         }
45040         function tryGetRestTypeOfSignature(signature) {
45041             if (signatureHasRestParameter(signature)) {
45042                 var sigRestType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
45043                 var restType = isTupleType(sigRestType) ? getRestTypeOfTupleType(sigRestType) : sigRestType;
45044                 return restType && getIndexTypeOfType(restType, 1);
45045             }
45046             return undefined;
45047         }
45048         function getSignatureInstantiation(signature, typeArguments, isJavascript, inferredTypeParameters) {
45049             var instantiatedSignature = getSignatureInstantiationWithoutFillingInTypeArguments(signature, fillMissingTypeArguments(typeArguments, signature.typeParameters, getMinTypeArgumentCount(signature.typeParameters), isJavascript));
45050             if (inferredTypeParameters) {
45051                 var returnSignature = getSingleCallOrConstructSignature(getReturnTypeOfSignature(instantiatedSignature));
45052                 if (returnSignature) {
45053                     var newReturnSignature = cloneSignature(returnSignature);
45054                     newReturnSignature.typeParameters = inferredTypeParameters;
45055                     var newInstantiatedSignature = cloneSignature(instantiatedSignature);
45056                     newInstantiatedSignature.resolvedReturnType = getOrCreateTypeFromSignature(newReturnSignature);
45057                     return newInstantiatedSignature;
45058                 }
45059             }
45060             return instantiatedSignature;
45061         }
45062         function getSignatureInstantiationWithoutFillingInTypeArguments(signature, typeArguments) {
45063             var instantiations = signature.instantiations || (signature.instantiations = new ts.Map());
45064             var id = getTypeListId(typeArguments);
45065             var instantiation = instantiations.get(id);
45066             if (!instantiation) {
45067                 instantiations.set(id, instantiation = createSignatureInstantiation(signature, typeArguments));
45068             }
45069             return instantiation;
45070         }
45071         function createSignatureInstantiation(signature, typeArguments) {
45072             return instantiateSignature(signature, createSignatureTypeMapper(signature, typeArguments), true);
45073         }
45074         function createSignatureTypeMapper(signature, typeArguments) {
45075             return createTypeMapper(signature.typeParameters, typeArguments);
45076         }
45077         function getErasedSignature(signature) {
45078             return signature.typeParameters ?
45079                 signature.erasedSignatureCache || (signature.erasedSignatureCache = createErasedSignature(signature)) :
45080                 signature;
45081         }
45082         function createErasedSignature(signature) {
45083             return instantiateSignature(signature, createTypeEraser(signature.typeParameters), true);
45084         }
45085         function getCanonicalSignature(signature) {
45086             return signature.typeParameters ?
45087                 signature.canonicalSignatureCache || (signature.canonicalSignatureCache = createCanonicalSignature(signature)) :
45088                 signature;
45089         }
45090         function createCanonicalSignature(signature) {
45091             return getSignatureInstantiation(signature, ts.map(signature.typeParameters, function (tp) { return tp.target && !getConstraintOfTypeParameter(tp.target) ? tp.target : tp; }), ts.isInJSFile(signature.declaration));
45092         }
45093         function getBaseSignature(signature) {
45094             var typeParameters = signature.typeParameters;
45095             if (typeParameters) {
45096                 var typeEraser_1 = createTypeEraser(typeParameters);
45097                 var baseConstraints = ts.map(typeParameters, function (tp) { return instantiateType(getBaseConstraintOfType(tp), typeEraser_1) || unknownType; });
45098                 return instantiateSignature(signature, createTypeMapper(typeParameters, baseConstraints), true);
45099             }
45100             return signature;
45101         }
45102         function getOrCreateTypeFromSignature(signature) {
45103             if (!signature.isolatedSignatureType) {
45104                 var kind = signature.declaration ? signature.declaration.kind : 0;
45105                 var isConstructor = kind === 166 || kind === 170 || kind === 175;
45106                 var type = createObjectType(16);
45107                 type.members = emptySymbols;
45108                 type.properties = ts.emptyArray;
45109                 type.callSignatures = !isConstructor ? [signature] : ts.emptyArray;
45110                 type.constructSignatures = isConstructor ? [signature] : ts.emptyArray;
45111                 signature.isolatedSignatureType = type;
45112             }
45113             return signature.isolatedSignatureType;
45114         }
45115         function getIndexSymbol(symbol) {
45116             return symbol.members.get("__index");
45117         }
45118         function getIndexDeclarationOfSymbol(symbol, kind) {
45119             var syntaxKind = kind === 1 ? 144 : 147;
45120             var indexSymbol = getIndexSymbol(symbol);
45121             if (indexSymbol) {
45122                 for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
45123                     var decl = _a[_i];
45124                     var node = ts.cast(decl, ts.isIndexSignatureDeclaration);
45125                     if (node.parameters.length === 1) {
45126                         var parameter = node.parameters[0];
45127                         if (parameter.type && parameter.type.kind === syntaxKind) {
45128                             return node;
45129                         }
45130                     }
45131                 }
45132             }
45133             return undefined;
45134         }
45135         function createIndexInfo(type, isReadonly, declaration) {
45136             return { type: type, isReadonly: isReadonly, declaration: declaration };
45137         }
45138         function getIndexInfoOfSymbol(symbol, kind) {
45139             var declaration = getIndexDeclarationOfSymbol(symbol, kind);
45140             if (declaration) {
45141                 return createIndexInfo(declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, ts.hasEffectiveModifier(declaration, 64), declaration);
45142             }
45143             return undefined;
45144         }
45145         function getConstraintDeclaration(type) {
45146             return ts.mapDefined(ts.filter(type.symbol && type.symbol.declarations, ts.isTypeParameterDeclaration), ts.getEffectiveConstraintOfTypeParameter)[0];
45147         }
45148         function getInferredTypeParameterConstraint(typeParameter) {
45149             var inferences;
45150             if (typeParameter.symbol) {
45151                 for (var _i = 0, _a = typeParameter.symbol.declarations; _i < _a.length; _i++) {
45152                     var declaration = _a[_i];
45153                     if (declaration.parent.kind === 185) {
45154                         var _b = ts.walkUpParenthesizedTypesAndGetParentAndChild(declaration.parent.parent), _c = _b[0], childTypeParameter = _c === void 0 ? declaration.parent : _c, grandParent = _b[1];
45155                         if (grandParent.kind === 173) {
45156                             var typeReference = grandParent;
45157                             var typeParameters = getTypeParametersForTypeReference(typeReference);
45158                             if (typeParameters) {
45159                                 var index = typeReference.typeArguments.indexOf(childTypeParameter);
45160                                 if (index < typeParameters.length) {
45161                                     var declaredConstraint = getConstraintOfTypeParameter(typeParameters[index]);
45162                                     if (declaredConstraint) {
45163                                         var mapper = createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReference, typeParameters));
45164                                         var constraint = instantiateType(declaredConstraint, mapper);
45165                                         if (constraint !== typeParameter) {
45166                                             inferences = ts.append(inferences, constraint);
45167                                         }
45168                                     }
45169                                 }
45170                             }
45171                         }
45172                         else if (grandParent.kind === 160 && grandParent.dotDotDotToken ||
45173                             grandParent.kind === 181 ||
45174                             grandParent.kind === 192 && grandParent.dotDotDotToken) {
45175                             inferences = ts.append(inferences, createArrayType(unknownType));
45176                         }
45177                         else if (grandParent.kind === 194) {
45178                             inferences = ts.append(inferences, stringType);
45179                         }
45180                         else if (grandParent.kind === 159 && grandParent.parent.kind === 190) {
45181                             inferences = ts.append(inferences, keyofConstraintType);
45182                         }
45183                     }
45184                 }
45185             }
45186             return inferences && getIntersectionType(inferences);
45187         }
45188         function getConstraintFromTypeParameter(typeParameter) {
45189             if (!typeParameter.constraint) {
45190                 if (typeParameter.target) {
45191                     var targetConstraint = getConstraintOfTypeParameter(typeParameter.target);
45192                     typeParameter.constraint = targetConstraint ? instantiateType(targetConstraint, typeParameter.mapper) : noConstraintType;
45193                 }
45194                 else {
45195                     var constraintDeclaration = getConstraintDeclaration(typeParameter);
45196                     if (!constraintDeclaration) {
45197                         typeParameter.constraint = getInferredTypeParameterConstraint(typeParameter) || noConstraintType;
45198                     }
45199                     else {
45200                         var type = getTypeFromTypeNode(constraintDeclaration);
45201                         if (type.flags & 1 && type !== errorType) {
45202                             type = constraintDeclaration.parent.parent.kind === 190 ? keyofConstraintType : unknownType;
45203                         }
45204                         typeParameter.constraint = type;
45205                     }
45206                 }
45207             }
45208             return typeParameter.constraint === noConstraintType ? undefined : typeParameter.constraint;
45209         }
45210         function getParentSymbolOfTypeParameter(typeParameter) {
45211             var tp = ts.getDeclarationOfKind(typeParameter.symbol, 159);
45212             var host = ts.isJSDocTemplateTag(tp.parent) ? ts.getHostSignatureFromJSDoc(tp.parent) : tp.parent;
45213             return host && getSymbolOfNode(host);
45214         }
45215         function getTypeListId(types) {
45216             var result = "";
45217             if (types) {
45218                 var length_4 = types.length;
45219                 var i = 0;
45220                 while (i < length_4) {
45221                     var startId = types[i].id;
45222                     var count = 1;
45223                     while (i + count < length_4 && types[i + count].id === startId + count) {
45224                         count++;
45225                     }
45226                     if (result.length) {
45227                         result += ",";
45228                     }
45229                     result += startId;
45230                     if (count > 1) {
45231                         result += ":" + count;
45232                     }
45233                     i += count;
45234                 }
45235             }
45236             return result;
45237         }
45238         function getAliasId(aliasSymbol, aliasTypeArguments) {
45239             return aliasSymbol ? "@" + getSymbolId(aliasSymbol) + (aliasTypeArguments ? ":" + getTypeListId(aliasTypeArguments) : "") : "";
45240         }
45241         function getPropagatingFlagsOfTypes(types, excludeKinds) {
45242             var result = 0;
45243             for (var _i = 0, types_9 = types; _i < types_9.length; _i++) {
45244                 var type = types_9[_i];
45245                 if (!(type.flags & excludeKinds)) {
45246                     result |= ts.getObjectFlags(type);
45247                 }
45248             }
45249             return result & 3670016;
45250         }
45251         function createTypeReference(target, typeArguments) {
45252             var id = getTypeListId(typeArguments);
45253             var type = target.instantiations.get(id);
45254             if (!type) {
45255                 type = createObjectType(4, target.symbol);
45256                 target.instantiations.set(id, type);
45257                 type.objectFlags |= typeArguments ? getPropagatingFlagsOfTypes(typeArguments, 0) : 0;
45258                 type.target = target;
45259                 type.resolvedTypeArguments = typeArguments;
45260             }
45261             return type;
45262         }
45263         function cloneTypeReference(source) {
45264             var type = createType(source.flags);
45265             type.symbol = source.symbol;
45266             type.objectFlags = source.objectFlags;
45267             type.target = source.target;
45268             type.resolvedTypeArguments = source.resolvedTypeArguments;
45269             return type;
45270         }
45271         function createDeferredTypeReference(target, node, mapper, aliasSymbol, aliasTypeArguments) {
45272             if (!aliasSymbol) {
45273                 aliasSymbol = getAliasSymbolForTypeNode(node);
45274                 var localAliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
45275                 aliasTypeArguments = mapper ? instantiateTypes(localAliasTypeArguments, mapper) : localAliasTypeArguments;
45276             }
45277             var type = createObjectType(4, target.symbol);
45278             type.target = target;
45279             type.node = node;
45280             type.mapper = mapper;
45281             type.aliasSymbol = aliasSymbol;
45282             type.aliasTypeArguments = aliasTypeArguments;
45283             return type;
45284         }
45285         function getTypeArguments(type) {
45286             var _a, _b;
45287             if (!type.resolvedTypeArguments) {
45288                 if (!pushTypeResolution(type, 6)) {
45289                     return ((_a = type.target.localTypeParameters) === null || _a === void 0 ? void 0 : _a.map(function () { return errorType; })) || ts.emptyArray;
45290                 }
45291                 var node = type.node;
45292                 var typeArguments = !node ? ts.emptyArray :
45293                     node.kind === 173 ? ts.concatenate(type.target.outerTypeParameters, getEffectiveTypeArguments(node, type.target.localTypeParameters)) :
45294                         node.kind === 178 ? [getTypeFromTypeNode(node.elementType)] :
45295                             ts.map(node.elements, getTypeFromTypeNode);
45296                 if (popTypeResolution()) {
45297                     type.resolvedTypeArguments = type.mapper ? instantiateTypes(typeArguments, type.mapper) : typeArguments;
45298                 }
45299                 else {
45300                     type.resolvedTypeArguments = ((_b = type.target.localTypeParameters) === null || _b === void 0 ? void 0 : _b.map(function () { return errorType; })) || ts.emptyArray;
45301                     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));
45302                 }
45303             }
45304             return type.resolvedTypeArguments;
45305         }
45306         function getTypeReferenceArity(type) {
45307             return ts.length(type.target.typeParameters);
45308         }
45309         function getTypeFromClassOrInterfaceReference(node, symbol) {
45310             var type = getDeclaredTypeOfSymbol(getMergedSymbol(symbol));
45311             var typeParameters = type.localTypeParameters;
45312             if (typeParameters) {
45313                 var numTypeArguments = ts.length(node.typeArguments);
45314                 var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters);
45315                 var isJs = ts.isInJSFile(node);
45316                 var isJsImplicitAny = !noImplicitAny && isJs;
45317                 if (!isJsImplicitAny && (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length)) {
45318                     var missingAugmentsTag = isJs && ts.isExpressionWithTypeArguments(node) && !ts.isJSDocAugmentsTag(node.parent);
45319                     var diag = minTypeArgumentCount === typeParameters.length ?
45320                         missingAugmentsTag ?
45321                             ts.Diagnostics.Expected_0_type_arguments_provide_these_with_an_extends_tag :
45322                             ts.Diagnostics.Generic_type_0_requires_1_type_argument_s :
45323                         missingAugmentsTag ?
45324                             ts.Diagnostics.Expected_0_1_type_arguments_provide_these_with_an_extends_tag :
45325                             ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments;
45326                     var typeStr = typeToString(type, undefined, 2);
45327                     error(node, diag, typeStr, minTypeArgumentCount, typeParameters.length);
45328                     if (!isJs) {
45329                         return errorType;
45330                     }
45331                 }
45332                 if (node.kind === 173 && isDeferredTypeReferenceNode(node, ts.length(node.typeArguments) !== typeParameters.length)) {
45333                     return createDeferredTypeReference(type, node, undefined);
45334                 }
45335                 var typeArguments = ts.concatenate(type.outerTypeParameters, fillMissingTypeArguments(typeArgumentsFromTypeReferenceNode(node), typeParameters, minTypeArgumentCount, isJs));
45336                 return createTypeReference(type, typeArguments);
45337             }
45338             return checkNoTypeArguments(node, symbol) ? type : errorType;
45339         }
45340         function getTypeAliasInstantiation(symbol, typeArguments, aliasSymbol, aliasTypeArguments) {
45341             var type = getDeclaredTypeOfSymbol(symbol);
45342             if (type === intrinsicMarkerType && intrinsicTypeKinds.has(symbol.escapedName) && typeArguments && typeArguments.length === 1) {
45343                 return getStringMappingType(symbol, typeArguments[0]);
45344             }
45345             var links = getSymbolLinks(symbol);
45346             var typeParameters = links.typeParameters;
45347             var id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
45348             var instantiation = links.instantiations.get(id);
45349             if (!instantiation) {
45350                 links.instantiations.set(id, instantiation = instantiateTypeWithAlias(type, createTypeMapper(typeParameters, fillMissingTypeArguments(typeArguments, typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(symbol.valueDeclaration))), aliasSymbol, aliasTypeArguments));
45351             }
45352             return instantiation;
45353         }
45354         function getTypeFromTypeAliasReference(node, symbol) {
45355             var type = getDeclaredTypeOfSymbol(symbol);
45356             var typeParameters = getSymbolLinks(symbol).typeParameters;
45357             if (typeParameters) {
45358                 var numTypeArguments = ts.length(node.typeArguments);
45359                 var minTypeArgumentCount = getMinTypeArgumentCount(typeParameters);
45360                 if (numTypeArguments < minTypeArgumentCount || numTypeArguments > typeParameters.length) {
45361                     error(node, minTypeArgumentCount === typeParameters.length ?
45362                         ts.Diagnostics.Generic_type_0_requires_1_type_argument_s :
45363                         ts.Diagnostics.Generic_type_0_requires_between_1_and_2_type_arguments, symbolToString(symbol), minTypeArgumentCount, typeParameters.length);
45364                     return errorType;
45365                 }
45366                 var aliasSymbol = getAliasSymbolForTypeNode(node);
45367                 return getTypeAliasInstantiation(symbol, typeArgumentsFromTypeReferenceNode(node), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
45368             }
45369             return checkNoTypeArguments(node, symbol) ? type : errorType;
45370         }
45371         function getTypeReferenceName(node) {
45372             switch (node.kind) {
45373                 case 173:
45374                     return node.typeName;
45375                 case 223:
45376                     var expr = node.expression;
45377                     if (ts.isEntityNameExpression(expr)) {
45378                         return expr;
45379                     }
45380             }
45381             return undefined;
45382         }
45383         function resolveTypeReferenceName(typeReferenceName, meaning, ignoreErrors) {
45384             if (!typeReferenceName) {
45385                 return unknownSymbol;
45386             }
45387             return resolveEntityName(typeReferenceName, meaning, ignoreErrors) || unknownSymbol;
45388         }
45389         function getTypeReferenceType(node, symbol) {
45390             if (symbol === unknownSymbol) {
45391                 return errorType;
45392             }
45393             symbol = getExpandoSymbol(symbol) || symbol;
45394             if (symbol.flags & (32 | 64)) {
45395                 return getTypeFromClassOrInterfaceReference(node, symbol);
45396             }
45397             if (symbol.flags & 524288) {
45398                 return getTypeFromTypeAliasReference(node, symbol);
45399             }
45400             var res = tryGetDeclaredTypeOfSymbol(symbol);
45401             if (res) {
45402                 return checkNoTypeArguments(node, symbol) ? getRegularTypeOfLiteralType(res) : errorType;
45403             }
45404             if (symbol.flags & 111551 && isJSDocTypeReference(node)) {
45405                 var jsdocType = getTypeFromJSDocValueReference(node, symbol);
45406                 if (jsdocType) {
45407                     return jsdocType;
45408                 }
45409                 else {
45410                     resolveTypeReferenceName(getTypeReferenceName(node), 788968);
45411                     return getTypeOfSymbol(symbol);
45412                 }
45413             }
45414             return errorType;
45415         }
45416         function getTypeFromJSDocValueReference(node, symbol) {
45417             var links = getNodeLinks(node);
45418             if (!links.resolvedJSDocType) {
45419                 var valueType = getTypeOfSymbol(symbol);
45420                 var typeType = valueType;
45421                 if (symbol.valueDeclaration) {
45422                     var isImportTypeWithQualifier = node.kind === 195 && node.qualifier;
45423                     if (valueType.symbol && valueType.symbol !== symbol && isImportTypeWithQualifier) {
45424                         typeType = getTypeReferenceType(node, valueType.symbol);
45425                     }
45426                 }
45427                 links.resolvedJSDocType = typeType;
45428             }
45429             return links.resolvedJSDocType;
45430         }
45431         function getSubstitutionType(baseType, substitute) {
45432             if (substitute.flags & 3 || substitute === baseType) {
45433                 return baseType;
45434             }
45435             var id = getTypeId(baseType) + ">" + getTypeId(substitute);
45436             var cached = substitutionTypes.get(id);
45437             if (cached) {
45438                 return cached;
45439             }
45440             var result = createType(33554432);
45441             result.baseType = baseType;
45442             result.substitute = substitute;
45443             substitutionTypes.set(id, result);
45444             return result;
45445         }
45446         function isUnaryTupleTypeNode(node) {
45447             return node.kind === 179 && node.elements.length === 1;
45448         }
45449         function getImpliedConstraint(type, checkNode, extendsNode) {
45450             return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) :
45451                 getActualTypeVariable(getTypeFromTypeNode(checkNode)) === type ? getTypeFromTypeNode(extendsNode) :
45452                     undefined;
45453         }
45454         function getConditionalFlowTypeOfType(type, node) {
45455             var constraints;
45456             while (node && !ts.isStatement(node) && node.kind !== 311) {
45457                 var parent = node.parent;
45458                 if (parent.kind === 184 && node === parent.trueType) {
45459                     var constraint = getImpliedConstraint(type, parent.checkType, parent.extendsType);
45460                     if (constraint) {
45461                         constraints = ts.append(constraints, constraint);
45462                     }
45463                 }
45464                 node = parent;
45465             }
45466             return constraints ? getSubstitutionType(type, getIntersectionType(ts.append(constraints, type))) : type;
45467         }
45468         function isJSDocTypeReference(node) {
45469             return !!(node.flags & 4194304) && (node.kind === 173 || node.kind === 195);
45470         }
45471         function checkNoTypeArguments(node, symbol) {
45472             if (node.typeArguments) {
45473                 error(node, ts.Diagnostics.Type_0_is_not_generic, symbol ? symbolToString(symbol) : node.typeName ? ts.declarationNameToString(node.typeName) : anon);
45474                 return false;
45475             }
45476             return true;
45477         }
45478         function getIntendedTypeFromJSDocTypeReference(node) {
45479             if (ts.isIdentifier(node.typeName)) {
45480                 var typeArgs = node.typeArguments;
45481                 switch (node.typeName.escapedText) {
45482                     case "String":
45483                         checkNoTypeArguments(node);
45484                         return stringType;
45485                     case "Number":
45486                         checkNoTypeArguments(node);
45487                         return numberType;
45488                     case "Boolean":
45489                         checkNoTypeArguments(node);
45490                         return booleanType;
45491                     case "Void":
45492                         checkNoTypeArguments(node);
45493                         return voidType;
45494                     case "Undefined":
45495                         checkNoTypeArguments(node);
45496                         return undefinedType;
45497                     case "Null":
45498                         checkNoTypeArguments(node);
45499                         return nullType;
45500                     case "Function":
45501                     case "function":
45502                         checkNoTypeArguments(node);
45503                         return globalFunctionType;
45504                     case "array":
45505                         return (!typeArgs || !typeArgs.length) && !noImplicitAny ? anyArrayType : undefined;
45506                     case "promise":
45507                         return (!typeArgs || !typeArgs.length) && !noImplicitAny ? createPromiseType(anyType) : undefined;
45508                     case "Object":
45509                         if (typeArgs && typeArgs.length === 2) {
45510                             if (ts.isJSDocIndexSignature(node)) {
45511                                 var indexed = getTypeFromTypeNode(typeArgs[0]);
45512                                 var target = getTypeFromTypeNode(typeArgs[1]);
45513                                 var index = createIndexInfo(target, false);
45514                                 return createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, indexed === stringType ? index : undefined, indexed === numberType ? index : undefined);
45515                             }
45516                             return anyType;
45517                         }
45518                         checkNoTypeArguments(node);
45519                         return !noImplicitAny ? anyType : undefined;
45520                 }
45521             }
45522         }
45523         function getTypeFromJSDocNullableTypeNode(node) {
45524             var type = getTypeFromTypeNode(node.type);
45525             return strictNullChecks ? getNullableType(type, 65536) : type;
45526         }
45527         function getTypeFromTypeReference(node) {
45528             var links = getNodeLinks(node);
45529             if (!links.resolvedType) {
45530                 if (ts.isConstTypeReference(node) && ts.isAssertionExpression(node.parent)) {
45531                     links.resolvedSymbol = unknownSymbol;
45532                     return links.resolvedType = checkExpressionCached(node.parent.expression);
45533                 }
45534                 var symbol = void 0;
45535                 var type = void 0;
45536                 var meaning = 788968;
45537                 if (isJSDocTypeReference(node)) {
45538                     type = getIntendedTypeFromJSDocTypeReference(node);
45539                     if (!type) {
45540                         symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning, true);
45541                         if (symbol === unknownSymbol) {
45542                             symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning | 111551);
45543                         }
45544                         else {
45545                             resolveTypeReferenceName(getTypeReferenceName(node), meaning);
45546                         }
45547                         type = getTypeReferenceType(node, symbol);
45548                     }
45549                 }
45550                 if (!type) {
45551                     symbol = resolveTypeReferenceName(getTypeReferenceName(node), meaning);
45552                     type = getTypeReferenceType(node, symbol);
45553                 }
45554                 links.resolvedSymbol = symbol;
45555                 links.resolvedType = type;
45556             }
45557             return links.resolvedType;
45558         }
45559         function typeArgumentsFromTypeReferenceNode(node) {
45560             return ts.map(node.typeArguments, getTypeFromTypeNode);
45561         }
45562         function getTypeFromTypeQueryNode(node) {
45563             var links = getNodeLinks(node);
45564             if (!links.resolvedType) {
45565                 links.resolvedType = getRegularTypeOfLiteralType(getWidenedType(checkExpression(node.exprName)));
45566             }
45567             return links.resolvedType;
45568         }
45569         function getTypeOfGlobalSymbol(symbol, arity) {
45570             function getTypeDeclaration(symbol) {
45571                 var declarations = symbol.declarations;
45572                 for (var _i = 0, declarations_3 = declarations; _i < declarations_3.length; _i++) {
45573                     var declaration = declarations_3[_i];
45574                     switch (declaration.kind) {
45575                         case 252:
45576                         case 253:
45577                         case 255:
45578                             return declaration;
45579                     }
45580                 }
45581             }
45582             if (!symbol) {
45583                 return arity ? emptyGenericType : emptyObjectType;
45584             }
45585             var type = getDeclaredTypeOfSymbol(symbol);
45586             if (!(type.flags & 524288)) {
45587                 error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, ts.symbolName(symbol));
45588                 return arity ? emptyGenericType : emptyObjectType;
45589             }
45590             if (ts.length(type.typeParameters) !== arity) {
45591                 error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, ts.symbolName(symbol), arity);
45592                 return arity ? emptyGenericType : emptyObjectType;
45593             }
45594             return type;
45595         }
45596         function getGlobalValueSymbol(name, reportErrors) {
45597             return getGlobalSymbol(name, 111551, reportErrors ? ts.Diagnostics.Cannot_find_global_value_0 : undefined);
45598         }
45599         function getGlobalTypeSymbol(name, reportErrors) {
45600             return getGlobalSymbol(name, 788968, reportErrors ? ts.Diagnostics.Cannot_find_global_type_0 : undefined);
45601         }
45602         function getGlobalSymbol(name, meaning, diagnostic) {
45603             return resolveName(undefined, name, meaning, diagnostic, name, false);
45604         }
45605         function getGlobalType(name, arity, reportErrors) {
45606             var symbol = getGlobalTypeSymbol(name, reportErrors);
45607             return symbol || reportErrors ? getTypeOfGlobalSymbol(symbol, arity) : undefined;
45608         }
45609         function getGlobalTypedPropertyDescriptorType() {
45610             return deferredGlobalTypedPropertyDescriptorType || (deferredGlobalTypedPropertyDescriptorType = getGlobalType("TypedPropertyDescriptor", 1, true)) || emptyGenericType;
45611         }
45612         function getGlobalTemplateStringsArrayType() {
45613             return deferredGlobalTemplateStringsArrayType || (deferredGlobalTemplateStringsArrayType = getGlobalType("TemplateStringsArray", 0, true)) || emptyObjectType;
45614         }
45615         function getGlobalImportMetaType() {
45616             return deferredGlobalImportMetaType || (deferredGlobalImportMetaType = getGlobalType("ImportMeta", 0, true)) || emptyObjectType;
45617         }
45618         function getGlobalESSymbolConstructorSymbol(reportErrors) {
45619             return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors));
45620         }
45621         function getGlobalESSymbolType(reportErrors) {
45622             return deferredGlobalESSymbolType || (deferredGlobalESSymbolType = getGlobalType("Symbol", 0, reportErrors)) || emptyObjectType;
45623         }
45624         function getGlobalPromiseType(reportErrors) {
45625             return deferredGlobalPromiseType || (deferredGlobalPromiseType = getGlobalType("Promise", 1, reportErrors)) || emptyGenericType;
45626         }
45627         function getGlobalPromiseLikeType(reportErrors) {
45628             return deferredGlobalPromiseLikeType || (deferredGlobalPromiseLikeType = getGlobalType("PromiseLike", 1, reportErrors)) || emptyGenericType;
45629         }
45630         function getGlobalPromiseConstructorSymbol(reportErrors) {
45631             return deferredGlobalPromiseConstructorSymbol || (deferredGlobalPromiseConstructorSymbol = getGlobalValueSymbol("Promise", reportErrors));
45632         }
45633         function getGlobalPromiseConstructorLikeType(reportErrors) {
45634             return deferredGlobalPromiseConstructorLikeType || (deferredGlobalPromiseConstructorLikeType = getGlobalType("PromiseConstructorLike", 0, reportErrors)) || emptyObjectType;
45635         }
45636         function getGlobalAsyncIterableType(reportErrors) {
45637             return deferredGlobalAsyncIterableType || (deferredGlobalAsyncIterableType = getGlobalType("AsyncIterable", 1, reportErrors)) || emptyGenericType;
45638         }
45639         function getGlobalAsyncIteratorType(reportErrors) {
45640             return deferredGlobalAsyncIteratorType || (deferredGlobalAsyncIteratorType = getGlobalType("AsyncIterator", 3, reportErrors)) || emptyGenericType;
45641         }
45642         function getGlobalAsyncIterableIteratorType(reportErrors) {
45643             return deferredGlobalAsyncIterableIteratorType || (deferredGlobalAsyncIterableIteratorType = getGlobalType("AsyncIterableIterator", 1, reportErrors)) || emptyGenericType;
45644         }
45645         function getGlobalAsyncGeneratorType(reportErrors) {
45646             return deferredGlobalAsyncGeneratorType || (deferredGlobalAsyncGeneratorType = getGlobalType("AsyncGenerator", 3, reportErrors)) || emptyGenericType;
45647         }
45648         function getGlobalIterableType(reportErrors) {
45649             return deferredGlobalIterableType || (deferredGlobalIterableType = getGlobalType("Iterable", 1, reportErrors)) || emptyGenericType;
45650         }
45651         function getGlobalIteratorType(reportErrors) {
45652             return deferredGlobalIteratorType || (deferredGlobalIteratorType = getGlobalType("Iterator", 3, reportErrors)) || emptyGenericType;
45653         }
45654         function getGlobalIterableIteratorType(reportErrors) {
45655             return deferredGlobalIterableIteratorType || (deferredGlobalIterableIteratorType = getGlobalType("IterableIterator", 1, reportErrors)) || emptyGenericType;
45656         }
45657         function getGlobalGeneratorType(reportErrors) {
45658             return deferredGlobalGeneratorType || (deferredGlobalGeneratorType = getGlobalType("Generator", 3, reportErrors)) || emptyGenericType;
45659         }
45660         function getGlobalIteratorYieldResultType(reportErrors) {
45661             return deferredGlobalIteratorYieldResultType || (deferredGlobalIteratorYieldResultType = getGlobalType("IteratorYieldResult", 1, reportErrors)) || emptyGenericType;
45662         }
45663         function getGlobalIteratorReturnResultType(reportErrors) {
45664             return deferredGlobalIteratorReturnResultType || (deferredGlobalIteratorReturnResultType = getGlobalType("IteratorReturnResult", 1, reportErrors)) || emptyGenericType;
45665         }
45666         function getGlobalTypeOrUndefined(name, arity) {
45667             if (arity === void 0) { arity = 0; }
45668             var symbol = getGlobalSymbol(name, 788968, undefined);
45669             return symbol && getTypeOfGlobalSymbol(symbol, arity);
45670         }
45671         function getGlobalExtractSymbol() {
45672             return deferredGlobalExtractSymbol || (deferredGlobalExtractSymbol = getGlobalSymbol("Extract", 524288, ts.Diagnostics.Cannot_find_global_type_0));
45673         }
45674         function getGlobalOmitSymbol() {
45675             return deferredGlobalOmitSymbol || (deferredGlobalOmitSymbol = getGlobalSymbol("Omit", 524288, ts.Diagnostics.Cannot_find_global_type_0));
45676         }
45677         function getGlobalBigIntType(reportErrors) {
45678             return deferredGlobalBigIntType || (deferredGlobalBigIntType = getGlobalType("BigInt", 0, reportErrors)) || emptyObjectType;
45679         }
45680         function createTypeFromGenericGlobalType(genericGlobalType, typeArguments) {
45681             return genericGlobalType !== emptyGenericType ? createTypeReference(genericGlobalType, typeArguments) : emptyObjectType;
45682         }
45683         function createTypedPropertyDescriptorType(propertyType) {
45684             return createTypeFromGenericGlobalType(getGlobalTypedPropertyDescriptorType(), [propertyType]);
45685         }
45686         function createIterableType(iteratedType) {
45687             return createTypeFromGenericGlobalType(getGlobalIterableType(true), [iteratedType]);
45688         }
45689         function createArrayType(elementType, readonly) {
45690             return createTypeFromGenericGlobalType(readonly ? globalReadonlyArrayType : globalArrayType, [elementType]);
45691         }
45692         function getTupleElementFlags(node) {
45693             switch (node.kind) {
45694                 case 180:
45695                     return 2;
45696                 case 181:
45697                     return getRestTypeElementFlags(node);
45698                 case 192:
45699                     return node.questionToken ? 2 :
45700                         node.dotDotDotToken ? getRestTypeElementFlags(node) :
45701                             1;
45702                 default:
45703                     return 1;
45704             }
45705         }
45706         function getRestTypeElementFlags(node) {
45707             return getArrayElementTypeNode(node.type) ? 4 : 8;
45708         }
45709         function getArrayOrTupleTargetType(node) {
45710             var readonly = isReadonlyTypeOperator(node.parent);
45711             var elementType = getArrayElementTypeNode(node);
45712             if (elementType) {
45713                 return readonly ? globalReadonlyArrayType : globalArrayType;
45714             }
45715             var elementFlags = ts.map(node.elements, getTupleElementFlags);
45716             var missingName = ts.some(node.elements, function (e) { return e.kind !== 192; });
45717             return getTupleTargetType(elementFlags, readonly, missingName ? undefined : node.elements);
45718         }
45719         function isDeferredTypeReferenceNode(node, hasDefaultTypeArguments) {
45720             return !!getAliasSymbolForTypeNode(node) || isResolvedByTypeAlias(node) && (node.kind === 178 ? mayResolveTypeAlias(node.elementType) :
45721                 node.kind === 179 ? ts.some(node.elements, mayResolveTypeAlias) :
45722                     hasDefaultTypeArguments || ts.some(node.typeArguments, mayResolveTypeAlias));
45723         }
45724         function isResolvedByTypeAlias(node) {
45725             var parent = node.parent;
45726             switch (parent.kind) {
45727                 case 186:
45728                 case 192:
45729                 case 173:
45730                 case 182:
45731                 case 183:
45732                 case 189:
45733                 case 184:
45734                 case 188:
45735                 case 178:
45736                 case 179:
45737                     return isResolvedByTypeAlias(parent);
45738                 case 254:
45739                     return true;
45740             }
45741             return false;
45742         }
45743         function mayResolveTypeAlias(node) {
45744             switch (node.kind) {
45745                 case 173:
45746                     return isJSDocTypeReference(node) || !!(resolveTypeReferenceName(node.typeName, 788968).flags & 524288);
45747                 case 176:
45748                     return true;
45749                 case 188:
45750                     return node.operator !== 151 && mayResolveTypeAlias(node.type);
45751                 case 186:
45752                 case 180:
45753                 case 192:
45754                 case 307:
45755                 case 305:
45756                 case 306:
45757                 case 301:
45758                     return mayResolveTypeAlias(node.type);
45759                 case 181:
45760                     return node.type.kind !== 178 || mayResolveTypeAlias(node.type.elementType);
45761                 case 182:
45762                 case 183:
45763                     return ts.some(node.types, mayResolveTypeAlias);
45764                 case 189:
45765                     return mayResolveTypeAlias(node.objectType) || mayResolveTypeAlias(node.indexType);
45766                 case 184:
45767                     return mayResolveTypeAlias(node.checkType) || mayResolveTypeAlias(node.extendsType) ||
45768                         mayResolveTypeAlias(node.trueType) || mayResolveTypeAlias(node.falseType);
45769             }
45770             return false;
45771         }
45772         function getTypeFromArrayOrTupleTypeNode(node) {
45773             var links = getNodeLinks(node);
45774             if (!links.resolvedType) {
45775                 var target = getArrayOrTupleTargetType(node);
45776                 if (target === emptyGenericType) {
45777                     links.resolvedType = emptyObjectType;
45778                 }
45779                 else if (!(node.kind === 179 && ts.some(node.elements, function (e) { return !!(getTupleElementFlags(e) & 8); })) && isDeferredTypeReferenceNode(node)) {
45780                     links.resolvedType = node.kind === 179 && node.elements.length === 0 ? target :
45781                         createDeferredTypeReference(target, node, undefined);
45782                 }
45783                 else {
45784                     var elementTypes = node.kind === 178 ? [getTypeFromTypeNode(node.elementType)] : ts.map(node.elements, getTypeFromTypeNode);
45785                     links.resolvedType = createNormalizedTypeReference(target, elementTypes);
45786                 }
45787             }
45788             return links.resolvedType;
45789         }
45790         function isReadonlyTypeOperator(node) {
45791             return ts.isTypeOperatorNode(node) && node.operator === 142;
45792         }
45793         function createTupleType(elementTypes, elementFlags, readonly, namedMemberDeclarations) {
45794             if (readonly === void 0) { readonly = false; }
45795             var tupleTarget = getTupleTargetType(elementFlags || ts.map(elementTypes, function (_) { return 1; }), readonly, namedMemberDeclarations);
45796             return tupleTarget === emptyGenericType ? emptyObjectType :
45797                 elementTypes.length ? createNormalizedTypeReference(tupleTarget, elementTypes) :
45798                     tupleTarget;
45799         }
45800         function getTupleTargetType(elementFlags, readonly, namedMemberDeclarations) {
45801             if (elementFlags.length === 1 && elementFlags[0] & 4) {
45802                 return readonly ? globalReadonlyArrayType : globalArrayType;
45803             }
45804             var key = ts.map(elementFlags, function (f) { return f & 1 ? "#" : f & 2 ? "?" : f & 4 ? "." : "*"; }).join() +
45805                 (readonly ? "R" : "") +
45806                 (namedMemberDeclarations && namedMemberDeclarations.length ? "," + ts.map(namedMemberDeclarations, getNodeId).join(",") : "");
45807             var type = tupleTypes.get(key);
45808             if (!type) {
45809                 tupleTypes.set(key, type = createTupleTargetType(elementFlags, readonly, namedMemberDeclarations));
45810             }
45811             return type;
45812         }
45813         function createTupleTargetType(elementFlags, readonly, namedMemberDeclarations) {
45814             var arity = elementFlags.length;
45815             var minLength = ts.countWhere(elementFlags, function (f) { return !!(f & (1 | 8)); });
45816             var typeParameters;
45817             var properties = [];
45818             var combinedFlags = 0;
45819             if (arity) {
45820                 typeParameters = new Array(arity);
45821                 for (var i = 0; i < arity; i++) {
45822                     var typeParameter = typeParameters[i] = createTypeParameter();
45823                     var flags = elementFlags[i];
45824                     combinedFlags |= flags;
45825                     if (!(combinedFlags & 12)) {
45826                         var property = createSymbol(4 | (flags & 2 ? 16777216 : 0), "" + i, readonly ? 8 : 0);
45827                         property.tupleLabelDeclaration = namedMemberDeclarations === null || namedMemberDeclarations === void 0 ? void 0 : namedMemberDeclarations[i];
45828                         property.type = typeParameter;
45829                         properties.push(property);
45830                     }
45831                 }
45832             }
45833             var fixedLength = properties.length;
45834             var lengthSymbol = createSymbol(4, "length");
45835             if (combinedFlags & 12) {
45836                 lengthSymbol.type = numberType;
45837             }
45838             else {
45839                 var literalTypes_1 = [];
45840                 for (var i = minLength; i <= arity; i++)
45841                     literalTypes_1.push(getLiteralType(i));
45842                 lengthSymbol.type = getUnionType(literalTypes_1);
45843             }
45844             properties.push(lengthSymbol);
45845             var type = createObjectType(8 | 4);
45846             type.typeParameters = typeParameters;
45847             type.outerTypeParameters = undefined;
45848             type.localTypeParameters = typeParameters;
45849             type.instantiations = new ts.Map();
45850             type.instantiations.set(getTypeListId(type.typeParameters), type);
45851             type.target = type;
45852             type.resolvedTypeArguments = type.typeParameters;
45853             type.thisType = createTypeParameter();
45854             type.thisType.isThisType = true;
45855             type.thisType.constraint = type;
45856             type.declaredProperties = properties;
45857             type.declaredCallSignatures = ts.emptyArray;
45858             type.declaredConstructSignatures = ts.emptyArray;
45859             type.declaredStringIndexInfo = undefined;
45860             type.declaredNumberIndexInfo = undefined;
45861             type.elementFlags = elementFlags;
45862             type.minLength = minLength;
45863             type.fixedLength = fixedLength;
45864             type.hasRestElement = !!(combinedFlags & 12);
45865             type.combinedFlags = combinedFlags;
45866             type.readonly = readonly;
45867             type.labeledElementDeclarations = namedMemberDeclarations;
45868             return type;
45869         }
45870         function createNormalizedTypeReference(target, typeArguments) {
45871             return target.objectFlags & 8 ? createNormalizedTupleType(target, typeArguments) : createTypeReference(target, typeArguments);
45872         }
45873         function createNormalizedTupleType(target, elementTypes) {
45874             var _a, _b, _c;
45875             if (!(target.combinedFlags & 14)) {
45876                 return createTypeReference(target, elementTypes);
45877             }
45878             if (target.combinedFlags & 8) {
45879                 var unionIndex_1 = ts.findIndex(elementTypes, function (t, i) { return !!(target.elementFlags[i] & 8 && t.flags & (131072 | 1048576)); });
45880                 if (unionIndex_1 >= 0) {
45881                     return checkCrossProductUnion(ts.map(elementTypes, function (t, i) { return target.elementFlags[i] & 8 ? t : unknownType; })) ?
45882                         mapType(elementTypes[unionIndex_1], function (t) { return createNormalizedTupleType(target, ts.replaceElement(elementTypes, unionIndex_1, t)); }) :
45883                         errorType;
45884                 }
45885             }
45886             var expandedTypes = [];
45887             var expandedFlags = [];
45888             var expandedDeclarations = [];
45889             var lastRequiredIndex = -1;
45890             var firstRestIndex = -1;
45891             var lastOptionalOrRestIndex = -1;
45892             var _loop_13 = function (i) {
45893                 var type = elementTypes[i];
45894                 var flags = target.elementFlags[i];
45895                 if (flags & 8) {
45896                     if (type.flags & 58982400 || isGenericMappedType(type)) {
45897                         addElement(type, 8, (_a = target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]);
45898                     }
45899                     else if (isTupleType(type)) {
45900                         var elements = getTypeArguments(type);
45901                         if (elements.length + expandedTypes.length >= 10000) {
45902                             error(currentNode, ts.isPartOfTypeNode(currentNode)
45903                                 ? ts.Diagnostics.Type_produces_a_tuple_type_that_is_too_large_to_represent
45904                                 : ts.Diagnostics.Expression_produces_a_tuple_type_that_is_too_large_to_represent);
45905                             return { value: errorType };
45906                         }
45907                         ts.forEach(elements, function (t, n) { var _a; return addElement(t, type.target.elementFlags[n], (_a = type.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[n]); });
45908                     }
45909                     else {
45910                         addElement(isArrayLikeType(type) && getIndexTypeOfType(type, 1) || errorType, 4, (_b = target.labeledElementDeclarations) === null || _b === void 0 ? void 0 : _b[i]);
45911                     }
45912                 }
45913                 else {
45914                     addElement(type, flags, (_c = target.labeledElementDeclarations) === null || _c === void 0 ? void 0 : _c[i]);
45915                 }
45916             };
45917             for (var i = 0; i < elementTypes.length; i++) {
45918                 var state_4 = _loop_13(i);
45919                 if (typeof state_4 === "object")
45920                     return state_4.value;
45921             }
45922             for (var i = 0; i < lastRequiredIndex; i++) {
45923                 if (expandedFlags[i] & 2)
45924                     expandedFlags[i] = 1;
45925             }
45926             if (firstRestIndex >= 0 && firstRestIndex < lastOptionalOrRestIndex) {
45927                 expandedTypes[firstRestIndex] = getUnionType(ts.sameMap(expandedTypes.slice(firstRestIndex, lastOptionalOrRestIndex + 1), function (t, i) { return expandedFlags[firstRestIndex + i] & 8 ? getIndexedAccessType(t, numberType) : t; }));
45928                 expandedTypes.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
45929                 expandedFlags.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
45930                 expandedDeclarations === null || expandedDeclarations === void 0 ? void 0 : expandedDeclarations.splice(firstRestIndex + 1, lastOptionalOrRestIndex - firstRestIndex);
45931             }
45932             var tupleTarget = getTupleTargetType(expandedFlags, target.readonly, expandedDeclarations);
45933             return tupleTarget === emptyGenericType ? emptyObjectType :
45934                 expandedFlags.length ? createTypeReference(tupleTarget, expandedTypes) :
45935                     tupleTarget;
45936             function addElement(type, flags, declaration) {
45937                 if (flags & 1) {
45938                     lastRequiredIndex = expandedFlags.length;
45939                 }
45940                 if (flags & 4 && firstRestIndex < 0) {
45941                     firstRestIndex = expandedFlags.length;
45942                 }
45943                 if (flags & (2 | 4)) {
45944                     lastOptionalOrRestIndex = expandedFlags.length;
45945                 }
45946                 expandedTypes.push(type);
45947                 expandedFlags.push(flags);
45948                 if (expandedDeclarations && declaration) {
45949                     expandedDeclarations.push(declaration);
45950                 }
45951                 else {
45952                     expandedDeclarations = undefined;
45953                 }
45954             }
45955         }
45956         function sliceTupleType(type, index, endSkipCount) {
45957             if (endSkipCount === void 0) { endSkipCount = 0; }
45958             var target = type.target;
45959             var endIndex = getTypeReferenceArity(type) - endSkipCount;
45960             return index > target.fixedLength ? getRestArrayTypeOfTupleType(type) || createTupleType(ts.emptyArray) :
45961                 createTupleType(getTypeArguments(type).slice(index, endIndex), target.elementFlags.slice(index, endIndex), false, target.labeledElementDeclarations && target.labeledElementDeclarations.slice(index, endIndex));
45962         }
45963         function getKnownKeysOfTupleType(type) {
45964             return getUnionType(ts.append(ts.arrayOf(type.target.fixedLength, function (i) { return getLiteralType("" + i); }), getIndexType(type.target.readonly ? globalReadonlyArrayType : globalArrayType)));
45965         }
45966         function getStartElementCount(type, flags) {
45967             var index = ts.findIndex(type.elementFlags, function (f) { return !(f & flags); });
45968             return index >= 0 ? index : type.elementFlags.length;
45969         }
45970         function getEndElementCount(type, flags) {
45971             return type.elementFlags.length - ts.findLastIndex(type.elementFlags, function (f) { return !(f & flags); }) - 1;
45972         }
45973         function getTypeFromOptionalTypeNode(node) {
45974             var type = getTypeFromTypeNode(node.type);
45975             return strictNullChecks ? getOptionalType(type) : type;
45976         }
45977         function getTypeId(type) {
45978             return type.id;
45979         }
45980         function containsType(types, type) {
45981             return ts.binarySearch(types, type, getTypeId, ts.compareValues) >= 0;
45982         }
45983         function insertType(types, type) {
45984             var index = ts.binarySearch(types, type, getTypeId, ts.compareValues);
45985             if (index < 0) {
45986                 types.splice(~index, 0, type);
45987                 return true;
45988             }
45989             return false;
45990         }
45991         function addTypeToUnion(typeSet, includes, type) {
45992             var flags = type.flags;
45993             if (flags & 1048576) {
45994                 return addTypesToUnion(typeSet, includes | (isNamedUnionType(type) ? 1048576 : 0), type.types);
45995             }
45996             if (!(flags & 131072)) {
45997                 includes |= flags & 205258751;
45998                 if (flags & 469499904)
45999                     includes |= 262144;
46000                 if (type === wildcardType)
46001                     includes |= 8388608;
46002                 if (!strictNullChecks && flags & 98304) {
46003                     if (!(ts.getObjectFlags(type) & 524288))
46004                         includes |= 4194304;
46005                 }
46006                 else {
46007                     var len = typeSet.length;
46008                     var index = len && type.id > typeSet[len - 1].id ? ~len : ts.binarySearch(typeSet, type, getTypeId, ts.compareValues);
46009                     if (index < 0) {
46010                         typeSet.splice(~index, 0, type);
46011                     }
46012                 }
46013             }
46014             return includes;
46015         }
46016         function addTypesToUnion(typeSet, includes, types) {
46017             for (var _i = 0, types_10 = types; _i < types_10.length; _i++) {
46018                 var type = types_10[_i];
46019                 includes = addTypeToUnion(typeSet, includes, type);
46020             }
46021             return includes;
46022         }
46023         function removeSubtypes(types, hasObjectTypes) {
46024             var hasEmptyObject = hasObjectTypes && ts.some(types, function (t) { return !!(t.flags & 524288) && !isGenericMappedType(t) && isEmptyResolvedType(resolveStructuredTypeMembers(t)); });
46025             var len = types.length;
46026             var i = len;
46027             var count = 0;
46028             while (i > 0) {
46029                 i--;
46030                 var source = types[i];
46031                 if (hasEmptyObject || source.flags & 469499904) {
46032                     for (var _i = 0, types_11 = types; _i < types_11.length; _i++) {
46033                         var target = types_11[_i];
46034                         if (source !== target) {
46035                             if (count === 100000) {
46036                                 var estimatedCount = (count / (len - i)) * len;
46037                                 if (estimatedCount > 1000000) {
46038                                     ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes", "removeSubtypes_DepthLimit", { typeIds: types.map(function (t) { return t.id; }) });
46039                                     error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
46040                                     return false;
46041                                 }
46042                             }
46043                             count++;
46044                             if (isTypeRelatedTo(source, target, strictSubtypeRelation) && (!(ts.getObjectFlags(getTargetType(source)) & 1) ||
46045                                 !(ts.getObjectFlags(getTargetType(target)) & 1) ||
46046                                 isTypeDerivedFrom(source, target))) {
46047                                 ts.orderedRemoveItemAt(types, i);
46048                                 break;
46049                             }
46050                         }
46051                     }
46052                 }
46053             }
46054             return true;
46055         }
46056         function removeRedundantLiteralTypes(types, includes, reduceVoidUndefined) {
46057             var i = types.length;
46058             while (i > 0) {
46059                 i--;
46060                 var t = types[i];
46061                 var flags = t.flags;
46062                 var remove = flags & 128 && includes & 4 ||
46063                     flags & 256 && includes & 8 ||
46064                     flags & 2048 && includes & 64 ||
46065                     flags & 8192 && includes & 4096 ||
46066                     reduceVoidUndefined && flags & 32768 && includes & 16384 ||
46067                     isFreshLiteralType(t) && containsType(types, t.regularType);
46068                 if (remove) {
46069                     ts.orderedRemoveItemAt(types, i);
46070                 }
46071             }
46072         }
46073         function removeStringLiteralsMatchedByTemplateLiterals(types) {
46074             var templates = ts.filter(types, isPatternLiteralType);
46075             if (templates.length) {
46076                 var i = types.length;
46077                 var _loop_14 = function () {
46078                     i--;
46079                     var t = types[i];
46080                     if (t.flags & 128 && ts.some(templates, function (template) { return isTypeSubtypeOf(t, template); })) {
46081                         ts.orderedRemoveItemAt(types, i);
46082                     }
46083                 };
46084                 while (i > 0) {
46085                     _loop_14();
46086                 }
46087             }
46088         }
46089         function isNamedUnionType(type) {
46090             return !!(type.flags & 1048576 && (type.aliasSymbol || type.origin));
46091         }
46092         function addNamedUnions(namedUnions, types) {
46093             for (var _i = 0, types_12 = types; _i < types_12.length; _i++) {
46094                 var t = types_12[_i];
46095                 if (t.flags & 1048576) {
46096                     var origin = t.origin;
46097                     if (t.aliasSymbol || origin && !(origin.flags & 1048576)) {
46098                         ts.pushIfUnique(namedUnions, t);
46099                     }
46100                     else if (origin && origin.flags & 1048576) {
46101                         addNamedUnions(namedUnions, origin.types);
46102                     }
46103                 }
46104             }
46105         }
46106         function createOriginUnionOrIntersectionType(flags, types) {
46107             var result = createOriginType(flags);
46108             result.types = types;
46109             return result;
46110         }
46111         function getUnionType(types, unionReduction, aliasSymbol, aliasTypeArguments, origin) {
46112             if (unionReduction === void 0) { unionReduction = 1; }
46113             if (types.length === 0) {
46114                 return neverType;
46115             }
46116             if (types.length === 1) {
46117                 return types[0];
46118             }
46119             var typeSet = [];
46120             var includes = addTypesToUnion(typeSet, 0, types);
46121             if (unionReduction !== 0) {
46122                 if (includes & 3) {
46123                     return includes & 1 ? includes & 8388608 ? wildcardType : anyType : unknownType;
46124                 }
46125                 if (unionReduction & (1 | 2)) {
46126                     if (includes & (2944 | 8192) || includes & 16384 && includes & 32768) {
46127                         removeRedundantLiteralTypes(typeSet, includes, !!(unionReduction & 2));
46128                     }
46129                     if (includes & 128 && includes & 134217728) {
46130                         removeStringLiteralsMatchedByTemplateLiterals(typeSet);
46131                     }
46132                 }
46133                 if (unionReduction & 2) {
46134                     if (!removeSubtypes(typeSet, !!(includes & 524288))) {
46135                         return errorType;
46136                     }
46137                 }
46138                 if (typeSet.length === 0) {
46139                     return includes & 65536 ? includes & 4194304 ? nullType : nullWideningType :
46140                         includes & 32768 ? includes & 4194304 ? undefinedType : undefinedWideningType :
46141                             neverType;
46142                 }
46143             }
46144             if (!origin && includes & 1048576) {
46145                 var namedUnions = [];
46146                 addNamedUnions(namedUnions, types);
46147                 var reducedTypes = [];
46148                 var _loop_15 = function (t) {
46149                     if (!ts.some(namedUnions, function (union) { return containsType(union.types, t); })) {
46150                         reducedTypes.push(t);
46151                     }
46152                 };
46153                 for (var _i = 0, typeSet_1 = typeSet; _i < typeSet_1.length; _i++) {
46154                     var t = typeSet_1[_i];
46155                     _loop_15(t);
46156                 }
46157                 if (!aliasSymbol && namedUnions.length === 1 && reducedTypes.length === 0) {
46158                     return namedUnions[0];
46159                 }
46160                 var namedTypesCount = ts.reduceLeft(namedUnions, function (sum, union) { return sum + union.types.length; }, 0);
46161                 if (namedTypesCount + reducedTypes.length === typeSet.length) {
46162                     for (var _a = 0, namedUnions_1 = namedUnions; _a < namedUnions_1.length; _a++) {
46163                         var t = namedUnions_1[_a];
46164                         insertType(reducedTypes, t);
46165                     }
46166                     origin = createOriginUnionOrIntersectionType(1048576, reducedTypes);
46167                 }
46168             }
46169             var objectFlags = (includes & 468598819 ? 0 : 262144) |
46170                 (includes & 2097152 ? 268435456 : 0);
46171             return getUnionTypeFromSortedList(typeSet, objectFlags, aliasSymbol, aliasTypeArguments, origin);
46172         }
46173         function getUnionTypePredicate(signatures) {
46174             var first;
46175             var types = [];
46176             for (var _i = 0, signatures_6 = signatures; _i < signatures_6.length; _i++) {
46177                 var sig = signatures_6[_i];
46178                 var pred = getTypePredicateOfSignature(sig);
46179                 if (!pred || pred.kind === 2 || pred.kind === 3) {
46180                     continue;
46181                 }
46182                 if (first) {
46183                     if (!typePredicateKindsMatch(first, pred)) {
46184                         return undefined;
46185                     }
46186                 }
46187                 else {
46188                     first = pred;
46189                 }
46190                 types.push(pred.type);
46191             }
46192             if (!first) {
46193                 return undefined;
46194             }
46195             var unionType = getUnionType(types);
46196             return createTypePredicate(first.kind, first.parameterName, first.parameterIndex, unionType);
46197         }
46198         function typePredicateKindsMatch(a, b) {
46199             return a.kind === b.kind && a.parameterIndex === b.parameterIndex;
46200         }
46201         function createUnionType(types, aliasSymbol, aliasTypeArguments, origin) {
46202             var result = createType(1048576);
46203             result.objectFlags = getPropagatingFlagsOfTypes(types, 98304);
46204             result.types = types;
46205             result.origin = origin;
46206             result.aliasSymbol = aliasSymbol;
46207             result.aliasTypeArguments = aliasTypeArguments;
46208             return result;
46209         }
46210         function getUnionTypeFromSortedList(types, objectFlags, aliasSymbol, aliasTypeArguments, origin) {
46211             if (types.length === 0) {
46212                 return neverType;
46213             }
46214             if (types.length === 1) {
46215                 return types[0];
46216             }
46217             var typeKey = !origin ? getTypeListId(types) :
46218                 origin.flags & 1048576 ? "|" + getTypeListId(origin.types) :
46219                     origin.flags & 2097152 ? "&" + getTypeListId(origin.types) :
46220                         "#" + origin.type.id;
46221             var id = typeKey + getAliasId(aliasSymbol, aliasTypeArguments);
46222             var type = unionTypes.get(id);
46223             if (!type) {
46224                 type = createUnionType(types, aliasSymbol, aliasTypeArguments, origin);
46225                 type.objectFlags |= objectFlags;
46226                 unionTypes.set(id, type);
46227             }
46228             return type;
46229         }
46230         function getTypeFromUnionTypeNode(node) {
46231             var links = getNodeLinks(node);
46232             if (!links.resolvedType) {
46233                 var aliasSymbol = getAliasSymbolForTypeNode(node);
46234                 links.resolvedType = getUnionType(ts.map(node.types, getTypeFromTypeNode), 1, aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
46235             }
46236             return links.resolvedType;
46237         }
46238         function addTypeToIntersection(typeSet, includes, type) {
46239             var flags = type.flags;
46240             if (flags & 2097152) {
46241                 return addTypesToIntersection(typeSet, includes, type.types);
46242             }
46243             if (isEmptyAnonymousObjectType(type)) {
46244                 if (!(includes & 16777216)) {
46245                     includes |= 16777216;
46246                     typeSet.set(type.id.toString(), type);
46247                 }
46248             }
46249             else {
46250                 if (flags & 3) {
46251                     if (type === wildcardType)
46252                         includes |= 8388608;
46253                 }
46254                 else if ((strictNullChecks || !(flags & 98304)) && !typeSet.has(type.id.toString())) {
46255                     if (type.flags & 109440 && includes & 109440) {
46256                         includes |= 67108864;
46257                     }
46258                     typeSet.set(type.id.toString(), type);
46259                 }
46260                 includes |= flags & 205258751;
46261             }
46262             return includes;
46263         }
46264         function addTypesToIntersection(typeSet, includes, types) {
46265             for (var _i = 0, types_13 = types; _i < types_13.length; _i++) {
46266                 var type = types_13[_i];
46267                 includes = addTypeToIntersection(typeSet, includes, getRegularTypeOfLiteralType(type));
46268             }
46269             return includes;
46270         }
46271         function removeRedundantPrimitiveTypes(types, includes) {
46272             var i = types.length;
46273             while (i > 0) {
46274                 i--;
46275                 var t = types[i];
46276                 var remove = t.flags & 4 && includes & 128 ||
46277                     t.flags & 8 && includes & 256 ||
46278                     t.flags & 64 && includes & 2048 ||
46279                     t.flags & 4096 && includes & 8192;
46280                 if (remove) {
46281                     ts.orderedRemoveItemAt(types, i);
46282                 }
46283             }
46284         }
46285         function eachUnionContains(unionTypes, type) {
46286             for (var _i = 0, unionTypes_1 = unionTypes; _i < unionTypes_1.length; _i++) {
46287                 var u = unionTypes_1[_i];
46288                 if (!containsType(u.types, type)) {
46289                     var primitive = type.flags & 128 ? stringType :
46290                         type.flags & 256 ? numberType :
46291                             type.flags & 2048 ? bigintType :
46292                                 type.flags & 8192 ? esSymbolType :
46293                                     undefined;
46294                     if (!primitive || !containsType(u.types, primitive)) {
46295                         return false;
46296                     }
46297                 }
46298             }
46299             return true;
46300         }
46301         function extractRedundantTemplateLiterals(types) {
46302             var i = types.length;
46303             var literals = ts.filter(types, function (t) { return !!(t.flags & 128); });
46304             while (i > 0) {
46305                 i--;
46306                 var t = types[i];
46307                 if (!(t.flags & 134217728))
46308                     continue;
46309                 for (var _i = 0, literals_1 = literals; _i < literals_1.length; _i++) {
46310                     var t2 = literals_1[_i];
46311                     if (isTypeSubtypeOf(t2, t)) {
46312                         ts.orderedRemoveItemAt(types, i);
46313                         break;
46314                     }
46315                     else if (isPatternLiteralType(t)) {
46316                         return true;
46317                     }
46318                 }
46319             }
46320             return false;
46321         }
46322         function extractIrreducible(types, flag) {
46323             if (ts.every(types, function (t) { return !!(t.flags & 1048576) && ts.some(t.types, function (tt) { return !!(tt.flags & flag); }); })) {
46324                 for (var i = 0; i < types.length; i++) {
46325                     types[i] = filterType(types[i], function (t) { return !(t.flags & flag); });
46326                 }
46327                 return true;
46328             }
46329             return false;
46330         }
46331         function intersectUnionsOfPrimitiveTypes(types) {
46332             var unionTypes;
46333             var index = ts.findIndex(types, function (t) { return !!(ts.getObjectFlags(t) & 262144); });
46334             if (index < 0) {
46335                 return false;
46336             }
46337             var i = index + 1;
46338             while (i < types.length) {
46339                 var t = types[i];
46340                 if (ts.getObjectFlags(t) & 262144) {
46341                     (unionTypes || (unionTypes = [types[index]])).push(t);
46342                     ts.orderedRemoveItemAt(types, i);
46343                 }
46344                 else {
46345                     i++;
46346                 }
46347             }
46348             if (!unionTypes) {
46349                 return false;
46350             }
46351             var checked = [];
46352             var result = [];
46353             for (var _i = 0, unionTypes_2 = unionTypes; _i < unionTypes_2.length; _i++) {
46354                 var u = unionTypes_2[_i];
46355                 for (var _a = 0, _b = u.types; _a < _b.length; _a++) {
46356                     var t = _b[_a];
46357                     if (insertType(checked, t)) {
46358                         if (eachUnionContains(unionTypes, t)) {
46359                             insertType(result, t);
46360                         }
46361                     }
46362                 }
46363             }
46364             types[index] = getUnionTypeFromSortedList(result, 262144);
46365             return true;
46366         }
46367         function createIntersectionType(types, aliasSymbol, aliasTypeArguments) {
46368             var result = createType(2097152);
46369             result.objectFlags = getPropagatingFlagsOfTypes(types, 98304);
46370             result.types = types;
46371             result.aliasSymbol = aliasSymbol;
46372             result.aliasTypeArguments = aliasTypeArguments;
46373             return result;
46374         }
46375         function getIntersectionType(types, aliasSymbol, aliasTypeArguments) {
46376             var typeMembershipMap = new ts.Map();
46377             var includes = addTypesToIntersection(typeMembershipMap, 0, types);
46378             var typeSet = ts.arrayFrom(typeMembershipMap.values());
46379             if (includes & 131072 ||
46380                 strictNullChecks && includes & 98304 && includes & (524288 | 67108864 | 16777216) ||
46381                 includes & 67108864 && includes & (469892092 & ~67108864) ||
46382                 includes & 402653316 && includes & (469892092 & ~402653316) ||
46383                 includes & 296 && includes & (469892092 & ~296) ||
46384                 includes & 2112 && includes & (469892092 & ~2112) ||
46385                 includes & 12288 && includes & (469892092 & ~12288) ||
46386                 includes & 49152 && includes & (469892092 & ~49152)) {
46387                 return neverType;
46388             }
46389             if (includes & 134217728 && includes & 128 && extractRedundantTemplateLiterals(typeSet)) {
46390                 return neverType;
46391             }
46392             if (includes & 1) {
46393                 return includes & 8388608 ? wildcardType : anyType;
46394             }
46395             if (!strictNullChecks && includes & 98304) {
46396                 return includes & 32768 ? undefinedType : nullType;
46397             }
46398             if (includes & 4 && includes & 128 ||
46399                 includes & 8 && includes & 256 ||
46400                 includes & 64 && includes & 2048 ||
46401                 includes & 4096 && includes & 8192) {
46402                 removeRedundantPrimitiveTypes(typeSet, includes);
46403             }
46404             if (includes & 16777216 && includes & 524288) {
46405                 ts.orderedRemoveItemAt(typeSet, ts.findIndex(typeSet, isEmptyAnonymousObjectType));
46406             }
46407             if (typeSet.length === 0) {
46408                 return unknownType;
46409             }
46410             if (typeSet.length === 1) {
46411                 return typeSet[0];
46412             }
46413             var id = getTypeListId(typeSet) + getAliasId(aliasSymbol, aliasTypeArguments);
46414             var result = intersectionTypes.get(id);
46415             if (!result) {
46416                 if (includes & 1048576) {
46417                     if (intersectUnionsOfPrimitiveTypes(typeSet)) {
46418                         result = getIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
46419                     }
46420                     else if (extractIrreducible(typeSet, 32768)) {
46421                         result = getUnionType([getIntersectionType(typeSet), undefinedType], 1, aliasSymbol, aliasTypeArguments);
46422                     }
46423                     else if (extractIrreducible(typeSet, 65536)) {
46424                         result = getUnionType([getIntersectionType(typeSet), nullType], 1, aliasSymbol, aliasTypeArguments);
46425                     }
46426                     else {
46427                         if (!checkCrossProductUnion(typeSet)) {
46428                             return errorType;
46429                         }
46430                         var constituents = getCrossProductIntersections(typeSet);
46431                         var origin = ts.some(constituents, function (t) { return !!(t.flags & 2097152); }) ? createOriginUnionOrIntersectionType(2097152, typeSet) : undefined;
46432                         result = getUnionType(constituents, 1, aliasSymbol, aliasTypeArguments, origin);
46433                     }
46434                 }
46435                 else {
46436                     result = createIntersectionType(typeSet, aliasSymbol, aliasTypeArguments);
46437                 }
46438                 intersectionTypes.set(id, result);
46439             }
46440             return result;
46441         }
46442         function getCrossProductUnionSize(types) {
46443             return ts.reduceLeft(types, function (n, t) { return t.flags & 1048576 ? n * t.types.length : t.flags & 131072 ? 0 : n; }, 1);
46444         }
46445         function checkCrossProductUnion(types) {
46446             var size = getCrossProductUnionSize(types);
46447             if (size >= 100000) {
46448                 ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes", "checkCrossProductUnion_DepthLimit", { typeIds: types.map(function (t) { return t.id; }), size: size });
46449                 error(currentNode, ts.Diagnostics.Expression_produces_a_union_type_that_is_too_complex_to_represent);
46450                 return false;
46451             }
46452             return true;
46453         }
46454         function getCrossProductIntersections(types) {
46455             var count = getCrossProductUnionSize(types);
46456             var intersections = [];
46457             for (var i = 0; i < count; i++) {
46458                 var constituents = types.slice();
46459                 var n = i;
46460                 for (var j = types.length - 1; j >= 0; j--) {
46461                     if (types[j].flags & 1048576) {
46462                         var sourceTypes = types[j].types;
46463                         var length_5 = sourceTypes.length;
46464                         constituents[j] = sourceTypes[n % length_5];
46465                         n = Math.floor(n / length_5);
46466                     }
46467                 }
46468                 var t = getIntersectionType(constituents);
46469                 if (!(t.flags & 131072))
46470                     intersections.push(t);
46471             }
46472             return intersections;
46473         }
46474         function getTypeFromIntersectionTypeNode(node) {
46475             var links = getNodeLinks(node);
46476             if (!links.resolvedType) {
46477                 var aliasSymbol = getAliasSymbolForTypeNode(node);
46478                 links.resolvedType = getIntersectionType(ts.map(node.types, getTypeFromTypeNode), aliasSymbol, getTypeArgumentsForAliasSymbol(aliasSymbol));
46479             }
46480             return links.resolvedType;
46481         }
46482         function createIndexType(type, stringsOnly) {
46483             var result = createType(4194304);
46484             result.type = type;
46485             result.stringsOnly = stringsOnly;
46486             return result;
46487         }
46488         function createOriginIndexType(type) {
46489             var result = createOriginType(4194304);
46490             result.type = type;
46491             return result;
46492         }
46493         function getIndexTypeForGenericType(type, stringsOnly) {
46494             return stringsOnly ?
46495                 type.resolvedStringIndexType || (type.resolvedStringIndexType = createIndexType(type, true)) :
46496                 type.resolvedIndexType || (type.resolvedIndexType = createIndexType(type, false));
46497         }
46498         function instantiateTypeAsMappedNameType(nameType, type, t) {
46499             return instantiateType(nameType, appendTypeMapping(type.mapper, getTypeParameterFromMappedType(type), t));
46500         }
46501         function getIndexTypeForMappedType(type, noIndexSignatures) {
46502             var constraint = filterType(getConstraintTypeFromMappedType(type), function (t) { return !(noIndexSignatures && t.flags & (1 | 4)); });
46503             var nameType = type.declaration.nameType && getTypeFromTypeNode(type.declaration.nameType);
46504             var properties = nameType && everyType(constraint, function (t) { return !!(t.flags & (4 | 8 | 131072)); }) && getPropertiesOfType(getApparentType(getModifiersTypeFromMappedType(type)));
46505             return nameType ?
46506                 getUnionType([mapType(constraint, function (t) { return instantiateTypeAsMappedNameType(nameType, type, t); }), mapType(getUnionType(ts.map(properties || ts.emptyArray, function (p) { return getLiteralTypeFromProperty(p, 8576); })), function (t) { return instantiateTypeAsMappedNameType(nameType, type, t); })]) :
46507                 constraint;
46508         }
46509         function maybeNonDistributiveNameType(type) {
46510             return !!(type && (type.flags & 16777216 && (!type.root.isDistributive || maybeNonDistributiveNameType(type.checkType)) ||
46511                 type.flags & (3145728 | 134217728) && ts.some(type.types, maybeNonDistributiveNameType) ||
46512                 type.flags & (4194304 | 268435456) && maybeNonDistributiveNameType(type.type) ||
46513                 type.flags & 8388608 && maybeNonDistributiveNameType(type.indexType) ||
46514                 type.flags & 33554432 && maybeNonDistributiveNameType(type.substitute)));
46515         }
46516         function getLiteralTypeFromPropertyName(name) {
46517             if (ts.isPrivateIdentifier(name)) {
46518                 return neverType;
46519             }
46520             return ts.isIdentifier(name) ? getLiteralType(ts.unescapeLeadingUnderscores(name.escapedText)) :
46521                 getRegularTypeOfLiteralType(ts.isComputedPropertyName(name) ? checkComputedPropertyName(name) : checkExpression(name));
46522         }
46523         function getBigIntLiteralType(node) {
46524             return getLiteralType({
46525                 negative: false,
46526                 base10Value: ts.parsePseudoBigInt(node.text)
46527             });
46528         }
46529         function getLiteralTypeFromProperty(prop, include) {
46530             if (!(ts.getDeclarationModifierFlagsFromSymbol(prop) & 24)) {
46531                 var type = getSymbolLinks(getLateBoundSymbol(prop)).nameType;
46532                 if (!type && !ts.isKnownSymbol(prop)) {
46533                     if (prop.escapedName === "default") {
46534                         type = getLiteralType("default");
46535                     }
46536                     else {
46537                         var name = prop.valueDeclaration && ts.getNameOfDeclaration(prop.valueDeclaration);
46538                         type = name && getLiteralTypeFromPropertyName(name) || getLiteralType(ts.symbolName(prop));
46539                     }
46540                 }
46541                 if (type && type.flags & include) {
46542                     return type;
46543                 }
46544             }
46545             return neverType;
46546         }
46547         function getLiteralTypeFromProperties(type, include, includeOrigin) {
46548             var origin = includeOrigin && (ts.getObjectFlags(type) & (3 | 4) || type.aliasSymbol) ? createOriginIndexType(type) : undefined;
46549             return getUnionType(ts.map(getPropertiesOfType(type), function (p) { return getLiteralTypeFromProperty(p, include); }), 1, undefined, undefined, origin);
46550         }
46551         function getNonEnumNumberIndexInfo(type) {
46552             var numberIndexInfo = getIndexInfoOfType(type, 1);
46553             return numberIndexInfo !== enumNumberIndexInfo ? numberIndexInfo : undefined;
46554         }
46555         function getIndexType(type, stringsOnly, noIndexSignatures) {
46556             if (stringsOnly === void 0) { stringsOnly = keyofStringsOnly; }
46557             var includeOrigin = stringsOnly === keyofStringsOnly && !noIndexSignatures;
46558             type = getReducedType(type);
46559             return type.flags & 1048576 ? getIntersectionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
46560                 type.flags & 2097152 ? getUnionType(ts.map(type.types, function (t) { return getIndexType(t, stringsOnly, noIndexSignatures); })) :
46561                     type.flags & 58982400 || isGenericTupleType(type) || isGenericMappedType(type) && maybeNonDistributiveNameType(getNameTypeFromMappedType(type)) ? getIndexTypeForGenericType(type, stringsOnly) :
46562                         ts.getObjectFlags(type) & 32 ? getIndexTypeForMappedType(type, noIndexSignatures) :
46563                             type === wildcardType ? wildcardType :
46564                                 type.flags & 2 ? neverType :
46565                                     type.flags & (1 | 131072) ? keyofConstraintType :
46566                                         stringsOnly ? !noIndexSignatures && getIndexInfoOfType(type, 0) ? stringType : getLiteralTypeFromProperties(type, 128, includeOrigin) :
46567                                             !noIndexSignatures && getIndexInfoOfType(type, 0) ? getUnionType([stringType, numberType, getLiteralTypeFromProperties(type, 8192, includeOrigin)]) :
46568                                                 getNonEnumNumberIndexInfo(type) ? getUnionType([numberType, getLiteralTypeFromProperties(type, 128 | 8192, includeOrigin)]) :
46569                                                     getLiteralTypeFromProperties(type, 8576, includeOrigin);
46570         }
46571         function getExtractStringType(type) {
46572             if (keyofStringsOnly) {
46573                 return type;
46574             }
46575             var extractTypeAlias = getGlobalExtractSymbol();
46576             return extractTypeAlias ? getTypeAliasInstantiation(extractTypeAlias, [type, stringType]) : stringType;
46577         }
46578         function getIndexTypeOrString(type) {
46579             var indexType = getExtractStringType(getIndexType(type));
46580             return indexType.flags & 131072 ? stringType : indexType;
46581         }
46582         function getTypeFromTypeOperatorNode(node) {
46583             var links = getNodeLinks(node);
46584             if (!links.resolvedType) {
46585                 switch (node.operator) {
46586                     case 138:
46587                         links.resolvedType = getIndexType(getTypeFromTypeNode(node.type));
46588                         break;
46589                     case 151:
46590                         links.resolvedType = node.type.kind === 148
46591                             ? getESSymbolLikeTypeForNode(ts.walkUpParenthesizedTypes(node.parent))
46592                             : errorType;
46593                         break;
46594                     case 142:
46595                         links.resolvedType = getTypeFromTypeNode(node.type);
46596                         break;
46597                     default:
46598                         throw ts.Debug.assertNever(node.operator);
46599                 }
46600             }
46601             return links.resolvedType;
46602         }
46603         function getTypeFromTemplateTypeNode(node) {
46604             var links = getNodeLinks(node);
46605             if (!links.resolvedType) {
46606                 links.resolvedType = getTemplateLiteralType(__spreadArray([node.head.text], ts.map(node.templateSpans, function (span) { return span.literal.text; })), ts.map(node.templateSpans, function (span) { return getTypeFromTypeNode(span.type); }));
46607             }
46608             return links.resolvedType;
46609         }
46610         function getTemplateLiteralType(texts, types) {
46611             var unionIndex = ts.findIndex(types, function (t) { return !!(t.flags & (131072 | 1048576)); });
46612             if (unionIndex >= 0) {
46613                 return checkCrossProductUnion(types) ?
46614                     mapType(types[unionIndex], function (t) { return getTemplateLiteralType(texts, ts.replaceElement(types, unionIndex, t)); }) :
46615                     errorType;
46616             }
46617             if (ts.contains(types, wildcardType)) {
46618                 return wildcardType;
46619             }
46620             var newTypes = [];
46621             var newTexts = [];
46622             var text = texts[0];
46623             if (!addSpans(texts, types)) {
46624                 return stringType;
46625             }
46626             if (newTypes.length === 0) {
46627                 return getLiteralType(text);
46628             }
46629             newTexts.push(text);
46630             if (ts.every(newTexts, function (t) { return t === ""; }) && ts.every(newTypes, function (t) { return !!(t.flags & 4); })) {
46631                 return stringType;
46632             }
46633             var id = getTypeListId(newTypes) + "|" + ts.map(newTexts, function (t) { return t.length; }).join(",") + "|" + newTexts.join("");
46634             var type = templateLiteralTypes.get(id);
46635             if (!type) {
46636                 templateLiteralTypes.set(id, type = createTemplateLiteralType(newTexts, newTypes));
46637             }
46638             return type;
46639             function addSpans(texts, types) {
46640                 for (var i = 0; i < types.length; i++) {
46641                     var t = types[i];
46642                     if (t.flags & (2944 | 65536 | 32768)) {
46643                         text += getTemplateStringForType(t) || "";
46644                         text += texts[i + 1];
46645                     }
46646                     else if (t.flags & 134217728) {
46647                         text += t.texts[0];
46648                         if (!addSpans(t.texts, t.types))
46649                             return false;
46650                         text += texts[i + 1];
46651                     }
46652                     else if (isGenericIndexType(t) || isPatternLiteralPlaceholderType(t)) {
46653                         newTypes.push(t);
46654                         newTexts.push(text);
46655                         text = texts[i + 1];
46656                     }
46657                     else {
46658                         return false;
46659                     }
46660                 }
46661                 return true;
46662             }
46663         }
46664         function getTemplateStringForType(type) {
46665             return type.flags & 128 ? type.value :
46666                 type.flags & 256 ? "" + type.value :
46667                     type.flags & 2048 ? ts.pseudoBigIntToString(type.value) :
46668                         type.flags & 512 ? type.intrinsicName :
46669                             type.flags & 65536 ? "null" :
46670                                 type.flags & 32768 ? "undefined" :
46671                                     undefined;
46672         }
46673         function createTemplateLiteralType(texts, types) {
46674             var type = createType(134217728);
46675             type.texts = texts;
46676             type.types = types;
46677             return type;
46678         }
46679         function getStringMappingType(symbol, type) {
46680             return type.flags & (1048576 | 131072) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
46681                 isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
46682                     type.flags & 128 ? getLiteralType(applyStringMapping(symbol, type.value)) :
46683                         type;
46684         }
46685         function applyStringMapping(symbol, str) {
46686             switch (intrinsicTypeKinds.get(symbol.escapedName)) {
46687                 case 0: return str.toUpperCase();
46688                 case 1: return str.toLowerCase();
46689                 case 2: return str.charAt(0).toUpperCase() + str.slice(1);
46690                 case 3: return str.charAt(0).toLowerCase() + str.slice(1);
46691             }
46692             return str;
46693         }
46694         function getStringMappingTypeForGenericType(symbol, type) {
46695             var id = getSymbolId(symbol) + "," + getTypeId(type);
46696             var result = stringMappingTypes.get(id);
46697             if (!result) {
46698                 stringMappingTypes.set(id, result = createStringMappingType(symbol, type));
46699             }
46700             return result;
46701         }
46702         function createStringMappingType(symbol, type) {
46703             var result = createType(268435456);
46704             result.symbol = symbol;
46705             result.type = type;
46706             return result;
46707         }
46708         function createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined) {
46709             var type = createType(8388608);
46710             type.objectType = objectType;
46711             type.indexType = indexType;
46712             type.aliasSymbol = aliasSymbol;
46713             type.aliasTypeArguments = aliasTypeArguments;
46714             type.noUncheckedIndexedAccessCandidate = shouldIncludeUndefined;
46715             return type;
46716         }
46717         function isJSLiteralType(type) {
46718             if (noImplicitAny) {
46719                 return false;
46720             }
46721             if (ts.getObjectFlags(type) & 16384) {
46722                 return true;
46723             }
46724             if (type.flags & 1048576) {
46725                 return ts.every(type.types, isJSLiteralType);
46726             }
46727             if (type.flags & 2097152) {
46728                 return ts.some(type.types, isJSLiteralType);
46729             }
46730             if (type.flags & 465829888) {
46731                 var constraint = getResolvedBaseConstraint(type);
46732                 return constraint !== type && isJSLiteralType(constraint);
46733             }
46734             return false;
46735         }
46736         function getPropertyNameFromIndex(indexType, accessNode) {
46737             var accessExpression = accessNode && accessNode.kind === 202 ? accessNode : undefined;
46738             return isTypeUsableAsPropertyName(indexType) ?
46739                 getPropertyNameFromType(indexType) :
46740                 accessExpression && checkThatExpressionIsProperSymbolReference(accessExpression.argumentExpression, indexType, false) ?
46741                     ts.getPropertyNameForKnownSymbolName(ts.idText(accessExpression.argumentExpression.name)) :
46742                     accessNode && ts.isPropertyName(accessNode) ?
46743                         ts.getPropertyNameForPropertyNameNode(accessNode) :
46744                         undefined;
46745         }
46746         function isUncalledFunctionReference(node, symbol) {
46747             if (symbol.flags & (16 | 8192)) {
46748                 var parent = ts.findAncestor(node.parent, function (n) { return !ts.isAccessExpression(n); }) || node.parent;
46749                 if (ts.isCallLikeExpression(parent)) {
46750                     return ts.isCallOrNewExpression(parent) && ts.isIdentifier(node) && hasMatchingArgument(parent, node);
46751                 }
46752                 return ts.every(symbol.declarations, function (d) { return !ts.isFunctionLike(d) || !!(ts.getCombinedNodeFlags(d) & 134217728); });
46753             }
46754             return true;
46755         }
46756         function getPropertyTypeForIndexType(originalObjectType, objectType, indexType, fullIndexType, suppressNoImplicitAnyError, accessNode, accessFlags, noUncheckedIndexedAccessCandidate, reportDeprecated) {
46757             var _a;
46758             var accessExpression = accessNode && accessNode.kind === 202 ? accessNode : undefined;
46759             var propName = accessNode && ts.isPrivateIdentifier(accessNode) ? undefined : getPropertyNameFromIndex(indexType, accessNode);
46760             if (propName !== undefined) {
46761                 var prop = getPropertyOfType(objectType, propName);
46762                 if (prop) {
46763                     if (reportDeprecated && accessNode && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 && isUncalledFunctionReference(accessNode, prop)) {
46764                         var deprecatedNode = (_a = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _a !== void 0 ? _a : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode);
46765                         addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName);
46766                     }
46767                     if (accessExpression) {
46768                         markPropertyAsReferenced(prop, accessExpression, accessExpression.expression.kind === 107);
46769                         if (isAssignmentToReadonlyEntity(accessExpression, prop, ts.getAssignmentTargetKind(accessExpression))) {
46770                             error(accessExpression.argumentExpression, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(prop));
46771                             return undefined;
46772                         }
46773                         if (accessFlags & 4) {
46774                             getNodeLinks(accessNode).resolvedSymbol = prop;
46775                         }
46776                         if (isThisPropertyAccessInConstructor(accessExpression, prop)) {
46777                             return autoType;
46778                         }
46779                     }
46780                     var propType = getTypeOfSymbol(prop);
46781                     return accessExpression && ts.getAssignmentTargetKind(accessExpression) !== 1 ?
46782                         getFlowTypeOfReference(accessExpression, propType) :
46783                         propType;
46784                 }
46785                 if (everyType(objectType, isTupleType) && isNumericLiteralName(propName) && +propName >= 0) {
46786                     if (accessNode && everyType(objectType, function (t) { return !t.target.hasRestElement; }) && !(accessFlags & 8)) {
46787                         var indexNode = getIndexNodeForAccessExpression(accessNode);
46788                         if (isTupleType(objectType)) {
46789                             error(indexNode, ts.Diagnostics.Tuple_type_0_of_length_1_has_no_element_at_index_2, typeToString(objectType), getTypeReferenceArity(objectType), ts.unescapeLeadingUnderscores(propName));
46790                         }
46791                         else {
46792                             error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
46793                         }
46794                     }
46795                     errorIfWritingToReadonlyIndex(getIndexInfoOfType(objectType, 1));
46796                     return mapType(objectType, function (t) {
46797                         var restType = getRestTypeOfTupleType(t) || undefinedType;
46798                         return noUncheckedIndexedAccessCandidate ? getUnionType([restType, undefinedType]) : restType;
46799                     });
46800                 }
46801             }
46802             if (!(indexType.flags & 98304) && isTypeAssignableToKind(indexType, 402653316 | 296 | 12288)) {
46803                 if (objectType.flags & (1 | 131072)) {
46804                     return objectType;
46805                 }
46806                 var stringIndexInfo = getIndexInfoOfType(objectType, 0);
46807                 var indexInfo = isTypeAssignableToKind(indexType, 296) && getIndexInfoOfType(objectType, 1) || stringIndexInfo;
46808                 if (indexInfo) {
46809                     if (accessFlags & 1 && indexInfo === stringIndexInfo) {
46810                         if (accessExpression) {
46811                             error(accessExpression, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(originalObjectType));
46812                         }
46813                         return undefined;
46814                     }
46815                     if (accessNode && !isTypeAssignableToKind(indexType, 4 | 8)) {
46816                         var indexNode = getIndexNodeForAccessExpression(accessNode);
46817                         error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
46818                         return noUncheckedIndexedAccessCandidate ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
46819                     }
46820                     errorIfWritingToReadonlyIndex(indexInfo);
46821                     return noUncheckedIndexedAccessCandidate ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
46822                 }
46823                 if (indexType.flags & 131072) {
46824                     return neverType;
46825                 }
46826                 if (isJSLiteralType(objectType)) {
46827                     return anyType;
46828                 }
46829                 if (accessExpression && !isConstEnumObjectType(objectType)) {
46830                     if (isObjectLiteralType(objectType)) {
46831                         if (noImplicitAny && indexType.flags & (128 | 256)) {
46832                             diagnostics.add(ts.createDiagnosticForNode(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType)));
46833                             return undefinedType;
46834                         }
46835                         else if (indexType.flags & (8 | 4)) {
46836                             var types = ts.map(objectType.properties, function (property) {
46837                                 return getTypeOfSymbol(property);
46838                             });
46839                             return getUnionType(ts.append(types, undefinedType));
46840                         }
46841                     }
46842                     if (objectType.symbol === globalThisSymbol && propName !== undefined && globalThisSymbol.exports.has(propName) && (globalThisSymbol.exports.get(propName).flags & 418)) {
46843                         error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(propName), typeToString(objectType));
46844                     }
46845                     else if (noImplicitAny && !compilerOptions.suppressImplicitAnyIndexErrors && !suppressNoImplicitAnyError) {
46846                         if (propName !== undefined && typeHasStaticProperty(propName, objectType)) {
46847                             var typeName = typeToString(objectType);
46848                             error(accessExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead, propName, typeName, typeName + "[" + ts.getTextOfNode(accessExpression.argumentExpression) + "]");
46849                         }
46850                         else if (getIndexTypeOfType(objectType, 1)) {
46851                             error(accessExpression.argumentExpression, ts.Diagnostics.Element_implicitly_has_an_any_type_because_index_expression_is_not_of_type_number);
46852                         }
46853                         else {
46854                             var suggestion = void 0;
46855                             if (propName !== undefined && (suggestion = getSuggestionForNonexistentProperty(propName, objectType))) {
46856                                 if (suggestion !== undefined) {
46857                                     error(accessExpression.argumentExpression, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, propName, typeToString(objectType), suggestion);
46858                                 }
46859                             }
46860                             else {
46861                                 var suggestion_1 = getSuggestionForNonexistentIndexSignature(objectType, accessExpression, indexType);
46862                                 if (suggestion_1 !== undefined) {
46863                                     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);
46864                                 }
46865                                 else {
46866                                     var errorInfo = void 0;
46867                                     if (indexType.flags & 1024) {
46868                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + typeToString(indexType) + "]", typeToString(objectType));
46869                                     }
46870                                     else if (indexType.flags & 8192) {
46871                                         var symbolName_2 = getFullyQualifiedName(indexType.symbol, accessExpression);
46872                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "[" + symbolName_2 + "]", typeToString(objectType));
46873                                     }
46874                                     else if (indexType.flags & 128) {
46875                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
46876                                     }
46877                                     else if (indexType.flags & 256) {
46878                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Property_0_does_not_exist_on_type_1, indexType.value, typeToString(objectType));
46879                                     }
46880                                     else if (indexType.flags & (8 | 4)) {
46881                                         errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.No_index_signature_with_a_parameter_of_type_0_was_found_on_type_1, typeToString(indexType), typeToString(objectType));
46882                                     }
46883                                     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));
46884                                     diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(accessExpression, errorInfo));
46885                                 }
46886                             }
46887                         }
46888                     }
46889                     return undefined;
46890                 }
46891             }
46892             if (isJSLiteralType(objectType)) {
46893                 return anyType;
46894             }
46895             if (accessNode) {
46896                 var indexNode = getIndexNodeForAccessExpression(accessNode);
46897                 if (indexType.flags & (128 | 256)) {
46898                     error(indexNode, ts.Diagnostics.Property_0_does_not_exist_on_type_1, "" + indexType.value, typeToString(objectType));
46899                 }
46900                 else if (indexType.flags & (4 | 8)) {
46901                     error(indexNode, ts.Diagnostics.Type_0_has_no_matching_index_signature_for_type_1, typeToString(objectType), typeToString(indexType));
46902                 }
46903                 else {
46904                     error(indexNode, ts.Diagnostics.Type_0_cannot_be_used_as_an_index_type, typeToString(indexType));
46905                 }
46906             }
46907             if (isTypeAny(indexType)) {
46908                 return indexType;
46909             }
46910             return undefined;
46911             function errorIfWritingToReadonlyIndex(indexInfo) {
46912                 if (indexInfo && indexInfo.isReadonly && accessExpression && (ts.isAssignmentTarget(accessExpression) || ts.isDeleteTarget(accessExpression))) {
46913                     error(accessExpression, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
46914                 }
46915             }
46916         }
46917         function getIndexNodeForAccessExpression(accessNode) {
46918             return accessNode.kind === 202 ? accessNode.argumentExpression :
46919                 accessNode.kind === 189 ? accessNode.indexType :
46920                     accessNode.kind === 158 ? accessNode.expression :
46921                         accessNode;
46922         }
46923         function isPatternLiteralPlaceholderType(type) {
46924             return templateConstraintType.types.indexOf(type) !== -1 || !!(type.flags & 1);
46925         }
46926         function isPatternLiteralType(type) {
46927             return !!(type.flags & 134217728) && ts.every(type.types, isPatternLiteralPlaceholderType);
46928         }
46929         function isGenericObjectType(type) {
46930             if (type.flags & 3145728) {
46931                 if (!(type.objectFlags & 4194304)) {
46932                     type.objectFlags |= 4194304 |
46933                         (ts.some(type.types, isGenericObjectType) ? 8388608 : 0);
46934                 }
46935                 return !!(type.objectFlags & 8388608);
46936             }
46937             return !!(type.flags & 58982400) || isGenericMappedType(type) || isGenericTupleType(type);
46938         }
46939         function isGenericIndexType(type) {
46940             if (type.flags & 3145728) {
46941                 if (!(type.objectFlags & 16777216)) {
46942                     type.objectFlags |= 16777216 |
46943                         (ts.some(type.types, isGenericIndexType) ? 33554432 : 0);
46944                 }
46945                 return !!(type.objectFlags & 33554432);
46946             }
46947             return !!(type.flags & (58982400 | 4194304 | 134217728 | 268435456)) && !isPatternLiteralType(type);
46948         }
46949         function isThisTypeParameter(type) {
46950             return !!(type.flags & 262144 && type.isThisType);
46951         }
46952         function getSimplifiedType(type, writing) {
46953             return type.flags & 8388608 ? getSimplifiedIndexedAccessType(type, writing) :
46954                 type.flags & 16777216 ? getSimplifiedConditionalType(type, writing) :
46955                     type;
46956         }
46957         function distributeIndexOverObjectType(objectType, indexType, writing) {
46958             if (objectType.flags & 3145728) {
46959                 var types = ts.map(objectType.types, function (t) { return getSimplifiedType(getIndexedAccessType(t, indexType), writing); });
46960                 return objectType.flags & 2097152 || writing ? getIntersectionType(types) : getUnionType(types);
46961             }
46962         }
46963         function distributeObjectOverIndexType(objectType, indexType, writing) {
46964             if (indexType.flags & 1048576) {
46965                 var types = ts.map(indexType.types, function (t) { return getSimplifiedType(getIndexedAccessType(objectType, t), writing); });
46966                 return writing ? getIntersectionType(types) : getUnionType(types);
46967             }
46968         }
46969         function getSimplifiedIndexedAccessType(type, writing) {
46970             var cache = writing ? "simplifiedForWriting" : "simplifiedForReading";
46971             if (type[cache]) {
46972                 return type[cache] === circularConstraintType ? type : type[cache];
46973             }
46974             type[cache] = circularConstraintType;
46975             var objectType = getSimplifiedType(type.objectType, writing);
46976             var indexType = getSimplifiedType(type.indexType, writing);
46977             var distributedOverIndex = distributeObjectOverIndexType(objectType, indexType, writing);
46978             if (distributedOverIndex) {
46979                 return type[cache] = distributedOverIndex;
46980             }
46981             if (!(indexType.flags & 465829888)) {
46982                 var distributedOverObject = distributeIndexOverObjectType(objectType, indexType, writing);
46983                 if (distributedOverObject) {
46984                     return type[cache] = distributedOverObject;
46985                 }
46986             }
46987             if (isGenericTupleType(objectType) && indexType.flags & 296) {
46988                 var elementType = getElementTypeOfSliceOfTupleType(objectType, indexType.flags & 8 ? 0 : objectType.target.fixedLength, 0, writing);
46989                 if (elementType) {
46990                     return type[cache] = elementType;
46991                 }
46992             }
46993             if (isGenericMappedType(objectType)) {
46994                 return type[cache] = mapType(substituteIndexedMappedType(objectType, type.indexType), function (t) { return getSimplifiedType(t, writing); });
46995             }
46996             return type[cache] = type;
46997         }
46998         function getSimplifiedConditionalType(type, writing) {
46999             var checkType = type.checkType;
47000             var extendsType = type.extendsType;
47001             var trueType = getTrueTypeFromConditionalType(type);
47002             var falseType = getFalseTypeFromConditionalType(type);
47003             if (falseType.flags & 131072 && getActualTypeVariable(trueType) === getActualTypeVariable(checkType)) {
47004                 if (checkType.flags & 1 || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) {
47005                     return getSimplifiedType(trueType, writing);
47006                 }
47007                 else if (isIntersectionEmpty(checkType, extendsType)) {
47008                     return neverType;
47009                 }
47010             }
47011             else if (trueType.flags & 131072 && getActualTypeVariable(falseType) === getActualTypeVariable(checkType)) {
47012                 if (!(checkType.flags & 1) && isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(extendsType))) {
47013                     return neverType;
47014                 }
47015                 else if (checkType.flags & 1 || isIntersectionEmpty(checkType, extendsType)) {
47016                     return getSimplifiedType(falseType, writing);
47017                 }
47018             }
47019             return type;
47020         }
47021         function isIntersectionEmpty(type1, type2) {
47022             return !!(getUnionType([intersectTypes(type1, type2), neverType]).flags & 131072);
47023         }
47024         function substituteIndexedMappedType(objectType, index) {
47025             var mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]);
47026             var templateMapper = combineTypeMappers(objectType.mapper, mapper);
47027             return instantiateType(getTemplateTypeFromMappedType(objectType), templateMapper);
47028         }
47029         function getIndexedAccessType(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, aliasSymbol, aliasTypeArguments, accessFlags) {
47030             if (accessFlags === void 0) { accessFlags = 0; }
47031             return getIndexedAccessTypeOrUndefined(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType);
47032         }
47033         function indexTypeLessThan(indexType, limit) {
47034             return everyType(indexType, function (t) {
47035                 if (t.flags & 384) {
47036                     var propName = getPropertyNameFromType(t);
47037                     if (isNumericLiteralName(propName)) {
47038                         var index = +propName;
47039                         return index >= 0 && index < limit;
47040                     }
47041                 }
47042                 return false;
47043             });
47044         }
47045         function getIndexedAccessTypeOrUndefined(objectType, indexType, noUncheckedIndexedAccessCandidate, accessNode, accessFlags, aliasSymbol, aliasTypeArguments) {
47046             if (accessFlags === void 0) { accessFlags = 0; }
47047             if (objectType === wildcardType || indexType === wildcardType) {
47048                 return wildcardType;
47049             }
47050             var shouldIncludeUndefined = noUncheckedIndexedAccessCandidate ||
47051                 (!!compilerOptions.noUncheckedIndexedAccess &&
47052                     (accessFlags & (2 | 16)) === 16);
47053             if (isStringIndexSignatureOnlyType(objectType) && !(indexType.flags & 98304) && isTypeAssignableToKind(indexType, 4 | 8)) {
47054                 indexType = stringType;
47055             }
47056             if (isGenericIndexType(indexType) || (accessNode && accessNode.kind !== 189 ?
47057                 isGenericTupleType(objectType) && !indexTypeLessThan(indexType, objectType.target.fixedLength) :
47058                 isGenericObjectType(objectType) && !(isTupleType(objectType) && indexTypeLessThan(indexType, objectType.target.fixedLength)))) {
47059                 if (objectType.flags & 3) {
47060                     return objectType;
47061                 }
47062                 var id = objectType.id + "," + indexType.id + (shouldIncludeUndefined ? "?" : "") + getAliasId(aliasSymbol, aliasTypeArguments);
47063                 var type = indexedAccessTypes.get(id);
47064                 if (!type) {
47065                     indexedAccessTypes.set(id, type = createIndexedAccessType(objectType, indexType, aliasSymbol, aliasTypeArguments, shouldIncludeUndefined));
47066                 }
47067                 return type;
47068             }
47069             var apparentObjectType = getReducedApparentType(objectType);
47070             if (indexType.flags & 1048576 && !(indexType.flags & 16)) {
47071                 var propTypes = [];
47072                 var wasMissingProp = false;
47073                 for (var _i = 0, _a = indexType.types; _i < _a.length; _i++) {
47074                     var t = _a[_i];
47075                     var propType = getPropertyTypeForIndexType(objectType, apparentObjectType, t, indexType, wasMissingProp, accessNode, accessFlags, shouldIncludeUndefined);
47076                     if (propType) {
47077                         propTypes.push(propType);
47078                     }
47079                     else if (!accessNode) {
47080                         return undefined;
47081                     }
47082                     else {
47083                         wasMissingProp = true;
47084                     }
47085                 }
47086                 if (wasMissingProp) {
47087                     return undefined;
47088                 }
47089                 return accessFlags & 2
47090                     ? getIntersectionType(propTypes, aliasSymbol, aliasTypeArguments)
47091                     : getUnionType(propTypes, 1, aliasSymbol, aliasTypeArguments);
47092             }
47093             return getPropertyTypeForIndexType(objectType, apparentObjectType, indexType, indexType, false, accessNode, accessFlags | 4, shouldIncludeUndefined, true);
47094         }
47095         function getTypeFromIndexedAccessTypeNode(node) {
47096             var links = getNodeLinks(node);
47097             if (!links.resolvedType) {
47098                 var objectType = getTypeFromTypeNode(node.objectType);
47099                 var indexType = getTypeFromTypeNode(node.indexType);
47100                 var potentialAlias = getAliasSymbolForTypeNode(node);
47101                 var resolved = getIndexedAccessType(objectType, indexType, undefined, node, potentialAlias, getTypeArgumentsForAliasSymbol(potentialAlias));
47102                 links.resolvedType = resolved.flags & 8388608 &&
47103                     resolved.objectType === objectType &&
47104                     resolved.indexType === indexType ?
47105                     getConditionalFlowTypeOfType(resolved, node) : resolved;
47106             }
47107             return links.resolvedType;
47108         }
47109         function getTypeFromMappedTypeNode(node) {
47110             var links = getNodeLinks(node);
47111             if (!links.resolvedType) {
47112                 var type = createObjectType(32, node.symbol);
47113                 type.declaration = node;
47114                 type.aliasSymbol = getAliasSymbolForTypeNode(node);
47115                 type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(type.aliasSymbol);
47116                 links.resolvedType = type;
47117                 getConstraintTypeFromMappedType(type);
47118             }
47119             return links.resolvedType;
47120         }
47121         function getActualTypeVariable(type) {
47122             if (type.flags & 33554432) {
47123                 return type.baseType;
47124             }
47125             if (type.flags & 8388608 && (type.objectType.flags & 33554432 ||
47126                 type.indexType.flags & 33554432)) {
47127                 return getIndexedAccessType(getActualTypeVariable(type.objectType), getActualTypeVariable(type.indexType));
47128             }
47129             return type;
47130         }
47131         function isTypicalNondistributiveConditional(root) {
47132             return !root.isDistributive
47133                 && root.node.checkType.kind === 179
47134                 && ts.length(root.node.checkType.elements) === 1
47135                 && root.node.extendsType.kind === 179
47136                 && ts.length(root.node.extendsType.elements) === 1;
47137         }
47138         function unwrapNondistributiveConditionalTuple(root, type) {
47139             return isTypicalNondistributiveConditional(root) && isTupleType(type) ? getTypeArguments(type)[0] : type;
47140         }
47141         function getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) {
47142             var result;
47143             var extraTypes;
47144             while (true) {
47145                 var isUnwrapped = isTypicalNondistributiveConditional(root);
47146                 var checkType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.checkType), mapper);
47147                 var checkTypeInstantiable = isGenericObjectType(checkType) || isGenericIndexType(checkType);
47148                 var extendsType = instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), mapper);
47149                 if (checkType === wildcardType || extendsType === wildcardType) {
47150                     return wildcardType;
47151                 }
47152                 var combinedMapper = void 0;
47153                 if (root.inferTypeParameters) {
47154                     var context = createInferenceContext(root.inferTypeParameters, undefined, 0);
47155                     if (!checkTypeInstantiable) {
47156                         inferTypes(context.inferences, checkType, extendsType, 256 | 512);
47157                     }
47158                     combinedMapper = mergeTypeMappers(mapper, context.mapper);
47159                 }
47160                 var inferredExtendsType = combinedMapper ? instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), combinedMapper) : extendsType;
47161                 if (!checkTypeInstantiable && !isGenericObjectType(inferredExtendsType) && !isGenericIndexType(inferredExtendsType)) {
47162                     if (!(inferredExtendsType.flags & 3) && ((checkType.flags & 1 && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
47163                         if (checkType.flags & 1 && !isUnwrapped) {
47164                             (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
47165                         }
47166                         var falseType_1 = getTypeFromTypeNode(root.node.falseType);
47167                         if (falseType_1.flags & 16777216) {
47168                             var newRoot = falseType_1.root;
47169                             if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
47170                                 root = newRoot;
47171                                 continue;
47172                             }
47173                         }
47174                         result = instantiateType(falseType_1, mapper);
47175                         break;
47176                     }
47177                     if (inferredExtendsType.flags & 3 || isTypeAssignableTo(getRestrictiveInstantiation(checkType), getRestrictiveInstantiation(inferredExtendsType))) {
47178                         result = instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper);
47179                         break;
47180                     }
47181                 }
47182                 result = createType(16777216);
47183                 result.root = root;
47184                 result.checkType = instantiateType(root.checkType, mapper);
47185                 result.extendsType = instantiateType(root.extendsType, mapper);
47186                 result.mapper = mapper;
47187                 result.combinedMapper = combinedMapper;
47188                 result.aliasSymbol = aliasSymbol || root.aliasSymbol;
47189                 result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(root.aliasTypeArguments, mapper);
47190                 break;
47191             }
47192             return extraTypes ? getUnionType(ts.append(extraTypes, result)) : result;
47193         }
47194         function getTrueTypeFromConditionalType(type) {
47195             return type.resolvedTrueType || (type.resolvedTrueType = instantiateType(getTypeFromTypeNode(type.root.node.trueType), type.mapper));
47196         }
47197         function getFalseTypeFromConditionalType(type) {
47198             return type.resolvedFalseType || (type.resolvedFalseType = instantiateType(getTypeFromTypeNode(type.root.node.falseType), type.mapper));
47199         }
47200         function getInferredTrueTypeFromConditionalType(type) {
47201             return type.resolvedInferredTrueType || (type.resolvedInferredTrueType = type.combinedMapper ? instantiateType(getTypeFromTypeNode(type.root.node.trueType), type.combinedMapper) : getTrueTypeFromConditionalType(type));
47202         }
47203         function getInferTypeParameters(node) {
47204             var result;
47205             if (node.locals) {
47206                 node.locals.forEach(function (symbol) {
47207                     if (symbol.flags & 262144) {
47208                         result = ts.append(result, getDeclaredTypeOfSymbol(symbol));
47209                     }
47210                 });
47211             }
47212             return result;
47213         }
47214         function getTypeFromConditionalTypeNode(node) {
47215             var links = getNodeLinks(node);
47216             if (!links.resolvedType) {
47217                 var checkType = getTypeFromTypeNode(node.checkType);
47218                 var aliasSymbol = getAliasSymbolForTypeNode(node);
47219                 var aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
47220                 var allOuterTypeParameters = getOuterTypeParameters(node, true);
47221                 var outerTypeParameters = aliasTypeArguments ? allOuterTypeParameters : ts.filter(allOuterTypeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, node); });
47222                 var root = {
47223                     node: node,
47224                     checkType: checkType,
47225                     extendsType: getTypeFromTypeNode(node.extendsType),
47226                     isDistributive: !!(checkType.flags & 262144),
47227                     inferTypeParameters: getInferTypeParameters(node),
47228                     outerTypeParameters: outerTypeParameters,
47229                     instantiations: undefined,
47230                     aliasSymbol: aliasSymbol,
47231                     aliasTypeArguments: aliasTypeArguments
47232                 };
47233                 links.resolvedType = getConditionalType(root, undefined);
47234                 if (outerTypeParameters) {
47235                     root.instantiations = new ts.Map();
47236                     root.instantiations.set(getTypeListId(outerTypeParameters), links.resolvedType);
47237                 }
47238             }
47239             return links.resolvedType;
47240         }
47241         function getTypeFromInferTypeNode(node) {
47242             var links = getNodeLinks(node);
47243             if (!links.resolvedType) {
47244                 links.resolvedType = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node.typeParameter));
47245             }
47246             return links.resolvedType;
47247         }
47248         function getIdentifierChain(node) {
47249             if (ts.isIdentifier(node)) {
47250                 return [node];
47251             }
47252             else {
47253                 return ts.append(getIdentifierChain(node.left), node.right);
47254             }
47255         }
47256         function getTypeFromImportTypeNode(node) {
47257             var links = getNodeLinks(node);
47258             if (!links.resolvedType) {
47259                 if (node.isTypeOf && node.typeArguments) {
47260                     error(node, ts.Diagnostics.Type_arguments_cannot_be_used_here);
47261                     links.resolvedSymbol = unknownSymbol;
47262                     return links.resolvedType = errorType;
47263                 }
47264                 if (!ts.isLiteralImportTypeNode(node)) {
47265                     error(node.argument, ts.Diagnostics.String_literal_expected);
47266                     links.resolvedSymbol = unknownSymbol;
47267                     return links.resolvedType = errorType;
47268                 }
47269                 var targetMeaning = node.isTypeOf ? 111551 : node.flags & 4194304 ? 111551 | 788968 : 788968;
47270                 var innerModuleSymbol = resolveExternalModuleName(node, node.argument.literal);
47271                 if (!innerModuleSymbol) {
47272                     links.resolvedSymbol = unknownSymbol;
47273                     return links.resolvedType = errorType;
47274                 }
47275                 var moduleSymbol = resolveExternalModuleSymbol(innerModuleSymbol, false);
47276                 if (!ts.nodeIsMissing(node.qualifier)) {
47277                     var nameStack = getIdentifierChain(node.qualifier);
47278                     var currentNamespace = moduleSymbol;
47279                     var current = void 0;
47280                     while (current = nameStack.shift()) {
47281                         var meaning = nameStack.length ? 1920 : targetMeaning;
47282                         var mergedResolvedSymbol = getMergedSymbol(resolveSymbol(currentNamespace));
47283                         var next = node.isTypeOf
47284                             ? getPropertyOfType(getTypeOfSymbol(mergedResolvedSymbol), current.escapedText)
47285                             : getSymbol(getExportsOfSymbol(mergedResolvedSymbol), current.escapedText, meaning);
47286                         if (!next) {
47287                             error(current, ts.Diagnostics.Namespace_0_has_no_exported_member_1, getFullyQualifiedName(currentNamespace), ts.declarationNameToString(current));
47288                             return links.resolvedType = errorType;
47289                         }
47290                         getNodeLinks(current).resolvedSymbol = next;
47291                         getNodeLinks(current.parent).resolvedSymbol = next;
47292                         currentNamespace = next;
47293                     }
47294                     links.resolvedType = resolveImportSymbolType(node, links, currentNamespace, targetMeaning);
47295                 }
47296                 else {
47297                     if (moduleSymbol.flags & targetMeaning) {
47298                         links.resolvedType = resolveImportSymbolType(node, links, moduleSymbol, targetMeaning);
47299                     }
47300                     else {
47301                         var errorMessage = targetMeaning === 111551
47302                             ? ts.Diagnostics.Module_0_does_not_refer_to_a_value_but_is_used_as_a_value_here
47303                             : ts.Diagnostics.Module_0_does_not_refer_to_a_type_but_is_used_as_a_type_here_Did_you_mean_typeof_import_0;
47304                         error(node, errorMessage, node.argument.literal.text);
47305                         links.resolvedSymbol = unknownSymbol;
47306                         links.resolvedType = errorType;
47307                     }
47308                 }
47309             }
47310             return links.resolvedType;
47311         }
47312         function resolveImportSymbolType(node, links, symbol, meaning) {
47313             var resolvedSymbol = resolveSymbol(symbol);
47314             links.resolvedSymbol = resolvedSymbol;
47315             if (meaning === 111551) {
47316                 return getTypeOfSymbol(symbol);
47317             }
47318             else {
47319                 return getTypeReferenceType(node, resolvedSymbol);
47320             }
47321         }
47322         function getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node) {
47323             var links = getNodeLinks(node);
47324             if (!links.resolvedType) {
47325                 var aliasSymbol = getAliasSymbolForTypeNode(node);
47326                 if (getMembersOfSymbol(node.symbol).size === 0 && !aliasSymbol) {
47327                     links.resolvedType = emptyTypeLiteralType;
47328                 }
47329                 else {
47330                     var type = createObjectType(16, node.symbol);
47331                     type.aliasSymbol = aliasSymbol;
47332                     type.aliasTypeArguments = getTypeArgumentsForAliasSymbol(aliasSymbol);
47333                     if (ts.isJSDocTypeLiteral(node) && node.isArrayType) {
47334                         type = createArrayType(type);
47335                     }
47336                     links.resolvedType = type;
47337                 }
47338             }
47339             return links.resolvedType;
47340         }
47341         function getAliasSymbolForTypeNode(node) {
47342             var host = node.parent;
47343             while (ts.isParenthesizedTypeNode(host) || ts.isJSDocTypeExpression(host) || ts.isTypeOperatorNode(host) && host.operator === 142) {
47344                 host = host.parent;
47345             }
47346             return ts.isTypeAlias(host) ? getSymbolOfNode(host) : undefined;
47347         }
47348         function getTypeArgumentsForAliasSymbol(symbol) {
47349             return symbol ? getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(symbol) : undefined;
47350         }
47351         function isNonGenericObjectType(type) {
47352             return !!(type.flags & 524288) && !isGenericMappedType(type);
47353         }
47354         function isEmptyObjectTypeOrSpreadsIntoEmptyObject(type) {
47355             return isEmptyObjectType(type) || !!(type.flags & (65536 | 32768 | 528 | 296 | 2112 | 402653316 | 1056 | 67108864 | 4194304));
47356         }
47357         function tryMergeUnionOfObjectTypeAndEmptyObject(type, readonly) {
47358             if (ts.every(type.types, isEmptyObjectTypeOrSpreadsIntoEmptyObject)) {
47359                 return ts.find(type.types, isEmptyObjectType) || emptyObjectType;
47360             }
47361             var firstType = ts.find(type.types, function (t) { return !isEmptyObjectTypeOrSpreadsIntoEmptyObject(t); });
47362             if (!firstType) {
47363                 return undefined;
47364             }
47365             var secondType = firstType && ts.find(type.types, function (t) { return t !== firstType && !isEmptyObjectTypeOrSpreadsIntoEmptyObject(t); });
47366             if (secondType) {
47367                 return undefined;
47368             }
47369             return getAnonymousPartialType(firstType);
47370             function getAnonymousPartialType(type) {
47371                 var members = ts.createSymbolTable();
47372                 for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
47373                     var prop = _a[_i];
47374                     if (ts.getDeclarationModifierFlagsFromSymbol(prop) & (8 | 16)) {
47375                     }
47376                     else if (isSpreadableProperty(prop)) {
47377                         var isSetonlyAccessor = prop.flags & 65536 && !(prop.flags & 32768);
47378                         var flags = 4 | 16777216;
47379                         var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 : 0));
47380                         result.type = isSetonlyAccessor ? undefinedType : getUnionType([getTypeOfSymbol(prop), undefinedType]);
47381                         result.declarations = prop.declarations;
47382                         result.nameType = getSymbolLinks(prop).nameType;
47383                         result.syntheticOrigin = prop;
47384                         members.set(prop.escapedName, result);
47385                     }
47386                 }
47387                 var spread = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoOfType(type, 0), getIndexInfoOfType(type, 1));
47388                 spread.objectFlags |= 128 | 1048576;
47389                 return spread;
47390             }
47391         }
47392         function getSpreadType(left, right, symbol, objectFlags, readonly) {
47393             if (left.flags & 1 || right.flags & 1) {
47394                 return anyType;
47395             }
47396             if (left.flags & 2 || right.flags & 2) {
47397                 return unknownType;
47398             }
47399             if (left.flags & 131072) {
47400                 return right;
47401             }
47402             if (right.flags & 131072) {
47403                 return left;
47404             }
47405             if (left.flags & 1048576) {
47406                 var merged = tryMergeUnionOfObjectTypeAndEmptyObject(left, readonly);
47407                 if (merged) {
47408                     return getSpreadType(merged, right, symbol, objectFlags, readonly);
47409                 }
47410                 return checkCrossProductUnion([left, right])
47411                     ? mapType(left, function (t) { return getSpreadType(t, right, symbol, objectFlags, readonly); })
47412                     : errorType;
47413             }
47414             if (right.flags & 1048576) {
47415                 var merged = tryMergeUnionOfObjectTypeAndEmptyObject(right, readonly);
47416                 if (merged) {
47417                     return getSpreadType(left, merged, symbol, objectFlags, readonly);
47418                 }
47419                 return checkCrossProductUnion([left, right])
47420                     ? mapType(right, function (t) { return getSpreadType(left, t, symbol, objectFlags, readonly); })
47421                     : errorType;
47422             }
47423             if (right.flags & (528 | 296 | 2112 | 402653316 | 1056 | 67108864 | 4194304)) {
47424                 return left;
47425             }
47426             if (isGenericObjectType(left) || isGenericObjectType(right)) {
47427                 if (isEmptyObjectType(left)) {
47428                     return right;
47429                 }
47430                 if (left.flags & 2097152) {
47431                     var types = left.types;
47432                     var lastLeft = types[types.length - 1];
47433                     if (isNonGenericObjectType(lastLeft) && isNonGenericObjectType(right)) {
47434                         return getIntersectionType(ts.concatenate(types.slice(0, types.length - 1), [getSpreadType(lastLeft, right, symbol, objectFlags, readonly)]));
47435                     }
47436                 }
47437                 return getIntersectionType([left, right]);
47438             }
47439             var members = ts.createSymbolTable();
47440             var skippedPrivateMembers = new ts.Set();
47441             var stringIndexInfo;
47442             var numberIndexInfo;
47443             if (left === emptyObjectType) {
47444                 stringIndexInfo = getIndexInfoOfType(right, 0);
47445                 numberIndexInfo = getIndexInfoOfType(right, 1);
47446             }
47447             else {
47448                 stringIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 0), getIndexInfoOfType(right, 0));
47449                 numberIndexInfo = unionSpreadIndexInfos(getIndexInfoOfType(left, 1), getIndexInfoOfType(right, 1));
47450             }
47451             for (var _i = 0, _a = getPropertiesOfType(right); _i < _a.length; _i++) {
47452                 var rightProp = _a[_i];
47453                 if (ts.getDeclarationModifierFlagsFromSymbol(rightProp) & (8 | 16)) {
47454                     skippedPrivateMembers.add(rightProp.escapedName);
47455                 }
47456                 else if (isSpreadableProperty(rightProp)) {
47457                     members.set(rightProp.escapedName, getSpreadSymbol(rightProp, readonly));
47458                 }
47459             }
47460             for (var _b = 0, _c = getPropertiesOfType(left); _b < _c.length; _b++) {
47461                 var leftProp = _c[_b];
47462                 if (skippedPrivateMembers.has(leftProp.escapedName) || !isSpreadableProperty(leftProp)) {
47463                     continue;
47464                 }
47465                 if (members.has(leftProp.escapedName)) {
47466                     var rightProp = members.get(leftProp.escapedName);
47467                     var rightType = getTypeOfSymbol(rightProp);
47468                     if (rightProp.flags & 16777216) {
47469                         var declarations = ts.concatenate(leftProp.declarations, rightProp.declarations);
47470                         var flags = 4 | (leftProp.flags & 16777216);
47471                         var result = createSymbol(flags, leftProp.escapedName);
47472                         result.type = getUnionType([getTypeOfSymbol(leftProp), getTypeWithFacts(rightType, 524288)]);
47473                         result.leftSpread = leftProp;
47474                         result.rightSpread = rightProp;
47475                         result.declarations = declarations;
47476                         result.nameType = getSymbolLinks(leftProp).nameType;
47477                         members.set(leftProp.escapedName, result);
47478                     }
47479                 }
47480                 else {
47481                     members.set(leftProp.escapedName, getSpreadSymbol(leftProp, readonly));
47482                 }
47483             }
47484             var spread = createAnonymousType(symbol, members, ts.emptyArray, ts.emptyArray, getIndexInfoWithReadonly(stringIndexInfo, readonly), getIndexInfoWithReadonly(numberIndexInfo, readonly));
47485             spread.objectFlags |= 128 | 1048576 | 1024 | objectFlags;
47486             return spread;
47487         }
47488         function isSpreadableProperty(prop) {
47489             return !ts.some(prop.declarations, ts.isPrivateIdentifierPropertyDeclaration) &&
47490                 (!(prop.flags & (8192 | 32768 | 65536)) ||
47491                     !prop.declarations.some(function (decl) { return ts.isClassLike(decl.parent); }));
47492         }
47493         function getSpreadSymbol(prop, readonly) {
47494             var isSetonlyAccessor = prop.flags & 65536 && !(prop.flags & 32768);
47495             if (!isSetonlyAccessor && readonly === isReadonlySymbol(prop)) {
47496                 return prop;
47497             }
47498             var flags = 4 | (prop.flags & 16777216);
47499             var result = createSymbol(flags, prop.escapedName, getIsLateCheckFlag(prop) | (readonly ? 8 : 0));
47500             result.type = isSetonlyAccessor ? undefinedType : getTypeOfSymbol(prop);
47501             result.declarations = prop.declarations;
47502             result.nameType = getSymbolLinks(prop).nameType;
47503             result.syntheticOrigin = prop;
47504             return result;
47505         }
47506         function getIndexInfoWithReadonly(info, readonly) {
47507             return info && info.isReadonly !== readonly ? createIndexInfo(info.type, readonly, info.declaration) : info;
47508         }
47509         function createLiteralType(flags, value, symbol) {
47510             var type = createType(flags);
47511             type.symbol = symbol;
47512             type.value = value;
47513             return type;
47514         }
47515         function getFreshTypeOfLiteralType(type) {
47516             if (type.flags & 2944) {
47517                 if (!type.freshType) {
47518                     var freshType = createLiteralType(type.flags, type.value, type.symbol);
47519                     freshType.regularType = type;
47520                     freshType.freshType = freshType;
47521                     type.freshType = freshType;
47522                 }
47523                 return type.freshType;
47524             }
47525             return type;
47526         }
47527         function getRegularTypeOfLiteralType(type) {
47528             return type.flags & 2944 ? type.regularType :
47529                 type.flags & 1048576 ? (type.regularType || (type.regularType = mapType(type, getRegularTypeOfLiteralType))) :
47530                     type;
47531         }
47532         function isFreshLiteralType(type) {
47533             return !!(type.flags & 2944) && type.freshType === type;
47534         }
47535         function getLiteralType(value, enumId, symbol) {
47536             var qualifier = typeof value === "number" ? "#" : typeof value === "string" ? "@" : "n";
47537             var key = (enumId ? enumId : "") + qualifier + (typeof value === "object" ? ts.pseudoBigIntToString(value) : value);
47538             var type = literalTypes.get(key);
47539             if (!type) {
47540                 var flags = (typeof value === "number" ? 256 :
47541                     typeof value === "string" ? 128 : 2048) |
47542                     (enumId ? 1024 : 0);
47543                 literalTypes.set(key, type = createLiteralType(flags, value, symbol));
47544                 type.regularType = type;
47545             }
47546             return type;
47547         }
47548         function getTypeFromLiteralTypeNode(node) {
47549             if (node.literal.kind === 103) {
47550                 return nullType;
47551             }
47552             var links = getNodeLinks(node);
47553             if (!links.resolvedType) {
47554                 links.resolvedType = getRegularTypeOfLiteralType(checkExpression(node.literal));
47555             }
47556             return links.resolvedType;
47557         }
47558         function createUniqueESSymbolType(symbol) {
47559             var type = createType(8192);
47560             type.symbol = symbol;
47561             type.escapedName = "__@" + type.symbol.escapedName + "@" + getSymbolId(type.symbol);
47562             return type;
47563         }
47564         function getESSymbolLikeTypeForNode(node) {
47565             if (ts.isValidESSymbolDeclaration(node)) {
47566                 var symbol = getSymbolOfNode(node);
47567                 var links = getSymbolLinks(symbol);
47568                 return links.uniqueESSymbolType || (links.uniqueESSymbolType = createUniqueESSymbolType(symbol));
47569             }
47570             return esSymbolType;
47571         }
47572         function getThisType(node) {
47573             var container = ts.getThisContainer(node, false);
47574             var parent = container && container.parent;
47575             if (parent && (ts.isClassLike(parent) || parent.kind === 253)) {
47576                 if (!ts.hasSyntacticModifier(container, 32) &&
47577                     (!ts.isConstructorDeclaration(container) || ts.isNodeDescendantOf(node, container.body))) {
47578                     return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent)).thisType;
47579                 }
47580             }
47581             if (parent && ts.isObjectLiteralExpression(parent) && ts.isBinaryExpression(parent.parent) && ts.getAssignmentDeclarationKind(parent.parent) === 6) {
47582                 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(parent.parent.left).parent).thisType;
47583             }
47584             var host = node.flags & 4194304 ? ts.getHostSignatureFromJSDoc(node) : undefined;
47585             if (host && ts.isFunctionExpression(host) && ts.isBinaryExpression(host.parent) && ts.getAssignmentDeclarationKind(host.parent) === 3) {
47586                 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(host.parent.left).parent).thisType;
47587             }
47588             if (isJSConstructor(container) && ts.isNodeDescendantOf(node, container.body)) {
47589                 return getDeclaredTypeOfClassOrInterface(getSymbolOfNode(container)).thisType;
47590             }
47591             error(node, ts.Diagnostics.A_this_type_is_available_only_in_a_non_static_member_of_a_class_or_interface);
47592             return errorType;
47593         }
47594         function getTypeFromThisTypeNode(node) {
47595             var links = getNodeLinks(node);
47596             if (!links.resolvedType) {
47597                 links.resolvedType = getThisType(node);
47598             }
47599             return links.resolvedType;
47600         }
47601         function getTypeFromRestTypeNode(node) {
47602             return getTypeFromTypeNode(getArrayElementTypeNode(node.type) || node.type);
47603         }
47604         function getArrayElementTypeNode(node) {
47605             switch (node.kind) {
47606                 case 186:
47607                     return getArrayElementTypeNode(node.type);
47608                 case 179:
47609                     if (node.elements.length === 1) {
47610                         node = node.elements[0];
47611                         if (node.kind === 181 || node.kind === 192 && node.dotDotDotToken) {
47612                             return getArrayElementTypeNode(node.type);
47613                         }
47614                     }
47615                     break;
47616                 case 178:
47617                     return node.elementType;
47618             }
47619             return undefined;
47620         }
47621         function getTypeFromNamedTupleTypeNode(node) {
47622             var links = getNodeLinks(node);
47623             return links.resolvedType || (links.resolvedType =
47624                 node.dotDotDotToken ? getTypeFromRestTypeNode(node) :
47625                     node.questionToken && strictNullChecks ? getOptionalType(getTypeFromTypeNode(node.type)) :
47626                         getTypeFromTypeNode(node.type));
47627         }
47628         function getTypeFromTypeNode(node) {
47629             return getConditionalFlowTypeOfType(getTypeFromTypeNodeWorker(node), node);
47630         }
47631         function getTypeFromTypeNodeWorker(node) {
47632             switch (node.kind) {
47633                 case 128:
47634                 case 303:
47635                 case 304:
47636                     return anyType;
47637                 case 152:
47638                     return unknownType;
47639                 case 147:
47640                     return stringType;
47641                 case 144:
47642                     return numberType;
47643                 case 155:
47644                     return bigintType;
47645                 case 131:
47646                     return booleanType;
47647                 case 148:
47648                     return esSymbolType;
47649                 case 113:
47650                     return voidType;
47651                 case 150:
47652                     return undefinedType;
47653                 case 103:
47654                     return nullType;
47655                 case 141:
47656                     return neverType;
47657                 case 145:
47658                     return node.flags & 131072 && !noImplicitAny ? anyType : nonPrimitiveType;
47659                 case 136:
47660                     return intrinsicMarkerType;
47661                 case 187:
47662                 case 107:
47663                     return getTypeFromThisTypeNode(node);
47664                 case 191:
47665                     return getTypeFromLiteralTypeNode(node);
47666                 case 173:
47667                     return getTypeFromTypeReference(node);
47668                 case 172:
47669                     return node.assertsModifier ? voidType : booleanType;
47670                 case 223:
47671                     return getTypeFromTypeReference(node);
47672                 case 176:
47673                     return getTypeFromTypeQueryNode(node);
47674                 case 178:
47675                 case 179:
47676                     return getTypeFromArrayOrTupleTypeNode(node);
47677                 case 180:
47678                     return getTypeFromOptionalTypeNode(node);
47679                 case 182:
47680                     return getTypeFromUnionTypeNode(node);
47681                 case 183:
47682                     return getTypeFromIntersectionTypeNode(node);
47683                 case 305:
47684                     return getTypeFromJSDocNullableTypeNode(node);
47685                 case 307:
47686                     return addOptionality(getTypeFromTypeNode(node.type));
47687                 case 192:
47688                     return getTypeFromNamedTupleTypeNode(node);
47689                 case 186:
47690                 case 306:
47691                 case 301:
47692                     return getTypeFromTypeNode(node.type);
47693                 case 181:
47694                     return getTypeFromRestTypeNode(node);
47695                 case 309:
47696                     return getTypeFromJSDocVariadicType(node);
47697                 case 174:
47698                 case 175:
47699                 case 177:
47700                 case 312:
47701                 case 308:
47702                 case 313:
47703                     return getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
47704                 case 188:
47705                     return getTypeFromTypeOperatorNode(node);
47706                 case 189:
47707                     return getTypeFromIndexedAccessTypeNode(node);
47708                 case 190:
47709                     return getTypeFromMappedTypeNode(node);
47710                 case 184:
47711                     return getTypeFromConditionalTypeNode(node);
47712                 case 185:
47713                     return getTypeFromInferTypeNode(node);
47714                 case 193:
47715                     return getTypeFromTemplateTypeNode(node);
47716                 case 195:
47717                     return getTypeFromImportTypeNode(node);
47718                 case 78:
47719                 case 157:
47720                 case 201:
47721                     var symbol = getSymbolAtLocation(node);
47722                     return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
47723                 default:
47724                     return errorType;
47725             }
47726         }
47727         function instantiateList(items, mapper, instantiator) {
47728             if (items && items.length) {
47729                 for (var i = 0; i < items.length; i++) {
47730                     var item = items[i];
47731                     var mapped = instantiator(item, mapper);
47732                     if (item !== mapped) {
47733                         var result = i === 0 ? [] : items.slice(0, i);
47734                         result.push(mapped);
47735                         for (i++; i < items.length; i++) {
47736                             result.push(instantiator(items[i], mapper));
47737                         }
47738                         return result;
47739                     }
47740                 }
47741             }
47742             return items;
47743         }
47744         function instantiateTypes(types, mapper) {
47745             return instantiateList(types, mapper, instantiateType);
47746         }
47747         function instantiateSignatures(signatures, mapper) {
47748             return instantiateList(signatures, mapper, instantiateSignature);
47749         }
47750         function createTypeMapper(sources, targets) {
47751             return sources.length === 1 ? makeUnaryTypeMapper(sources[0], targets ? targets[0] : anyType) : makeArrayTypeMapper(sources, targets);
47752         }
47753         function getMappedType(type, mapper) {
47754             switch (mapper.kind) {
47755                 case 0:
47756                     return type === mapper.source ? mapper.target : type;
47757                 case 1:
47758                     var sources = mapper.sources;
47759                     var targets = mapper.targets;
47760                     for (var i = 0; i < sources.length; i++) {
47761                         if (type === sources[i]) {
47762                             return targets ? targets[i] : anyType;
47763                         }
47764                     }
47765                     return type;
47766                 case 2:
47767                     return mapper.func(type);
47768                 case 3:
47769                 case 4:
47770                     var t1 = getMappedType(type, mapper.mapper1);
47771                     return t1 !== type && mapper.kind === 3 ? instantiateType(t1, mapper.mapper2) : getMappedType(t1, mapper.mapper2);
47772             }
47773         }
47774         function makeUnaryTypeMapper(source, target) {
47775             return { kind: 0, source: source, target: target };
47776         }
47777         function makeArrayTypeMapper(sources, targets) {
47778             return { kind: 1, sources: sources, targets: targets };
47779         }
47780         function makeFunctionTypeMapper(func) {
47781             return { kind: 2, func: func };
47782         }
47783         function makeCompositeTypeMapper(kind, mapper1, mapper2) {
47784             return { kind: kind, mapper1: mapper1, mapper2: mapper2 };
47785         }
47786         function createTypeEraser(sources) {
47787             return createTypeMapper(sources, undefined);
47788         }
47789         function createBackreferenceMapper(context, index) {
47790             return makeFunctionTypeMapper(function (t) { return ts.findIndex(context.inferences, function (info) { return info.typeParameter === t; }) >= index ? unknownType : t; });
47791         }
47792         function combineTypeMappers(mapper1, mapper2) {
47793             return mapper1 ? makeCompositeTypeMapper(3, mapper1, mapper2) : mapper2;
47794         }
47795         function mergeTypeMappers(mapper1, mapper2) {
47796             return mapper1 ? makeCompositeTypeMapper(4, mapper1, mapper2) : mapper2;
47797         }
47798         function prependTypeMapping(source, target, mapper) {
47799             return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4, makeUnaryTypeMapper(source, target), mapper);
47800         }
47801         function appendTypeMapping(mapper, source, target) {
47802             return !mapper ? makeUnaryTypeMapper(source, target) : makeCompositeTypeMapper(4, mapper, makeUnaryTypeMapper(source, target));
47803         }
47804         function getRestrictiveTypeParameter(tp) {
47805             return tp.constraint === unknownType ? tp : tp.restrictiveInstantiation || (tp.restrictiveInstantiation = createTypeParameter(tp.symbol),
47806                 tp.restrictiveInstantiation.constraint = unknownType,
47807                 tp.restrictiveInstantiation);
47808         }
47809         function cloneTypeParameter(typeParameter) {
47810             var result = createTypeParameter(typeParameter.symbol);
47811             result.target = typeParameter;
47812             return result;
47813         }
47814         function instantiateTypePredicate(predicate, mapper) {
47815             return createTypePredicate(predicate.kind, predicate.parameterName, predicate.parameterIndex, instantiateType(predicate.type, mapper));
47816         }
47817         function instantiateSignature(signature, mapper, eraseTypeParameters) {
47818             var freshTypeParameters;
47819             if (signature.typeParameters && !eraseTypeParameters) {
47820                 freshTypeParameters = ts.map(signature.typeParameters, cloneTypeParameter);
47821                 mapper = combineTypeMappers(createTypeMapper(signature.typeParameters, freshTypeParameters), mapper);
47822                 for (var _i = 0, freshTypeParameters_1 = freshTypeParameters; _i < freshTypeParameters_1.length; _i++) {
47823                     var tp = freshTypeParameters_1[_i];
47824                     tp.mapper = mapper;
47825                 }
47826             }
47827             var result = createSignature(signature.declaration, freshTypeParameters, signature.thisParameter && instantiateSymbol(signature.thisParameter, mapper), instantiateList(signature.parameters, mapper, instantiateSymbol), undefined, undefined, signature.minArgumentCount, signature.flags & 39);
47828             result.target = signature;
47829             result.mapper = mapper;
47830             return result;
47831         }
47832         function instantiateSymbol(symbol, mapper) {
47833             var links = getSymbolLinks(symbol);
47834             if (links.type && !couldContainTypeVariables(links.type)) {
47835                 return symbol;
47836             }
47837             if (ts.getCheckFlags(symbol) & 1) {
47838                 symbol = links.target;
47839                 mapper = combineTypeMappers(links.mapper, mapper);
47840             }
47841             var result = createSymbol(symbol.flags, symbol.escapedName, 1 | ts.getCheckFlags(symbol) & (8 | 4096 | 16384 | 32768));
47842             result.declarations = symbol.declarations;
47843             result.parent = symbol.parent;
47844             result.target = symbol;
47845             result.mapper = mapper;
47846             if (symbol.valueDeclaration) {
47847                 result.valueDeclaration = symbol.valueDeclaration;
47848             }
47849             if (links.nameType) {
47850                 result.nameType = links.nameType;
47851             }
47852             return result;
47853         }
47854         function getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
47855             var declaration = type.objectFlags & 4 ? type.node : type.symbol.declarations[0];
47856             var links = getNodeLinks(declaration);
47857             var target = type.objectFlags & 4 ? links.resolvedType :
47858                 type.objectFlags & 64 ? type.target : type;
47859             var typeParameters = links.outerTypeParameters;
47860             if (!typeParameters) {
47861                 var outerTypeParameters = getOuterTypeParameters(declaration, true);
47862                 if (isJSConstructor(declaration)) {
47863                     var templateTagParameters = getTypeParametersFromDeclaration(declaration);
47864                     outerTypeParameters = ts.addRange(outerTypeParameters, templateTagParameters);
47865                 }
47866                 typeParameters = outerTypeParameters || ts.emptyArray;
47867                 typeParameters = (target.objectFlags & 4 || target.symbol.flags & 2048) && !target.aliasTypeArguments ?
47868                     ts.filter(typeParameters, function (tp) { return isTypeParameterPossiblyReferenced(tp, declaration); }) :
47869                     typeParameters;
47870                 links.outerTypeParameters = typeParameters;
47871             }
47872             if (typeParameters.length) {
47873                 var combinedMapper_1 = combineTypeMappers(type.mapper, mapper);
47874                 var typeArguments = ts.map(typeParameters, function (t) { return getMappedType(t, combinedMapper_1); });
47875                 var newAliasSymbol = aliasSymbol || type.aliasSymbol;
47876                 var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
47877                 var id = getTypeListId(typeArguments) + getAliasId(newAliasSymbol, newAliasTypeArguments);
47878                 if (!target.instantiations) {
47879                     target.instantiations = new ts.Map();
47880                     target.instantiations.set(getTypeListId(typeParameters) + getAliasId(target.aliasSymbol, target.aliasTypeArguments), target);
47881                 }
47882                 var result = target.instantiations.get(id);
47883                 if (!result) {
47884                     var newMapper = createTypeMapper(typeParameters, typeArguments);
47885                     result = target.objectFlags & 4 ? createDeferredTypeReference(type.target, type.node, newMapper, newAliasSymbol, newAliasTypeArguments) :
47886                         target.objectFlags & 32 ? instantiateMappedType(target, newMapper, newAliasSymbol, newAliasTypeArguments) :
47887                             instantiateAnonymousType(target, newMapper, newAliasSymbol, newAliasTypeArguments);
47888                     target.instantiations.set(id, result);
47889                 }
47890                 return result;
47891             }
47892             return type;
47893         }
47894         function maybeTypeParameterReference(node) {
47895             return !(node.kind === 157 ||
47896                 node.parent.kind === 173 && node.parent.typeArguments && node === node.parent.typeName ||
47897                 node.parent.kind === 195 && node.parent.typeArguments && node === node.parent.qualifier);
47898         }
47899         function isTypeParameterPossiblyReferenced(tp, node) {
47900             if (tp.symbol && tp.symbol.declarations && tp.symbol.declarations.length === 1) {
47901                 var container = tp.symbol.declarations[0].parent;
47902                 for (var n = node; n !== container; n = n.parent) {
47903                     if (!n || n.kind === 230 || n.kind === 184 && ts.forEachChild(n.extendsType, containsReference)) {
47904                         return true;
47905                     }
47906                 }
47907                 return !!ts.forEachChild(node, containsReference);
47908             }
47909             return true;
47910             function containsReference(node) {
47911                 switch (node.kind) {
47912                     case 187:
47913                         return !!tp.isThisType;
47914                     case 78:
47915                         return !tp.isThisType && ts.isPartOfTypeNode(node) && maybeTypeParameterReference(node) &&
47916                             getTypeFromTypeNodeWorker(node) === tp;
47917                     case 176:
47918                         return true;
47919                 }
47920                 return !!ts.forEachChild(node, containsReference);
47921             }
47922         }
47923         function getHomomorphicTypeVariable(type) {
47924             var constraintType = getConstraintTypeFromMappedType(type);
47925             if (constraintType.flags & 4194304) {
47926                 var typeVariable = getActualTypeVariable(constraintType.type);
47927                 if (typeVariable.flags & 262144) {
47928                     return typeVariable;
47929                 }
47930             }
47931             return undefined;
47932         }
47933         function instantiateMappedType(type, mapper, aliasSymbol, aliasTypeArguments) {
47934             var typeVariable = getHomomorphicTypeVariable(type);
47935             if (typeVariable) {
47936                 var mappedTypeVariable = instantiateType(typeVariable, mapper);
47937                 if (typeVariable !== mappedTypeVariable) {
47938                     return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) {
47939                         if (t.flags & (3 | 58982400 | 524288 | 2097152) && t !== wildcardType && t !== errorType) {
47940                             if (!type.declaration.nameType) {
47941                                 if (isArrayType(t)) {
47942                                     return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
47943                                 }
47944                                 if (isGenericTupleType(t)) {
47945                                     return instantiateMappedGenericTupleType(t, type, typeVariable, mapper);
47946                                 }
47947                                 if (isTupleType(t)) {
47948                                     return instantiateMappedTupleType(t, type, prependTypeMapping(typeVariable, t, mapper));
47949                                 }
47950                             }
47951                             return instantiateAnonymousType(type, prependTypeMapping(typeVariable, t, mapper));
47952                         }
47953                         return t;
47954                     }, aliasSymbol, aliasTypeArguments);
47955                 }
47956             }
47957             return instantiateType(getConstraintTypeFromMappedType(type), mapper) === wildcardType ? wildcardType : instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments);
47958         }
47959         function getModifiedReadonlyState(state, modifiers) {
47960             return modifiers & 1 ? true : modifiers & 2 ? false : state;
47961         }
47962         function instantiateMappedGenericTupleType(tupleType, mappedType, typeVariable, mapper) {
47963             var elementFlags = tupleType.target.elementFlags;
47964             var elementTypes = ts.map(getTypeArguments(tupleType), function (t, i) {
47965                 var singleton = elementFlags[i] & 8 ? t :
47966                     elementFlags[i] & 4 ? createArrayType(t) :
47967                         createTupleType([t], [elementFlags[i]]);
47968                 return instantiateMappedType(mappedType, prependTypeMapping(typeVariable, singleton, mapper));
47969             });
47970             var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, getMappedTypeModifiers(mappedType));
47971             return createTupleType(elementTypes, ts.map(elementTypes, function (_) { return 8; }), newReadonly);
47972         }
47973         function instantiateMappedArrayType(arrayType, mappedType, mapper) {
47974             var elementType = instantiateMappedTypeTemplate(mappedType, numberType, true, mapper);
47975             return elementType === errorType ? errorType :
47976                 createArrayType(elementType, getModifiedReadonlyState(isReadonlyArrayType(arrayType), getMappedTypeModifiers(mappedType)));
47977         }
47978         function instantiateMappedTupleType(tupleType, mappedType, mapper) {
47979             var elementFlags = tupleType.target.elementFlags;
47980             var elementTypes = ts.map(getTypeArguments(tupleType), function (_, i) {
47981                 return instantiateMappedTypeTemplate(mappedType, getLiteralType("" + i), !!(elementFlags[i] & 2), mapper);
47982             });
47983             var modifiers = getMappedTypeModifiers(mappedType);
47984             var newTupleModifiers = modifiers & 4 ? ts.map(elementFlags, function (f) { return f & 1 ? 2 : f; }) :
47985                 modifiers & 8 ? ts.map(elementFlags, function (f) { return f & 2 ? 1 : f; }) :
47986                     elementFlags;
47987             var newReadonly = getModifiedReadonlyState(tupleType.target.readonly, modifiers);
47988             return ts.contains(elementTypes, errorType) ? errorType :
47989                 createTupleType(elementTypes, newTupleModifiers, newReadonly, tupleType.target.labeledElementDeclarations);
47990         }
47991         function instantiateMappedTypeTemplate(type, key, isOptional, mapper) {
47992             var templateMapper = appendTypeMapping(mapper, getTypeParameterFromMappedType(type), key);
47993             var propType = instantiateType(getTemplateTypeFromMappedType(type.target || type), templateMapper);
47994             var modifiers = getMappedTypeModifiers(type);
47995             return strictNullChecks && modifiers & 4 && !maybeTypeOfKind(propType, 32768 | 16384) ? getOptionalType(propType) :
47996                 strictNullChecks && modifiers & 8 && isOptional ? getTypeWithFacts(propType, 524288) :
47997                     propType;
47998         }
47999         function instantiateAnonymousType(type, mapper, aliasSymbol, aliasTypeArguments) {
48000             var result = createObjectType(type.objectFlags | 64, type.symbol);
48001             if (type.objectFlags & 32) {
48002                 result.declaration = type.declaration;
48003                 var origTypeParameter = getTypeParameterFromMappedType(type);
48004                 var freshTypeParameter = cloneTypeParameter(origTypeParameter);
48005                 result.typeParameter = freshTypeParameter;
48006                 mapper = combineTypeMappers(makeUnaryTypeMapper(origTypeParameter, freshTypeParameter), mapper);
48007                 freshTypeParameter.mapper = mapper;
48008             }
48009             result.target = type;
48010             result.mapper = mapper;
48011             result.aliasSymbol = aliasSymbol || type.aliasSymbol;
48012             result.aliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
48013             return result;
48014         }
48015         function getConditionalTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments) {
48016             var root = type.root;
48017             if (root.outerTypeParameters) {
48018                 var typeArguments = ts.map(root.outerTypeParameters, function (t) { return getMappedType(t, mapper); });
48019                 var id = getTypeListId(typeArguments) + getAliasId(aliasSymbol, aliasTypeArguments);
48020                 var result = root.instantiations.get(id);
48021                 if (!result) {
48022                     var newMapper = createTypeMapper(root.outerTypeParameters, typeArguments);
48023                     result = instantiateConditionalType(root, newMapper, aliasSymbol, aliasTypeArguments);
48024                     root.instantiations.set(id, result);
48025                 }
48026                 return result;
48027             }
48028             return type;
48029         }
48030         function instantiateConditionalType(root, mapper, aliasSymbol, aliasTypeArguments) {
48031             if (root.isDistributive) {
48032                 var checkType_1 = root.checkType;
48033                 var instantiatedType = getMappedType(checkType_1, mapper);
48034                 if (checkType_1 !== instantiatedType && instantiatedType.flags & (1048576 | 131072)) {
48035                     return mapTypeWithAlias(instantiatedType, function (t) { return getConditionalType(root, prependTypeMapping(checkType_1, t, mapper)); }, aliasSymbol, aliasTypeArguments);
48036                 }
48037             }
48038             return getConditionalType(root, mapper, aliasSymbol, aliasTypeArguments);
48039         }
48040         function instantiateType(type, mapper) {
48041             return type && mapper ? instantiateTypeWithAlias(type, mapper, undefined, undefined) : type;
48042         }
48043         function instantiateTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
48044             if (!couldContainTypeVariables(type)) {
48045                 return type;
48046             }
48047             if (instantiationDepth === 50 || instantiationCount >= 5000000) {
48048                 ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes", "instantiateType_DepthLimit", { typeId: type.id, instantiationDepth: instantiationDepth, instantiationCount: instantiationCount });
48049                 error(currentNode, ts.Diagnostics.Type_instantiation_is_excessively_deep_and_possibly_infinite);
48050                 return errorType;
48051             }
48052             totalInstantiationCount++;
48053             instantiationCount++;
48054             instantiationDepth++;
48055             var result = instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments);
48056             instantiationDepth--;
48057             return result;
48058         }
48059         function instantiateTypeWorker(type, mapper, aliasSymbol, aliasTypeArguments) {
48060             var flags = type.flags;
48061             if (flags & 262144) {
48062                 return getMappedType(type, mapper);
48063             }
48064             if (flags & 524288) {
48065                 var objectFlags = type.objectFlags;
48066                 if (objectFlags & (4 | 16 | 32)) {
48067                     if (objectFlags & 4 && !type.node) {
48068                         var resolvedTypeArguments = type.resolvedTypeArguments;
48069                         var newTypeArguments = instantiateTypes(resolvedTypeArguments, mapper);
48070                         return newTypeArguments !== resolvedTypeArguments ? createNormalizedTypeReference(type.target, newTypeArguments) : type;
48071                     }
48072                     return getObjectTypeInstantiation(type, mapper, aliasSymbol, aliasTypeArguments);
48073                 }
48074                 return type;
48075             }
48076             if (flags & 3145728) {
48077                 var origin = type.flags & 1048576 ? type.origin : undefined;
48078                 var types = origin && origin.flags & 3145728 ? origin.types : type.types;
48079                 var newTypes = instantiateTypes(types, mapper);
48080                 if (newTypes === types && aliasSymbol === type.aliasSymbol) {
48081                     return type;
48082                 }
48083                 var newAliasSymbol = aliasSymbol || type.aliasSymbol;
48084                 var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
48085                 return flags & 2097152 || origin && origin.flags & 2097152 ?
48086                     getIntersectionType(newTypes, newAliasSymbol, newAliasTypeArguments) :
48087                     getUnionType(newTypes, 1, newAliasSymbol, newAliasTypeArguments);
48088             }
48089             if (flags & 4194304) {
48090                 return getIndexType(instantiateType(type.type, mapper));
48091             }
48092             if (flags & 134217728) {
48093                 return getTemplateLiteralType(type.texts, instantiateTypes(type.types, mapper));
48094             }
48095             if (flags & 268435456) {
48096                 return getStringMappingType(type.symbol, instantiateType(type.type, mapper));
48097             }
48098             if (flags & 8388608) {
48099                 var newAliasSymbol = aliasSymbol || type.aliasSymbol;
48100                 var newAliasTypeArguments = aliasSymbol ? aliasTypeArguments : instantiateTypes(type.aliasTypeArguments, mapper);
48101                 return getIndexedAccessType(instantiateType(type.objectType, mapper), instantiateType(type.indexType, mapper), type.noUncheckedIndexedAccessCandidate, undefined, newAliasSymbol, newAliasTypeArguments);
48102             }
48103             if (flags & 16777216) {
48104                 return getConditionalTypeInstantiation(type, combineTypeMappers(type.mapper, mapper), aliasSymbol, aliasTypeArguments);
48105             }
48106             if (flags & 33554432) {
48107                 var maybeVariable = instantiateType(type.baseType, mapper);
48108                 if (maybeVariable.flags & 8650752) {
48109                     return getSubstitutionType(maybeVariable, instantiateType(type.substitute, mapper));
48110                 }
48111                 else {
48112                     var sub = instantiateType(type.substitute, mapper);
48113                     if (sub.flags & 3 || isTypeAssignableTo(getRestrictiveInstantiation(maybeVariable), getRestrictiveInstantiation(sub))) {
48114                         return maybeVariable;
48115                     }
48116                     return sub;
48117                 }
48118             }
48119             return type;
48120         }
48121         function getPermissiveInstantiation(type) {
48122             return type.flags & (131068 | 3 | 131072) ? type :
48123                 type.permissiveInstantiation || (type.permissiveInstantiation = instantiateType(type, permissiveMapper));
48124         }
48125         function getRestrictiveInstantiation(type) {
48126             if (type.flags & (131068 | 3 | 131072)) {
48127                 return type;
48128             }
48129             if (type.restrictiveInstantiation) {
48130                 return type.restrictiveInstantiation;
48131             }
48132             type.restrictiveInstantiation = instantiateType(type, restrictiveMapper);
48133             type.restrictiveInstantiation.restrictiveInstantiation = type.restrictiveInstantiation;
48134             return type.restrictiveInstantiation;
48135         }
48136         function instantiateIndexInfo(info, mapper) {
48137             return info && createIndexInfo(instantiateType(info.type, mapper), info.isReadonly, info.declaration);
48138         }
48139         function isContextSensitive(node) {
48140             ts.Debug.assert(node.kind !== 165 || ts.isObjectLiteralMethod(node));
48141             switch (node.kind) {
48142                 case 208:
48143                 case 209:
48144                 case 165:
48145                 case 251:
48146                     return isContextSensitiveFunctionLikeDeclaration(node);
48147                 case 200:
48148                     return ts.some(node.properties, isContextSensitive);
48149                 case 199:
48150                     return ts.some(node.elements, isContextSensitive);
48151                 case 217:
48152                     return isContextSensitive(node.whenTrue) ||
48153                         isContextSensitive(node.whenFalse);
48154                 case 216:
48155                     return (node.operatorToken.kind === 56 || node.operatorToken.kind === 60) &&
48156                         (isContextSensitive(node.left) || isContextSensitive(node.right));
48157                 case 288:
48158                     return isContextSensitive(node.initializer);
48159                 case 207:
48160                     return isContextSensitive(node.expression);
48161                 case 281:
48162                     return ts.some(node.properties, isContextSensitive) || ts.isJsxOpeningElement(node.parent) && ts.some(node.parent.parent.children, isContextSensitive);
48163                 case 280: {
48164                     var initializer = node.initializer;
48165                     return !!initializer && isContextSensitive(initializer);
48166                 }
48167                 case 283: {
48168                     var expression = node.expression;
48169                     return !!expression && isContextSensitive(expression);
48170                 }
48171             }
48172             return false;
48173         }
48174         function isContextSensitiveFunctionLikeDeclaration(node) {
48175             return (!ts.isFunctionDeclaration(node) || ts.isInJSFile(node) && !!getTypeForDeclarationFromJSDocComment(node)) &&
48176                 (hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node));
48177         }
48178         function hasContextSensitiveParameters(node) {
48179             if (!node.typeParameters) {
48180                 if (ts.some(node.parameters, function (p) { return !ts.getEffectiveTypeAnnotationNode(p); })) {
48181                     return true;
48182                 }
48183                 if (node.kind !== 209) {
48184                     var parameter = ts.firstOrUndefined(node.parameters);
48185                     if (!(parameter && ts.parameterIsThisKeyword(parameter))) {
48186                         return true;
48187                     }
48188                 }
48189             }
48190             return false;
48191         }
48192         function hasContextSensitiveReturnExpression(node) {
48193             return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 230 && isContextSensitive(node.body);
48194         }
48195         function isContextSensitiveFunctionOrObjectLiteralMethod(func) {
48196             return (ts.isInJSFile(func) && ts.isFunctionDeclaration(func) || isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
48197                 isContextSensitiveFunctionLikeDeclaration(func);
48198         }
48199         function getTypeWithoutSignatures(type) {
48200             if (type.flags & 524288) {
48201                 var resolved = resolveStructuredTypeMembers(type);
48202                 if (resolved.constructSignatures.length || resolved.callSignatures.length) {
48203                     var result = createObjectType(16, type.symbol);
48204                     result.members = resolved.members;
48205                     result.properties = resolved.properties;
48206                     result.callSignatures = ts.emptyArray;
48207                     result.constructSignatures = ts.emptyArray;
48208                     return result;
48209                 }
48210             }
48211             else if (type.flags & 2097152) {
48212                 return getIntersectionType(ts.map(type.types, getTypeWithoutSignatures));
48213             }
48214             return type;
48215         }
48216         function isTypeIdenticalTo(source, target) {
48217             return isTypeRelatedTo(source, target, identityRelation);
48218         }
48219         function compareTypesIdentical(source, target) {
48220             return isTypeRelatedTo(source, target, identityRelation) ? -1 : 0;
48221         }
48222         function compareTypesAssignable(source, target) {
48223             return isTypeRelatedTo(source, target, assignableRelation) ? -1 : 0;
48224         }
48225         function compareTypesSubtypeOf(source, target) {
48226             return isTypeRelatedTo(source, target, subtypeRelation) ? -1 : 0;
48227         }
48228         function isTypeSubtypeOf(source, target) {
48229             return isTypeRelatedTo(source, target, subtypeRelation);
48230         }
48231         function isTypeAssignableTo(source, target) {
48232             return isTypeRelatedTo(source, target, assignableRelation);
48233         }
48234         function isTypeDerivedFrom(source, target) {
48235             return source.flags & 1048576 ? ts.every(source.types, function (t) { return isTypeDerivedFrom(t, target); }) :
48236                 target.flags & 1048576 ? ts.some(target.types, function (t) { return isTypeDerivedFrom(source, t); }) :
48237                     source.flags & 58982400 ? isTypeDerivedFrom(getBaseConstraintOfType(source) || unknownType, target) :
48238                         target === globalObjectType ? !!(source.flags & (524288 | 67108864)) :
48239                             target === globalFunctionType ? !!(source.flags & 524288) && isFunctionObjectType(source) :
48240                                 hasBaseType(source, getTargetType(target)) || (isArrayType(target) && !isReadonlyArrayType(target) && isTypeDerivedFrom(source, globalReadonlyArrayType));
48241         }
48242         function isTypeComparableTo(source, target) {
48243             return isTypeRelatedTo(source, target, comparableRelation);
48244         }
48245         function areTypesComparable(type1, type2) {
48246             return isTypeComparableTo(type1, type2) || isTypeComparableTo(type2, type1);
48247         }
48248         function checkTypeAssignableTo(source, target, errorNode, headMessage, containingMessageChain, errorOutputObject) {
48249             return checkTypeRelatedTo(source, target, assignableRelation, errorNode, headMessage, containingMessageChain, errorOutputObject);
48250         }
48251         function checkTypeAssignableToAndOptionallyElaborate(source, target, errorNode, expr, headMessage, containingMessageChain) {
48252             return checkTypeRelatedToAndOptionallyElaborate(source, target, assignableRelation, errorNode, expr, headMessage, containingMessageChain, undefined);
48253         }
48254         function checkTypeRelatedToAndOptionallyElaborate(source, target, relation, errorNode, expr, headMessage, containingMessageChain, errorOutputContainer) {
48255             if (isTypeRelatedTo(source, target, relation))
48256                 return true;
48257             if (!errorNode || !elaborateError(expr, source, target, relation, headMessage, containingMessageChain, errorOutputContainer)) {
48258                 return checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer);
48259             }
48260             return false;
48261         }
48262         function isOrHasGenericConditional(type) {
48263             return !!(type.flags & 16777216 || (type.flags & 2097152 && ts.some(type.types, isOrHasGenericConditional)));
48264         }
48265         function elaborateError(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) {
48266             if (!node || isOrHasGenericConditional(target))
48267                 return false;
48268             if (!checkTypeRelatedTo(source, target, relation, undefined)
48269                 && elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer)) {
48270                 return true;
48271             }
48272             switch (node.kind) {
48273                 case 283:
48274                 case 207:
48275                     return elaborateError(node.expression, source, target, relation, headMessage, containingMessageChain, errorOutputContainer);
48276                 case 216:
48277                     switch (node.operatorToken.kind) {
48278                         case 62:
48279                         case 27:
48280                             return elaborateError(node.right, source, target, relation, headMessage, containingMessageChain, errorOutputContainer);
48281                     }
48282                     break;
48283                 case 200:
48284                     return elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer);
48285                 case 199:
48286                     return elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer);
48287                 case 281:
48288                     return elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer);
48289                 case 209:
48290                     return elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer);
48291             }
48292             return false;
48293         }
48294         function elaborateDidYouMeanToCallOrConstruct(node, source, target, relation, headMessage, containingMessageChain, errorOutputContainer) {
48295             var callSignatures = getSignaturesOfType(source, 0);
48296             var constructSignatures = getSignaturesOfType(source, 1);
48297             for (var _i = 0, _a = [constructSignatures, callSignatures]; _i < _a.length; _i++) {
48298                 var signatures = _a[_i];
48299                 if (ts.some(signatures, function (s) {
48300                     var returnType = getReturnTypeOfSignature(s);
48301                     return !(returnType.flags & (1 | 131072)) && checkTypeRelatedTo(returnType, target, relation, undefined);
48302                 })) {
48303                     var resultObj = errorOutputContainer || {};
48304                     checkTypeAssignableTo(source, target, node, headMessage, containingMessageChain, resultObj);
48305                     var diagnostic = resultObj.errors[resultObj.errors.length - 1];
48306                     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));
48307                     return true;
48308                 }
48309             }
48310             return false;
48311         }
48312         function elaborateArrowFunction(node, source, target, relation, containingMessageChain, errorOutputContainer) {
48313             if (ts.isBlock(node.body)) {
48314                 return false;
48315             }
48316             if (ts.some(node.parameters, ts.hasType)) {
48317                 return false;
48318             }
48319             var sourceSig = getSingleCallSignature(source);
48320             if (!sourceSig) {
48321                 return false;
48322             }
48323             var targetSignatures = getSignaturesOfType(target, 0);
48324             if (!ts.length(targetSignatures)) {
48325                 return false;
48326             }
48327             var returnExpression = node.body;
48328             var sourceReturn = getReturnTypeOfSignature(sourceSig);
48329             var targetReturn = getUnionType(ts.map(targetSignatures, getReturnTypeOfSignature));
48330             if (!checkTypeRelatedTo(sourceReturn, targetReturn, relation, undefined)) {
48331                 var elaborated = returnExpression && elaborateError(returnExpression, sourceReturn, targetReturn, relation, undefined, containingMessageChain, errorOutputContainer);
48332                 if (elaborated) {
48333                     return elaborated;
48334                 }
48335                 var resultObj = errorOutputContainer || {};
48336                 checkTypeRelatedTo(sourceReturn, targetReturn, relation, returnExpression, undefined, containingMessageChain, resultObj);
48337                 if (resultObj.errors) {
48338                     if (target.symbol && ts.length(target.symbol.declarations)) {
48339                         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));
48340                     }
48341                     if ((ts.getFunctionFlags(node) & 2) === 0
48342                         && !getTypeOfPropertyOfType(sourceReturn, "then")
48343                         && checkTypeRelatedTo(createPromiseType(sourceReturn), targetReturn, relation, undefined)) {
48344                         ts.addRelatedInfo(resultObj.errors[resultObj.errors.length - 1], ts.createDiagnosticForNode(node, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async));
48345                     }
48346                     return true;
48347                 }
48348             }
48349             return false;
48350         }
48351         function getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType) {
48352             var idx = getIndexedAccessTypeOrUndefined(target, nameType);
48353             if (idx) {
48354                 return idx;
48355             }
48356             if (target.flags & 1048576) {
48357                 var best = getBestMatchingType(source, target);
48358                 if (best) {
48359                     return getIndexedAccessTypeOrUndefined(best, nameType);
48360                 }
48361             }
48362         }
48363         function checkExpressionForMutableLocationWithContextualType(next, sourcePropType) {
48364             next.contextualType = sourcePropType;
48365             try {
48366                 return checkExpressionForMutableLocation(next, 1, sourcePropType);
48367             }
48368             finally {
48369                 next.contextualType = undefined;
48370             }
48371         }
48372         function elaborateElementwise(iterator, source, target, relation, containingMessageChain, errorOutputContainer) {
48373             var reportedError = false;
48374             for (var status = iterator.next(); !status.done; status = iterator.next()) {
48375                 var _a = status.value, prop = _a.errorNode, next = _a.innerExpression, nameType = _a.nameType, errorMessage = _a.errorMessage;
48376                 var targetPropType = getBestMatchIndexedAccessTypeOrUndefined(source, target, nameType);
48377                 if (!targetPropType || targetPropType.flags & 8388608)
48378                     continue;
48379                 var sourcePropType = getIndexedAccessTypeOrUndefined(source, nameType);
48380                 if (sourcePropType && !checkTypeRelatedTo(sourcePropType, targetPropType, relation, undefined)) {
48381                     var elaborated = next && elaborateError(next, sourcePropType, targetPropType, relation, undefined, containingMessageChain, errorOutputContainer);
48382                     if (elaborated) {
48383                         reportedError = true;
48384                     }
48385                     else {
48386                         var resultObj = errorOutputContainer || {};
48387                         var specificSource = next ? checkExpressionForMutableLocationWithContextualType(next, sourcePropType) : sourcePropType;
48388                         var result = checkTypeRelatedTo(specificSource, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj);
48389                         if (result && specificSource !== sourcePropType) {
48390                             checkTypeRelatedTo(sourcePropType, targetPropType, relation, prop, errorMessage, containingMessageChain, resultObj);
48391                         }
48392                         if (resultObj.errors) {
48393                             var reportedDiag = resultObj.errors[resultObj.errors.length - 1];
48394                             var propertyName = isTypeUsableAsPropertyName(nameType) ? getPropertyNameFromType(nameType) : undefined;
48395                             var targetProp = propertyName !== undefined ? getPropertyOfType(target, propertyName) : undefined;
48396                             var issuedElaboration = false;
48397                             if (!targetProp) {
48398                                 var indexInfo = isTypeAssignableToKind(nameType, 296) && getIndexInfoOfType(target, 1) ||
48399                                     getIndexInfoOfType(target, 0) ||
48400                                     undefined;
48401                                 if (indexInfo && indexInfo.declaration && !ts.getSourceFileOfNode(indexInfo.declaration).hasNoDefaultLib) {
48402                                     issuedElaboration = true;
48403                                     ts.addRelatedInfo(reportedDiag, ts.createDiagnosticForNode(indexInfo.declaration, ts.Diagnostics.The_expected_type_comes_from_this_index_signature));
48404                                 }
48405                             }
48406                             if (!issuedElaboration && (targetProp && ts.length(targetProp.declarations) || target.symbol && ts.length(target.symbol.declarations))) {
48407                                 var targetNode = targetProp && ts.length(targetProp.declarations) ? targetProp.declarations[0] : target.symbol.declarations[0];
48408                                 if (!ts.getSourceFileOfNode(targetNode).hasNoDefaultLib) {
48409                                     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)));
48410                                 }
48411                             }
48412                         }
48413                         reportedError = true;
48414                     }
48415                 }
48416             }
48417             return reportedError;
48418         }
48419         function generateJsxAttributes(node) {
48420             var _i, _a, prop;
48421             return __generator(this, function (_b) {
48422                 switch (_b.label) {
48423                     case 0:
48424                         if (!ts.length(node.properties))
48425                             return [2];
48426                         _i = 0, _a = node.properties;
48427                         _b.label = 1;
48428                     case 1:
48429                         if (!(_i < _a.length)) return [3, 4];
48430                         prop = _a[_i];
48431                         if (ts.isJsxSpreadAttribute(prop))
48432                             return [3, 3];
48433                         return [4, { errorNode: prop.name, innerExpression: prop.initializer, nameType: getLiteralType(ts.idText(prop.name)) }];
48434                     case 2:
48435                         _b.sent();
48436                         _b.label = 3;
48437                     case 3:
48438                         _i++;
48439                         return [3, 1];
48440                     case 4: return [2];
48441                 }
48442             });
48443         }
48444         function generateJsxChildren(node, getInvalidTextDiagnostic) {
48445             var memberOffset, i, child, nameType, elem;
48446             return __generator(this, function (_a) {
48447                 switch (_a.label) {
48448                     case 0:
48449                         if (!ts.length(node.children))
48450                             return [2];
48451                         memberOffset = 0;
48452                         i = 0;
48453                         _a.label = 1;
48454                     case 1:
48455                         if (!(i < node.children.length)) return [3, 5];
48456                         child = node.children[i];
48457                         nameType = getLiteralType(i - memberOffset);
48458                         elem = getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic);
48459                         if (!elem) return [3, 3];
48460                         return [4, elem];
48461                     case 2:
48462                         _a.sent();
48463                         return [3, 4];
48464                     case 3:
48465                         memberOffset++;
48466                         _a.label = 4;
48467                     case 4:
48468                         i++;
48469                         return [3, 1];
48470                     case 5: return [2];
48471                 }
48472             });
48473         }
48474         function getElaborationElementForJsxChild(child, nameType, getInvalidTextDiagnostic) {
48475             switch (child.kind) {
48476                 case 283:
48477                     return { errorNode: child, innerExpression: child.expression, nameType: nameType };
48478                 case 11:
48479                     if (child.containsOnlyTriviaWhiteSpaces) {
48480                         break;
48481                     }
48482                     return { errorNode: child, innerExpression: undefined, nameType: nameType, errorMessage: getInvalidTextDiagnostic() };
48483                 case 273:
48484                 case 274:
48485                 case 277:
48486                     return { errorNode: child, innerExpression: child, nameType: nameType };
48487                 default:
48488                     return ts.Debug.assertNever(child, "Found invalid jsx child");
48489             }
48490         }
48491         function elaborateJsxComponents(node, source, target, relation, containingMessageChain, errorOutputContainer) {
48492             var result = elaborateElementwise(generateJsxAttributes(node), source, target, relation, containingMessageChain, errorOutputContainer);
48493             var invalidTextDiagnostic;
48494             if (ts.isJsxOpeningElement(node.parent) && ts.isJsxElement(node.parent.parent)) {
48495                 var containingElement = node.parent.parent;
48496                 var childPropName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
48497                 var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName);
48498                 var childrenNameType = getLiteralType(childrenPropName);
48499                 var childrenTargetType = getIndexedAccessType(target, childrenNameType);
48500                 var validChildren = ts.getSemanticJsxChildren(containingElement.children);
48501                 if (!ts.length(validChildren)) {
48502                     return result;
48503                 }
48504                 var moreThanOneRealChildren = ts.length(validChildren) > 1;
48505                 var arrayLikeTargetParts = filterType(childrenTargetType, isArrayOrTupleLikeType);
48506                 var nonArrayLikeTargetParts = filterType(childrenTargetType, function (t) { return !isArrayOrTupleLikeType(t); });
48507                 if (moreThanOneRealChildren) {
48508                     if (arrayLikeTargetParts !== neverType) {
48509                         var realSource = createTupleType(checkJsxChildren(containingElement, 0));
48510                         var children = generateJsxChildren(containingElement, getInvalidTextualChildDiagnostic);
48511                         result = elaborateElementwise(children, realSource, arrayLikeTargetParts, relation, containingMessageChain, errorOutputContainer) || result;
48512                     }
48513                     else if (!isTypeRelatedTo(getIndexedAccessType(source, childrenNameType), childrenTargetType, relation)) {
48514                         result = true;
48515                         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));
48516                         if (errorOutputContainer && errorOutputContainer.skipLogging) {
48517                             (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
48518                         }
48519                     }
48520                 }
48521                 else {
48522                     if (nonArrayLikeTargetParts !== neverType) {
48523                         var child = validChildren[0];
48524                         var elem_1 = getElaborationElementForJsxChild(child, childrenNameType, getInvalidTextualChildDiagnostic);
48525                         if (elem_1) {
48526                             result = elaborateElementwise((function () { return __generator(this, function (_a) {
48527                                 switch (_a.label) {
48528                                     case 0: return [4, elem_1];
48529                                     case 1:
48530                                         _a.sent();
48531                                         return [2];
48532                                 }
48533                             }); })(), source, target, relation, containingMessageChain, errorOutputContainer) || result;
48534                         }
48535                     }
48536                     else if (!isTypeRelatedTo(getIndexedAccessType(source, childrenNameType), childrenTargetType, relation)) {
48537                         result = true;
48538                         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));
48539                         if (errorOutputContainer && errorOutputContainer.skipLogging) {
48540                             (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
48541                         }
48542                     }
48543                 }
48544             }
48545             return result;
48546             function getInvalidTextualChildDiagnostic() {
48547                 if (!invalidTextDiagnostic) {
48548                     var tagNameText = ts.getTextOfNode(node.parent.tagName);
48549                     var childPropName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
48550                     var childrenPropName = childPropName === undefined ? "children" : ts.unescapeLeadingUnderscores(childPropName);
48551                     var childrenTargetType = getIndexedAccessType(target, getLiteralType(childrenPropName));
48552                     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;
48553                     invalidTextDiagnostic = __assign(__assign({}, diagnostic), { key: "!!ALREADY FORMATTED!!", message: ts.formatMessage(undefined, diagnostic, tagNameText, childrenPropName, typeToString(childrenTargetType)) });
48554                 }
48555                 return invalidTextDiagnostic;
48556             }
48557         }
48558         function generateLimitedTupleElements(node, target) {
48559             var len, i, elem, nameType;
48560             return __generator(this, function (_a) {
48561                 switch (_a.label) {
48562                     case 0:
48563                         len = ts.length(node.elements);
48564                         if (!len)
48565                             return [2];
48566                         i = 0;
48567                         _a.label = 1;
48568                     case 1:
48569                         if (!(i < len)) return [3, 4];
48570                         if (isTupleLikeType(target) && !getPropertyOfType(target, ("" + i)))
48571                             return [3, 3];
48572                         elem = node.elements[i];
48573                         if (ts.isOmittedExpression(elem))
48574                             return [3, 3];
48575                         nameType = getLiteralType(i);
48576                         return [4, { errorNode: elem, innerExpression: elem, nameType: nameType }];
48577                     case 2:
48578                         _a.sent();
48579                         _a.label = 3;
48580                     case 3:
48581                         i++;
48582                         return [3, 1];
48583                     case 4: return [2];
48584                 }
48585             });
48586         }
48587         function elaborateArrayLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) {
48588             if (target.flags & 131068)
48589                 return false;
48590             if (isTupleLikeType(source)) {
48591                 return elaborateElementwise(generateLimitedTupleElements(node, target), source, target, relation, containingMessageChain, errorOutputContainer);
48592             }
48593             var oldContext = node.contextualType;
48594             node.contextualType = target;
48595             try {
48596                 var tupleizedType = checkArrayLiteral(node, 1, true);
48597                 node.contextualType = oldContext;
48598                 if (isTupleLikeType(tupleizedType)) {
48599                     return elaborateElementwise(generateLimitedTupleElements(node, target), tupleizedType, target, relation, containingMessageChain, errorOutputContainer);
48600                 }
48601                 return false;
48602             }
48603             finally {
48604                 node.contextualType = oldContext;
48605             }
48606         }
48607         function generateObjectLiteralElements(node) {
48608             var _i, _a, prop, type, _b;
48609             return __generator(this, function (_c) {
48610                 switch (_c.label) {
48611                     case 0:
48612                         if (!ts.length(node.properties))
48613                             return [2];
48614                         _i = 0, _a = node.properties;
48615                         _c.label = 1;
48616                     case 1:
48617                         if (!(_i < _a.length)) return [3, 8];
48618                         prop = _a[_i];
48619                         if (ts.isSpreadAssignment(prop))
48620                             return [3, 7];
48621                         type = getLiteralTypeFromProperty(getSymbolOfNode(prop), 8576);
48622                         if (!type || (type.flags & 131072)) {
48623                             return [3, 7];
48624                         }
48625                         _b = prop.kind;
48626                         switch (_b) {
48627                             case 168: return [3, 2];
48628                             case 167: return [3, 2];
48629                             case 165: return [3, 2];
48630                             case 289: return [3, 2];
48631                             case 288: return [3, 4];
48632                         }
48633                         return [3, 6];
48634                     case 2: return [4, { errorNode: prop.name, innerExpression: undefined, nameType: type }];
48635                     case 3:
48636                         _c.sent();
48637                         return [3, 7];
48638                     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 }];
48639                     case 5:
48640                         _c.sent();
48641                         return [3, 7];
48642                     case 6:
48643                         ts.Debug.assertNever(prop);
48644                         _c.label = 7;
48645                     case 7:
48646                         _i++;
48647                         return [3, 1];
48648                     case 8: return [2];
48649                 }
48650             });
48651         }
48652         function elaborateObjectLiteral(node, source, target, relation, containingMessageChain, errorOutputContainer) {
48653             if (target.flags & 131068)
48654                 return false;
48655             return elaborateElementwise(generateObjectLiteralElements(node), source, target, relation, containingMessageChain, errorOutputContainer);
48656         }
48657         function checkTypeComparableTo(source, target, errorNode, headMessage, containingMessageChain) {
48658             return checkTypeRelatedTo(source, target, comparableRelation, errorNode, headMessage, containingMessageChain);
48659         }
48660         function isSignatureAssignableTo(source, target, ignoreReturnTypes) {
48661             return compareSignaturesRelated(source, target, ignoreReturnTypes ? 4 : 0, false, undefined, undefined, compareTypesAssignable, undefined) !== 0;
48662         }
48663         function isAnySignature(s) {
48664             return !s.typeParameters && (!s.thisParameter || isTypeAny(getTypeOfParameter(s.thisParameter))) && s.parameters.length === 1 &&
48665                 signatureHasRestParameter(s) && (getTypeOfParameter(s.parameters[0]) === anyArrayType || isTypeAny(getTypeOfParameter(s.parameters[0]))) &&
48666                 isTypeAny(getReturnTypeOfSignature(s));
48667         }
48668         function compareSignaturesRelated(source, target, checkMode, reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) {
48669             if (source === target) {
48670                 return -1;
48671             }
48672             if (isAnySignature(target)) {
48673                 return -1;
48674             }
48675             var targetCount = getParameterCount(target);
48676             var sourceHasMoreParameters = !hasEffectiveRestParameter(target) &&
48677                 (checkMode & 8 ? hasEffectiveRestParameter(source) || getParameterCount(source) > targetCount : getMinArgumentCount(source) > targetCount);
48678             if (sourceHasMoreParameters) {
48679                 return 0;
48680             }
48681             if (source.typeParameters && source.typeParameters !== target.typeParameters) {
48682                 target = getCanonicalSignature(target);
48683                 source = instantiateSignatureInContextOf(source, target, undefined, compareTypes);
48684             }
48685             var sourceCount = getParameterCount(source);
48686             var sourceRestType = getNonArrayRestType(source);
48687             var targetRestType = getNonArrayRestType(target);
48688             if (sourceRestType || targetRestType) {
48689                 void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers);
48690             }
48691             if (sourceRestType && targetRestType && sourceCount !== targetCount) {
48692                 return 0;
48693             }
48694             var kind = target.declaration ? target.declaration.kind : 0;
48695             var strictVariance = !(checkMode & 3) && strictFunctionTypes && kind !== 165 &&
48696                 kind !== 164 && kind !== 166;
48697             var result = -1;
48698             var sourceThisType = getThisTypeOfSignature(source);
48699             if (sourceThisType && sourceThisType !== voidType) {
48700                 var targetThisType = getThisTypeOfSignature(target);
48701                 if (targetThisType) {
48702                     var related = !strictVariance && compareTypes(sourceThisType, targetThisType, false)
48703                         || compareTypes(targetThisType, sourceThisType, reportErrors);
48704                     if (!related) {
48705                         if (reportErrors) {
48706                             errorReporter(ts.Diagnostics.The_this_types_of_each_signature_are_incompatible);
48707                         }
48708                         return 0;
48709                     }
48710                     result &= related;
48711                 }
48712             }
48713             var paramCount = sourceRestType || targetRestType ? Math.min(sourceCount, targetCount) : Math.max(sourceCount, targetCount);
48714             var restIndex = sourceRestType || targetRestType ? paramCount - 1 : -1;
48715             for (var i = 0; i < paramCount; i++) {
48716                 var sourceType = i === restIndex ? getRestTypeAtPosition(source, i) : tryGetTypeAtPosition(source, i);
48717                 var targetType = i === restIndex ? getRestTypeAtPosition(target, i) : tryGetTypeAtPosition(target, i);
48718                 if (sourceType && targetType) {
48719                     var sourceSig = checkMode & 3 ? undefined : getSingleCallSignature(getNonNullableType(sourceType));
48720                     var targetSig = checkMode & 3 ? undefined : getSingleCallSignature(getNonNullableType(targetType));
48721                     var callbacks = sourceSig && targetSig && !getTypePredicateOfSignature(sourceSig) && !getTypePredicateOfSignature(targetSig) &&
48722                         (getFalsyFlags(sourceType) & 98304) === (getFalsyFlags(targetType) & 98304);
48723                     var related = callbacks ?
48724                         compareSignaturesRelated(targetSig, sourceSig, (checkMode & 8) | (strictVariance ? 2 : 1), reportErrors, errorReporter, incompatibleErrorReporter, compareTypes, reportUnreliableMarkers) :
48725                         !(checkMode & 3) && !strictVariance && compareTypes(sourceType, targetType, false) || compareTypes(targetType, sourceType, reportErrors);
48726                     if (related && checkMode & 8 && i >= getMinArgumentCount(source) && i < getMinArgumentCount(target) && compareTypes(sourceType, targetType, false)) {
48727                         related = 0;
48728                     }
48729                     if (!related) {
48730                         if (reportErrors) {
48731                             errorReporter(ts.Diagnostics.Types_of_parameters_0_and_1_are_incompatible, ts.unescapeLeadingUnderscores(getParameterNameAtPosition(source, i)), ts.unescapeLeadingUnderscores(getParameterNameAtPosition(target, i)));
48732                         }
48733                         return 0;
48734                     }
48735                     result &= related;
48736                 }
48737             }
48738             if (!(checkMode & 4)) {
48739                 var targetReturnType = isResolvingReturnTypeOfSignature(target) ? anyType
48740                     : target.declaration && isJSConstructor(target.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(target.declaration.symbol))
48741                         : getReturnTypeOfSignature(target);
48742                 if (targetReturnType === voidType) {
48743                     return result;
48744                 }
48745                 var sourceReturnType = isResolvingReturnTypeOfSignature(source) ? anyType
48746                     : source.declaration && isJSConstructor(source.declaration) ? getDeclaredTypeOfClassOrInterface(getMergedSymbol(source.declaration.symbol))
48747                         : getReturnTypeOfSignature(source);
48748                 var targetTypePredicate = getTypePredicateOfSignature(target);
48749                 if (targetTypePredicate) {
48750                     var sourceTypePredicate = getTypePredicateOfSignature(source);
48751                     if (sourceTypePredicate) {
48752                         result &= compareTypePredicateRelatedTo(sourceTypePredicate, targetTypePredicate, reportErrors, errorReporter, compareTypes);
48753                     }
48754                     else if (ts.isIdentifierTypePredicate(targetTypePredicate)) {
48755                         if (reportErrors) {
48756                             errorReporter(ts.Diagnostics.Signature_0_must_be_a_type_predicate, signatureToString(source));
48757                         }
48758                         return 0;
48759                     }
48760                 }
48761                 else {
48762                     result &= checkMode & 1 && compareTypes(targetReturnType, sourceReturnType, false) ||
48763                         compareTypes(sourceReturnType, targetReturnType, reportErrors);
48764                     if (!result && reportErrors && incompatibleErrorReporter) {
48765                         incompatibleErrorReporter(sourceReturnType, targetReturnType);
48766                     }
48767                 }
48768             }
48769             return result;
48770         }
48771         function compareTypePredicateRelatedTo(source, target, reportErrors, errorReporter, compareTypes) {
48772             if (source.kind !== target.kind) {
48773                 if (reportErrors) {
48774                     errorReporter(ts.Diagnostics.A_this_based_type_guard_is_not_compatible_with_a_parameter_based_type_guard);
48775                     errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
48776                 }
48777                 return 0;
48778             }
48779             if (source.kind === 1 || source.kind === 3) {
48780                 if (source.parameterIndex !== target.parameterIndex) {
48781                     if (reportErrors) {
48782                         errorReporter(ts.Diagnostics.Parameter_0_is_not_in_the_same_position_as_parameter_1, source.parameterName, target.parameterName);
48783                         errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
48784                     }
48785                     return 0;
48786                 }
48787             }
48788             var related = source.type === target.type ? -1 :
48789                 source.type && target.type ? compareTypes(source.type, target.type, reportErrors) :
48790                     0;
48791             if (related === 0 && reportErrors) {
48792                 errorReporter(ts.Diagnostics.Type_predicate_0_is_not_assignable_to_1, typePredicateToString(source), typePredicateToString(target));
48793             }
48794             return related;
48795         }
48796         function isImplementationCompatibleWithOverload(implementation, overload) {
48797             var erasedSource = getErasedSignature(implementation);
48798             var erasedTarget = getErasedSignature(overload);
48799             var sourceReturnType = getReturnTypeOfSignature(erasedSource);
48800             var targetReturnType = getReturnTypeOfSignature(erasedTarget);
48801             if (targetReturnType === voidType
48802                 || isTypeRelatedTo(targetReturnType, sourceReturnType, assignableRelation)
48803                 || isTypeRelatedTo(sourceReturnType, targetReturnType, assignableRelation)) {
48804                 return isSignatureAssignableTo(erasedSource, erasedTarget, true);
48805             }
48806             return false;
48807         }
48808         function isEmptyResolvedType(t) {
48809             return t !== anyFunctionType &&
48810                 t.properties.length === 0 &&
48811                 t.callSignatures.length === 0 &&
48812                 t.constructSignatures.length === 0 &&
48813                 !t.stringIndexInfo &&
48814                 !t.numberIndexInfo;
48815         }
48816         function isEmptyObjectType(type) {
48817             return type.flags & 524288 ? !isGenericMappedType(type) && isEmptyResolvedType(resolveStructuredTypeMembers(type)) :
48818                 type.flags & 67108864 ? true :
48819                     type.flags & 1048576 ? ts.some(type.types, isEmptyObjectType) :
48820                         type.flags & 2097152 ? ts.every(type.types, isEmptyObjectType) :
48821                             false;
48822         }
48823         function isEmptyAnonymousObjectType(type) {
48824             return !!(ts.getObjectFlags(type) & 16 && (type.members && isEmptyResolvedType(type) ||
48825                 type.symbol && type.symbol.flags & 2048 && getMembersOfSymbol(type.symbol).size === 0));
48826         }
48827         function isStringIndexSignatureOnlyType(type) {
48828             return type.flags & 524288 && !isGenericMappedType(type) && getPropertiesOfType(type).length === 0 && getIndexInfoOfType(type, 0) && !getIndexInfoOfType(type, 1) ||
48829                 type.flags & 3145728 && ts.every(type.types, isStringIndexSignatureOnlyType) ||
48830                 false;
48831         }
48832         function isEnumTypeRelatedTo(sourceSymbol, targetSymbol, errorReporter) {
48833             if (sourceSymbol === targetSymbol) {
48834                 return true;
48835             }
48836             var id = getSymbolId(sourceSymbol) + "," + getSymbolId(targetSymbol);
48837             var entry = enumRelation.get(id);
48838             if (entry !== undefined && !(!(entry & 4) && entry & 2 && errorReporter)) {
48839                 return !!(entry & 1);
48840             }
48841             if (sourceSymbol.escapedName !== targetSymbol.escapedName || !(sourceSymbol.flags & 256) || !(targetSymbol.flags & 256)) {
48842                 enumRelation.set(id, 2 | 4);
48843                 return false;
48844             }
48845             var targetEnumType = getTypeOfSymbol(targetSymbol);
48846             for (var _i = 0, _a = getPropertiesOfType(getTypeOfSymbol(sourceSymbol)); _i < _a.length; _i++) {
48847                 var property = _a[_i];
48848                 if (property.flags & 8) {
48849                     var targetProperty = getPropertyOfType(targetEnumType, property.escapedName);
48850                     if (!targetProperty || !(targetProperty.flags & 8)) {
48851                         if (errorReporter) {
48852                             errorReporter(ts.Diagnostics.Property_0_is_missing_in_type_1, ts.symbolName(property), typeToString(getDeclaredTypeOfSymbol(targetSymbol), undefined, 64));
48853                             enumRelation.set(id, 2 | 4);
48854                         }
48855                         else {
48856                             enumRelation.set(id, 2);
48857                         }
48858                         return false;
48859                     }
48860                 }
48861             }
48862             enumRelation.set(id, 1);
48863             return true;
48864         }
48865         function isSimpleTypeRelatedTo(source, target, relation, errorReporter) {
48866             var s = source.flags;
48867             var t = target.flags;
48868             if (t & 3 || s & 131072 || source === wildcardType)
48869                 return true;
48870             if (t & 131072)
48871                 return false;
48872             if (s & 402653316 && t & 4)
48873                 return true;
48874             if (s & 128 && s & 1024 &&
48875                 t & 128 && !(t & 1024) &&
48876                 source.value === target.value)
48877                 return true;
48878             if (s & 296 && t & 8)
48879                 return true;
48880             if (s & 256 && s & 1024 &&
48881                 t & 256 && !(t & 1024) &&
48882                 source.value === target.value)
48883                 return true;
48884             if (s & 2112 && t & 64)
48885                 return true;
48886             if (s & 528 && t & 16)
48887                 return true;
48888             if (s & 12288 && t & 4096)
48889                 return true;
48890             if (s & 32 && t & 32 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter))
48891                 return true;
48892             if (s & 1024 && t & 1024) {
48893                 if (s & 1048576 && t & 1048576 && isEnumTypeRelatedTo(source.symbol, target.symbol, errorReporter))
48894                     return true;
48895                 if (s & 2944 && t & 2944 &&
48896                     source.value === target.value &&
48897                     isEnumTypeRelatedTo(getParentOfSymbol(source.symbol), getParentOfSymbol(target.symbol), errorReporter))
48898                     return true;
48899             }
48900             if (s & 32768 && (!strictNullChecks || t & (32768 | 16384)))
48901                 return true;
48902             if (s & 65536 && (!strictNullChecks || t & 65536))
48903                 return true;
48904             if (s & 524288 && t & 67108864)
48905                 return true;
48906             if (relation === assignableRelation || relation === comparableRelation) {
48907                 if (s & 1)
48908                     return true;
48909                 if (s & (8 | 256) && !(s & 1024) && (t & 32 || t & 256 && t & 1024))
48910                     return true;
48911             }
48912             return false;
48913         }
48914         function isTypeRelatedTo(source, target, relation) {
48915             if (isFreshLiteralType(source)) {
48916                 source = source.regularType;
48917             }
48918             if (isFreshLiteralType(target)) {
48919                 target = target.regularType;
48920             }
48921             if (source === target) {
48922                 return true;
48923             }
48924             if (relation !== identityRelation) {
48925                 if (relation === comparableRelation && !(target.flags & 131072) && isSimpleTypeRelatedTo(target, source, relation) || isSimpleTypeRelatedTo(source, target, relation)) {
48926                     return true;
48927                 }
48928             }
48929             else {
48930                 if (!(source.flags & 3145728) && !(target.flags & 3145728) &&
48931                     source.flags !== target.flags && !(source.flags & 469237760))
48932                     return false;
48933             }
48934             if (source.flags & 524288 && target.flags & 524288) {
48935                 var related = relation.get(getRelationKey(source, target, 0, relation));
48936                 if (related !== undefined) {
48937                     return !!(related & 1);
48938                 }
48939             }
48940             if (source.flags & 469499904 || target.flags & 469499904) {
48941                 return checkTypeRelatedTo(source, target, relation, undefined);
48942             }
48943             return false;
48944         }
48945         function isIgnoredJsxProperty(source, sourceProp) {
48946             return ts.getObjectFlags(source) & 4096 && !isUnhyphenatedJsxName(sourceProp.escapedName);
48947         }
48948         function getNormalizedType(type, writing) {
48949             while (true) {
48950                 var t = isFreshLiteralType(type) ? type.regularType :
48951                     ts.getObjectFlags(type) & 4 && type.node ? createTypeReference(type.target, getTypeArguments(type)) :
48952                         type.flags & 3145728 ? getReducedType(type) :
48953                             type.flags & 33554432 ? writing ? type.baseType : type.substitute :
48954                                 type.flags & 25165824 ? getSimplifiedType(type, writing) :
48955                                     type;
48956                 if (t === type)
48957                     break;
48958                 type = t;
48959             }
48960             return type;
48961         }
48962         function checkTypeRelatedTo(source, target, relation, errorNode, headMessage, containingMessageChain, errorOutputContainer) {
48963             var errorInfo;
48964             var relatedInfo;
48965             var maybeKeys;
48966             var sourceStack;
48967             var targetStack;
48968             var maybeCount = 0;
48969             var depth = 0;
48970             var expandingFlags = 0;
48971             var overflow = false;
48972             var overrideNextErrorInfo = 0;
48973             var lastSkippedInfo;
48974             var incompatibleStack = [];
48975             var inPropertyCheck = false;
48976             ts.Debug.assert(relation !== identityRelation || !errorNode, "no error reporting in identity checking");
48977             var result = isRelatedTo(source, target, !!errorNode, headMessage);
48978             if (incompatibleStack.length) {
48979                 reportIncompatibleStack();
48980             }
48981             if (overflow) {
48982                 ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes", "checkTypeRelatedTo_DepthLimit", { sourceId: source.id, targetId: target.id, depth: depth });
48983                 var diag = error(errorNode || currentNode, ts.Diagnostics.Excessive_stack_depth_comparing_types_0_and_1, typeToString(source), typeToString(target));
48984                 if (errorOutputContainer) {
48985                     (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
48986                 }
48987             }
48988             else if (errorInfo) {
48989                 if (containingMessageChain) {
48990                     var chain = containingMessageChain();
48991                     if (chain) {
48992                         ts.concatenateDiagnosticMessageChains(chain, errorInfo);
48993                         errorInfo = chain;
48994                     }
48995                 }
48996                 var relatedInformation = void 0;
48997                 if (headMessage && errorNode && !result && source.symbol) {
48998                     var links = getSymbolLinks(source.symbol);
48999                     if (links.originatingImport && !ts.isImportCall(links.originatingImport)) {
49000                         var helpfulRetry = checkTypeRelatedTo(getTypeOfSymbol(links.target), target, relation, undefined);
49001                         if (helpfulRetry) {
49002                             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);
49003                             relatedInformation = ts.append(relatedInformation, diag_1);
49004                         }
49005                     }
49006                 }
49007                 var diag = ts.createDiagnosticForNodeFromMessageChain(errorNode, errorInfo, relatedInformation);
49008                 if (relatedInfo) {
49009                     ts.addRelatedInfo.apply(void 0, __spreadArray([diag], relatedInfo));
49010                 }
49011                 if (errorOutputContainer) {
49012                     (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
49013                 }
49014                 if (!errorOutputContainer || !errorOutputContainer.skipLogging) {
49015                     diagnostics.add(diag);
49016                 }
49017             }
49018             if (errorNode && errorOutputContainer && errorOutputContainer.skipLogging && result === 0) {
49019                 ts.Debug.assert(!!errorOutputContainer.errors, "missed opportunity to interact with error.");
49020             }
49021             return result !== 0;
49022             function resetErrorInfo(saved) {
49023                 errorInfo = saved.errorInfo;
49024                 lastSkippedInfo = saved.lastSkippedInfo;
49025                 incompatibleStack = saved.incompatibleStack;
49026                 overrideNextErrorInfo = saved.overrideNextErrorInfo;
49027                 relatedInfo = saved.relatedInfo;
49028             }
49029             function captureErrorCalculationState() {
49030                 return {
49031                     errorInfo: errorInfo,
49032                     lastSkippedInfo: lastSkippedInfo,
49033                     incompatibleStack: incompatibleStack.slice(),
49034                     overrideNextErrorInfo: overrideNextErrorInfo,
49035                     relatedInfo: !relatedInfo ? undefined : relatedInfo.slice()
49036                 };
49037             }
49038             function reportIncompatibleError(message, arg0, arg1, arg2, arg3) {
49039                 overrideNextErrorInfo++;
49040                 lastSkippedInfo = undefined;
49041                 incompatibleStack.push([message, arg0, arg1, arg2, arg3]);
49042             }
49043             function reportIncompatibleStack() {
49044                 var stack = incompatibleStack;
49045                 incompatibleStack = [];
49046                 var info = lastSkippedInfo;
49047                 lastSkippedInfo = undefined;
49048                 if (stack.length === 1) {
49049                     reportError.apply(void 0, stack[0]);
49050                     if (info) {
49051                         reportRelationError.apply(void 0, __spreadArray([undefined], info));
49052                     }
49053                     return;
49054                 }
49055                 var path = "";
49056                 var secondaryRootErrors = [];
49057                 while (stack.length) {
49058                     var _a = stack.pop(), msg = _a[0], args = _a.slice(1);
49059                     switch (msg.code) {
49060                         case ts.Diagnostics.Types_of_property_0_are_incompatible.code: {
49061                             if (path.indexOf("new ") === 0) {
49062                                 path = "(" + path + ")";
49063                             }
49064                             var str = "" + args[0];
49065                             if (path.length === 0) {
49066                                 path = "" + str;
49067                             }
49068                             else if (ts.isIdentifierText(str, compilerOptions.target)) {
49069                                 path = path + "." + str;
49070                             }
49071                             else if (str[0] === "[" && str[str.length - 1] === "]") {
49072                                 path = "" + path + str;
49073                             }
49074                             else {
49075                                 path = path + "[" + str + "]";
49076                             }
49077                             break;
49078                         }
49079                         case ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible.code:
49080                         case ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code:
49081                         case ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code:
49082                         case ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code: {
49083                             if (path.length === 0) {
49084                                 var mappedMsg = msg;
49085                                 if (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) {
49086                                     mappedMsg = ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible;
49087                                 }
49088                                 else if (msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code) {
49089                                     mappedMsg = ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible;
49090                                 }
49091                                 secondaryRootErrors.unshift([mappedMsg, args[0], args[1]]);
49092                             }
49093                             else {
49094                                 var prefix = (msg.code === ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible.code ||
49095                                     msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code)
49096                                     ? "new "
49097                                     : "";
49098                                 var params = (msg.code === ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code ||
49099                                     msg.code === ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1.code)
49100                                     ? ""
49101                                     : "...";
49102                                 path = "" + prefix + path + "(" + params + ")";
49103                             }
49104                             break;
49105                         }
49106                         default:
49107                             return ts.Debug.fail("Unhandled Diagnostic: " + msg.code);
49108                     }
49109                 }
49110                 if (path) {
49111                     reportError(path[path.length - 1] === ")"
49112                         ? ts.Diagnostics.The_types_returned_by_0_are_incompatible_between_these_types
49113                         : ts.Diagnostics.The_types_of_0_are_incompatible_between_these_types, path);
49114                 }
49115                 else {
49116                     secondaryRootErrors.shift();
49117                 }
49118                 for (var _i = 0, secondaryRootErrors_1 = secondaryRootErrors; _i < secondaryRootErrors_1.length; _i++) {
49119                     var _b = secondaryRootErrors_1[_i], msg = _b[0], args = _b.slice(1);
49120                     var originalValue = msg.elidedInCompatabilityPyramid;
49121                     msg.elidedInCompatabilityPyramid = false;
49122                     reportError.apply(void 0, __spreadArray([msg], args));
49123                     msg.elidedInCompatabilityPyramid = originalValue;
49124                 }
49125                 if (info) {
49126                     reportRelationError.apply(void 0, __spreadArray([undefined], info));
49127                 }
49128             }
49129             function reportError(message, arg0, arg1, arg2, arg3) {
49130                 ts.Debug.assert(!!errorNode);
49131                 if (incompatibleStack.length)
49132                     reportIncompatibleStack();
49133                 if (message.elidedInCompatabilityPyramid)
49134                     return;
49135                 errorInfo = ts.chainDiagnosticMessages(errorInfo, message, arg0, arg1, arg2, arg3);
49136             }
49137             function associateRelatedInfo(info) {
49138                 ts.Debug.assert(!!errorInfo);
49139                 if (!relatedInfo) {
49140                     relatedInfo = [info];
49141                 }
49142                 else {
49143                     relatedInfo.push(info);
49144                 }
49145             }
49146             function reportRelationError(message, source, target) {
49147                 if (incompatibleStack.length)
49148                     reportIncompatibleStack();
49149                 var _a = getTypeNamesForErrorDisplay(source, target), sourceType = _a[0], targetType = _a[1];
49150                 var generalizedSource = source;
49151                 var generalizedSourceType = sourceType;
49152                 if (isLiteralType(source) && !typeCouldHaveTopLevelSingletonTypes(target)) {
49153                     generalizedSource = getBaseTypeOfLiteralType(source);
49154                     ts.Debug.assert(!isTypeAssignableTo(generalizedSource, target), "generalized source shouldn't be assignable");
49155                     generalizedSourceType = getTypeNameForErrorDisplay(generalizedSource);
49156                 }
49157                 if (target.flags & 262144) {
49158                     var constraint = getBaseConstraintOfType(target);
49159                     var needsOriginalSource = void 0;
49160                     if (constraint && (isTypeAssignableTo(generalizedSource, constraint) || (needsOriginalSource = isTypeAssignableTo(source, constraint)))) {
49161                         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));
49162                     }
49163                     else {
49164                         reportError(ts.Diagnostics._0_could_be_instantiated_with_an_arbitrary_type_which_could_be_unrelated_to_1, targetType, generalizedSourceType);
49165                     }
49166                 }
49167                 if (!message) {
49168                     if (relation === comparableRelation) {
49169                         message = ts.Diagnostics.Type_0_is_not_comparable_to_type_1;
49170                     }
49171                     else if (sourceType === targetType) {
49172                         message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated;
49173                     }
49174                     else {
49175                         message = ts.Diagnostics.Type_0_is_not_assignable_to_type_1;
49176                     }
49177                 }
49178                 reportError(message, generalizedSourceType, targetType);
49179             }
49180             function tryElaborateErrorsForPrimitivesAndObjects(source, target) {
49181                 var sourceType = symbolValueDeclarationIsContextSensitive(source.symbol) ? typeToString(source, source.symbol.valueDeclaration) : typeToString(source);
49182                 var targetType = symbolValueDeclarationIsContextSensitive(target.symbol) ? typeToString(target, target.symbol.valueDeclaration) : typeToString(target);
49183                 if ((globalStringType === source && stringType === target) ||
49184                     (globalNumberType === source && numberType === target) ||
49185                     (globalBooleanType === source && booleanType === target) ||
49186                     (getGlobalESSymbolType(false) === source && esSymbolType === target)) {
49187                     reportError(ts.Diagnostics._0_is_a_primitive_but_1_is_a_wrapper_object_Prefer_using_0_when_possible, targetType, sourceType);
49188                 }
49189             }
49190             function tryElaborateArrayLikeErrors(source, target, reportErrors) {
49191                 if (isTupleType(source)) {
49192                     if (source.target.readonly && isMutableArrayOrTuple(target)) {
49193                         if (reportErrors) {
49194                             reportError(ts.Diagnostics.The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1, typeToString(source), typeToString(target));
49195                         }
49196                         return false;
49197                     }
49198                     return isTupleType(target) || isArrayType(target);
49199                 }
49200                 if (isReadonlyArrayType(source) && isMutableArrayOrTuple(target)) {
49201                     if (reportErrors) {
49202                         reportError(ts.Diagnostics.The_type_0_is_readonly_and_cannot_be_assigned_to_the_mutable_type_1, typeToString(source), typeToString(target));
49203                     }
49204                     return false;
49205                 }
49206                 if (isTupleType(target)) {
49207                     return isArrayType(source);
49208                 }
49209                 return true;
49210             }
49211             function isRelatedTo(originalSource, originalTarget, reportErrors, headMessage, intersectionState) {
49212                 if (reportErrors === void 0) { reportErrors = false; }
49213                 if (intersectionState === void 0) { intersectionState = 0; }
49214                 if (originalSource.flags & 524288 && originalTarget.flags & 131068) {
49215                     if (isSimpleTypeRelatedTo(originalSource, originalTarget, relation, reportErrors ? reportError : undefined)) {
49216                         return -1;
49217                     }
49218                     reportErrorResults(originalSource, originalTarget, 0, !!(ts.getObjectFlags(originalSource) & 4096));
49219                     return 0;
49220                 }
49221                 var source = getNormalizedType(originalSource, false);
49222                 var target = getNormalizedType(originalTarget, true);
49223                 if (source === target)
49224                     return -1;
49225                 if (relation === identityRelation) {
49226                     return isIdenticalTo(source, target);
49227                 }
49228                 if (source.flags & 262144 && getConstraintOfType(source) === target) {
49229                     return -1;
49230                 }
49231                 if (target.flags & 1048576 && source.flags & 524288 &&
49232                     target.types.length <= 3 && maybeTypeOfKind(target, 98304)) {
49233                     var nullStrippedTarget = extractTypesOfKind(target, ~98304);
49234                     if (!(nullStrippedTarget.flags & (1048576 | 131072))) {
49235                         if (source === nullStrippedTarget)
49236                             return -1;
49237                         target = nullStrippedTarget;
49238                     }
49239                 }
49240                 if (relation === comparableRelation && !(target.flags & 131072) && isSimpleTypeRelatedTo(target, source, relation) ||
49241                     isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined))
49242                     return -1;
49243                 var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096);
49244                 var isPerformingExcessPropertyChecks = !(intersectionState & 2) && (isObjectLiteralType(source) && ts.getObjectFlags(source) & 32768);
49245                 if (isPerformingExcessPropertyChecks) {
49246                     if (hasExcessProperties(source, target, reportErrors)) {
49247                         if (reportErrors) {
49248                             reportRelationError(headMessage, source, originalTarget.aliasSymbol ? originalTarget : target);
49249                         }
49250                         return 0;
49251                     }
49252                 }
49253                 var isPerformingCommonPropertyChecks = relation !== comparableRelation && !(intersectionState & 2) &&
49254                     source.flags & (131068 | 524288 | 2097152) && source !== globalObjectType &&
49255                     target.flags & (524288 | 2097152) && isWeakType(target) &&
49256                     (getPropertiesOfType(source).length > 0 || typeHasCallOrConstructSignatures(source));
49257                 if (isPerformingCommonPropertyChecks && !hasCommonProperties(source, target, isComparingJsxAttributes)) {
49258                     if (reportErrors) {
49259                         var sourceString = typeToString(originalSource.aliasSymbol ? originalSource : source);
49260                         var targetString = typeToString(originalTarget.aliasSymbol ? originalTarget : target);
49261                         var calls = getSignaturesOfType(source, 0);
49262                         var constructs = getSignaturesOfType(source, 1);
49263                         if (calls.length > 0 && isRelatedTo(getReturnTypeOfSignature(calls[0]), target, false) ||
49264                             constructs.length > 0 && isRelatedTo(getReturnTypeOfSignature(constructs[0]), target, false)) {
49265                             reportError(ts.Diagnostics.Value_of_type_0_has_no_properties_in_common_with_type_1_Did_you_mean_to_call_it, sourceString, targetString);
49266                         }
49267                         else {
49268                             reportError(ts.Diagnostics.Type_0_has_no_properties_in_common_with_type_1, sourceString, targetString);
49269                         }
49270                     }
49271                     return 0;
49272                 }
49273                 traceUnionsOrIntersectionsTooLarge(source, target);
49274                 var result = 0;
49275                 var saveErrorInfo = captureErrorCalculationState();
49276                 if (source.flags & 3145728 || target.flags & 3145728) {
49277                     result = getConstituentCount(source) * getConstituentCount(target) >= 4 ?
49278                         recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8) :
49279                         structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8);
49280                 }
49281                 if (!result && !(source.flags & 1048576) && (source.flags & (469499904) || target.flags & 469499904)) {
49282                     if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState)) {
49283                         resetErrorInfo(saveErrorInfo);
49284                     }
49285                 }
49286                 if (!result && source.flags & (2097152 | 262144)) {
49287                     var constraint = getEffectiveConstraintOfIntersection(source.flags & 2097152 ? source.types : [source], !!(target.flags & 1048576));
49288                     if (constraint && (source.flags & 2097152 || target.flags & 1048576)) {
49289                         if (everyType(constraint, function (c) { return c !== source; })) {
49290                             if (result = isRelatedTo(constraint, target, false, undefined, intersectionState)) {
49291                                 resetErrorInfo(saveErrorInfo);
49292                             }
49293                         }
49294                     }
49295                 }
49296                 if (result && !inPropertyCheck && (target.flags & 2097152 && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) ||
49297                     isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152); }))) {
49298                     inPropertyCheck = true;
49299                     result &= recursiveTypeRelatedTo(source, target, reportErrors, 4);
49300                     inPropertyCheck = false;
49301                 }
49302                 reportErrorResults(source, target, result, isComparingJsxAttributes);
49303                 return result;
49304                 function reportErrorResults(source, target, result, isComparingJsxAttributes) {
49305                     if (!result && reportErrors) {
49306                         source = originalSource.aliasSymbol ? originalSource : source;
49307                         target = originalTarget.aliasSymbol ? originalTarget : target;
49308                         var maybeSuppress = overrideNextErrorInfo > 0;
49309                         if (maybeSuppress) {
49310                             overrideNextErrorInfo--;
49311                         }
49312                         if (source.flags & 524288 && target.flags & 524288) {
49313                             var currentError = errorInfo;
49314                             tryElaborateArrayLikeErrors(source, target, reportErrors);
49315                             if (errorInfo !== currentError) {
49316                                 maybeSuppress = !!errorInfo;
49317                             }
49318                         }
49319                         if (source.flags & 524288 && target.flags & 131068) {
49320                             tryElaborateErrorsForPrimitivesAndObjects(source, target);
49321                         }
49322                         else if (source.symbol && source.flags & 524288 && globalObjectType === source) {
49323                             reportError(ts.Diagnostics.The_Object_type_is_assignable_to_very_few_other_types_Did_you_mean_to_use_the_any_type_instead);
49324                         }
49325                         else if (isComparingJsxAttributes && target.flags & 2097152) {
49326                             var targetTypes = target.types;
49327                             var intrinsicAttributes = getJsxType(JsxNames.IntrinsicAttributes, errorNode);
49328                             var intrinsicClassAttributes = getJsxType(JsxNames.IntrinsicClassAttributes, errorNode);
49329                             if (intrinsicAttributes !== errorType && intrinsicClassAttributes !== errorType &&
49330                                 (ts.contains(targetTypes, intrinsicAttributes) || ts.contains(targetTypes, intrinsicClassAttributes))) {
49331                                 return result;
49332                             }
49333                         }
49334                         else {
49335                             errorInfo = elaborateNeverIntersection(errorInfo, originalTarget);
49336                         }
49337                         if (!headMessage && maybeSuppress) {
49338                             lastSkippedInfo = [source, target];
49339                             return result;
49340                         }
49341                         reportRelationError(headMessage, source, target);
49342                     }
49343                 }
49344             }
49345             function traceUnionsOrIntersectionsTooLarge(source, target) {
49346                 if (!ts.tracing) {
49347                     return;
49348                 }
49349                 if ((source.flags & 3145728) && (target.flags & 3145728)) {
49350                     var sourceUnionOrIntersection = source;
49351                     var targetUnionOrIntersection = target;
49352                     if (sourceUnionOrIntersection.objectFlags & targetUnionOrIntersection.objectFlags & 262144) {
49353                         return;
49354                     }
49355                     var sourceSize = sourceUnionOrIntersection.types.length;
49356                     var targetSize = targetUnionOrIntersection.types.length;
49357                     if (sourceSize * targetSize > 1E6) {
49358                         ts.tracing.instant("checkTypes", "traceUnionsOrIntersectionsTooLarge_DepthLimit", {
49359                             sourceId: source.id,
49360                             sourceSize: sourceSize,
49361                             targetId: target.id,
49362                             targetSize: targetSize,
49363                             pos: errorNode === null || errorNode === void 0 ? void 0 : errorNode.pos,
49364                             end: errorNode === null || errorNode === void 0 ? void 0 : errorNode.end
49365                         });
49366                     }
49367                 }
49368             }
49369             function isIdenticalTo(source, target) {
49370                 var flags = source.flags & target.flags;
49371                 if (!(flags & 469237760)) {
49372                     return 0;
49373                 }
49374                 traceUnionsOrIntersectionsTooLarge(source, target);
49375                 if (flags & 3145728) {
49376                     var result_6 = eachTypeRelatedToSomeType(source, target);
49377                     if (result_6) {
49378                         result_6 &= eachTypeRelatedToSomeType(target, source);
49379                     }
49380                     return result_6;
49381                 }
49382                 return recursiveTypeRelatedTo(source, target, false, 0);
49383             }
49384             function getTypeOfPropertyInTypes(types, name) {
49385                 var appendPropType = function (propTypes, type) {
49386                     type = getApparentType(type);
49387                     var prop = type.flags & 3145728 ? getPropertyOfUnionOrIntersectionType(type, name) : getPropertyOfObjectType(type, name);
49388                     var propType = prop && getTypeOfSymbol(prop) || isNumericLiteralName(name) && getIndexTypeOfType(type, 1) || getIndexTypeOfType(type, 0) || undefinedType;
49389                     return ts.append(propTypes, propType);
49390                 };
49391                 return getUnionType(ts.reduceLeft(types, appendPropType, undefined) || ts.emptyArray);
49392             }
49393             function hasExcessProperties(source, target, reportErrors) {
49394                 if (!isExcessPropertyCheckTarget(target) || !noImplicitAny && ts.getObjectFlags(target) & 16384) {
49395                     return false;
49396                 }
49397                 var isComparingJsxAttributes = !!(ts.getObjectFlags(source) & 4096);
49398                 if ((relation === assignableRelation || relation === comparableRelation) &&
49399                     (isTypeSubsetOf(globalObjectType, target) || (!isComparingJsxAttributes && isEmptyObjectType(target)))) {
49400                     return false;
49401                 }
49402                 var reducedTarget = target;
49403                 var checkTypes;
49404                 if (target.flags & 1048576) {
49405                     reducedTarget = findMatchingDiscriminantType(source, target, isRelatedTo) || filterPrimitivesIfContainsNonPrimitive(target);
49406                     checkTypes = reducedTarget.flags & 1048576 ? reducedTarget.types : [reducedTarget];
49407                 }
49408                 var _loop_16 = function (prop) {
49409                     if (shouldCheckAsExcessProperty(prop, source.symbol) && !isIgnoredJsxProperty(source, prop)) {
49410                         if (!isKnownProperty(reducedTarget, prop.escapedName, isComparingJsxAttributes)) {
49411                             if (reportErrors) {
49412                                 var errorTarget = filterType(reducedTarget, isExcessPropertyCheckTarget);
49413                                 if (!errorNode)
49414                                     return { value: ts.Debug.fail() };
49415                                 if (ts.isJsxAttributes(errorNode) || ts.isJsxOpeningLikeElement(errorNode) || ts.isJsxOpeningLikeElement(errorNode.parent)) {
49416                                     if (prop.valueDeclaration && ts.isJsxAttribute(prop.valueDeclaration) && ts.getSourceFileOfNode(errorNode) === ts.getSourceFileOfNode(prop.valueDeclaration.name)) {
49417                                         errorNode = prop.valueDeclaration.name;
49418                                     }
49419                                     var propName = symbolToString(prop);
49420                                     var suggestionSymbol = getSuggestedSymbolForNonexistentJSXAttribute(propName, errorTarget);
49421                                     var suggestion = suggestionSymbol ? symbolToString(suggestionSymbol) : undefined;
49422                                     if (suggestion) {
49423                                         reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, propName, typeToString(errorTarget), suggestion);
49424                                     }
49425                                     else {
49426                                         reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, propName, typeToString(errorTarget));
49427                                     }
49428                                 }
49429                                 else {
49430                                     var objectLiteralDeclaration_1 = source.symbol && ts.firstOrUndefined(source.symbol.declarations);
49431                                     var suggestion = void 0;
49432                                     if (prop.valueDeclaration && ts.findAncestor(prop.valueDeclaration, function (d) { return d === objectLiteralDeclaration_1; }) && ts.getSourceFileOfNode(objectLiteralDeclaration_1) === ts.getSourceFileOfNode(errorNode)) {
49433                                         var propDeclaration = prop.valueDeclaration;
49434                                         ts.Debug.assertNode(propDeclaration, ts.isObjectLiteralElementLike);
49435                                         errorNode = propDeclaration;
49436                                         var name = propDeclaration.name;
49437                                         if (ts.isIdentifier(name)) {
49438                                             suggestion = getSuggestionForNonexistentProperty(name, errorTarget);
49439                                         }
49440                                     }
49441                                     if (suggestion !== undefined) {
49442                                         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);
49443                                     }
49444                                     else {
49445                                         reportError(ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(prop), typeToString(errorTarget));
49446                                     }
49447                                 }
49448                             }
49449                             return { value: true };
49450                         }
49451                         if (checkTypes && !isRelatedTo(getTypeOfSymbol(prop), getTypeOfPropertyInTypes(checkTypes, prop.escapedName), reportErrors)) {
49452                             if (reportErrors) {
49453                                 reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(prop));
49454                             }
49455                             return { value: true };
49456                         }
49457                     }
49458                 };
49459                 for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
49460                     var prop = _a[_i];
49461                     var state_5 = _loop_16(prop);
49462                     if (typeof state_5 === "object")
49463                         return state_5.value;
49464                 }
49465                 return false;
49466             }
49467             function shouldCheckAsExcessProperty(prop, container) {
49468                 return prop.valueDeclaration && container.valueDeclaration && prop.valueDeclaration.parent === container.valueDeclaration;
49469             }
49470             function eachTypeRelatedToSomeType(source, target) {
49471                 var result = -1;
49472                 var sourceTypes = source.types;
49473                 for (var _i = 0, sourceTypes_1 = sourceTypes; _i < sourceTypes_1.length; _i++) {
49474                     var sourceType = sourceTypes_1[_i];
49475                     var related = typeRelatedToSomeType(sourceType, target, false);
49476                     if (!related) {
49477                         return 0;
49478                     }
49479                     result &= related;
49480                 }
49481                 return result;
49482             }
49483             function typeRelatedToSomeType(source, target, reportErrors) {
49484                 var targetTypes = target.types;
49485                 if (target.flags & 1048576 && containsType(targetTypes, source)) {
49486                     return -1;
49487                 }
49488                 for (var _i = 0, targetTypes_1 = targetTypes; _i < targetTypes_1.length; _i++) {
49489                     var type = targetTypes_1[_i];
49490                     var related = isRelatedTo(source, type, false);
49491                     if (related) {
49492                         return related;
49493                     }
49494                 }
49495                 if (reportErrors) {
49496                     var bestMatchingType = getBestMatchingType(source, target, isRelatedTo);
49497                     isRelatedTo(source, bestMatchingType || targetTypes[targetTypes.length - 1], true);
49498                 }
49499                 return 0;
49500             }
49501             function typeRelatedToEachType(source, target, reportErrors, intersectionState) {
49502                 var result = -1;
49503                 var targetTypes = target.types;
49504                 for (var _i = 0, targetTypes_2 = targetTypes; _i < targetTypes_2.length; _i++) {
49505                     var targetType = targetTypes_2[_i];
49506                     var related = isRelatedTo(source, targetType, reportErrors, undefined, intersectionState);
49507                     if (!related) {
49508                         return 0;
49509                     }
49510                     result &= related;
49511                 }
49512                 return result;
49513             }
49514             function someTypeRelatedToType(source, target, reportErrors, intersectionState) {
49515                 var sourceTypes = source.types;
49516                 if (source.flags & 1048576 && containsType(sourceTypes, target)) {
49517                     return -1;
49518                 }
49519                 var len = sourceTypes.length;
49520                 for (var i = 0; i < len; i++) {
49521                     var related = isRelatedTo(sourceTypes[i], target, reportErrors && i === len - 1, undefined, intersectionState);
49522                     if (related) {
49523                         return related;
49524                     }
49525                 }
49526                 return 0;
49527             }
49528             function getUndefinedStrippedTargetIfNeeded(source, target) {
49529                 if (source.flags & 1048576 && target.flags & 1048576 &&
49530                     !(source.types[0].flags & 32768) && target.types[0].flags & 32768) {
49531                     return extractTypesOfKind(target, ~32768);
49532                 }
49533                 return target;
49534             }
49535             function eachTypeRelatedToType(source, target, reportErrors, intersectionState) {
49536                 var result = -1;
49537                 var sourceTypes = source.types;
49538                 var undefinedStrippedTarget = getUndefinedStrippedTargetIfNeeded(source, target);
49539                 for (var i = 0; i < sourceTypes.length; i++) {
49540                     var sourceType = sourceTypes[i];
49541                     if (undefinedStrippedTarget.flags & 1048576 && sourceTypes.length >= undefinedStrippedTarget.types.length && sourceTypes.length % undefinedStrippedTarget.types.length === 0) {
49542                         var related_1 = isRelatedTo(sourceType, undefinedStrippedTarget.types[i % undefinedStrippedTarget.types.length], false, undefined, intersectionState);
49543                         if (related_1) {
49544                             result &= related_1;
49545                             continue;
49546                         }
49547                     }
49548                     var related = isRelatedTo(sourceType, target, reportErrors, undefined, intersectionState);
49549                     if (!related) {
49550                         return 0;
49551                     }
49552                     result &= related;
49553                 }
49554                 return result;
49555             }
49556             function typeArgumentsRelatedTo(sources, targets, variances, reportErrors, intersectionState) {
49557                 if (sources === void 0) { sources = ts.emptyArray; }
49558                 if (targets === void 0) { targets = ts.emptyArray; }
49559                 if (variances === void 0) { variances = ts.emptyArray; }
49560                 if (sources.length !== targets.length && relation === identityRelation) {
49561                     return 0;
49562                 }
49563                 var length = sources.length <= targets.length ? sources.length : targets.length;
49564                 var result = -1;
49565                 for (var i = 0; i < length; i++) {
49566                     var varianceFlags = i < variances.length ? variances[i] : 1;
49567                     var variance = varianceFlags & 7;
49568                     if (variance !== 4) {
49569                         var s = sources[i];
49570                         var t = targets[i];
49571                         var related = -1;
49572                         if (varianceFlags & 8) {
49573                             related = relation === identityRelation ? isRelatedTo(s, t, false) : compareTypesIdentical(s, t);
49574                         }
49575                         else if (variance === 1) {
49576                             related = isRelatedTo(s, t, reportErrors, undefined, intersectionState);
49577                         }
49578                         else if (variance === 2) {
49579                             related = isRelatedTo(t, s, reportErrors, undefined, intersectionState);
49580                         }
49581                         else if (variance === 3) {
49582                             related = isRelatedTo(t, s, false);
49583                             if (!related) {
49584                                 related = isRelatedTo(s, t, reportErrors, undefined, intersectionState);
49585                             }
49586                         }
49587                         else {
49588                             related = isRelatedTo(s, t, reportErrors, undefined, intersectionState);
49589                             if (related) {
49590                                 related &= isRelatedTo(t, s, reportErrors, undefined, intersectionState);
49591                             }
49592                         }
49593                         if (!related) {
49594                             return 0;
49595                         }
49596                         result &= related;
49597                     }
49598                 }
49599                 return result;
49600             }
49601             function recursiveTypeRelatedTo(source, target, reportErrors, intersectionState) {
49602                 if (overflow) {
49603                     return 0;
49604                 }
49605                 var id = getRelationKey(source, target, intersectionState | (inPropertyCheck ? 16 : 0), relation);
49606                 var entry = relation.get(id);
49607                 if (entry !== undefined) {
49608                     if (reportErrors && entry & 2 && !(entry & 4)) {
49609                     }
49610                     else {
49611                         if (outofbandVarianceMarkerHandler) {
49612                             var saved = entry & 24;
49613                             if (saved & 8) {
49614                                 instantiateType(source, makeFunctionTypeMapper(reportUnmeasurableMarkers));
49615                             }
49616                             if (saved & 16) {
49617                                 instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
49618                             }
49619                         }
49620                         return entry & 1 ? -1 : 0;
49621                     }
49622                 }
49623                 if (!maybeKeys) {
49624                     maybeKeys = [];
49625                     sourceStack = [];
49626                     targetStack = [];
49627                 }
49628                 else {
49629                     for (var i = 0; i < maybeCount; i++) {
49630                         if (id === maybeKeys[i]) {
49631                             return 3;
49632                         }
49633                     }
49634                     if (depth === 100) {
49635                         overflow = true;
49636                         return 0;
49637                     }
49638                 }
49639                 var maybeStart = maybeCount;
49640                 maybeKeys[maybeCount] = id;
49641                 maybeCount++;
49642                 sourceStack[depth] = source;
49643                 targetStack[depth] = target;
49644                 depth++;
49645                 var saveExpandingFlags = expandingFlags;
49646                 if (!(expandingFlags & 1) && isDeeplyNestedType(source, sourceStack, depth))
49647                     expandingFlags |= 1;
49648                 if (!(expandingFlags & 2) && isDeeplyNestedType(target, targetStack, depth))
49649                     expandingFlags |= 2;
49650                 var originalHandler;
49651                 var propagatingVarianceFlags = 0;
49652                 if (outofbandVarianceMarkerHandler) {
49653                     originalHandler = outofbandVarianceMarkerHandler;
49654                     outofbandVarianceMarkerHandler = function (onlyUnreliable) {
49655                         propagatingVarianceFlags |= onlyUnreliable ? 16 : 8;
49656                         return originalHandler(onlyUnreliable);
49657                     };
49658                 }
49659                 if (expandingFlags === 3) {
49660                     ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes", "recursiveTypeRelatedTo_DepthLimit", {
49661                         sourceId: source.id,
49662                         sourceIdStack: sourceStack.map(function (t) { return t.id; }),
49663                         targetId: target.id,
49664                         targetIdStack: targetStack.map(function (t) { return t.id; }),
49665                         depth: depth,
49666                     });
49667                 }
49668                 var result = expandingFlags !== 3 ? structuredTypeRelatedTo(source, target, reportErrors, intersectionState) : 3;
49669                 if (outofbandVarianceMarkerHandler) {
49670                     outofbandVarianceMarkerHandler = originalHandler;
49671                 }
49672                 expandingFlags = saveExpandingFlags;
49673                 depth--;
49674                 if (result) {
49675                     if (result === -1 || depth === 0) {
49676                         if (result === -1 || result === 3) {
49677                             for (var i = maybeStart; i < maybeCount; i++) {
49678                                 relation.set(maybeKeys[i], 1 | propagatingVarianceFlags);
49679                             }
49680                         }
49681                         maybeCount = maybeStart;
49682                     }
49683                 }
49684                 else {
49685                     relation.set(id, (reportErrors ? 4 : 0) | 2 | propagatingVarianceFlags);
49686                     maybeCount = maybeStart;
49687                 }
49688                 return result;
49689             }
49690             function structuredTypeRelatedTo(source, target, reportErrors, intersectionState) {
49691                 ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes", "structuredTypeRelatedTo", { sourceId: source.id, targetId: target.id });
49692                 var result = structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState);
49693                 ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
49694                 return result;
49695             }
49696             function structuredTypeRelatedToWorker(source, target, reportErrors, intersectionState) {
49697                 if (intersectionState & 4) {
49698                     return propertiesRelatedTo(source, target, reportErrors, undefined, 0);
49699                 }
49700                 if (intersectionState & 8) {
49701                     if (source.flags & 1048576) {
49702                         return relation === comparableRelation ?
49703                             someTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), intersectionState & ~8) :
49704                             eachTypeRelatedToType(source, target, reportErrors && !(source.flags & 131068), intersectionState & ~8);
49705                     }
49706                     if (target.flags & 1048576) {
49707                         return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068) && !(target.flags & 131068));
49708                     }
49709                     if (target.flags & 2097152) {
49710                         return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2);
49711                     }
49712                     return someTypeRelatedToType(source, target, false, 1);
49713                 }
49714                 var flags = source.flags & target.flags;
49715                 if (relation === identityRelation && !(flags & 524288)) {
49716                     if (flags & 4194304) {
49717                         return isRelatedTo(source.type, target.type, false);
49718                     }
49719                     var result_7 = 0;
49720                     if (flags & 8388608) {
49721                         if (result_7 = isRelatedTo(source.objectType, target.objectType, false)) {
49722                             if (result_7 &= isRelatedTo(source.indexType, target.indexType, false)) {
49723                                 return result_7;
49724                             }
49725                         }
49726                     }
49727                     if (flags & 16777216) {
49728                         if (source.root.isDistributive === target.root.isDistributive) {
49729                             if (result_7 = isRelatedTo(source.checkType, target.checkType, false)) {
49730                                 if (result_7 &= isRelatedTo(source.extendsType, target.extendsType, false)) {
49731                                     if (result_7 &= isRelatedTo(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target), false)) {
49732                                         if (result_7 &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), false)) {
49733                                             return result_7;
49734                                         }
49735                                     }
49736                                 }
49737                             }
49738                         }
49739                     }
49740                     if (flags & 33554432) {
49741                         return isRelatedTo(source.substitute, target.substitute, false);
49742                     }
49743                     return 0;
49744                 }
49745                 var result;
49746                 var originalErrorInfo;
49747                 var varianceCheckFailed = false;
49748                 var saveErrorInfo = captureErrorCalculationState();
49749                 if (source.flags & (524288 | 16777216) && source.aliasSymbol &&
49750                     source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol &&
49751                     !(source.aliasTypeArgumentsContainsMarker || target.aliasTypeArgumentsContainsMarker)) {
49752                     var variances = getAliasVariances(source.aliasSymbol);
49753                     if (variances === ts.emptyArray) {
49754                         return 1;
49755                     }
49756                     var varianceResult = relateVariances(source.aliasTypeArguments, target.aliasTypeArguments, variances, intersectionState);
49757                     if (varianceResult !== undefined) {
49758                         return varianceResult;
49759                     }
49760                 }
49761                 if (isSingleElementGenericTupleType(source) && !source.target.readonly && (result = isRelatedTo(getTypeArguments(source)[0], target)) ||
49762                     isSingleElementGenericTupleType(target) && (target.target.readonly || isMutableArrayOrTuple(getBaseConstraintOfType(source) || source)) && (result = isRelatedTo(source, getTypeArguments(target)[0]))) {
49763                     return result;
49764                 }
49765                 if (target.flags & 262144) {
49766                     if (ts.getObjectFlags(source) & 32 && !source.declaration.nameType && isRelatedTo(getIndexType(target), getConstraintTypeFromMappedType(source))) {
49767                         if (!(getMappedTypeModifiers(source) & 4)) {
49768                             var templateType = getTemplateTypeFromMappedType(source);
49769                             var indexedAccessType = getIndexedAccessType(target, getTypeParameterFromMappedType(source));
49770                             if (result = isRelatedTo(templateType, indexedAccessType, reportErrors)) {
49771                                 return result;
49772                             }
49773                         }
49774                     }
49775                 }
49776                 else if (target.flags & 4194304) {
49777                     var targetType = target.type;
49778                     if (source.flags & 4194304) {
49779                         if (result = isRelatedTo(targetType, source.type, false)) {
49780                             return result;
49781                         }
49782                     }
49783                     if (isTupleType(targetType)) {
49784                         if (result = isRelatedTo(source, getKnownKeysOfTupleType(targetType), reportErrors)) {
49785                             return result;
49786                         }
49787                     }
49788                     else {
49789                         var constraint = getSimplifiedTypeOrConstraint(targetType);
49790                         if (constraint) {
49791                             if (isRelatedTo(source, getIndexType(constraint, target.stringsOnly), reportErrors) === -1) {
49792                                 return -1;
49793                             }
49794                         }
49795                     }
49796                 }
49797                 else if (target.flags & 8388608) {
49798                     if (relation === assignableRelation || relation === comparableRelation) {
49799                         var objectType = target.objectType;
49800                         var indexType = target.indexType;
49801                         var baseObjectType = getBaseConstraintOfType(objectType) || objectType;
49802                         var baseIndexType = getBaseConstraintOfType(indexType) || indexType;
49803                         if (!isGenericObjectType(baseObjectType) && !isGenericIndexType(baseIndexType)) {
49804                             var accessFlags = 2 | (baseObjectType !== objectType ? 1 : 0);
49805                             var constraint = getIndexedAccessTypeOrUndefined(baseObjectType, baseIndexType, target.noUncheckedIndexedAccessCandidate, undefined, accessFlags);
49806                             if (constraint && (result = isRelatedTo(source, constraint, reportErrors))) {
49807                                 return result;
49808                             }
49809                         }
49810                     }
49811                 }
49812                 else if (isGenericMappedType(target) && !target.declaration.nameType) {
49813                     var template = getTemplateTypeFromMappedType(target);
49814                     var modifiers = getMappedTypeModifiers(target);
49815                     if (!(modifiers & 8)) {
49816                         if (template.flags & 8388608 && template.objectType === source &&
49817                             template.indexType === getTypeParameterFromMappedType(target)) {
49818                             return -1;
49819                         }
49820                         if (!isGenericMappedType(source)) {
49821                             var targetConstraint = getConstraintTypeFromMappedType(target);
49822                             var sourceKeys = getIndexType(source, undefined, true);
49823                             var includeOptional = modifiers & 4;
49824                             var filteredByApplicability = includeOptional ? intersectTypes(targetConstraint, sourceKeys) : undefined;
49825                             if (includeOptional
49826                                 ? !(filteredByApplicability.flags & 131072)
49827                                 : isRelatedTo(targetConstraint, sourceKeys)) {
49828                                 var templateType = getTemplateTypeFromMappedType(target);
49829                                 var typeParameter = getTypeParameterFromMappedType(target);
49830                                 var nonNullComponent = extractTypesOfKind(templateType, ~98304);
49831                                 if (nonNullComponent.flags & 8388608 && nonNullComponent.indexType === typeParameter) {
49832                                     if (result = isRelatedTo(source, nonNullComponent.objectType, reportErrors)) {
49833                                         return result;
49834                                     }
49835                                 }
49836                                 else {
49837                                     var indexingType = filteredByApplicability ? getIntersectionType([filteredByApplicability, typeParameter]) : typeParameter;
49838                                     var indexedAccessType = getIndexedAccessType(source, indexingType);
49839                                     if (result = isRelatedTo(indexedAccessType, templateType, reportErrors)) {
49840                                         return result;
49841                                     }
49842                                 }
49843                             }
49844                             originalErrorInfo = errorInfo;
49845                             resetErrorInfo(saveErrorInfo);
49846                         }
49847                     }
49848                 }
49849                 else if (target.flags & 134217728 && source.flags & 128) {
49850                     if (isPatternLiteralType(target)) {
49851                         var result_8 = inferLiteralsFromTemplateLiteralType(source, target);
49852                         if (result_8 && ts.every(result_8, function (r, i) { return isStringLiteralTypeValueParsableAsType(r, target.types[i]); })) {
49853                             return -1;
49854                         }
49855                     }
49856                 }
49857                 if (source.flags & 8650752) {
49858                     if (source.flags & 8388608 && target.flags & 8388608) {
49859                         if (result = isRelatedTo(source.objectType, target.objectType, reportErrors)) {
49860                             result &= isRelatedTo(source.indexType, target.indexType, reportErrors);
49861                         }
49862                         if (result) {
49863                             resetErrorInfo(saveErrorInfo);
49864                             return result;
49865                         }
49866                     }
49867                     else {
49868                         var constraint = getConstraintOfType(source);
49869                         if (!constraint || (source.flags & 262144 && constraint.flags & 1)) {
49870                             if (result = isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864))) {
49871                                 resetErrorInfo(saveErrorInfo);
49872                                 return result;
49873                             }
49874                         }
49875                         else if (result = isRelatedTo(constraint, target, false, undefined, intersectionState)) {
49876                             resetErrorInfo(saveErrorInfo);
49877                             return result;
49878                         }
49879                         else if (result = isRelatedTo(getTypeWithThisArgument(constraint, source), target, reportErrors, undefined, intersectionState)) {
49880                             resetErrorInfo(saveErrorInfo);
49881                             return result;
49882                         }
49883                     }
49884                 }
49885                 else if (source.flags & 4194304) {
49886                     if (result = isRelatedTo(keyofConstraintType, target, reportErrors)) {
49887                         resetErrorInfo(saveErrorInfo);
49888                         return result;
49889                     }
49890                 }
49891                 else if (source.flags & 134217728) {
49892                     if (target.flags & 134217728 &&
49893                         source.texts.length === target.texts.length &&
49894                         source.types.length === target.types.length &&
49895                         ts.every(source.texts, function (t, i) { return t === target.texts[i]; }) &&
49896                         ts.every(instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers)).types, function (t, i) { return !!(target.types[i].flags & (1 | 4)) || !!isRelatedTo(t, target.types[i], false); })) {
49897                         return -1;
49898                     }
49899                     var constraint = getBaseConstraintOfType(source);
49900                     if (constraint && constraint !== source && (result = isRelatedTo(constraint, target, reportErrors))) {
49901                         resetErrorInfo(saveErrorInfo);
49902                         return result;
49903                     }
49904                 }
49905                 else if (source.flags & 268435456) {
49906                     if (target.flags & 268435456 && source.symbol === target.symbol) {
49907                         if (result = isRelatedTo(source.type, target.type, reportErrors)) {
49908                             resetErrorInfo(saveErrorInfo);
49909                             return result;
49910                         }
49911                     }
49912                     else {
49913                         var constraint = getBaseConstraintOfType(source);
49914                         if (constraint && (result = isRelatedTo(constraint, target, reportErrors))) {
49915                             resetErrorInfo(saveErrorInfo);
49916                             return result;
49917                         }
49918                     }
49919                 }
49920                 else if (source.flags & 16777216) {
49921                     if (target.flags & 16777216) {
49922                         var sourceParams = source.root.inferTypeParameters;
49923                         var sourceExtends = source.extendsType;
49924                         var mapper = void 0;
49925                         if (sourceParams) {
49926                             var ctx = createInferenceContext(sourceParams, undefined, 0, isRelatedTo);
49927                             inferTypes(ctx.inferences, target.extendsType, sourceExtends, 256 | 512);
49928                             sourceExtends = instantiateType(sourceExtends, ctx.mapper);
49929                             mapper = ctx.mapper;
49930                         }
49931                         if (isTypeIdenticalTo(sourceExtends, target.extendsType) &&
49932                             (isRelatedTo(source.checkType, target.checkType) || isRelatedTo(target.checkType, source.checkType))) {
49933                             if (result = isRelatedTo(instantiateType(getTrueTypeFromConditionalType(source), mapper), getTrueTypeFromConditionalType(target), reportErrors)) {
49934                                 result &= isRelatedTo(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target), reportErrors);
49935                             }
49936                             if (result) {
49937                                 resetErrorInfo(saveErrorInfo);
49938                                 return result;
49939                             }
49940                         }
49941                     }
49942                     else {
49943                         var distributiveConstraint = getConstraintOfDistributiveConditionalType(source);
49944                         if (distributiveConstraint) {
49945                             if (result = isRelatedTo(distributiveConstraint, target, reportErrors)) {
49946                                 resetErrorInfo(saveErrorInfo);
49947                                 return result;
49948                             }
49949                         }
49950                     }
49951                     var defaultConstraint = getDefaultConstraintOfConditionalType(source);
49952                     if (defaultConstraint) {
49953                         if (result = isRelatedTo(defaultConstraint, target, reportErrors)) {
49954                             resetErrorInfo(saveErrorInfo);
49955                             return result;
49956                         }
49957                     }
49958                 }
49959                 else {
49960                     if (relation !== subtypeRelation && relation !== strictSubtypeRelation && isPartialMappedType(target) && isEmptyObjectType(source)) {
49961                         return -1;
49962                     }
49963                     if (isGenericMappedType(target)) {
49964                         if (isGenericMappedType(source)) {
49965                             if (result = mappedTypeRelatedTo(source, target, reportErrors)) {
49966                                 resetErrorInfo(saveErrorInfo);
49967                                 return result;
49968                             }
49969                         }
49970                         return 0;
49971                     }
49972                     var sourceIsPrimitive = !!(source.flags & 131068);
49973                     if (relation !== identityRelation) {
49974                         source = getApparentType(source);
49975                     }
49976                     else if (isGenericMappedType(source)) {
49977                         return 0;
49978                     }
49979                     if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && source.target === target.target &&
49980                         !(ts.getObjectFlags(source) & 8192 || ts.getObjectFlags(target) & 8192)) {
49981                         var variances = getVariances(source.target);
49982                         if (variances === ts.emptyArray) {
49983                             return 1;
49984                         }
49985                         var varianceResult = relateVariances(getTypeArguments(source), getTypeArguments(target), variances, intersectionState);
49986                         if (varianceResult !== undefined) {
49987                             return varianceResult;
49988                         }
49989                     }
49990                     else if (isReadonlyArrayType(target) ? isArrayType(source) || isTupleType(source) : isArrayType(target) && isTupleType(source) && !source.target.readonly) {
49991                         if (relation !== identityRelation) {
49992                             return isRelatedTo(getIndexTypeOfType(source, 1) || anyType, getIndexTypeOfType(target, 1) || anyType, reportErrors);
49993                         }
49994                         else {
49995                             return 0;
49996                         }
49997                     }
49998                     else if ((relation === subtypeRelation || relation === strictSubtypeRelation) && isEmptyObjectType(target) && ts.getObjectFlags(target) & 32768 && !isEmptyObjectType(source)) {
49999                         return 0;
50000                     }
50001                     if (source.flags & (524288 | 2097152) && target.flags & 524288) {
50002                         var reportStructuralErrors = reportErrors && errorInfo === saveErrorInfo.errorInfo && !sourceIsPrimitive;
50003                         result = propertiesRelatedTo(source, target, reportStructuralErrors, undefined, intersectionState);
50004                         if (result) {
50005                             result &= signaturesRelatedTo(source, target, 0, reportStructuralErrors);
50006                             if (result) {
50007                                 result &= signaturesRelatedTo(source, target, 1, reportStructuralErrors);
50008                                 if (result) {
50009                                     result &= indexTypesRelatedTo(source, target, 0, sourceIsPrimitive, reportStructuralErrors, intersectionState);
50010                                     if (result) {
50011                                         result &= indexTypesRelatedTo(source, target, 1, sourceIsPrimitive, reportStructuralErrors, intersectionState);
50012                                     }
50013                                 }
50014                             }
50015                         }
50016                         if (varianceCheckFailed && result) {
50017                             errorInfo = originalErrorInfo || errorInfo || saveErrorInfo.errorInfo;
50018                         }
50019                         else if (result) {
50020                             return result;
50021                         }
50022                     }
50023                     if (source.flags & (524288 | 2097152) && target.flags & 1048576) {
50024                         var objectOnlyTarget = extractTypesOfKind(target, 524288 | 2097152 | 33554432);
50025                         if (objectOnlyTarget.flags & 1048576) {
50026                             var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
50027                             if (result_9) {
50028                                 return result_9;
50029                             }
50030                         }
50031                     }
50032                 }
50033                 return 0;
50034                 function relateVariances(sourceTypeArguments, targetTypeArguments, variances, intersectionState) {
50035                     if (result = typeArgumentsRelatedTo(sourceTypeArguments, targetTypeArguments, variances, reportErrors, intersectionState)) {
50036                         return result;
50037                     }
50038                     if (ts.some(variances, function (v) { return !!(v & 24); })) {
50039                         originalErrorInfo = undefined;
50040                         resetErrorInfo(saveErrorInfo);
50041                         return undefined;
50042                     }
50043                     var allowStructuralFallback = targetTypeArguments && hasCovariantVoidArgument(targetTypeArguments, variances);
50044                     varianceCheckFailed = !allowStructuralFallback;
50045                     if (variances !== ts.emptyArray && !allowStructuralFallback) {
50046                         if (varianceCheckFailed && !(reportErrors && ts.some(variances, function (v) { return (v & 7) === 0; }))) {
50047                             return 0;
50048                         }
50049                         originalErrorInfo = errorInfo;
50050                         resetErrorInfo(saveErrorInfo);
50051                     }
50052                 }
50053             }
50054             function reportUnmeasurableMarkers(p) {
50055                 if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) {
50056                     outofbandVarianceMarkerHandler(false);
50057                 }
50058                 return p;
50059             }
50060             function reportUnreliableMarkers(p) {
50061                 if (outofbandVarianceMarkerHandler && (p === markerSuperType || p === markerSubType || p === markerOtherType)) {
50062                     outofbandVarianceMarkerHandler(true);
50063                 }
50064                 return p;
50065             }
50066             function mappedTypeRelatedTo(source, target, reportErrors) {
50067                 var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) :
50068                     getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target));
50069                 if (modifiersRelated) {
50070                     var result_10;
50071                     var targetConstraint = getConstraintTypeFromMappedType(target);
50072                     var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers));
50073                     if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, reportErrors)) {
50074                         var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]);
50075                         if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) {
50076                             return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), reportErrors);
50077                         }
50078                     }
50079                 }
50080                 return 0;
50081             }
50082             function typeRelatedToDiscriminatedType(source, target) {
50083                 var sourceProperties = getPropertiesOfType(source);
50084                 var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
50085                 if (!sourcePropertiesFiltered)
50086                     return 0;
50087                 var numCombinations = 1;
50088                 for (var _i = 0, sourcePropertiesFiltered_1 = sourcePropertiesFiltered; _i < sourcePropertiesFiltered_1.length; _i++) {
50089                     var sourceProperty = sourcePropertiesFiltered_1[_i];
50090                     numCombinations *= countTypes(getTypeOfSymbol(sourceProperty));
50091                     if (numCombinations > 25) {
50092                         ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes", "typeRelatedToDiscriminatedType_DepthLimit", { sourceId: source.id, targetId: target.id, numCombinations: numCombinations });
50093                         return 0;
50094                     }
50095                 }
50096                 var sourceDiscriminantTypes = new Array(sourcePropertiesFiltered.length);
50097                 var excludedProperties = new ts.Set();
50098                 for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
50099                     var sourceProperty = sourcePropertiesFiltered[i];
50100                     var sourcePropertyType = getTypeOfSymbol(sourceProperty);
50101                     sourceDiscriminantTypes[i] = sourcePropertyType.flags & 1048576
50102                         ? sourcePropertyType.types
50103                         : [sourcePropertyType];
50104                     excludedProperties.add(sourceProperty.escapedName);
50105                 }
50106                 var discriminantCombinations = ts.cartesianProduct(sourceDiscriminantTypes);
50107                 var matchingTypes = [];
50108                 var _loop_17 = function (combination) {
50109                     var hasMatch = false;
50110                     outer: for (var _c = 0, _d = target.types; _c < _d.length; _c++) {
50111                         var type = _d[_c];
50112                         var _loop_18 = function (i) {
50113                             var sourceProperty = sourcePropertiesFiltered[i];
50114                             var targetProperty = getPropertyOfType(type, sourceProperty.escapedName);
50115                             if (!targetProperty)
50116                                 return "continue-outer";
50117                             if (sourceProperty === targetProperty)
50118                                 return "continue";
50119                             var related = propertyRelatedTo(source, target, sourceProperty, targetProperty, function (_) { return combination[i]; }, false, 0, strictNullChecks || relation === comparableRelation);
50120                             if (!related) {
50121                                 return "continue-outer";
50122                             }
50123                         };
50124                         for (var i = 0; i < sourcePropertiesFiltered.length; i++) {
50125                             var state_7 = _loop_18(i);
50126                             switch (state_7) {
50127                                 case "continue-outer": continue outer;
50128                             }
50129                         }
50130                         ts.pushIfUnique(matchingTypes, type, ts.equateValues);
50131                         hasMatch = true;
50132                     }
50133                     if (!hasMatch) {
50134                         return { value: 0 };
50135                     }
50136                 };
50137                 for (var _a = 0, discriminantCombinations_1 = discriminantCombinations; _a < discriminantCombinations_1.length; _a++) {
50138                     var combination = discriminantCombinations_1[_a];
50139                     var state_6 = _loop_17(combination);
50140                     if (typeof state_6 === "object")
50141                         return state_6.value;
50142                 }
50143                 var result = -1;
50144                 for (var _b = 0, matchingTypes_1 = matchingTypes; _b < matchingTypes_1.length; _b++) {
50145                     var type = matchingTypes_1[_b];
50146                     result &= propertiesRelatedTo(source, type, false, excludedProperties, 0);
50147                     if (result) {
50148                         result &= signaturesRelatedTo(source, type, 0, false);
50149                         if (result) {
50150                             result &= signaturesRelatedTo(source, type, 1, false);
50151                             if (result) {
50152                                 result &= indexTypesRelatedTo(source, type, 0, false, false, 0);
50153                                 if (result && !(isTupleType(source) && isTupleType(type))) {
50154                                     result &= indexTypesRelatedTo(source, type, 1, false, false, 0);
50155                                 }
50156                             }
50157                         }
50158                     }
50159                     if (!result) {
50160                         return result;
50161                     }
50162                 }
50163                 return result;
50164             }
50165             function excludeProperties(properties, excludedProperties) {
50166                 if (!excludedProperties || properties.length === 0)
50167                     return properties;
50168                 var result;
50169                 for (var i = 0; i < properties.length; i++) {
50170                     if (!excludedProperties.has(properties[i].escapedName)) {
50171                         if (result) {
50172                             result.push(properties[i]);
50173                         }
50174                     }
50175                     else if (!result) {
50176                         result = properties.slice(0, i);
50177                     }
50178                 }
50179                 return result || properties;
50180             }
50181             function isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState) {
50182                 var targetIsOptional = strictNullChecks && !!(ts.getCheckFlags(targetProp) & 48);
50183                 var source = getTypeOfSourceProperty(sourceProp);
50184                 if (ts.getCheckFlags(targetProp) & 65536 && !getSymbolLinks(targetProp).type) {
50185                     var links = getSymbolLinks(targetProp);
50186                     ts.Debug.assertIsDefined(links.deferralParent);
50187                     ts.Debug.assertIsDefined(links.deferralConstituents);
50188                     var unionParent = !!(links.deferralParent.flags & 1048576);
50189                     var result_11 = unionParent ? 0 : -1;
50190                     var targetTypes = links.deferralConstituents;
50191                     for (var _i = 0, targetTypes_3 = targetTypes; _i < targetTypes_3.length; _i++) {
50192                         var targetType = targetTypes_3[_i];
50193                         var related = isRelatedTo(source, targetType, false, undefined, unionParent ? 0 : 2);
50194                         if (!unionParent) {
50195                             if (!related) {
50196                                 return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors);
50197                             }
50198                             result_11 &= related;
50199                         }
50200                         else {
50201                             if (related) {
50202                                 return related;
50203                             }
50204                         }
50205                     }
50206                     if (unionParent && !result_11 && targetIsOptional) {
50207                         result_11 = isRelatedTo(source, undefinedType);
50208                     }
50209                     if (unionParent && !result_11 && reportErrors) {
50210                         return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors);
50211                     }
50212                     return result_11;
50213                 }
50214                 else {
50215                     return isRelatedTo(source, addOptionality(getTypeOfSymbol(targetProp), targetIsOptional), reportErrors, undefined, intersectionState);
50216                 }
50217             }
50218             function propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState, skipOptional) {
50219                 var sourcePropFlags = ts.getDeclarationModifierFlagsFromSymbol(sourceProp);
50220                 var targetPropFlags = ts.getDeclarationModifierFlagsFromSymbol(targetProp);
50221                 if (sourcePropFlags & 8 || targetPropFlags & 8) {
50222                     if (sourceProp.valueDeclaration !== targetProp.valueDeclaration) {
50223                         if (reportErrors) {
50224                             if (sourcePropFlags & 8 && targetPropFlags & 8) {
50225                                 reportError(ts.Diagnostics.Types_have_separate_declarations_of_a_private_property_0, symbolToString(targetProp));
50226                             }
50227                             else {
50228                                 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));
50229                             }
50230                         }
50231                         return 0;
50232                     }
50233                 }
50234                 else if (targetPropFlags & 16) {
50235                     if (!isValidOverrideOf(sourceProp, targetProp)) {
50236                         if (reportErrors) {
50237                             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));
50238                         }
50239                         return 0;
50240                     }
50241                 }
50242                 else if (sourcePropFlags & 16) {
50243                     if (reportErrors) {
50244                         reportError(ts.Diagnostics.Property_0_is_protected_in_type_1_but_public_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target));
50245                     }
50246                     return 0;
50247                 }
50248                 var related = isPropertySymbolTypeRelated(sourceProp, targetProp, getTypeOfSourceProperty, reportErrors, intersectionState);
50249                 if (!related) {
50250                     if (reportErrors) {
50251                         reportIncompatibleError(ts.Diagnostics.Types_of_property_0_are_incompatible, symbolToString(targetProp));
50252                     }
50253                     return 0;
50254                 }
50255                 if (!skipOptional && sourceProp.flags & 16777216 && !(targetProp.flags & 16777216)) {
50256                     if (reportErrors) {
50257                         reportError(ts.Diagnostics.Property_0_is_optional_in_type_1_but_required_in_type_2, symbolToString(targetProp), typeToString(source), typeToString(target));
50258                     }
50259                     return 0;
50260                 }
50261                 return related;
50262             }
50263             function reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties) {
50264                 var shouldSkipElaboration = false;
50265                 if (unmatchedProperty.valueDeclaration
50266                     && ts.isNamedDeclaration(unmatchedProperty.valueDeclaration)
50267                     && ts.isPrivateIdentifier(unmatchedProperty.valueDeclaration.name)
50268                     && source.symbol
50269                     && source.symbol.flags & 32) {
50270                     var privateIdentifierDescription = unmatchedProperty.valueDeclaration.name.escapedText;
50271                     var symbolTableKey = ts.getSymbolNameForPrivateIdentifier(source.symbol, privateIdentifierDescription);
50272                     if (symbolTableKey && getPropertyOfType(source, symbolTableKey)) {
50273                         var sourceName = ts.factory.getDeclarationName(source.symbol.valueDeclaration);
50274                         var targetName = ts.factory.getDeclarationName(target.symbol.valueDeclaration);
50275                         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));
50276                         return;
50277                     }
50278                 }
50279                 var props = ts.arrayFrom(getUnmatchedProperties(source, target, requireOptionalProperties, false));
50280                 if (!headMessage || (headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_interface_1.code &&
50281                     headMessage.code !== ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass.code)) {
50282                     shouldSkipElaboration = true;
50283                 }
50284                 if (props.length === 1) {
50285                     var propName = symbolToString(unmatchedProperty);
50286                     reportError.apply(void 0, __spreadArray([ts.Diagnostics.Property_0_is_missing_in_type_1_but_required_in_type_2, propName], getTypeNamesForErrorDisplay(source, target)));
50287                     if (ts.length(unmatchedProperty.declarations)) {
50288                         associateRelatedInfo(ts.createDiagnosticForNode(unmatchedProperty.declarations[0], ts.Diagnostics._0_is_declared_here, propName));
50289                     }
50290                     if (shouldSkipElaboration && errorInfo) {
50291                         overrideNextErrorInfo++;
50292                     }
50293                 }
50294                 else if (tryElaborateArrayLikeErrors(source, target, false)) {
50295                     if (props.length > 5) {
50296                         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);
50297                     }
50298                     else {
50299                         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(", "));
50300                     }
50301                     if (shouldSkipElaboration && errorInfo) {
50302                         overrideNextErrorInfo++;
50303                     }
50304                 }
50305             }
50306             function propertiesRelatedTo(source, target, reportErrors, excludedProperties, intersectionState) {
50307                 if (relation === identityRelation) {
50308                     return propertiesIdenticalTo(source, target, excludedProperties);
50309                 }
50310                 var result = -1;
50311                 if (isTupleType(target)) {
50312                     if (isArrayType(source) || isTupleType(source)) {
50313                         if (!target.target.readonly && (isReadonlyArrayType(source) || isTupleType(source) && source.target.readonly)) {
50314                             return 0;
50315                         }
50316                         var sourceArity = getTypeReferenceArity(source);
50317                         var targetArity = getTypeReferenceArity(target);
50318                         var sourceRestFlag = isTupleType(source) ? source.target.combinedFlags & 4 : 4;
50319                         var targetRestFlag = target.target.combinedFlags & 4;
50320                         var sourceMinLength = isTupleType(source) ? source.target.minLength : 0;
50321                         var targetMinLength = target.target.minLength;
50322                         if (!sourceRestFlag && sourceArity < targetMinLength) {
50323                             if (reportErrors) {
50324                                 reportError(ts.Diagnostics.Source_has_0_element_s_but_target_requires_1, sourceArity, targetMinLength);
50325                             }
50326                             return 0;
50327                         }
50328                         if (!targetRestFlag && targetArity < sourceMinLength) {
50329                             if (reportErrors) {
50330                                 reportError(ts.Diagnostics.Source_has_0_element_s_but_target_allows_only_1, sourceMinLength, targetArity);
50331                             }
50332                             return 0;
50333                         }
50334                         if (!targetRestFlag && sourceRestFlag) {
50335                             if (reportErrors) {
50336                                 if (sourceMinLength < targetMinLength) {
50337                                     reportError(ts.Diagnostics.Target_requires_0_element_s_but_source_may_have_fewer, targetMinLength);
50338                                 }
50339                                 else {
50340                                     reportError(ts.Diagnostics.Target_allows_only_0_element_s_but_source_may_have_more, targetArity);
50341                                 }
50342                             }
50343                             return 0;
50344                         }
50345                         var sourceTypeArguments = getTypeArguments(source);
50346                         var targetTypeArguments = getTypeArguments(target);
50347                         var startCount = Math.min(isTupleType(source) ? getStartElementCount(source.target, 11) : 0, getStartElementCount(target.target, 11));
50348                         var endCount = Math.min(isTupleType(source) ? getEndElementCount(source.target, 11) : 0, targetRestFlag ? getEndElementCount(target.target, 11) : 0);
50349                         var canExcludeDiscriminants = !!excludedProperties;
50350                         for (var i = 0; i < targetArity; i++) {
50351                             var sourceIndex = i < targetArity - endCount ? i : i + sourceArity - targetArity;
50352                             var sourceFlags = isTupleType(source) && (i < startCount || i >= targetArity - endCount) ? source.target.elementFlags[sourceIndex] : 4;
50353                             var targetFlags = target.target.elementFlags[i];
50354                             if (targetFlags & 8 && !(sourceFlags & 8)) {
50355                                 if (reportErrors) {
50356                                     reportError(ts.Diagnostics.Source_provides_no_match_for_variadic_element_at_position_0_in_target, i);
50357                                 }
50358                                 return 0;
50359                             }
50360                             if (sourceFlags & 8 && !(targetFlags & 12)) {
50361                                 if (reportErrors) {
50362                                     reportError(ts.Diagnostics.Variadic_element_at_position_0_in_source_does_not_match_element_at_position_1_in_target, sourceIndex, i);
50363                                 }
50364                                 return 0;
50365                             }
50366                             if (targetFlags & 1 && !(sourceFlags & 1)) {
50367                                 if (reportErrors) {
50368                                     reportError(ts.Diagnostics.Source_provides_no_match_for_required_element_at_position_0_in_target, i);
50369                                 }
50370                                 return 0;
50371                             }
50372                             if (canExcludeDiscriminants) {
50373                                 if (sourceFlags & 12 || targetFlags & 12) {
50374                                     canExcludeDiscriminants = false;
50375                                 }
50376                                 if (canExcludeDiscriminants && (excludedProperties === null || excludedProperties === void 0 ? void 0 : excludedProperties.has(("" + i)))) {
50377                                     continue;
50378                                 }
50379                             }
50380                             var sourceType = !isTupleType(source) ? sourceTypeArguments[0] :
50381                                 i < startCount || i >= targetArity - endCount ? sourceTypeArguments[sourceIndex] :
50382                                     getElementTypeOfSliceOfTupleType(source, startCount, endCount) || neverType;
50383                             var targetType = targetTypeArguments[i];
50384                             var targetCheckType = sourceFlags & 8 && targetFlags & 4 ? createArrayType(targetType) : targetType;
50385                             var related = isRelatedTo(sourceType, targetCheckType, reportErrors, undefined, intersectionState);
50386                             if (!related) {
50387                                 if (reportErrors) {
50388                                     if (i < startCount || i >= targetArity - endCount || sourceArity - startCount - endCount === 1) {
50389                                         reportIncompatibleError(ts.Diagnostics.Type_at_position_0_in_source_is_not_compatible_with_type_at_position_1_in_target, sourceIndex, i);
50390                                     }
50391                                     else {
50392                                         reportIncompatibleError(ts.Diagnostics.Type_at_positions_0_through_1_in_source_is_not_compatible_with_type_at_position_2_in_target, startCount, sourceArity - endCount - 1, i);
50393                                     }
50394                                 }
50395                                 return 0;
50396                             }
50397                             result &= related;
50398                         }
50399                         return result;
50400                     }
50401                     if (target.target.combinedFlags & 12) {
50402                         return 0;
50403                     }
50404                 }
50405                 var requireOptionalProperties = (relation === subtypeRelation || relation === strictSubtypeRelation) && !isObjectLiteralType(source) && !isEmptyArrayLiteralType(source) && !isTupleType(source);
50406                 var unmatchedProperty = getUnmatchedProperty(source, target, requireOptionalProperties, false);
50407                 if (unmatchedProperty) {
50408                     if (reportErrors) {
50409                         reportUnmatchedProperty(source, target, unmatchedProperty, requireOptionalProperties);
50410                     }
50411                     return 0;
50412                 }
50413                 if (isObjectLiteralType(target)) {
50414                     for (var _i = 0, _a = excludeProperties(getPropertiesOfType(source), excludedProperties); _i < _a.length; _i++) {
50415                         var sourceProp = _a[_i];
50416                         if (!getPropertyOfObjectType(target, sourceProp.escapedName)) {
50417                             var sourceType = getTypeOfSymbol(sourceProp);
50418                             if (!(sourceType === undefinedType || sourceType === undefinedWideningType || sourceType === optionalType)) {
50419                                 if (reportErrors) {
50420                                     reportError(ts.Diagnostics.Property_0_does_not_exist_on_type_1, symbolToString(sourceProp), typeToString(target));
50421                                 }
50422                                 return 0;
50423                             }
50424                         }
50425                     }
50426                 }
50427                 var properties = getPropertiesOfType(target);
50428                 var numericNamesOnly = isTupleType(source) && isTupleType(target);
50429                 for (var _b = 0, _c = excludeProperties(properties, excludedProperties); _b < _c.length; _b++) {
50430                     var targetProp = _c[_b];
50431                     var name = targetProp.escapedName;
50432                     if (!(targetProp.flags & 4194304) && (!numericNamesOnly || isNumericLiteralName(name) || name === "length")) {
50433                         var sourceProp = getPropertyOfType(source, name);
50434                         if (sourceProp && sourceProp !== targetProp) {
50435                             var related = propertyRelatedTo(source, target, sourceProp, targetProp, getTypeOfSymbol, reportErrors, intersectionState, relation === comparableRelation);
50436                             if (!related) {
50437                                 return 0;
50438                             }
50439                             result &= related;
50440                         }
50441                     }
50442                 }
50443                 return result;
50444             }
50445             function propertiesIdenticalTo(source, target, excludedProperties) {
50446                 if (!(source.flags & 524288 && target.flags & 524288)) {
50447                     return 0;
50448                 }
50449                 var sourceProperties = excludeProperties(getPropertiesOfObjectType(source), excludedProperties);
50450                 var targetProperties = excludeProperties(getPropertiesOfObjectType(target), excludedProperties);
50451                 if (sourceProperties.length !== targetProperties.length) {
50452                     return 0;
50453                 }
50454                 var result = -1;
50455                 for (var _i = 0, sourceProperties_1 = sourceProperties; _i < sourceProperties_1.length; _i++) {
50456                     var sourceProp = sourceProperties_1[_i];
50457                     var targetProp = getPropertyOfObjectType(target, sourceProp.escapedName);
50458                     if (!targetProp) {
50459                         return 0;
50460                     }
50461                     var related = compareProperties(sourceProp, targetProp, isRelatedTo);
50462                     if (!related) {
50463                         return 0;
50464                     }
50465                     result &= related;
50466                 }
50467                 return result;
50468             }
50469             function signaturesRelatedTo(source, target, kind, reportErrors) {
50470                 var _a, _b;
50471                 if (relation === identityRelation) {
50472                     return signaturesIdenticalTo(source, target, kind);
50473                 }
50474                 if (target === anyFunctionType || source === anyFunctionType) {
50475                     return -1;
50476                 }
50477                 var sourceIsJSConstructor = source.symbol && isJSConstructor(source.symbol.valueDeclaration);
50478                 var targetIsJSConstructor = target.symbol && isJSConstructor(target.symbol.valueDeclaration);
50479                 var sourceSignatures = getSignaturesOfType(source, (sourceIsJSConstructor && kind === 1) ?
50480                     0 : kind);
50481                 var targetSignatures = getSignaturesOfType(target, (targetIsJSConstructor && kind === 1) ?
50482                     0 : kind);
50483                 if (kind === 1 && sourceSignatures.length && targetSignatures.length) {
50484                     var sourceIsAbstract = !!(sourceSignatures[0].flags & 4);
50485                     var targetIsAbstract = !!(targetSignatures[0].flags & 4);
50486                     if (sourceIsAbstract && !targetIsAbstract) {
50487                         if (reportErrors) {
50488                             reportError(ts.Diagnostics.Cannot_assign_an_abstract_constructor_type_to_a_non_abstract_constructor_type);
50489                         }
50490                         return 0;
50491                     }
50492                     if (!constructorVisibilitiesAreCompatible(sourceSignatures[0], targetSignatures[0], reportErrors)) {
50493                         return 0;
50494                     }
50495                 }
50496                 var result = -1;
50497                 var saveErrorInfo = captureErrorCalculationState();
50498                 var incompatibleReporter = kind === 1 ? reportIncompatibleConstructSignatureReturn : reportIncompatibleCallSignatureReturn;
50499                 var sourceObjectFlags = ts.getObjectFlags(source);
50500                 var targetObjectFlags = ts.getObjectFlags(target);
50501                 if (sourceObjectFlags & 64 && targetObjectFlags & 64 && source.symbol === target.symbol) {
50502                     for (var i = 0; i < targetSignatures.length; i++) {
50503                         var related = signatureRelatedTo(sourceSignatures[i], targetSignatures[i], true, reportErrors, incompatibleReporter(sourceSignatures[i], targetSignatures[i]));
50504                         if (!related) {
50505                             return 0;
50506                         }
50507                         result &= related;
50508                     }
50509                 }
50510                 else if (sourceSignatures.length === 1 && targetSignatures.length === 1) {
50511                     var eraseGenerics = relation === comparableRelation || !!compilerOptions.noStrictGenericChecks;
50512                     var sourceSignature = ts.first(sourceSignatures);
50513                     var targetSignature = ts.first(targetSignatures);
50514                     result = signatureRelatedTo(sourceSignature, targetSignature, eraseGenerics, reportErrors, incompatibleReporter(sourceSignature, targetSignature));
50515                     if (!result && reportErrors && kind === 1 && (sourceObjectFlags & targetObjectFlags) &&
50516                         (((_a = targetSignature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 166 || ((_b = sourceSignature.declaration) === null || _b === void 0 ? void 0 : _b.kind) === 166)) {
50517                         var constructSignatureToString = function (signature) {
50518                             return signatureToString(signature, undefined, 262144, kind);
50519                         };
50520                         reportError(ts.Diagnostics.Type_0_is_not_assignable_to_type_1, constructSignatureToString(sourceSignature), constructSignatureToString(targetSignature));
50521                         reportError(ts.Diagnostics.Types_of_construct_signatures_are_incompatible);
50522                         return result;
50523                     }
50524                 }
50525                 else {
50526                     outer: for (var _i = 0, targetSignatures_1 = targetSignatures; _i < targetSignatures_1.length; _i++) {
50527                         var t = targetSignatures_1[_i];
50528                         var shouldElaborateErrors = reportErrors;
50529                         for (var _c = 0, sourceSignatures_1 = sourceSignatures; _c < sourceSignatures_1.length; _c++) {
50530                             var s = sourceSignatures_1[_c];
50531                             var related = signatureRelatedTo(s, t, true, shouldElaborateErrors, incompatibleReporter(s, t));
50532                             if (related) {
50533                                 result &= related;
50534                                 resetErrorInfo(saveErrorInfo);
50535                                 continue outer;
50536                             }
50537                             shouldElaborateErrors = false;
50538                         }
50539                         if (shouldElaborateErrors) {
50540                             reportError(ts.Diagnostics.Type_0_provides_no_match_for_the_signature_1, typeToString(source), signatureToString(t, undefined, undefined, kind));
50541                         }
50542                         return 0;
50543                     }
50544                 }
50545                 return result;
50546             }
50547             function reportIncompatibleCallSignatureReturn(siga, sigb) {
50548                 if (siga.parameters.length === 0 && sigb.parameters.length === 0) {
50549                     return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); };
50550                 }
50551                 return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Call_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); };
50552             }
50553             function reportIncompatibleConstructSignatureReturn(siga, sigb) {
50554                 if (siga.parameters.length === 0 && sigb.parameters.length === 0) {
50555                     return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1, typeToString(source), typeToString(target)); };
50556                 }
50557                 return function (source, target) { return reportIncompatibleError(ts.Diagnostics.Construct_signature_return_types_0_and_1_are_incompatible, typeToString(source), typeToString(target)); };
50558             }
50559             function signatureRelatedTo(source, target, erase, reportErrors, incompatibleReporter) {
50560                 return compareSignaturesRelated(erase ? getErasedSignature(source) : source, erase ? getErasedSignature(target) : target, relation === strictSubtypeRelation ? 8 : 0, reportErrors, reportError, incompatibleReporter, isRelatedTo, makeFunctionTypeMapper(reportUnreliableMarkers));
50561             }
50562             function signaturesIdenticalTo(source, target, kind) {
50563                 var sourceSignatures = getSignaturesOfType(source, kind);
50564                 var targetSignatures = getSignaturesOfType(target, kind);
50565                 if (sourceSignatures.length !== targetSignatures.length) {
50566                     return 0;
50567                 }
50568                 var result = -1;
50569                 for (var i = 0; i < sourceSignatures.length; i++) {
50570                     var related = compareSignaturesIdentical(sourceSignatures[i], targetSignatures[i], false, false, false, isRelatedTo);
50571                     if (!related) {
50572                         return 0;
50573                     }
50574                     result &= related;
50575                 }
50576                 return result;
50577             }
50578             function eachPropertyRelatedTo(source, target, kind, reportErrors) {
50579                 var result = -1;
50580                 var props = source.flags & 2097152 ? getPropertiesOfUnionOrIntersectionType(source) : getPropertiesOfObjectType(source);
50581                 for (var _i = 0, props_2 = props; _i < props_2.length; _i++) {
50582                     var prop = props_2[_i];
50583                     if (isIgnoredJsxProperty(source, prop)) {
50584                         continue;
50585                     }
50586                     var nameType = getSymbolLinks(prop).nameType;
50587                     if (nameType && nameType.flags & 8192) {
50588                         continue;
50589                     }
50590                     if (kind === 0 || isNumericLiteralName(prop.escapedName)) {
50591                         var propType = getTypeOfSymbol(prop);
50592                         var type = propType.flags & 32768 || !(kind === 0 && prop.flags & 16777216)
50593                             ? propType
50594                             : getTypeWithFacts(propType, 524288);
50595                         var related = isRelatedTo(type, target, reportErrors);
50596                         if (!related) {
50597                             if (reportErrors) {
50598                                 reportError(ts.Diagnostics.Property_0_is_incompatible_with_index_signature, symbolToString(prop));
50599                             }
50600                             return 0;
50601                         }
50602                         result &= related;
50603                     }
50604                 }
50605                 return result;
50606             }
50607             function indexTypeRelatedTo(sourceType, targetType, reportErrors) {
50608                 var related = isRelatedTo(sourceType, targetType, reportErrors);
50609                 if (!related && reportErrors) {
50610                     reportError(ts.Diagnostics.Index_signatures_are_incompatible);
50611                 }
50612                 return related;
50613             }
50614             function indexTypesRelatedTo(source, target, kind, sourceIsPrimitive, reportErrors, intersectionState) {
50615                 if (relation === identityRelation) {
50616                     return indexTypesIdenticalTo(source, target, kind);
50617                 }
50618                 var targetType = getIndexTypeOfType(target, kind);
50619                 if (!targetType || targetType.flags & 1 && !sourceIsPrimitive) {
50620                     return -1;
50621                 }
50622                 if (isGenericMappedType(source)) {
50623                     return getIndexTypeOfType(target, 0) ? isRelatedTo(getTemplateTypeFromMappedType(source), targetType, reportErrors) : 0;
50624                 }
50625                 var indexType = getIndexTypeOfType(source, kind) || kind === 1 && getIndexTypeOfType(source, 0);
50626                 if (indexType) {
50627                     return indexTypeRelatedTo(indexType, targetType, reportErrors);
50628                 }
50629                 if (!(intersectionState & 1) && isObjectTypeWithInferableIndex(source)) {
50630                     var related = eachPropertyRelatedTo(source, targetType, kind, reportErrors);
50631                     if (related && kind === 0) {
50632                         var numberIndexType = getIndexTypeOfType(source, 1);
50633                         if (numberIndexType) {
50634                             related &= indexTypeRelatedTo(numberIndexType, targetType, reportErrors);
50635                         }
50636                     }
50637                     return related;
50638                 }
50639                 if (reportErrors) {
50640                     reportError(ts.Diagnostics.Index_signature_is_missing_in_type_0, typeToString(source));
50641                 }
50642                 return 0;
50643             }
50644             function indexTypesIdenticalTo(source, target, indexKind) {
50645                 var targetInfo = getIndexInfoOfType(target, indexKind);
50646                 var sourceInfo = getIndexInfoOfType(source, indexKind);
50647                 if (!sourceInfo && !targetInfo) {
50648                     return -1;
50649                 }
50650                 if (sourceInfo && targetInfo && sourceInfo.isReadonly === targetInfo.isReadonly) {
50651                     return isRelatedTo(sourceInfo.type, targetInfo.type);
50652                 }
50653                 return 0;
50654             }
50655             function constructorVisibilitiesAreCompatible(sourceSignature, targetSignature, reportErrors) {
50656                 if (!sourceSignature.declaration || !targetSignature.declaration) {
50657                     return true;
50658                 }
50659                 var sourceAccessibility = ts.getSelectedEffectiveModifierFlags(sourceSignature.declaration, 24);
50660                 var targetAccessibility = ts.getSelectedEffectiveModifierFlags(targetSignature.declaration, 24);
50661                 if (targetAccessibility === 8) {
50662                     return true;
50663                 }
50664                 if (targetAccessibility === 16 && sourceAccessibility !== 8) {
50665                     return true;
50666                 }
50667                 if (targetAccessibility !== 16 && !sourceAccessibility) {
50668                     return true;
50669                 }
50670                 if (reportErrors) {
50671                     reportError(ts.Diagnostics.Cannot_assign_a_0_constructor_type_to_a_1_constructor_type, visibilityToString(sourceAccessibility), visibilityToString(targetAccessibility));
50672                 }
50673                 return false;
50674             }
50675         }
50676         function typeCouldHaveTopLevelSingletonTypes(type) {
50677             if (type.flags & 16) {
50678                 return false;
50679             }
50680             if (type.flags & 3145728) {
50681                 return !!ts.forEach(type.types, typeCouldHaveTopLevelSingletonTypes);
50682             }
50683             if (type.flags & 465829888) {
50684                 var constraint = getConstraintOfType(type);
50685                 if (constraint && constraint !== type) {
50686                     return typeCouldHaveTopLevelSingletonTypes(constraint);
50687                 }
50688             }
50689             return isUnitType(type) || !!(type.flags & 134217728);
50690         }
50691         function getBestMatchingType(source, target, isRelatedTo) {
50692             if (isRelatedTo === void 0) { isRelatedTo = compareTypesAssignable; }
50693             return findMatchingDiscriminantType(source, target, isRelatedTo, true) ||
50694                 findMatchingTypeReferenceOrTypeAliasReference(source, target) ||
50695                 findBestTypeForObjectLiteral(source, target) ||
50696                 findBestTypeForInvokable(source, target) ||
50697                 findMostOverlappyType(source, target);
50698         }
50699         function discriminateTypeByDiscriminableItems(target, discriminators, related, defaultValue, skipPartial) {
50700             var discriminable = target.types.map(function (_) { return undefined; });
50701             for (var _i = 0, discriminators_1 = discriminators; _i < discriminators_1.length; _i++) {
50702                 var _a = discriminators_1[_i], getDiscriminatingType = _a[0], propertyName = _a[1];
50703                 var targetProp = getUnionOrIntersectionProperty(target, propertyName);
50704                 if (skipPartial && targetProp && ts.getCheckFlags(targetProp) & 16) {
50705                     continue;
50706                 }
50707                 var i = 0;
50708                 for (var _b = 0, _c = target.types; _b < _c.length; _b++) {
50709                     var type = _c[_b];
50710                     var targetType = getTypeOfPropertyOfType(type, propertyName);
50711                     if (targetType && related(getDiscriminatingType(), targetType)) {
50712                         discriminable[i] = discriminable[i] === undefined ? true : discriminable[i];
50713                     }
50714                     else {
50715                         discriminable[i] = false;
50716                     }
50717                     i++;
50718                 }
50719             }
50720             var match = discriminable.indexOf(true);
50721             if (match === -1) {
50722                 return defaultValue;
50723             }
50724             var nextMatch = discriminable.indexOf(true, match + 1);
50725             while (nextMatch !== -1) {
50726                 if (!isTypeIdenticalTo(target.types[match], target.types[nextMatch])) {
50727                     return defaultValue;
50728                 }
50729                 nextMatch = discriminable.indexOf(true, nextMatch + 1);
50730             }
50731             return target.types[match];
50732         }
50733         function isWeakType(type) {
50734             if (type.flags & 524288) {
50735                 var resolved = resolveStructuredTypeMembers(type);
50736                 return resolved.callSignatures.length === 0 && resolved.constructSignatures.length === 0 &&
50737                     !resolved.stringIndexInfo && !resolved.numberIndexInfo &&
50738                     resolved.properties.length > 0 &&
50739                     ts.every(resolved.properties, function (p) { return !!(p.flags & 16777216); });
50740             }
50741             if (type.flags & 2097152) {
50742                 return ts.every(type.types, isWeakType);
50743             }
50744             return false;
50745         }
50746         function hasCommonProperties(source, target, isComparingJsxAttributes) {
50747             for (var _i = 0, _a = getPropertiesOfType(source); _i < _a.length; _i++) {
50748                 var prop = _a[_i];
50749                 if (isKnownProperty(target, prop.escapedName, isComparingJsxAttributes)) {
50750                     return true;
50751                 }
50752             }
50753             return false;
50754         }
50755         function getMarkerTypeReference(type, source, target) {
50756             var result = createTypeReference(type, ts.map(type.typeParameters, function (t) { return t === source ? target : t; }));
50757             result.objectFlags |= 8192;
50758             return result;
50759         }
50760         function getAliasVariances(symbol) {
50761             var links = getSymbolLinks(symbol);
50762             return getVariancesWorker(links.typeParameters, links, function (_links, param, marker) {
50763                 var type = getTypeAliasInstantiation(symbol, instantiateTypes(links.typeParameters, makeUnaryTypeMapper(param, marker)));
50764                 type.aliasTypeArgumentsContainsMarker = true;
50765                 return type;
50766             });
50767         }
50768         function getVariancesWorker(typeParameters, cache, createMarkerType) {
50769             var _a, _b, _c;
50770             if (typeParameters === void 0) { typeParameters = ts.emptyArray; }
50771             var variances = cache.variances;
50772             if (!variances) {
50773                 ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes", "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 });
50774                 cache.variances = ts.emptyArray;
50775                 variances = [];
50776                 var _loop_19 = function (tp) {
50777                     var unmeasurable = false;
50778                     var unreliable = false;
50779                     var oldHandler = outofbandVarianceMarkerHandler;
50780                     outofbandVarianceMarkerHandler = function (onlyUnreliable) { return onlyUnreliable ? unreliable = true : unmeasurable = true; };
50781                     var typeWithSuper = createMarkerType(cache, tp, markerSuperType);
50782                     var typeWithSub = createMarkerType(cache, tp, markerSubType);
50783                     var variance = (isTypeAssignableTo(typeWithSub, typeWithSuper) ? 1 : 0) |
50784                         (isTypeAssignableTo(typeWithSuper, typeWithSub) ? 2 : 0);
50785                     if (variance === 3 && isTypeAssignableTo(createMarkerType(cache, tp, markerOtherType), typeWithSuper)) {
50786                         variance = 4;
50787                     }
50788                     outofbandVarianceMarkerHandler = oldHandler;
50789                     if (unmeasurable || unreliable) {
50790                         if (unmeasurable) {
50791                             variance |= 8;
50792                         }
50793                         if (unreliable) {
50794                             variance |= 16;
50795                         }
50796                     }
50797                     variances.push(variance);
50798                 };
50799                 for (var _i = 0, typeParameters_1 = typeParameters; _i < typeParameters_1.length; _i++) {
50800                     var tp = typeParameters_1[_i];
50801                     _loop_19(tp);
50802                 }
50803                 cache.variances = variances;
50804                 ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
50805             }
50806             return variances;
50807         }
50808         function getVariances(type) {
50809             if (type === globalArrayType || type === globalReadonlyArrayType || type.objectFlags & 8) {
50810                 return arrayVariances;
50811             }
50812             return getVariancesWorker(type.typeParameters, type, getMarkerTypeReference);
50813         }
50814         function hasCovariantVoidArgument(typeArguments, variances) {
50815             for (var i = 0; i < variances.length; i++) {
50816                 if ((variances[i] & 7) === 1 && typeArguments[i].flags & 16384) {
50817                     return true;
50818                 }
50819             }
50820             return false;
50821         }
50822         function isUnconstrainedTypeParameter(type) {
50823             return type.flags & 262144 && !getConstraintOfTypeParameter(type);
50824         }
50825         function isNonDeferredTypeReference(type) {
50826             return !!(ts.getObjectFlags(type) & 4) && !type.node;
50827         }
50828         function isTypeReferenceWithGenericArguments(type) {
50829             return isNonDeferredTypeReference(type) && ts.some(getTypeArguments(type), function (t) { return isUnconstrainedTypeParameter(t) || isTypeReferenceWithGenericArguments(t); });
50830         }
50831         function getTypeReferenceId(type, typeParameters, depth) {
50832             if (depth === void 0) { depth = 0; }
50833             var result = "" + type.target.id;
50834             for (var _i = 0, _a = getTypeArguments(type); _i < _a.length; _i++) {
50835                 var t = _a[_i];
50836                 if (isUnconstrainedTypeParameter(t)) {
50837                     var index = typeParameters.indexOf(t);
50838                     if (index < 0) {
50839                         index = typeParameters.length;
50840                         typeParameters.push(t);
50841                     }
50842                     result += "=" + index;
50843                 }
50844                 else if (depth < 4 && isTypeReferenceWithGenericArguments(t)) {
50845                     result += "<" + getTypeReferenceId(t, typeParameters, depth + 1) + ">";
50846                 }
50847                 else {
50848                     result += "-" + t.id;
50849                 }
50850             }
50851             return result;
50852         }
50853         function getRelationKey(source, target, intersectionState, relation) {
50854             if (relation === identityRelation && source.id > target.id) {
50855                 var temp = source;
50856                 source = target;
50857                 target = temp;
50858             }
50859             var postFix = intersectionState ? ":" + intersectionState : "";
50860             if (isTypeReferenceWithGenericArguments(source) && isTypeReferenceWithGenericArguments(target)) {
50861                 var typeParameters = [];
50862                 return getTypeReferenceId(source, typeParameters) + "," + getTypeReferenceId(target, typeParameters) + postFix;
50863             }
50864             return source.id + "," + target.id + postFix;
50865         }
50866         function forEachProperty(prop, callback) {
50867             if (ts.getCheckFlags(prop) & 6) {
50868                 for (var _i = 0, _a = prop.containingType.types; _i < _a.length; _i++) {
50869                     var t = _a[_i];
50870                     var p = getPropertyOfType(t, prop.escapedName);
50871                     var result = p && forEachProperty(p, callback);
50872                     if (result) {
50873                         return result;
50874                     }
50875                 }
50876                 return undefined;
50877             }
50878             return callback(prop);
50879         }
50880         function getDeclaringClass(prop) {
50881             return prop.parent && prop.parent.flags & 32 ? getDeclaredTypeOfSymbol(getParentOfSymbol(prop)) : undefined;
50882         }
50883         function getTypeOfPropertyInBaseClass(property) {
50884             var classType = getDeclaringClass(property);
50885             var baseClassType = classType && getBaseTypes(classType)[0];
50886             return baseClassType && getTypeOfPropertyOfType(baseClassType, property.escapedName);
50887         }
50888         function isPropertyInClassDerivedFrom(prop, baseClass) {
50889             return forEachProperty(prop, function (sp) {
50890                 var sourceClass = getDeclaringClass(sp);
50891                 return sourceClass ? hasBaseType(sourceClass, baseClass) : false;
50892             });
50893         }
50894         function isValidOverrideOf(sourceProp, targetProp) {
50895             return !forEachProperty(targetProp, function (tp) { return ts.getDeclarationModifierFlagsFromSymbol(tp) & 16 ?
50896                 !isPropertyInClassDerivedFrom(sourceProp, getDeclaringClass(tp)) : false; });
50897         }
50898         function isClassDerivedFromDeclaringClasses(checkClass, prop) {
50899             return forEachProperty(prop, function (p) { return ts.getDeclarationModifierFlagsFromSymbol(p) & 16 ?
50900                 !hasBaseType(checkClass, getDeclaringClass(p)) : false; }) ? undefined : checkClass;
50901         }
50902         function isDeeplyNestedType(type, stack, depth) {
50903             if (depth >= 5) {
50904                 var identity_1 = getRecursionIdentity(type);
50905                 if (identity_1) {
50906                     var count = 0;
50907                     for (var i = 0; i < depth; i++) {
50908                         if (getRecursionIdentity(stack[i]) === identity_1) {
50909                             count++;
50910                             if (count >= 5) {
50911                                 return true;
50912                             }
50913                         }
50914                     }
50915                 }
50916             }
50917             return false;
50918         }
50919         function getRecursionIdentity(type) {
50920             if (type.flags & 524288 && !isObjectOrArrayLiteralType(type)) {
50921                 if (ts.getObjectFlags(type) && 4 && type.node) {
50922                     return type.node;
50923                 }
50924                 if (type.symbol && !(ts.getObjectFlags(type) & 16 && type.symbol.flags & 32)) {
50925                     return type.symbol;
50926                 }
50927                 if (isTupleType(type)) {
50928                     return type.target;
50929                 }
50930             }
50931             if (type.flags & 8388608) {
50932                 do {
50933                     type = type.objectType;
50934                 } while (type.flags & 8388608);
50935                 return type;
50936             }
50937             if (type.flags & 16777216) {
50938                 return type.root;
50939             }
50940             return undefined;
50941         }
50942         function isPropertyIdenticalTo(sourceProp, targetProp) {
50943             return compareProperties(sourceProp, targetProp, compareTypesIdentical) !== 0;
50944         }
50945         function compareProperties(sourceProp, targetProp, compareTypes) {
50946             if (sourceProp === targetProp) {
50947                 return -1;
50948             }
50949             var sourcePropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(sourceProp) & 24;
50950             var targetPropAccessibility = ts.getDeclarationModifierFlagsFromSymbol(targetProp) & 24;
50951             if (sourcePropAccessibility !== targetPropAccessibility) {
50952                 return 0;
50953             }
50954             if (sourcePropAccessibility) {
50955                 if (getTargetSymbol(sourceProp) !== getTargetSymbol(targetProp)) {
50956                     return 0;
50957                 }
50958             }
50959             else {
50960                 if ((sourceProp.flags & 16777216) !== (targetProp.flags & 16777216)) {
50961                     return 0;
50962                 }
50963             }
50964             if (isReadonlySymbol(sourceProp) !== isReadonlySymbol(targetProp)) {
50965                 return 0;
50966             }
50967             return compareTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
50968         }
50969         function isMatchingSignature(source, target, partialMatch) {
50970             var sourceParameterCount = getParameterCount(source);
50971             var targetParameterCount = getParameterCount(target);
50972             var sourceMinArgumentCount = getMinArgumentCount(source);
50973             var targetMinArgumentCount = getMinArgumentCount(target);
50974             var sourceHasRestParameter = hasEffectiveRestParameter(source);
50975             var targetHasRestParameter = hasEffectiveRestParameter(target);
50976             if (sourceParameterCount === targetParameterCount &&
50977                 sourceMinArgumentCount === targetMinArgumentCount &&
50978                 sourceHasRestParameter === targetHasRestParameter) {
50979                 return true;
50980             }
50981             if (partialMatch && sourceMinArgumentCount <= targetMinArgumentCount) {
50982                 return true;
50983             }
50984             return false;
50985         }
50986         function compareSignaturesIdentical(source, target, partialMatch, ignoreThisTypes, ignoreReturnTypes, compareTypes) {
50987             if (source === target) {
50988                 return -1;
50989             }
50990             if (!(isMatchingSignature(source, target, partialMatch))) {
50991                 return 0;
50992             }
50993             if (ts.length(source.typeParameters) !== ts.length(target.typeParameters)) {
50994                 return 0;
50995             }
50996             if (target.typeParameters) {
50997                 var mapper = createTypeMapper(source.typeParameters, target.typeParameters);
50998                 for (var i = 0; i < target.typeParameters.length; i++) {
50999                     var s = source.typeParameters[i];
51000                     var t = target.typeParameters[i];
51001                     if (!(s === t || compareTypes(instantiateType(getConstraintFromTypeParameter(s), mapper) || unknownType, getConstraintFromTypeParameter(t) || unknownType) &&
51002                         compareTypes(instantiateType(getDefaultFromTypeParameter(s), mapper) || unknownType, getDefaultFromTypeParameter(t) || unknownType))) {
51003                         return 0;
51004                     }
51005                 }
51006                 source = instantiateSignature(source, mapper, true);
51007             }
51008             var result = -1;
51009             if (!ignoreThisTypes) {
51010                 var sourceThisType = getThisTypeOfSignature(source);
51011                 if (sourceThisType) {
51012                     var targetThisType = getThisTypeOfSignature(target);
51013                     if (targetThisType) {
51014                         var related = compareTypes(sourceThisType, targetThisType);
51015                         if (!related) {
51016                             return 0;
51017                         }
51018                         result &= related;
51019                     }
51020                 }
51021             }
51022             var targetLen = getParameterCount(target);
51023             for (var i = 0; i < targetLen; i++) {
51024                 var s = getTypeAtPosition(source, i);
51025                 var t = getTypeAtPosition(target, i);
51026                 var related = compareTypes(t, s);
51027                 if (!related) {
51028                     return 0;
51029                 }
51030                 result &= related;
51031             }
51032             if (!ignoreReturnTypes) {
51033                 var sourceTypePredicate = getTypePredicateOfSignature(source);
51034                 var targetTypePredicate = getTypePredicateOfSignature(target);
51035                 result &= sourceTypePredicate || targetTypePredicate ?
51036                     compareTypePredicatesIdentical(sourceTypePredicate, targetTypePredicate, compareTypes) :
51037                     compareTypes(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
51038             }
51039             return result;
51040         }
51041         function compareTypePredicatesIdentical(source, target, compareTypes) {
51042             return !(source && target && typePredicateKindsMatch(source, target)) ? 0 :
51043                 source.type === target.type ? -1 :
51044                     source.type && target.type ? compareTypes(source.type, target.type) :
51045                         0;
51046         }
51047         function literalTypesWithSameBaseType(types) {
51048             var commonBaseType;
51049             for (var _i = 0, types_14 = types; _i < types_14.length; _i++) {
51050                 var t = types_14[_i];
51051                 var baseType = getBaseTypeOfLiteralType(t);
51052                 if (!commonBaseType) {
51053                     commonBaseType = baseType;
51054                 }
51055                 if (baseType === t || baseType !== commonBaseType) {
51056                     return false;
51057                 }
51058             }
51059             return true;
51060         }
51061         function getSupertypeOrUnion(types) {
51062             return literalTypesWithSameBaseType(types) ?
51063                 getUnionType(types) :
51064                 ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; });
51065         }
51066         function getCommonSupertype(types) {
51067             if (!strictNullChecks) {
51068                 return getSupertypeOrUnion(types);
51069             }
51070             var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304); });
51071             return primaryTypes.length ?
51072                 getNullableType(getSupertypeOrUnion(primaryTypes), getFalsyFlagsOfTypes(types) & 98304) :
51073                 getUnionType(types, 2);
51074         }
51075         function getCommonSubtype(types) {
51076             return ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(t, s) ? t : s; });
51077         }
51078         function isArrayType(type) {
51079             return !!(ts.getObjectFlags(type) & 4) && (type.target === globalArrayType || type.target === globalReadonlyArrayType);
51080         }
51081         function isReadonlyArrayType(type) {
51082             return !!(ts.getObjectFlags(type) & 4) && type.target === globalReadonlyArrayType;
51083         }
51084         function isMutableArrayOrTuple(type) {
51085             return isArrayType(type) && !isReadonlyArrayType(type) || isTupleType(type) && !type.target.readonly;
51086         }
51087         function getElementTypeOfArrayType(type) {
51088             return isArrayType(type) ? getTypeArguments(type)[0] : undefined;
51089         }
51090         function isArrayLikeType(type) {
51091             return isArrayType(type) || !(type.flags & 98304) && isTypeAssignableTo(type, anyReadonlyArrayType);
51092         }
51093         function isEmptyArrayLiteralType(type) {
51094             var elementType = isArrayType(type) ? getTypeArguments(type)[0] : undefined;
51095             return elementType === undefinedWideningType || elementType === implicitNeverType;
51096         }
51097         function isTupleLikeType(type) {
51098             return isTupleType(type) || !!getPropertyOfType(type, "0");
51099         }
51100         function isArrayOrTupleLikeType(type) {
51101             return isArrayLikeType(type) || isTupleLikeType(type);
51102         }
51103         function getTupleElementType(type, index) {
51104             var propType = getTypeOfPropertyOfType(type, "" + index);
51105             if (propType) {
51106                 return propType;
51107             }
51108             if (everyType(type, isTupleType)) {
51109                 return mapType(type, function (t) { return getRestTypeOfTupleType(t) || undefinedType; });
51110             }
51111             return undefined;
51112         }
51113         function isNeitherUnitTypeNorNever(type) {
51114             return !(type.flags & (109440 | 131072));
51115         }
51116         function isUnitType(type) {
51117             return !!(type.flags & 109440);
51118         }
51119         function isLiteralType(type) {
51120             return type.flags & 16 ? true :
51121                 type.flags & 1048576 ? type.flags & 1024 ? true : ts.every(type.types, isUnitType) :
51122                     isUnitType(type);
51123         }
51124         function getBaseTypeOfLiteralType(type) {
51125             return type.flags & 1024 ? getBaseTypeOfEnumLiteralType(type) :
51126                 type.flags & 128 ? stringType :
51127                     type.flags & 256 ? numberType :
51128                         type.flags & 2048 ? bigintType :
51129                             type.flags & 512 ? booleanType :
51130                                 type.flags & 1048576 ? mapType(type, getBaseTypeOfLiteralType) :
51131                                     type;
51132         }
51133         function getWidenedLiteralType(type) {
51134             return type.flags & 1024 && isFreshLiteralType(type) ? getBaseTypeOfEnumLiteralType(type) :
51135                 type.flags & 128 && isFreshLiteralType(type) ? stringType :
51136                     type.flags & 256 && isFreshLiteralType(type) ? numberType :
51137                         type.flags & 2048 && isFreshLiteralType(type) ? bigintType :
51138                             type.flags & 512 && isFreshLiteralType(type) ? booleanType :
51139                                 type.flags & 1048576 ? mapType(type, getWidenedLiteralType) :
51140                                     type;
51141         }
51142         function getWidenedUniqueESSymbolType(type) {
51143             return type.flags & 8192 ? esSymbolType :
51144                 type.flags & 1048576 ? mapType(type, getWidenedUniqueESSymbolType) :
51145                     type;
51146         }
51147         function getWidenedLiteralLikeTypeForContextualType(type, contextualType) {
51148             if (!isLiteralOfContextualType(type, contextualType)) {
51149                 type = getWidenedUniqueESSymbolType(getWidenedLiteralType(type));
51150             }
51151             return type;
51152         }
51153         function getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(type, contextualSignatureReturnType, isAsync) {
51154             if (type && isUnitType(type)) {
51155                 var contextualType = !contextualSignatureReturnType ? undefined :
51156                     isAsync ? getPromisedTypeOfPromise(contextualSignatureReturnType) :
51157                         contextualSignatureReturnType;
51158                 type = getWidenedLiteralLikeTypeForContextualType(type, contextualType);
51159             }
51160             return type;
51161         }
51162         function getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(type, contextualSignatureReturnType, kind, isAsyncGenerator) {
51163             if (type && isUnitType(type)) {
51164                 var contextualType = !contextualSignatureReturnType ? undefined :
51165                     getIterationTypeOfGeneratorFunctionReturnType(kind, contextualSignatureReturnType, isAsyncGenerator);
51166                 type = getWidenedLiteralLikeTypeForContextualType(type, contextualType);
51167             }
51168             return type;
51169         }
51170         function isTupleType(type) {
51171             return !!(ts.getObjectFlags(type) & 4 && type.target.objectFlags & 8);
51172         }
51173         function isGenericTupleType(type) {
51174             return isTupleType(type) && !!(type.target.combinedFlags & 8);
51175         }
51176         function isSingleElementGenericTupleType(type) {
51177             return isGenericTupleType(type) && type.target.elementFlags.length === 1;
51178         }
51179         function getRestTypeOfTupleType(type) {
51180             return getElementTypeOfSliceOfTupleType(type, type.target.fixedLength);
51181         }
51182         function getRestArrayTypeOfTupleType(type) {
51183             var restType = getRestTypeOfTupleType(type);
51184             return restType && createArrayType(restType);
51185         }
51186         function getElementTypeOfSliceOfTupleType(type, index, endSkipCount, writing) {
51187             if (endSkipCount === void 0) { endSkipCount = 0; }
51188             if (writing === void 0) { writing = false; }
51189             var length = getTypeReferenceArity(type) - endSkipCount;
51190             if (index < length) {
51191                 var typeArguments = getTypeArguments(type);
51192                 var elementTypes = [];
51193                 for (var i = index; i < length; i++) {
51194                     var t = typeArguments[i];
51195                     elementTypes.push(type.target.elementFlags[i] & 8 ? getIndexedAccessType(t, numberType) : t);
51196                 }
51197                 return writing ? getIntersectionType(elementTypes) : getUnionType(elementTypes);
51198             }
51199             return undefined;
51200         }
51201         function isTupleTypeStructureMatching(t1, t2) {
51202             return getTypeReferenceArity(t1) === getTypeReferenceArity(t2) &&
51203                 ts.every(t1.target.elementFlags, function (f, i) { return (f & 12) === (t2.target.elementFlags[i] & 12); });
51204         }
51205         function isZeroBigInt(_a) {
51206             var value = _a.value;
51207             return value.base10Value === "0";
51208         }
51209         function getFalsyFlagsOfTypes(types) {
51210             var result = 0;
51211             for (var _i = 0, types_15 = types; _i < types_15.length; _i++) {
51212                 var t = types_15[_i];
51213                 result |= getFalsyFlags(t);
51214             }
51215             return result;
51216         }
51217         function getFalsyFlags(type) {
51218             return type.flags & 1048576 ? getFalsyFlagsOfTypes(type.types) :
51219                 type.flags & 128 ? type.value === "" ? 128 : 0 :
51220                     type.flags & 256 ? type.value === 0 ? 256 : 0 :
51221                         type.flags & 2048 ? isZeroBigInt(type) ? 2048 : 0 :
51222                             type.flags & 512 ? (type === falseType || type === regularFalseType) ? 512 : 0 :
51223                                 type.flags & 117724;
51224         }
51225         function removeDefinitelyFalsyTypes(type) {
51226             return getFalsyFlags(type) & 117632 ?
51227                 filterType(type, function (t) { return !(getFalsyFlags(t) & 117632); }) :
51228                 type;
51229         }
51230         function extractDefinitelyFalsyTypes(type) {
51231             return mapType(type, getDefinitelyFalsyPartOfType);
51232         }
51233         function getDefinitelyFalsyPartOfType(type) {
51234             return type.flags & 4 ? emptyStringType :
51235                 type.flags & 8 ? zeroType :
51236                     type.flags & 64 ? zeroBigIntType :
51237                         type === regularFalseType ||
51238                             type === falseType ||
51239                             type.flags & (16384 | 32768 | 65536 | 3) ||
51240                             type.flags & 128 && type.value === "" ||
51241                             type.flags & 256 && type.value === 0 ||
51242                             type.flags & 2048 && isZeroBigInt(type) ? type :
51243                             neverType;
51244         }
51245         function getNullableType(type, flags) {
51246             var missing = (flags & ~type.flags) & (32768 | 65536);
51247             return missing === 0 ? type :
51248                 missing === 32768 ? getUnionType([type, undefinedType]) :
51249                     missing === 65536 ? getUnionType([type, nullType]) :
51250                         getUnionType([type, undefinedType, nullType]);
51251         }
51252         function getOptionalType(type) {
51253             ts.Debug.assert(strictNullChecks);
51254             return type.flags & 32768 ? type : getUnionType([type, undefinedType]);
51255         }
51256         function getGlobalNonNullableTypeInstantiation(type) {
51257             if (!deferredGlobalNonNullableTypeAlias) {
51258                 deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288, undefined) || unknownSymbol;
51259             }
51260             if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) {
51261                 return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]);
51262             }
51263             return getTypeWithFacts(type, 2097152);
51264         }
51265         function getNonNullableType(type) {
51266             return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
51267         }
51268         function addOptionalTypeMarker(type) {
51269             return strictNullChecks ? getUnionType([type, optionalType]) : type;
51270         }
51271         function isNotOptionalTypeMarker(type) {
51272             return type !== optionalType;
51273         }
51274         function removeOptionalTypeMarker(type) {
51275             return strictNullChecks ? filterType(type, isNotOptionalTypeMarker) : type;
51276         }
51277         function propagateOptionalTypeMarker(type, node, wasOptional) {
51278             return wasOptional ? ts.isOutermostOptionalChain(node) ? getOptionalType(type) : addOptionalTypeMarker(type) : type;
51279         }
51280         function getOptionalExpressionType(exprType, expression) {
51281             return ts.isExpressionOfOptionalChainRoot(expression) ? getNonNullableType(exprType) :
51282                 ts.isOptionalChain(expression) ? removeOptionalTypeMarker(exprType) :
51283                     exprType;
51284         }
51285         function isCoercibleUnderDoubleEquals(source, target) {
51286             return ((source.flags & (8 | 4 | 512)) !== 0)
51287                 && ((target.flags & (8 | 4 | 16)) !== 0);
51288         }
51289         function isObjectTypeWithInferableIndex(type) {
51290             return type.flags & 2097152 ? ts.every(type.types, isObjectTypeWithInferableIndex) :
51291                 !!(type.symbol && (type.symbol.flags & (4096 | 2048 | 384 | 512)) !== 0 &&
51292                     !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 2048 && isObjectTypeWithInferableIndex(type.source));
51293         }
51294         function createSymbolWithType(source, type) {
51295             var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8);
51296             symbol.declarations = source.declarations;
51297             symbol.parent = source.parent;
51298             symbol.type = type;
51299             symbol.target = source;
51300             if (source.valueDeclaration) {
51301                 symbol.valueDeclaration = source.valueDeclaration;
51302             }
51303             var nameType = getSymbolLinks(source).nameType;
51304             if (nameType) {
51305                 symbol.nameType = nameType;
51306             }
51307             return symbol;
51308         }
51309         function transformTypeOfMembers(type, f) {
51310             var members = ts.createSymbolTable();
51311             for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) {
51312                 var property = _a[_i];
51313                 var original = getTypeOfSymbol(property);
51314                 var updated = f(original);
51315                 members.set(property.escapedName, updated === original ? property : createSymbolWithType(property, updated));
51316             }
51317             return members;
51318         }
51319         function getRegularTypeOfObjectLiteral(type) {
51320             if (!(isObjectLiteralType(type) && ts.getObjectFlags(type) & 32768)) {
51321                 return type;
51322             }
51323             var regularType = type.regularType;
51324             if (regularType) {
51325                 return regularType;
51326             }
51327             var resolved = type;
51328             var members = transformTypeOfMembers(type, getRegularTypeOfObjectLiteral);
51329             var regularNew = createAnonymousType(resolved.symbol, members, resolved.callSignatures, resolved.constructSignatures, resolved.stringIndexInfo, resolved.numberIndexInfo);
51330             regularNew.flags = resolved.flags;
51331             regularNew.objectFlags |= resolved.objectFlags & ~32768;
51332             type.regularType = regularNew;
51333             return regularNew;
51334         }
51335         function createWideningContext(parent, propertyName, siblings) {
51336             return { parent: parent, propertyName: propertyName, siblings: siblings, resolvedProperties: undefined };
51337         }
51338         function getSiblingsOfContext(context) {
51339             if (!context.siblings) {
51340                 var siblings_1 = [];
51341                 for (var _i = 0, _a = getSiblingsOfContext(context.parent); _i < _a.length; _i++) {
51342                     var type = _a[_i];
51343                     if (isObjectLiteralType(type)) {
51344                         var prop = getPropertyOfObjectType(type, context.propertyName);
51345                         if (prop) {
51346                             forEachType(getTypeOfSymbol(prop), function (t) {
51347                                 siblings_1.push(t);
51348                             });
51349                         }
51350                     }
51351                 }
51352                 context.siblings = siblings_1;
51353             }
51354             return context.siblings;
51355         }
51356         function getPropertiesOfContext(context) {
51357             if (!context.resolvedProperties) {
51358                 var names = new ts.Map();
51359                 for (var _i = 0, _a = getSiblingsOfContext(context); _i < _a.length; _i++) {
51360                     var t = _a[_i];
51361                     if (isObjectLiteralType(t) && !(ts.getObjectFlags(t) & 1024)) {
51362                         for (var _b = 0, _c = getPropertiesOfType(t); _b < _c.length; _b++) {
51363                             var prop = _c[_b];
51364                             names.set(prop.escapedName, prop);
51365                         }
51366                     }
51367                 }
51368                 context.resolvedProperties = ts.arrayFrom(names.values());
51369             }
51370             return context.resolvedProperties;
51371         }
51372         function getWidenedProperty(prop, context) {
51373             if (!(prop.flags & 4)) {
51374                 return prop;
51375             }
51376             var original = getTypeOfSymbol(prop);
51377             var propContext = context && createWideningContext(context, prop.escapedName, undefined);
51378             var widened = getWidenedTypeWithContext(original, propContext);
51379             return widened === original ? prop : createSymbolWithType(prop, widened);
51380         }
51381         function getUndefinedProperty(prop) {
51382             var cached = undefinedProperties.get(prop.escapedName);
51383             if (cached) {
51384                 return cached;
51385             }
51386             var result = createSymbolWithType(prop, undefinedType);
51387             result.flags |= 16777216;
51388             undefinedProperties.set(prop.escapedName, result);
51389             return result;
51390         }
51391         function getWidenedTypeOfObjectLiteral(type, context) {
51392             var members = ts.createSymbolTable();
51393             for (var _i = 0, _a = getPropertiesOfObjectType(type); _i < _a.length; _i++) {
51394                 var prop = _a[_i];
51395                 members.set(prop.escapedName, getWidenedProperty(prop, context));
51396             }
51397             if (context) {
51398                 for (var _b = 0, _c = getPropertiesOfContext(context); _b < _c.length; _b++) {
51399                     var prop = _c[_b];
51400                     if (!members.has(prop.escapedName)) {
51401                         members.set(prop.escapedName, getUndefinedProperty(prop));
51402                     }
51403                 }
51404             }
51405             var stringIndexInfo = getIndexInfoOfType(type, 0);
51406             var numberIndexInfo = getIndexInfoOfType(type, 1);
51407             var result = createAnonymousType(type.symbol, members, ts.emptyArray, ts.emptyArray, stringIndexInfo && createIndexInfo(getWidenedType(stringIndexInfo.type), stringIndexInfo.isReadonly), numberIndexInfo && createIndexInfo(getWidenedType(numberIndexInfo.type), numberIndexInfo.isReadonly));
51408             result.objectFlags |= (ts.getObjectFlags(type) & (16384 | 2097152));
51409             return result;
51410         }
51411         function getWidenedType(type) {
51412             return getWidenedTypeWithContext(type, undefined);
51413         }
51414         function getWidenedTypeWithContext(type, context) {
51415             if (ts.getObjectFlags(type) & 1572864) {
51416                 if (context === undefined && type.widened) {
51417                     return type.widened;
51418                 }
51419                 var result = void 0;
51420                 if (type.flags & (1 | 98304)) {
51421                     result = anyType;
51422                 }
51423                 else if (isObjectLiteralType(type)) {
51424                     result = getWidenedTypeOfObjectLiteral(type, context);
51425                 }
51426                 else if (type.flags & 1048576) {
51427                     var unionContext_1 = context || createWideningContext(undefined, undefined, type.types);
51428                     var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 ? t : getWidenedTypeWithContext(t, unionContext_1); });
51429                     result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 : 1);
51430                 }
51431                 else if (type.flags & 2097152) {
51432                     result = getIntersectionType(ts.sameMap(type.types, getWidenedType));
51433                 }
51434                 else if (isArrayType(type) || isTupleType(type)) {
51435                     result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType));
51436                 }
51437                 if (result && context === undefined) {
51438                     type.widened = result;
51439                 }
51440                 return result || type;
51441             }
51442             return type;
51443         }
51444         function reportWideningErrorsInType(type) {
51445             var errorReported = false;
51446             if (ts.getObjectFlags(type) & 524288) {
51447                 if (type.flags & 1048576) {
51448                     if (ts.some(type.types, isEmptyObjectType)) {
51449                         errorReported = true;
51450                     }
51451                     else {
51452                         for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
51453                             var t = _a[_i];
51454                             if (reportWideningErrorsInType(t)) {
51455                                 errorReported = true;
51456                             }
51457                         }
51458                     }
51459                 }
51460                 if (isArrayType(type) || isTupleType(type)) {
51461                     for (var _b = 0, _c = getTypeArguments(type); _b < _c.length; _b++) {
51462                         var t = _c[_b];
51463                         if (reportWideningErrorsInType(t)) {
51464                             errorReported = true;
51465                         }
51466                     }
51467                 }
51468                 if (isObjectLiteralType(type)) {
51469                     for (var _d = 0, _e = getPropertiesOfObjectType(type); _d < _e.length; _d++) {
51470                         var p = _e[_d];
51471                         var t = getTypeOfSymbol(p);
51472                         if (ts.getObjectFlags(t) & 524288) {
51473                             if (!reportWideningErrorsInType(t)) {
51474                                 error(p.valueDeclaration, ts.Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, symbolToString(p), typeToString(getWidenedType(t)));
51475                             }
51476                             errorReported = true;
51477                         }
51478                     }
51479                 }
51480             }
51481             return errorReported;
51482         }
51483         function reportImplicitAny(declaration, type, wideningKind) {
51484             var typeAsString = typeToString(getWidenedType(type));
51485             if (ts.isInJSFile(declaration) && !ts.isCheckJsEnabledForFile(ts.getSourceFileOfNode(declaration), compilerOptions)) {
51486                 return;
51487             }
51488             var diagnostic;
51489             switch (declaration.kind) {
51490                 case 216:
51491                 case 163:
51492                 case 162:
51493                     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;
51494                     break;
51495                 case 160:
51496                     var param = declaration;
51497                     if (ts.isIdentifier(param.name) &&
51498                         (ts.isCallSignatureDeclaration(param.parent) || ts.isMethodSignature(param.parent) || ts.isFunctionTypeNode(param.parent)) &&
51499                         param.parent.parameters.indexOf(param) > -1 &&
51500                         (resolveName(param, param.name.escapedText, 788968, undefined, param.name.escapedText, true) ||
51501                             param.name.originalKeywordKind && ts.isTypeNodeKind(param.name.originalKeywordKind))) {
51502                         var newName = "arg" + param.parent.parameters.indexOf(param);
51503                         errorOrSuggestion(noImplicitAny, declaration, ts.Diagnostics.Parameter_has_a_name_but_no_type_Did_you_mean_0_Colon_1, newName, ts.declarationNameToString(param.name));
51504                         return;
51505                     }
51506                     diagnostic = declaration.dotDotDotToken ?
51507                         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 :
51508                         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;
51509                     break;
51510                 case 198:
51511                     diagnostic = ts.Diagnostics.Binding_element_0_implicitly_has_an_1_type;
51512                     if (!noImplicitAny) {
51513                         return;
51514                     }
51515                     break;
51516                 case 308:
51517                     error(declaration, ts.Diagnostics.Function_type_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString);
51518                     return;
51519                 case 251:
51520                 case 165:
51521                 case 164:
51522                 case 167:
51523                 case 168:
51524                 case 208:
51525                 case 209:
51526                     if (noImplicitAny && !declaration.name) {
51527                         if (wideningKind === 3) {
51528                             error(declaration, ts.Diagnostics.Generator_implicitly_has_yield_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type_annotation, typeAsString);
51529                         }
51530                         else {
51531                             error(declaration, ts.Diagnostics.Function_expression_which_lacks_return_type_annotation_implicitly_has_an_0_return_type, typeAsString);
51532                         }
51533                         return;
51534                     }
51535                     diagnostic = !noImplicitAny ? ts.Diagnostics._0_implicitly_has_an_1_return_type_but_a_better_type_may_be_inferred_from_usage :
51536                         wideningKind === 3 ? ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_yield_type :
51537                             ts.Diagnostics._0_which_lacks_return_type_annotation_implicitly_has_an_1_return_type;
51538                     break;
51539                 case 190:
51540                     if (noImplicitAny) {
51541                         error(declaration, ts.Diagnostics.Mapped_object_type_implicitly_has_an_any_template_type);
51542                     }
51543                     return;
51544                 default:
51545                     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;
51546             }
51547             errorOrSuggestion(noImplicitAny, declaration, diagnostic, ts.declarationNameToString(ts.getNameOfDeclaration(declaration)), typeAsString);
51548         }
51549         function reportErrorsFromWidening(declaration, type, wideningKind) {
51550             if (produceDiagnostics && noImplicitAny && ts.getObjectFlags(type) & 524288 && (!wideningKind || !getContextualSignatureForFunctionLikeDeclaration(declaration))) {
51551                 if (!reportWideningErrorsInType(type)) {
51552                     reportImplicitAny(declaration, type, wideningKind);
51553                 }
51554             }
51555         }
51556         function applyToParameterTypes(source, target, callback) {
51557             var sourceCount = getParameterCount(source);
51558             var targetCount = getParameterCount(target);
51559             var sourceRestType = getEffectiveRestType(source);
51560             var targetRestType = getEffectiveRestType(target);
51561             var targetNonRestCount = targetRestType ? targetCount - 1 : targetCount;
51562             var paramCount = sourceRestType ? targetNonRestCount : Math.min(sourceCount, targetNonRestCount);
51563             var sourceThisType = getThisTypeOfSignature(source);
51564             if (sourceThisType) {
51565                 var targetThisType = getThisTypeOfSignature(target);
51566                 if (targetThisType) {
51567                     callback(sourceThisType, targetThisType);
51568                 }
51569             }
51570             for (var i = 0; i < paramCount; i++) {
51571                 callback(getTypeAtPosition(source, i), getTypeAtPosition(target, i));
51572             }
51573             if (targetRestType) {
51574                 callback(getRestTypeAtPosition(source, paramCount), targetRestType);
51575             }
51576         }
51577         function applyToReturnTypes(source, target, callback) {
51578             var sourceTypePredicate = getTypePredicateOfSignature(source);
51579             var targetTypePredicate = getTypePredicateOfSignature(target);
51580             if (sourceTypePredicate && targetTypePredicate && typePredicateKindsMatch(sourceTypePredicate, targetTypePredicate) && sourceTypePredicate.type && targetTypePredicate.type) {
51581                 callback(sourceTypePredicate.type, targetTypePredicate.type);
51582             }
51583             else {
51584                 callback(getReturnTypeOfSignature(source), getReturnTypeOfSignature(target));
51585             }
51586         }
51587         function createInferenceContext(typeParameters, signature, flags, compareTypes) {
51588             return createInferenceContextWorker(typeParameters.map(createInferenceInfo), signature, flags, compareTypes || compareTypesAssignable);
51589         }
51590         function cloneInferenceContext(context, extraFlags) {
51591             if (extraFlags === void 0) { extraFlags = 0; }
51592             return context && createInferenceContextWorker(ts.map(context.inferences, cloneInferenceInfo), context.signature, context.flags | extraFlags, context.compareTypes);
51593         }
51594         function createInferenceContextWorker(inferences, signature, flags, compareTypes) {
51595             var context = {
51596                 inferences: inferences,
51597                 signature: signature,
51598                 flags: flags,
51599                 compareTypes: compareTypes,
51600                 mapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, true); }),
51601                 nonFixingMapper: makeFunctionTypeMapper(function (t) { return mapToInferredType(context, t, false); }),
51602             };
51603             return context;
51604         }
51605         function mapToInferredType(context, t, fix) {
51606             var inferences = context.inferences;
51607             for (var i = 0; i < inferences.length; i++) {
51608                 var inference = inferences[i];
51609                 if (t === inference.typeParameter) {
51610                     if (fix && !inference.isFixed) {
51611                         clearCachedInferences(inferences);
51612                         inference.isFixed = true;
51613                     }
51614                     return getInferredType(context, i);
51615                 }
51616             }
51617             return t;
51618         }
51619         function clearCachedInferences(inferences) {
51620             for (var _i = 0, inferences_1 = inferences; _i < inferences_1.length; _i++) {
51621                 var inference = inferences_1[_i];
51622                 if (!inference.isFixed) {
51623                     inference.inferredType = undefined;
51624                 }
51625             }
51626         }
51627         function createInferenceInfo(typeParameter) {
51628             return {
51629                 typeParameter: typeParameter,
51630                 candidates: undefined,
51631                 contraCandidates: undefined,
51632                 inferredType: undefined,
51633                 priority: undefined,
51634                 topLevel: true,
51635                 isFixed: false,
51636                 impliedArity: undefined
51637             };
51638         }
51639         function cloneInferenceInfo(inference) {
51640             return {
51641                 typeParameter: inference.typeParameter,
51642                 candidates: inference.candidates && inference.candidates.slice(),
51643                 contraCandidates: inference.contraCandidates && inference.contraCandidates.slice(),
51644                 inferredType: inference.inferredType,
51645                 priority: inference.priority,
51646                 topLevel: inference.topLevel,
51647                 isFixed: inference.isFixed,
51648                 impliedArity: inference.impliedArity
51649             };
51650         }
51651         function cloneInferredPartOfContext(context) {
51652             var inferences = ts.filter(context.inferences, hasInferenceCandidates);
51653             return inferences.length ?
51654                 createInferenceContextWorker(ts.map(inferences, cloneInferenceInfo), context.signature, context.flags, context.compareTypes) :
51655                 undefined;
51656         }
51657         function getMapperFromContext(context) {
51658             return context && context.mapper;
51659         }
51660         function couldContainTypeVariables(type) {
51661             var objectFlags = ts.getObjectFlags(type);
51662             if (objectFlags & 67108864) {
51663                 return !!(objectFlags & 134217728);
51664             }
51665             var result = !!(type.flags & 465829888 ||
51666                 type.flags & 524288 && !isNonGenericTopLevelType(type) && (objectFlags & 4 && (type.node || ts.forEach(getTypeArguments(type), couldContainTypeVariables)) ||
51667                     objectFlags & 16 && type.symbol && type.symbol.flags & (16 | 8192 | 32 | 2048 | 4096) && type.symbol.declarations ||
51668                     objectFlags & (32 | 131072)) ||
51669                 type.flags & 3145728 && !(type.flags & 1024) && !isNonGenericTopLevelType(type) && ts.some(type.types, couldContainTypeVariables));
51670             if (type.flags & 3899393) {
51671                 type.objectFlags |= 67108864 | (result ? 134217728 : 0);
51672             }
51673             return result;
51674         }
51675         function isNonGenericTopLevelType(type) {
51676             if (type.aliasSymbol && !type.aliasTypeArguments) {
51677                 var declaration = ts.getDeclarationOfKind(type.aliasSymbol, 254);
51678                 return !!(declaration && ts.findAncestor(declaration.parent, function (n) { return n.kind === 297 ? true : n.kind === 256 ? false : "quit"; }));
51679             }
51680             return false;
51681         }
51682         function isTypeParameterAtTopLevel(type, typeParameter) {
51683             return !!(type === typeParameter ||
51684                 type.flags & 3145728 && ts.some(type.types, function (t) { return isTypeParameterAtTopLevel(t, typeParameter); }) ||
51685                 type.flags & 16777216 && (getTrueTypeFromConditionalType(type) === typeParameter || getFalseTypeFromConditionalType(type) === typeParameter));
51686         }
51687         function createEmptyObjectTypeFromStringLiteral(type) {
51688             var members = ts.createSymbolTable();
51689             forEachType(type, function (t) {
51690                 if (!(t.flags & 128)) {
51691                     return;
51692                 }
51693                 var name = ts.escapeLeadingUnderscores(t.value);
51694                 var literalProp = createSymbol(4, name);
51695                 literalProp.type = anyType;
51696                 if (t.symbol) {
51697                     literalProp.declarations = t.symbol.declarations;
51698                     literalProp.valueDeclaration = t.symbol.valueDeclaration;
51699                 }
51700                 members.set(name, literalProp);
51701             });
51702             var indexInfo = type.flags & 4 ? createIndexInfo(emptyObjectType, false) : undefined;
51703             return createAnonymousType(undefined, members, ts.emptyArray, ts.emptyArray, indexInfo, undefined);
51704         }
51705         function inferTypeForHomomorphicMappedType(source, target, constraint) {
51706             if (inInferTypeForHomomorphicMappedType) {
51707                 return undefined;
51708             }
51709             var key = source.id + "," + target.id + "," + constraint.id;
51710             if (reverseMappedCache.has(key)) {
51711                 return reverseMappedCache.get(key);
51712             }
51713             inInferTypeForHomomorphicMappedType = true;
51714             var type = createReverseMappedType(source, target, constraint);
51715             inInferTypeForHomomorphicMappedType = false;
51716             reverseMappedCache.set(key, type);
51717             return type;
51718         }
51719         function isPartiallyInferableType(type) {
51720             return !(ts.getObjectFlags(type) & 2097152) ||
51721                 isObjectLiteralType(type) && ts.some(getPropertiesOfType(type), function (prop) { return isPartiallyInferableType(getTypeOfSymbol(prop)); }) ||
51722                 isTupleType(type) && ts.some(getTypeArguments(type), isPartiallyInferableType);
51723         }
51724         function createReverseMappedType(source, target, constraint) {
51725             if (!(getIndexInfoOfType(source, 0) || getPropertiesOfType(source).length !== 0 && isPartiallyInferableType(source))) {
51726                 return undefined;
51727             }
51728             if (isArrayType(source)) {
51729                 return createArrayType(inferReverseMappedType(getTypeArguments(source)[0], target, constraint), isReadonlyArrayType(source));
51730             }
51731             if (isTupleType(source)) {
51732                 var elementTypes = ts.map(getTypeArguments(source), function (t) { return inferReverseMappedType(t, target, constraint); });
51733                 var elementFlags = getMappedTypeModifiers(target) & 4 ?
51734                     ts.sameMap(source.target.elementFlags, function (f) { return f & 2 ? 1 : f; }) :
51735                     source.target.elementFlags;
51736                 return createTupleType(elementTypes, elementFlags, source.target.readonly, source.target.labeledElementDeclarations);
51737             }
51738             var reversed = createObjectType(2048 | 16, undefined);
51739             reversed.source = source;
51740             reversed.mappedType = target;
51741             reversed.constraintType = constraint;
51742             return reversed;
51743         }
51744         function getTypeOfReverseMappedSymbol(symbol) {
51745             return inferReverseMappedType(symbol.propertyType, symbol.mappedType, symbol.constraintType);
51746         }
51747         function inferReverseMappedType(sourceType, target, constraint) {
51748             var typeParameter = getIndexedAccessType(constraint.type, getTypeParameterFromMappedType(target));
51749             var templateType = getTemplateTypeFromMappedType(target);
51750             var inference = createInferenceInfo(typeParameter);
51751             inferTypes([inference], sourceType, templateType);
51752             return getTypeFromInference(inference) || unknownType;
51753         }
51754         function getUnmatchedProperties(source, target, requireOptionalProperties, matchDiscriminantProperties) {
51755             var properties, _i, properties_2, targetProp, sourceProp, targetType, sourceType;
51756             return __generator(this, function (_a) {
51757                 switch (_a.label) {
51758                     case 0:
51759                         properties = getPropertiesOfType(target);
51760                         _i = 0, properties_2 = properties;
51761                         _a.label = 1;
51762                     case 1:
51763                         if (!(_i < properties_2.length)) return [3, 6];
51764                         targetProp = properties_2[_i];
51765                         if (isStaticPrivateIdentifierProperty(targetProp)) {
51766                             return [3, 5];
51767                         }
51768                         if (!(requireOptionalProperties || !(targetProp.flags & 16777216 || ts.getCheckFlags(targetProp) & 48))) return [3, 5];
51769                         sourceProp = getPropertyOfType(source, targetProp.escapedName);
51770                         if (!!sourceProp) return [3, 3];
51771                         return [4, targetProp];
51772                     case 2:
51773                         _a.sent();
51774                         return [3, 5];
51775                     case 3:
51776                         if (!matchDiscriminantProperties) return [3, 5];
51777                         targetType = getTypeOfSymbol(targetProp);
51778                         if (!(targetType.flags & 109440)) return [3, 5];
51779                         sourceType = getTypeOfSymbol(sourceProp);
51780                         if (!!(sourceType.flags & 1 || getRegularTypeOfLiteralType(sourceType) === getRegularTypeOfLiteralType(targetType))) return [3, 5];
51781                         return [4, targetProp];
51782                     case 4:
51783                         _a.sent();
51784                         _a.label = 5;
51785                     case 5:
51786                         _i++;
51787                         return [3, 1];
51788                     case 6: return [2];
51789                 }
51790             });
51791         }
51792         function getUnmatchedProperty(source, target, requireOptionalProperties, matchDiscriminantProperties) {
51793             var result = getUnmatchedProperties(source, target, requireOptionalProperties, matchDiscriminantProperties).next();
51794             if (!result.done)
51795                 return result.value;
51796         }
51797         function tupleTypesDefinitelyUnrelated(source, target) {
51798             return !(target.target.combinedFlags & 8) && target.target.minLength > source.target.minLength ||
51799                 !target.target.hasRestElement && (source.target.hasRestElement || target.target.fixedLength < source.target.fixedLength);
51800         }
51801         function typesDefinitelyUnrelated(source, target) {
51802             return isTupleType(source) && isTupleType(target) ? tupleTypesDefinitelyUnrelated(source, target) :
51803                 !!getUnmatchedProperty(source, target, false, true) &&
51804                     !!getUnmatchedProperty(target, source, false, false);
51805         }
51806         function getTypeFromInference(inference) {
51807             return inference.candidates ? getUnionType(inference.candidates, 2) :
51808                 inference.contraCandidates ? getIntersectionType(inference.contraCandidates) :
51809                     undefined;
51810         }
51811         function hasSkipDirectInferenceFlag(node) {
51812             return !!getNodeLinks(node).skipDirectInference;
51813         }
51814         function isFromInferenceBlockedSource(type) {
51815             return !!(type.symbol && ts.some(type.symbol.declarations, hasSkipDirectInferenceFlag));
51816         }
51817         function isValidBigIntString(s) {
51818             var scanner = ts.createScanner(99, false);
51819             var success = true;
51820             scanner.setOnError(function () { return success = false; });
51821             scanner.setText(s + "n");
51822             var result = scanner.scan();
51823             if (result === 40) {
51824                 result = scanner.scan();
51825             }
51826             var flags = scanner.getTokenFlags();
51827             return success && result === 9 && scanner.getTextPos() === (s.length + 1) && !(flags & 512);
51828         }
51829         function isStringLiteralTypeValueParsableAsType(s, target) {
51830             if (target.flags & 1048576) {
51831                 return !!forEachType(target, function (t) { return isStringLiteralTypeValueParsableAsType(s, t); });
51832             }
51833             switch (target) {
51834                 case stringType: return true;
51835                 case numberType: return s.value !== "" && isFinite(+(s.value));
51836                 case bigintType: return s.value !== "" && isValidBigIntString(s.value);
51837                 case trueType: return s.value === "true";
51838                 case falseType: return s.value === "false";
51839                 case undefinedType: return s.value === "undefined";
51840                 case nullType: return s.value === "null";
51841                 default: return !!(target.flags & 1);
51842             }
51843         }
51844         function inferLiteralsFromTemplateLiteralType(source, target) {
51845             var value = source.value;
51846             var texts = target.texts;
51847             var lastIndex = texts.length - 1;
51848             var startText = texts[0];
51849             var endText = texts[lastIndex];
51850             if (!(value.startsWith(startText) && value.slice(startText.length).endsWith(endText)))
51851                 return undefined;
51852             var matches = [];
51853             var str = value.slice(startText.length, value.length - endText.length);
51854             var pos = 0;
51855             for (var i = 1; i < lastIndex; i++) {
51856                 var delim = texts[i];
51857                 var delimPos = delim.length > 0 ? str.indexOf(delim, pos) : pos < str.length ? pos + 1 : -1;
51858                 if (delimPos < 0)
51859                     return undefined;
51860                 matches.push(getLiteralType(str.slice(pos, delimPos)));
51861                 pos = delimPos + delim.length;
51862             }
51863             matches.push(getLiteralType(str.slice(pos)));
51864             return matches;
51865         }
51866         function inferTypes(inferences, originalSource, originalTarget, priority, contravariant) {
51867             if (priority === void 0) { priority = 0; }
51868             if (contravariant === void 0) { contravariant = false; }
51869             var bivariant = false;
51870             var propagationType;
51871             var inferencePriority = 1024;
51872             var allowComplexConstraintInference = true;
51873             var visited;
51874             var sourceStack;
51875             var targetStack;
51876             var expandingFlags = 0;
51877             inferFromTypes(originalSource, originalTarget);
51878             function inferFromTypes(source, target) {
51879                 if (!couldContainTypeVariables(target)) {
51880                     return;
51881                 }
51882                 if (source === wildcardType) {
51883                     var savePropagationType = propagationType;
51884                     propagationType = source;
51885                     inferFromTypes(target, target);
51886                     propagationType = savePropagationType;
51887                     return;
51888                 }
51889                 if (source.aliasSymbol && source.aliasTypeArguments && source.aliasSymbol === target.aliasSymbol) {
51890                     inferFromTypeArguments(source.aliasTypeArguments, target.aliasTypeArguments, getAliasVariances(source.aliasSymbol));
51891                     return;
51892                 }
51893                 if (source === target && source.flags & 3145728) {
51894                     for (var _i = 0, _a = source.types; _i < _a.length; _i++) {
51895                         var t = _a[_i];
51896                         inferFromTypes(t, t);
51897                     }
51898                     return;
51899                 }
51900                 if (target.flags & 1048576) {
51901                     var _b = inferFromMatchingTypes(source.flags & 1048576 ? source.types : [source], target.types, isTypeOrBaseIdenticalTo), tempSources = _b[0], tempTargets = _b[1];
51902                     var _c = inferFromMatchingTypes(tempSources, tempTargets, isTypeCloselyMatchedBy), sources = _c[0], targets = _c[1];
51903                     if (targets.length === 0) {
51904                         return;
51905                     }
51906                     target = getUnionType(targets);
51907                     if (sources.length === 0) {
51908                         inferWithPriority(source, target, 1);
51909                         return;
51910                     }
51911                     source = getUnionType(sources);
51912                 }
51913                 else if (target.flags & 2097152 && ts.some(target.types, function (t) { return !!getInferenceInfoForType(t) || (isGenericMappedType(t) && !!getInferenceInfoForType(getHomomorphicTypeVariable(t) || neverType)); })) {
51914                     if (!(source.flags & 1048576)) {
51915                         var _d = inferFromMatchingTypes(source.flags & 2097152 ? source.types : [source], target.types, isTypeIdenticalTo), sources = _d[0], targets = _d[1];
51916                         if (sources.length === 0 || targets.length === 0) {
51917                             return;
51918                         }
51919                         source = getIntersectionType(sources);
51920                         target = getIntersectionType(targets);
51921                     }
51922                 }
51923                 else if (target.flags & (8388608 | 33554432)) {
51924                     target = getActualTypeVariable(target);
51925                 }
51926                 if (target.flags & 8650752) {
51927                     if (ts.getObjectFlags(source) & 2097152 || source === nonInferrableAnyType || source === silentNeverType ||
51928                         (priority & 64 && (source === autoType || source === autoArrayType)) || isFromInferenceBlockedSource(source)) {
51929                         return;
51930                     }
51931                     var inference = getInferenceInfoForType(target);
51932                     if (inference) {
51933                         if (!inference.isFixed) {
51934                             if (inference.priority === undefined || priority < inference.priority) {
51935                                 inference.candidates = undefined;
51936                                 inference.contraCandidates = undefined;
51937                                 inference.topLevel = true;
51938                                 inference.priority = priority;
51939                             }
51940                             if (priority === inference.priority) {
51941                                 var candidate = propagationType || source;
51942                                 if (contravariant && !bivariant) {
51943                                     if (!ts.contains(inference.contraCandidates, candidate)) {
51944                                         inference.contraCandidates = ts.append(inference.contraCandidates, candidate);
51945                                         clearCachedInferences(inferences);
51946                                     }
51947                                 }
51948                                 else if (!ts.contains(inference.candidates, candidate)) {
51949                                     inference.candidates = ts.append(inference.candidates, candidate);
51950                                     clearCachedInferences(inferences);
51951                                 }
51952                             }
51953                             if (!(priority & 64) && target.flags & 262144 && inference.topLevel && !isTypeParameterAtTopLevel(originalTarget, target)) {
51954                                 inference.topLevel = false;
51955                                 clearCachedInferences(inferences);
51956                             }
51957                         }
51958                         inferencePriority = Math.min(inferencePriority, priority);
51959                         return;
51960                     }
51961                     else {
51962                         var simplified = getSimplifiedType(target, false);
51963                         if (simplified !== target) {
51964                             invokeOnce(source, simplified, inferFromTypes);
51965                         }
51966                         else if (target.flags & 8388608) {
51967                             var indexType = getSimplifiedType(target.indexType, false);
51968                             if (indexType.flags & 465829888) {
51969                                 var simplified_1 = distributeIndexOverObjectType(getSimplifiedType(target.objectType, false), indexType, false);
51970                                 if (simplified_1 && simplified_1 !== target) {
51971                                     invokeOnce(source, simplified_1, inferFromTypes);
51972                                 }
51973                             }
51974                         }
51975                     }
51976                 }
51977                 if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && (source.target === target.target || isArrayType(source) && isArrayType(target)) &&
51978                     !(source.node && target.node)) {
51979                     inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
51980                 }
51981                 else if (source.flags & 4194304 && target.flags & 4194304) {
51982                     contravariant = !contravariant;
51983                     inferFromTypes(source.type, target.type);
51984                     contravariant = !contravariant;
51985                 }
51986                 else if ((isLiteralType(source) || source.flags & 4) && target.flags & 4194304) {
51987                     var empty = createEmptyObjectTypeFromStringLiteral(source);
51988                     contravariant = !contravariant;
51989                     inferWithPriority(empty, target.type, 128);
51990                     contravariant = !contravariant;
51991                 }
51992                 else if (source.flags & 8388608 && target.flags & 8388608) {
51993                     inferFromTypes(source.objectType, target.objectType);
51994                     inferFromTypes(source.indexType, target.indexType);
51995                 }
51996                 else if (source.flags & 268435456 && target.flags & 268435456) {
51997                     if (source.symbol === target.symbol) {
51998                         inferFromTypes(source.type, target.type);
51999                     }
52000                 }
52001                 else if (target.flags & 16777216) {
52002                     invokeOnce(source, target, inferToConditionalType);
52003                 }
52004                 else if (target.flags & 3145728) {
52005                     inferToMultipleTypes(source, target.types, target.flags);
52006                 }
52007                 else if (source.flags & 1048576) {
52008                     var sourceTypes = source.types;
52009                     for (var _e = 0, sourceTypes_2 = sourceTypes; _e < sourceTypes_2.length; _e++) {
52010                         var sourceType = sourceTypes_2[_e];
52011                         inferFromTypes(sourceType, target);
52012                     }
52013                 }
52014                 else if (target.flags & 134217728) {
52015                     inferToTemplateLiteralType(source, target);
52016                 }
52017                 else {
52018                     source = getReducedType(source);
52019                     if (!(priority & 256 && source.flags & (2097152 | 465829888))) {
52020                         var apparentSource = getApparentType(source);
52021                         if (apparentSource !== source && allowComplexConstraintInference && !(apparentSource.flags & (524288 | 2097152))) {
52022                             allowComplexConstraintInference = false;
52023                             return inferFromTypes(apparentSource, target);
52024                         }
52025                         source = apparentSource;
52026                     }
52027                     if (source.flags & (524288 | 2097152)) {
52028                         invokeOnce(source, target, inferFromObjectTypes);
52029                     }
52030                 }
52031             }
52032             function inferWithPriority(source, target, newPriority) {
52033                 var savePriority = priority;
52034                 priority |= newPriority;
52035                 inferFromTypes(source, target);
52036                 priority = savePriority;
52037             }
52038             function invokeOnce(source, target, action) {
52039                 var key = source.id + "," + target.id;
52040                 var status = visited && visited.get(key);
52041                 if (status !== undefined) {
52042                     inferencePriority = Math.min(inferencePriority, status);
52043                     return;
52044                 }
52045                 (visited || (visited = new ts.Map())).set(key, -1);
52046                 var saveInferencePriority = inferencePriority;
52047                 inferencePriority = 1024;
52048                 var saveExpandingFlags = expandingFlags;
52049                 var sourceIdentity = getRecursionIdentity(source) || source;
52050                 var targetIdentity = getRecursionIdentity(target) || target;
52051                 if (sourceIdentity && ts.contains(sourceStack, sourceIdentity))
52052                     expandingFlags |= 1;
52053                 if (targetIdentity && ts.contains(targetStack, targetIdentity))
52054                     expandingFlags |= 2;
52055                 if (expandingFlags !== 3) {
52056                     if (sourceIdentity)
52057                         (sourceStack || (sourceStack = [])).push(sourceIdentity);
52058                     if (targetIdentity)
52059                         (targetStack || (targetStack = [])).push(targetIdentity);
52060                     action(source, target);
52061                     if (targetIdentity)
52062                         targetStack.pop();
52063                     if (sourceIdentity)
52064                         sourceStack.pop();
52065                 }
52066                 else {
52067                     inferencePriority = -1;
52068                 }
52069                 expandingFlags = saveExpandingFlags;
52070                 visited.set(key, inferencePriority);
52071                 inferencePriority = Math.min(inferencePriority, saveInferencePriority);
52072             }
52073             function inferFromMatchingTypes(sources, targets, matches) {
52074                 var matchedSources;
52075                 var matchedTargets;
52076                 for (var _i = 0, targets_1 = targets; _i < targets_1.length; _i++) {
52077                     var t = targets_1[_i];
52078                     for (var _a = 0, sources_1 = sources; _a < sources_1.length; _a++) {
52079                         var s = sources_1[_a];
52080                         if (matches(s, t)) {
52081                             inferFromTypes(s, t);
52082                             matchedSources = ts.appendIfUnique(matchedSources, s);
52083                             matchedTargets = ts.appendIfUnique(matchedTargets, t);
52084                         }
52085                     }
52086                 }
52087                 return [
52088                     matchedSources ? ts.filter(sources, function (t) { return !ts.contains(matchedSources, t); }) : sources,
52089                     matchedTargets ? ts.filter(targets, function (t) { return !ts.contains(matchedTargets, t); }) : targets,
52090                 ];
52091             }
52092             function inferFromTypeArguments(sourceTypes, targetTypes, variances) {
52093                 var count = sourceTypes.length < targetTypes.length ? sourceTypes.length : targetTypes.length;
52094                 for (var i = 0; i < count; i++) {
52095                     if (i < variances.length && (variances[i] & 7) === 2) {
52096                         inferFromContravariantTypes(sourceTypes[i], targetTypes[i]);
52097                     }
52098                     else {
52099                         inferFromTypes(sourceTypes[i], targetTypes[i]);
52100                     }
52101                 }
52102             }
52103             function inferFromContravariantTypes(source, target) {
52104                 if (strictFunctionTypes || priority & 512) {
52105                     contravariant = !contravariant;
52106                     inferFromTypes(source, target);
52107                     contravariant = !contravariant;
52108                 }
52109                 else {
52110                     inferFromTypes(source, target);
52111                 }
52112             }
52113             function getInferenceInfoForType(type) {
52114                 if (type.flags & 8650752) {
52115                     for (var _i = 0, inferences_2 = inferences; _i < inferences_2.length; _i++) {
52116                         var inference = inferences_2[_i];
52117                         if (type === inference.typeParameter) {
52118                             return inference;
52119                         }
52120                     }
52121                 }
52122                 return undefined;
52123             }
52124             function getSingleTypeVariableFromIntersectionTypes(types) {
52125                 var typeVariable;
52126                 for (var _i = 0, types_16 = types; _i < types_16.length; _i++) {
52127                     var type = types_16[_i];
52128                     var t = type.flags & 2097152 && ts.find(type.types, function (t) { return !!getInferenceInfoForType(t); });
52129                     if (!t || typeVariable && t !== typeVariable) {
52130                         return undefined;
52131                     }
52132                     typeVariable = t;
52133                 }
52134                 return typeVariable;
52135             }
52136             function inferToMultipleTypes(source, targets, targetFlags) {
52137                 var typeVariableCount = 0;
52138                 if (targetFlags & 1048576) {
52139                     var nakedTypeVariable = void 0;
52140                     var sources = source.flags & 1048576 ? source.types : [source];
52141                     var matched_1 = new Array(sources.length);
52142                     var inferenceCircularity = false;
52143                     for (var _i = 0, targets_2 = targets; _i < targets_2.length; _i++) {
52144                         var t = targets_2[_i];
52145                         if (getInferenceInfoForType(t)) {
52146                             nakedTypeVariable = t;
52147                             typeVariableCount++;
52148                         }
52149                         else {
52150                             for (var i = 0; i < sources.length; i++) {
52151                                 var saveInferencePriority = inferencePriority;
52152                                 inferencePriority = 1024;
52153                                 inferFromTypes(sources[i], t);
52154                                 if (inferencePriority === priority)
52155                                     matched_1[i] = true;
52156                                 inferenceCircularity = inferenceCircularity || inferencePriority === -1;
52157                                 inferencePriority = Math.min(inferencePriority, saveInferencePriority);
52158                             }
52159                         }
52160                     }
52161                     if (typeVariableCount === 0) {
52162                         var intersectionTypeVariable = getSingleTypeVariableFromIntersectionTypes(targets);
52163                         if (intersectionTypeVariable) {
52164                             inferWithPriority(source, intersectionTypeVariable, 1);
52165                         }
52166                         return;
52167                     }
52168                     if (typeVariableCount === 1 && !inferenceCircularity) {
52169                         var unmatched = ts.flatMap(sources, function (s, i) { return matched_1[i] ? undefined : s; });
52170                         if (unmatched.length) {
52171                             inferFromTypes(getUnionType(unmatched), nakedTypeVariable);
52172                             return;
52173                         }
52174                     }
52175                 }
52176                 else {
52177                     for (var _a = 0, targets_3 = targets; _a < targets_3.length; _a++) {
52178                         var t = targets_3[_a];
52179                         if (getInferenceInfoForType(t)) {
52180                             typeVariableCount++;
52181                         }
52182                         else {
52183                             inferFromTypes(source, t);
52184                         }
52185                     }
52186                 }
52187                 if (targetFlags & 2097152 ? typeVariableCount === 1 : typeVariableCount > 0) {
52188                     for (var _b = 0, targets_4 = targets; _b < targets_4.length; _b++) {
52189                         var t = targets_4[_b];
52190                         if (getInferenceInfoForType(t)) {
52191                             inferWithPriority(source, t, 1);
52192                         }
52193                     }
52194                 }
52195             }
52196             function inferToMappedType(source, target, constraintType) {
52197                 if (constraintType.flags & 1048576) {
52198                     var result = false;
52199                     for (var _i = 0, _a = constraintType.types; _i < _a.length; _i++) {
52200                         var type = _a[_i];
52201                         result = inferToMappedType(source, target, type) || result;
52202                     }
52203                     return result;
52204                 }
52205                 if (constraintType.flags & 4194304) {
52206                     var inference = getInferenceInfoForType(constraintType.type);
52207                     if (inference && !inference.isFixed && !isFromInferenceBlockedSource(source)) {
52208                         var inferredType = inferTypeForHomomorphicMappedType(source, target, constraintType);
52209                         if (inferredType) {
52210                             inferWithPriority(inferredType, inference.typeParameter, ts.getObjectFlags(source) & 2097152 ?
52211                                 8 :
52212                                 4);
52213                         }
52214                     }
52215                     return true;
52216                 }
52217                 if (constraintType.flags & 262144) {
52218                     inferWithPriority(getIndexType(source), constraintType, 16);
52219                     var extendedConstraint = getConstraintOfType(constraintType);
52220                     if (extendedConstraint && inferToMappedType(source, target, extendedConstraint)) {
52221                         return true;
52222                     }
52223                     var propTypes = ts.map(getPropertiesOfType(source), getTypeOfSymbol);
52224                     var stringIndexType = getIndexTypeOfType(source, 0);
52225                     var numberIndexInfo = getNonEnumNumberIndexInfo(source);
52226                     var numberIndexType = numberIndexInfo && numberIndexInfo.type;
52227                     inferFromTypes(getUnionType(ts.append(ts.append(propTypes, stringIndexType), numberIndexType)), getTemplateTypeFromMappedType(target));
52228                     return true;
52229                 }
52230                 return false;
52231             }
52232             function inferToConditionalType(source, target) {
52233                 if (source.flags & 16777216) {
52234                     inferFromTypes(source.checkType, target.checkType);
52235                     inferFromTypes(source.extendsType, target.extendsType);
52236                     inferFromTypes(getTrueTypeFromConditionalType(source), getTrueTypeFromConditionalType(target));
52237                     inferFromTypes(getFalseTypeFromConditionalType(source), getFalseTypeFromConditionalType(target));
52238                 }
52239                 else {
52240                     var savePriority = priority;
52241                     priority |= contravariant ? 32 : 0;
52242                     var targetTypes = [getTrueTypeFromConditionalType(target), getFalseTypeFromConditionalType(target)];
52243                     inferToMultipleTypes(source, targetTypes, target.flags);
52244                     priority = savePriority;
52245                 }
52246             }
52247             function inferToTemplateLiteralType(source, target) {
52248                 var matches = source.flags & 128 ? inferLiteralsFromTemplateLiteralType(source, target) :
52249                     source.flags & 134217728 && ts.arraysEqual(source.texts, target.texts) ? source.types :
52250                         undefined;
52251                 var types = target.types;
52252                 for (var i = 0; i < types.length; i++) {
52253                     inferFromTypes(matches ? matches[i] : neverType, types[i]);
52254                 }
52255             }
52256             function inferFromObjectTypes(source, target) {
52257                 if (ts.getObjectFlags(source) & 4 && ts.getObjectFlags(target) & 4 && (source.target === target.target || isArrayType(source) && isArrayType(target))) {
52258                     inferFromTypeArguments(getTypeArguments(source), getTypeArguments(target), getVariances(source.target));
52259                     return;
52260                 }
52261                 if (isGenericMappedType(source) && isGenericMappedType(target)) {
52262                     inferFromTypes(getConstraintTypeFromMappedType(source), getConstraintTypeFromMappedType(target));
52263                     inferFromTypes(getTemplateTypeFromMappedType(source), getTemplateTypeFromMappedType(target));
52264                     var sourceNameType = getNameTypeFromMappedType(source);
52265                     var targetNameType = getNameTypeFromMappedType(target);
52266                     if (sourceNameType && targetNameType)
52267                         inferFromTypes(sourceNameType, targetNameType);
52268                 }
52269                 if (ts.getObjectFlags(target) & 32 && !target.declaration.nameType) {
52270                     var constraintType = getConstraintTypeFromMappedType(target);
52271                     if (inferToMappedType(source, target, constraintType)) {
52272                         return;
52273                     }
52274                 }
52275                 if (!typesDefinitelyUnrelated(source, target)) {
52276                     if (isArrayType(source) || isTupleType(source)) {
52277                         if (isTupleType(target)) {
52278                             var sourceArity = getTypeReferenceArity(source);
52279                             var targetArity = getTypeReferenceArity(target);
52280                             var elementTypes = getTypeArguments(target);
52281                             var elementFlags = target.target.elementFlags;
52282                             if (isTupleType(source) && isTupleTypeStructureMatching(source, target)) {
52283                                 for (var i = 0; i < targetArity; i++) {
52284                                     inferFromTypes(getTypeArguments(source)[i], elementTypes[i]);
52285                                 }
52286                                 return;
52287                             }
52288                             var startLength = isTupleType(source) ? Math.min(source.target.fixedLength, target.target.fixedLength) : 0;
52289                             var endLength = Math.min(isTupleType(source) ? getEndElementCount(source.target, 3) : 0, target.target.hasRestElement ? getEndElementCount(target.target, 3) : 0);
52290                             for (var i = 0; i < startLength; i++) {
52291                                 inferFromTypes(getTypeArguments(source)[i], elementTypes[i]);
52292                             }
52293                             if (!isTupleType(source) || sourceArity - startLength - endLength === 1 && source.target.elementFlags[startLength] & 4) {
52294                                 var restType = getTypeArguments(source)[startLength];
52295                                 for (var i = startLength; i < targetArity - endLength; i++) {
52296                                     inferFromTypes(elementFlags[i] & 8 ? createArrayType(restType) : restType, elementTypes[i]);
52297                                 }
52298                             }
52299                             else {
52300                                 var middleLength = targetArity - startLength - endLength;
52301                                 if (middleLength === 2 && elementFlags[startLength] & elementFlags[startLength + 1] & 8 && isTupleType(source)) {
52302                                     var targetInfo = getInferenceInfoForType(elementTypes[startLength]);
52303                                     if (targetInfo && targetInfo.impliedArity !== undefined) {
52304                                         inferFromTypes(sliceTupleType(source, startLength, endLength + sourceArity - targetInfo.impliedArity), elementTypes[startLength]);
52305                                         inferFromTypes(sliceTupleType(source, startLength + targetInfo.impliedArity, endLength), elementTypes[startLength + 1]);
52306                                     }
52307                                 }
52308                                 else if (middleLength === 1 && elementFlags[startLength] & 8) {
52309                                     var endsInOptional = target.target.elementFlags[targetArity - 1] & 2;
52310                                     var sourceSlice = isTupleType(source) ? sliceTupleType(source, startLength, endLength) : createArrayType(getTypeArguments(source)[0]);
52311                                     inferWithPriority(sourceSlice, elementTypes[startLength], endsInOptional ? 2 : 0);
52312                                 }
52313                                 else if (middleLength === 1 && elementFlags[startLength] & 4) {
52314                                     var restType = isTupleType(source) ? getElementTypeOfSliceOfTupleType(source, startLength, endLength) : getTypeArguments(source)[0];
52315                                     if (restType) {
52316                                         inferFromTypes(restType, elementTypes[startLength]);
52317                                     }
52318                                 }
52319                             }
52320                             for (var i = 0; i < endLength; i++) {
52321                                 inferFromTypes(getTypeArguments(source)[sourceArity - i - 1], elementTypes[targetArity - i - 1]);
52322                             }
52323                             return;
52324                         }
52325                         if (isArrayType(target)) {
52326                             inferFromIndexTypes(source, target);
52327                             return;
52328                         }
52329                     }
52330                     inferFromProperties(source, target);
52331                     inferFromSignatures(source, target, 0);
52332                     inferFromSignatures(source, target, 1);
52333                     inferFromIndexTypes(source, target);
52334                 }
52335             }
52336             function inferFromProperties(source, target) {
52337                 var properties = getPropertiesOfObjectType(target);
52338                 for (var _i = 0, properties_3 = properties; _i < properties_3.length; _i++) {
52339                     var targetProp = properties_3[_i];
52340                     var sourceProp = getPropertyOfType(source, targetProp.escapedName);
52341                     if (sourceProp) {
52342                         inferFromTypes(getTypeOfSymbol(sourceProp), getTypeOfSymbol(targetProp));
52343                     }
52344                 }
52345             }
52346             function inferFromSignatures(source, target, kind) {
52347                 var sourceSignatures = getSignaturesOfType(source, kind);
52348                 var targetSignatures = getSignaturesOfType(target, kind);
52349                 var sourceLen = sourceSignatures.length;
52350                 var targetLen = targetSignatures.length;
52351                 var len = sourceLen < targetLen ? sourceLen : targetLen;
52352                 var skipParameters = !!(ts.getObjectFlags(source) & 2097152);
52353                 for (var i = 0; i < len; i++) {
52354                     inferFromSignature(getBaseSignature(sourceSignatures[sourceLen - len + i]), getErasedSignature(targetSignatures[targetLen - len + i]), skipParameters);
52355                 }
52356             }
52357             function inferFromSignature(source, target, skipParameters) {
52358                 if (!skipParameters) {
52359                     var saveBivariant = bivariant;
52360                     var kind = target.declaration ? target.declaration.kind : 0;
52361                     bivariant = bivariant || kind === 165 || kind === 164 || kind === 166;
52362                     applyToParameterTypes(source, target, inferFromContravariantTypes);
52363                     bivariant = saveBivariant;
52364                 }
52365                 applyToReturnTypes(source, target, inferFromTypes);
52366             }
52367             function inferFromIndexTypes(source, target) {
52368                 var targetStringIndexType = getIndexTypeOfType(target, 0);
52369                 if (targetStringIndexType) {
52370                     var sourceIndexType = getIndexTypeOfType(source, 0) ||
52371                         getImplicitIndexTypeOfType(source, 0);
52372                     if (sourceIndexType) {
52373                         inferFromTypes(sourceIndexType, targetStringIndexType);
52374                     }
52375                 }
52376                 var targetNumberIndexType = getIndexTypeOfType(target, 1);
52377                 if (targetNumberIndexType) {
52378                     var sourceIndexType = getIndexTypeOfType(source, 1) ||
52379                         getIndexTypeOfType(source, 0) ||
52380                         getImplicitIndexTypeOfType(source, 1);
52381                     if (sourceIndexType) {
52382                         inferFromTypes(sourceIndexType, targetNumberIndexType);
52383                     }
52384                 }
52385             }
52386         }
52387         function isTypeOrBaseIdenticalTo(s, t) {
52388             return isTypeIdenticalTo(s, t) || !!(t.flags & 4 && s.flags & 128 || t.flags & 8 && s.flags & 256);
52389         }
52390         function isTypeCloselyMatchedBy(s, t) {
52391             return !!(s.flags & 524288 && t.flags & 524288 && s.symbol && s.symbol === t.symbol ||
52392                 s.aliasSymbol && s.aliasTypeArguments && s.aliasSymbol === t.aliasSymbol);
52393         }
52394         function hasPrimitiveConstraint(type) {
52395             var constraint = getConstraintOfTypeParameter(type);
52396             return !!constraint && maybeTypeOfKind(constraint.flags & 16777216 ? getDefaultConstraintOfConditionalType(constraint) : constraint, 131068 | 4194304 | 134217728 | 268435456);
52397         }
52398         function isObjectLiteralType(type) {
52399             return !!(ts.getObjectFlags(type) & 128);
52400         }
52401         function isObjectOrArrayLiteralType(type) {
52402             return !!(ts.getObjectFlags(type) & (128 | 65536));
52403         }
52404         function unionObjectAndArrayLiteralCandidates(candidates) {
52405             if (candidates.length > 1) {
52406                 var objectLiterals = ts.filter(candidates, isObjectOrArrayLiteralType);
52407                 if (objectLiterals.length) {
52408                     var literalsType = getUnionType(objectLiterals, 2);
52409                     return ts.concatenate(ts.filter(candidates, function (t) { return !isObjectOrArrayLiteralType(t); }), [literalsType]);
52410                 }
52411             }
52412             return candidates;
52413         }
52414         function getContravariantInference(inference) {
52415             return inference.priority & 208 ? getIntersectionType(inference.contraCandidates) : getCommonSubtype(inference.contraCandidates);
52416         }
52417         function getCovariantInference(inference, signature) {
52418             var candidates = unionObjectAndArrayLiteralCandidates(inference.candidates);
52419             var primitiveConstraint = hasPrimitiveConstraint(inference.typeParameter);
52420             var widenLiteralTypes = !primitiveConstraint && inference.topLevel &&
52421                 (inference.isFixed || !isTypeParameterAtTopLevel(getReturnTypeOfSignature(signature), inference.typeParameter));
52422             var baseCandidates = primitiveConstraint ? ts.sameMap(candidates, getRegularTypeOfLiteralType) :
52423                 widenLiteralTypes ? ts.sameMap(candidates, getWidenedLiteralType) :
52424                     candidates;
52425             var unwidenedType = inference.priority & 208 ?
52426                 getUnionType(baseCandidates, 2) :
52427                 getCommonSupertype(baseCandidates);
52428             return getWidenedType(unwidenedType);
52429         }
52430         function getInferredType(context, index) {
52431             var inference = context.inferences[index];
52432             if (!inference.inferredType) {
52433                 var inferredType = void 0;
52434                 var signature = context.signature;
52435                 if (signature) {
52436                     var inferredCovariantType = inference.candidates ? getCovariantInference(inference, signature) : undefined;
52437                     if (inference.contraCandidates) {
52438                         var inferredContravariantType = getContravariantInference(inference);
52439                         inferredType = inferredCovariantType && !(inferredCovariantType.flags & 131072) &&
52440                             isTypeSubtypeOf(inferredCovariantType, inferredContravariantType) ?
52441                             inferredCovariantType : inferredContravariantType;
52442                     }
52443                     else if (inferredCovariantType) {
52444                         inferredType = inferredCovariantType;
52445                     }
52446                     else if (context.flags & 1) {
52447                         inferredType = silentNeverType;
52448                     }
52449                     else {
52450                         var defaultType = getDefaultFromTypeParameter(inference.typeParameter);
52451                         if (defaultType) {
52452                             inferredType = instantiateType(defaultType, mergeTypeMappers(createBackreferenceMapper(context, index), context.nonFixingMapper));
52453                         }
52454                     }
52455                 }
52456                 else {
52457                     inferredType = getTypeFromInference(inference);
52458                 }
52459                 inference.inferredType = inferredType || getDefaultTypeArgumentType(!!(context.flags & 2));
52460                 var constraint = getConstraintOfTypeParameter(inference.typeParameter);
52461                 if (constraint) {
52462                     var instantiatedConstraint = instantiateType(constraint, context.nonFixingMapper);
52463                     if (!inferredType || !context.compareTypes(inferredType, getTypeWithThisArgument(instantiatedConstraint, inferredType))) {
52464                         inference.inferredType = inferredType = instantiatedConstraint;
52465                     }
52466                 }
52467             }
52468             return inference.inferredType;
52469         }
52470         function getDefaultTypeArgumentType(isInJavaScriptFile) {
52471             return isInJavaScriptFile ? anyType : unknownType;
52472         }
52473         function getInferredTypes(context) {
52474             var result = [];
52475             for (var i = 0; i < context.inferences.length; i++) {
52476                 result.push(getInferredType(context, i));
52477             }
52478             return result;
52479         }
52480         function getCannotFindNameDiagnosticForName(node) {
52481             switch (node.escapedText) {
52482                 case "document":
52483                 case "console":
52484                     return ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_change_your_target_library_Try_changing_the_lib_compiler_option_to_include_dom;
52485                 case "$":
52486                     return compilerOptions.types
52487                         ? 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
52488                         : ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_jQuery_Try_npm_i_save_dev_types_Slashjquery;
52489                 case "describe":
52490                 case "suite":
52491                 case "it":
52492                 case "test":
52493                     return compilerOptions.types
52494                         ? 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
52495                         : 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;
52496                 case "process":
52497                 case "require":
52498                 case "Buffer":
52499                 case "module":
52500                     return compilerOptions.types
52501                         ? 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
52502                         : ts.Diagnostics.Cannot_find_name_0_Do_you_need_to_install_type_definitions_for_node_Try_npm_i_save_dev_types_Slashnode;
52503                 case "Map":
52504                 case "Set":
52505                 case "Promise":
52506                 case "Symbol":
52507                 case "WeakMap":
52508                 case "WeakSet":
52509                 case "Iterator":
52510                 case "AsyncIterator":
52511                 case "SharedArrayBuffer":
52512                 case "Atomics":
52513                 case "AsyncIterable":
52514                 case "AsyncIterableIterator":
52515                 case "AsyncGenerator":
52516                 case "AsyncGeneratorFunction":
52517                 case "BigInt":
52518                 case "Reflect":
52519                 case "BigInt64Array":
52520                 case "BigUint64Array":
52521                     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;
52522                 default:
52523                     if (node.parent.kind === 289) {
52524                         return ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer;
52525                     }
52526                     else {
52527                         return ts.Diagnostics.Cannot_find_name_0;
52528                     }
52529             }
52530         }
52531         function getResolvedSymbol(node) {
52532             var links = getNodeLinks(node);
52533             if (!links.resolvedSymbol) {
52534                 links.resolvedSymbol = !ts.nodeIsMissing(node) &&
52535                     resolveName(node, node.escapedText, 111551 | 1048576, getCannotFindNameDiagnosticForName(node), node, !ts.isWriteOnlyAccess(node), false, ts.Diagnostics.Cannot_find_name_0_Did_you_mean_1) || unknownSymbol;
52536             }
52537             return links.resolvedSymbol;
52538         }
52539         function isInTypeQuery(node) {
52540             return !!ts.findAncestor(node, function (n) { return n.kind === 176 ? true : n.kind === 78 || n.kind === 157 ? false : "quit"; });
52541         }
52542         function getFlowCacheKey(node, declaredType, initialType, flowContainer) {
52543             switch (node.kind) {
52544                 case 78:
52545                     var symbol = getResolvedSymbol(node);
52546                     return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + (isConstraintPosition(node) ? "@" : "") + getSymbolId(symbol) : undefined;
52547                 case 107:
52548                     return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType);
52549                 case 225:
52550                 case 207:
52551                     return getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
52552                 case 201:
52553                 case 202:
52554                     var propName = getAccessedPropertyName(node);
52555                     if (propName !== undefined) {
52556                         var key = getFlowCacheKey(node.expression, declaredType, initialType, flowContainer);
52557                         return key && key + "." + propName;
52558                     }
52559             }
52560             return undefined;
52561         }
52562         function isMatchingReference(source, target) {
52563             switch (target.kind) {
52564                 case 207:
52565                 case 225:
52566                     return isMatchingReference(source, target.expression);
52567                 case 216:
52568                     return (ts.isAssignmentExpression(target) && isMatchingReference(source, target.left)) ||
52569                         (ts.isBinaryExpression(target) && target.operatorToken.kind === 27 && isMatchingReference(source, target.right));
52570             }
52571             switch (source.kind) {
52572                 case 78:
52573                 case 79:
52574                     return target.kind === 78 && getResolvedSymbol(source) === getResolvedSymbol(target) ||
52575                         (target.kind === 249 || target.kind === 198) &&
52576                             getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(source)) === getSymbolOfNode(target);
52577                 case 107:
52578                     return target.kind === 107;
52579                 case 105:
52580                     return target.kind === 105;
52581                 case 225:
52582                 case 207:
52583                     return isMatchingReference(source.expression, target);
52584                 case 201:
52585                 case 202:
52586                     return ts.isAccessExpression(target) &&
52587                         getAccessedPropertyName(source) === getAccessedPropertyName(target) &&
52588                         isMatchingReference(source.expression, target.expression);
52589                 case 157:
52590                     return ts.isAccessExpression(target) &&
52591                         source.right.escapedText === getAccessedPropertyName(target) &&
52592                         isMatchingReference(source.left, target.expression);
52593                 case 216:
52594                     return (ts.isBinaryExpression(source) && source.operatorToken.kind === 27 && isMatchingReference(source.right, target));
52595             }
52596             return false;
52597         }
52598         function containsTruthyCheck(source, target) {
52599             return isMatchingReference(source, target) ||
52600                 (target.kind === 216 && target.operatorToken.kind === 55 &&
52601                     (containsTruthyCheck(source, target.left) || containsTruthyCheck(source, target.right)));
52602         }
52603         function getAccessedPropertyName(access) {
52604             return access.kind === 201 ? access.name.escapedText :
52605                 ts.isStringOrNumericLiteralLike(access.argumentExpression) ? ts.escapeLeadingUnderscores(access.argumentExpression.text) :
52606                     undefined;
52607         }
52608         function containsMatchingReference(source, target) {
52609             while (ts.isAccessExpression(source)) {
52610                 source = source.expression;
52611                 if (isMatchingReference(source, target)) {
52612                     return true;
52613                 }
52614             }
52615             return false;
52616         }
52617         function optionalChainContainsReference(source, target) {
52618             while (ts.isOptionalChain(source)) {
52619                 source = source.expression;
52620                 if (isMatchingReference(source, target)) {
52621                     return true;
52622                 }
52623             }
52624             return false;
52625         }
52626         function isDiscriminantProperty(type, name) {
52627             if (type && type.flags & 1048576) {
52628                 var prop = getUnionOrIntersectionProperty(type, name);
52629                 if (prop && ts.getCheckFlags(prop) & 2) {
52630                     if (prop.isDiscriminantProperty === undefined) {
52631                         prop.isDiscriminantProperty =
52632                             (prop.checkFlags & 192) === 192 &&
52633                                 !maybeTypeOfKind(getTypeOfSymbol(prop), 465829888);
52634                     }
52635                     return !!prop.isDiscriminantProperty;
52636                 }
52637             }
52638             return false;
52639         }
52640         function findDiscriminantProperties(sourceProperties, target) {
52641             var result;
52642             for (var _i = 0, sourceProperties_2 = sourceProperties; _i < sourceProperties_2.length; _i++) {
52643                 var sourceProperty = sourceProperties_2[_i];
52644                 if (isDiscriminantProperty(target, sourceProperty.escapedName)) {
52645                     if (result) {
52646                         result.push(sourceProperty);
52647                         continue;
52648                     }
52649                     result = [sourceProperty];
52650                 }
52651             }
52652             return result;
52653         }
52654         function isOrContainsMatchingReference(source, target) {
52655             return isMatchingReference(source, target) || containsMatchingReference(source, target);
52656         }
52657         function hasMatchingArgument(expression, reference) {
52658             if (expression.arguments) {
52659                 for (var _i = 0, _a = expression.arguments; _i < _a.length; _i++) {
52660                     var argument = _a[_i];
52661                     if (isOrContainsMatchingReference(reference, argument)) {
52662                         return true;
52663                     }
52664                 }
52665             }
52666             if (expression.expression.kind === 201 &&
52667                 isOrContainsMatchingReference(reference, expression.expression.expression)) {
52668                 return true;
52669             }
52670             return false;
52671         }
52672         function getFlowNodeId(flow) {
52673             if (!flow.id || flow.id < 0) {
52674                 flow.id = nextFlowId;
52675                 nextFlowId++;
52676             }
52677             return flow.id;
52678         }
52679         function typeMaybeAssignableTo(source, target) {
52680             if (!(source.flags & 1048576)) {
52681                 return isTypeAssignableTo(source, target);
52682             }
52683             for (var _i = 0, _a = source.types; _i < _a.length; _i++) {
52684                 var t = _a[_i];
52685                 if (isTypeAssignableTo(t, target)) {
52686                     return true;
52687                 }
52688             }
52689             return false;
52690         }
52691         function getAssignmentReducedType(declaredType, assignedType) {
52692             if (declaredType !== assignedType) {
52693                 if (assignedType.flags & 131072) {
52694                     return assignedType;
52695                 }
52696                 var reducedType = filterType(declaredType, function (t) { return typeMaybeAssignableTo(assignedType, t); });
52697                 if (assignedType.flags & 512 && isFreshLiteralType(assignedType)) {
52698                     reducedType = mapType(reducedType, getFreshTypeOfLiteralType);
52699                 }
52700                 if (isTypeAssignableTo(assignedType, reducedType)) {
52701                     return reducedType;
52702                 }
52703             }
52704             return declaredType;
52705         }
52706         function getTypeFactsOfTypes(types) {
52707             var result = 0;
52708             for (var _i = 0, types_17 = types; _i < types_17.length; _i++) {
52709                 var t = types_17[_i];
52710                 result |= getTypeFacts(t);
52711             }
52712             return result;
52713         }
52714         function isFunctionObjectType(type) {
52715             var resolved = resolveStructuredTypeMembers(type);
52716             return !!(resolved.callSignatures.length || resolved.constructSignatures.length ||
52717                 resolved.members.get("bind") && isTypeSubtypeOf(type, globalFunctionType));
52718         }
52719         function getTypeFacts(type) {
52720             var flags = type.flags;
52721             if (flags & 4) {
52722                 return strictNullChecks ? 16317953 : 16776705;
52723             }
52724             if (flags & 128) {
52725                 var isEmpty = type.value === "";
52726                 return strictNullChecks ?
52727                     isEmpty ? 12123649 : 7929345 :
52728                     isEmpty ? 12582401 : 16776705;
52729             }
52730             if (flags & (8 | 32)) {
52731                 return strictNullChecks ? 16317698 : 16776450;
52732             }
52733             if (flags & 256) {
52734                 var isZero = type.value === 0;
52735                 return strictNullChecks ?
52736                     isZero ? 12123394 : 7929090 :
52737                     isZero ? 12582146 : 16776450;
52738             }
52739             if (flags & 64) {
52740                 return strictNullChecks ? 16317188 : 16775940;
52741             }
52742             if (flags & 2048) {
52743                 var isZero = isZeroBigInt(type);
52744                 return strictNullChecks ?
52745                     isZero ? 12122884 : 7928580 :
52746                     isZero ? 12581636 : 16775940;
52747             }
52748             if (flags & 16) {
52749                 return strictNullChecks ? 16316168 : 16774920;
52750             }
52751             if (flags & 528) {
52752                 return strictNullChecks ?
52753                     (type === falseType || type === regularFalseType) ? 12121864 : 7927560 :
52754                     (type === falseType || type === regularFalseType) ? 12580616 : 16774920;
52755             }
52756             if (flags & 524288) {
52757                 return ts.getObjectFlags(type) & 16 && isEmptyObjectType(type) ?
52758                     strictNullChecks ? 16318463 : 16777215 :
52759                     isFunctionObjectType(type) ?
52760                         strictNullChecks ? 7880640 : 16728000 :
52761                         strictNullChecks ? 7888800 : 16736160;
52762             }
52763             if (flags & (16384 | 32768)) {
52764                 return 9830144;
52765             }
52766             if (flags & 65536) {
52767                 return 9363232;
52768             }
52769             if (flags & 12288) {
52770                 return strictNullChecks ? 7925520 : 16772880;
52771             }
52772             if (flags & 67108864) {
52773                 return strictNullChecks ? 7888800 : 16736160;
52774             }
52775             if (flags & 131072) {
52776                 return 0;
52777             }
52778             if (flags & 465829888) {
52779                 return !isPatternLiteralType(type) ? getTypeFacts(getBaseConstraintOfType(type) || unknownType) :
52780                     strictNullChecks ? 7929345 : 16776705;
52781             }
52782             if (flags & 3145728) {
52783                 return getTypeFactsOfTypes(type.types);
52784             }
52785             return 16777215;
52786         }
52787         function getTypeWithFacts(type, include) {
52788             return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
52789         }
52790         function getTypeWithDefault(type, defaultExpression) {
52791             if (defaultExpression) {
52792                 var defaultType = getTypeOfExpression(defaultExpression);
52793                 return getUnionType([getTypeWithFacts(type, 524288), defaultType]);
52794             }
52795             return type;
52796         }
52797         function getTypeOfDestructuredProperty(type, name) {
52798             var nameType = getLiteralTypeFromPropertyName(name);
52799             if (!isTypeUsableAsPropertyName(nameType))
52800                 return errorType;
52801             var text = getPropertyNameFromType(nameType);
52802             return getConstraintForLocation(getTypeOfPropertyOfType(type, text), name) ||
52803                 isNumericLiteralName(text) && includeUndefinedInIndexSignature(getIndexTypeOfType(type, 1)) ||
52804                 includeUndefinedInIndexSignature(getIndexTypeOfType(type, 0)) ||
52805                 errorType;
52806         }
52807         function getTypeOfDestructuredArrayElement(type, index) {
52808             return everyType(type, isTupleLikeType) && getTupleElementType(type, index) ||
52809                 includeUndefinedInIndexSignature(checkIteratedTypeOrElementType(65, type, undefinedType, undefined)) ||
52810                 errorType;
52811         }
52812         function includeUndefinedInIndexSignature(type) {
52813             if (!type)
52814                 return type;
52815             return compilerOptions.noUncheckedIndexedAccess ?
52816                 getUnionType([type, undefinedType]) :
52817                 type;
52818         }
52819         function getTypeOfDestructuredSpreadExpression(type) {
52820             return createArrayType(checkIteratedTypeOrElementType(65, type, undefinedType, undefined) || errorType);
52821         }
52822         function getAssignedTypeOfBinaryExpression(node) {
52823             var isDestructuringDefaultAssignment = node.parent.kind === 199 && isDestructuringAssignmentTarget(node.parent) ||
52824                 node.parent.kind === 288 && isDestructuringAssignmentTarget(node.parent.parent);
52825             return isDestructuringDefaultAssignment ?
52826                 getTypeWithDefault(getAssignedType(node), node.right) :
52827                 getTypeOfExpression(node.right);
52828         }
52829         function isDestructuringAssignmentTarget(parent) {
52830             return parent.parent.kind === 216 && parent.parent.left === parent ||
52831                 parent.parent.kind === 239 && parent.parent.initializer === parent;
52832         }
52833         function getAssignedTypeOfArrayLiteralElement(node, element) {
52834             return getTypeOfDestructuredArrayElement(getAssignedType(node), node.elements.indexOf(element));
52835         }
52836         function getAssignedTypeOfSpreadExpression(node) {
52837             return getTypeOfDestructuredSpreadExpression(getAssignedType(node.parent));
52838         }
52839         function getAssignedTypeOfPropertyAssignment(node) {
52840             return getTypeOfDestructuredProperty(getAssignedType(node.parent), node.name);
52841         }
52842         function getAssignedTypeOfShorthandPropertyAssignment(node) {
52843             return getTypeWithDefault(getAssignedTypeOfPropertyAssignment(node), node.objectAssignmentInitializer);
52844         }
52845         function getAssignedType(node) {
52846             var parent = node.parent;
52847             switch (parent.kind) {
52848                 case 238:
52849                     return stringType;
52850                 case 239:
52851                     return checkRightHandSideOfForOf(parent) || errorType;
52852                 case 216:
52853                     return getAssignedTypeOfBinaryExpression(parent);
52854                 case 210:
52855                     return undefinedType;
52856                 case 199:
52857                     return getAssignedTypeOfArrayLiteralElement(parent, node);
52858                 case 220:
52859                     return getAssignedTypeOfSpreadExpression(parent);
52860                 case 288:
52861                     return getAssignedTypeOfPropertyAssignment(parent);
52862                 case 289:
52863                     return getAssignedTypeOfShorthandPropertyAssignment(parent);
52864             }
52865             return errorType;
52866         }
52867         function getInitialTypeOfBindingElement(node) {
52868             var pattern = node.parent;
52869             var parentType = getInitialType(pattern.parent);
52870             var type = pattern.kind === 196 ?
52871                 getTypeOfDestructuredProperty(parentType, node.propertyName || node.name) :
52872                 !node.dotDotDotToken ?
52873                     getTypeOfDestructuredArrayElement(parentType, pattern.elements.indexOf(node)) :
52874                     getTypeOfDestructuredSpreadExpression(parentType);
52875             return getTypeWithDefault(type, node.initializer);
52876         }
52877         function getTypeOfInitializer(node) {
52878             var links = getNodeLinks(node);
52879             return links.resolvedType || getTypeOfExpression(node);
52880         }
52881         function getInitialTypeOfVariableDeclaration(node) {
52882             if (node.initializer) {
52883                 return getTypeOfInitializer(node.initializer);
52884             }
52885             if (node.parent.parent.kind === 238) {
52886                 return stringType;
52887             }
52888             if (node.parent.parent.kind === 239) {
52889                 return checkRightHandSideOfForOf(node.parent.parent) || errorType;
52890             }
52891             return errorType;
52892         }
52893         function getInitialType(node) {
52894             return node.kind === 249 ?
52895                 getInitialTypeOfVariableDeclaration(node) :
52896                 getInitialTypeOfBindingElement(node);
52897         }
52898         function isEmptyArrayAssignment(node) {
52899             return node.kind === 249 && node.initializer &&
52900                 isEmptyArrayLiteral(node.initializer) ||
52901                 node.kind !== 198 && node.parent.kind === 216 &&
52902                     isEmptyArrayLiteral(node.parent.right);
52903         }
52904         function getReferenceCandidate(node) {
52905             switch (node.kind) {
52906                 case 207:
52907                     return getReferenceCandidate(node.expression);
52908                 case 216:
52909                     switch (node.operatorToken.kind) {
52910                         case 62:
52911                         case 74:
52912                         case 75:
52913                         case 76:
52914                             return getReferenceCandidate(node.left);
52915                         case 27:
52916                             return getReferenceCandidate(node.right);
52917                     }
52918             }
52919             return node;
52920         }
52921         function getReferenceRoot(node) {
52922             var parent = node.parent;
52923             return parent.kind === 207 ||
52924                 parent.kind === 216 && parent.operatorToken.kind === 62 && parent.left === node ||
52925                 parent.kind === 216 && parent.operatorToken.kind === 27 && parent.right === node ?
52926                 getReferenceRoot(parent) : node;
52927         }
52928         function getTypeOfSwitchClause(clause) {
52929             if (clause.kind === 284) {
52930                 return getRegularTypeOfLiteralType(getTypeOfExpression(clause.expression));
52931             }
52932             return neverType;
52933         }
52934         function getSwitchClauseTypes(switchStatement) {
52935             var links = getNodeLinks(switchStatement);
52936             if (!links.switchTypes) {
52937                 links.switchTypes = [];
52938                 for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) {
52939                     var clause = _a[_i];
52940                     links.switchTypes.push(getTypeOfSwitchClause(clause));
52941                 }
52942             }
52943             return links.switchTypes;
52944         }
52945         function getSwitchClauseTypeOfWitnesses(switchStatement, retainDefault) {
52946             var witnesses = [];
52947             for (var _i = 0, _a = switchStatement.caseBlock.clauses; _i < _a.length; _i++) {
52948                 var clause = _a[_i];
52949                 if (clause.kind === 284) {
52950                     if (ts.isStringLiteralLike(clause.expression)) {
52951                         witnesses.push(clause.expression.text);
52952                         continue;
52953                     }
52954                     return ts.emptyArray;
52955                 }
52956                 if (retainDefault)
52957                     witnesses.push(undefined);
52958             }
52959             return witnesses;
52960         }
52961         function eachTypeContainedIn(source, types) {
52962             return source.flags & 1048576 ? !ts.forEach(source.types, function (t) { return !ts.contains(types, t); }) : ts.contains(types, source);
52963         }
52964         function isTypeSubsetOf(source, target) {
52965             return source === target || target.flags & 1048576 && isTypeSubsetOfUnion(source, target);
52966         }
52967         function isTypeSubsetOfUnion(source, target) {
52968             if (source.flags & 1048576) {
52969                 for (var _i = 0, _a = source.types; _i < _a.length; _i++) {
52970                     var t = _a[_i];
52971                     if (!containsType(target.types, t)) {
52972                         return false;
52973                     }
52974                 }
52975                 return true;
52976             }
52977             if (source.flags & 1024 && getBaseTypeOfEnumLiteralType(source) === target) {
52978                 return true;
52979             }
52980             return containsType(target.types, source);
52981         }
52982         function forEachType(type, f) {
52983             return type.flags & 1048576 ? ts.forEach(type.types, f) : f(type);
52984         }
52985         function everyType(type, f) {
52986             return type.flags & 1048576 ? ts.every(type.types, f) : f(type);
52987         }
52988         function filterType(type, f) {
52989             if (type.flags & 1048576) {
52990                 var types = type.types;
52991                 var filtered = ts.filter(types, f);
52992                 if (filtered === types) {
52993                     return type;
52994                 }
52995                 var origin = type.origin;
52996                 var newOrigin = void 0;
52997                 if (origin && origin.flags & 1048576) {
52998                     var originTypes = origin.types;
52999                     var originFiltered = ts.filter(originTypes, function (t) { return !!(t.flags & 1048576) || f(t); });
53000                     if (originTypes.length - originFiltered.length === types.length - filtered.length) {
53001                         if (originFiltered.length === 1) {
53002                             return originFiltered[0];
53003                         }
53004                         newOrigin = createOriginUnionOrIntersectionType(1048576, originFiltered);
53005                     }
53006                 }
53007                 return getUnionTypeFromSortedList(filtered, type.objectFlags, undefined, undefined, newOrigin);
53008             }
53009             return type.flags & 131072 || f(type) ? type : neverType;
53010         }
53011         function countTypes(type) {
53012             return type.flags & 1048576 ? type.types.length : 1;
53013         }
53014         function mapType(type, mapper, noReductions) {
53015             if (type.flags & 131072) {
53016                 return type;
53017             }
53018             if (!(type.flags & 1048576)) {
53019                 return mapper(type);
53020             }
53021             var origin = type.origin;
53022             var types = origin && origin.flags & 1048576 ? origin.types : type.types;
53023             var mappedTypes;
53024             var changed = false;
53025             for (var _i = 0, types_18 = types; _i < types_18.length; _i++) {
53026                 var t = types_18[_i];
53027                 var mapped = t.flags & 1048576 ? mapType(t, mapper, noReductions) : mapper(t);
53028                 changed || (changed = t !== mapped);
53029                 if (mapped) {
53030                     if (!mappedTypes) {
53031                         mappedTypes = [mapped];
53032                     }
53033                     else {
53034                         mappedTypes.push(mapped);
53035                     }
53036                 }
53037             }
53038             return changed ? mappedTypes && getUnionType(mappedTypes, noReductions ? 0 : 1) : type;
53039         }
53040         function mapTypeWithAlias(type, mapper, aliasSymbol, aliasTypeArguments) {
53041             return type.flags & 1048576 && aliasSymbol ?
53042                 getUnionType(ts.map(type.types, mapper), 1, aliasSymbol, aliasTypeArguments) :
53043                 mapType(type, mapper);
53044         }
53045         function getConstituentCount(type) {
53046             return type.flags & 3145728 ? type.types.length : 1;
53047         }
53048         function extractTypesOfKind(type, kind) {
53049             return filterType(type, function (t) { return (t.flags & kind) !== 0; });
53050         }
53051         function replacePrimitivesWithLiterals(typeWithPrimitives, typeWithLiterals) {
53052             if (isTypeSubsetOf(stringType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 128) ||
53053                 isTypeSubsetOf(numberType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 256) ||
53054                 isTypeSubsetOf(bigintType, typeWithPrimitives) && maybeTypeOfKind(typeWithLiterals, 2048)) {
53055                 return mapType(typeWithPrimitives, function (t) {
53056                     return t.flags & 4 ? extractTypesOfKind(typeWithLiterals, 4 | 128) :
53057                         t.flags & 8 ? extractTypesOfKind(typeWithLiterals, 8 | 256) :
53058                             t.flags & 64 ? extractTypesOfKind(typeWithLiterals, 64 | 2048) : t;
53059                 });
53060             }
53061             return typeWithPrimitives;
53062         }
53063         function isIncomplete(flowType) {
53064             return flowType.flags === 0;
53065         }
53066         function getTypeFromFlowType(flowType) {
53067             return flowType.flags === 0 ? flowType.type : flowType;
53068         }
53069         function createFlowType(type, incomplete) {
53070             return incomplete ? { flags: 0, type: type.flags & 131072 ? silentNeverType : type } : type;
53071         }
53072         function createEvolvingArrayType(elementType) {
53073             var result = createObjectType(256);
53074             result.elementType = elementType;
53075             return result;
53076         }
53077         function getEvolvingArrayType(elementType) {
53078             return evolvingArrayTypes[elementType.id] || (evolvingArrayTypes[elementType.id] = createEvolvingArrayType(elementType));
53079         }
53080         function addEvolvingArrayElementType(evolvingArrayType, node) {
53081             var elementType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(getContextFreeTypeOfExpression(node)));
53082             return isTypeSubsetOf(elementType, evolvingArrayType.elementType) ? evolvingArrayType : getEvolvingArrayType(getUnionType([evolvingArrayType.elementType, elementType]));
53083         }
53084         function createFinalArrayType(elementType) {
53085             return elementType.flags & 131072 ?
53086                 autoArrayType :
53087                 createArrayType(elementType.flags & 1048576 ?
53088                     getUnionType(elementType.types, 2) :
53089                     elementType);
53090         }
53091         function getFinalArrayType(evolvingArrayType) {
53092             return evolvingArrayType.finalArrayType || (evolvingArrayType.finalArrayType = createFinalArrayType(evolvingArrayType.elementType));
53093         }
53094         function finalizeEvolvingArrayType(type) {
53095             return ts.getObjectFlags(type) & 256 ? getFinalArrayType(type) : type;
53096         }
53097         function getElementTypeOfEvolvingArrayType(type) {
53098             return ts.getObjectFlags(type) & 256 ? type.elementType : neverType;
53099         }
53100         function isEvolvingArrayTypeList(types) {
53101             var hasEvolvingArrayType = false;
53102             for (var _i = 0, types_19 = types; _i < types_19.length; _i++) {
53103                 var t = types_19[_i];
53104                 if (!(t.flags & 131072)) {
53105                     if (!(ts.getObjectFlags(t) & 256)) {
53106                         return false;
53107                     }
53108                     hasEvolvingArrayType = true;
53109                 }
53110             }
53111             return hasEvolvingArrayType;
53112         }
53113         function isEvolvingArrayOperationTarget(node) {
53114             var root = getReferenceRoot(node);
53115             var parent = root.parent;
53116             var isLengthPushOrUnshift = ts.isPropertyAccessExpression(parent) && (parent.name.escapedText === "length" ||
53117                 parent.parent.kind === 203
53118                     && ts.isIdentifier(parent.name)
53119                     && ts.isPushOrUnshiftIdentifier(parent.name));
53120             var isElementAssignment = parent.kind === 202 &&
53121                 parent.expression === root &&
53122                 parent.parent.kind === 216 &&
53123                 parent.parent.operatorToken.kind === 62 &&
53124                 parent.parent.left === parent &&
53125                 !ts.isAssignmentTarget(parent.parent) &&
53126                 isTypeAssignableToKind(getTypeOfExpression(parent.argumentExpression), 296);
53127             return isLengthPushOrUnshift || isElementAssignment;
53128         }
53129         function isDeclarationWithExplicitTypeAnnotation(declaration) {
53130             return (declaration.kind === 249 || declaration.kind === 160 ||
53131                 declaration.kind === 163 || declaration.kind === 162) &&
53132                 !!ts.getEffectiveTypeAnnotationNode(declaration);
53133         }
53134         function getExplicitTypeOfSymbol(symbol, diagnostic) {
53135             if (symbol.flags & (16 | 8192 | 32 | 512)) {
53136                 return getTypeOfSymbol(symbol);
53137             }
53138             if (symbol.flags & (3 | 4)) {
53139                 if (ts.getCheckFlags(symbol) & 262144) {
53140                     var origin = symbol.syntheticOrigin;
53141                     if (origin && getExplicitTypeOfSymbol(origin)) {
53142                         return getTypeOfSymbol(symbol);
53143                     }
53144                 }
53145                 var declaration = symbol.valueDeclaration;
53146                 if (declaration) {
53147                     if (isDeclarationWithExplicitTypeAnnotation(declaration)) {
53148                         return getTypeOfSymbol(symbol);
53149                     }
53150                     if (ts.isVariableDeclaration(declaration) && declaration.parent.parent.kind === 239) {
53151                         var statement = declaration.parent.parent;
53152                         var expressionType = getTypeOfDottedName(statement.expression, undefined);
53153                         if (expressionType) {
53154                             var use = statement.awaitModifier ? 15 : 13;
53155                             return checkIteratedTypeOrElementType(use, expressionType, undefinedType, undefined);
53156                         }
53157                     }
53158                     if (diagnostic) {
53159                         ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(declaration, ts.Diagnostics._0_needs_an_explicit_type_annotation, symbolToString(symbol)));
53160                     }
53161                 }
53162             }
53163         }
53164         function getTypeOfDottedName(node, diagnostic) {
53165             if (!(node.flags & 16777216)) {
53166                 switch (node.kind) {
53167                     case 78:
53168                         var symbol = getExportSymbolOfValueSymbolIfExported(getResolvedSymbol(node));
53169                         return getExplicitTypeOfSymbol(symbol.flags & 2097152 ? resolveAlias(symbol) : symbol, diagnostic);
53170                     case 107:
53171                         return getExplicitThisType(node);
53172                     case 105:
53173                         return checkSuperExpression(node);
53174                     case 201: {
53175                         var type = getTypeOfDottedName(node.expression, diagnostic);
53176                         if (type) {
53177                             var name = node.name;
53178                             var prop = void 0;
53179                             if (ts.isPrivateIdentifier(name)) {
53180                                 if (!type.symbol) {
53181                                     return undefined;
53182                                 }
53183                                 prop = getPropertyOfType(type, ts.getSymbolNameForPrivateIdentifier(type.symbol, name.escapedText));
53184                             }
53185                             else {
53186                                 prop = getPropertyOfType(type, name.escapedText);
53187                             }
53188                             return prop && getExplicitTypeOfSymbol(prop, diagnostic);
53189                         }
53190                         return undefined;
53191                     }
53192                     case 207:
53193                         return getTypeOfDottedName(node.expression, diagnostic);
53194                 }
53195             }
53196         }
53197         function getEffectsSignature(node) {
53198             var links = getNodeLinks(node);
53199             var signature = links.effectsSignature;
53200             if (signature === undefined) {
53201                 var funcType = void 0;
53202                 if (node.parent.kind === 233) {
53203                     funcType = getTypeOfDottedName(node.expression, undefined);
53204                 }
53205                 else if (node.expression.kind !== 105) {
53206                     if (ts.isOptionalChain(node)) {
53207                         funcType = checkNonNullType(getOptionalExpressionType(checkExpression(node.expression), node.expression), node.expression);
53208                     }
53209                     else {
53210                         funcType = checkNonNullExpression(node.expression);
53211                     }
53212                 }
53213                 var signatures = getSignaturesOfType(funcType && getApparentType(funcType) || unknownType, 0);
53214                 var candidate = signatures.length === 1 && !signatures[0].typeParameters ? signatures[0] :
53215                     ts.some(signatures, hasTypePredicateOrNeverReturnType) ? getResolvedSignature(node) :
53216                         undefined;
53217                 signature = links.effectsSignature = candidate && hasTypePredicateOrNeverReturnType(candidate) ? candidate : unknownSignature;
53218             }
53219             return signature === unknownSignature ? undefined : signature;
53220         }
53221         function hasTypePredicateOrNeverReturnType(signature) {
53222             return !!(getTypePredicateOfSignature(signature) ||
53223                 signature.declaration && (getReturnTypeFromAnnotation(signature.declaration) || unknownType).flags & 131072);
53224         }
53225         function getTypePredicateArgument(predicate, callExpression) {
53226             if (predicate.kind === 1 || predicate.kind === 3) {
53227                 return callExpression.arguments[predicate.parameterIndex];
53228             }
53229             var invokedExpression = ts.skipParentheses(callExpression.expression);
53230             return ts.isAccessExpression(invokedExpression) ? ts.skipParentheses(invokedExpression.expression) : undefined;
53231         }
53232         function reportFlowControlError(node) {
53233             var block = ts.findAncestor(node, ts.isFunctionOrModuleBlock);
53234             var sourceFile = ts.getSourceFileOfNode(node);
53235             var span = ts.getSpanOfTokenAtPosition(sourceFile, block.statements.pos);
53236             diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, ts.Diagnostics.The_containing_function_or_module_body_is_too_large_for_control_flow_analysis));
53237         }
53238         function isReachableFlowNode(flow) {
53239             var result = isReachableFlowNodeWorker(flow, false);
53240             lastFlowNode = flow;
53241             lastFlowNodeReachable = result;
53242             return result;
53243         }
53244         function isFalseExpression(expr) {
53245             var node = ts.skipParentheses(expr);
53246             return node.kind === 94 || node.kind === 216 && (node.operatorToken.kind === 55 && (isFalseExpression(node.left) || isFalseExpression(node.right)) ||
53247                 node.operatorToken.kind === 56 && isFalseExpression(node.left) && isFalseExpression(node.right));
53248         }
53249         function isReachableFlowNodeWorker(flow, noCacheCheck) {
53250             while (true) {
53251                 if (flow === lastFlowNode) {
53252                     return lastFlowNodeReachable;
53253                 }
53254                 var flags = flow.flags;
53255                 if (flags & 4096) {
53256                     if (!noCacheCheck) {
53257                         var id = getFlowNodeId(flow);
53258                         var reachable = flowNodeReachable[id];
53259                         return reachable !== undefined ? reachable : (flowNodeReachable[id] = isReachableFlowNodeWorker(flow, true));
53260                     }
53261                     noCacheCheck = false;
53262                 }
53263                 if (flags & (16 | 96 | 256)) {
53264                     flow = flow.antecedent;
53265                 }
53266                 else if (flags & 512) {
53267                     var signature = getEffectsSignature(flow.node);
53268                     if (signature) {
53269                         var predicate = getTypePredicateOfSignature(signature);
53270                         if (predicate && predicate.kind === 3 && !predicate.type) {
53271                             var predicateArgument = flow.node.arguments[predicate.parameterIndex];
53272                             if (predicateArgument && isFalseExpression(predicateArgument)) {
53273                                 return false;
53274                             }
53275                         }
53276                         if (getReturnTypeOfSignature(signature).flags & 131072) {
53277                             return false;
53278                         }
53279                     }
53280                     flow = flow.antecedent;
53281                 }
53282                 else if (flags & 4) {
53283                     return ts.some(flow.antecedents, function (f) { return isReachableFlowNodeWorker(f, false); });
53284                 }
53285                 else if (flags & 8) {
53286                     var antecedents = flow.antecedents;
53287                     if (antecedents === undefined || antecedents.length === 0) {
53288                         return false;
53289                     }
53290                     flow = antecedents[0];
53291                 }
53292                 else if (flags & 128) {
53293                     if (flow.clauseStart === flow.clauseEnd && isExhaustiveSwitchStatement(flow.switchStatement)) {
53294                         return false;
53295                     }
53296                     flow = flow.antecedent;
53297                 }
53298                 else if (flags & 1024) {
53299                     lastFlowNode = undefined;
53300                     var target = flow.target;
53301                     var saveAntecedents = target.antecedents;
53302                     target.antecedents = flow.antecedents;
53303                     var result = isReachableFlowNodeWorker(flow.antecedent, false);
53304                     target.antecedents = saveAntecedents;
53305                     return result;
53306                 }
53307                 else {
53308                     return !(flags & 1);
53309                 }
53310             }
53311         }
53312         function isPostSuperFlowNode(flow, noCacheCheck) {
53313             while (true) {
53314                 var flags = flow.flags;
53315                 if (flags & 4096) {
53316                     if (!noCacheCheck) {
53317                         var id = getFlowNodeId(flow);
53318                         var postSuper = flowNodePostSuper[id];
53319                         return postSuper !== undefined ? postSuper : (flowNodePostSuper[id] = isPostSuperFlowNode(flow, true));
53320                     }
53321                     noCacheCheck = false;
53322                 }
53323                 if (flags & (16 | 96 | 256 | 128)) {
53324                     flow = flow.antecedent;
53325                 }
53326                 else if (flags & 512) {
53327                     if (flow.node.expression.kind === 105) {
53328                         return true;
53329                     }
53330                     flow = flow.antecedent;
53331                 }
53332                 else if (flags & 4) {
53333                     return ts.every(flow.antecedents, function (f) { return isPostSuperFlowNode(f, false); });
53334                 }
53335                 else if (flags & 8) {
53336                     flow = flow.antecedents[0];
53337                 }
53338                 else if (flags & 1024) {
53339                     var target = flow.target;
53340                     var saveAntecedents = target.antecedents;
53341                     target.antecedents = flow.antecedents;
53342                     var result = isPostSuperFlowNode(flow.antecedent, false);
53343                     target.antecedents = saveAntecedents;
53344                     return result;
53345                 }
53346                 else {
53347                     return !!(flags & 1);
53348                 }
53349             }
53350         }
53351         function getFlowTypeOfReference(reference, declaredType, initialType, flowContainer, couldBeUninitialized) {
53352             if (initialType === void 0) { initialType = declaredType; }
53353             var key;
53354             var isKeySet = false;
53355             var flowDepth = 0;
53356             if (flowAnalysisDisabled) {
53357                 return errorType;
53358             }
53359             if (!reference.flowNode || !couldBeUninitialized && !(declaredType.flags & 536624127)) {
53360                 return declaredType;
53361             }
53362             flowInvocationCount++;
53363             var sharedFlowStart = sharedFlowCount;
53364             var evolvedType = getTypeFromFlowType(getTypeAtFlowNode(reference.flowNode));
53365             sharedFlowCount = sharedFlowStart;
53366             var resultType = ts.getObjectFlags(evolvedType) & 256 && isEvolvingArrayOperationTarget(reference) ? autoArrayType : finalizeEvolvingArrayType(evolvedType);
53367             if (resultType === unreachableNeverType || reference.parent && reference.parent.kind === 225 && getTypeWithFacts(resultType, 2097152).flags & 131072) {
53368                 return declaredType;
53369             }
53370             return resultType;
53371             function getOrSetCacheKey() {
53372                 if (isKeySet) {
53373                     return key;
53374                 }
53375                 isKeySet = true;
53376                 return key = getFlowCacheKey(reference, declaredType, initialType, flowContainer);
53377             }
53378             function getTypeAtFlowNode(flow) {
53379                 if (flowDepth === 2000) {
53380                     ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.instant("checkTypes", "getTypeAtFlowNode_DepthLimit", { flowId: flow.id });
53381                     flowAnalysisDisabled = true;
53382                     reportFlowControlError(reference);
53383                     return errorType;
53384                 }
53385                 flowDepth++;
53386                 var sharedFlow;
53387                 while (true) {
53388                     var flags = flow.flags;
53389                     if (flags & 4096) {
53390                         for (var i = sharedFlowStart; i < sharedFlowCount; i++) {
53391                             if (sharedFlowNodes[i] === flow) {
53392                                 flowDepth--;
53393                                 return sharedFlowTypes[i];
53394                             }
53395                         }
53396                         sharedFlow = flow;
53397                     }
53398                     var type = void 0;
53399                     if (flags & 16) {
53400                         type = getTypeAtFlowAssignment(flow);
53401                         if (!type) {
53402                             flow = flow.antecedent;
53403                             continue;
53404                         }
53405                     }
53406                     else if (flags & 512) {
53407                         type = getTypeAtFlowCall(flow);
53408                         if (!type) {
53409                             flow = flow.antecedent;
53410                             continue;
53411                         }
53412                     }
53413                     else if (flags & 96) {
53414                         type = getTypeAtFlowCondition(flow);
53415                     }
53416                     else if (flags & 128) {
53417                         type = getTypeAtSwitchClause(flow);
53418                     }
53419                     else if (flags & 12) {
53420                         if (flow.antecedents.length === 1) {
53421                             flow = flow.antecedents[0];
53422                             continue;
53423                         }
53424                         type = flags & 4 ?
53425                             getTypeAtFlowBranchLabel(flow) :
53426                             getTypeAtFlowLoopLabel(flow);
53427                     }
53428                     else if (flags & 256) {
53429                         type = getTypeAtFlowArrayMutation(flow);
53430                         if (!type) {
53431                             flow = flow.antecedent;
53432                             continue;
53433                         }
53434                     }
53435                     else if (flags & 1024) {
53436                         var target = flow.target;
53437                         var saveAntecedents = target.antecedents;
53438                         target.antecedents = flow.antecedents;
53439                         type = getTypeAtFlowNode(flow.antecedent);
53440                         target.antecedents = saveAntecedents;
53441                     }
53442                     else if (flags & 2) {
53443                         var container = flow.node;
53444                         if (container && container !== flowContainer &&
53445                             reference.kind !== 201 &&
53446                             reference.kind !== 202 &&
53447                             reference.kind !== 107) {
53448                             flow = container.flowNode;
53449                             continue;
53450                         }
53451                         type = initialType;
53452                     }
53453                     else {
53454                         type = convertAutoToAny(declaredType);
53455                     }
53456                     if (sharedFlow) {
53457                         sharedFlowNodes[sharedFlowCount] = sharedFlow;
53458                         sharedFlowTypes[sharedFlowCount] = type;
53459                         sharedFlowCount++;
53460                     }
53461                     flowDepth--;
53462                     return type;
53463                 }
53464             }
53465             function getInitialOrAssignedType(flow) {
53466                 var node = flow.node;
53467                 return getConstraintForLocation(node.kind === 249 || node.kind === 198 ?
53468                     getInitialType(node) :
53469                     getAssignedType(node), reference);
53470             }
53471             function getTypeAtFlowAssignment(flow) {
53472                 var node = flow.node;
53473                 if (isMatchingReference(reference, node)) {
53474                     if (!isReachableFlowNode(flow)) {
53475                         return unreachableNeverType;
53476                     }
53477                     if (ts.getAssignmentTargetKind(node) === 2) {
53478                         var flowType = getTypeAtFlowNode(flow.antecedent);
53479                         return createFlowType(getBaseTypeOfLiteralType(getTypeFromFlowType(flowType)), isIncomplete(flowType));
53480                     }
53481                     if (declaredType === autoType || declaredType === autoArrayType) {
53482                         if (isEmptyArrayAssignment(node)) {
53483                             return getEvolvingArrayType(neverType);
53484                         }
53485                         var assignedType = getWidenedLiteralType(getInitialOrAssignedType(flow));
53486                         return isTypeAssignableTo(assignedType, declaredType) ? assignedType : anyArrayType;
53487                     }
53488                     if (declaredType.flags & 1048576) {
53489                         return getAssignmentReducedType(declaredType, getInitialOrAssignedType(flow));
53490                     }
53491                     return declaredType;
53492                 }
53493                 if (containsMatchingReference(reference, node)) {
53494                     if (!isReachableFlowNode(flow)) {
53495                         return unreachableNeverType;
53496                     }
53497                     if (ts.isVariableDeclaration(node) && (ts.isInJSFile(node) || ts.isVarConst(node))) {
53498                         var init = ts.getDeclaredExpandoInitializer(node);
53499                         if (init && (init.kind === 208 || init.kind === 209)) {
53500                             return getTypeAtFlowNode(flow.antecedent);
53501                         }
53502                     }
53503                     return declaredType;
53504                 }
53505                 if (ts.isVariableDeclaration(node) && node.parent.parent.kind === 238 && isMatchingReference(reference, node.parent.parent.expression)) {
53506                     return getNonNullableTypeIfNeeded(getTypeFromFlowType(getTypeAtFlowNode(flow.antecedent)));
53507                 }
53508                 return undefined;
53509             }
53510             function narrowTypeByAssertion(type, expr) {
53511                 var node = ts.skipParentheses(expr);
53512                 if (node.kind === 94) {
53513                     return unreachableNeverType;
53514                 }
53515                 if (node.kind === 216) {
53516                     if (node.operatorToken.kind === 55) {
53517                         return narrowTypeByAssertion(narrowTypeByAssertion(type, node.left), node.right);
53518                     }
53519                     if (node.operatorToken.kind === 56) {
53520                         return getUnionType([narrowTypeByAssertion(type, node.left), narrowTypeByAssertion(type, node.right)]);
53521                     }
53522                 }
53523                 return narrowType(type, node, true);
53524             }
53525             function getTypeAtFlowCall(flow) {
53526                 var signature = getEffectsSignature(flow.node);
53527                 if (signature) {
53528                     var predicate = getTypePredicateOfSignature(signature);
53529                     if (predicate && (predicate.kind === 2 || predicate.kind === 3)) {
53530                         var flowType = getTypeAtFlowNode(flow.antecedent);
53531                         var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType));
53532                         var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, true) :
53533                             predicate.kind === 3 && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) :
53534                                 type;
53535                         return narrowedType === type ? flowType : createFlowType(narrowedType, isIncomplete(flowType));
53536                     }
53537                     if (getReturnTypeOfSignature(signature).flags & 131072) {
53538                         return unreachableNeverType;
53539                     }
53540                 }
53541                 return undefined;
53542             }
53543             function getTypeAtFlowArrayMutation(flow) {
53544                 if (declaredType === autoType || declaredType === autoArrayType) {
53545                     var node = flow.node;
53546                     var expr = node.kind === 203 ?
53547                         node.expression.expression :
53548                         node.left.expression;
53549                     if (isMatchingReference(reference, getReferenceCandidate(expr))) {
53550                         var flowType = getTypeAtFlowNode(flow.antecedent);
53551                         var type = getTypeFromFlowType(flowType);
53552                         if (ts.getObjectFlags(type) & 256) {
53553                             var evolvedType_1 = type;
53554                             if (node.kind === 203) {
53555                                 for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) {
53556                                     var arg = _a[_i];
53557                                     evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, arg);
53558                                 }
53559                             }
53560                             else {
53561                                 var indexType = getContextFreeTypeOfExpression(node.left.argumentExpression);
53562                                 if (isTypeAssignableToKind(indexType, 296)) {
53563                                     evolvedType_1 = addEvolvingArrayElementType(evolvedType_1, node.right);
53564                                 }
53565                             }
53566                             return evolvedType_1 === type ? flowType : createFlowType(evolvedType_1, isIncomplete(flowType));
53567                         }
53568                         return flowType;
53569                     }
53570                 }
53571                 return undefined;
53572             }
53573             function getTypeAtFlowCondition(flow) {
53574                 var flowType = getTypeAtFlowNode(flow.antecedent);
53575                 var type = getTypeFromFlowType(flowType);
53576                 if (type.flags & 131072) {
53577                     return flowType;
53578                 }
53579                 var assumeTrue = (flow.flags & 32) !== 0;
53580                 var nonEvolvingType = finalizeEvolvingArrayType(type);
53581                 var narrowedType = narrowType(nonEvolvingType, flow.node, assumeTrue);
53582                 if (narrowedType === nonEvolvingType) {
53583                     return flowType;
53584                 }
53585                 return createFlowType(narrowedType, isIncomplete(flowType));
53586             }
53587             function getTypeAtSwitchClause(flow) {
53588                 var expr = flow.switchStatement.expression;
53589                 var flowType = getTypeAtFlowNode(flow.antecedent);
53590                 var type = getTypeFromFlowType(flowType);
53591                 if (isMatchingReference(reference, expr)) {
53592                     type = narrowTypeBySwitchOnDiscriminant(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
53593                 }
53594                 else if (expr.kind === 211 && isMatchingReference(reference, expr.expression)) {
53595                     type = narrowBySwitchOnTypeOf(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd);
53596                 }
53597                 else {
53598                     if (strictNullChecks) {
53599                         if (optionalChainContainsReference(expr, reference)) {
53600                             type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & (32768 | 131072)); });
53601                         }
53602                         else if (expr.kind === 211 && optionalChainContainsReference(expr.expression, reference)) {
53603                             type = narrowTypeBySwitchOptionalChainContainment(type, flow.switchStatement, flow.clauseStart, flow.clauseEnd, function (t) { return !(t.flags & 131072 || t.flags & 128 && t.value === "undefined"); });
53604                         }
53605                     }
53606                     if (isMatchingReferenceDiscriminant(expr, type)) {
53607                         type = narrowTypeByDiscriminant(type, expr, function (t) { return narrowTypeBySwitchOnDiscriminant(t, flow.switchStatement, flow.clauseStart, flow.clauseEnd); });
53608                     }
53609                 }
53610                 return createFlowType(type, isIncomplete(flowType));
53611             }
53612             function getTypeAtFlowBranchLabel(flow) {
53613                 var antecedentTypes = [];
53614                 var subtypeReduction = false;
53615                 var seenIncomplete = false;
53616                 var bypassFlow;
53617                 for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) {
53618                     var antecedent = _a[_i];
53619                     if (!bypassFlow && antecedent.flags & 128 && antecedent.clauseStart === antecedent.clauseEnd) {
53620                         bypassFlow = antecedent;
53621                         continue;
53622                     }
53623                     var flowType = getTypeAtFlowNode(antecedent);
53624                     var type = getTypeFromFlowType(flowType);
53625                     if (type === declaredType && declaredType === initialType) {
53626                         return type;
53627                     }
53628                     ts.pushIfUnique(antecedentTypes, type);
53629                     if (!isTypeSubsetOf(type, declaredType)) {
53630                         subtypeReduction = true;
53631                     }
53632                     if (isIncomplete(flowType)) {
53633                         seenIncomplete = true;
53634                     }
53635                 }
53636                 if (bypassFlow) {
53637                     var flowType = getTypeAtFlowNode(bypassFlow);
53638                     var type = getTypeFromFlowType(flowType);
53639                     if (!ts.contains(antecedentTypes, type) && !isExhaustiveSwitchStatement(bypassFlow.switchStatement)) {
53640                         if (type === declaredType && declaredType === initialType) {
53641                             return type;
53642                         }
53643                         antecedentTypes.push(type);
53644                         if (!isTypeSubsetOf(type, declaredType)) {
53645                             subtypeReduction = true;
53646                         }
53647                         if (isIncomplete(flowType)) {
53648                             seenIncomplete = true;
53649                         }
53650                     }
53651                 }
53652                 return createFlowType(getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 : 1), seenIncomplete);
53653             }
53654             function getTypeAtFlowLoopLabel(flow) {
53655                 var id = getFlowNodeId(flow);
53656                 var cache = flowLoopCaches[id] || (flowLoopCaches[id] = new ts.Map());
53657                 var key = getOrSetCacheKey();
53658                 if (!key) {
53659                     return declaredType;
53660                 }
53661                 var cached = cache.get(key);
53662                 if (cached) {
53663                     return cached;
53664                 }
53665                 for (var i = flowLoopStart; i < flowLoopCount; i++) {
53666                     if (flowLoopNodes[i] === flow && flowLoopKeys[i] === key && flowLoopTypes[i].length) {
53667                         return createFlowType(getUnionOrEvolvingArrayType(flowLoopTypes[i], 1), true);
53668                     }
53669                 }
53670                 var antecedentTypes = [];
53671                 var subtypeReduction = false;
53672                 var firstAntecedentType;
53673                 for (var _i = 0, _a = flow.antecedents; _i < _a.length; _i++) {
53674                     var antecedent = _a[_i];
53675                     var flowType = void 0;
53676                     if (!firstAntecedentType) {
53677                         flowType = firstAntecedentType = getTypeAtFlowNode(antecedent);
53678                     }
53679                     else {
53680                         flowLoopNodes[flowLoopCount] = flow;
53681                         flowLoopKeys[flowLoopCount] = key;
53682                         flowLoopTypes[flowLoopCount] = antecedentTypes;
53683                         flowLoopCount++;
53684                         var saveFlowTypeCache = flowTypeCache;
53685                         flowTypeCache = undefined;
53686                         flowType = getTypeAtFlowNode(antecedent);
53687                         flowTypeCache = saveFlowTypeCache;
53688                         flowLoopCount--;
53689                         var cached_1 = cache.get(key);
53690                         if (cached_1) {
53691                             return cached_1;
53692                         }
53693                     }
53694                     var type = getTypeFromFlowType(flowType);
53695                     ts.pushIfUnique(antecedentTypes, type);
53696                     if (!isTypeSubsetOf(type, declaredType)) {
53697                         subtypeReduction = true;
53698                     }
53699                     if (type === declaredType) {
53700                         break;
53701                     }
53702                 }
53703                 var result = getUnionOrEvolvingArrayType(antecedentTypes, subtypeReduction ? 2 : 1);
53704                 if (isIncomplete(firstAntecedentType)) {
53705                     return createFlowType(result, true);
53706                 }
53707                 cache.set(key, result);
53708                 return result;
53709             }
53710             function getUnionOrEvolvingArrayType(types, subtypeReduction) {
53711                 if (isEvolvingArrayTypeList(types)) {
53712                     return getEvolvingArrayType(getUnionType(ts.map(types, getElementTypeOfEvolvingArrayType)));
53713                 }
53714                 var result = getUnionType(ts.sameMap(types, finalizeEvolvingArrayType), subtypeReduction);
53715                 if (result !== declaredType && result.flags & declaredType.flags & 1048576 && ts.arraysEqual(result.types, declaredType.types)) {
53716                     return declaredType;
53717                 }
53718                 return result;
53719             }
53720             function isMatchingReferenceDiscriminant(expr, computedType) {
53721                 var type = declaredType.flags & 1048576 ? declaredType : computedType;
53722                 if (!(type.flags & 1048576) || !ts.isAccessExpression(expr)) {
53723                     return false;
53724                 }
53725                 var name = getAccessedPropertyName(expr);
53726                 if (name === undefined) {
53727                     return false;
53728                 }
53729                 return isMatchingReference(reference, expr.expression) && isDiscriminantProperty(type, name);
53730             }
53731             function narrowTypeByDiscriminant(type, access, narrowType) {
53732                 var propName = getAccessedPropertyName(access);
53733                 if (propName === undefined) {
53734                     return type;
53735                 }
53736                 var includesNullable = strictNullChecks && maybeTypeOfKind(type, 98304);
53737                 var removeNullable = includesNullable && ts.isOptionalChain(access);
53738                 var propType = getTypeOfPropertyOfType(removeNullable ? getTypeWithFacts(type, 2097152) : type, propName);
53739                 if (!propType) {
53740                     return type;
53741                 }
53742                 propType = removeNullable ? getOptionalType(propType) : propType;
53743                 var narrowedPropType = narrowType(propType);
53744                 return filterType(type, function (t) {
53745                     var discriminantType = getTypeOfPropertyOrIndexSignature(t, propName);
53746                     return !(discriminantType.flags & 131072) && isTypeComparableTo(discriminantType, narrowedPropType);
53747                 });
53748             }
53749             function narrowTypeByTruthiness(type, expr, assumeTrue) {
53750                 if (isMatchingReference(reference, expr)) {
53751                     return getTypeWithFacts(type, assumeTrue ? 4194304 : 8388608);
53752                 }
53753                 if (strictNullChecks && assumeTrue && optionalChainContainsReference(expr, reference)) {
53754                     type = getTypeWithFacts(type, 2097152);
53755                 }
53756                 if (isMatchingReferenceDiscriminant(expr, type)) {
53757                     return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumeTrue ? 4194304 : 8388608); });
53758                 }
53759                 return type;
53760             }
53761             function isTypePresencePossible(type, propName, assumeTrue) {
53762                 if (getIndexInfoOfType(type, 0)) {
53763                     return true;
53764                 }
53765                 var prop = getPropertyOfType(type, propName);
53766                 if (prop) {
53767                     return prop.flags & 16777216 ? true : assumeTrue;
53768                 }
53769                 return !assumeTrue;
53770             }
53771             function narrowByInKeyword(type, literal, assumeTrue) {
53772                 if (type.flags & (1048576 | 524288)
53773                     || isThisTypeParameter(type)
53774                     || type.flags & 2097152 && ts.every(type.types, function (t) { return t.symbol !== globalThisSymbol; })) {
53775                     var propName_1 = ts.escapeLeadingUnderscores(literal.text);
53776                     return filterType(type, function (t) { return isTypePresencePossible(t, propName_1, assumeTrue); });
53777                 }
53778                 return type;
53779             }
53780             function narrowTypeByBinaryExpression(type, expr, assumeTrue) {
53781                 switch (expr.operatorToken.kind) {
53782                     case 62:
53783                     case 74:
53784                     case 75:
53785                     case 76:
53786                         return narrowTypeByTruthiness(narrowType(type, expr.right, assumeTrue), expr.left, assumeTrue);
53787                     case 34:
53788                     case 35:
53789                     case 36:
53790                     case 37:
53791                         var operator_1 = expr.operatorToken.kind;
53792                         var left_1 = getReferenceCandidate(expr.left);
53793                         var right_1 = getReferenceCandidate(expr.right);
53794                         if (left_1.kind === 211 && ts.isStringLiteralLike(right_1)) {
53795                             return narrowTypeByTypeof(type, left_1, operator_1, right_1, assumeTrue);
53796                         }
53797                         if (right_1.kind === 211 && ts.isStringLiteralLike(left_1)) {
53798                             return narrowTypeByTypeof(type, right_1, operator_1, left_1, assumeTrue);
53799                         }
53800                         if (isMatchingReference(reference, left_1)) {
53801                             return narrowTypeByEquality(type, operator_1, right_1, assumeTrue);
53802                         }
53803                         if (isMatchingReference(reference, right_1)) {
53804                             return narrowTypeByEquality(type, operator_1, left_1, assumeTrue);
53805                         }
53806                         if (strictNullChecks) {
53807                             if (optionalChainContainsReference(left_1, reference)) {
53808                                 type = narrowTypeByOptionalChainContainment(type, operator_1, right_1, assumeTrue);
53809                             }
53810                             else if (optionalChainContainsReference(right_1, reference)) {
53811                                 type = narrowTypeByOptionalChainContainment(type, operator_1, left_1, assumeTrue);
53812                             }
53813                         }
53814                         if (isMatchingReferenceDiscriminant(left_1, type)) {
53815                             return narrowTypeByDiscriminant(type, left_1, function (t) { return narrowTypeByEquality(t, operator_1, right_1, assumeTrue); });
53816                         }
53817                         if (isMatchingReferenceDiscriminant(right_1, type)) {
53818                             return narrowTypeByDiscriminant(type, right_1, function (t) { return narrowTypeByEquality(t, operator_1, left_1, assumeTrue); });
53819                         }
53820                         if (isMatchingConstructorReference(left_1)) {
53821                             return narrowTypeByConstructor(type, operator_1, right_1, assumeTrue);
53822                         }
53823                         if (isMatchingConstructorReference(right_1)) {
53824                             return narrowTypeByConstructor(type, operator_1, left_1, assumeTrue);
53825                         }
53826                         break;
53827                     case 101:
53828                         return narrowTypeByInstanceof(type, expr, assumeTrue);
53829                     case 100:
53830                         var target = getReferenceCandidate(expr.right);
53831                         if (ts.isStringLiteralLike(expr.left) && isMatchingReference(reference, target)) {
53832                             return narrowByInKeyword(type, expr.left, assumeTrue);
53833                         }
53834                         break;
53835                     case 27:
53836                         return narrowType(type, expr.right, assumeTrue);
53837                 }
53838                 return type;
53839             }
53840             function narrowTypeByOptionalChainContainment(type, operator, value, assumeTrue) {
53841                 var equalsOperator = operator === 34 || operator === 36;
53842                 var nullableFlags = operator === 34 || operator === 35 ? 98304 : 32768;
53843                 var valueType = getTypeOfExpression(value);
53844                 var removeNullable = equalsOperator !== assumeTrue && everyType(valueType, function (t) { return !!(t.flags & nullableFlags); }) ||
53845                     equalsOperator === assumeTrue && everyType(valueType, function (t) { return !(t.flags & (3 | nullableFlags)); });
53846                 return removeNullable ? getTypeWithFacts(type, 2097152) : type;
53847             }
53848             function narrowTypeByEquality(type, operator, value, assumeTrue) {
53849                 if (type.flags & 1) {
53850                     return type;
53851                 }
53852                 if (operator === 35 || operator === 37) {
53853                     assumeTrue = !assumeTrue;
53854                 }
53855                 var valueType = getTypeOfExpression(value);
53856                 if ((type.flags & 2) && assumeTrue && (operator === 36 || operator === 37)) {
53857                     if (valueType.flags & (131068 | 67108864)) {
53858                         return valueType;
53859                     }
53860                     if (valueType.flags & 524288) {
53861                         return nonPrimitiveType;
53862                     }
53863                     return type;
53864                 }
53865                 if (valueType.flags & 98304) {
53866                     if (!strictNullChecks) {
53867                         return type;
53868                     }
53869                     var doubleEquals = operator === 34 || operator === 35;
53870                     var facts = doubleEquals ?
53871                         assumeTrue ? 262144 : 2097152 :
53872                         valueType.flags & 65536 ?
53873                             assumeTrue ? 131072 : 1048576 :
53874                             assumeTrue ? 65536 : 524288;
53875                     return getTypeWithFacts(type, facts);
53876                 }
53877                 if (assumeTrue) {
53878                     var filterFn = operator === 34 ?
53879                         (function (t) { return areTypesComparable(t, valueType) || isCoercibleUnderDoubleEquals(t, valueType); }) :
53880                         function (t) { return areTypesComparable(t, valueType); };
53881                     return replacePrimitivesWithLiterals(filterType(type, filterFn), valueType);
53882                 }
53883                 if (isUnitType(valueType)) {
53884                     var regularType_1 = getRegularTypeOfLiteralType(valueType);
53885                     return filterType(type, function (t) { return isUnitType(t) ? !areTypesComparable(t, valueType) : getRegularTypeOfLiteralType(t) !== regularType_1; });
53886                 }
53887                 return type;
53888             }
53889             function narrowTypeByTypeof(type, typeOfExpr, operator, literal, assumeTrue) {
53890                 if (operator === 35 || operator === 37) {
53891                     assumeTrue = !assumeTrue;
53892                 }
53893                 var target = getReferenceCandidate(typeOfExpr.expression);
53894                 if (!isMatchingReference(reference, target)) {
53895                     if (strictNullChecks && optionalChainContainsReference(target, reference) && assumeTrue === (literal.text !== "undefined")) {
53896                         return getTypeWithFacts(type, 2097152);
53897                     }
53898                     return type;
53899                 }
53900                 if (type.flags & 1 && literal.text === "function") {
53901                     return type;
53902                 }
53903                 if (assumeTrue && type.flags & 2 && literal.text === "object") {
53904                     if (typeOfExpr.parent.parent.kind === 216) {
53905                         var expr = typeOfExpr.parent.parent;
53906                         if (expr.operatorToken.kind === 55 && expr.right === typeOfExpr.parent && containsTruthyCheck(reference, expr.left)) {
53907                             return nonPrimitiveType;
53908                         }
53909                     }
53910                     return getUnionType([nonPrimitiveType, nullType]);
53911                 }
53912                 var facts = assumeTrue ?
53913                     typeofEQFacts.get(literal.text) || 128 :
53914                     typeofNEFacts.get(literal.text) || 32768;
53915                 var impliedType = getImpliedTypeFromTypeofGuard(type, literal.text);
53916                 return getTypeWithFacts(assumeTrue && impliedType ? mapType(type, narrowUnionMemberByTypeof(impliedType)) : type, facts);
53917             }
53918             function narrowTypeBySwitchOptionalChainContainment(type, switchStatement, clauseStart, clauseEnd, clauseCheck) {
53919                 var everyClauseChecks = clauseStart !== clauseEnd && ts.every(getSwitchClauseTypes(switchStatement).slice(clauseStart, clauseEnd), clauseCheck);
53920                 return everyClauseChecks ? getTypeWithFacts(type, 2097152) : type;
53921             }
53922             function narrowTypeBySwitchOnDiscriminant(type, switchStatement, clauseStart, clauseEnd) {
53923                 var switchTypes = getSwitchClauseTypes(switchStatement);
53924                 if (!switchTypes.length) {
53925                     return type;
53926                 }
53927                 var clauseTypes = switchTypes.slice(clauseStart, clauseEnd);
53928                 var hasDefaultClause = clauseStart === clauseEnd || ts.contains(clauseTypes, neverType);
53929                 if ((type.flags & 2) && !hasDefaultClause) {
53930                     var groundClauseTypes = void 0;
53931                     for (var i = 0; i < clauseTypes.length; i += 1) {
53932                         var t = clauseTypes[i];
53933                         if (t.flags & (131068 | 67108864)) {
53934                             if (groundClauseTypes !== undefined) {
53935                                 groundClauseTypes.push(t);
53936                             }
53937                         }
53938                         else if (t.flags & 524288) {
53939                             if (groundClauseTypes === undefined) {
53940                                 groundClauseTypes = clauseTypes.slice(0, i);
53941                             }
53942                             groundClauseTypes.push(nonPrimitiveType);
53943                         }
53944                         else {
53945                             return type;
53946                         }
53947                     }
53948                     return getUnionType(groundClauseTypes === undefined ? clauseTypes : groundClauseTypes);
53949                 }
53950                 var discriminantType = getUnionType(clauseTypes);
53951                 var caseType = discriminantType.flags & 131072 ? neverType :
53952                     replacePrimitivesWithLiterals(filterType(type, function (t) { return areTypesComparable(discriminantType, t); }), discriminantType);
53953                 if (!hasDefaultClause) {
53954                     return caseType;
53955                 }
53956                 var defaultType = filterType(type, function (t) { return !(isUnitType(t) && ts.contains(switchTypes, getRegularTypeOfLiteralType(t))); });
53957                 return caseType.flags & 131072 ? defaultType : getUnionType([caseType, defaultType]);
53958             }
53959             function getImpliedTypeFromTypeofGuard(type, text) {
53960                 switch (text) {
53961                     case "function":
53962                         return type.flags & 1 ? type : globalFunctionType;
53963                     case "object":
53964                         return type.flags & 2 ? getUnionType([nonPrimitiveType, nullType]) : type;
53965                     default:
53966                         return typeofTypesByName.get(text);
53967                 }
53968             }
53969             function narrowUnionMemberByTypeof(candidate) {
53970                 return function (type) {
53971                     if (isTypeSubtypeOf(type, candidate)) {
53972                         return type;
53973                     }
53974                     if (isTypeSubtypeOf(candidate, type)) {
53975                         return candidate;
53976                     }
53977                     if (type.flags & 465829888) {
53978                         var constraint = getBaseConstraintOfType(type) || anyType;
53979                         if (isTypeSubtypeOf(candidate, constraint)) {
53980                             return getIntersectionType([type, candidate]);
53981                         }
53982                     }
53983                     return type;
53984                 };
53985             }
53986             function narrowBySwitchOnTypeOf(type, switchStatement, clauseStart, clauseEnd) {
53987                 var switchWitnesses = getSwitchClauseTypeOfWitnesses(switchStatement, true);
53988                 if (!switchWitnesses.length) {
53989                     return type;
53990                 }
53991                 var defaultCaseLocation = ts.findIndex(switchWitnesses, function (elem) { return elem === undefined; });
53992                 var hasDefaultClause = clauseStart === clauseEnd || (defaultCaseLocation >= clauseStart && defaultCaseLocation < clauseEnd);
53993                 var clauseWitnesses;
53994                 var switchFacts;
53995                 if (defaultCaseLocation > -1) {
53996                     var witnesses = switchWitnesses.filter(function (witness) { return witness !== undefined; });
53997                     var fixedClauseStart = defaultCaseLocation < clauseStart ? clauseStart - 1 : clauseStart;
53998                     var fixedClauseEnd = defaultCaseLocation < clauseEnd ? clauseEnd - 1 : clauseEnd;
53999                     clauseWitnesses = witnesses.slice(fixedClauseStart, fixedClauseEnd);
54000                     switchFacts = getFactsFromTypeofSwitch(fixedClauseStart, fixedClauseEnd, witnesses, hasDefaultClause);
54001                 }
54002                 else {
54003                     clauseWitnesses = switchWitnesses.slice(clauseStart, clauseEnd);
54004                     switchFacts = getFactsFromTypeofSwitch(clauseStart, clauseEnd, switchWitnesses, hasDefaultClause);
54005                 }
54006                 if (hasDefaultClause) {
54007                     return filterType(type, function (t) { return (getTypeFacts(t) & switchFacts) === switchFacts; });
54008                 }
54009                 var impliedType = getTypeWithFacts(getUnionType(clauseWitnesses.map(function (text) { return getImpliedTypeFromTypeofGuard(type, text) || type; })), switchFacts);
54010                 return getTypeWithFacts(mapType(type, narrowUnionMemberByTypeof(impliedType)), switchFacts);
54011             }
54012             function isMatchingConstructorReference(expr) {
54013                 return (ts.isPropertyAccessExpression(expr) && ts.idText(expr.name) === "constructor" ||
54014                     ts.isElementAccessExpression(expr) && ts.isStringLiteralLike(expr.argumentExpression) && expr.argumentExpression.text === "constructor") &&
54015                     isMatchingReference(reference, expr.expression);
54016             }
54017             function narrowTypeByConstructor(type, operator, identifier, assumeTrue) {
54018                 if (assumeTrue ? (operator !== 34 && operator !== 36) : (operator !== 35 && operator !== 37)) {
54019                     return type;
54020                 }
54021                 var identifierType = getTypeOfExpression(identifier);
54022                 if (!isFunctionType(identifierType) && !isConstructorType(identifierType)) {
54023                     return type;
54024                 }
54025                 var prototypeProperty = getPropertyOfType(identifierType, "prototype");
54026                 if (!prototypeProperty) {
54027                     return type;
54028                 }
54029                 var prototypeType = getTypeOfSymbol(prototypeProperty);
54030                 var candidate = !isTypeAny(prototypeType) ? prototypeType : undefined;
54031                 if (!candidate || candidate === globalObjectType || candidate === globalFunctionType) {
54032                     return type;
54033                 }
54034                 if (isTypeAny(type)) {
54035                     return candidate;
54036                 }
54037                 return filterType(type, function (t) { return isConstructedBy(t, candidate); });
54038                 function isConstructedBy(source, target) {
54039                     if (source.flags & 524288 && ts.getObjectFlags(source) & 1 ||
54040                         target.flags & 524288 && ts.getObjectFlags(target) & 1) {
54041                         return source.symbol === target.symbol;
54042                     }
54043                     return isTypeSubtypeOf(source, target);
54044                 }
54045             }
54046             function narrowTypeByInstanceof(type, expr, assumeTrue) {
54047                 var left = getReferenceCandidate(expr.left);
54048                 if (!isMatchingReference(reference, left)) {
54049                     if (assumeTrue && strictNullChecks && optionalChainContainsReference(left, reference)) {
54050                         return getTypeWithFacts(type, 2097152);
54051                     }
54052                     return type;
54053                 }
54054                 var rightType = getTypeOfExpression(expr.right);
54055                 if (!isTypeDerivedFrom(rightType, globalFunctionType)) {
54056                     return type;
54057                 }
54058                 var targetType;
54059                 var prototypeProperty = getPropertyOfType(rightType, "prototype");
54060                 if (prototypeProperty) {
54061                     var prototypePropertyType = getTypeOfSymbol(prototypeProperty);
54062                     if (!isTypeAny(prototypePropertyType)) {
54063                         targetType = prototypePropertyType;
54064                     }
54065                 }
54066                 if (isTypeAny(type) && (targetType === globalObjectType || targetType === globalFunctionType)) {
54067                     return type;
54068                 }
54069                 if (!targetType) {
54070                     var constructSignatures = getSignaturesOfType(rightType, 1);
54071                     targetType = constructSignatures.length ?
54072                         getUnionType(ts.map(constructSignatures, function (signature) { return getReturnTypeOfSignature(getErasedSignature(signature)); })) :
54073                         emptyObjectType;
54074                 }
54075                 if (!assumeTrue && rightType.flags & 1048576) {
54076                     var nonConstructorTypeInUnion = ts.find(rightType.types, function (t) { return !isConstructorType(t); });
54077                     if (!nonConstructorTypeInUnion)
54078                         return type;
54079                 }
54080                 return getNarrowedType(type, targetType, assumeTrue, isTypeDerivedFrom);
54081             }
54082             function getNarrowedType(type, candidate, assumeTrue, isRelated) {
54083                 if (!assumeTrue) {
54084                     return filterType(type, function (t) { return !isRelated(t, candidate); });
54085                 }
54086                 if (type.flags & 1048576) {
54087                     var assignableType = filterType(type, function (t) { return isRelated(t, candidate); });
54088                     if (!(assignableType.flags & 131072)) {
54089                         return assignableType;
54090                     }
54091                 }
54092                 return isTypeSubtypeOf(candidate, type) ? candidate :
54093                     isTypeAssignableTo(type, candidate) ? type :
54094                         isTypeAssignableTo(candidate, type) ? candidate :
54095                             getIntersectionType([type, candidate]);
54096             }
54097             function narrowTypeByCallExpression(type, callExpression, assumeTrue) {
54098                 if (hasMatchingArgument(callExpression, reference)) {
54099                     var signature = assumeTrue || !ts.isCallChain(callExpression) ? getEffectsSignature(callExpression) : undefined;
54100                     var predicate = signature && getTypePredicateOfSignature(signature);
54101                     if (predicate && (predicate.kind === 0 || predicate.kind === 1)) {
54102                         return narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue);
54103                     }
54104                 }
54105                 return type;
54106             }
54107             function narrowTypeByTypePredicate(type, predicate, callExpression, assumeTrue) {
54108                 if (predicate.type && !(isTypeAny(type) && (predicate.type === globalObjectType || predicate.type === globalFunctionType))) {
54109                     var predicateArgument = getTypePredicateArgument(predicate, callExpression);
54110                     if (predicateArgument) {
54111                         if (isMatchingReference(reference, predicateArgument)) {
54112                             return getNarrowedType(type, predicate.type, assumeTrue, isTypeSubtypeOf);
54113                         }
54114                         if (strictNullChecks && assumeTrue && optionalChainContainsReference(predicateArgument, reference) &&
54115                             !(getTypeFacts(predicate.type) & 65536)) {
54116                             type = getTypeWithFacts(type, 2097152);
54117                         }
54118                         if (isMatchingReferenceDiscriminant(predicateArgument, type)) {
54119                             return narrowTypeByDiscriminant(type, predicateArgument, function (t) { return getNarrowedType(t, predicate.type, assumeTrue, isTypeSubtypeOf); });
54120                         }
54121                     }
54122                 }
54123                 return type;
54124             }
54125             function narrowType(type, expr, assumeTrue) {
54126                 if (ts.isExpressionOfOptionalChainRoot(expr) ||
54127                     ts.isBinaryExpression(expr.parent) && expr.parent.operatorToken.kind === 60 && expr.parent.left === expr) {
54128                     return narrowTypeByOptionality(type, expr, assumeTrue);
54129                 }
54130                 switch (expr.kind) {
54131                     case 78:
54132                     case 107:
54133                     case 105:
54134                     case 201:
54135                     case 202:
54136                         return narrowTypeByTruthiness(type, expr, assumeTrue);
54137                     case 203:
54138                         return narrowTypeByCallExpression(type, expr, assumeTrue);
54139                     case 207:
54140                     case 225:
54141                         return narrowType(type, expr.expression, assumeTrue);
54142                     case 216:
54143                         return narrowTypeByBinaryExpression(type, expr, assumeTrue);
54144                     case 214:
54145                         if (expr.operator === 53) {
54146                             return narrowType(type, expr.operand, !assumeTrue);
54147                         }
54148                         break;
54149                 }
54150                 return type;
54151             }
54152             function narrowTypeByOptionality(type, expr, assumePresent) {
54153                 if (isMatchingReference(reference, expr)) {
54154                     return getTypeWithFacts(type, assumePresent ? 2097152 : 262144);
54155                 }
54156                 if (isMatchingReferenceDiscriminant(expr, type)) {
54157                     return narrowTypeByDiscriminant(type, expr, function (t) { return getTypeWithFacts(t, assumePresent ? 2097152 : 262144); });
54158                 }
54159                 return type;
54160             }
54161         }
54162         function getTypeOfSymbolAtLocation(symbol, location) {
54163             symbol = symbol.exportSymbol || symbol;
54164             if (location.kind === 78) {
54165                 if (ts.isRightSideOfQualifiedNameOrPropertyAccess(location)) {
54166                     location = location.parent;
54167                 }
54168                 if (ts.isExpressionNode(location) && !ts.isAssignmentTarget(location)) {
54169                     var type = getTypeOfExpression(location);
54170                     if (getExportSymbolOfValueSymbolIfExported(getNodeLinks(location).resolvedSymbol) === symbol) {
54171                         return type;
54172                     }
54173                 }
54174             }
54175             return getTypeOfSymbol(symbol);
54176         }
54177         function getControlFlowContainer(node) {
54178             return ts.findAncestor(node.parent, function (node) {
54179                 return ts.isFunctionLike(node) && !ts.getImmediatelyInvokedFunctionExpression(node) ||
54180                     node.kind === 257 ||
54181                     node.kind === 297 ||
54182                     node.kind === 163;
54183             });
54184         }
54185         function isParameterAssigned(symbol) {
54186             var func = ts.getRootDeclaration(symbol.valueDeclaration).parent;
54187             var links = getNodeLinks(func);
54188             if (!(links.flags & 8388608)) {
54189                 links.flags |= 8388608;
54190                 if (!hasParentWithAssignmentsMarked(func)) {
54191                     markParameterAssignments(func);
54192                 }
54193             }
54194             return symbol.isAssigned || false;
54195         }
54196         function hasParentWithAssignmentsMarked(node) {
54197             return !!ts.findAncestor(node.parent, function (node) { return ts.isFunctionLike(node) && !!(getNodeLinks(node).flags & 8388608); });
54198         }
54199         function markParameterAssignments(node) {
54200             if (node.kind === 78) {
54201                 if (ts.isAssignmentTarget(node)) {
54202                     var symbol = getResolvedSymbol(node);
54203                     if (symbol.valueDeclaration && ts.getRootDeclaration(symbol.valueDeclaration).kind === 160) {
54204                         symbol.isAssigned = true;
54205                     }
54206                 }
54207             }
54208             else {
54209                 ts.forEachChild(node, markParameterAssignments);
54210             }
54211         }
54212         function isConstVariable(symbol) {
54213             return symbol.flags & 3 && (getDeclarationNodeFlagsFromSymbol(symbol) & 2) !== 0 && getTypeOfSymbol(symbol) !== autoArrayType;
54214         }
54215         function removeOptionalityFromDeclaredType(declaredType, declaration) {
54216             if (pushTypeResolution(declaration.symbol, 2)) {
54217                 var annotationIncludesUndefined = strictNullChecks &&
54218                     declaration.kind === 160 &&
54219                     declaration.initializer &&
54220                     getFalsyFlags(declaredType) & 32768 &&
54221                     !(getFalsyFlags(checkExpression(declaration.initializer)) & 32768);
54222                 popTypeResolution();
54223                 return annotationIncludesUndefined ? getTypeWithFacts(declaredType, 524288) : declaredType;
54224             }
54225             else {
54226                 reportCircularityError(declaration.symbol);
54227                 return declaredType;
54228             }
54229         }
54230         function isConstraintPosition(node) {
54231             var parent = node.parent;
54232             return parent.kind === 201 ||
54233                 parent.kind === 203 && parent.expression === node ||
54234                 parent.kind === 202 && parent.expression === node ||
54235                 parent.kind === 198 && parent.name === node && !!parent.initializer;
54236         }
54237         function typeHasNullableConstraint(type) {
54238             return type.flags & 58982400 && maybeTypeOfKind(getBaseConstraintOfType(type) || unknownType, 98304);
54239         }
54240         function getConstraintForLocation(type, node) {
54241             if (type && isConstraintPosition(node) && forEachType(type, typeHasNullableConstraint)) {
54242                 return mapType(getWidenedType(type), getBaseConstraintOrType);
54243             }
54244             return type;
54245         }
54246         function isExportOrExportExpression(location) {
54247             return !!ts.findAncestor(location, function (e) { return e.parent && ts.isExportAssignment(e.parent) && e.parent.expression === e && ts.isEntityNameExpression(e); });
54248         }
54249         function markAliasReferenced(symbol, location) {
54250             if (isNonLocalAlias(symbol, 111551) && !isInTypeQuery(location) && !getTypeOnlyAliasDeclaration(symbol)) {
54251                 var target = resolveAlias(symbol);
54252                 if (target.flags & 111551) {
54253                     if (compilerOptions.isolatedModules ||
54254                         ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(location) ||
54255                         !isConstEnumOrConstEnumOnlyModule(target)) {
54256                         markAliasSymbolAsReferenced(symbol);
54257                     }
54258                     else {
54259                         markConstEnumAliasAsReferenced(symbol);
54260                     }
54261                 }
54262             }
54263         }
54264         function checkIdentifier(node) {
54265             var symbol = getResolvedSymbol(node);
54266             if (symbol === unknownSymbol) {
54267                 return errorType;
54268             }
54269             if (symbol === argumentsSymbol) {
54270                 var container = ts.getContainingFunction(node);
54271                 if (languageVersion < 2) {
54272                     if (container.kind === 209) {
54273                         error(node, ts.Diagnostics.The_arguments_object_cannot_be_referenced_in_an_arrow_function_in_ES3_and_ES5_Consider_using_a_standard_function_expression);
54274                     }
54275                     else if (ts.hasSyntacticModifier(container, 256)) {
54276                         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);
54277                     }
54278                 }
54279                 getNodeLinks(container).flags |= 8192;
54280                 return getTypeOfSymbol(symbol);
54281             }
54282             if (!(node.parent && ts.isPropertyAccessExpression(node.parent) && node.parent.expression === node)) {
54283                 markAliasReferenced(symbol, node);
54284             }
54285             var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
54286             var sourceSymbol = localOrExportSymbol.flags & 2097152 ? resolveAlias(localOrExportSymbol) : localOrExportSymbol;
54287             if (getDeclarationNodeFlagsFromSymbol(sourceSymbol) & 134217728 && isUncalledFunctionReference(node, sourceSymbol)) {
54288                 addDeprecatedSuggestion(node, sourceSymbol.declarations, node.escapedText);
54289             }
54290             var declaration = localOrExportSymbol.valueDeclaration;
54291             if (localOrExportSymbol.flags & 32) {
54292                 if (declaration.kind === 252
54293                     && ts.nodeIsDecorated(declaration)) {
54294                     var container = ts.getContainingClass(node);
54295                     while (container !== undefined) {
54296                         if (container === declaration && container.name !== node) {
54297                             getNodeLinks(declaration).flags |= 16777216;
54298                             getNodeLinks(node).flags |= 33554432;
54299                             break;
54300                         }
54301                         container = ts.getContainingClass(container);
54302                     }
54303                 }
54304                 else if (declaration.kind === 221) {
54305                     var container = ts.getThisContainer(node, false);
54306                     while (container.kind !== 297) {
54307                         if (container.parent === declaration) {
54308                             if (container.kind === 163 && ts.hasSyntacticModifier(container, 32)) {
54309                                 getNodeLinks(declaration).flags |= 16777216;
54310                                 getNodeLinks(node).flags |= 33554432;
54311                             }
54312                             break;
54313                         }
54314                         container = ts.getThisContainer(container, false);
54315                     }
54316                 }
54317             }
54318             checkNestedBlockScopedBinding(node, symbol);
54319             var type = getConstraintForLocation(getTypeOfSymbol(localOrExportSymbol), node);
54320             var assignmentKind = ts.getAssignmentTargetKind(node);
54321             if (assignmentKind) {
54322                 if (!(localOrExportSymbol.flags & 3) &&
54323                     !(ts.isInJSFile(node) && localOrExportSymbol.flags & 512)) {
54324                     error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_not_a_variable, symbolToString(symbol));
54325                     return errorType;
54326                 }
54327                 if (isReadonlySymbol(localOrExportSymbol)) {
54328                     if (localOrExportSymbol.flags & 3) {
54329                         error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_constant, symbolToString(symbol));
54330                     }
54331                     else {
54332                         error(node, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, symbolToString(symbol));
54333                     }
54334                     return errorType;
54335                 }
54336             }
54337             var isAlias = localOrExportSymbol.flags & 2097152;
54338             if (localOrExportSymbol.flags & 3) {
54339                 if (assignmentKind === 1) {
54340                     return type;
54341                 }
54342             }
54343             else if (isAlias) {
54344                 declaration = ts.find(symbol.declarations, isSomeImportDeclaration);
54345             }
54346             else {
54347                 return type;
54348             }
54349             if (!declaration) {
54350                 return type;
54351             }
54352             var isParameter = ts.getRootDeclaration(declaration).kind === 160;
54353             var declarationContainer = getControlFlowContainer(declaration);
54354             var flowContainer = getControlFlowContainer(node);
54355             var isOuterVariable = flowContainer !== declarationContainer;
54356             var isSpreadDestructuringAssignmentTarget = node.parent && node.parent.parent && ts.isSpreadAssignment(node.parent) && isDestructuringAssignmentTarget(node.parent.parent);
54357             var isModuleExports = symbol.flags & 134217728;
54358             while (flowContainer !== declarationContainer && (flowContainer.kind === 208 ||
54359                 flowContainer.kind === 209 || ts.isObjectLiteralOrClassExpressionMethod(flowContainer)) &&
54360                 (isConstVariable(localOrExportSymbol) || isParameter && !isParameterAssigned(localOrExportSymbol))) {
54361                 flowContainer = getControlFlowContainer(flowContainer);
54362             }
54363             var assumeInitialized = isParameter || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || ts.isBindingElement(declaration) ||
54364                 type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 | 16384)) !== 0 ||
54365                     isInTypeQuery(node) || node.parent.kind === 270) ||
54366                 node.parent.kind === 225 ||
54367                 declaration.kind === 249 && declaration.exclamationToken ||
54368                 declaration.flags & 8388608;
54369             var initialType = assumeInitialized ? (isParameter ? removeOptionalityFromDeclaredType(type, declaration) : type) :
54370                 type === autoType || type === autoArrayType ? undefinedType :
54371                     getOptionalType(type);
54372             var flowType = getFlowTypeOfReference(node, type, initialType, flowContainer, !assumeInitialized);
54373             if (!isEvolvingArrayOperationTarget(node) && (type === autoType || type === autoArrayType)) {
54374                 if (flowType === autoType || flowType === autoArrayType) {
54375                     if (noImplicitAny) {
54376                         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));
54377                         error(node, ts.Diagnostics.Variable_0_implicitly_has_an_1_type, symbolToString(symbol), typeToString(flowType));
54378                     }
54379                     return convertAutoToAny(flowType);
54380                 }
54381             }
54382             else if (!assumeInitialized && !(getFalsyFlags(type) & 32768) && getFalsyFlags(flowType) & 32768) {
54383                 error(node, ts.Diagnostics.Variable_0_is_used_before_being_assigned, symbolToString(symbol));
54384                 return type;
54385             }
54386             return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
54387         }
54388         function isInsideFunction(node, threshold) {
54389             return !!ts.findAncestor(node, function (n) { return n === threshold ? "quit" : ts.isFunctionLike(n); });
54390         }
54391         function getPartOfForStatementContainingNode(node, container) {
54392             return ts.findAncestor(node, function (n) { return n === container ? "quit" : n === container.initializer || n === container.condition || n === container.incrementor || n === container.statement; });
54393         }
54394         function checkNestedBlockScopedBinding(node, symbol) {
54395             if (languageVersion >= 2 ||
54396                 (symbol.flags & (2 | 32)) === 0 ||
54397                 ts.isSourceFile(symbol.valueDeclaration) ||
54398                 symbol.valueDeclaration.parent.kind === 287) {
54399                 return;
54400             }
54401             var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration);
54402             var usedInFunction = isInsideFunction(node.parent, container);
54403             var current = container;
54404             var containedInIterationStatement = false;
54405             while (current && !ts.nodeStartsNewLexicalEnvironment(current)) {
54406                 if (ts.isIterationStatement(current, false)) {
54407                     containedInIterationStatement = true;
54408                     break;
54409                 }
54410                 current = current.parent;
54411             }
54412             if (containedInIterationStatement) {
54413                 if (usedInFunction) {
54414                     var capturesBlockScopeBindingInLoopBody = true;
54415                     if (ts.isForStatement(container)) {
54416                         var varDeclList = ts.getAncestor(symbol.valueDeclaration, 250);
54417                         if (varDeclList && varDeclList.parent === container) {
54418                             var part = getPartOfForStatementContainingNode(node.parent, container);
54419                             if (part) {
54420                                 var links = getNodeLinks(part);
54421                                 links.flags |= 131072;
54422                                 var capturedBindings = links.capturedBlockScopeBindings || (links.capturedBlockScopeBindings = []);
54423                                 ts.pushIfUnique(capturedBindings, symbol);
54424                                 if (part === container.initializer) {
54425                                     capturesBlockScopeBindingInLoopBody = false;
54426                                 }
54427                             }
54428                         }
54429                     }
54430                     if (capturesBlockScopeBindingInLoopBody) {
54431                         getNodeLinks(current).flags |= 65536;
54432                     }
54433                 }
54434                 if (ts.isForStatement(container)) {
54435                     var varDeclList = ts.getAncestor(symbol.valueDeclaration, 250);
54436                     if (varDeclList && varDeclList.parent === container && isAssignedInBodyOfForStatement(node, container)) {
54437                         getNodeLinks(symbol.valueDeclaration).flags |= 4194304;
54438                     }
54439                 }
54440                 getNodeLinks(symbol.valueDeclaration).flags |= 524288;
54441             }
54442             if (usedInFunction) {
54443                 getNodeLinks(symbol.valueDeclaration).flags |= 262144;
54444             }
54445         }
54446         function isBindingCapturedByNode(node, decl) {
54447             var links = getNodeLinks(node);
54448             return !!links && ts.contains(links.capturedBlockScopeBindings, getSymbolOfNode(decl));
54449         }
54450         function isAssignedInBodyOfForStatement(node, container) {
54451             var current = node;
54452             while (current.parent.kind === 207) {
54453                 current = current.parent;
54454             }
54455             var isAssigned = false;
54456             if (ts.isAssignmentTarget(current)) {
54457                 isAssigned = true;
54458             }
54459             else if ((current.parent.kind === 214 || current.parent.kind === 215)) {
54460                 var expr = current.parent;
54461                 isAssigned = expr.operator === 45 || expr.operator === 46;
54462             }
54463             if (!isAssigned) {
54464                 return false;
54465             }
54466             return !!ts.findAncestor(current, function (n) { return n === container ? "quit" : n === container.statement; });
54467         }
54468         function captureLexicalThis(node, container) {
54469             getNodeLinks(node).flags |= 2;
54470             if (container.kind === 163 || container.kind === 166) {
54471                 var classNode = container.parent;
54472                 getNodeLinks(classNode).flags |= 4;
54473             }
54474             else {
54475                 getNodeLinks(container).flags |= 4;
54476             }
54477         }
54478         function findFirstSuperCall(node) {
54479             return ts.isSuperCall(node) ? node :
54480                 ts.isFunctionLike(node) ? undefined :
54481                     ts.forEachChild(node, findFirstSuperCall);
54482         }
54483         function classDeclarationExtendsNull(classDecl) {
54484             var classSymbol = getSymbolOfNode(classDecl);
54485             var classInstanceType = getDeclaredTypeOfSymbol(classSymbol);
54486             var baseConstructorType = getBaseConstructorTypeOfClass(classInstanceType);
54487             return baseConstructorType === nullWideningType;
54488         }
54489         function checkThisBeforeSuper(node, container, diagnosticMessage) {
54490             var containingClassDecl = container.parent;
54491             var baseTypeNode = ts.getClassExtendsHeritageElement(containingClassDecl);
54492             if (baseTypeNode && !classDeclarationExtendsNull(containingClassDecl)) {
54493                 if (node.flowNode && !isPostSuperFlowNode(node.flowNode, false)) {
54494                     error(node, diagnosticMessage);
54495                 }
54496             }
54497         }
54498         function checkThisExpression(node) {
54499             var container = ts.getThisContainer(node, true);
54500             var capturedByArrowFunction = false;
54501             if (container.kind === 166) {
54502                 checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_this_in_the_constructor_of_a_derived_class);
54503             }
54504             if (container.kind === 209) {
54505                 container = ts.getThisContainer(container, false);
54506                 capturedByArrowFunction = true;
54507             }
54508             switch (container.kind) {
54509                 case 256:
54510                     error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_module_or_namespace_body);
54511                     break;
54512                 case 255:
54513                     error(node, ts.Diagnostics.this_cannot_be_referenced_in_current_location);
54514                     break;
54515                 case 166:
54516                     if (isInConstructorArgumentInitializer(node, container)) {
54517                         error(node, ts.Diagnostics.this_cannot_be_referenced_in_constructor_arguments);
54518                     }
54519                     break;
54520                 case 163:
54521                 case 162:
54522                     if (ts.hasSyntacticModifier(container, 32) && !(compilerOptions.target === 99 && compilerOptions.useDefineForClassFields)) {
54523                         error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_static_property_initializer);
54524                     }
54525                     break;
54526                 case 158:
54527                     error(node, ts.Diagnostics.this_cannot_be_referenced_in_a_computed_property_name);
54528                     break;
54529             }
54530             if (capturedByArrowFunction && languageVersion < 2) {
54531                 captureLexicalThis(node, container);
54532             }
54533             var type = tryGetThisTypeAt(node, true, container);
54534             if (noImplicitThis) {
54535                 var globalThisType_1 = getTypeOfSymbol(globalThisSymbol);
54536                 if (type === globalThisType_1 && capturedByArrowFunction) {
54537                     error(node, ts.Diagnostics.The_containing_arrow_function_captures_the_global_value_of_this);
54538                 }
54539                 else if (!type) {
54540                     var diag = error(node, ts.Diagnostics.this_implicitly_has_type_any_because_it_does_not_have_a_type_annotation);
54541                     if (!ts.isSourceFile(container)) {
54542                         var outsideThis = tryGetThisTypeAt(container);
54543                         if (outsideThis && outsideThis !== globalThisType_1) {
54544                             ts.addRelatedInfo(diag, ts.createDiagnosticForNode(container, ts.Diagnostics.An_outer_value_of_this_is_shadowed_by_this_container));
54545                         }
54546                     }
54547                 }
54548             }
54549             return type || anyType;
54550         }
54551         function tryGetThisTypeAt(node, includeGlobalThis, container) {
54552             if (includeGlobalThis === void 0) { includeGlobalThis = true; }
54553             if (container === void 0) { container = ts.getThisContainer(node, false); }
54554             var isInJS = ts.isInJSFile(node);
54555             if (ts.isFunctionLike(container) &&
54556                 (!isInParameterInitializerBeforeContainingFunction(node) || ts.getThisParameter(container))) {
54557                 var thisType = getThisTypeOfDeclaration(container) || isInJS && getTypeForThisExpressionFromJSDoc(container);
54558                 if (!thisType) {
54559                     var className = getClassNameFromPrototypeMethod(container);
54560                     if (isInJS && className) {
54561                         var classSymbol = checkExpression(className).symbol;
54562                         if (classSymbol && classSymbol.members && (classSymbol.flags & 16)) {
54563                             thisType = getDeclaredTypeOfSymbol(classSymbol).thisType;
54564                         }
54565                     }
54566                     else if (isJSConstructor(container)) {
54567                         thisType = getDeclaredTypeOfSymbol(getMergedSymbol(container.symbol)).thisType;
54568                     }
54569                     thisType || (thisType = getContextualThisParameterType(container));
54570                 }
54571                 if (thisType) {
54572                     return getFlowTypeOfReference(node, thisType);
54573                 }
54574             }
54575             if (ts.isClassLike(container.parent)) {
54576                 var symbol = getSymbolOfNode(container.parent);
54577                 var type = ts.hasSyntacticModifier(container, 32) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType;
54578                 return getFlowTypeOfReference(node, type);
54579             }
54580             if (ts.isSourceFile(container)) {
54581                 if (container.commonJsModuleIndicator) {
54582                     var fileSymbol = getSymbolOfNode(container);
54583                     return fileSymbol && getTypeOfSymbol(fileSymbol);
54584                 }
54585                 else if (container.externalModuleIndicator) {
54586                     return undefinedType;
54587                 }
54588                 else if (includeGlobalThis) {
54589                     return getTypeOfSymbol(globalThisSymbol);
54590                 }
54591             }
54592         }
54593         function getExplicitThisType(node) {
54594             var container = ts.getThisContainer(node, false);
54595             if (ts.isFunctionLike(container)) {
54596                 var signature = getSignatureFromDeclaration(container);
54597                 if (signature.thisParameter) {
54598                     return getExplicitTypeOfSymbol(signature.thisParameter);
54599                 }
54600             }
54601             if (ts.isClassLike(container.parent)) {
54602                 var symbol = getSymbolOfNode(container.parent);
54603                 return ts.hasSyntacticModifier(container, 32) ? getTypeOfSymbol(symbol) : getDeclaredTypeOfSymbol(symbol).thisType;
54604             }
54605         }
54606         function getClassNameFromPrototypeMethod(container) {
54607             if (container.kind === 208 &&
54608                 ts.isBinaryExpression(container.parent) &&
54609                 ts.getAssignmentDeclarationKind(container.parent) === 3) {
54610                 return container.parent
54611                     .left
54612                     .expression
54613                     .expression;
54614             }
54615             else if (container.kind === 165 &&
54616                 container.parent.kind === 200 &&
54617                 ts.isBinaryExpression(container.parent.parent) &&
54618                 ts.getAssignmentDeclarationKind(container.parent.parent) === 6) {
54619                 return container.parent.parent.left.expression;
54620             }
54621             else if (container.kind === 208 &&
54622                 container.parent.kind === 288 &&
54623                 container.parent.parent.kind === 200 &&
54624                 ts.isBinaryExpression(container.parent.parent.parent) &&
54625                 ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 6) {
54626                 return container.parent.parent.parent.left.expression;
54627             }
54628             else if (container.kind === 208 &&
54629                 ts.isPropertyAssignment(container.parent) &&
54630                 ts.isIdentifier(container.parent.name) &&
54631                 (container.parent.name.escapedText === "value" || container.parent.name.escapedText === "get" || container.parent.name.escapedText === "set") &&
54632                 ts.isObjectLiteralExpression(container.parent.parent) &&
54633                 ts.isCallExpression(container.parent.parent.parent) &&
54634                 container.parent.parent.parent.arguments[2] === container.parent.parent &&
54635                 ts.getAssignmentDeclarationKind(container.parent.parent.parent) === 9) {
54636                 return container.parent.parent.parent.arguments[0].expression;
54637             }
54638             else if (ts.isMethodDeclaration(container) &&
54639                 ts.isIdentifier(container.name) &&
54640                 (container.name.escapedText === "value" || container.name.escapedText === "get" || container.name.escapedText === "set") &&
54641                 ts.isObjectLiteralExpression(container.parent) &&
54642                 ts.isCallExpression(container.parent.parent) &&
54643                 container.parent.parent.arguments[2] === container.parent &&
54644                 ts.getAssignmentDeclarationKind(container.parent.parent) === 9) {
54645                 return container.parent.parent.arguments[0].expression;
54646             }
54647         }
54648         function getTypeForThisExpressionFromJSDoc(node) {
54649             var jsdocType = ts.getJSDocType(node);
54650             if (jsdocType && jsdocType.kind === 308) {
54651                 var jsDocFunctionType = jsdocType;
54652                 if (jsDocFunctionType.parameters.length > 0 &&
54653                     jsDocFunctionType.parameters[0].name &&
54654                     jsDocFunctionType.parameters[0].name.escapedText === "this") {
54655                     return getTypeFromTypeNode(jsDocFunctionType.parameters[0].type);
54656                 }
54657             }
54658             var thisTag = ts.getJSDocThisTag(node);
54659             if (thisTag && thisTag.typeExpression) {
54660                 return getTypeFromTypeNode(thisTag.typeExpression);
54661             }
54662         }
54663         function isInConstructorArgumentInitializer(node, constructorDecl) {
54664             return !!ts.findAncestor(node, function (n) { return ts.isFunctionLikeDeclaration(n) ? "quit" : n.kind === 160 && n.parent === constructorDecl; });
54665         }
54666         function checkSuperExpression(node) {
54667             var isCallExpression = node.parent.kind === 203 && node.parent.expression === node;
54668             var immediateContainer = ts.getSuperContainer(node, true);
54669             var container = immediateContainer;
54670             var needToCaptureLexicalThis = false;
54671             if (!isCallExpression) {
54672                 while (container && container.kind === 209) {
54673                     container = ts.getSuperContainer(container, true);
54674                     needToCaptureLexicalThis = languageVersion < 2;
54675                 }
54676             }
54677             var canUseSuperExpression = isLegalUsageOfSuperExpression(container);
54678             var nodeCheckFlag = 0;
54679             if (!canUseSuperExpression) {
54680                 var current = ts.findAncestor(node, function (n) { return n === container ? "quit" : n.kind === 158; });
54681                 if (current && current.kind === 158) {
54682                     error(node, ts.Diagnostics.super_cannot_be_referenced_in_a_computed_property_name);
54683                 }
54684                 else if (isCallExpression) {
54685                     error(node, ts.Diagnostics.Super_calls_are_not_permitted_outside_constructors_or_in_nested_functions_inside_constructors);
54686                 }
54687                 else if (!container || !container.parent || !(ts.isClassLike(container.parent) || container.parent.kind === 200)) {
54688                     error(node, ts.Diagnostics.super_can_only_be_referenced_in_members_of_derived_classes_or_object_literal_expressions);
54689                 }
54690                 else {
54691                     error(node, ts.Diagnostics.super_property_access_is_permitted_only_in_a_constructor_member_function_or_member_accessor_of_a_derived_class);
54692                 }
54693                 return errorType;
54694             }
54695             if (!isCallExpression && immediateContainer.kind === 166) {
54696                 checkThisBeforeSuper(node, container, ts.Diagnostics.super_must_be_called_before_accessing_a_property_of_super_in_the_constructor_of_a_derived_class);
54697             }
54698             if (ts.hasSyntacticModifier(container, 32) || isCallExpression) {
54699                 nodeCheckFlag = 512;
54700             }
54701             else {
54702                 nodeCheckFlag = 256;
54703             }
54704             getNodeLinks(node).flags |= nodeCheckFlag;
54705             if (container.kind === 165 && ts.hasSyntacticModifier(container, 256)) {
54706                 if (ts.isSuperProperty(node.parent) && ts.isAssignmentTarget(node.parent)) {
54707                     getNodeLinks(container).flags |= 4096;
54708                 }
54709                 else {
54710                     getNodeLinks(container).flags |= 2048;
54711                 }
54712             }
54713             if (needToCaptureLexicalThis) {
54714                 captureLexicalThis(node.parent, container);
54715             }
54716             if (container.parent.kind === 200) {
54717                 if (languageVersion < 2) {
54718                     error(node, ts.Diagnostics.super_is_only_allowed_in_members_of_object_literal_expressions_when_option_target_is_ES2015_or_higher);
54719                     return errorType;
54720                 }
54721                 else {
54722                     return anyType;
54723                 }
54724             }
54725             var classLikeDeclaration = container.parent;
54726             if (!ts.getClassExtendsHeritageElement(classLikeDeclaration)) {
54727                 error(node, ts.Diagnostics.super_can_only_be_referenced_in_a_derived_class);
54728                 return errorType;
54729             }
54730             var classType = getDeclaredTypeOfSymbol(getSymbolOfNode(classLikeDeclaration));
54731             var baseClassType = classType && getBaseTypes(classType)[0];
54732             if (!baseClassType) {
54733                 return errorType;
54734             }
54735             if (container.kind === 166 && isInConstructorArgumentInitializer(node, container)) {
54736                 error(node, ts.Diagnostics.super_cannot_be_referenced_in_constructor_arguments);
54737                 return errorType;
54738             }
54739             return nodeCheckFlag === 512
54740                 ? getBaseConstructorTypeOfClass(classType)
54741                 : getTypeWithThisArgument(baseClassType, classType.thisType);
54742             function isLegalUsageOfSuperExpression(container) {
54743                 if (!container) {
54744                     return false;
54745                 }
54746                 if (isCallExpression) {
54747                     return container.kind === 166;
54748                 }
54749                 else {
54750                     if (ts.isClassLike(container.parent) || container.parent.kind === 200) {
54751                         if (ts.hasSyntacticModifier(container, 32)) {
54752                             return container.kind === 165 ||
54753                                 container.kind === 164 ||
54754                                 container.kind === 167 ||
54755                                 container.kind === 168;
54756                         }
54757                         else {
54758                             return container.kind === 165 ||
54759                                 container.kind === 164 ||
54760                                 container.kind === 167 ||
54761                                 container.kind === 168 ||
54762                                 container.kind === 163 ||
54763                                 container.kind === 162 ||
54764                                 container.kind === 166;
54765                         }
54766                     }
54767                 }
54768                 return false;
54769             }
54770         }
54771         function getContainingObjectLiteral(func) {
54772             return (func.kind === 165 ||
54773                 func.kind === 167 ||
54774                 func.kind === 168) && func.parent.kind === 200 ? func.parent :
54775                 func.kind === 208 && func.parent.kind === 288 ? func.parent.parent :
54776                     undefined;
54777         }
54778         function getThisTypeArgument(type) {
54779             return ts.getObjectFlags(type) & 4 && type.target === globalThisType ? getTypeArguments(type)[0] : undefined;
54780         }
54781         function getThisTypeFromContextualType(type) {
54782             return mapType(type, function (t) {
54783                 return t.flags & 2097152 ? ts.forEach(t.types, getThisTypeArgument) : getThisTypeArgument(t);
54784             });
54785         }
54786         function getContextualThisParameterType(func) {
54787             if (func.kind === 209) {
54788                 return undefined;
54789             }
54790             if (isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
54791                 var contextualSignature = getContextualSignature(func);
54792                 if (contextualSignature) {
54793                     var thisParameter = contextualSignature.thisParameter;
54794                     if (thisParameter) {
54795                         return getTypeOfSymbol(thisParameter);
54796                     }
54797                 }
54798             }
54799             var inJs = ts.isInJSFile(func);
54800             if (noImplicitThis || inJs) {
54801                 var containingLiteral = getContainingObjectLiteral(func);
54802                 if (containingLiteral) {
54803                     var contextualType = getApparentTypeOfContextualType(containingLiteral);
54804                     var literal = containingLiteral;
54805                     var type = contextualType;
54806                     while (type) {
54807                         var thisType = getThisTypeFromContextualType(type);
54808                         if (thisType) {
54809                             return instantiateType(thisType, getMapperFromContext(getInferenceContext(containingLiteral)));
54810                         }
54811                         if (literal.parent.kind !== 288) {
54812                             break;
54813                         }
54814                         literal = literal.parent.parent;
54815                         type = getApparentTypeOfContextualType(literal);
54816                     }
54817                     return getWidenedType(contextualType ? getNonNullableType(contextualType) : checkExpressionCached(containingLiteral));
54818                 }
54819                 var parent = ts.walkUpParenthesizedExpressions(func.parent);
54820                 if (parent.kind === 216 && parent.operatorToken.kind === 62) {
54821                     var target = parent.left;
54822                     if (ts.isAccessExpression(target)) {
54823                         var expression = target.expression;
54824                         if (inJs && ts.isIdentifier(expression)) {
54825                             var sourceFile = ts.getSourceFileOfNode(parent);
54826                             if (sourceFile.commonJsModuleIndicator && getResolvedSymbol(expression) === sourceFile.symbol) {
54827                                 return undefined;
54828                             }
54829                         }
54830                         return getWidenedType(checkExpressionCached(expression));
54831                     }
54832                 }
54833             }
54834             return undefined;
54835         }
54836         function getContextuallyTypedParameterType(parameter) {
54837             var func = parameter.parent;
54838             if (!isContextSensitiveFunctionOrObjectLiteralMethod(func)) {
54839                 return undefined;
54840             }
54841             var iife = ts.getImmediatelyInvokedFunctionExpression(func);
54842             if (iife && iife.arguments) {
54843                 var args = getEffectiveCallArguments(iife);
54844                 var indexOfParameter = func.parameters.indexOf(parameter);
54845                 if (parameter.dotDotDotToken) {
54846                     return getSpreadArgumentType(args, indexOfParameter, args.length, anyType, undefined, 0);
54847                 }
54848                 var links = getNodeLinks(iife);
54849                 var cached = links.resolvedSignature;
54850                 links.resolvedSignature = anySignature;
54851                 var type = indexOfParameter < args.length ?
54852                     getWidenedLiteralType(checkExpression(args[indexOfParameter])) :
54853                     parameter.initializer ? undefined : undefinedWideningType;
54854                 links.resolvedSignature = cached;
54855                 return type;
54856             }
54857             var contextualSignature = getContextualSignature(func);
54858             if (contextualSignature) {
54859                 var index = func.parameters.indexOf(parameter) - (ts.getThisParameter(func) ? 1 : 0);
54860                 return parameter.dotDotDotToken && ts.lastOrUndefined(func.parameters) === parameter ?
54861                     getRestTypeAtPosition(contextualSignature, index) :
54862                     tryGetTypeAtPosition(contextualSignature, index);
54863             }
54864         }
54865         function getContextualTypeForVariableLikeDeclaration(declaration) {
54866             var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
54867             if (typeNode) {
54868                 return getTypeFromTypeNode(typeNode);
54869             }
54870             switch (declaration.kind) {
54871                 case 160:
54872                     return getContextuallyTypedParameterType(declaration);
54873                 case 198:
54874                     return getContextualTypeForBindingElement(declaration);
54875                 case 163:
54876                     if (ts.hasSyntacticModifier(declaration, 32)) {
54877                         return getContextualTypeForStaticPropertyDeclaration(declaration);
54878                     }
54879             }
54880         }
54881         function getContextualTypeForBindingElement(declaration) {
54882             var parent = declaration.parent.parent;
54883             var name = declaration.propertyName || declaration.name;
54884             var parentType = getContextualTypeForVariableLikeDeclaration(parent) ||
54885                 parent.kind !== 198 && parent.initializer && checkDeclarationInitializer(parent);
54886             if (!parentType || ts.isBindingPattern(name) || ts.isComputedNonLiteralName(name))
54887                 return undefined;
54888             if (parent.name.kind === 197) {
54889                 var index = ts.indexOfNode(declaration.parent.elements, declaration);
54890                 if (index < 0)
54891                     return undefined;
54892                 return getContextualTypeForElementExpression(parentType, index);
54893             }
54894             var nameType = getLiteralTypeFromPropertyName(name);
54895             if (isTypeUsableAsPropertyName(nameType)) {
54896                 var text = getPropertyNameFromType(nameType);
54897                 return getTypeOfPropertyOfType(parentType, text);
54898             }
54899         }
54900         function getContextualTypeForStaticPropertyDeclaration(declaration) {
54901             var parentType = ts.isExpression(declaration.parent) && getContextualType(declaration.parent);
54902             if (!parentType)
54903                 return undefined;
54904             return getTypeOfPropertyOfContextualType(parentType, getSymbolOfNode(declaration).escapedName);
54905         }
54906         function getContextualTypeForInitializerExpression(node, contextFlags) {
54907             var declaration = node.parent;
54908             if (ts.hasInitializer(declaration) && node === declaration.initializer) {
54909                 var result = getContextualTypeForVariableLikeDeclaration(declaration);
54910                 if (result) {
54911                     return result;
54912                 }
54913                 if (!(contextFlags & 8) && ts.isBindingPattern(declaration.name)) {
54914                     return getTypeFromBindingPattern(declaration.name, true, false);
54915                 }
54916             }
54917             return undefined;
54918         }
54919         function getContextualTypeForReturnExpression(node) {
54920             var func = ts.getContainingFunction(node);
54921             if (func) {
54922                 var contextualReturnType = getContextualReturnType(func);
54923                 if (contextualReturnType) {
54924                     var functionFlags = ts.getFunctionFlags(func);
54925                     if (functionFlags & 1) {
54926                         var use = functionFlags & 2 ? 2 : 1;
54927                         var iterationTypes = getIterationTypesOfIterable(contextualReturnType, use, undefined);
54928                         if (!iterationTypes) {
54929                             return undefined;
54930                         }
54931                         contextualReturnType = iterationTypes.returnType;
54932                     }
54933                     if (functionFlags & 2) {
54934                         var contextualAwaitedType = mapType(contextualReturnType, getAwaitedType);
54935                         return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]);
54936                     }
54937                     return contextualReturnType;
54938                 }
54939             }
54940             return undefined;
54941         }
54942         function getContextualTypeForAwaitOperand(node, contextFlags) {
54943             var contextualType = getContextualType(node, contextFlags);
54944             if (contextualType) {
54945                 var contextualAwaitedType = getAwaitedType(contextualType);
54946                 return contextualAwaitedType && getUnionType([contextualAwaitedType, createPromiseLikeType(contextualAwaitedType)]);
54947             }
54948             return undefined;
54949         }
54950         function getContextualTypeForYieldOperand(node) {
54951             var func = ts.getContainingFunction(node);
54952             if (func) {
54953                 var functionFlags = ts.getFunctionFlags(func);
54954                 var contextualReturnType = getContextualReturnType(func);
54955                 if (contextualReturnType) {
54956                     return node.asteriskToken
54957                         ? contextualReturnType
54958                         : getIterationTypeOfGeneratorFunctionReturnType(0, contextualReturnType, (functionFlags & 2) !== 0);
54959                 }
54960             }
54961             return undefined;
54962         }
54963         function isInParameterInitializerBeforeContainingFunction(node) {
54964             var inBindingInitializer = false;
54965             while (node.parent && !ts.isFunctionLike(node.parent)) {
54966                 if (ts.isParameter(node.parent) && (inBindingInitializer || node.parent.initializer === node)) {
54967                     return true;
54968                 }
54969                 if (ts.isBindingElement(node.parent) && node.parent.initializer === node) {
54970                     inBindingInitializer = true;
54971                 }
54972                 node = node.parent;
54973             }
54974             return false;
54975         }
54976         function getContextualIterationType(kind, functionDecl) {
54977             var isAsync = !!(ts.getFunctionFlags(functionDecl) & 2);
54978             var contextualReturnType = getContextualReturnType(functionDecl);
54979             if (contextualReturnType) {
54980                 return getIterationTypeOfGeneratorFunctionReturnType(kind, contextualReturnType, isAsync)
54981                     || undefined;
54982             }
54983             return undefined;
54984         }
54985         function getContextualReturnType(functionDecl) {
54986             var returnType = getReturnTypeFromAnnotation(functionDecl);
54987             if (returnType) {
54988                 return returnType;
54989             }
54990             var signature = getContextualSignatureForFunctionLikeDeclaration(functionDecl);
54991             if (signature && !isResolvingReturnTypeOfSignature(signature)) {
54992                 return getReturnTypeOfSignature(signature);
54993             }
54994             return undefined;
54995         }
54996         function getContextualTypeForArgument(callTarget, arg) {
54997             var args = getEffectiveCallArguments(callTarget);
54998             var argIndex = args.indexOf(arg);
54999             return argIndex === -1 ? undefined : getContextualTypeForArgumentAtIndex(callTarget, argIndex);
55000         }
55001         function getContextualTypeForArgumentAtIndex(callTarget, argIndex) {
55002             var signature = getNodeLinks(callTarget).resolvedSignature === resolvingSignature ? resolvingSignature : getResolvedSignature(callTarget);
55003             if (ts.isJsxOpeningLikeElement(callTarget) && argIndex === 0) {
55004                 return getEffectiveFirstArgumentForJsxSignature(signature, callTarget);
55005             }
55006             return getTypeAtPosition(signature, argIndex);
55007         }
55008         function getContextualTypeForSubstitutionExpression(template, substitutionExpression) {
55009             if (template.parent.kind === 205) {
55010                 return getContextualTypeForArgument(template.parent, substitutionExpression);
55011             }
55012             return undefined;
55013         }
55014         function getContextualTypeForBinaryOperand(node, contextFlags) {
55015             var binaryExpression = node.parent;
55016             var left = binaryExpression.left, operatorToken = binaryExpression.operatorToken, right = binaryExpression.right;
55017             switch (operatorToken.kind) {
55018                 case 62:
55019                 case 75:
55020                 case 74:
55021                 case 76:
55022                     return node === right ? getContextualTypeForAssignmentDeclaration(binaryExpression) : undefined;
55023                 case 56:
55024                 case 60:
55025                     var type = getContextualType(binaryExpression, contextFlags);
55026                     return node === right && (type && type.pattern || !type && !ts.isDefaultedExpandoInitializer(binaryExpression)) ?
55027                         getTypeOfExpression(left) : type;
55028                 case 55:
55029                 case 27:
55030                     return node === right ? getContextualType(binaryExpression, contextFlags) : undefined;
55031                 default:
55032                     return undefined;
55033             }
55034         }
55035         function getContextualTypeForAssignmentDeclaration(binaryExpression) {
55036             var kind = ts.getAssignmentDeclarationKind(binaryExpression);
55037             switch (kind) {
55038                 case 0:
55039                     return getTypeOfExpression(binaryExpression.left);
55040                 case 5:
55041                 case 1:
55042                 case 6:
55043                 case 3:
55044                     if (isPossiblyAliasedThisProperty(binaryExpression, kind)) {
55045                         return getContextualTypeForThisPropertyAssignment(binaryExpression, kind);
55046                     }
55047                     else if (!binaryExpression.left.symbol) {
55048                         return getTypeOfExpression(binaryExpression.left);
55049                     }
55050                     else {
55051                         var decl = binaryExpression.left.symbol.valueDeclaration;
55052                         if (!decl) {
55053                             return undefined;
55054                         }
55055                         var lhs = ts.cast(binaryExpression.left, ts.isAccessExpression);
55056                         var overallAnnotation = ts.getEffectiveTypeAnnotationNode(decl);
55057                         if (overallAnnotation) {
55058                             return getTypeFromTypeNode(overallAnnotation);
55059                         }
55060                         else if (ts.isIdentifier(lhs.expression)) {
55061                             var id = lhs.expression;
55062                             var parentSymbol = resolveName(id, id.escapedText, 111551, undefined, id.escapedText, true);
55063                             if (parentSymbol) {
55064                                 var annotated = parentSymbol.valueDeclaration && ts.getEffectiveTypeAnnotationNode(parentSymbol.valueDeclaration);
55065                                 if (annotated) {
55066                                     var nameStr = ts.getElementOrPropertyAccessName(lhs);
55067                                     if (nameStr !== undefined) {
55068                                         return getTypeOfPropertyOfContextualType(getTypeFromTypeNode(annotated), nameStr);
55069                                     }
55070                                 }
55071                                 return undefined;
55072                             }
55073                         }
55074                         return ts.isInJSFile(decl) ? undefined : getTypeOfExpression(binaryExpression.left);
55075                     }
55076                 case 2:
55077                 case 4:
55078                     return getContextualTypeForThisPropertyAssignment(binaryExpression, kind);
55079                 case 7:
55080                 case 8:
55081                 case 9:
55082                     return ts.Debug.fail("Does not apply");
55083                 default:
55084                     return ts.Debug.assertNever(kind);
55085             }
55086         }
55087         function isPossiblyAliasedThisProperty(declaration, kind) {
55088             if (kind === void 0) { kind = ts.getAssignmentDeclarationKind(declaration); }
55089             if (kind === 4) {
55090                 return true;
55091             }
55092             if (!ts.isInJSFile(declaration) || kind !== 5 || !ts.isIdentifier(declaration.left.expression)) {
55093                 return false;
55094             }
55095             var name = declaration.left.expression.escapedText;
55096             var symbol = resolveName(declaration.left, name, 111551, undefined, undefined, true, true);
55097             return ts.isThisInitializedDeclaration(symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration);
55098         }
55099         function getContextualTypeForThisPropertyAssignment(binaryExpression, kind) {
55100             if (!binaryExpression.symbol)
55101                 return getTypeOfExpression(binaryExpression.left);
55102             if (binaryExpression.symbol.valueDeclaration) {
55103                 var annotated = ts.getEffectiveTypeAnnotationNode(binaryExpression.symbol.valueDeclaration);
55104                 if (annotated) {
55105                     var type = getTypeFromTypeNode(annotated);
55106                     if (type) {
55107                         return type;
55108                     }
55109                 }
55110             }
55111             if (kind === 2)
55112                 return undefined;
55113             var thisAccess = ts.cast(binaryExpression.left, ts.isAccessExpression);
55114             if (!ts.isObjectLiteralMethod(ts.getThisContainer(thisAccess.expression, false))) {
55115                 return undefined;
55116             }
55117             var thisType = checkThisExpression(thisAccess.expression);
55118             var nameStr = ts.getElementOrPropertyAccessName(thisAccess);
55119             return nameStr !== undefined && getTypeOfPropertyOfContextualType(thisType, nameStr) || undefined;
55120         }
55121         function isCircularMappedProperty(symbol) {
55122             return !!(ts.getCheckFlags(symbol) & 262144 && !symbol.type && findResolutionCycleStartIndex(symbol, 0) >= 0);
55123         }
55124         function getTypeOfPropertyOfContextualType(type, name) {
55125             return mapType(type, function (t) {
55126                 if (isGenericMappedType(t)) {
55127                     var constraint = getConstraintTypeFromMappedType(t);
55128                     var constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
55129                     var propertyNameType = getLiteralType(ts.unescapeLeadingUnderscores(name));
55130                     if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
55131                         return substituteIndexedMappedType(t, propertyNameType);
55132                     }
55133                 }
55134                 else if (t.flags & 3670016) {
55135                     var prop = getPropertyOfType(t, name);
55136                     if (prop) {
55137                         return isCircularMappedProperty(prop) ? undefined : getTypeOfSymbol(prop);
55138                     }
55139                     if (isTupleType(t)) {
55140                         var restType = getRestTypeOfTupleType(t);
55141                         if (restType && isNumericLiteralName(name) && +name >= 0) {
55142                             return restType;
55143                         }
55144                     }
55145                     return isNumericLiteralName(name) && getIndexTypeOfContextualType(t, 1) ||
55146                         getIndexTypeOfContextualType(t, 0);
55147                 }
55148                 return undefined;
55149             }, true);
55150         }
55151         function getIndexTypeOfContextualType(type, kind) {
55152             return mapType(type, function (t) { return getIndexTypeOfStructuredType(t, kind); }, true);
55153         }
55154         function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
55155             ts.Debug.assert(ts.isObjectLiteralMethod(node));
55156             if (node.flags & 16777216) {
55157                 return undefined;
55158             }
55159             return getContextualTypeForObjectLiteralElement(node, contextFlags);
55160         }
55161         function getContextualTypeForObjectLiteralElement(element, contextFlags) {
55162             var objectLiteral = element.parent;
55163             var type = getApparentTypeOfContextualType(objectLiteral, contextFlags);
55164             if (type) {
55165                 if (hasBindableName(element)) {
55166                     var symbolName_3 = getSymbolOfNode(element).escapedName;
55167                     var propertyType = getTypeOfPropertyOfContextualType(type, symbolName_3);
55168                     if (propertyType) {
55169                         return propertyType;
55170                     }
55171                 }
55172                 return isNumericName(element.name) && getIndexTypeOfContextualType(type, 1) ||
55173                     getIndexTypeOfContextualType(type, 0);
55174             }
55175             return undefined;
55176         }
55177         function getContextualTypeForElementExpression(arrayContextualType, index) {
55178             return arrayContextualType && (getTypeOfPropertyOfContextualType(arrayContextualType, "" + index)
55179                 || mapType(arrayContextualType, function (t) { return getIteratedTypeOrElementType(1, t, undefinedType, undefined, false); }, true));
55180         }
55181         function getContextualTypeForConditionalOperand(node, contextFlags) {
55182             var conditional = node.parent;
55183             return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional, contextFlags) : undefined;
55184         }
55185         function getContextualTypeForChildJsxExpression(node, child) {
55186             var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName);
55187             var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
55188             if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) {
55189                 return undefined;
55190             }
55191             var realChildren = ts.getSemanticJsxChildren(node.children);
55192             var childIndex = realChildren.indexOf(child);
55193             var childFieldType = getTypeOfPropertyOfContextualType(attributesType, jsxChildrenPropertyName);
55194             return childFieldType && (realChildren.length === 1 ? childFieldType : mapType(childFieldType, function (t) {
55195                 if (isArrayLikeType(t)) {
55196                     return getIndexedAccessType(t, getLiteralType(childIndex));
55197                 }
55198                 else {
55199                     return t;
55200                 }
55201             }, true));
55202         }
55203         function getContextualTypeForJsxExpression(node) {
55204             var exprParent = node.parent;
55205             return ts.isJsxAttributeLike(exprParent)
55206                 ? getContextualType(node)
55207                 : ts.isJsxElement(exprParent)
55208                     ? getContextualTypeForChildJsxExpression(exprParent, node)
55209                     : undefined;
55210         }
55211         function getContextualTypeForJsxAttribute(attribute) {
55212             if (ts.isJsxAttribute(attribute)) {
55213                 var attributesType = getApparentTypeOfContextualType(attribute.parent);
55214                 if (!attributesType || isTypeAny(attributesType)) {
55215                     return undefined;
55216                 }
55217                 return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText);
55218             }
55219             else {
55220                 return getContextualType(attribute.parent);
55221             }
55222         }
55223         function isPossiblyDiscriminantValue(node) {
55224             switch (node.kind) {
55225                 case 10:
55226                 case 8:
55227                 case 9:
55228                 case 14:
55229                 case 109:
55230                 case 94:
55231                 case 103:
55232                 case 78:
55233                 case 150:
55234                     return true;
55235                 case 201:
55236                 case 207:
55237                     return isPossiblyDiscriminantValue(node.expression);
55238                 case 283:
55239                     return !node.expression || isPossiblyDiscriminantValue(node.expression);
55240             }
55241             return false;
55242         }
55243         function discriminateContextualTypeByObjectMembers(node, contextualType) {
55244             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);
55245         }
55246         function discriminateContextualTypeByJSXAttributes(node, contextualType) {
55247             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);
55248         }
55249         function getApparentTypeOfContextualType(node, contextFlags) {
55250             var contextualType = ts.isObjectLiteralMethod(node) ?
55251                 getContextualTypeForObjectLiteralMethod(node, contextFlags) :
55252                 getContextualType(node, contextFlags);
55253             var instantiatedType = instantiateContextualType(contextualType, node, contextFlags);
55254             if (instantiatedType && !(contextFlags && contextFlags & 2 && instantiatedType.flags & 8650752)) {
55255                 var apparentType = mapType(instantiatedType, getApparentType, true);
55256                 if (apparentType.flags & 1048576) {
55257                     if (ts.isObjectLiteralExpression(node)) {
55258                         return discriminateContextualTypeByObjectMembers(node, apparentType);
55259                     }
55260                     else if (ts.isJsxAttributes(node)) {
55261                         return discriminateContextualTypeByJSXAttributes(node, apparentType);
55262                     }
55263                 }
55264                 return apparentType;
55265             }
55266         }
55267         function instantiateContextualType(contextualType, node, contextFlags) {
55268             if (contextualType && maybeTypeOfKind(contextualType, 465829888)) {
55269                 var inferenceContext = getInferenceContext(node);
55270                 if (inferenceContext && ts.some(inferenceContext.inferences, hasInferenceCandidates)) {
55271                     if (contextFlags && contextFlags & 1) {
55272                         return instantiateInstantiableTypes(contextualType, inferenceContext.nonFixingMapper);
55273                     }
55274                     if (inferenceContext.returnMapper) {
55275                         return instantiateInstantiableTypes(contextualType, inferenceContext.returnMapper);
55276                     }
55277                 }
55278             }
55279             return contextualType;
55280         }
55281         function instantiateInstantiableTypes(type, mapper) {
55282             if (type.flags & 465829888) {
55283                 return instantiateType(type, mapper);
55284             }
55285             if (type.flags & 1048576) {
55286                 return getUnionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }), 0);
55287             }
55288             if (type.flags & 2097152) {
55289                 return getIntersectionType(ts.map(type.types, function (t) { return instantiateInstantiableTypes(t, mapper); }));
55290             }
55291             return type;
55292         }
55293         function getContextualType(node, contextFlags) {
55294             if (node.flags & 16777216) {
55295                 return undefined;
55296             }
55297             if (node.contextualType) {
55298                 return node.contextualType;
55299             }
55300             var parent = node.parent;
55301             switch (parent.kind) {
55302                 case 249:
55303                 case 160:
55304                 case 163:
55305                 case 162:
55306                 case 198:
55307                     return getContextualTypeForInitializerExpression(node, contextFlags);
55308                 case 209:
55309                 case 242:
55310                     return getContextualTypeForReturnExpression(node);
55311                 case 219:
55312                     return getContextualTypeForYieldOperand(parent);
55313                 case 213:
55314                     return getContextualTypeForAwaitOperand(parent, contextFlags);
55315                 case 203:
55316                     if (parent.expression.kind === 99) {
55317                         return stringType;
55318                     }
55319                 case 204:
55320                     return getContextualTypeForArgument(parent, node);
55321                 case 206:
55322                 case 224:
55323                     return ts.isConstTypeReference(parent.type) ? tryFindWhenConstTypeReference(parent) : getTypeFromTypeNode(parent.type);
55324                 case 216:
55325                     return getContextualTypeForBinaryOperand(node, contextFlags);
55326                 case 288:
55327                 case 289:
55328                     return getContextualTypeForObjectLiteralElement(parent, contextFlags);
55329                 case 290:
55330                     return getApparentTypeOfContextualType(parent.parent, contextFlags);
55331                 case 199: {
55332                     var arrayLiteral = parent;
55333                     var type = getApparentTypeOfContextualType(arrayLiteral, contextFlags);
55334                     return getContextualTypeForElementExpression(type, ts.indexOfNode(arrayLiteral.elements, node));
55335                 }
55336                 case 217:
55337                     return getContextualTypeForConditionalOperand(node, contextFlags);
55338                 case 228:
55339                     ts.Debug.assert(parent.parent.kind === 218);
55340                     return getContextualTypeForSubstitutionExpression(parent.parent, node);
55341                 case 207: {
55342                     var tag = ts.isInJSFile(parent) ? ts.getJSDocTypeTag(parent) : undefined;
55343                     return tag ? getTypeFromTypeNode(tag.typeExpression.type) : getContextualType(parent, contextFlags);
55344                 }
55345                 case 225:
55346                     return getContextualType(parent, contextFlags);
55347                 case 283:
55348                     return getContextualTypeForJsxExpression(parent);
55349                 case 280:
55350                 case 282:
55351                     return getContextualTypeForJsxAttribute(parent);
55352                 case 275:
55353                 case 274:
55354                     return getContextualJsxElementAttributesType(parent, contextFlags);
55355             }
55356             return undefined;
55357             function tryFindWhenConstTypeReference(node) {
55358                 return getContextualType(node);
55359             }
55360         }
55361         function getInferenceContext(node) {
55362             var ancestor = ts.findAncestor(node, function (n) { return !!n.inferenceContext; });
55363             return ancestor && ancestor.inferenceContext;
55364         }
55365         function getContextualJsxElementAttributesType(node, contextFlags) {
55366             if (ts.isJsxOpeningElement(node) && node.parent.contextualType && contextFlags !== 4) {
55367                 return node.parent.contextualType;
55368             }
55369             return getContextualTypeForArgumentAtIndex(node, 0);
55370         }
55371         function getEffectiveFirstArgumentForJsxSignature(signature, node) {
55372             return getJsxReferenceKind(node) !== 0
55373                 ? getJsxPropsTypeFromCallSignature(signature, node)
55374                 : getJsxPropsTypeFromClassType(signature, node);
55375         }
55376         function getJsxPropsTypeFromCallSignature(sig, context) {
55377             var propsType = getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType);
55378             propsType = getJsxManagedAttributesFromLocatedAttributes(context, getJsxNamespaceAt(context), propsType);
55379             var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
55380             if (intrinsicAttribs !== errorType) {
55381                 propsType = intersectTypes(intrinsicAttribs, propsType);
55382             }
55383             return propsType;
55384         }
55385         function getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation) {
55386             if (sig.unionSignatures) {
55387                 var results = [];
55388                 for (var _i = 0, _a = sig.unionSignatures; _i < _a.length; _i++) {
55389                     var signature = _a[_i];
55390                     var instance = getReturnTypeOfSignature(signature);
55391                     if (isTypeAny(instance)) {
55392                         return instance;
55393                     }
55394                     var propType = getTypeOfPropertyOfType(instance, forcedLookupLocation);
55395                     if (!propType) {
55396                         return;
55397                     }
55398                     results.push(propType);
55399                 }
55400                 return getIntersectionType(results);
55401             }
55402             var instanceType = getReturnTypeOfSignature(sig);
55403             return isTypeAny(instanceType) ? instanceType : getTypeOfPropertyOfType(instanceType, forcedLookupLocation);
55404         }
55405         function getStaticTypeOfReferencedJsxConstructor(context) {
55406             if (isJsxIntrinsicIdentifier(context.tagName)) {
55407                 var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(context);
55408                 var fakeSignature = createSignatureForJSXIntrinsic(context, result);
55409                 return getOrCreateTypeFromSignature(fakeSignature);
55410             }
55411             var tagType = checkExpressionCached(context.tagName);
55412             if (tagType.flags & 128) {
55413                 var result = getIntrinsicAttributesTypeFromStringLiteralType(tagType, context);
55414                 if (!result) {
55415                     return errorType;
55416                 }
55417                 var fakeSignature = createSignatureForJSXIntrinsic(context, result);
55418                 return getOrCreateTypeFromSignature(fakeSignature);
55419             }
55420             return tagType;
55421         }
55422         function getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType) {
55423             var managedSym = getJsxLibraryManagedAttributes(ns);
55424             if (managedSym) {
55425                 var declaredManagedType = getDeclaredTypeOfSymbol(managedSym);
55426                 var ctorType = getStaticTypeOfReferencedJsxConstructor(context);
55427                 if (managedSym.flags & 524288) {
55428                     var params = getSymbolLinks(managedSym).typeParameters;
55429                     if (ts.length(params) >= 2) {
55430                         var args = fillMissingTypeArguments([ctorType, attributesType], params, 2, ts.isInJSFile(context));
55431                         return getTypeAliasInstantiation(managedSym, args);
55432                     }
55433                 }
55434                 if (ts.length(declaredManagedType.typeParameters) >= 2) {
55435                     var args = fillMissingTypeArguments([ctorType, attributesType], declaredManagedType.typeParameters, 2, ts.isInJSFile(context));
55436                     return createTypeReference(declaredManagedType, args);
55437                 }
55438             }
55439             return attributesType;
55440         }
55441         function getJsxPropsTypeFromClassType(sig, context) {
55442             var ns = getJsxNamespaceAt(context);
55443             var forcedLookupLocation = getJsxElementPropertiesName(ns);
55444             var attributesType = forcedLookupLocation === undefined
55445                 ? getTypeOfFirstParameterOfSignatureWithFallback(sig, unknownType)
55446                 : forcedLookupLocation === ""
55447                     ? getReturnTypeOfSignature(sig)
55448                     : getJsxPropsTypeForSignatureFromMember(sig, forcedLookupLocation);
55449             if (!attributesType) {
55450                 if (!!forcedLookupLocation && !!ts.length(context.attributes.properties)) {
55451                     error(context, ts.Diagnostics.JSX_element_class_does_not_support_attributes_because_it_does_not_have_a_0_property, ts.unescapeLeadingUnderscores(forcedLookupLocation));
55452                 }
55453                 return unknownType;
55454             }
55455             attributesType = getJsxManagedAttributesFromLocatedAttributes(context, ns, attributesType);
55456             if (isTypeAny(attributesType)) {
55457                 return attributesType;
55458             }
55459             else {
55460                 var apparentAttributesType = attributesType;
55461                 var intrinsicClassAttribs = getJsxType(JsxNames.IntrinsicClassAttributes, context);
55462                 if (intrinsicClassAttribs !== errorType) {
55463                     var typeParams = getLocalTypeParametersOfClassOrInterfaceOrTypeAlias(intrinsicClassAttribs.symbol);
55464                     var hostClassType = getReturnTypeOfSignature(sig);
55465                     apparentAttributesType = intersectTypes(typeParams
55466                         ? createTypeReference(intrinsicClassAttribs, fillMissingTypeArguments([hostClassType], typeParams, getMinTypeArgumentCount(typeParams), ts.isInJSFile(context)))
55467                         : intrinsicClassAttribs, apparentAttributesType);
55468                 }
55469                 var intrinsicAttribs = getJsxType(JsxNames.IntrinsicAttributes, context);
55470                 if (intrinsicAttribs !== errorType) {
55471                     apparentAttributesType = intersectTypes(intrinsicAttribs, apparentAttributesType);
55472                 }
55473                 return apparentAttributesType;
55474             }
55475         }
55476         function getContextualCallSignature(type, node) {
55477             var signatures = getSignaturesOfType(type, 0);
55478             if (signatures.length === 1) {
55479                 var signature = signatures[0];
55480                 if (!isAritySmaller(signature, node)) {
55481                     return signature;
55482                 }
55483             }
55484         }
55485         function isAritySmaller(signature, target) {
55486             var targetParameterCount = 0;
55487             for (; targetParameterCount < target.parameters.length; targetParameterCount++) {
55488                 var param = target.parameters[targetParameterCount];
55489                 if (param.initializer || param.questionToken || param.dotDotDotToken || isJSDocOptionalParameter(param)) {
55490                     break;
55491                 }
55492             }
55493             if (target.parameters.length && ts.parameterIsThisKeyword(target.parameters[0])) {
55494                 targetParameterCount--;
55495             }
55496             return !hasEffectiveRestParameter(signature) && getParameterCount(signature) < targetParameterCount;
55497         }
55498         function isFunctionExpressionOrArrowFunction(node) {
55499             return node.kind === 208 || node.kind === 209;
55500         }
55501         function getContextualSignatureForFunctionLikeDeclaration(node) {
55502             return isFunctionExpressionOrArrowFunction(node) || ts.isObjectLiteralMethod(node)
55503                 ? getContextualSignature(node)
55504                 : undefined;
55505         }
55506         function getContextualSignature(node) {
55507             ts.Debug.assert(node.kind !== 165 || ts.isObjectLiteralMethod(node));
55508             var typeTagSignature = getSignatureOfTypeTag(node);
55509             if (typeTagSignature) {
55510                 return typeTagSignature;
55511             }
55512             var type = getApparentTypeOfContextualType(node, 1);
55513             if (!type) {
55514                 return undefined;
55515             }
55516             if (!(type.flags & 1048576)) {
55517                 return getContextualCallSignature(type, node);
55518             }
55519             var signatureList;
55520             var types = type.types;
55521             for (var _i = 0, types_20 = types; _i < types_20.length; _i++) {
55522                 var current = types_20[_i];
55523                 var signature = getContextualCallSignature(current, node);
55524                 if (signature) {
55525                     if (!signatureList) {
55526                         signatureList = [signature];
55527                     }
55528                     else if (!compareSignaturesIdentical(signatureList[0], signature, false, true, true, compareTypesIdentical)) {
55529                         return undefined;
55530                     }
55531                     else {
55532                         signatureList.push(signature);
55533                     }
55534                 }
55535             }
55536             if (signatureList) {
55537                 return signatureList.length === 1 ? signatureList[0] : createUnionSignature(signatureList[0], signatureList);
55538             }
55539         }
55540         function checkSpreadExpression(node, checkMode) {
55541             if (languageVersion < 2) {
55542                 checkExternalEmitHelpers(node, compilerOptions.downlevelIteration ? 1536 : 1024);
55543             }
55544             var arrayOrIterableType = checkExpression(node.expression, checkMode);
55545             return checkIteratedTypeOrElementType(33, arrayOrIterableType, undefinedType, node.expression);
55546         }
55547         function checkSyntheticExpression(node) {
55548             return node.isSpread ? getIndexedAccessType(node.type, numberType) : node.type;
55549         }
55550         function hasDefaultValue(node) {
55551             return (node.kind === 198 && !!node.initializer) ||
55552                 (node.kind === 216 && node.operatorToken.kind === 62);
55553         }
55554         function checkArrayLiteral(node, checkMode, forceTuple) {
55555             var elements = node.elements;
55556             var elementCount = elements.length;
55557             var elementTypes = [];
55558             var elementFlags = [];
55559             var contextualType = getApparentTypeOfContextualType(node);
55560             var inDestructuringPattern = ts.isAssignmentTarget(node);
55561             var inConstContext = isConstContext(node);
55562             for (var i = 0; i < elementCount; i++) {
55563                 var e = elements[i];
55564                 if (e.kind === 220) {
55565                     if (languageVersion < 2) {
55566                         checkExternalEmitHelpers(e, compilerOptions.downlevelIteration ? 1536 : 1024);
55567                     }
55568                     var spreadType = checkExpression(e.expression, checkMode, forceTuple);
55569                     if (isArrayLikeType(spreadType)) {
55570                         elementTypes.push(spreadType);
55571                         elementFlags.push(8);
55572                     }
55573                     else if (inDestructuringPattern) {
55574                         var restElementType = getIndexTypeOfType(spreadType, 1) ||
55575                             getIteratedTypeOrElementType(65, spreadType, undefinedType, undefined, false) ||
55576                             unknownType;
55577                         elementTypes.push(restElementType);
55578                         elementFlags.push(4);
55579                     }
55580                     else {
55581                         elementTypes.push(checkIteratedTypeOrElementType(33, spreadType, undefinedType, e.expression));
55582                         elementFlags.push(4);
55583                     }
55584                 }
55585                 else {
55586                     var elementContextualType = getContextualTypeForElementExpression(contextualType, elementTypes.length);
55587                     var type = checkExpressionForMutableLocation(e, checkMode, elementContextualType, forceTuple);
55588                     elementTypes.push(type);
55589                     elementFlags.push(1);
55590                 }
55591             }
55592             if (inDestructuringPattern) {
55593                 return createTupleType(elementTypes, elementFlags);
55594             }
55595             if (forceTuple || inConstContext || contextualType && forEachType(contextualType, isTupleLikeType)) {
55596                 return createArrayLiteralType(createTupleType(elementTypes, elementFlags, inConstContext));
55597             }
55598             return createArrayLiteralType(createArrayType(elementTypes.length ?
55599                 getUnionType(ts.sameMap(elementTypes, function (t, i) { return elementFlags[i] & 8 ? getIndexedAccessTypeOrUndefined(t, numberType) || anyType : t; }), 2) :
55600                 strictNullChecks ? implicitNeverType : undefinedWideningType, inConstContext));
55601         }
55602         function createArrayLiteralType(type) {
55603             if (!(ts.getObjectFlags(type) & 4)) {
55604                 return type;
55605             }
55606             var literalType = type.literalType;
55607             if (!literalType) {
55608                 literalType = type.literalType = cloneTypeReference(type);
55609                 literalType.objectFlags |= 65536 | 1048576;
55610             }
55611             return literalType;
55612         }
55613         function isNumericName(name) {
55614             switch (name.kind) {
55615                 case 158:
55616                     return isNumericComputedName(name);
55617                 case 78:
55618                     return isNumericLiteralName(name.escapedText);
55619                 case 8:
55620                 case 10:
55621                     return isNumericLiteralName(name.text);
55622                 default:
55623                     return false;
55624             }
55625         }
55626         function isNumericComputedName(name) {
55627             return isTypeAssignableToKind(checkComputedPropertyName(name), 296);
55628         }
55629         function isInfinityOrNaNString(name) {
55630             return name === "Infinity" || name === "-Infinity" || name === "NaN";
55631         }
55632         function isNumericLiteralName(name) {
55633             return (+name).toString() === name;
55634         }
55635         function checkComputedPropertyName(node) {
55636             var links = getNodeLinks(node.expression);
55637             if (!links.resolvedType) {
55638                 links.resolvedType = checkExpression(node.expression);
55639                 if (links.resolvedType.flags & 98304 ||
55640                     !isTypeAssignableToKind(links.resolvedType, 402653316 | 296 | 12288) &&
55641                         !isTypeAssignableTo(links.resolvedType, stringNumberSymbolType)) {
55642                     error(node, ts.Diagnostics.A_computed_property_name_must_be_of_type_string_number_symbol_or_any);
55643                 }
55644                 else {
55645                     checkThatExpressionIsProperSymbolReference(node.expression, links.resolvedType, true);
55646                 }
55647             }
55648             return links.resolvedType;
55649         }
55650         function isSymbolWithNumericName(symbol) {
55651             var _a;
55652             var firstDecl = (_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a[0];
55653             return isNumericLiteralName(symbol.escapedName) || (firstDecl && ts.isNamedDeclaration(firstDecl) && isNumericName(firstDecl.name));
55654         }
55655         function getObjectLiteralIndexInfo(node, offset, properties, kind) {
55656             var propTypes = [];
55657             for (var i = offset; i < properties.length; i++) {
55658                 if (kind === 0 || isSymbolWithNumericName(properties[i])) {
55659                     propTypes.push(getTypeOfSymbol(properties[i]));
55660                 }
55661             }
55662             var unionType = propTypes.length ? getUnionType(propTypes, 2) : undefinedType;
55663             return createIndexInfo(unionType, isConstContext(node));
55664         }
55665         function getImmediateAliasedSymbol(symbol) {
55666             ts.Debug.assert((symbol.flags & 2097152) !== 0, "Should only get Alias here.");
55667             var links = getSymbolLinks(symbol);
55668             if (!links.immediateTarget) {
55669                 var node = getDeclarationOfAliasSymbol(symbol);
55670                 if (!node)
55671                     return ts.Debug.fail();
55672                 links.immediateTarget = getTargetOfAliasDeclaration(node, true);
55673             }
55674             return links.immediateTarget;
55675         }
55676         function checkObjectLiteral(node, checkMode) {
55677             var inDestructuringPattern = ts.isAssignmentTarget(node);
55678             checkGrammarObjectLiteralExpression(node, inDestructuringPattern);
55679             var allPropertiesTable = strictNullChecks ? ts.createSymbolTable() : undefined;
55680             var propertiesTable = ts.createSymbolTable();
55681             var propertiesArray = [];
55682             var spread = emptyObjectType;
55683             var contextualType = getApparentTypeOfContextualType(node);
55684             var contextualTypeHasPattern = contextualType && contextualType.pattern &&
55685                 (contextualType.pattern.kind === 196 || contextualType.pattern.kind === 200);
55686             var inConstContext = isConstContext(node);
55687             var checkFlags = inConstContext ? 8 : 0;
55688             var isInJavascript = ts.isInJSFile(node) && !ts.isInJsonFile(node);
55689             var enumTag = ts.getJSDocEnumTag(node);
55690             var isJSObjectLiteral = !contextualType && isInJavascript && !enumTag;
55691             var objectFlags = freshObjectLiteralFlag;
55692             var patternWithComputedProperties = false;
55693             var hasComputedStringProperty = false;
55694             var hasComputedNumberProperty = false;
55695             for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
55696                 var elem = _a[_i];
55697                 if (elem.name && ts.isComputedPropertyName(elem.name) && !ts.isWellKnownSymbolSyntactically(elem.name)) {
55698                     checkComputedPropertyName(elem.name);
55699                 }
55700             }
55701             var offset = 0;
55702             for (var _b = 0, _c = node.properties; _b < _c.length; _b++) {
55703                 var memberDecl = _c[_b];
55704                 var member = getSymbolOfNode(memberDecl);
55705                 var computedNameType = memberDecl.name && memberDecl.name.kind === 158 && !ts.isWellKnownSymbolSyntactically(memberDecl.name.expression) ?
55706                     checkComputedPropertyName(memberDecl.name) : undefined;
55707                 if (memberDecl.kind === 288 ||
55708                     memberDecl.kind === 289 ||
55709                     ts.isObjectLiteralMethod(memberDecl)) {
55710                     var type = memberDecl.kind === 288 ? checkPropertyAssignment(memberDecl, checkMode) :
55711                         memberDecl.kind === 289 ? checkExpressionForMutableLocation(!inDestructuringPattern && memberDecl.objectAssignmentInitializer ? memberDecl.objectAssignmentInitializer : memberDecl.name, checkMode) :
55712                             checkObjectLiteralMethod(memberDecl, checkMode);
55713                     if (isInJavascript) {
55714                         var jsDocType = getTypeForDeclarationFromJSDocComment(memberDecl);
55715                         if (jsDocType) {
55716                             checkTypeAssignableTo(type, jsDocType, memberDecl);
55717                             type = jsDocType;
55718                         }
55719                         else if (enumTag && enumTag.typeExpression) {
55720                             checkTypeAssignableTo(type, getTypeFromTypeNode(enumTag.typeExpression), memberDecl);
55721                         }
55722                     }
55723                     objectFlags |= ts.getObjectFlags(type) & 3670016;
55724                     var nameType = computedNameType && isTypeUsableAsPropertyName(computedNameType) ? computedNameType : undefined;
55725                     var prop = nameType ?
55726                         createSymbol(4 | member.flags, getPropertyNameFromType(nameType), checkFlags | 4096) :
55727                         createSymbol(4 | member.flags, member.escapedName, checkFlags);
55728                     if (nameType) {
55729                         prop.nameType = nameType;
55730                     }
55731                     if (inDestructuringPattern) {
55732                         var isOptional = (memberDecl.kind === 288 && hasDefaultValue(memberDecl.initializer)) ||
55733                             (memberDecl.kind === 289 && memberDecl.objectAssignmentInitializer);
55734                         if (isOptional) {
55735                             prop.flags |= 16777216;
55736                         }
55737                     }
55738                     else if (contextualTypeHasPattern && !(ts.getObjectFlags(contextualType) & 512)) {
55739                         var impliedProp = getPropertyOfType(contextualType, member.escapedName);
55740                         if (impliedProp) {
55741                             prop.flags |= impliedProp.flags & 16777216;
55742                         }
55743                         else if (!compilerOptions.suppressExcessPropertyErrors && !getIndexInfoOfType(contextualType, 0)) {
55744                             error(memberDecl.name, ts.Diagnostics.Object_literal_may_only_specify_known_properties_and_0_does_not_exist_in_type_1, symbolToString(member), typeToString(contextualType));
55745                         }
55746                     }
55747                     prop.declarations = member.declarations;
55748                     prop.parent = member.parent;
55749                     if (member.valueDeclaration) {
55750                         prop.valueDeclaration = member.valueDeclaration;
55751                     }
55752                     prop.type = type;
55753                     prop.target = member;
55754                     member = prop;
55755                     allPropertiesTable === null || allPropertiesTable === void 0 ? void 0 : allPropertiesTable.set(prop.escapedName, prop);
55756                 }
55757                 else if (memberDecl.kind === 290) {
55758                     if (languageVersion < 2) {
55759                         checkExternalEmitHelpers(memberDecl, 2);
55760                     }
55761                     if (propertiesArray.length > 0) {
55762                         spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext);
55763                         propertiesArray = [];
55764                         propertiesTable = ts.createSymbolTable();
55765                         hasComputedStringProperty = false;
55766                         hasComputedNumberProperty = false;
55767                     }
55768                     var type = getReducedType(checkExpression(memberDecl.expression));
55769                     if (!isValidSpreadType(type)) {
55770                         error(memberDecl, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types);
55771                         return errorType;
55772                     }
55773                     if (allPropertiesTable) {
55774                         checkSpreadPropOverrides(type, allPropertiesTable, memberDecl);
55775                     }
55776                     spread = getSpreadType(spread, type, node.symbol, objectFlags, inConstContext);
55777                     offset = propertiesArray.length;
55778                     continue;
55779                 }
55780                 else {
55781                     ts.Debug.assert(memberDecl.kind === 167 || memberDecl.kind === 168);
55782                     checkNodeDeferred(memberDecl);
55783                 }
55784                 if (computedNameType && !(computedNameType.flags & 8576)) {
55785                     if (isTypeAssignableTo(computedNameType, stringNumberSymbolType)) {
55786                         if (isTypeAssignableTo(computedNameType, numberType)) {
55787                             hasComputedNumberProperty = true;
55788                         }
55789                         else {
55790                             hasComputedStringProperty = true;
55791                         }
55792                         if (inDestructuringPattern) {
55793                             patternWithComputedProperties = true;
55794                         }
55795                     }
55796                 }
55797                 else {
55798                     propertiesTable.set(member.escapedName, member);
55799                 }
55800                 propertiesArray.push(member);
55801             }
55802             if (contextualTypeHasPattern && node.parent.kind !== 290) {
55803                 for (var _d = 0, _e = getPropertiesOfType(contextualType); _d < _e.length; _d++) {
55804                     var prop = _e[_d];
55805                     if (!propertiesTable.get(prop.escapedName) && !getPropertyOfType(spread, prop.escapedName)) {
55806                         if (!(prop.flags & 16777216)) {
55807                             error(prop.valueDeclaration || prop.bindingElement, ts.Diagnostics.Initializer_provides_no_value_for_this_binding_element_and_the_binding_element_has_no_default_value);
55808                         }
55809                         propertiesTable.set(prop.escapedName, prop);
55810                         propertiesArray.push(prop);
55811                     }
55812                 }
55813             }
55814             if (spread !== emptyObjectType) {
55815                 if (propertiesArray.length > 0) {
55816                     spread = getSpreadType(spread, createObjectLiteralType(), node.symbol, objectFlags, inConstContext);
55817                     propertiesArray = [];
55818                     propertiesTable = ts.createSymbolTable();
55819                     hasComputedStringProperty = false;
55820                     hasComputedNumberProperty = false;
55821                 }
55822                 return mapType(spread, function (t) { return t === emptyObjectType ? createObjectLiteralType() : t; });
55823             }
55824             return createObjectLiteralType();
55825             function createObjectLiteralType() {
55826                 var stringIndexInfo = hasComputedStringProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 0) : undefined;
55827                 var numberIndexInfo = hasComputedNumberProperty ? getObjectLiteralIndexInfo(node, offset, propertiesArray, 1) : undefined;
55828                 var result = createAnonymousType(node.symbol, propertiesTable, ts.emptyArray, ts.emptyArray, stringIndexInfo, numberIndexInfo);
55829                 result.objectFlags |= objectFlags | 128 | 1048576;
55830                 if (isJSObjectLiteral) {
55831                     result.objectFlags |= 16384;
55832                 }
55833                 if (patternWithComputedProperties) {
55834                     result.objectFlags |= 512;
55835                 }
55836                 if (inDestructuringPattern) {
55837                     result.pattern = node;
55838                 }
55839                 return result;
55840             }
55841         }
55842         function isValidSpreadType(type) {
55843             if (type.flags & 465829888) {
55844                 var constraint = getBaseConstraintOfType(type);
55845                 if (constraint !== undefined) {
55846                     return isValidSpreadType(constraint);
55847                 }
55848             }
55849             return !!(type.flags & (1 | 67108864 | 524288 | 58982400) ||
55850                 getFalsyFlags(type) & 117632 && isValidSpreadType(removeDefinitelyFalsyTypes(type)) ||
55851                 type.flags & 3145728 && ts.every(type.types, isValidSpreadType));
55852         }
55853         function checkJsxSelfClosingElementDeferred(node) {
55854             checkJsxOpeningLikeElementOrOpeningFragment(node);
55855         }
55856         function checkJsxSelfClosingElement(node, _checkMode) {
55857             checkNodeDeferred(node);
55858             return getJsxElementTypeAt(node) || anyType;
55859         }
55860         function checkJsxElementDeferred(node) {
55861             checkJsxOpeningLikeElementOrOpeningFragment(node.openingElement);
55862             if (isJsxIntrinsicIdentifier(node.closingElement.tagName)) {
55863                 getIntrinsicTagSymbol(node.closingElement);
55864             }
55865             else {
55866                 checkExpression(node.closingElement.tagName);
55867             }
55868             checkJsxChildren(node);
55869         }
55870         function checkJsxElement(node, _checkMode) {
55871             checkNodeDeferred(node);
55872             return getJsxElementTypeAt(node) || anyType;
55873         }
55874         function checkJsxFragment(node) {
55875             checkJsxOpeningLikeElementOrOpeningFragment(node.openingFragment);
55876             var nodeSourceFile = ts.getSourceFileOfNode(node);
55877             if (ts.getJSXTransformEnabled(compilerOptions) && (compilerOptions.jsxFactory || nodeSourceFile.pragmas.has("jsx"))
55878                 && !compilerOptions.jsxFragmentFactory && !nodeSourceFile.pragmas.has("jsxfrag")) {
55879                 error(node, compilerOptions.jsxFactory
55880                     ? ts.Diagnostics.The_jsxFragmentFactory_compiler_option_must_be_provided_to_use_JSX_fragments_with_the_jsxFactory_compiler_option
55881                     : ts.Diagnostics.An_jsxFrag_pragma_is_required_when_using_an_jsx_pragma_with_JSX_fragments);
55882             }
55883             checkJsxChildren(node);
55884             return getJsxElementTypeAt(node) || anyType;
55885         }
55886         function isUnhyphenatedJsxName(name) {
55887             return !ts.stringContains(name, "-");
55888         }
55889         function isJsxIntrinsicIdentifier(tagName) {
55890             return tagName.kind === 78 && ts.isIntrinsicJsxName(tagName.escapedText);
55891         }
55892         function checkJsxAttribute(node, checkMode) {
55893             return node.initializer
55894                 ? checkExpressionForMutableLocation(node.initializer, checkMode)
55895                 : trueType;
55896         }
55897         function createJsxAttributesTypeFromAttributesProperty(openingLikeElement, checkMode) {
55898             var attributes = openingLikeElement.attributes;
55899             var allAttributesTable = strictNullChecks ? ts.createSymbolTable() : undefined;
55900             var attributesTable = ts.createSymbolTable();
55901             var spread = emptyJsxObjectType;
55902             var hasSpreadAnyType = false;
55903             var typeToIntersect;
55904             var explicitlySpecifyChildrenAttribute = false;
55905             var objectFlags = 4096;
55906             var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(openingLikeElement));
55907             for (var _i = 0, _a = attributes.properties; _i < _a.length; _i++) {
55908                 var attributeDecl = _a[_i];
55909                 var member = attributeDecl.symbol;
55910                 if (ts.isJsxAttribute(attributeDecl)) {
55911                     var exprType = checkJsxAttribute(attributeDecl, checkMode);
55912                     objectFlags |= ts.getObjectFlags(exprType) & 3670016;
55913                     var attributeSymbol = createSymbol(4 | member.flags, member.escapedName);
55914                     attributeSymbol.declarations = member.declarations;
55915                     attributeSymbol.parent = member.parent;
55916                     if (member.valueDeclaration) {
55917                         attributeSymbol.valueDeclaration = member.valueDeclaration;
55918                     }
55919                     attributeSymbol.type = exprType;
55920                     attributeSymbol.target = member;
55921                     attributesTable.set(attributeSymbol.escapedName, attributeSymbol);
55922                     allAttributesTable === null || allAttributesTable === void 0 ? void 0 : allAttributesTable.set(attributeSymbol.escapedName, attributeSymbol);
55923                     if (attributeDecl.name.escapedText === jsxChildrenPropertyName) {
55924                         explicitlySpecifyChildrenAttribute = true;
55925                     }
55926                 }
55927                 else {
55928                     ts.Debug.assert(attributeDecl.kind === 282);
55929                     if (attributesTable.size > 0) {
55930                         spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false);
55931                         attributesTable = ts.createSymbolTable();
55932                     }
55933                     var exprType = getReducedType(checkExpressionCached(attributeDecl.expression, checkMode));
55934                     if (isTypeAny(exprType)) {
55935                         hasSpreadAnyType = true;
55936                     }
55937                     if (isValidSpreadType(exprType)) {
55938                         spread = getSpreadType(spread, exprType, attributes.symbol, objectFlags, false);
55939                         if (allAttributesTable) {
55940                             checkSpreadPropOverrides(exprType, allAttributesTable, attributeDecl);
55941                         }
55942                     }
55943                     else {
55944                         typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType;
55945                     }
55946                 }
55947             }
55948             if (!hasSpreadAnyType) {
55949                 if (attributesTable.size > 0) {
55950                     spread = getSpreadType(spread, createJsxAttributesType(), attributes.symbol, objectFlags, false);
55951                 }
55952             }
55953             var parent = openingLikeElement.parent.kind === 273 ? openingLikeElement.parent : undefined;
55954             if (parent && parent.openingElement === openingLikeElement && parent.children.length > 0) {
55955                 var childrenTypes = checkJsxChildren(parent, checkMode);
55956                 if (!hasSpreadAnyType && jsxChildrenPropertyName && jsxChildrenPropertyName !== "") {
55957                     if (explicitlySpecifyChildrenAttribute) {
55958                         error(attributes, ts.Diagnostics._0_are_specified_twice_The_attribute_named_0_will_be_overwritten, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName));
55959                     }
55960                     var contextualType = getApparentTypeOfContextualType(openingLikeElement.attributes);
55961                     var childrenContextualType = contextualType && getTypeOfPropertyOfContextualType(contextualType, jsxChildrenPropertyName);
55962                     var childrenPropSymbol = createSymbol(4, jsxChildrenPropertyName);
55963                     childrenPropSymbol.type = childrenTypes.length === 1 ? childrenTypes[0] :
55964                         childrenContextualType && forEachType(childrenContextualType, isTupleLikeType) ? createTupleType(childrenTypes) :
55965                             createArrayType(getUnionType(childrenTypes));
55966                     childrenPropSymbol.valueDeclaration = ts.factory.createPropertySignature(undefined, ts.unescapeLeadingUnderscores(jsxChildrenPropertyName), undefined, undefined);
55967                     ts.setParent(childrenPropSymbol.valueDeclaration, attributes);
55968                     childrenPropSymbol.valueDeclaration.symbol = childrenPropSymbol;
55969                     var childPropMap = ts.createSymbolTable();
55970                     childPropMap.set(jsxChildrenPropertyName, childrenPropSymbol);
55971                     spread = getSpreadType(spread, createAnonymousType(attributes.symbol, childPropMap, ts.emptyArray, ts.emptyArray, undefined, undefined), attributes.symbol, objectFlags, false);
55972                 }
55973             }
55974             if (hasSpreadAnyType) {
55975                 return anyType;
55976             }
55977             if (typeToIntersect && spread !== emptyJsxObjectType) {
55978                 return getIntersectionType([typeToIntersect, spread]);
55979             }
55980             return typeToIntersect || (spread === emptyJsxObjectType ? createJsxAttributesType() : spread);
55981             function createJsxAttributesType() {
55982                 objectFlags |= freshObjectLiteralFlag;
55983                 var result = createAnonymousType(attributes.symbol, attributesTable, ts.emptyArray, ts.emptyArray, undefined, undefined);
55984                 result.objectFlags |= objectFlags | 128 | 1048576;
55985                 return result;
55986             }
55987         }
55988         function checkJsxChildren(node, checkMode) {
55989             var childrenTypes = [];
55990             for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
55991                 var child = _a[_i];
55992                 if (child.kind === 11) {
55993                     if (!child.containsOnlyTriviaWhiteSpaces) {
55994                         childrenTypes.push(stringType);
55995                     }
55996                 }
55997                 else if (child.kind === 283 && !child.expression) {
55998                     continue;
55999                 }
56000                 else {
56001                     childrenTypes.push(checkExpressionForMutableLocation(child, checkMode));
56002                 }
56003             }
56004             return childrenTypes;
56005         }
56006         function checkSpreadPropOverrides(type, props, spread) {
56007             for (var _i = 0, _a = getPropertiesOfType(type); _i < _a.length; _i++) {
56008                 var right = _a[_i];
56009                 var left = props.get(right.escapedName);
56010                 var rightType = getTypeOfSymbol(right);
56011                 if (left && !maybeTypeOfKind(rightType, 98304) && !(maybeTypeOfKind(rightType, 3) && right.flags & 16777216)) {
56012                     var diagnostic = error(left.valueDeclaration, ts.Diagnostics._0_is_specified_more_than_once_so_this_usage_will_be_overwritten, ts.unescapeLeadingUnderscores(left.escapedName));
56013                     ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(spread, ts.Diagnostics.This_spread_always_overwrites_this_property));
56014                 }
56015             }
56016         }
56017         function checkJsxAttributes(node, checkMode) {
56018             return createJsxAttributesTypeFromAttributesProperty(node.parent, checkMode);
56019         }
56020         function getJsxType(name, location) {
56021             var namespace = getJsxNamespaceAt(location);
56022             var exports = namespace && getExportsOfSymbol(namespace);
56023             var typeSymbol = exports && getSymbol(exports, name, 788968);
56024             return typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType;
56025         }
56026         function getIntrinsicTagSymbol(node) {
56027             var links = getNodeLinks(node);
56028             if (!links.resolvedSymbol) {
56029                 var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, node);
56030                 if (intrinsicElementsType !== errorType) {
56031                     if (!ts.isIdentifier(node.tagName))
56032                         return ts.Debug.fail();
56033                     var intrinsicProp = getPropertyOfType(intrinsicElementsType, node.tagName.escapedText);
56034                     if (intrinsicProp) {
56035                         links.jsxFlags |= 1;
56036                         return links.resolvedSymbol = intrinsicProp;
56037                     }
56038                     var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0);
56039                     if (indexSignatureType) {
56040                         links.jsxFlags |= 2;
56041                         return links.resolvedSymbol = intrinsicElementsType.symbol;
56042                     }
56043                     error(node, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.idText(node.tagName), "JSX." + JsxNames.IntrinsicElements);
56044                     return links.resolvedSymbol = unknownSymbol;
56045                 }
56046                 else {
56047                     if (noImplicitAny) {
56048                         error(node, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_no_interface_JSX_0_exists, ts.unescapeLeadingUnderscores(JsxNames.IntrinsicElements));
56049                     }
56050                     return links.resolvedSymbol = unknownSymbol;
56051                 }
56052             }
56053             return links.resolvedSymbol;
56054         }
56055         function getJsxNamespaceContainerForImplicitImport(location) {
56056             var file = location && ts.getSourceFileOfNode(location);
56057             var links = file && getNodeLinks(file);
56058             if (links && links.jsxImplicitImportContainer === false) {
56059                 return undefined;
56060             }
56061             if (links && links.jsxImplicitImportContainer) {
56062                 return links.jsxImplicitImportContainer;
56063             }
56064             var runtimeImportSpecifier = ts.getJSXRuntimeImport(ts.getJSXImplicitImportBase(compilerOptions, file), compilerOptions);
56065             if (!runtimeImportSpecifier) {
56066                 return undefined;
56067             }
56068             var isClassic = ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.Classic;
56069             var errorMessage = isClassic
56070                 ? ts.Diagnostics.Cannot_find_module_0_Did_you_mean_to_set_the_moduleResolution_option_to_node_or_to_add_aliases_to_the_paths_option
56071                 : ts.Diagnostics.Cannot_find_module_0_or_its_corresponding_type_declarations;
56072             var mod = resolveExternalModule(location, runtimeImportSpecifier, errorMessage, location);
56073             var result = mod && mod !== unknownSymbol ? getMergedSymbol(resolveSymbol(mod)) : undefined;
56074             if (links) {
56075                 links.jsxImplicitImportContainer = result || false;
56076             }
56077             return result;
56078         }
56079         function getJsxNamespaceAt(location) {
56080             var links = location && getNodeLinks(location);
56081             if (links && links.jsxNamespace) {
56082                 return links.jsxNamespace;
56083             }
56084             if (!links || links.jsxNamespace !== false) {
56085                 var resolvedNamespace = getJsxNamespaceContainerForImplicitImport(location);
56086                 if (!resolvedNamespace || resolvedNamespace === unknownSymbol) {
56087                     var namespaceName = getJsxNamespace(location);
56088                     resolvedNamespace = resolveName(location, namespaceName, 1920, undefined, namespaceName, false);
56089                 }
56090                 if (resolvedNamespace) {
56091                     var candidate = resolveSymbol(getSymbol(getExportsOfSymbol(resolveSymbol(resolvedNamespace)), JsxNames.JSX, 1920));
56092                     if (candidate && candidate !== unknownSymbol) {
56093                         if (links) {
56094                             links.jsxNamespace = candidate;
56095                         }
56096                         return candidate;
56097                     }
56098                 }
56099                 if (links) {
56100                     links.jsxNamespace = false;
56101                 }
56102             }
56103             var s = resolveSymbol(getGlobalSymbol(JsxNames.JSX, 1920, undefined));
56104             if (s === unknownSymbol) {
56105                 return undefined;
56106             }
56107             return s;
56108         }
56109         function getNameFromJsxElementAttributesContainer(nameOfAttribPropContainer, jsxNamespace) {
56110             var jsxElementAttribPropInterfaceSym = jsxNamespace && getSymbol(jsxNamespace.exports, nameOfAttribPropContainer, 788968);
56111             var jsxElementAttribPropInterfaceType = jsxElementAttribPropInterfaceSym && getDeclaredTypeOfSymbol(jsxElementAttribPropInterfaceSym);
56112             var propertiesOfJsxElementAttribPropInterface = jsxElementAttribPropInterfaceType && getPropertiesOfType(jsxElementAttribPropInterfaceType);
56113             if (propertiesOfJsxElementAttribPropInterface) {
56114                 if (propertiesOfJsxElementAttribPropInterface.length === 0) {
56115                     return "";
56116                 }
56117                 else if (propertiesOfJsxElementAttribPropInterface.length === 1) {
56118                     return propertiesOfJsxElementAttribPropInterface[0].escapedName;
56119                 }
56120                 else if (propertiesOfJsxElementAttribPropInterface.length > 1) {
56121                     error(jsxElementAttribPropInterfaceSym.declarations[0], ts.Diagnostics.The_global_type_JSX_0_may_not_have_more_than_one_property, ts.unescapeLeadingUnderscores(nameOfAttribPropContainer));
56122                 }
56123             }
56124             return undefined;
56125         }
56126         function getJsxLibraryManagedAttributes(jsxNamespace) {
56127             return jsxNamespace && getSymbol(jsxNamespace.exports, JsxNames.LibraryManagedAttributes, 788968);
56128         }
56129         function getJsxElementPropertiesName(jsxNamespace) {
56130             return getNameFromJsxElementAttributesContainer(JsxNames.ElementAttributesPropertyNameContainer, jsxNamespace);
56131         }
56132         function getJsxElementChildrenPropertyName(jsxNamespace) {
56133             return getNameFromJsxElementAttributesContainer(JsxNames.ElementChildrenAttributeNameContainer, jsxNamespace);
56134         }
56135         function getUninstantiatedJsxSignaturesOfType(elementType, caller) {
56136             if (elementType.flags & 4) {
56137                 return [anySignature];
56138             }
56139             else if (elementType.flags & 128) {
56140                 var intrinsicType = getIntrinsicAttributesTypeFromStringLiteralType(elementType, caller);
56141                 if (!intrinsicType) {
56142                     error(caller, ts.Diagnostics.Property_0_does_not_exist_on_type_1, elementType.value, "JSX." + JsxNames.IntrinsicElements);
56143                     return ts.emptyArray;
56144                 }
56145                 else {
56146                     var fakeSignature = createSignatureForJSXIntrinsic(caller, intrinsicType);
56147                     return [fakeSignature];
56148                 }
56149             }
56150             var apparentElemType = getApparentType(elementType);
56151             var signatures = getSignaturesOfType(apparentElemType, 1);
56152             if (signatures.length === 0) {
56153                 signatures = getSignaturesOfType(apparentElemType, 0);
56154             }
56155             if (signatures.length === 0 && apparentElemType.flags & 1048576) {
56156                 signatures = getUnionSignatures(ts.map(apparentElemType.types, function (t) { return getUninstantiatedJsxSignaturesOfType(t, caller); }));
56157             }
56158             return signatures;
56159         }
56160         function getIntrinsicAttributesTypeFromStringLiteralType(type, location) {
56161             var intrinsicElementsType = getJsxType(JsxNames.IntrinsicElements, location);
56162             if (intrinsicElementsType !== errorType) {
56163                 var stringLiteralTypeName = type.value;
56164                 var intrinsicProp = getPropertyOfType(intrinsicElementsType, ts.escapeLeadingUnderscores(stringLiteralTypeName));
56165                 if (intrinsicProp) {
56166                     return getTypeOfSymbol(intrinsicProp);
56167                 }
56168                 var indexSignatureType = getIndexTypeOfType(intrinsicElementsType, 0);
56169                 if (indexSignatureType) {
56170                     return indexSignatureType;
56171                 }
56172                 return undefined;
56173             }
56174             return anyType;
56175         }
56176         function checkJsxReturnAssignableToAppropriateBound(refKind, elemInstanceType, openingLikeElement) {
56177             if (refKind === 1) {
56178                 var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement);
56179                 if (sfcReturnConstraint) {
56180                     checkTypeRelatedTo(elemInstanceType, sfcReturnConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_return_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
56181                 }
56182             }
56183             else if (refKind === 0) {
56184                 var classConstraint = getJsxElementClassTypeAt(openingLikeElement);
56185                 if (classConstraint) {
56186                     checkTypeRelatedTo(elemInstanceType, classConstraint, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_instance_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
56187                 }
56188             }
56189             else {
56190                 var sfcReturnConstraint = getJsxStatelessElementTypeAt(openingLikeElement);
56191                 var classConstraint = getJsxElementClassTypeAt(openingLikeElement);
56192                 if (!sfcReturnConstraint || !classConstraint) {
56193                     return;
56194                 }
56195                 var combined = getUnionType([sfcReturnConstraint, classConstraint]);
56196                 checkTypeRelatedTo(elemInstanceType, combined, assignableRelation, openingLikeElement.tagName, ts.Diagnostics.Its_element_type_0_is_not_a_valid_JSX_element, generateInitialErrorChain);
56197             }
56198             function generateInitialErrorChain() {
56199                 var componentName = ts.getTextOfNode(openingLikeElement.tagName);
56200                 return ts.chainDiagnosticMessages(undefined, ts.Diagnostics._0_cannot_be_used_as_a_JSX_component, componentName);
56201             }
56202         }
56203         function getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node) {
56204             ts.Debug.assert(isJsxIntrinsicIdentifier(node.tagName));
56205             var links = getNodeLinks(node);
56206             if (!links.resolvedJsxElementAttributesType) {
56207                 var symbol = getIntrinsicTagSymbol(node);
56208                 if (links.jsxFlags & 1) {
56209                     return links.resolvedJsxElementAttributesType = getTypeOfSymbol(symbol);
56210                 }
56211                 else if (links.jsxFlags & 2) {
56212                     return links.resolvedJsxElementAttributesType =
56213                         getIndexTypeOfType(getDeclaredTypeOfSymbol(symbol), 0);
56214                 }
56215                 else {
56216                     return links.resolvedJsxElementAttributesType = errorType;
56217                 }
56218             }
56219             return links.resolvedJsxElementAttributesType;
56220         }
56221         function getJsxElementClassTypeAt(location) {
56222             var type = getJsxType(JsxNames.ElementClass, location);
56223             if (type === errorType)
56224                 return undefined;
56225             return type;
56226         }
56227         function getJsxElementTypeAt(location) {
56228             return getJsxType(JsxNames.Element, location);
56229         }
56230         function getJsxStatelessElementTypeAt(location) {
56231             var jsxElementType = getJsxElementTypeAt(location);
56232             if (jsxElementType) {
56233                 return getUnionType([jsxElementType, nullType]);
56234             }
56235         }
56236         function getJsxIntrinsicTagNamesAt(location) {
56237             var intrinsics = getJsxType(JsxNames.IntrinsicElements, location);
56238             return intrinsics ? getPropertiesOfType(intrinsics) : ts.emptyArray;
56239         }
56240         function checkJsxPreconditions(errorNode) {
56241             if ((compilerOptions.jsx || 0) === 0) {
56242                 error(errorNode, ts.Diagnostics.Cannot_use_JSX_unless_the_jsx_flag_is_provided);
56243             }
56244             if (getJsxElementTypeAt(errorNode) === undefined) {
56245                 if (noImplicitAny) {
56246                     error(errorNode, ts.Diagnostics.JSX_element_implicitly_has_type_any_because_the_global_type_JSX_Element_does_not_exist);
56247                 }
56248             }
56249         }
56250         function checkJsxOpeningLikeElementOrOpeningFragment(node) {
56251             var isNodeOpeningLikeElement = ts.isJsxOpeningLikeElement(node);
56252             if (isNodeOpeningLikeElement) {
56253                 checkGrammarJsxElement(node);
56254             }
56255             checkJsxPreconditions(node);
56256             if (!getJsxNamespaceContainerForImplicitImport(node)) {
56257                 var jsxFactoryRefErr = diagnostics && compilerOptions.jsx === 2 ? ts.Diagnostics.Cannot_find_name_0 : undefined;
56258                 var jsxFactoryNamespace = getJsxNamespace(node);
56259                 var jsxFactoryLocation = isNodeOpeningLikeElement ? node.tagName : node;
56260                 var jsxFactorySym = void 0;
56261                 if (!(ts.isJsxOpeningFragment(node) && jsxFactoryNamespace === "null")) {
56262                     jsxFactorySym = resolveName(jsxFactoryLocation, jsxFactoryNamespace, 111551, jsxFactoryRefErr, jsxFactoryNamespace, true);
56263                 }
56264                 if (jsxFactorySym) {
56265                     jsxFactorySym.isReferenced = 67108863;
56266                     if (jsxFactorySym.flags & 2097152 && !getTypeOnlyAliasDeclaration(jsxFactorySym)) {
56267                         markAliasSymbolAsReferenced(jsxFactorySym);
56268                     }
56269                 }
56270             }
56271             if (isNodeOpeningLikeElement) {
56272                 var jsxOpeningLikeNode = node;
56273                 var sig = getResolvedSignature(jsxOpeningLikeNode);
56274                 checkDeprecatedSignature(sig, node);
56275                 checkJsxReturnAssignableToAppropriateBound(getJsxReferenceKind(jsxOpeningLikeNode), getReturnTypeOfSignature(sig), jsxOpeningLikeNode);
56276             }
56277         }
56278         function isKnownProperty(targetType, name, isComparingJsxAttributes) {
56279             if (targetType.flags & 524288) {
56280                 var resolved = resolveStructuredTypeMembers(targetType);
56281                 if (resolved.stringIndexInfo ||
56282                     resolved.numberIndexInfo && isNumericLiteralName(name) ||
56283                     getPropertyOfObjectType(targetType, name) ||
56284                     isComparingJsxAttributes && !isUnhyphenatedJsxName(name)) {
56285                     return true;
56286                 }
56287             }
56288             else if (targetType.flags & 3145728 && isExcessPropertyCheckTarget(targetType)) {
56289                 for (var _i = 0, _a = targetType.types; _i < _a.length; _i++) {
56290                     var t = _a[_i];
56291                     if (isKnownProperty(t, name, isComparingJsxAttributes)) {
56292                         return true;
56293                     }
56294                 }
56295             }
56296             return false;
56297         }
56298         function isExcessPropertyCheckTarget(type) {
56299             return !!(type.flags & 524288 && !(ts.getObjectFlags(type) & 512) ||
56300                 type.flags & 67108864 ||
56301                 type.flags & 1048576 && ts.some(type.types, isExcessPropertyCheckTarget) ||
56302                 type.flags & 2097152 && ts.every(type.types, isExcessPropertyCheckTarget));
56303         }
56304         function checkJsxExpression(node, checkMode) {
56305             checkGrammarJsxExpression(node);
56306             if (node.expression) {
56307                 var type = checkExpression(node.expression, checkMode);
56308                 if (node.dotDotDotToken && type !== anyType && !isArrayType(type)) {
56309                     error(node, ts.Diagnostics.JSX_spread_child_must_be_an_array_type);
56310                 }
56311                 return type;
56312             }
56313             else {
56314                 return errorType;
56315             }
56316         }
56317         function getDeclarationNodeFlagsFromSymbol(s) {
56318             return s.valueDeclaration ? ts.getCombinedNodeFlags(s.valueDeclaration) : 0;
56319         }
56320         function isPrototypeProperty(symbol) {
56321             if (symbol.flags & 8192 || ts.getCheckFlags(symbol) & 4) {
56322                 return true;
56323             }
56324             if (ts.isInJSFile(symbol.valueDeclaration)) {
56325                 var parent = symbol.valueDeclaration.parent;
56326                 return parent && ts.isBinaryExpression(parent) &&
56327                     ts.getAssignmentDeclarationKind(parent) === 3;
56328             }
56329         }
56330         function checkPropertyAccessibility(node, isSuper, type, prop) {
56331             var flags = ts.getDeclarationModifierFlagsFromSymbol(prop);
56332             var errorNode = node.kind === 157 ? node.right : node.kind === 195 ? node : node.name;
56333             if (isSuper) {
56334                 if (languageVersion < 2) {
56335                     if (symbolHasNonMethodDeclaration(prop)) {
56336                         error(errorNode, ts.Diagnostics.Only_public_and_protected_methods_of_the_base_class_are_accessible_via_the_super_keyword);
56337                         return false;
56338                     }
56339                 }
56340                 if (flags & 128) {
56341                     error(errorNode, ts.Diagnostics.Abstract_method_0_in_class_1_cannot_be_accessed_via_super_expression, symbolToString(prop), typeToString(getDeclaringClass(prop)));
56342                     return false;
56343                 }
56344             }
56345             if ((flags & 128) && ts.isThisProperty(node) && symbolHasNonMethodDeclaration(prop)) {
56346                 var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop));
56347                 if (declaringClassDeclaration && isNodeUsedDuringClassInitialization(node)) {
56348                     error(errorNode, ts.Diagnostics.Abstract_property_0_in_class_1_cannot_be_accessed_in_the_constructor, symbolToString(prop), ts.getTextOfIdentifierOrLiteral(declaringClassDeclaration.name));
56349                     return false;
56350                 }
56351             }
56352             if (ts.isPropertyAccessExpression(node) && ts.isPrivateIdentifier(node.name)) {
56353                 if (!ts.getContainingClass(node)) {
56354                     error(errorNode, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
56355                     return false;
56356                 }
56357                 return true;
56358             }
56359             if (!(flags & 24)) {
56360                 return true;
56361             }
56362             if (flags & 8) {
56363                 var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(getParentOfSymbol(prop));
56364                 if (!isNodeWithinClass(node, declaringClassDeclaration)) {
56365                     error(errorNode, ts.Diagnostics.Property_0_is_private_and_only_accessible_within_class_1, symbolToString(prop), typeToString(getDeclaringClass(prop)));
56366                     return false;
56367                 }
56368                 return true;
56369             }
56370             if (isSuper) {
56371                 return true;
56372             }
56373             var enclosingClass = forEachEnclosingClass(node, function (enclosingDeclaration) {
56374                 var enclosingClass = getDeclaredTypeOfSymbol(getSymbolOfNode(enclosingDeclaration));
56375                 return isClassDerivedFromDeclaringClasses(enclosingClass, prop) ? enclosingClass : undefined;
56376             });
56377             if (!enclosingClass) {
56378                 var thisParameter = void 0;
56379                 if (flags & 32 || !(thisParameter = getThisParameterFromNodeContext(node)) || !thisParameter.type) {
56380                     error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_within_class_1_and_its_subclasses, symbolToString(prop), typeToString(getDeclaringClass(prop) || type));
56381                     return false;
56382                 }
56383                 var thisType = getTypeFromTypeNode(thisParameter.type);
56384                 enclosingClass = ((thisType.flags & 262144) ? getConstraintOfTypeParameter(thisType) : thisType).target;
56385             }
56386             if (flags & 32) {
56387                 return true;
56388             }
56389             if (type.flags & 262144) {
56390                 type = type.isThisType ? getConstraintOfTypeParameter(type) : getBaseConstraintOfType(type);
56391             }
56392             if (!type || !hasBaseType(type, enclosingClass)) {
56393                 error(errorNode, ts.Diagnostics.Property_0_is_protected_and_only_accessible_through_an_instance_of_class_1, symbolToString(prop), typeToString(enclosingClass));
56394                 return false;
56395             }
56396             return true;
56397         }
56398         function getThisParameterFromNodeContext(node) {
56399             var thisContainer = ts.getThisContainer(node, false);
56400             return thisContainer && ts.isFunctionLike(thisContainer) ? ts.getThisParameter(thisContainer) : undefined;
56401         }
56402         function symbolHasNonMethodDeclaration(symbol) {
56403             return !!forEachProperty(symbol, function (prop) { return !(prop.flags & 8192); });
56404         }
56405         function checkNonNullExpression(node) {
56406             return checkNonNullType(checkExpression(node), node);
56407         }
56408         function isNullableType(type) {
56409             return !!((strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304);
56410         }
56411         function getNonNullableTypeIfNeeded(type) {
56412             return isNullableType(type) ? getNonNullableType(type) : type;
56413         }
56414         function reportObjectPossiblyNullOrUndefinedError(node, flags) {
56415             error(node, flags & 32768 ? flags & 65536 ?
56416                 ts.Diagnostics.Object_is_possibly_null_or_undefined :
56417                 ts.Diagnostics.Object_is_possibly_undefined :
56418                 ts.Diagnostics.Object_is_possibly_null);
56419         }
56420         function reportCannotInvokePossiblyNullOrUndefinedError(node, flags) {
56421             error(node, flags & 32768 ? flags & 65536 ?
56422                 ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null_or_undefined :
56423                 ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_undefined :
56424                 ts.Diagnostics.Cannot_invoke_an_object_which_is_possibly_null);
56425         }
56426         function checkNonNullTypeWithReporter(type, node, reportError) {
56427             if (strictNullChecks && type.flags & 2) {
56428                 error(node, ts.Diagnostics.Object_is_of_type_unknown);
56429                 return errorType;
56430             }
56431             var kind = (strictNullChecks ? getFalsyFlags(type) : type.flags) & 98304;
56432             if (kind) {
56433                 reportError(node, kind);
56434                 var t = getNonNullableType(type);
56435                 return t.flags & (98304 | 131072) ? errorType : t;
56436             }
56437             return type;
56438         }
56439         function checkNonNullType(type, node) {
56440             return checkNonNullTypeWithReporter(type, node, reportObjectPossiblyNullOrUndefinedError);
56441         }
56442         function checkNonNullNonVoidType(type, node) {
56443             var nonNullType = checkNonNullType(type, node);
56444             if (nonNullType !== errorType && nonNullType.flags & 16384) {
56445                 error(node, ts.Diagnostics.Object_is_possibly_undefined);
56446             }
56447             return nonNullType;
56448         }
56449         function checkPropertyAccessExpression(node) {
56450             return node.flags & 32 ? checkPropertyAccessChain(node) :
56451                 checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullExpression(node.expression), node.name);
56452         }
56453         function checkPropertyAccessChain(node) {
56454             var leftType = checkExpression(node.expression);
56455             var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
56456             return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType);
56457         }
56458         function checkQualifiedName(node) {
56459             return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right);
56460         }
56461         function isMethodAccessForCall(node) {
56462             while (node.parent.kind === 207) {
56463                 node = node.parent;
56464             }
56465             return ts.isCallOrNewExpression(node.parent) && node.parent.expression === node;
56466         }
56467         function lookupSymbolForPrivateIdentifierDeclaration(propName, location) {
56468             for (var containingClass = ts.getContainingClass(location); !!containingClass; containingClass = ts.getContainingClass(containingClass)) {
56469                 var symbol = containingClass.symbol;
56470                 var name = ts.getSymbolNameForPrivateIdentifier(symbol, propName);
56471                 var prop = (symbol.members && symbol.members.get(name)) || (symbol.exports && symbol.exports.get(name));
56472                 if (prop) {
56473                     return prop;
56474                 }
56475             }
56476         }
56477         function getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedIdentifier) {
56478             return getPropertyOfType(leftType, lexicallyScopedIdentifier.escapedName);
56479         }
56480         function checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedIdentifier) {
56481             var propertyOnType;
56482             var properties = getPropertiesOfType(leftType);
56483             if (properties) {
56484                 ts.forEach(properties, function (symbol) {
56485                     var decl = symbol.valueDeclaration;
56486                     if (decl && ts.isNamedDeclaration(decl) && ts.isPrivateIdentifier(decl.name) && decl.name.escapedText === right.escapedText) {
56487                         propertyOnType = symbol;
56488                         return true;
56489                     }
56490                 });
56491             }
56492             var diagName = diagnosticName(right);
56493             if (propertyOnType) {
56494                 var typeValueDecl = propertyOnType.valueDeclaration;
56495                 var typeClass_1 = ts.getContainingClass(typeValueDecl);
56496                 ts.Debug.assert(!!typeClass_1);
56497                 if (lexicallyScopedIdentifier) {
56498                     var lexicalValueDecl = lexicallyScopedIdentifier.valueDeclaration;
56499                     var lexicalClass = ts.getContainingClass(lexicalValueDecl);
56500                     ts.Debug.assert(!!lexicalClass);
56501                     if (ts.findAncestor(lexicalClass, function (n) { return typeClass_1 === n; })) {
56502                         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));
56503                         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));
56504                         return true;
56505                     }
56506                 }
56507                 error(right, ts.Diagnostics.Property_0_is_not_accessible_outside_class_1_because_it_has_a_private_identifier, diagName, diagnosticName(typeClass_1.name || anon));
56508                 return true;
56509             }
56510             return false;
56511         }
56512         function isThisPropertyAccessInConstructor(node, prop) {
56513             return (isConstructorDeclaredProperty(prop) || ts.isThisProperty(node) && isAutoTypedProperty(prop))
56514                 && ts.getThisContainer(node, true) === getDeclaringConstructor(prop);
56515         }
56516         function checkPropertyAccessExpressionOrQualifiedName(node, left, leftType, right) {
56517             var parentSymbol = getNodeLinks(left).resolvedSymbol;
56518             var assignmentKind = ts.getAssignmentTargetKind(node);
56519             var apparentType = getApparentType(assignmentKind !== 0 || isMethodAccessForCall(node) ? getWidenedType(leftType) : leftType);
56520             if (ts.isPrivateIdentifier(right)) {
56521                 checkExternalEmitHelpers(node, 524288);
56522             }
56523             var isAnyLike = isTypeAny(apparentType) || apparentType === silentNeverType;
56524             var prop;
56525             if (ts.isPrivateIdentifier(right)) {
56526                 var lexicallyScopedSymbol = lookupSymbolForPrivateIdentifierDeclaration(right.escapedText, right);
56527                 if (isAnyLike) {
56528                     if (lexicallyScopedSymbol) {
56529                         return apparentType;
56530                     }
56531                     if (!ts.getContainingClass(right)) {
56532                         grammarErrorOnNode(right, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
56533                         return anyType;
56534                     }
56535                 }
56536                 prop = lexicallyScopedSymbol ? getPrivateIdentifierPropertyOfType(leftType, lexicallyScopedSymbol) : undefined;
56537                 if (!prop && checkPrivateIdentifierPropertyAccess(leftType, right, lexicallyScopedSymbol)) {
56538                     return errorType;
56539                 }
56540             }
56541             else {
56542                 if (isAnyLike) {
56543                     if (ts.isIdentifier(left) && parentSymbol) {
56544                         markAliasReferenced(parentSymbol, node);
56545                     }
56546                     return apparentType;
56547                 }
56548                 prop = getPropertyOfType(apparentType, right.escapedText);
56549             }
56550             if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || !(prop && isConstEnumOrConstEnumOnlyModule(prop)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) {
56551                 markAliasReferenced(parentSymbol, node);
56552             }
56553             var propType;
56554             if (!prop) {
56555                 var indexInfo = !ts.isPrivateIdentifier(right) && (assignmentKind === 0 || !isGenericObjectType(leftType) || isThisTypeParameter(leftType)) ? getIndexInfoOfType(apparentType, 0) : undefined;
56556                 if (!(indexInfo && indexInfo.type)) {
56557                     if (isJSLiteralType(leftType)) {
56558                         return anyType;
56559                     }
56560                     if (leftType.symbol === globalThisSymbol) {
56561                         if (globalThisSymbol.exports.has(right.escapedText) && (globalThisSymbol.exports.get(right.escapedText).flags & 418)) {
56562                             error(right, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.unescapeLeadingUnderscores(right.escapedText), typeToString(leftType));
56563                         }
56564                         else if (noImplicitAny) {
56565                             error(right, ts.Diagnostics.Element_implicitly_has_an_any_type_because_type_0_has_no_index_signature, typeToString(leftType));
56566                         }
56567                         return anyType;
56568                     }
56569                     if (right.escapedText && !checkAndReportErrorForExtendingInterface(node)) {
56570                         reportNonexistentProperty(right, isThisTypeParameter(leftType) ? apparentType : leftType);
56571                     }
56572                     return errorType;
56573                 }
56574                 if (indexInfo.isReadonly && (ts.isAssignmentTarget(node) || ts.isDeleteTarget(node))) {
56575                     error(node, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(apparentType));
56576                 }
56577                 propType = (compilerOptions.noUncheckedIndexedAccess && !ts.isAssignmentTarget(node)) ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
56578                 if (compilerOptions.noPropertyAccessFromIndexSignature && ts.isPropertyAccessExpression(node)) {
56579                     error(right, ts.Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, ts.unescapeLeadingUnderscores(right.escapedText));
56580                 }
56581             }
56582             else {
56583                 if (getDeclarationNodeFlagsFromSymbol(prop) & 134217728 && isUncalledFunctionReference(node, prop)) {
56584                     addDeprecatedSuggestion(right, prop.declarations, right.escapedText);
56585                 }
56586                 checkPropertyNotUsedBeforeDeclaration(prop, node, right);
56587                 markPropertyAsReferenced(prop, node, left.kind === 107);
56588                 getNodeLinks(node).resolvedSymbol = prop;
56589                 checkPropertyAccessibility(node, left.kind === 105, apparentType, prop);
56590                 if (isAssignmentToReadonlyEntity(node, prop, assignmentKind)) {
56591                     error(right, ts.Diagnostics.Cannot_assign_to_0_because_it_is_a_read_only_property, ts.idText(right));
56592                     return errorType;
56593                 }
56594                 propType = isThisPropertyAccessInConstructor(node, prop) ? autoType : getConstraintForLocation(getTypeOfSymbol(prop), node);
56595             }
56596             return getFlowTypeOfAccessExpression(node, prop, propType, right);
56597         }
56598         function getFlowTypeOfAccessExpression(node, prop, propType, errorNode) {
56599             var assignmentKind = ts.getAssignmentTargetKind(node);
56600             if (assignmentKind === 1 ||
56601                 prop && !(prop.flags & (3 | 4 | 98304)) && !(prop.flags & 8192 && propType.flags & 1048576)) {
56602                 return propType;
56603             }
56604             if (propType === autoType) {
56605                 return getFlowTypeOfProperty(node, prop);
56606             }
56607             var assumeUninitialized = false;
56608             if (strictNullChecks && strictPropertyInitialization && ts.isAccessExpression(node) && node.expression.kind === 107) {
56609                 var declaration = prop && prop.valueDeclaration;
56610                 if (declaration && isInstancePropertyWithoutInitializer(declaration)) {
56611                     var flowContainer = getControlFlowContainer(node);
56612                     if (flowContainer.kind === 166 && flowContainer.parent === declaration.parent && !(declaration.flags & 8388608)) {
56613                         assumeUninitialized = true;
56614                     }
56615                 }
56616             }
56617             else if (strictNullChecks && prop && prop.valueDeclaration &&
56618                 ts.isPropertyAccessExpression(prop.valueDeclaration) &&
56619                 ts.getAssignmentDeclarationPropertyAccessKind(prop.valueDeclaration) &&
56620                 getControlFlowContainer(node) === getControlFlowContainer(prop.valueDeclaration)) {
56621                 assumeUninitialized = true;
56622             }
56623             var flowType = getFlowTypeOfReference(node, propType, assumeUninitialized ? getOptionalType(propType) : propType);
56624             if (assumeUninitialized && !(getFalsyFlags(propType) & 32768) && getFalsyFlags(flowType) & 32768) {
56625                 error(errorNode, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(prop));
56626                 return propType;
56627             }
56628             return assignmentKind ? getBaseTypeOfLiteralType(flowType) : flowType;
56629         }
56630         function checkPropertyNotUsedBeforeDeclaration(prop, node, right) {
56631             var valueDeclaration = prop.valueDeclaration;
56632             if (!valueDeclaration || ts.getSourceFileOfNode(node).isDeclarationFile) {
56633                 return;
56634             }
56635             var diagnosticMessage;
56636             var declarationName = ts.idText(right);
56637             if (isInPropertyInitializer(node)
56638                 && !(ts.isAccessExpression(node) && ts.isAccessExpression(node.expression))
56639                 && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)
56640                 && !isPropertyDeclaredInAncestorClass(prop)) {
56641                 diagnosticMessage = error(right, ts.Diagnostics.Property_0_is_used_before_its_initialization, declarationName);
56642             }
56643             else if (valueDeclaration.kind === 252 &&
56644                 node.parent.kind !== 173 &&
56645                 !(valueDeclaration.flags & 8388608) &&
56646                 !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
56647                 diagnosticMessage = error(right, ts.Diagnostics.Class_0_used_before_its_declaration, declarationName);
56648             }
56649             if (diagnosticMessage) {
56650                 ts.addRelatedInfo(diagnosticMessage, ts.createDiagnosticForNode(valueDeclaration, ts.Diagnostics._0_is_declared_here, declarationName));
56651             }
56652         }
56653         function isInPropertyInitializer(node) {
56654             return !!ts.findAncestor(node, function (node) {
56655                 switch (node.kind) {
56656                     case 163:
56657                         return true;
56658                     case 288:
56659                     case 165:
56660                     case 167:
56661                     case 168:
56662                     case 290:
56663                     case 158:
56664                     case 228:
56665                     case 283:
56666                     case 280:
56667                     case 281:
56668                     case 282:
56669                     case 275:
56670                     case 223:
56671                     case 286:
56672                         return false;
56673                     default:
56674                         return ts.isExpressionNode(node) ? false : "quit";
56675                 }
56676             });
56677         }
56678         function isPropertyDeclaredInAncestorClass(prop) {
56679             if (!(prop.parent.flags & 32)) {
56680                 return false;
56681             }
56682             var classType = getTypeOfSymbol(prop.parent);
56683             while (true) {
56684                 classType = classType.symbol && getSuperClass(classType);
56685                 if (!classType) {
56686                     return false;
56687                 }
56688                 var superProperty = getPropertyOfType(classType, prop.escapedName);
56689                 if (superProperty && superProperty.valueDeclaration) {
56690                     return true;
56691                 }
56692             }
56693         }
56694         function getSuperClass(classType) {
56695             var x = getBaseTypes(classType);
56696             if (x.length === 0) {
56697                 return undefined;
56698             }
56699             return getIntersectionType(x);
56700         }
56701         function reportNonexistentProperty(propNode, containingType) {
56702             var errorInfo;
56703             var relatedInfo;
56704             if (!ts.isPrivateIdentifier(propNode) && containingType.flags & 1048576 && !(containingType.flags & 131068)) {
56705                 for (var _i = 0, _a = containingType.types; _i < _a.length; _i++) {
56706                     var subtype = _a[_i];
56707                     if (!getPropertyOfType(subtype, propNode.escapedText) && !getIndexInfoOfType(subtype, 0)) {
56708                         errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(subtype));
56709                         break;
56710                     }
56711                 }
56712             }
56713             if (typeHasStaticProperty(propNode.escapedText, containingType)) {
56714                 var propName = ts.declarationNameToString(propNode);
56715                 var typeName = typeToString(containingType);
56716                 errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_to_access_the_static_member_2_instead, propName, typeName, typeName + "." + propName);
56717             }
56718             else {
56719                 var promisedType = getPromisedTypeOfPromise(containingType);
56720                 if (promisedType && getPropertyOfType(promisedType, propNode.escapedText)) {
56721                     errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1, ts.declarationNameToString(propNode), typeToString(containingType));
56722                     relatedInfo = ts.createDiagnosticForNode(propNode, ts.Diagnostics.Did_you_forget_to_use_await);
56723                 }
56724                 else {
56725                     var missingProperty = ts.declarationNameToString(propNode);
56726                     var container = typeToString(containingType);
56727                     var libSuggestion = getSuggestedLibForNonExistentProperty(missingProperty, containingType);
56728                     if (libSuggestion !== undefined) {
56729                         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);
56730                     }
56731                     else {
56732                         var suggestion = getSuggestedSymbolForNonexistentProperty(propNode, containingType);
56733                         if (suggestion !== undefined) {
56734                             var suggestedName = ts.symbolName(suggestion);
56735                             errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Property_0_does_not_exist_on_type_1_Did_you_mean_2, missingProperty, container, suggestedName);
56736                             relatedInfo = suggestion.valueDeclaration && ts.createDiagnosticForNode(suggestion.valueDeclaration, ts.Diagnostics._0_is_declared_here, suggestedName);
56737                         }
56738                         else {
56739                             errorInfo = ts.chainDiagnosticMessages(elaborateNeverIntersection(errorInfo, containingType), ts.Diagnostics.Property_0_does_not_exist_on_type_1, missingProperty, container);
56740                         }
56741                     }
56742                 }
56743             }
56744             var resultDiagnostic = ts.createDiagnosticForNodeFromMessageChain(propNode, errorInfo);
56745             if (relatedInfo) {
56746                 ts.addRelatedInfo(resultDiagnostic, relatedInfo);
56747             }
56748             diagnostics.add(resultDiagnostic);
56749         }
56750         function typeHasStaticProperty(propName, containingType) {
56751             var prop = containingType.symbol && getPropertyOfType(getTypeOfSymbol(containingType.symbol), propName);
56752             return prop !== undefined && prop.valueDeclaration && ts.hasSyntacticModifier(prop.valueDeclaration, 32);
56753         }
56754         function getSuggestedLibForNonExistentName(name) {
56755             var missingName = diagnosticName(name);
56756             var allFeatures = ts.getScriptTargetFeatures();
56757             var libTargets = ts.getOwnKeys(allFeatures);
56758             for (var _i = 0, libTargets_1 = libTargets; _i < libTargets_1.length; _i++) {
56759                 var libTarget = libTargets_1[_i];
56760                 var containingTypes = ts.getOwnKeys(allFeatures[libTarget]);
56761                 if (containingTypes !== undefined && ts.contains(containingTypes, missingName)) {
56762                     return libTarget;
56763                 }
56764             }
56765         }
56766         function getSuggestedLibForNonExistentProperty(missingProperty, containingType) {
56767             var container = getApparentType(containingType).symbol;
56768             if (!container) {
56769                 return undefined;
56770             }
56771             var allFeatures = ts.getScriptTargetFeatures();
56772             var libTargets = ts.getOwnKeys(allFeatures);
56773             for (var _i = 0, libTargets_2 = libTargets; _i < libTargets_2.length; _i++) {
56774                 var libTarget = libTargets_2[_i];
56775                 var featuresOfLib = allFeatures[libTarget];
56776                 var featuresOfContainingType = featuresOfLib[ts.symbolName(container)];
56777                 if (featuresOfContainingType !== undefined && ts.contains(featuresOfContainingType, missingProperty)) {
56778                     return libTarget;
56779                 }
56780             }
56781         }
56782         function getSuggestedSymbolForNonexistentProperty(name, containingType) {
56783             return getSpellingSuggestionForName(ts.isString(name) ? name : ts.idText(name), getPropertiesOfType(containingType), 111551);
56784         }
56785         function getSuggestedSymbolForNonexistentJSXAttribute(name, containingType) {
56786             var strName = ts.isString(name) ? name : ts.idText(name);
56787             var properties = getPropertiesOfType(containingType);
56788             var jsxSpecific = strName === "for" ? ts.find(properties, function (x) { return ts.symbolName(x) === "htmlFor"; })
56789                 : strName === "class" ? ts.find(properties, function (x) { return ts.symbolName(x) === "className"; })
56790                     : undefined;
56791             return jsxSpecific !== null && jsxSpecific !== void 0 ? jsxSpecific : getSpellingSuggestionForName(strName, properties, 111551);
56792         }
56793         function getSuggestionForNonexistentProperty(name, containingType) {
56794             var suggestion = getSuggestedSymbolForNonexistentProperty(name, containingType);
56795             return suggestion && ts.symbolName(suggestion);
56796         }
56797         function getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning) {
56798             ts.Debug.assert(outerName !== undefined, "outername should always be defined");
56799             var result = resolveNameHelper(location, outerName, meaning, undefined, outerName, false, false, function (symbols, name, meaning) {
56800                 ts.Debug.assertEqual(outerName, name, "name should equal outerName");
56801                 var symbol = getSymbol(symbols, name, meaning);
56802                 return symbol || getSpellingSuggestionForName(ts.unescapeLeadingUnderscores(name), ts.arrayFrom(symbols.values()), meaning);
56803             });
56804             return result;
56805         }
56806         function getSuggestionForNonexistentSymbol(location, outerName, meaning) {
56807             var symbolResult = getSuggestedSymbolForNonexistentSymbol(location, outerName, meaning);
56808             return symbolResult && ts.symbolName(symbolResult);
56809         }
56810         function getSuggestedSymbolForNonexistentModule(name, targetModule) {
56811             return targetModule.exports && getSpellingSuggestionForName(ts.idText(name), getExportsOfModuleAsArray(targetModule), 2623475);
56812         }
56813         function getSuggestionForNonexistentExport(name, targetModule) {
56814             var suggestion = getSuggestedSymbolForNonexistentModule(name, targetModule);
56815             return suggestion && ts.symbolName(suggestion);
56816         }
56817         function getSuggestionForNonexistentIndexSignature(objectType, expr, keyedType) {
56818             function hasProp(name) {
56819                 var prop = getPropertyOfObjectType(objectType, name);
56820                 if (prop) {
56821                     var s = getSingleCallSignature(getTypeOfSymbol(prop));
56822                     return !!s && getMinArgumentCount(s) >= 1 && isTypeAssignableTo(keyedType, getTypeAtPosition(s, 0));
56823                 }
56824                 return false;
56825             }
56826             ;
56827             var suggestedMethod = ts.isAssignmentTarget(expr) ? "set" : "get";
56828             if (!hasProp(suggestedMethod)) {
56829                 return undefined;
56830             }
56831             var suggestion = ts.tryGetPropertyAccessOrIdentifierToString(expr.expression);
56832             if (suggestion === undefined) {
56833                 suggestion = suggestedMethod;
56834             }
56835             else {
56836                 suggestion += "." + suggestedMethod;
56837             }
56838             return suggestion;
56839         }
56840         function getSpellingSuggestionForName(name, symbols, meaning) {
56841             return ts.getSpellingSuggestion(name, symbols, getCandidateName);
56842             function getCandidateName(candidate) {
56843                 var candidateName = ts.symbolName(candidate);
56844                 if (ts.startsWith(candidateName, "\"")) {
56845                     return undefined;
56846                 }
56847                 if (candidate.flags & meaning) {
56848                     return candidateName;
56849                 }
56850                 if (candidate.flags & 2097152) {
56851                     var alias = tryResolveAlias(candidate);
56852                     if (alias && alias.flags & meaning) {
56853                         return candidateName;
56854                     }
56855                 }
56856                 return undefined;
56857             }
56858         }
56859         function markPropertyAsReferenced(prop, nodeForCheckWriteOnly, isThisAccess) {
56860             var valueDeclaration = prop && (prop.flags & 106500) && prop.valueDeclaration;
56861             if (!valueDeclaration) {
56862                 return;
56863             }
56864             var hasPrivateModifier = ts.hasEffectiveModifier(valueDeclaration, 8);
56865             var hasPrivateIdentifier = ts.isNamedDeclaration(prop.valueDeclaration) && ts.isPrivateIdentifier(prop.valueDeclaration.name);
56866             if (!hasPrivateModifier && !hasPrivateIdentifier) {
56867                 return;
56868             }
56869             if (nodeForCheckWriteOnly && ts.isWriteOnlyAccess(nodeForCheckWriteOnly) && !(prop.flags & 65536)) {
56870                 return;
56871             }
56872             if (isThisAccess) {
56873                 var containingMethod = ts.findAncestor(nodeForCheckWriteOnly, ts.isFunctionLikeDeclaration);
56874                 if (containingMethod && containingMethod.symbol === prop) {
56875                     return;
56876                 }
56877             }
56878             (ts.getCheckFlags(prop) & 1 ? getSymbolLinks(prop).target : prop).isReferenced = 67108863;
56879         }
56880         function isValidPropertyAccess(node, propertyName) {
56881             switch (node.kind) {
56882                 case 201:
56883                     return isValidPropertyAccessWithType(node, node.expression.kind === 105, propertyName, getWidenedType(checkExpression(node.expression)));
56884                 case 157:
56885                     return isValidPropertyAccessWithType(node, false, propertyName, getWidenedType(checkExpression(node.left)));
56886                 case 195:
56887                     return isValidPropertyAccessWithType(node, false, propertyName, getTypeFromTypeNode(node));
56888             }
56889         }
56890         function isValidPropertyAccessForCompletions(node, type, property) {
56891             return isValidPropertyAccessWithType(node, node.kind === 201 && node.expression.kind === 105, property.escapedName, type);
56892         }
56893         function isValidPropertyAccessWithType(node, isSuper, propertyName, type) {
56894             if (type === errorType || isTypeAny(type)) {
56895                 return true;
56896             }
56897             var prop = getPropertyOfType(type, propertyName);
56898             if (prop) {
56899                 if (ts.isPropertyAccessExpression(node) && prop.valueDeclaration && ts.isPrivateIdentifierPropertyDeclaration(prop.valueDeclaration)) {
56900                     var declClass_1 = ts.getContainingClass(prop.valueDeclaration);
56901                     return !ts.isOptionalChain(node) && !!ts.findAncestor(node, function (parent) { return parent === declClass_1; });
56902                 }
56903                 return checkPropertyAccessibility(node, isSuper, type, prop);
56904             }
56905             return ts.isInJSFile(node) && (type.flags & 1048576) !== 0 && type.types.some(function (elementType) { return isValidPropertyAccessWithType(node, isSuper, propertyName, elementType); });
56906         }
56907         function getForInVariableSymbol(node) {
56908             var initializer = node.initializer;
56909             if (initializer.kind === 250) {
56910                 var variable = initializer.declarations[0];
56911                 if (variable && !ts.isBindingPattern(variable.name)) {
56912                     return getSymbolOfNode(variable);
56913                 }
56914             }
56915             else if (initializer.kind === 78) {
56916                 return getResolvedSymbol(initializer);
56917             }
56918             return undefined;
56919         }
56920         function hasNumericPropertyNames(type) {
56921             return getIndexTypeOfType(type, 1) && !getIndexTypeOfType(type, 0);
56922         }
56923         function isForInVariableForNumericPropertyNames(expr) {
56924             var e = ts.skipParentheses(expr);
56925             if (e.kind === 78) {
56926                 var symbol = getResolvedSymbol(e);
56927                 if (symbol.flags & 3) {
56928                     var child = expr;
56929                     var node = expr.parent;
56930                     while (node) {
56931                         if (node.kind === 238 &&
56932                             child === node.statement &&
56933                             getForInVariableSymbol(node) === symbol &&
56934                             hasNumericPropertyNames(getTypeOfExpression(node.expression))) {
56935                             return true;
56936                         }
56937                         child = node;
56938                         node = node.parent;
56939                     }
56940                 }
56941             }
56942             return false;
56943         }
56944         function checkIndexedAccess(node) {
56945             return node.flags & 32 ? checkElementAccessChain(node) :
56946                 checkElementAccessExpression(node, checkNonNullExpression(node.expression));
56947         }
56948         function checkElementAccessChain(node) {
56949             var exprType = checkExpression(node.expression);
56950             var nonOptionalType = getOptionalExpressionType(exprType, node.expression);
56951             return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType);
56952         }
56953         function checkElementAccessExpression(node, exprType) {
56954             var objectType = ts.getAssignmentTargetKind(node) !== 0 || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
56955             var indexExpression = node.argumentExpression;
56956             var indexType = checkExpression(indexExpression);
56957             if (objectType === errorType || objectType === silentNeverType) {
56958                 return objectType;
56959             }
56960             if (isConstEnumObjectType(objectType) && !ts.isStringLiteralLike(indexExpression)) {
56961                 error(indexExpression, ts.Diagnostics.A_const_enum_member_can_only_be_accessed_using_a_string_literal);
56962                 return errorType;
56963             }
56964             var effectiveIndexType = isForInVariableForNumericPropertyNames(indexExpression) ? numberType : indexType;
56965             var accessFlags = ts.isAssignmentTarget(node) ?
56966                 2 | (isGenericObjectType(objectType) && !isThisTypeParameter(objectType) ? 1 : 0) :
56967                 0;
56968             var indexedAccessType = getIndexedAccessTypeOrUndefined(objectType, effectiveIndexType, undefined, node, accessFlags | 16) || errorType;
56969             return checkIndexedAccessIndexType(getFlowTypeOfAccessExpression(node, indexedAccessType.symbol, indexedAccessType, indexExpression), node);
56970         }
56971         function checkThatExpressionIsProperSymbolReference(expression, expressionType, reportError) {
56972             if (expressionType === errorType) {
56973                 return false;
56974             }
56975             if (!ts.isWellKnownSymbolSyntactically(expression)) {
56976                 return false;
56977             }
56978             if ((expressionType.flags & 12288) === 0) {
56979                 if (reportError) {
56980                     error(expression, ts.Diagnostics.A_computed_property_name_of_the_form_0_must_be_of_type_symbol, ts.getTextOfNode(expression));
56981                 }
56982                 return false;
56983             }
56984             var leftHandSide = expression.expression;
56985             var leftHandSideSymbol = getResolvedSymbol(leftHandSide);
56986             if (!leftHandSideSymbol) {
56987                 return false;
56988             }
56989             var globalESSymbol = getGlobalESSymbolConstructorSymbol(true);
56990             if (!globalESSymbol) {
56991                 return false;
56992             }
56993             if (leftHandSideSymbol !== globalESSymbol) {
56994                 if (reportError) {
56995                     error(leftHandSide, ts.Diagnostics.Symbol_reference_does_not_refer_to_the_global_Symbol_constructor_object);
56996                 }
56997                 return false;
56998             }
56999             return true;
57000         }
57001         function callLikeExpressionMayHaveTypeArguments(node) {
57002             return ts.isCallOrNewExpression(node) || ts.isTaggedTemplateExpression(node) || ts.isJsxOpeningLikeElement(node);
57003         }
57004         function resolveUntypedCall(node) {
57005             if (callLikeExpressionMayHaveTypeArguments(node)) {
57006                 ts.forEach(node.typeArguments, checkSourceElement);
57007             }
57008             if (node.kind === 205) {
57009                 checkExpression(node.template);
57010             }
57011             else if (ts.isJsxOpeningLikeElement(node)) {
57012                 checkExpression(node.attributes);
57013             }
57014             else if (node.kind !== 161) {
57015                 ts.forEach(node.arguments, function (argument) {
57016                     checkExpression(argument);
57017                 });
57018             }
57019             return anySignature;
57020         }
57021         function resolveErrorCall(node) {
57022             resolveUntypedCall(node);
57023             return unknownSignature;
57024         }
57025         function reorderCandidates(signatures, result, callChainFlags) {
57026             var lastParent;
57027             var lastSymbol;
57028             var cutoffIndex = 0;
57029             var index;
57030             var specializedIndex = -1;
57031             var spliceIndex;
57032             ts.Debug.assert(!result.length);
57033             for (var _i = 0, signatures_7 = signatures; _i < signatures_7.length; _i++) {
57034                 var signature = signatures_7[_i];
57035                 var symbol = signature.declaration && getSymbolOfNode(signature.declaration);
57036                 var parent = signature.declaration && signature.declaration.parent;
57037                 if (!lastSymbol || symbol === lastSymbol) {
57038                     if (lastParent && parent === lastParent) {
57039                         index = index + 1;
57040                     }
57041                     else {
57042                         lastParent = parent;
57043                         index = cutoffIndex;
57044                     }
57045                 }
57046                 else {
57047                     index = cutoffIndex = result.length;
57048                     lastParent = parent;
57049                 }
57050                 lastSymbol = symbol;
57051                 if (signatureHasLiteralTypes(signature)) {
57052                     specializedIndex++;
57053                     spliceIndex = specializedIndex;
57054                     cutoffIndex++;
57055                 }
57056                 else {
57057                     spliceIndex = index;
57058                 }
57059                 result.splice(spliceIndex, 0, callChainFlags ? getOptionalCallSignature(signature, callChainFlags) : signature);
57060             }
57061         }
57062         function isSpreadArgument(arg) {
57063             return !!arg && (arg.kind === 220 || arg.kind === 227 && arg.isSpread);
57064         }
57065         function getSpreadArgumentIndex(args) {
57066             return ts.findIndex(args, isSpreadArgument);
57067         }
57068         function acceptsVoid(t) {
57069             return !!(t.flags & 16384);
57070         }
57071         function acceptsVoidUndefinedUnknownOrAny(t) {
57072             return !!(t.flags & (16384 | 32768 | 2 | 1));
57073         }
57074         function hasCorrectArity(node, args, signature, signatureHelpTrailingComma) {
57075             if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; }
57076             var argCount;
57077             var callIsIncomplete = false;
57078             var effectiveParameterCount = getParameterCount(signature);
57079             var effectiveMinimumArguments = getMinArgumentCount(signature);
57080             if (node.kind === 205) {
57081                 argCount = args.length;
57082                 if (node.template.kind === 218) {
57083                     var lastSpan = ts.last(node.template.templateSpans);
57084                     callIsIncomplete = ts.nodeIsMissing(lastSpan.literal) || !!lastSpan.literal.isUnterminated;
57085                 }
57086                 else {
57087                     var templateLiteral = node.template;
57088                     ts.Debug.assert(templateLiteral.kind === 14);
57089                     callIsIncomplete = !!templateLiteral.isUnterminated;
57090                 }
57091             }
57092             else if (node.kind === 161) {
57093                 argCount = getDecoratorArgumentCount(node, signature);
57094             }
57095             else if (ts.isJsxOpeningLikeElement(node)) {
57096                 callIsIncomplete = node.attributes.end === node.end;
57097                 if (callIsIncomplete) {
57098                     return true;
57099                 }
57100                 argCount = effectiveMinimumArguments === 0 ? args.length : 1;
57101                 effectiveParameterCount = args.length === 0 ? effectiveParameterCount : 1;
57102                 effectiveMinimumArguments = Math.min(effectiveMinimumArguments, 1);
57103             }
57104             else if (!node.arguments) {
57105                 ts.Debug.assert(node.kind === 204);
57106                 return getMinArgumentCount(signature) === 0;
57107             }
57108             else {
57109                 argCount = signatureHelpTrailingComma ? args.length + 1 : args.length;
57110                 callIsIncomplete = node.arguments.end === node.end;
57111                 var spreadArgIndex = getSpreadArgumentIndex(args);
57112                 if (spreadArgIndex >= 0) {
57113                     return spreadArgIndex >= getMinArgumentCount(signature) && (hasEffectiveRestParameter(signature) || spreadArgIndex < getParameterCount(signature));
57114                 }
57115             }
57116             if (!hasEffectiveRestParameter(signature) && argCount > effectiveParameterCount) {
57117                 return false;
57118             }
57119             if (callIsIncomplete || argCount >= effectiveMinimumArguments) {
57120                 return true;
57121             }
57122             for (var i = argCount; i < effectiveMinimumArguments; i++) {
57123                 var type = getTypeAtPosition(signature, i);
57124                 if (filterType(type, ts.isInJSFile(node) && !strictNullChecks ? acceptsVoidUndefinedUnknownOrAny : acceptsVoid).flags & 131072) {
57125                     return false;
57126                 }
57127             }
57128             return true;
57129         }
57130         function hasCorrectTypeArgumentArity(signature, typeArguments) {
57131             var numTypeParameters = ts.length(signature.typeParameters);
57132             var minTypeArgumentCount = getMinTypeArgumentCount(signature.typeParameters);
57133             return !ts.some(typeArguments) ||
57134                 (typeArguments.length >= minTypeArgumentCount && typeArguments.length <= numTypeParameters);
57135         }
57136         function getSingleCallSignature(type) {
57137             return getSingleSignature(type, 0, false);
57138         }
57139         function getSingleCallOrConstructSignature(type) {
57140             return getSingleSignature(type, 0, false) ||
57141                 getSingleSignature(type, 1, false);
57142         }
57143         function getSingleSignature(type, kind, allowMembers) {
57144             if (type.flags & 524288) {
57145                 var resolved = resolveStructuredTypeMembers(type);
57146                 if (allowMembers || resolved.properties.length === 0 && !resolved.stringIndexInfo && !resolved.numberIndexInfo) {
57147                     if (kind === 0 && resolved.callSignatures.length === 1 && resolved.constructSignatures.length === 0) {
57148                         return resolved.callSignatures[0];
57149                     }
57150                     if (kind === 1 && resolved.constructSignatures.length === 1 && resolved.callSignatures.length === 0) {
57151                         return resolved.constructSignatures[0];
57152                     }
57153                 }
57154             }
57155             return undefined;
57156         }
57157         function instantiateSignatureInContextOf(signature, contextualSignature, inferenceContext, compareTypes) {
57158             var context = createInferenceContext(signature.typeParameters, signature, 0, compareTypes);
57159             var restType = getEffectiveRestType(contextualSignature);
57160             var mapper = inferenceContext && (restType && restType.flags & 262144 ? inferenceContext.nonFixingMapper : inferenceContext.mapper);
57161             var sourceSignature = mapper ? instantiateSignature(contextualSignature, mapper) : contextualSignature;
57162             applyToParameterTypes(sourceSignature, signature, function (source, target) {
57163                 inferTypes(context.inferences, source, target);
57164             });
57165             if (!inferenceContext) {
57166                 applyToReturnTypes(contextualSignature, signature, function (source, target) {
57167                     inferTypes(context.inferences, source, target, 64);
57168                 });
57169             }
57170             return getSignatureInstantiation(signature, getInferredTypes(context), ts.isInJSFile(contextualSignature.declaration));
57171         }
57172         function inferJsxTypeArguments(node, signature, checkMode, context) {
57173             var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node);
57174             var checkAttrType = checkExpressionWithContextualType(node.attributes, paramType, context, checkMode);
57175             inferTypes(context.inferences, checkAttrType, paramType);
57176             return getInferredTypes(context);
57177         }
57178         function getThisArgumentType(thisArgumentNode) {
57179             if (!thisArgumentNode) {
57180                 return voidType;
57181             }
57182             var thisArgumentType = checkExpression(thisArgumentNode);
57183             return ts.isOptionalChainRoot(thisArgumentNode.parent) ? getNonNullableType(thisArgumentType) :
57184                 ts.isOptionalChain(thisArgumentNode.parent) ? removeOptionalTypeMarker(thisArgumentType) :
57185                     thisArgumentType;
57186         }
57187         function inferTypeArguments(node, signature, args, checkMode, context) {
57188             if (ts.isJsxOpeningLikeElement(node)) {
57189                 return inferJsxTypeArguments(node, signature, checkMode, context);
57190             }
57191             if (node.kind !== 161) {
57192                 var contextualType = getContextualType(node, ts.every(signature.typeParameters, function (p) { return !!getDefaultFromTypeParameter(p); }) ? 8 : 0);
57193                 if (contextualType) {
57194                     var outerContext = getInferenceContext(node);
57195                     var outerMapper = getMapperFromContext(cloneInferenceContext(outerContext, 1));
57196                     var instantiatedType = instantiateType(contextualType, outerMapper);
57197                     var contextualSignature = getSingleCallSignature(instantiatedType);
57198                     var inferenceSourceType = contextualSignature && contextualSignature.typeParameters ?
57199                         getOrCreateTypeFromSignature(getSignatureInstantiationWithoutFillingInTypeArguments(contextualSignature, contextualSignature.typeParameters)) :
57200                         instantiatedType;
57201                     var inferenceTargetType = getReturnTypeOfSignature(signature);
57202                     inferTypes(context.inferences, inferenceSourceType, inferenceTargetType, 64);
57203                     var returnContext = createInferenceContext(signature.typeParameters, signature, context.flags);
57204                     var returnSourceType = instantiateType(contextualType, outerContext && outerContext.returnMapper);
57205                     inferTypes(returnContext.inferences, returnSourceType, inferenceTargetType);
57206                     context.returnMapper = ts.some(returnContext.inferences, hasInferenceCandidates) ? getMapperFromContext(cloneInferredPartOfContext(returnContext)) : undefined;
57207                 }
57208             }
57209             var restType = getNonArrayRestType(signature);
57210             var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length;
57211             if (restType && restType.flags & 262144) {
57212                 var info = ts.find(context.inferences, function (info) { return info.typeParameter === restType; });
57213                 if (info) {
57214                     info.impliedArity = ts.findIndex(args, isSpreadArgument, argCount) < 0 ? args.length - argCount : undefined;
57215                 }
57216             }
57217             var thisType = getThisTypeOfSignature(signature);
57218             if (thisType) {
57219                 var thisArgumentNode = getThisArgumentOfCall(node);
57220                 inferTypes(context.inferences, getThisArgumentType(thisArgumentNode), thisType);
57221             }
57222             for (var i = 0; i < argCount; i++) {
57223                 var arg = args[i];
57224                 if (arg.kind !== 222) {
57225                     var paramType = getTypeAtPosition(signature, i);
57226                     var argType = checkExpressionWithContextualType(arg, paramType, context, checkMode);
57227                     inferTypes(context.inferences, argType, paramType);
57228                 }
57229             }
57230             if (restType) {
57231                 var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, context, checkMode);
57232                 inferTypes(context.inferences, spreadType, restType);
57233             }
57234             return getInferredTypes(context);
57235         }
57236         function getMutableArrayOrTupleType(type) {
57237             return type.flags & 1048576 ? mapType(type, getMutableArrayOrTupleType) :
57238                 type.flags & 1 || isMutableArrayOrTuple(getBaseConstraintOfType(type) || type) ? type :
57239                     isTupleType(type) ? createTupleType(getTypeArguments(type), type.target.elementFlags, false, type.target.labeledElementDeclarations) :
57240                         createTupleType([type], [8]);
57241         }
57242         function getSpreadArgumentType(args, index, argCount, restType, context, checkMode) {
57243             if (index >= argCount - 1) {
57244                 var arg = args[argCount - 1];
57245                 if (isSpreadArgument(arg)) {
57246                     return getMutableArrayOrTupleType(arg.kind === 227 ? arg.type :
57247                         checkExpressionWithContextualType(arg.expression, restType, context, checkMode));
57248                 }
57249             }
57250             var types = [];
57251             var flags = [];
57252             var names = [];
57253             for (var i = index; i < argCount; i++) {
57254                 var arg = args[i];
57255                 if (isSpreadArgument(arg)) {
57256                     var spreadType = arg.kind === 227 ? arg.type : checkExpression(arg.expression);
57257                     if (isArrayLikeType(spreadType)) {
57258                         types.push(spreadType);
57259                         flags.push(8);
57260                     }
57261                     else {
57262                         types.push(checkIteratedTypeOrElementType(33, spreadType, undefinedType, arg.kind === 220 ? arg.expression : arg));
57263                         flags.push(4);
57264                     }
57265                 }
57266                 else {
57267                     var contextualType = getIndexedAccessType(restType, getLiteralType(i - index));
57268                     var argType = checkExpressionWithContextualType(arg, contextualType, context, checkMode);
57269                     var hasPrimitiveContextualType = maybeTypeOfKind(contextualType, 131068 | 4194304 | 134217728 | 268435456);
57270                     types.push(hasPrimitiveContextualType ? getRegularTypeOfLiteralType(argType) : getWidenedLiteralType(argType));
57271                     flags.push(1);
57272                 }
57273                 if (arg.kind === 227 && arg.tupleNameSource) {
57274                     names.push(arg.tupleNameSource);
57275                 }
57276             }
57277             return createTupleType(types, flags, false, ts.length(names) === ts.length(types) ? names : undefined);
57278         }
57279         function checkTypeArguments(signature, typeArgumentNodes, reportErrors, headMessage) {
57280             var isJavascript = ts.isInJSFile(signature.declaration);
57281             var typeParameters = signature.typeParameters;
57282             var typeArgumentTypes = fillMissingTypeArguments(ts.map(typeArgumentNodes, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), isJavascript);
57283             var mapper;
57284             for (var i = 0; i < typeArgumentNodes.length; i++) {
57285                 ts.Debug.assert(typeParameters[i] !== undefined, "Should not call checkTypeArguments with too many type arguments");
57286                 var constraint = getConstraintOfTypeParameter(typeParameters[i]);
57287                 if (constraint) {
57288                     var errorInfo = reportErrors && headMessage ? (function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1); }) : undefined;
57289                     var typeArgumentHeadMessage = headMessage || ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1;
57290                     if (!mapper) {
57291                         mapper = createTypeMapper(typeParameters, typeArgumentTypes);
57292                     }
57293                     var typeArgument = typeArgumentTypes[i];
57294                     if (!checkTypeAssignableTo(typeArgument, getTypeWithThisArgument(instantiateType(constraint, mapper), typeArgument), reportErrors ? typeArgumentNodes[i] : undefined, typeArgumentHeadMessage, errorInfo)) {
57295                         return undefined;
57296                     }
57297                 }
57298             }
57299             return typeArgumentTypes;
57300         }
57301         function getJsxReferenceKind(node) {
57302             if (isJsxIntrinsicIdentifier(node.tagName)) {
57303                 return 2;
57304             }
57305             var tagType = getApparentType(checkExpression(node.tagName));
57306             if (ts.length(getSignaturesOfType(tagType, 1))) {
57307                 return 0;
57308             }
57309             if (ts.length(getSignaturesOfType(tagType, 0))) {
57310                 return 1;
57311             }
57312             return 2;
57313         }
57314         function checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer) {
57315             var paramType = getEffectiveFirstArgumentForJsxSignature(signature, node);
57316             var attributesType = checkExpressionWithContextualType(node.attributes, paramType, undefined, checkMode);
57317             return checkTagNameDoesNotExpectTooManyArguments() && checkTypeRelatedToAndOptionallyElaborate(attributesType, paramType, relation, reportErrors ? node.tagName : undefined, node.attributes, undefined, containingMessageChain, errorOutputContainer);
57318             function checkTagNameDoesNotExpectTooManyArguments() {
57319                 var _a;
57320                 if (getJsxNamespaceContainerForImplicitImport(node)) {
57321                     return true;
57322                 }
57323                 var tagType = ts.isJsxOpeningElement(node) || ts.isJsxSelfClosingElement(node) && !isJsxIntrinsicIdentifier(node.tagName) ? checkExpression(node.tagName) : undefined;
57324                 if (!tagType) {
57325                     return true;
57326                 }
57327                 var tagCallSignatures = getSignaturesOfType(tagType, 0);
57328                 if (!ts.length(tagCallSignatures)) {
57329                     return true;
57330                 }
57331                 var factory = getJsxFactoryEntity(node);
57332                 if (!factory) {
57333                     return true;
57334                 }
57335                 var factorySymbol = resolveEntityName(factory, 111551, true, false, node);
57336                 if (!factorySymbol) {
57337                     return true;
57338                 }
57339                 var factoryType = getTypeOfSymbol(factorySymbol);
57340                 var callSignatures = getSignaturesOfType(factoryType, 0);
57341                 if (!ts.length(callSignatures)) {
57342                     return true;
57343                 }
57344                 var hasFirstParamSignatures = false;
57345                 var maxParamCount = 0;
57346                 for (var _i = 0, callSignatures_1 = callSignatures; _i < callSignatures_1.length; _i++) {
57347                     var sig = callSignatures_1[_i];
57348                     var firstparam = getTypeAtPosition(sig, 0);
57349                     var signaturesOfParam = getSignaturesOfType(firstparam, 0);
57350                     if (!ts.length(signaturesOfParam))
57351                         continue;
57352                     for (var _b = 0, signaturesOfParam_1 = signaturesOfParam; _b < signaturesOfParam_1.length; _b++) {
57353                         var paramSig = signaturesOfParam_1[_b];
57354                         hasFirstParamSignatures = true;
57355                         if (hasEffectiveRestParameter(paramSig)) {
57356                             return true;
57357                         }
57358                         var paramCount = getParameterCount(paramSig);
57359                         if (paramCount > maxParamCount) {
57360                             maxParamCount = paramCount;
57361                         }
57362                     }
57363                 }
57364                 if (!hasFirstParamSignatures) {
57365                     return true;
57366                 }
57367                 var absoluteMinArgCount = Infinity;
57368                 for (var _c = 0, tagCallSignatures_1 = tagCallSignatures; _c < tagCallSignatures_1.length; _c++) {
57369                     var tagSig = tagCallSignatures_1[_c];
57370                     var tagRequiredArgCount = getMinArgumentCount(tagSig);
57371                     if (tagRequiredArgCount < absoluteMinArgCount) {
57372                         absoluteMinArgCount = tagRequiredArgCount;
57373                     }
57374                 }
57375                 if (absoluteMinArgCount <= maxParamCount) {
57376                     return true;
57377                 }
57378                 if (reportErrors) {
57379                     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);
57380                     var tagNameDeclaration = (_a = getSymbolAtLocation(node.tagName)) === null || _a === void 0 ? void 0 : _a.valueDeclaration;
57381                     if (tagNameDeclaration) {
57382                         ts.addRelatedInfo(diag, ts.createDiagnosticForNode(tagNameDeclaration, ts.Diagnostics._0_is_declared_here, ts.entityNameToString(node.tagName)));
57383                     }
57384                     if (errorOutputContainer && errorOutputContainer.skipLogging) {
57385                         (errorOutputContainer.errors || (errorOutputContainer.errors = [])).push(diag);
57386                     }
57387                     if (!errorOutputContainer.skipLogging) {
57388                         diagnostics.add(diag);
57389                     }
57390                 }
57391                 return false;
57392             }
57393         }
57394         function getSignatureApplicabilityError(node, args, signature, relation, checkMode, reportErrors, containingMessageChain) {
57395             var errorOutputContainer = { errors: undefined, skipLogging: true };
57396             if (ts.isJsxOpeningLikeElement(node)) {
57397                 if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors, containingMessageChain, errorOutputContainer)) {
57398                     ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "jsx should have errors when reporting errors");
57399                     return errorOutputContainer.errors || ts.emptyArray;
57400                 }
57401                 return undefined;
57402             }
57403             var thisType = getThisTypeOfSignature(signature);
57404             if (thisType && thisType !== voidType && node.kind !== 204) {
57405                 var thisArgumentNode = getThisArgumentOfCall(node);
57406                 var thisArgumentType = getThisArgumentType(thisArgumentNode);
57407                 var errorNode = reportErrors ? (thisArgumentNode || node) : undefined;
57408                 var headMessage_1 = ts.Diagnostics.The_this_context_of_type_0_is_not_assignable_to_method_s_this_of_type_1;
57409                 if (!checkTypeRelatedTo(thisArgumentType, thisType, relation, errorNode, headMessage_1, containingMessageChain, errorOutputContainer)) {
57410                     ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "this parameter should have errors when reporting errors");
57411                     return errorOutputContainer.errors || ts.emptyArray;
57412                 }
57413             }
57414             var headMessage = ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1;
57415             var restType = getNonArrayRestType(signature);
57416             var argCount = restType ? Math.min(getParameterCount(signature) - 1, args.length) : args.length;
57417             for (var i = 0; i < argCount; i++) {
57418                 var arg = args[i];
57419                 if (arg.kind !== 222) {
57420                     var paramType = getTypeAtPosition(signature, i);
57421                     var argType = checkExpressionWithContextualType(arg, paramType, undefined, checkMode);
57422                     var checkArgType = checkMode & 4 ? getRegularTypeOfObjectLiteral(argType) : argType;
57423                     if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors ? arg : undefined, arg, headMessage, containingMessageChain, errorOutputContainer)) {
57424                         ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "parameter should have errors when reporting errors");
57425                         maybeAddMissingAwaitInfo(arg, checkArgType, paramType);
57426                         return errorOutputContainer.errors || ts.emptyArray;
57427                     }
57428                 }
57429             }
57430             if (restType) {
57431                 var spreadType = getSpreadArgumentType(args, argCount, args.length, restType, undefined, checkMode);
57432                 var restArgCount = args.length - argCount;
57433                 var errorNode = !reportErrors ? undefined :
57434                     restArgCount === 0 ? node :
57435                         restArgCount === 1 ? args[argCount] :
57436                             ts.setTextRangePosEnd(createSyntheticExpression(node, spreadType), args[argCount].pos, args[args.length - 1].end);
57437                 if (!checkTypeRelatedTo(spreadType, restType, relation, errorNode, headMessage, undefined, errorOutputContainer)) {
57438                     ts.Debug.assert(!reportErrors || !!errorOutputContainer.errors, "rest parameter should have errors when reporting errors");
57439                     maybeAddMissingAwaitInfo(errorNode, spreadType, restType);
57440                     return errorOutputContainer.errors || ts.emptyArray;
57441                 }
57442             }
57443             return undefined;
57444             function maybeAddMissingAwaitInfo(errorNode, source, target) {
57445                 if (errorNode && reportErrors && errorOutputContainer.errors && errorOutputContainer.errors.length) {
57446                     if (getAwaitedTypeOfPromise(target)) {
57447                         return;
57448                     }
57449                     var awaitedTypeOfSource = getAwaitedTypeOfPromise(source);
57450                     if (awaitedTypeOfSource && isTypeRelatedTo(awaitedTypeOfSource, target, relation)) {
57451                         ts.addRelatedInfo(errorOutputContainer.errors[0], ts.createDiagnosticForNode(errorNode, ts.Diagnostics.Did_you_forget_to_use_await));
57452                     }
57453                 }
57454             }
57455         }
57456         function getThisArgumentOfCall(node) {
57457             if (node.kind === 203) {
57458                 var callee = ts.skipOuterExpressions(node.expression);
57459                 if (ts.isAccessExpression(callee)) {
57460                     return callee.expression;
57461                 }
57462             }
57463         }
57464         function createSyntheticExpression(parent, type, isSpread, tupleNameSource) {
57465             var result = ts.parseNodeFactory.createSyntheticExpression(type, isSpread, tupleNameSource);
57466             ts.setTextRange(result, parent);
57467             ts.setParent(result, parent);
57468             return result;
57469         }
57470         function getEffectiveCallArguments(node) {
57471             if (node.kind === 205) {
57472                 var template = node.template;
57473                 var args_3 = [createSyntheticExpression(template, getGlobalTemplateStringsArrayType())];
57474                 if (template.kind === 218) {
57475                     ts.forEach(template.templateSpans, function (span) {
57476                         args_3.push(span.expression);
57477                     });
57478                 }
57479                 return args_3;
57480             }
57481             if (node.kind === 161) {
57482                 return getEffectiveDecoratorArguments(node);
57483             }
57484             if (ts.isJsxOpeningLikeElement(node)) {
57485                 return node.attributes.properties.length > 0 || (ts.isJsxOpeningElement(node) && node.parent.children.length > 0) ? [node.attributes] : ts.emptyArray;
57486             }
57487             var args = node.arguments || ts.emptyArray;
57488             var spreadIndex = getSpreadArgumentIndex(args);
57489             if (spreadIndex >= 0) {
57490                 var effectiveArgs_1 = args.slice(0, spreadIndex);
57491                 var _loop_20 = function (i) {
57492                     var arg = args[i];
57493                     var spreadType = arg.kind === 220 && (flowLoopCount ? checkExpression(arg.expression) : checkExpressionCached(arg.expression));
57494                     if (spreadType && isTupleType(spreadType)) {
57495                         ts.forEach(getTypeArguments(spreadType), function (t, i) {
57496                             var _a;
57497                             var flags = spreadType.target.elementFlags[i];
57498                             var syntheticArg = createSyntheticExpression(arg, flags & 4 ? createArrayType(t) : t, !!(flags & 12), (_a = spreadType.target.labeledElementDeclarations) === null || _a === void 0 ? void 0 : _a[i]);
57499                             effectiveArgs_1.push(syntheticArg);
57500                         });
57501                     }
57502                     else {
57503                         effectiveArgs_1.push(arg);
57504                     }
57505                 };
57506                 for (var i = spreadIndex; i < args.length; i++) {
57507                     _loop_20(i);
57508                 }
57509                 return effectiveArgs_1;
57510             }
57511             return args;
57512         }
57513         function getEffectiveDecoratorArguments(node) {
57514             var parent = node.parent;
57515             var expr = node.expression;
57516             switch (parent.kind) {
57517                 case 252:
57518                 case 221:
57519                     return [
57520                         createSyntheticExpression(expr, getTypeOfSymbol(getSymbolOfNode(parent)))
57521                     ];
57522                 case 160:
57523                     var func = parent.parent;
57524                     return [
57525                         createSyntheticExpression(expr, parent.parent.kind === 166 ? getTypeOfSymbol(getSymbolOfNode(func)) : errorType),
57526                         createSyntheticExpression(expr, anyType),
57527                         createSyntheticExpression(expr, numberType)
57528                     ];
57529                 case 163:
57530                 case 165:
57531                 case 167:
57532                 case 168:
57533                     var hasPropDesc = parent.kind !== 163 && languageVersion !== 0;
57534                     return [
57535                         createSyntheticExpression(expr, getParentTypeOfClassElement(parent)),
57536                         createSyntheticExpression(expr, getClassElementPropertyKeyType(parent)),
57537                         createSyntheticExpression(expr, hasPropDesc ? createTypedPropertyDescriptorType(getTypeOfNode(parent)) : anyType)
57538                     ];
57539             }
57540             return ts.Debug.fail();
57541         }
57542         function getDecoratorArgumentCount(node, signature) {
57543             switch (node.parent.kind) {
57544                 case 252:
57545                 case 221:
57546                     return 1;
57547                 case 163:
57548                     return 2;
57549                 case 165:
57550                 case 167:
57551                 case 168:
57552                     return languageVersion === 0 || signature.parameters.length <= 2 ? 2 : 3;
57553                 case 160:
57554                     return 3;
57555                 default:
57556                     return ts.Debug.fail();
57557             }
57558         }
57559         function getDiagnosticSpanForCallNode(node, doNotIncludeArguments) {
57560             var start;
57561             var length;
57562             var sourceFile = ts.getSourceFileOfNode(node);
57563             if (ts.isPropertyAccessExpression(node.expression)) {
57564                 var nameSpan = ts.getErrorSpanForNode(sourceFile, node.expression.name);
57565                 start = nameSpan.start;
57566                 length = doNotIncludeArguments ? nameSpan.length : node.end - start;
57567             }
57568             else {
57569                 var expressionSpan = ts.getErrorSpanForNode(sourceFile, node.expression);
57570                 start = expressionSpan.start;
57571                 length = doNotIncludeArguments ? expressionSpan.length : node.end - start;
57572             }
57573             return { start: start, length: length, sourceFile: sourceFile };
57574         }
57575         function getDiagnosticForCallNode(node, message, arg0, arg1, arg2, arg3) {
57576             if (ts.isCallExpression(node)) {
57577                 var _a = getDiagnosticSpanForCallNode(node), sourceFile = _a.sourceFile, start = _a.start, length_6 = _a.length;
57578                 return ts.createFileDiagnostic(sourceFile, start, length_6, message, arg0, arg1, arg2, arg3);
57579             }
57580             else {
57581                 return ts.createDiagnosticForNode(node, message, arg0, arg1, arg2, arg3);
57582             }
57583         }
57584         function isPromiseResolveArityError(node) {
57585             if (!ts.isCallExpression(node) || !ts.isIdentifier(node.expression))
57586                 return false;
57587             var symbol = resolveName(node.expression, node.expression.escapedText, 111551, undefined, undefined, false);
57588             var decl = symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration;
57589             if (!decl || !ts.isParameter(decl) || !isFunctionExpressionOrArrowFunction(decl.parent) || !ts.isNewExpression(decl.parent.parent) || !ts.isIdentifier(decl.parent.parent.expression)) {
57590                 return false;
57591             }
57592             var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(false);
57593             if (!globalPromiseSymbol)
57594                 return false;
57595             var constructorSymbol = getSymbolAtLocation(decl.parent.parent.expression, true);
57596             return constructorSymbol === globalPromiseSymbol;
57597         }
57598         function getArgumentArityError(node, signatures, args) {
57599             var min = Number.POSITIVE_INFINITY;
57600             var max = Number.NEGATIVE_INFINITY;
57601             var belowArgCount = Number.NEGATIVE_INFINITY;
57602             var aboveArgCount = Number.POSITIVE_INFINITY;
57603             var argCount = args.length;
57604             var closestSignature;
57605             for (var _i = 0, signatures_8 = signatures; _i < signatures_8.length; _i++) {
57606                 var sig = signatures_8[_i];
57607                 var minCount = getMinArgumentCount(sig);
57608                 var maxCount = getParameterCount(sig);
57609                 if (minCount < argCount && minCount > belowArgCount)
57610                     belowArgCount = minCount;
57611                 if (argCount < maxCount && maxCount < aboveArgCount)
57612                     aboveArgCount = maxCount;
57613                 if (minCount < min) {
57614                     min = minCount;
57615                     closestSignature = sig;
57616                 }
57617                 max = Math.max(max, maxCount);
57618             }
57619             var hasRestParameter = ts.some(signatures, hasEffectiveRestParameter);
57620             var paramRange = hasRestParameter ? min :
57621                 min < max ? min + "-" + max :
57622                     min;
57623             var hasSpreadArgument = getSpreadArgumentIndex(args) > -1;
57624             if (argCount <= max && hasSpreadArgument) {
57625                 argCount--;
57626             }
57627             var spanArray;
57628             var related;
57629             var error = hasRestParameter || hasSpreadArgument ?
57630                 hasRestParameter && hasSpreadArgument ?
57631                     ts.Diagnostics.Expected_at_least_0_arguments_but_got_1_or_more :
57632                     hasRestParameter ?
57633                         ts.Diagnostics.Expected_at_least_0_arguments_but_got_1 :
57634                         ts.Diagnostics.Expected_0_arguments_but_got_1_or_more :
57635                 paramRange === 1 && argCount === 0 && isPromiseResolveArityError(node) ?
57636                     ts.Diagnostics.Expected_0_arguments_but_got_1_Did_you_forget_to_include_void_in_your_type_argument_to_Promise :
57637                     ts.Diagnostics.Expected_0_arguments_but_got_1;
57638             if (closestSignature && getMinArgumentCount(closestSignature) > argCount && closestSignature.declaration) {
57639                 var paramDecl = closestSignature.declaration.parameters[closestSignature.thisParameter ? argCount + 1 : argCount];
57640                 if (paramDecl) {
57641                     related = ts.createDiagnosticForNode(paramDecl, ts.isBindingPattern(paramDecl.name) ? ts.Diagnostics.An_argument_matching_this_binding_pattern_was_not_provided :
57642                         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);
57643                 }
57644             }
57645             if (min < argCount && argCount < max) {
57646                 return getDiagnosticForCallNode(node, ts.Diagnostics.No_overload_expects_0_arguments_but_overloads_do_exist_that_expect_either_1_or_2_arguments, argCount, belowArgCount, aboveArgCount);
57647             }
57648             if (!hasSpreadArgument && argCount < min) {
57649                 var diagnostic_1 = getDiagnosticForCallNode(node, error, paramRange, argCount);
57650                 return related ? ts.addRelatedInfo(diagnostic_1, related) : diagnostic_1;
57651             }
57652             if (hasRestParameter || hasSpreadArgument) {
57653                 spanArray = ts.factory.createNodeArray(args);
57654                 if (hasSpreadArgument && argCount) {
57655                     var nextArg = ts.elementAt(args, getSpreadArgumentIndex(args) + 1) || undefined;
57656                     spanArray = ts.factory.createNodeArray(args.slice(max > argCount && nextArg ? args.indexOf(nextArg) : Math.min(max, args.length - 1)));
57657                 }
57658             }
57659             else {
57660                 spanArray = ts.factory.createNodeArray(args.slice(max));
57661             }
57662             var pos = ts.first(spanArray).pos;
57663             var end = ts.last(spanArray).end;
57664             if (end === pos) {
57665                 end++;
57666             }
57667             ts.setTextRangePosEnd(spanArray, pos, end);
57668             var diagnostic = ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), spanArray, error, paramRange, argCount);
57669             return related ? ts.addRelatedInfo(diagnostic, related) : diagnostic;
57670         }
57671         function getTypeArgumentArityError(node, signatures, typeArguments) {
57672             var argCount = typeArguments.length;
57673             if (signatures.length === 1) {
57674                 var sig = signatures[0];
57675                 var min_1 = getMinTypeArgumentCount(sig.typeParameters);
57676                 var max = ts.length(sig.typeParameters);
57677                 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);
57678             }
57679             var belowArgCount = -Infinity;
57680             var aboveArgCount = Infinity;
57681             for (var _i = 0, signatures_9 = signatures; _i < signatures_9.length; _i++) {
57682                 var sig = signatures_9[_i];
57683                 var min_2 = getMinTypeArgumentCount(sig.typeParameters);
57684                 var max = ts.length(sig.typeParameters);
57685                 if (min_2 > argCount) {
57686                     aboveArgCount = Math.min(aboveArgCount, min_2);
57687                 }
57688                 else if (max < argCount) {
57689                     belowArgCount = Math.max(belowArgCount, max);
57690                 }
57691             }
57692             if (belowArgCount !== -Infinity && aboveArgCount !== Infinity) {
57693                 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);
57694             }
57695             return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
57696         }
57697         function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) {
57698             var isTaggedTemplate = node.kind === 205;
57699             var isDecorator = node.kind === 161;
57700             var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
57701             var reportErrors = !candidatesOutArray && produceDiagnostics;
57702             var typeArguments;
57703             if (!isDecorator) {
57704                 typeArguments = node.typeArguments;
57705                 if (isTaggedTemplate || isJsxOpeningOrSelfClosingElement || node.expression.kind !== 105) {
57706                     ts.forEach(typeArguments, checkSourceElement);
57707                 }
57708             }
57709             var candidates = candidatesOutArray || [];
57710             reorderCandidates(signatures, candidates, callChainFlags);
57711             if (!candidates.length) {
57712                 if (reportErrors) {
57713                     diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures));
57714                 }
57715                 return resolveErrorCall(node);
57716             }
57717             var args = getEffectiveCallArguments(node);
57718             var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
57719             var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 : 0;
57720             var candidatesForArgumentError;
57721             var candidateForArgumentArityError;
57722             var candidateForTypeArgumentError;
57723             var result;
57724             var signatureHelpTrailingComma = !!(checkMode & 16) && node.kind === 203 && node.arguments.hasTrailingComma;
57725             if (candidates.length > 1) {
57726                 result = chooseOverload(candidates, subtypeRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
57727             }
57728             if (!result) {
57729                 result = chooseOverload(candidates, assignableRelation, isSingleNonGenericCandidate, signatureHelpTrailingComma);
57730             }
57731             if (result) {
57732                 return result;
57733             }
57734             if (reportErrors) {
57735                 if (candidatesForArgumentError) {
57736                     if (candidatesForArgumentError.length === 1 || candidatesForArgumentError.length > 3) {
57737                         var last_2 = candidatesForArgumentError[candidatesForArgumentError.length - 1];
57738                         var chain_1;
57739                         if (candidatesForArgumentError.length > 3) {
57740                             chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.The_last_overload_gave_the_following_error);
57741                             chain_1 = ts.chainDiagnosticMessages(chain_1, ts.Diagnostics.No_overload_matches_this_call);
57742                         }
57743                         var diags = getSignatureApplicabilityError(node, args, last_2, assignableRelation, 0, true, function () { return chain_1; });
57744                         if (diags) {
57745                             for (var _i = 0, diags_1 = diags; _i < diags_1.length; _i++) {
57746                                 var d = diags_1[_i];
57747                                 if (last_2.declaration && candidatesForArgumentError.length > 3) {
57748                                     ts.addRelatedInfo(d, ts.createDiagnosticForNode(last_2.declaration, ts.Diagnostics.The_last_overload_is_declared_here));
57749                                 }
57750                                 addImplementationSuccessElaboration(last_2, d);
57751                                 diagnostics.add(d);
57752                             }
57753                         }
57754                         else {
57755                             ts.Debug.fail("No error for last overload signature");
57756                         }
57757                     }
57758                     else {
57759                         var allDiagnostics = [];
57760                         var max = 0;
57761                         var min_3 = Number.MAX_VALUE;
57762                         var minIndex = 0;
57763                         var i_1 = 0;
57764                         var _loop_21 = function (c) {
57765                             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)); };
57766                             var diags_2 = getSignatureApplicabilityError(node, args, c, assignableRelation, 0, true, chain_2);
57767                             if (diags_2) {
57768                                 if (diags_2.length <= min_3) {
57769                                     min_3 = diags_2.length;
57770                                     minIndex = i_1;
57771                                 }
57772                                 max = Math.max(max, diags_2.length);
57773                                 allDiagnostics.push(diags_2);
57774                             }
57775                             else {
57776                                 ts.Debug.fail("No error for 3 or fewer overload signatures");
57777                             }
57778                             i_1++;
57779                         };
57780                         for (var _a = 0, candidatesForArgumentError_1 = candidatesForArgumentError; _a < candidatesForArgumentError_1.length; _a++) {
57781                             var c = candidatesForArgumentError_1[_a];
57782                             _loop_21(c);
57783                         }
57784                         var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
57785                         ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
57786                         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);
57787                         var related = __spreadArray([], ts.flatMap(diags_3, function (d) { return d.relatedInformation; }));
57788                         var diag = void 0;
57789                         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; })) {
57790                             var _b = diags_3[0], file = _b.file, start = _b.start, length_7 = _b.length;
57791                             diag = { file: file, start: start, length: length_7, code: chain.code, category: chain.category, messageText: chain, relatedInformation: related };
57792                         }
57793                         else {
57794                             diag = ts.createDiagnosticForNodeFromMessageChain(node, chain, related);
57795                         }
57796                         addImplementationSuccessElaboration(candidatesForArgumentError[0], diag);
57797                         diagnostics.add(diag);
57798                     }
57799                 }
57800                 else if (candidateForArgumentArityError) {
57801                     diagnostics.add(getArgumentArityError(node, [candidateForArgumentArityError], args));
57802                 }
57803                 else if (candidateForTypeArgumentError) {
57804                     checkTypeArguments(candidateForTypeArgumentError, node.typeArguments, true, fallbackError);
57805                 }
57806                 else {
57807                     var signaturesWithCorrectTypeArgumentArity = ts.filter(signatures, function (s) { return hasCorrectTypeArgumentArity(s, typeArguments); });
57808                     if (signaturesWithCorrectTypeArgumentArity.length === 0) {
57809                         diagnostics.add(getTypeArgumentArityError(node, signatures, typeArguments));
57810                     }
57811                     else if (!isDecorator) {
57812                         diagnostics.add(getArgumentArityError(node, signaturesWithCorrectTypeArgumentArity, args));
57813                     }
57814                     else if (fallbackError) {
57815                         diagnostics.add(getDiagnosticForCallNode(node, fallbackError));
57816                     }
57817                 }
57818             }
57819             return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
57820             function addImplementationSuccessElaboration(failed, diagnostic) {
57821                 var _a, _b;
57822                 var oldCandidatesForArgumentError = candidatesForArgumentError;
57823                 var oldCandidateForArgumentArityError = candidateForArgumentArityError;
57824                 var oldCandidateForTypeArgumentError = candidateForTypeArgumentError;
57825                 var failedSignatureDeclarations = ((_b = (_a = failed.declaration) === null || _a === void 0 ? void 0 : _a.symbol) === null || _b === void 0 ? void 0 : _b.declarations) || ts.emptyArray;
57826                 var isOverload = failedSignatureDeclarations.length > 1;
57827                 var implDecl = isOverload ? ts.find(failedSignatureDeclarations, function (d) { return ts.isFunctionLikeDeclaration(d) && ts.nodeIsPresent(d.body); }) : undefined;
57828                 if (implDecl) {
57829                     var candidate = getSignatureFromDeclaration(implDecl);
57830                     var isSingleNonGenericCandidate_1 = !candidate.typeParameters;
57831                     if (chooseOverload([candidate], assignableRelation, isSingleNonGenericCandidate_1)) {
57832                         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));
57833                     }
57834                 }
57835                 candidatesForArgumentError = oldCandidatesForArgumentError;
57836                 candidateForArgumentArityError = oldCandidateForArgumentArityError;
57837                 candidateForTypeArgumentError = oldCandidateForTypeArgumentError;
57838             }
57839             function chooseOverload(candidates, relation, isSingleNonGenericCandidate, signatureHelpTrailingComma) {
57840                 if (signatureHelpTrailingComma === void 0) { signatureHelpTrailingComma = false; }
57841                 candidatesForArgumentError = undefined;
57842                 candidateForArgumentArityError = undefined;
57843                 candidateForTypeArgumentError = undefined;
57844                 if (isSingleNonGenericCandidate) {
57845                     var candidate = candidates[0];
57846                     if (ts.some(typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) {
57847                         return undefined;
57848                     }
57849                     if (getSignatureApplicabilityError(node, args, candidate, relation, 0, false, undefined)) {
57850                         candidatesForArgumentError = [candidate];
57851                         return undefined;
57852                     }
57853                     return candidate;
57854                 }
57855                 for (var candidateIndex = 0; candidateIndex < candidates.length; candidateIndex++) {
57856                     var candidate = candidates[candidateIndex];
57857                     if (!hasCorrectTypeArgumentArity(candidate, typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma)) {
57858                         continue;
57859                     }
57860                     var checkCandidate = void 0;
57861                     var inferenceContext = void 0;
57862                     if (candidate.typeParameters) {
57863                         var typeArgumentTypes = void 0;
57864                         if (ts.some(typeArguments)) {
57865                             typeArgumentTypes = checkTypeArguments(candidate, typeArguments, false);
57866                             if (!typeArgumentTypes) {
57867                                 candidateForTypeArgumentError = candidate;
57868                                 continue;
57869                             }
57870                         }
57871                         else {
57872                             inferenceContext = createInferenceContext(candidate.typeParameters, candidate, ts.isInJSFile(node) ? 2 : 0);
57873                             typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8, inferenceContext);
57874                             argCheckMode |= inferenceContext.flags & 4 ? 8 : 0;
57875                         }
57876                         checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
57877                         if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
57878                             candidateForArgumentArityError = checkCandidate;
57879                             continue;
57880                         }
57881                     }
57882                     else {
57883                         checkCandidate = candidate;
57884                     }
57885                     if (getSignatureApplicabilityError(node, args, checkCandidate, relation, argCheckMode, false, undefined)) {
57886                         (candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
57887                         continue;
57888                     }
57889                     if (argCheckMode) {
57890                         argCheckMode = 0;
57891                         if (inferenceContext) {
57892                             var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
57893                             checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
57894                             if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma)) {
57895                                 candidateForArgumentArityError = checkCandidate;
57896                                 continue;
57897                             }
57898                         }
57899                         if (getSignatureApplicabilityError(node, args, checkCandidate, relation, argCheckMode, false, undefined)) {
57900                             (candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
57901                             continue;
57902                         }
57903                     }
57904                     candidates[candidateIndex] = checkCandidate;
57905                     return checkCandidate;
57906                 }
57907                 return undefined;
57908             }
57909         }
57910         function getCandidateForOverloadFailure(node, candidates, args, hasCandidatesOutArray) {
57911             ts.Debug.assert(candidates.length > 0);
57912             checkNodeDeferred(node);
57913             return hasCandidatesOutArray || candidates.length === 1 || candidates.some(function (c) { return !!c.typeParameters; })
57914                 ? pickLongestCandidateSignature(node, candidates, args)
57915                 : createUnionOfSignaturesForOverloadFailure(candidates);
57916         }
57917         function createUnionOfSignaturesForOverloadFailure(candidates) {
57918             var thisParameters = ts.mapDefined(candidates, function (c) { return c.thisParameter; });
57919             var thisParameter;
57920             if (thisParameters.length) {
57921                 thisParameter = createCombinedSymbolFromTypes(thisParameters, thisParameters.map(getTypeOfParameter));
57922             }
57923             var _a = ts.minAndMax(candidates, getNumNonRestParameters), minArgumentCount = _a.min, maxNonRestParam = _a.max;
57924             var parameters = [];
57925             var _loop_22 = function (i) {
57926                 var symbols = ts.mapDefined(candidates, function (s) { return signatureHasRestParameter(s) ?
57927                     i < s.parameters.length - 1 ? s.parameters[i] : ts.last(s.parameters) :
57928                     i < s.parameters.length ? s.parameters[i] : undefined; });
57929                 ts.Debug.assert(symbols.length !== 0);
57930                 parameters.push(createCombinedSymbolFromTypes(symbols, ts.mapDefined(candidates, function (candidate) { return tryGetTypeAtPosition(candidate, i); })));
57931             };
57932             for (var i = 0; i < maxNonRestParam; i++) {
57933                 _loop_22(i);
57934             }
57935             var restParameterSymbols = ts.mapDefined(candidates, function (c) { return signatureHasRestParameter(c) ? ts.last(c.parameters) : undefined; });
57936             var flags = 0;
57937             if (restParameterSymbols.length !== 0) {
57938                 var type = createArrayType(getUnionType(ts.mapDefined(candidates, tryGetRestTypeOfSignature), 2));
57939                 parameters.push(createCombinedSymbolForOverloadFailure(restParameterSymbols, type));
57940                 flags |= 1;
57941             }
57942             if (candidates.some(signatureHasLiteralTypes)) {
57943                 flags |= 2;
57944             }
57945             return createSignature(candidates[0].declaration, undefined, thisParameter, parameters, getIntersectionType(candidates.map(getReturnTypeOfSignature)), undefined, minArgumentCount, flags);
57946         }
57947         function getNumNonRestParameters(signature) {
57948             var numParams = signature.parameters.length;
57949             return signatureHasRestParameter(signature) ? numParams - 1 : numParams;
57950         }
57951         function createCombinedSymbolFromTypes(sources, types) {
57952             return createCombinedSymbolForOverloadFailure(sources, getUnionType(types, 2));
57953         }
57954         function createCombinedSymbolForOverloadFailure(sources, type) {
57955             return createSymbolWithType(ts.first(sources), type);
57956         }
57957         function pickLongestCandidateSignature(node, candidates, args) {
57958             var bestIndex = getLongestCandidateIndex(candidates, apparentArgumentCount === undefined ? args.length : apparentArgumentCount);
57959             var candidate = candidates[bestIndex];
57960             var typeParameters = candidate.typeParameters;
57961             if (!typeParameters) {
57962                 return candidate;
57963             }
57964             var typeArgumentNodes = callLikeExpressionMayHaveTypeArguments(node) ? node.typeArguments : undefined;
57965             var instantiated = typeArgumentNodes
57966                 ? createSignatureInstantiation(candidate, getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, ts.isInJSFile(node)))
57967                 : inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args);
57968             candidates[bestIndex] = instantiated;
57969             return instantiated;
57970         }
57971         function getTypeArgumentsFromNodes(typeArgumentNodes, typeParameters, isJs) {
57972             var typeArguments = typeArgumentNodes.map(getTypeOfNode);
57973             while (typeArguments.length > typeParameters.length) {
57974                 typeArguments.pop();
57975             }
57976             while (typeArguments.length < typeParameters.length) {
57977                 typeArguments.push(getConstraintOfTypeParameter(typeParameters[typeArguments.length]) || getDefaultTypeArgumentType(isJs));
57978             }
57979             return typeArguments;
57980         }
57981         function inferSignatureInstantiationForOverloadFailure(node, typeParameters, candidate, args) {
57982             var inferenceContext = createInferenceContext(typeParameters, candidate, ts.isInJSFile(node) ? 2 : 0);
57983             var typeArgumentTypes = inferTypeArguments(node, candidate, args, 4 | 8, inferenceContext);
57984             return createSignatureInstantiation(candidate, typeArgumentTypes);
57985         }
57986         function getLongestCandidateIndex(candidates, argsCount) {
57987             var maxParamsIndex = -1;
57988             var maxParams = -1;
57989             for (var i = 0; i < candidates.length; i++) {
57990                 var candidate = candidates[i];
57991                 var paramCount = getParameterCount(candidate);
57992                 if (hasEffectiveRestParameter(candidate) || paramCount >= argsCount) {
57993                     return i;
57994                 }
57995                 if (paramCount > maxParams) {
57996                     maxParams = paramCount;
57997                     maxParamsIndex = i;
57998                 }
57999             }
58000             return maxParamsIndex;
58001         }
58002         function resolveCallExpression(node, candidatesOutArray, checkMode) {
58003             if (node.expression.kind === 105) {
58004                 var superType = checkSuperExpression(node.expression);
58005                 if (isTypeAny(superType)) {
58006                     for (var _i = 0, _a = node.arguments; _i < _a.length; _i++) {
58007                         var arg = _a[_i];
58008                         checkExpression(arg);
58009                     }
58010                     return anySignature;
58011                 }
58012                 if (superType !== errorType) {
58013                     var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
58014                     if (baseTypeNode) {
58015                         var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode);
58016                         return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0);
58017                     }
58018                 }
58019                 return resolveUntypedCall(node);
58020             }
58021             var callChainFlags;
58022             var funcType = checkExpression(node.expression);
58023             if (ts.isCallChain(node)) {
58024                 var nonOptionalType = getOptionalExpressionType(funcType, node.expression);
58025                 callChainFlags = nonOptionalType === funcType ? 0 :
58026                     ts.isOutermostOptionalChain(node) ? 16 :
58027                         8;
58028                 funcType = nonOptionalType;
58029             }
58030             else {
58031                 callChainFlags = 0;
58032             }
58033             funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError);
58034             if (funcType === silentNeverType) {
58035                 return silentNeverSignature;
58036             }
58037             var apparentType = getApparentType(funcType);
58038             if (apparentType === errorType) {
58039                 return resolveErrorCall(node);
58040             }
58041             var callSignatures = getSignaturesOfType(apparentType, 0);
58042             var numConstructSignatures = getSignaturesOfType(apparentType, 1).length;
58043             if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
58044                 if (funcType !== errorType && node.typeArguments) {
58045                     error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
58046                 }
58047                 return resolveUntypedCall(node);
58048             }
58049             if (!callSignatures.length) {
58050                 if (numConstructSignatures) {
58051                     error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
58052                 }
58053                 else {
58054                     var relatedInformation = void 0;
58055                     if (node.arguments.length === 1) {
58056                         var text = ts.getSourceFileOfNode(node).text;
58057                         if (ts.isLineBreak(text.charCodeAt(ts.skipTrivia(text, node.expression.end, true) - 1))) {
58058                             relatedInformation = ts.createDiagnosticForNode(node.expression, ts.Diagnostics.Are_you_missing_a_semicolon);
58059                         }
58060                     }
58061                     invocationError(node.expression, apparentType, 0, relatedInformation);
58062                 }
58063                 return resolveErrorCall(node);
58064             }
58065             if (checkMode & 8 && !node.typeArguments && callSignatures.some(isGenericFunctionReturningFunction)) {
58066                 skippedGenericFunction(node, checkMode);
58067                 return resolvingSignature;
58068             }
58069             if (callSignatures.some(function (sig) { return ts.isInJSFile(sig.declaration) && !!ts.getJSDocClassTag(sig.declaration); })) {
58070                 error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
58071                 return resolveErrorCall(node);
58072             }
58073             return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
58074         }
58075         function isGenericFunctionReturningFunction(signature) {
58076             return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
58077         }
58078         function isUntypedFunctionCall(funcType, apparentFuncType, numCallSignatures, numConstructSignatures) {
58079             return isTypeAny(funcType) || isTypeAny(apparentFuncType) && !!(funcType.flags & 262144) ||
58080                 !numCallSignatures && !numConstructSignatures && !(apparentFuncType.flags & (1048576 | 131072)) && isTypeAssignableTo(funcType, globalFunctionType);
58081         }
58082         function resolveNewExpression(node, candidatesOutArray, checkMode) {
58083             if (node.arguments && languageVersion < 1) {
58084                 var spreadIndex = getSpreadArgumentIndex(node.arguments);
58085                 if (spreadIndex >= 0) {
58086                     error(node.arguments[spreadIndex], ts.Diagnostics.Spread_operator_in_new_expressions_is_only_available_when_targeting_ECMAScript_5_and_higher);
58087                 }
58088             }
58089             var expressionType = checkNonNullExpression(node.expression);
58090             if (expressionType === silentNeverType) {
58091                 return silentNeverSignature;
58092             }
58093             expressionType = getApparentType(expressionType);
58094             if (expressionType === errorType) {
58095                 return resolveErrorCall(node);
58096             }
58097             if (isTypeAny(expressionType)) {
58098                 if (node.typeArguments) {
58099                     error(node, ts.Diagnostics.Untyped_function_calls_may_not_accept_type_arguments);
58100                 }
58101                 return resolveUntypedCall(node);
58102             }
58103             var constructSignatures = getSignaturesOfType(expressionType, 1);
58104             if (constructSignatures.length) {
58105                 if (!isConstructorAccessible(node, constructSignatures[0])) {
58106                     return resolveErrorCall(node);
58107                 }
58108                 if (constructSignatures.some(function (signature) { return signature.flags & 4; })) {
58109                     error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class);
58110                     return resolveErrorCall(node);
58111                 }
58112                 var valueDecl = expressionType.symbol && ts.getClassLikeDeclarationOfSymbol(expressionType.symbol);
58113                 if (valueDecl && ts.hasSyntacticModifier(valueDecl, 128)) {
58114                     error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class);
58115                     return resolveErrorCall(node);
58116                 }
58117                 return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0);
58118             }
58119             var callSignatures = getSignaturesOfType(expressionType, 0);
58120             if (callSignatures.length) {
58121                 var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0);
58122                 if (!noImplicitAny) {
58123                     if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
58124                         error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
58125                     }
58126                     if (getThisTypeOfSignature(signature) === voidType) {
58127                         error(node, ts.Diagnostics.A_function_that_is_called_with_the_new_keyword_cannot_have_a_this_type_that_is_void);
58128                     }
58129                 }
58130                 return signature;
58131             }
58132             invocationError(node.expression, expressionType, 1);
58133             return resolveErrorCall(node);
58134         }
58135         function typeHasProtectedAccessibleBase(target, type) {
58136             var baseTypes = getBaseTypes(type);
58137             if (!ts.length(baseTypes)) {
58138                 return false;
58139             }
58140             var firstBase = baseTypes[0];
58141             if (firstBase.flags & 2097152) {
58142                 var types = firstBase.types;
58143                 var mixinFlags = findMixins(types);
58144                 var i = 0;
58145                 for (var _i = 0, _a = firstBase.types; _i < _a.length; _i++) {
58146                     var intersectionMember = _a[_i];
58147                     if (!mixinFlags[i]) {
58148                         if (ts.getObjectFlags(intersectionMember) & (1 | 2)) {
58149                             if (intersectionMember.symbol === target) {
58150                                 return true;
58151                             }
58152                             if (typeHasProtectedAccessibleBase(target, intersectionMember)) {
58153                                 return true;
58154                             }
58155                         }
58156                     }
58157                     i++;
58158                 }
58159                 return false;
58160             }
58161             if (firstBase.symbol === target) {
58162                 return true;
58163             }
58164             return typeHasProtectedAccessibleBase(target, firstBase);
58165         }
58166         function isConstructorAccessible(node, signature) {
58167             if (!signature || !signature.declaration) {
58168                 return true;
58169             }
58170             var declaration = signature.declaration;
58171             var modifiers = ts.getSelectedEffectiveModifierFlags(declaration, 24);
58172             if (!modifiers || declaration.kind !== 166) {
58173                 return true;
58174             }
58175             var declaringClassDeclaration = ts.getClassLikeDeclarationOfSymbol(declaration.parent.symbol);
58176             var declaringClass = getDeclaredTypeOfSymbol(declaration.parent.symbol);
58177             if (!isNodeWithinClass(node, declaringClassDeclaration)) {
58178                 var containingClass = ts.getContainingClass(node);
58179                 if (containingClass && modifiers & 16) {
58180                     var containingType = getTypeOfNode(containingClass);
58181                     if (typeHasProtectedAccessibleBase(declaration.parent.symbol, containingType)) {
58182                         return true;
58183                     }
58184                 }
58185                 if (modifiers & 8) {
58186                     error(node, ts.Diagnostics.Constructor_of_class_0_is_private_and_only_accessible_within_the_class_declaration, typeToString(declaringClass));
58187                 }
58188                 if (modifiers & 16) {
58189                     error(node, ts.Diagnostics.Constructor_of_class_0_is_protected_and_only_accessible_within_the_class_declaration, typeToString(declaringClass));
58190                 }
58191                 return false;
58192             }
58193             return true;
58194         }
58195         function invocationErrorDetails(errorTarget, apparentType, kind) {
58196             var errorInfo;
58197             var isCall = kind === 0;
58198             var awaitedType = getAwaitedType(apparentType);
58199             var maybeMissingAwait = awaitedType && getSignaturesOfType(awaitedType, kind).length > 0;
58200             if (apparentType.flags & 1048576) {
58201                 var types = apparentType.types;
58202                 var hasSignatures = false;
58203                 for (var _i = 0, types_21 = types; _i < types_21.length; _i++) {
58204                     var constituent = types_21[_i];
58205                     var signatures = getSignaturesOfType(constituent, kind);
58206                     if (signatures.length !== 0) {
58207                         hasSignatures = true;
58208                         if (errorInfo) {
58209                             break;
58210                         }
58211                     }
58212                     else {
58213                         if (!errorInfo) {
58214                             errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
58215                                 ts.Diagnostics.Type_0_has_no_call_signatures :
58216                                 ts.Diagnostics.Type_0_has_no_construct_signatures, typeToString(constituent));
58217                             errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
58218                                 ts.Diagnostics.Not_all_constituents_of_type_0_are_callable :
58219                                 ts.Diagnostics.Not_all_constituents_of_type_0_are_constructable, typeToString(apparentType));
58220                         }
58221                         if (hasSignatures) {
58222                             break;
58223                         }
58224                     }
58225                 }
58226                 if (!hasSignatures) {
58227                     errorInfo = ts.chainDiagnosticMessages(undefined, isCall ?
58228                         ts.Diagnostics.No_constituent_of_type_0_is_callable :
58229                         ts.Diagnostics.No_constituent_of_type_0_is_constructable, typeToString(apparentType));
58230                 }
58231                 if (!errorInfo) {
58232                     errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
58233                         ts.Diagnostics.Each_member_of_the_union_type_0_has_signatures_but_none_of_those_signatures_are_compatible_with_each_other :
58234                         ts.Diagnostics.Each_member_of_the_union_type_0_has_construct_signatures_but_none_of_those_signatures_are_compatible_with_each_other, typeToString(apparentType));
58235                 }
58236             }
58237             else {
58238                 errorInfo = ts.chainDiagnosticMessages(errorInfo, isCall ?
58239                     ts.Diagnostics.Type_0_has_no_call_signatures :
58240                     ts.Diagnostics.Type_0_has_no_construct_signatures, typeToString(apparentType));
58241             }
58242             var headMessage = isCall ? ts.Diagnostics.This_expression_is_not_callable : ts.Diagnostics.This_expression_is_not_constructable;
58243             if (ts.isCallExpression(errorTarget.parent) && errorTarget.parent.arguments.length === 0) {
58244                 var resolvedSymbol = getNodeLinks(errorTarget).resolvedSymbol;
58245                 if (resolvedSymbol && resolvedSymbol.flags & 32768) {
58246                     headMessage = ts.Diagnostics.This_expression_is_not_callable_because_it_is_a_get_accessor_Did_you_mean_to_use_it_without;
58247                 }
58248             }
58249             return {
58250                 messageChain: ts.chainDiagnosticMessages(errorInfo, headMessage),
58251                 relatedMessage: maybeMissingAwait ? ts.Diagnostics.Did_you_forget_to_use_await : undefined,
58252             };
58253         }
58254         function invocationError(errorTarget, apparentType, kind, relatedInformation) {
58255             var _a = invocationErrorDetails(errorTarget, apparentType, kind), messageChain = _a.messageChain, relatedInfo = _a.relatedMessage;
58256             var diagnostic = ts.createDiagnosticForNodeFromMessageChain(errorTarget, messageChain);
58257             if (relatedInfo) {
58258                 ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(errorTarget, relatedInfo));
58259             }
58260             if (ts.isCallExpression(errorTarget.parent)) {
58261                 var _b = getDiagnosticSpanForCallNode(errorTarget.parent, true), start = _b.start, length_8 = _b.length;
58262                 diagnostic.start = start;
58263                 diagnostic.length = length_8;
58264             }
58265             diagnostics.add(diagnostic);
58266             invocationErrorRecovery(apparentType, kind, relatedInformation ? ts.addRelatedInfo(diagnostic, relatedInformation) : diagnostic);
58267         }
58268         function invocationErrorRecovery(apparentType, kind, diagnostic) {
58269             if (!apparentType.symbol) {
58270                 return;
58271             }
58272             var importNode = getSymbolLinks(apparentType.symbol).originatingImport;
58273             if (importNode && !ts.isImportCall(importNode)) {
58274                 var sigs = getSignaturesOfType(getTypeOfSymbol(getSymbolLinks(apparentType.symbol).target), kind);
58275                 if (!sigs || !sigs.length)
58276                     return;
58277                 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));
58278             }
58279         }
58280         function resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode) {
58281             var tagType = checkExpression(node.tag);
58282             var apparentType = getApparentType(tagType);
58283             if (apparentType === errorType) {
58284                 return resolveErrorCall(node);
58285             }
58286             var callSignatures = getSignaturesOfType(apparentType, 0);
58287             var numConstructSignatures = getSignaturesOfType(apparentType, 1).length;
58288             if (isUntypedFunctionCall(tagType, apparentType, callSignatures.length, numConstructSignatures)) {
58289                 return resolveUntypedCall(node);
58290             }
58291             if (!callSignatures.length) {
58292                 if (ts.isArrayLiteralExpression(node.parent)) {
58293                     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);
58294                     diagnostics.add(diagnostic);
58295                     return resolveErrorCall(node);
58296                 }
58297                 invocationError(node.tag, apparentType, 0);
58298                 return resolveErrorCall(node);
58299             }
58300             return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0);
58301         }
58302         function getDiagnosticHeadMessageForDecoratorResolution(node) {
58303             switch (node.parent.kind) {
58304                 case 252:
58305                 case 221:
58306                     return ts.Diagnostics.Unable_to_resolve_signature_of_class_decorator_when_called_as_an_expression;
58307                 case 160:
58308                     return ts.Diagnostics.Unable_to_resolve_signature_of_parameter_decorator_when_called_as_an_expression;
58309                 case 163:
58310                     return ts.Diagnostics.Unable_to_resolve_signature_of_property_decorator_when_called_as_an_expression;
58311                 case 165:
58312                 case 167:
58313                 case 168:
58314                     return ts.Diagnostics.Unable_to_resolve_signature_of_method_decorator_when_called_as_an_expression;
58315                 default:
58316                     return ts.Debug.fail();
58317             }
58318         }
58319         function resolveDecorator(node, candidatesOutArray, checkMode) {
58320             var funcType = checkExpression(node.expression);
58321             var apparentType = getApparentType(funcType);
58322             if (apparentType === errorType) {
58323                 return resolveErrorCall(node);
58324             }
58325             var callSignatures = getSignaturesOfType(apparentType, 0);
58326             var numConstructSignatures = getSignaturesOfType(apparentType, 1).length;
58327             if (isUntypedFunctionCall(funcType, apparentType, callSignatures.length, numConstructSignatures)) {
58328                 return resolveUntypedCall(node);
58329             }
58330             if (isPotentiallyUncalledDecorator(node, callSignatures)) {
58331                 var nodeStr = ts.getTextOfNode(node.expression, false);
58332                 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);
58333                 return resolveErrorCall(node);
58334             }
58335             var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
58336             if (!callSignatures.length) {
58337                 var errorDetails = invocationErrorDetails(node.expression, apparentType, 0);
58338                 var messageChain = ts.chainDiagnosticMessages(errorDetails.messageChain, headMessage);
58339                 var diag = ts.createDiagnosticForNodeFromMessageChain(node.expression, messageChain);
58340                 if (errorDetails.relatedMessage) {
58341                     ts.addRelatedInfo(diag, ts.createDiagnosticForNode(node.expression, errorDetails.relatedMessage));
58342                 }
58343                 diagnostics.add(diag);
58344                 invocationErrorRecovery(apparentType, 0, diag);
58345                 return resolveErrorCall(node);
58346             }
58347             return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0, headMessage);
58348         }
58349         function createSignatureForJSXIntrinsic(node, result) {
58350             var namespace = getJsxNamespaceAt(node);
58351             var exports = namespace && getExportsOfSymbol(namespace);
58352             var typeSymbol = exports && getSymbol(exports, JsxNames.Element, 788968);
58353             var returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, 788968, node);
58354             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));
58355             var parameterSymbol = createSymbol(1, "props");
58356             parameterSymbol.type = result;
58357             return createSignature(declaration, undefined, undefined, [parameterSymbol], typeSymbol ? getDeclaredTypeOfSymbol(typeSymbol) : errorType, undefined, 1, 0);
58358         }
58359         function resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode) {
58360             if (isJsxIntrinsicIdentifier(node.tagName)) {
58361                 var result = getIntrinsicAttributesTypeFromJsxOpeningLikeElement(node);
58362                 var fakeSignature = createSignatureForJSXIntrinsic(node, result);
58363                 checkTypeAssignableToAndOptionallyElaborate(checkExpressionWithContextualType(node.attributes, getEffectiveFirstArgumentForJsxSignature(fakeSignature, node), undefined, 0), result, node.tagName, node.attributes);
58364                 if (ts.length(node.typeArguments)) {
58365                     ts.forEach(node.typeArguments, checkSourceElement);
58366                     diagnostics.add(ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), node.typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, 0, ts.length(node.typeArguments)));
58367                 }
58368                 return fakeSignature;
58369             }
58370             var exprTypes = checkExpression(node.tagName);
58371             var apparentType = getApparentType(exprTypes);
58372             if (apparentType === errorType) {
58373                 return resolveErrorCall(node);
58374             }
58375             var signatures = getUninstantiatedJsxSignaturesOfType(exprTypes, node);
58376             if (isUntypedFunctionCall(exprTypes, apparentType, signatures.length, 0)) {
58377                 return resolveUntypedCall(node);
58378             }
58379             if (signatures.length === 0) {
58380                 error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName));
58381                 return resolveErrorCall(node);
58382             }
58383             return resolveCall(node, signatures, candidatesOutArray, checkMode, 0);
58384         }
58385         function isPotentiallyUncalledDecorator(decorator, signatures) {
58386             return signatures.length && ts.every(signatures, function (signature) {
58387                 return signature.minArgumentCount === 0 &&
58388                     !signatureHasRestParameter(signature) &&
58389                     signature.parameters.length < getDecoratorArgumentCount(decorator, signature);
58390             });
58391         }
58392         function resolveSignature(node, candidatesOutArray, checkMode) {
58393             switch (node.kind) {
58394                 case 203:
58395                     return resolveCallExpression(node, candidatesOutArray, checkMode);
58396                 case 204:
58397                     return resolveNewExpression(node, candidatesOutArray, checkMode);
58398                 case 205:
58399                     return resolveTaggedTemplateExpression(node, candidatesOutArray, checkMode);
58400                 case 161:
58401                     return resolveDecorator(node, candidatesOutArray, checkMode);
58402                 case 275:
58403                 case 274:
58404                     return resolveJsxOpeningLikeElement(node, candidatesOutArray, checkMode);
58405             }
58406             throw ts.Debug.assertNever(node, "Branch in 'resolveSignature' should be unreachable.");
58407         }
58408         function getResolvedSignature(node, candidatesOutArray, checkMode) {
58409             var links = getNodeLinks(node);
58410             var cached = links.resolvedSignature;
58411             if (cached && cached !== resolvingSignature && !candidatesOutArray) {
58412                 return cached;
58413             }
58414             links.resolvedSignature = resolvingSignature;
58415             var result = resolveSignature(node, candidatesOutArray, checkMode || 0);
58416             if (result !== resolvingSignature) {
58417                 links.resolvedSignature = flowLoopStart === flowLoopCount ? result : cached;
58418             }
58419             return result;
58420         }
58421         function isJSConstructor(node) {
58422             var _a;
58423             if (!node || !ts.isInJSFile(node)) {
58424                 return false;
58425             }
58426             var func = ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) ? node :
58427                 ts.isVariableDeclaration(node) && node.initializer && ts.isFunctionExpression(node.initializer) ? node.initializer :
58428                     undefined;
58429             if (func) {
58430                 if (ts.getJSDocClassTag(node))
58431                     return true;
58432                 var symbol = getSymbolOfNode(func);
58433                 return !!((_a = symbol === null || symbol === void 0 ? void 0 : symbol.members) === null || _a === void 0 ? void 0 : _a.size);
58434             }
58435             return false;
58436         }
58437         function mergeJSSymbols(target, source) {
58438             var _a, _b;
58439             if (source) {
58440                 var links = getSymbolLinks(source);
58441                 if (!links.inferredClassSymbol || !links.inferredClassSymbol.has(getSymbolId(target))) {
58442                     var inferred = ts.isTransientSymbol(target) ? target : cloneSymbol(target);
58443                     inferred.exports = inferred.exports || ts.createSymbolTable();
58444                     inferred.members = inferred.members || ts.createSymbolTable();
58445                     inferred.flags |= source.flags & 32;
58446                     if ((_a = source.exports) === null || _a === void 0 ? void 0 : _a.size) {
58447                         mergeSymbolTable(inferred.exports, source.exports);
58448                     }
58449                     if ((_b = source.members) === null || _b === void 0 ? void 0 : _b.size) {
58450                         mergeSymbolTable(inferred.members, source.members);
58451                     }
58452                     (links.inferredClassSymbol || (links.inferredClassSymbol = new ts.Map())).set(getSymbolId(inferred), inferred);
58453                     return inferred;
58454                 }
58455                 return links.inferredClassSymbol.get(getSymbolId(target));
58456             }
58457         }
58458         function getAssignedClassSymbol(decl) {
58459             var _a;
58460             var assignmentSymbol = decl && getSymbolOfExpando(decl, true);
58461             var prototype = (_a = assignmentSymbol === null || assignmentSymbol === void 0 ? void 0 : assignmentSymbol.exports) === null || _a === void 0 ? void 0 : _a.get("prototype");
58462             var init = (prototype === null || prototype === void 0 ? void 0 : prototype.valueDeclaration) && getAssignedJSPrototype(prototype.valueDeclaration);
58463             return init ? getSymbolOfNode(init) : undefined;
58464         }
58465         function getSymbolOfExpando(node, allowDeclaration) {
58466             if (!node.parent) {
58467                 return undefined;
58468             }
58469             var name;
58470             var decl;
58471             if (ts.isVariableDeclaration(node.parent) && node.parent.initializer === node) {
58472                 if (!ts.isInJSFile(node) && !(ts.isVarConst(node.parent) && ts.isFunctionLikeDeclaration(node))) {
58473                     return undefined;
58474                 }
58475                 name = node.parent.name;
58476                 decl = node.parent;
58477             }
58478             else if (ts.isBinaryExpression(node.parent)) {
58479                 var parentNode = node.parent;
58480                 var parentNodeOperator = node.parent.operatorToken.kind;
58481                 if (parentNodeOperator === 62 && (allowDeclaration || parentNode.right === node)) {
58482                     name = parentNode.left;
58483                     decl = name;
58484                 }
58485                 else if (parentNodeOperator === 56 || parentNodeOperator === 60) {
58486                     if (ts.isVariableDeclaration(parentNode.parent) && parentNode.parent.initializer === parentNode) {
58487                         name = parentNode.parent.name;
58488                         decl = parentNode.parent;
58489                     }
58490                     else if (ts.isBinaryExpression(parentNode.parent) && parentNode.parent.operatorToken.kind === 62 && (allowDeclaration || parentNode.parent.right === parentNode)) {
58491                         name = parentNode.parent.left;
58492                         decl = name;
58493                     }
58494                     if (!name || !ts.isBindableStaticNameExpression(name) || !ts.isSameEntityName(name, parentNode.left)) {
58495                         return undefined;
58496                     }
58497                 }
58498             }
58499             else if (allowDeclaration && ts.isFunctionDeclaration(node)) {
58500                 name = node.name;
58501                 decl = node;
58502             }
58503             if (!decl || !name || (!allowDeclaration && !ts.getExpandoInitializer(node, ts.isPrototypeAccess(name)))) {
58504                 return undefined;
58505             }
58506             return getSymbolOfNode(decl);
58507         }
58508         function getAssignedJSPrototype(node) {
58509             if (!node.parent) {
58510                 return false;
58511             }
58512             var parent = node.parent;
58513             while (parent && parent.kind === 201) {
58514                 parent = parent.parent;
58515             }
58516             if (parent && ts.isBinaryExpression(parent) && ts.isPrototypeAccess(parent.left) && parent.operatorToken.kind === 62) {
58517                 var right = ts.getInitializerOfBinaryExpression(parent);
58518                 return ts.isObjectLiteralExpression(right) && right;
58519             }
58520         }
58521         function checkCallExpression(node, checkMode) {
58522             var _a;
58523             if (!checkGrammarTypeArguments(node, node.typeArguments))
58524                 checkGrammarArguments(node.arguments);
58525             var signature = getResolvedSignature(node, undefined, checkMode);
58526             if (signature === resolvingSignature) {
58527                 return nonInferrableType;
58528             }
58529             checkDeprecatedSignature(signature, node);
58530             if (node.expression.kind === 105) {
58531                 return voidType;
58532             }
58533             if (node.kind === 204) {
58534                 var declaration = signature.declaration;
58535                 if (declaration &&
58536                     declaration.kind !== 166 &&
58537                     declaration.kind !== 170 &&
58538                     declaration.kind !== 175 &&
58539                     !ts.isJSDocConstructSignature(declaration) &&
58540                     !isJSConstructor(declaration)) {
58541                     if (noImplicitAny) {
58542                         error(node, ts.Diagnostics.new_expression_whose_target_lacks_a_construct_signature_implicitly_has_an_any_type);
58543                     }
58544                     return anyType;
58545                 }
58546             }
58547             if (ts.isInJSFile(node) && isCommonJsRequire(node)) {
58548                 return resolveExternalModuleTypeByLiteral(node.arguments[0]);
58549             }
58550             var returnType = getReturnTypeOfSignature(signature);
58551             if (returnType.flags & 12288 && isSymbolOrSymbolForCall(node)) {
58552                 return getESSymbolLikeTypeForNode(ts.walkUpParenthesizedExpressions(node.parent));
58553             }
58554             if (node.kind === 203 && !node.questionDotToken && node.parent.kind === 233 &&
58555                 returnType.flags & 16384 && getTypePredicateOfSignature(signature)) {
58556                 if (!ts.isDottedName(node.expression)) {
58557                     error(node.expression, ts.Diagnostics.Assertions_require_the_call_target_to_be_an_identifier_or_qualified_name);
58558                 }
58559                 else if (!getEffectsSignature(node)) {
58560                     var diagnostic = error(node.expression, ts.Diagnostics.Assertions_require_every_name_in_the_call_target_to_be_declared_with_an_explicit_type_annotation);
58561                     getTypeOfDottedName(node.expression, diagnostic);
58562                 }
58563             }
58564             if (ts.isInJSFile(node)) {
58565                 var jsSymbol = getSymbolOfExpando(node, false);
58566                 if ((_a = jsSymbol === null || jsSymbol === void 0 ? void 0 : jsSymbol.exports) === null || _a === void 0 ? void 0 : _a.size) {
58567                     var jsAssignmentType = createAnonymousType(jsSymbol, jsSymbol.exports, ts.emptyArray, ts.emptyArray, undefined, undefined);
58568                     jsAssignmentType.objectFlags |= 16384;
58569                     return getIntersectionType([returnType, jsAssignmentType]);
58570                 }
58571             }
58572             return returnType;
58573         }
58574         function checkDeprecatedSignature(signature, node) {
58575             if (signature.declaration && signature.declaration.flags & 134217728) {
58576                 var suggestionNode = getDeprecatedSuggestionNode(node);
58577                 var name = ts.tryGetPropertyAccessOrIdentifierToString(ts.getInvokedExpression(node));
58578                 addDeprecatedSuggestionWithSignature(suggestionNode, signature.declaration, name, signatureToString(signature));
58579             }
58580         }
58581         function getDeprecatedSuggestionNode(node) {
58582             node = ts.skipParentheses(node);
58583             switch (node.kind) {
58584                 case 203:
58585                 case 161:
58586                 case 204:
58587                     return getDeprecatedSuggestionNode(node.expression);
58588                 case 205:
58589                     return getDeprecatedSuggestionNode(node.tag);
58590                 case 275:
58591                 case 274:
58592                     return getDeprecatedSuggestionNode(node.tagName);
58593                 case 202:
58594                     return node.argumentExpression;
58595                 case 201:
58596                     return node.name;
58597                 case 173:
58598                     var typeReference = node;
58599                     return ts.isQualifiedName(typeReference.typeName) ? typeReference.typeName.right : typeReference;
58600                 default:
58601                     return node;
58602             }
58603         }
58604         function isSymbolOrSymbolForCall(node) {
58605             if (!ts.isCallExpression(node))
58606                 return false;
58607             var left = node.expression;
58608             if (ts.isPropertyAccessExpression(left) && left.name.escapedText === "for") {
58609                 left = left.expression;
58610             }
58611             if (!ts.isIdentifier(left) || left.escapedText !== "Symbol") {
58612                 return false;
58613             }
58614             var globalESSymbol = getGlobalESSymbolConstructorSymbol(false);
58615             if (!globalESSymbol) {
58616                 return false;
58617             }
58618             return globalESSymbol === resolveName(left, "Symbol", 111551, undefined, undefined, false);
58619         }
58620         function checkImportCallExpression(node) {
58621             if (!checkGrammarArguments(node.arguments))
58622                 checkGrammarImportCallExpression(node);
58623             if (node.arguments.length === 0) {
58624                 return createPromiseReturnType(node, anyType);
58625             }
58626             var specifier = node.arguments[0];
58627             var specifierType = checkExpressionCached(specifier);
58628             for (var i = 1; i < node.arguments.length; ++i) {
58629                 checkExpressionCached(node.arguments[i]);
58630             }
58631             if (specifierType.flags & 32768 || specifierType.flags & 65536 || !isTypeAssignableTo(specifierType, stringType)) {
58632                 error(specifier, ts.Diagnostics.Dynamic_import_s_specifier_must_be_of_type_string_but_here_has_type_0, typeToString(specifierType));
58633             }
58634             var moduleSymbol = resolveExternalModuleName(node, specifier);
58635             if (moduleSymbol) {
58636                 var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, true, false);
58637                 if (esModuleSymbol) {
58638                     return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol));
58639                 }
58640             }
58641             return createPromiseReturnType(node, anyType);
58642         }
58643         function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol) {
58644             if (allowSyntheticDefaultImports && type && type !== errorType) {
58645                 var synthType = type;
58646                 if (!synthType.syntheticType) {
58647                     var file = ts.find(originalSymbol.declarations, ts.isSourceFile);
58648                     var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, false);
58649                     if (hasSyntheticDefault) {
58650                         var memberTable = ts.createSymbolTable();
58651                         var newSymbol = createSymbol(2097152, "default");
58652                         newSymbol.parent = originalSymbol;
58653                         newSymbol.nameType = getLiteralType("default");
58654                         newSymbol.target = resolveSymbol(symbol);
58655                         memberTable.set("default", newSymbol);
58656                         var anonymousSymbol = createSymbol(2048, "__type");
58657                         var defaultContainingObject = createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, undefined, undefined);
58658                         anonymousSymbol.type = defaultContainingObject;
58659                         synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, 0, false) : defaultContainingObject;
58660                     }
58661                     else {
58662                         synthType.syntheticType = type;
58663                     }
58664                 }
58665                 return synthType.syntheticType;
58666             }
58667             return type;
58668         }
58669         function isCommonJsRequire(node) {
58670             if (!ts.isRequireCall(node, true)) {
58671                 return false;
58672             }
58673             if (!ts.isIdentifier(node.expression))
58674                 return ts.Debug.fail();
58675             var resolvedRequire = resolveName(node.expression, node.expression.escapedText, 111551, undefined, undefined, true);
58676             if (resolvedRequire === requireSymbol) {
58677                 return true;
58678             }
58679             if (resolvedRequire.flags & 2097152) {
58680                 return false;
58681             }
58682             var targetDeclarationKind = resolvedRequire.flags & 16
58683                 ? 251
58684                 : resolvedRequire.flags & 3
58685                     ? 249
58686                     : 0;
58687             if (targetDeclarationKind !== 0) {
58688                 var decl = ts.getDeclarationOfKind(resolvedRequire, targetDeclarationKind);
58689                 return !!decl && !!(decl.flags & 8388608);
58690             }
58691             return false;
58692         }
58693         function checkTaggedTemplateExpression(node) {
58694             if (!checkGrammarTaggedTemplateChain(node))
58695                 checkGrammarTypeArguments(node, node.typeArguments);
58696             if (languageVersion < 2) {
58697                 checkExternalEmitHelpers(node, 262144);
58698             }
58699             var signature = getResolvedSignature(node);
58700             checkDeprecatedSignature(signature, node);
58701             return getReturnTypeOfSignature(signature);
58702         }
58703         function checkAssertion(node) {
58704             return checkAssertionWorker(node, node.type, node.expression);
58705         }
58706         function isValidConstAssertionArgument(node) {
58707             switch (node.kind) {
58708                 case 10:
58709                 case 14:
58710                 case 8:
58711                 case 9:
58712                 case 109:
58713                 case 94:
58714                 case 199:
58715                 case 200:
58716                 case 218:
58717                     return true;
58718                 case 207:
58719                     return isValidConstAssertionArgument(node.expression);
58720                 case 214:
58721                     var op = node.operator;
58722                     var arg = node.operand;
58723                     return op === 40 && (arg.kind === 8 || arg.kind === 9) ||
58724                         op === 39 && arg.kind === 8;
58725                 case 201:
58726                 case 202:
58727                     var expr = node.expression;
58728                     if (ts.isIdentifier(expr)) {
58729                         var symbol = getSymbolAtLocation(expr);
58730                         if (symbol && symbol.flags & 2097152) {
58731                             symbol = resolveAlias(symbol);
58732                         }
58733                         return !!(symbol && (symbol.flags & 384) && getEnumKind(symbol) === 1);
58734                     }
58735             }
58736             return false;
58737         }
58738         function checkAssertionWorker(errNode, type, expression, checkMode) {
58739             var exprType = checkExpression(expression, checkMode);
58740             if (ts.isConstTypeReference(type)) {
58741                 if (!isValidConstAssertionArgument(expression)) {
58742                     error(expression, ts.Diagnostics.A_const_assertions_can_only_be_applied_to_references_to_enum_members_or_string_number_boolean_array_or_object_literals);
58743                 }
58744                 return getRegularTypeOfLiteralType(exprType);
58745             }
58746             checkSourceElement(type);
58747             exprType = getRegularTypeOfObjectLiteral(getBaseTypeOfLiteralType(exprType));
58748             var targetType = getTypeFromTypeNode(type);
58749             if (produceDiagnostics && targetType !== errorType) {
58750                 var widenedType = getWidenedType(exprType);
58751                 if (!isTypeComparableTo(targetType, widenedType)) {
58752                     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);
58753                 }
58754             }
58755             return targetType;
58756         }
58757         function checkNonNullChain(node) {
58758             var leftType = checkExpression(node.expression);
58759             var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
58760             return propagateOptionalTypeMarker(getNonNullableType(nonOptionalType), node, nonOptionalType !== leftType);
58761         }
58762         function checkNonNullAssertion(node) {
58763             return node.flags & 32 ? checkNonNullChain(node) :
58764                 getNonNullableType(checkExpression(node.expression));
58765         }
58766         function checkMetaProperty(node) {
58767             checkGrammarMetaProperty(node);
58768             if (node.keywordToken === 102) {
58769                 return checkNewTargetMetaProperty(node);
58770             }
58771             if (node.keywordToken === 99) {
58772                 return checkImportMetaProperty(node);
58773             }
58774             return ts.Debug.assertNever(node.keywordToken);
58775         }
58776         function checkNewTargetMetaProperty(node) {
58777             var container = ts.getNewTargetContainer(node);
58778             if (!container) {
58779                 error(node, ts.Diagnostics.Meta_property_0_is_only_allowed_in_the_body_of_a_function_declaration_function_expression_or_constructor, "new.target");
58780                 return errorType;
58781             }
58782             else if (container.kind === 166) {
58783                 var symbol = getSymbolOfNode(container.parent);
58784                 return getTypeOfSymbol(symbol);
58785             }
58786             else {
58787                 var symbol = getSymbolOfNode(container);
58788                 return getTypeOfSymbol(symbol);
58789             }
58790         }
58791         function checkImportMetaProperty(node) {
58792             if (moduleKind !== ts.ModuleKind.ES2020 && moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) {
58793                 error(node, ts.Diagnostics.The_import_meta_meta_property_is_only_allowed_when_the_module_option_is_es2020_esnext_or_system);
58794             }
58795             var file = ts.getSourceFileOfNode(node);
58796             ts.Debug.assert(!!(file.flags & 2097152), "Containing file is missing import meta node flag.");
58797             ts.Debug.assert(!!file.externalModuleIndicator, "Containing file should be a module.");
58798             return node.name.escapedText === "meta" ? getGlobalImportMetaType() : errorType;
58799         }
58800         function getTypeOfParameter(symbol) {
58801             var type = getTypeOfSymbol(symbol);
58802             if (strictNullChecks) {
58803                 var declaration = symbol.valueDeclaration;
58804                 if (declaration && ts.hasInitializer(declaration)) {
58805                     return getOptionalType(type);
58806                 }
58807             }
58808             return type;
58809         }
58810         function getTupleElementLabel(d) {
58811             ts.Debug.assert(ts.isIdentifier(d.name));
58812             return d.name.escapedText;
58813         }
58814         function getParameterNameAtPosition(signature, pos, overrideRestType) {
58815             var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
58816             if (pos < paramCount) {
58817                 return signature.parameters[pos].escapedName;
58818             }
58819             var restParameter = signature.parameters[paramCount] || unknownSymbol;
58820             var restType = overrideRestType || getTypeOfSymbol(restParameter);
58821             if (isTupleType(restType)) {
58822                 var associatedNames = restType.target.labeledElementDeclarations;
58823                 var index = pos - paramCount;
58824                 return associatedNames && getTupleElementLabel(associatedNames[index]) || restParameter.escapedName + "_" + index;
58825             }
58826             return restParameter.escapedName;
58827         }
58828         function isValidDeclarationForTupleLabel(d) {
58829             return d.kind === 192 || (ts.isParameter(d) && d.name && ts.isIdentifier(d.name));
58830         }
58831         function getNameableDeclarationAtPosition(signature, pos) {
58832             var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
58833             if (pos < paramCount) {
58834                 var decl = signature.parameters[pos].valueDeclaration;
58835                 return decl && isValidDeclarationForTupleLabel(decl) ? decl : undefined;
58836             }
58837             var restParameter = signature.parameters[paramCount] || unknownSymbol;
58838             var restType = getTypeOfSymbol(restParameter);
58839             if (isTupleType(restType)) {
58840                 var associatedNames = restType.target.labeledElementDeclarations;
58841                 var index = pos - paramCount;
58842                 return associatedNames && associatedNames[index];
58843             }
58844             return restParameter.valueDeclaration && isValidDeclarationForTupleLabel(restParameter.valueDeclaration) ? restParameter.valueDeclaration : undefined;
58845         }
58846         function getTypeAtPosition(signature, pos) {
58847             return tryGetTypeAtPosition(signature, pos) || anyType;
58848         }
58849         function tryGetTypeAtPosition(signature, pos) {
58850             var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
58851             if (pos < paramCount) {
58852                 return getTypeOfParameter(signature.parameters[pos]);
58853             }
58854             if (signatureHasRestParameter(signature)) {
58855                 var restType = getTypeOfSymbol(signature.parameters[paramCount]);
58856                 var index = pos - paramCount;
58857                 if (!isTupleType(restType) || restType.target.hasRestElement || index < restType.target.fixedLength) {
58858                     return getIndexedAccessType(restType, getLiteralType(index));
58859                 }
58860             }
58861             return undefined;
58862         }
58863         function getRestTypeAtPosition(source, pos) {
58864             var parameterCount = getParameterCount(source);
58865             var minArgumentCount = getMinArgumentCount(source);
58866             var restType = getEffectiveRestType(source);
58867             if (restType && pos >= parameterCount - 1) {
58868                 return pos === parameterCount - 1 ? restType : createArrayType(getIndexedAccessType(restType, numberType));
58869             }
58870             var types = [];
58871             var flags = [];
58872             var names = [];
58873             for (var i = pos; i < parameterCount; i++) {
58874                 if (!restType || i < parameterCount - 1) {
58875                     types.push(getTypeAtPosition(source, i));
58876                     flags.push(i < minArgumentCount ? 1 : 2);
58877                 }
58878                 else {
58879                     types.push(restType);
58880                     flags.push(8);
58881                 }
58882                 var name = getNameableDeclarationAtPosition(source, i);
58883                 if (name) {
58884                     names.push(name);
58885                 }
58886             }
58887             return createTupleType(types, flags, false, ts.length(names) === ts.length(types) ? names : undefined);
58888         }
58889         function getParameterCount(signature) {
58890             var length = signature.parameters.length;
58891             if (signatureHasRestParameter(signature)) {
58892                 var restType = getTypeOfSymbol(signature.parameters[length - 1]);
58893                 if (isTupleType(restType)) {
58894                     return length + restType.target.fixedLength - (restType.target.hasRestElement ? 0 : 1);
58895                 }
58896             }
58897             return length;
58898         }
58899         function getMinArgumentCount(signature, flags) {
58900             var strongArityForUntypedJS = flags & 1;
58901             var voidIsNonOptional = flags & 2;
58902             if (voidIsNonOptional || signature.resolvedMinArgumentCount === undefined) {
58903                 var minArgumentCount = void 0;
58904                 if (signatureHasRestParameter(signature)) {
58905                     var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
58906                     if (isTupleType(restType)) {
58907                         var firstOptionalIndex = ts.findIndex(restType.target.elementFlags, function (f) { return !(f & 1); });
58908                         var requiredCount = firstOptionalIndex < 0 ? restType.target.fixedLength : firstOptionalIndex;
58909                         if (requiredCount > 0) {
58910                             minArgumentCount = signature.parameters.length - 1 + requiredCount;
58911                         }
58912                     }
58913                 }
58914                 if (minArgumentCount === undefined) {
58915                     if (!strongArityForUntypedJS && signature.flags & 32) {
58916                         return 0;
58917                     }
58918                     minArgumentCount = signature.minArgumentCount;
58919                 }
58920                 if (voidIsNonOptional) {
58921                     return minArgumentCount;
58922                 }
58923                 for (var i = minArgumentCount - 1; i >= 0; i--) {
58924                     var type = getTypeAtPosition(signature, i);
58925                     if (filterType(type, acceptsVoid).flags & 131072) {
58926                         break;
58927                     }
58928                     minArgumentCount = i;
58929                 }
58930                 signature.resolvedMinArgumentCount = minArgumentCount;
58931             }
58932             return signature.resolvedMinArgumentCount;
58933         }
58934         function hasEffectiveRestParameter(signature) {
58935             if (signatureHasRestParameter(signature)) {
58936                 var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
58937                 return !isTupleType(restType) || restType.target.hasRestElement;
58938             }
58939             return false;
58940         }
58941         function getEffectiveRestType(signature) {
58942             if (signatureHasRestParameter(signature)) {
58943                 var restType = getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]);
58944                 if (!isTupleType(restType)) {
58945                     return restType;
58946                 }
58947                 if (restType.target.hasRestElement) {
58948                     return sliceTupleType(restType, restType.target.fixedLength);
58949                 }
58950             }
58951             return undefined;
58952         }
58953         function getNonArrayRestType(signature) {
58954             var restType = getEffectiveRestType(signature);
58955             return restType && !isArrayType(restType) && !isTypeAny(restType) && (getReducedType(restType).flags & 131072) === 0 ? restType : undefined;
58956         }
58957         function getTypeOfFirstParameterOfSignature(signature) {
58958             return getTypeOfFirstParameterOfSignatureWithFallback(signature, neverType);
58959         }
58960         function getTypeOfFirstParameterOfSignatureWithFallback(signature, fallbackType) {
58961             return signature.parameters.length > 0 ? getTypeAtPosition(signature, 0) : fallbackType;
58962         }
58963         function inferFromAnnotatedParameters(signature, context, inferenceContext) {
58964             var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
58965             for (var i = 0; i < len; i++) {
58966                 var declaration = signature.parameters[i].valueDeclaration;
58967                 if (declaration.type) {
58968                     var typeNode = ts.getEffectiveTypeAnnotationNode(declaration);
58969                     if (typeNode) {
58970                         inferTypes(inferenceContext.inferences, getTypeFromTypeNode(typeNode), getTypeAtPosition(context, i));
58971                     }
58972                 }
58973             }
58974             var restType = getEffectiveRestType(context);
58975             if (restType && restType.flags & 262144) {
58976                 var instantiatedContext = instantiateSignature(context, inferenceContext.nonFixingMapper);
58977                 assignContextualParameterTypes(signature, instantiatedContext);
58978                 var restPos = getParameterCount(context) - 1;
58979                 inferTypes(inferenceContext.inferences, getRestTypeAtPosition(signature, restPos), restType);
58980             }
58981         }
58982         function assignContextualParameterTypes(signature, context) {
58983             signature.typeParameters = context.typeParameters;
58984             if (context.thisParameter) {
58985                 var parameter = signature.thisParameter;
58986                 if (!parameter || parameter.valueDeclaration && !parameter.valueDeclaration.type) {
58987                     if (!parameter) {
58988                         signature.thisParameter = createSymbolWithType(context.thisParameter, undefined);
58989                     }
58990                     assignParameterType(signature.thisParameter, getTypeOfSymbol(context.thisParameter));
58991                 }
58992             }
58993             var len = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
58994             for (var i = 0; i < len; i++) {
58995                 var parameter = signature.parameters[i];
58996                 if (!ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) {
58997                     var contextualParameterType = tryGetTypeAtPosition(context, i);
58998                     assignParameterType(parameter, contextualParameterType);
58999                 }
59000             }
59001             if (signatureHasRestParameter(signature)) {
59002                 var parameter = ts.last(signature.parameters);
59003                 if (ts.isTransientSymbol(parameter) || !ts.getEffectiveTypeAnnotationNode(parameter.valueDeclaration)) {
59004                     var contextualParameterType = getRestTypeAtPosition(context, len);
59005                     assignParameterType(parameter, contextualParameterType);
59006                 }
59007             }
59008         }
59009         function assignNonContextualParameterTypes(signature) {
59010             if (signature.thisParameter) {
59011                 assignParameterType(signature.thisParameter);
59012             }
59013             for (var _i = 0, _a = signature.parameters; _i < _a.length; _i++) {
59014                 var parameter = _a[_i];
59015                 assignParameterType(parameter);
59016             }
59017         }
59018         function assignParameterType(parameter, type) {
59019             var links = getSymbolLinks(parameter);
59020             if (!links.type) {
59021                 var declaration = parameter.valueDeclaration;
59022                 links.type = type || getWidenedTypeForVariableLikeDeclaration(declaration, true);
59023                 if (declaration.name.kind !== 78) {
59024                     if (links.type === unknownType) {
59025                         links.type = getTypeFromBindingPattern(declaration.name);
59026                     }
59027                     assignBindingElementTypes(declaration.name);
59028                 }
59029             }
59030         }
59031         function assignBindingElementTypes(pattern) {
59032             for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
59033                 var element = _a[_i];
59034                 if (!ts.isOmittedExpression(element)) {
59035                     if (element.name.kind === 78) {
59036                         getSymbolLinks(getSymbolOfNode(element)).type = getTypeForBindingElement(element);
59037                     }
59038                     else {
59039                         assignBindingElementTypes(element.name);
59040                     }
59041                 }
59042             }
59043         }
59044         function createPromiseType(promisedType) {
59045             var globalPromiseType = getGlobalPromiseType(true);
59046             if (globalPromiseType !== emptyGenericType) {
59047                 promisedType = getAwaitedType(promisedType) || unknownType;
59048                 return createTypeReference(globalPromiseType, [promisedType]);
59049             }
59050             return unknownType;
59051         }
59052         function createPromiseLikeType(promisedType) {
59053             var globalPromiseLikeType = getGlobalPromiseLikeType(true);
59054             if (globalPromiseLikeType !== emptyGenericType) {
59055                 promisedType = getAwaitedType(promisedType) || unknownType;
59056                 return createTypeReference(globalPromiseLikeType, [promisedType]);
59057             }
59058             return unknownType;
59059         }
59060         function createPromiseReturnType(func, promisedType) {
59061             var promiseType = createPromiseType(promisedType);
59062             if (promiseType === unknownType) {
59063                 error(func, ts.isImportCall(func) ?
59064                     ts.Diagnostics.A_dynamic_import_call_returns_a_Promise_Make_sure_you_have_a_declaration_for_Promise_or_include_ES2015_in_your_lib_option :
59065                     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);
59066                 return errorType;
59067             }
59068             else if (!getGlobalPromiseConstructorSymbol(true)) {
59069                 error(func, ts.isImportCall(func) ?
59070                     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 :
59071                     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);
59072             }
59073             return promiseType;
59074         }
59075         function getReturnTypeFromBody(func, checkMode) {
59076             if (!func.body) {
59077                 return errorType;
59078             }
59079             var functionFlags = ts.getFunctionFlags(func);
59080             var isAsync = (functionFlags & 2) !== 0;
59081             var isGenerator = (functionFlags & 1) !== 0;
59082             var returnType;
59083             var yieldType;
59084             var nextType;
59085             var fallbackReturnType = voidType;
59086             if (func.body.kind !== 230) {
59087                 returnType = checkExpressionCached(func.body, checkMode && checkMode & ~8);
59088                 if (isAsync) {
59089                     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);
59090                 }
59091             }
59092             else if (isGenerator) {
59093                 var returnTypes = checkAndAggregateReturnExpressionTypes(func, checkMode);
59094                 if (!returnTypes) {
59095                     fallbackReturnType = neverType;
59096                 }
59097                 else if (returnTypes.length > 0) {
59098                     returnType = getUnionType(returnTypes, 2);
59099                 }
59100                 var _a = checkAndAggregateYieldOperandTypes(func, checkMode), yieldTypes = _a.yieldTypes, nextTypes = _a.nextTypes;
59101                 yieldType = ts.some(yieldTypes) ? getUnionType(yieldTypes, 2) : undefined;
59102                 nextType = ts.some(nextTypes) ? getIntersectionType(nextTypes) : undefined;
59103             }
59104             else {
59105                 var types = checkAndAggregateReturnExpressionTypes(func, checkMode);
59106                 if (!types) {
59107                     return functionFlags & 2
59108                         ? createPromiseReturnType(func, neverType)
59109                         : neverType;
59110                 }
59111                 if (types.length === 0) {
59112                     return functionFlags & 2
59113                         ? createPromiseReturnType(func, voidType)
59114                         : voidType;
59115                 }
59116                 returnType = getUnionType(types, 2);
59117             }
59118             if (returnType || yieldType || nextType) {
59119                 if (yieldType)
59120                     reportErrorsFromWidening(func, yieldType, 3);
59121                 if (returnType)
59122                     reportErrorsFromWidening(func, returnType, 1);
59123                 if (nextType)
59124                     reportErrorsFromWidening(func, nextType, 2);
59125                 if (returnType && isUnitType(returnType) ||
59126                     yieldType && isUnitType(yieldType) ||
59127                     nextType && isUnitType(nextType)) {
59128                     var contextualSignature = getContextualSignatureForFunctionLikeDeclaration(func);
59129                     var contextualType = !contextualSignature ? undefined :
59130                         contextualSignature === getSignatureFromDeclaration(func) ? isGenerator ? undefined : returnType :
59131                             instantiateContextualType(getReturnTypeOfSignature(contextualSignature), func);
59132                     if (isGenerator) {
59133                         yieldType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(yieldType, contextualType, 0, isAsync);
59134                         returnType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(returnType, contextualType, 1, isAsync);
59135                         nextType = getWidenedLiteralLikeTypeForContextualIterationTypeIfNeeded(nextType, contextualType, 2, isAsync);
59136                     }
59137                     else {
59138                         returnType = getWidenedLiteralLikeTypeForContextualReturnTypeIfNeeded(returnType, contextualType, isAsync);
59139                     }
59140                 }
59141                 if (yieldType)
59142                     yieldType = getWidenedType(yieldType);
59143                 if (returnType)
59144                     returnType = getWidenedType(returnType);
59145                 if (nextType)
59146                     nextType = getWidenedType(nextType);
59147             }
59148             if (isGenerator) {
59149                 return createGeneratorReturnType(yieldType || neverType, returnType || fallbackReturnType, nextType || getContextualIterationType(2, func) || unknownType, isAsync);
59150             }
59151             else {
59152                 return isAsync
59153                     ? createPromiseType(returnType || fallbackReturnType)
59154                     : returnType || fallbackReturnType;
59155             }
59156         }
59157         function createGeneratorReturnType(yieldType, returnType, nextType, isAsyncGenerator) {
59158             var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
59159             var globalGeneratorType = resolver.getGlobalGeneratorType(false);
59160             yieldType = resolver.resolveIterationType(yieldType, undefined) || unknownType;
59161             returnType = resolver.resolveIterationType(returnType, undefined) || unknownType;
59162             nextType = resolver.resolveIterationType(nextType, undefined) || unknownType;
59163             if (globalGeneratorType === emptyGenericType) {
59164                 var globalType = resolver.getGlobalIterableIteratorType(false);
59165                 var iterationTypes = globalType !== emptyGenericType ? getIterationTypesOfGlobalIterableType(globalType, resolver) : undefined;
59166                 var iterableIteratorReturnType = iterationTypes ? iterationTypes.returnType : anyType;
59167                 var iterableIteratorNextType = iterationTypes ? iterationTypes.nextType : undefinedType;
59168                 if (isTypeAssignableTo(returnType, iterableIteratorReturnType) &&
59169                     isTypeAssignableTo(iterableIteratorNextType, nextType)) {
59170                     if (globalType !== emptyGenericType) {
59171                         return createTypeFromGenericGlobalType(globalType, [yieldType]);
59172                     }
59173                     resolver.getGlobalIterableIteratorType(true);
59174                     return emptyObjectType;
59175                 }
59176                 resolver.getGlobalGeneratorType(true);
59177                 return emptyObjectType;
59178             }
59179             return createTypeFromGenericGlobalType(globalGeneratorType, [yieldType, returnType, nextType]);
59180         }
59181         function checkAndAggregateYieldOperandTypes(func, checkMode) {
59182             var yieldTypes = [];
59183             var nextTypes = [];
59184             var isAsync = (ts.getFunctionFlags(func) & 2) !== 0;
59185             ts.forEachYieldExpression(func.body, function (yieldExpression) {
59186                 var yieldExpressionType = yieldExpression.expression ? checkExpression(yieldExpression.expression, checkMode) : undefinedWideningType;
59187                 ts.pushIfUnique(yieldTypes, getYieldedTypeOfYieldExpression(yieldExpression, yieldExpressionType, anyType, isAsync));
59188                 var nextType;
59189                 if (yieldExpression.asteriskToken) {
59190                     var iterationTypes = getIterationTypesOfIterable(yieldExpressionType, isAsync ? 19 : 17, yieldExpression.expression);
59191                     nextType = iterationTypes && iterationTypes.nextType;
59192                 }
59193                 else {
59194                     nextType = getContextualType(yieldExpression);
59195                 }
59196                 if (nextType)
59197                     ts.pushIfUnique(nextTypes, nextType);
59198             });
59199             return { yieldTypes: yieldTypes, nextTypes: nextTypes };
59200         }
59201         function getYieldedTypeOfYieldExpression(node, expressionType, sentType, isAsync) {
59202             var errorNode = node.expression || node;
59203             var yieldedType = node.asteriskToken ? checkIteratedTypeOrElementType(isAsync ? 19 : 17, expressionType, sentType, errorNode) : expressionType;
59204             return !isAsync ? yieldedType : getAwaitedType(yieldedType, errorNode, node.asteriskToken
59205                 ? 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
59206                 : ts.Diagnostics.Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member);
59207         }
59208         function getFactsFromTypeofSwitch(start, end, witnesses, hasDefault) {
59209             var facts = 0;
59210             if (hasDefault) {
59211                 for (var i = end; i < witnesses.length; i++) {
59212                     facts |= typeofNEFacts.get(witnesses[i]) || 32768;
59213                 }
59214                 for (var i = start; i < end; i++) {
59215                     facts &= ~(typeofNEFacts.get(witnesses[i]) || 0);
59216                 }
59217                 for (var i = 0; i < start; i++) {
59218                     facts |= typeofNEFacts.get(witnesses[i]) || 32768;
59219                 }
59220             }
59221             else {
59222                 for (var i = start; i < end; i++) {
59223                     facts |= typeofEQFacts.get(witnesses[i]) || 128;
59224                 }
59225                 for (var i = 0; i < start; i++) {
59226                     facts &= ~(typeofEQFacts.get(witnesses[i]) || 0);
59227                 }
59228             }
59229             return facts;
59230         }
59231         function isExhaustiveSwitchStatement(node) {
59232             var links = getNodeLinks(node);
59233             return links.isExhaustive !== undefined ? links.isExhaustive : (links.isExhaustive = computeExhaustiveSwitchStatement(node));
59234         }
59235         function computeExhaustiveSwitchStatement(node) {
59236             if (node.expression.kind === 211) {
59237                 var operandType = getTypeOfExpression(node.expression.expression);
59238                 var witnesses = getSwitchClauseTypeOfWitnesses(node, false);
59239                 var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, true);
59240                 var type_4 = getBaseConstraintOfType(operandType) || operandType;
59241                 if (type_4.flags & 3) {
59242                     return (556800 & notEqualFacts_1) === 556800;
59243                 }
59244                 return !!(filterType(type_4, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072);
59245             }
59246             var type = getTypeOfExpression(node.expression);
59247             if (!isLiteralType(type)) {
59248                 return false;
59249             }
59250             var switchTypes = getSwitchClauseTypes(node);
59251             if (!switchTypes.length || ts.some(switchTypes, isNeitherUnitTypeNorNever)) {
59252                 return false;
59253             }
59254             return eachTypeContainedIn(mapType(type, getRegularTypeOfLiteralType), switchTypes);
59255         }
59256         function functionHasImplicitReturn(func) {
59257             return func.endFlowNode && isReachableFlowNode(func.endFlowNode);
59258         }
59259         function checkAndAggregateReturnExpressionTypes(func, checkMode) {
59260             var functionFlags = ts.getFunctionFlags(func);
59261             var aggregatedTypes = [];
59262             var hasReturnWithNoExpression = functionHasImplicitReturn(func);
59263             var hasReturnOfTypeNever = false;
59264             ts.forEachReturnStatement(func.body, function (returnStatement) {
59265                 var expr = returnStatement.expression;
59266                 if (expr) {
59267                     var type = checkExpressionCached(expr, checkMode && checkMode & ~8);
59268                     if (functionFlags & 2) {
59269                         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);
59270                     }
59271                     if (type.flags & 131072) {
59272                         hasReturnOfTypeNever = true;
59273                     }
59274                     ts.pushIfUnique(aggregatedTypes, type);
59275                 }
59276                 else {
59277                     hasReturnWithNoExpression = true;
59278                 }
59279             });
59280             if (aggregatedTypes.length === 0 && !hasReturnWithNoExpression && (hasReturnOfTypeNever || mayReturnNever(func))) {
59281                 return undefined;
59282             }
59283             if (strictNullChecks && aggregatedTypes.length && hasReturnWithNoExpression &&
59284                 !(isJSConstructor(func) && aggregatedTypes.some(function (t) { return t.symbol === func.symbol; }))) {
59285                 ts.pushIfUnique(aggregatedTypes, undefinedType);
59286             }
59287             return aggregatedTypes;
59288         }
59289         function mayReturnNever(func) {
59290             switch (func.kind) {
59291                 case 208:
59292                 case 209:
59293                     return true;
59294                 case 165:
59295                     return func.parent.kind === 200;
59296                 default:
59297                     return false;
59298             }
59299         }
59300         function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
59301             if (!produceDiagnostics) {
59302                 return;
59303             }
59304             var functionFlags = ts.getFunctionFlags(func);
59305             var type = returnType && unwrapReturnType(returnType, functionFlags);
59306             if (type && maybeTypeOfKind(type, 1 | 16384)) {
59307                 return;
59308             }
59309             if (func.kind === 164 || ts.nodeIsMissing(func.body) || func.body.kind !== 230 || !functionHasImplicitReturn(func)) {
59310                 return;
59311             }
59312             var hasExplicitReturn = func.flags & 512;
59313             if (type && type.flags & 131072) {
59314                 error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_returning_never_cannot_have_a_reachable_end_point);
59315             }
59316             else if (type && !hasExplicitReturn) {
59317                 error(ts.getEffectiveReturnTypeNode(func), ts.Diagnostics.A_function_whose_declared_type_is_neither_void_nor_any_must_return_a_value);
59318             }
59319             else if (type && strictNullChecks && !isTypeAssignableTo(undefinedType, type)) {
59320                 error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Function_lacks_ending_return_statement_and_return_type_does_not_include_undefined);
59321             }
59322             else if (compilerOptions.noImplicitReturns) {
59323                 if (!type) {
59324                     if (!hasExplicitReturn) {
59325                         return;
59326                     }
59327                     var inferredReturnType = getReturnTypeOfSignature(getSignatureFromDeclaration(func));
59328                     if (isUnwrappedReturnTypeVoidOrAny(func, inferredReturnType)) {
59329                         return;
59330                     }
59331                 }
59332                 error(ts.getEffectiveReturnTypeNode(func) || func, ts.Diagnostics.Not_all_code_paths_return_a_value);
59333             }
59334         }
59335         function checkFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
59336             ts.Debug.assert(node.kind !== 165 || ts.isObjectLiteralMethod(node));
59337             checkNodeDeferred(node);
59338             if (checkMode && checkMode & 4 && isContextSensitive(node)) {
59339                 if (!ts.getEffectiveReturnTypeNode(node) && !hasContextSensitiveParameters(node)) {
59340                     var contextualSignature = getContextualSignature(node);
59341                     if (contextualSignature && couldContainTypeVariables(getReturnTypeOfSignature(contextualSignature))) {
59342                         var links = getNodeLinks(node);
59343                         if (links.contextFreeType) {
59344                             return links.contextFreeType;
59345                         }
59346                         var returnType = getReturnTypeFromBody(node, checkMode);
59347                         var returnOnlySignature = createSignature(undefined, undefined, undefined, ts.emptyArray, returnType, undefined, 0, 0);
59348                         var returnOnlyType = createAnonymousType(node.symbol, emptySymbols, [returnOnlySignature], ts.emptyArray, undefined, undefined);
59349                         returnOnlyType.objectFlags |= 2097152;
59350                         return links.contextFreeType = returnOnlyType;
59351                     }
59352                 }
59353                 return anyFunctionType;
59354             }
59355             var hasGrammarError = checkGrammarFunctionLikeDeclaration(node);
59356             if (!hasGrammarError && node.kind === 208) {
59357                 checkGrammarForGenerator(node);
59358             }
59359             contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode);
59360             return getTypeOfSymbol(getSymbolOfNode(node));
59361         }
59362         function contextuallyCheckFunctionExpressionOrObjectLiteralMethod(node, checkMode) {
59363             var links = getNodeLinks(node);
59364             if (!(links.flags & 1024)) {
59365                 var contextualSignature = getContextualSignature(node);
59366                 if (!(links.flags & 1024)) {
59367                     links.flags |= 1024;
59368                     var signature = ts.firstOrUndefined(getSignaturesOfType(getTypeOfSymbol(getSymbolOfNode(node)), 0));
59369                     if (!signature) {
59370                         return;
59371                     }
59372                     if (isContextSensitive(node)) {
59373                         if (contextualSignature) {
59374                             var inferenceContext = getInferenceContext(node);
59375                             if (checkMode && checkMode & 2) {
59376                                 inferFromAnnotatedParameters(signature, contextualSignature, inferenceContext);
59377                             }
59378                             var instantiatedContextualSignature = inferenceContext ?
59379                                 instantiateSignature(contextualSignature, inferenceContext.mapper) : contextualSignature;
59380                             assignContextualParameterTypes(signature, instantiatedContextualSignature);
59381                         }
59382                         else {
59383                             assignNonContextualParameterTypes(signature);
59384                         }
59385                     }
59386                     if (contextualSignature && !getReturnTypeFromAnnotation(node) && !signature.resolvedReturnType) {
59387                         var returnType = getReturnTypeFromBody(node, checkMode);
59388                         if (!signature.resolvedReturnType) {
59389                             signature.resolvedReturnType = returnType;
59390                         }
59391                     }
59392                     checkSignatureDeclaration(node);
59393                 }
59394             }
59395         }
59396         function checkFunctionExpressionOrObjectLiteralMethodDeferred(node) {
59397             ts.Debug.assert(node.kind !== 165 || ts.isObjectLiteralMethod(node));
59398             var functionFlags = ts.getFunctionFlags(node);
59399             var returnType = getReturnTypeFromAnnotation(node);
59400             checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
59401             if (node.body) {
59402                 if (!ts.getEffectiveReturnTypeNode(node)) {
59403                     getReturnTypeOfSignature(getSignatureFromDeclaration(node));
59404                 }
59405                 if (node.body.kind === 230) {
59406                     checkSourceElement(node.body);
59407                 }
59408                 else {
59409                     var exprType = checkExpression(node.body);
59410                     var returnOrPromisedType = returnType && unwrapReturnType(returnType, functionFlags);
59411                     if (returnOrPromisedType) {
59412                         if ((functionFlags & 3) === 2) {
59413                             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);
59414                             checkTypeAssignableToAndOptionallyElaborate(awaitedType, returnOrPromisedType, node.body, node.body);
59415                         }
59416                         else {
59417                             checkTypeAssignableToAndOptionallyElaborate(exprType, returnOrPromisedType, node.body, node.body);
59418                         }
59419                     }
59420                 }
59421             }
59422         }
59423         function checkArithmeticOperandType(operand, type, diagnostic, isAwaitValid) {
59424             if (isAwaitValid === void 0) { isAwaitValid = false; }
59425             if (!isTypeAssignableTo(type, numberOrBigIntType)) {
59426                 var awaitedType = isAwaitValid && getAwaitedTypeOfPromise(type);
59427                 errorAndMaybeSuggestAwait(operand, !!awaitedType && isTypeAssignableTo(awaitedType, numberOrBigIntType), diagnostic);
59428                 return false;
59429             }
59430             return true;
59431         }
59432         function isReadonlyAssignmentDeclaration(d) {
59433             if (!ts.isCallExpression(d)) {
59434                 return false;
59435             }
59436             if (!ts.isBindableObjectDefinePropertyCall(d)) {
59437                 return false;
59438             }
59439             var objectLitType = checkExpressionCached(d.arguments[2]);
59440             var valueType = getTypeOfPropertyOfType(objectLitType, "value");
59441             if (valueType) {
59442                 var writableProp = getPropertyOfType(objectLitType, "writable");
59443                 var writableType = writableProp && getTypeOfSymbol(writableProp);
59444                 if (!writableType || writableType === falseType || writableType === regularFalseType) {
59445                     return true;
59446                 }
59447                 if (writableProp && writableProp.valueDeclaration && ts.isPropertyAssignment(writableProp.valueDeclaration)) {
59448                     var initializer = writableProp.valueDeclaration.initializer;
59449                     var rawOriginalType = checkExpression(initializer);
59450                     if (rawOriginalType === falseType || rawOriginalType === regularFalseType) {
59451                         return true;
59452                     }
59453                 }
59454                 return false;
59455             }
59456             var setProp = getPropertyOfType(objectLitType, "set");
59457             return !setProp;
59458         }
59459         function isReadonlySymbol(symbol) {
59460             return !!(ts.getCheckFlags(symbol) & 8 ||
59461                 symbol.flags & 4 && ts.getDeclarationModifierFlagsFromSymbol(symbol) & 64 ||
59462                 symbol.flags & 3 && getDeclarationNodeFlagsFromSymbol(symbol) & 2 ||
59463                 symbol.flags & 98304 && !(symbol.flags & 65536) ||
59464                 symbol.flags & 8 ||
59465                 ts.some(symbol.declarations, isReadonlyAssignmentDeclaration));
59466         }
59467         function isAssignmentToReadonlyEntity(expr, symbol, assignmentKind) {
59468             var _a, _b;
59469             if (assignmentKind === 0) {
59470                 return false;
59471             }
59472             if (isReadonlySymbol(symbol)) {
59473                 if (symbol.flags & 4 &&
59474                     ts.isAccessExpression(expr) &&
59475                     expr.expression.kind === 107) {
59476                     var ctor = ts.getContainingFunction(expr);
59477                     if (!(ctor && (ctor.kind === 166 || isJSConstructor(ctor)))) {
59478                         return true;
59479                     }
59480                     if (symbol.valueDeclaration) {
59481                         var isAssignmentDeclaration_1 = ts.isBinaryExpression(symbol.valueDeclaration);
59482                         var isLocalPropertyDeclaration = ctor.parent === symbol.valueDeclaration.parent;
59483                         var isLocalParameterProperty = ctor === symbol.valueDeclaration.parent;
59484                         var isLocalThisPropertyAssignment = isAssignmentDeclaration_1 && ((_a = symbol.parent) === null || _a === void 0 ? void 0 : _a.valueDeclaration) === ctor.parent;
59485                         var isLocalThisPropertyAssignmentConstructorFunction = isAssignmentDeclaration_1 && ((_b = symbol.parent) === null || _b === void 0 ? void 0 : _b.valueDeclaration) === ctor;
59486                         var isWriteableSymbol = isLocalPropertyDeclaration
59487                             || isLocalParameterProperty
59488                             || isLocalThisPropertyAssignment
59489                             || isLocalThisPropertyAssignmentConstructorFunction;
59490                         return !isWriteableSymbol;
59491                     }
59492                 }
59493                 return true;
59494             }
59495             if (ts.isAccessExpression(expr)) {
59496                 var node = ts.skipParentheses(expr.expression);
59497                 if (node.kind === 78) {
59498                     var symbol_2 = getNodeLinks(node).resolvedSymbol;
59499                     if (symbol_2.flags & 2097152) {
59500                         var declaration = getDeclarationOfAliasSymbol(symbol_2);
59501                         return !!declaration && declaration.kind === 263;
59502                     }
59503                 }
59504             }
59505             return false;
59506         }
59507         function checkReferenceExpression(expr, invalidReferenceMessage, invalidOptionalChainMessage) {
59508             var node = ts.skipOuterExpressions(expr, 6 | 1);
59509             if (node.kind !== 78 && !ts.isAccessExpression(node)) {
59510                 error(expr, invalidReferenceMessage);
59511                 return false;
59512             }
59513             if (node.flags & 32) {
59514                 error(expr, invalidOptionalChainMessage);
59515                 return false;
59516             }
59517             return true;
59518         }
59519         function checkDeleteExpression(node) {
59520             checkExpression(node.expression);
59521             var expr = ts.skipParentheses(node.expression);
59522             if (!ts.isAccessExpression(expr)) {
59523                 error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference);
59524                 return booleanType;
59525             }
59526             if (ts.isPropertyAccessExpression(expr) && ts.isPrivateIdentifier(expr.name)) {
59527                 error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_private_identifier);
59528             }
59529             var links = getNodeLinks(expr);
59530             var symbol = getExportSymbolOfValueSymbolIfExported(links.resolvedSymbol);
59531             if (symbol) {
59532                 if (isReadonlySymbol(symbol)) {
59533                     error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_read_only_property);
59534                 }
59535                 checkDeleteExpressionMustBeOptional(expr, getTypeOfSymbol(symbol));
59536             }
59537             return booleanType;
59538         }
59539         function checkDeleteExpressionMustBeOptional(expr, type) {
59540             var AnyOrUnknownOrNeverFlags = 3 | 131072;
59541             if (strictNullChecks && !(type.flags & AnyOrUnknownOrNeverFlags) && !(getFalsyFlags(type) & 32768)) {
59542                 error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_optional);
59543             }
59544         }
59545         function checkTypeOfExpression(node) {
59546             checkExpression(node.expression);
59547             return typeofType;
59548         }
59549         function checkVoidExpression(node) {
59550             checkExpression(node.expression);
59551             return undefinedWideningType;
59552         }
59553         function checkAwaitExpression(node) {
59554             if (produceDiagnostics) {
59555                 if (!(node.flags & 32768)) {
59556                     if (ts.isInTopLevelContext(node)) {
59557                         var sourceFile = ts.getSourceFileOfNode(node);
59558                         if (!hasParseDiagnostics(sourceFile)) {
59559                             var span = void 0;
59560                             if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
59561                                 if (!span)
59562                                     span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
59563                                 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);
59564                                 diagnostics.add(diagnostic);
59565                             }
59566                             if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4) {
59567                                 span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
59568                                 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);
59569                                 diagnostics.add(diagnostic);
59570                             }
59571                         }
59572                     }
59573                     else {
59574                         var sourceFile = ts.getSourceFileOfNode(node);
59575                         if (!hasParseDiagnostics(sourceFile)) {
59576                             var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
59577                             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);
59578                             var func = ts.getContainingFunction(node);
59579                             if (func && func.kind !== 166 && (ts.getFunctionFlags(func) & 2) === 0) {
59580                                 var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
59581                                 ts.addRelatedInfo(diagnostic, relatedInfo);
59582                             }
59583                             diagnostics.add(diagnostic);
59584                         }
59585                     }
59586                 }
59587                 if (isInParameterInitializerBeforeContainingFunction(node)) {
59588                     error(node, ts.Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer);
59589                 }
59590             }
59591             var operandType = checkExpression(node.expression);
59592             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);
59593             if (awaitedType === operandType && awaitedType !== errorType && !(operandType.flags & 3)) {
59594                 addErrorOrSuggestion(false, ts.createDiagnosticForNode(node, ts.Diagnostics.await_has_no_effect_on_the_type_of_this_expression));
59595             }
59596             return awaitedType;
59597         }
59598         function checkPrefixUnaryExpression(node) {
59599             var operandType = checkExpression(node.operand);
59600             if (operandType === silentNeverType) {
59601                 return silentNeverType;
59602             }
59603             switch (node.operand.kind) {
59604                 case 8:
59605                     switch (node.operator) {
59606                         case 40:
59607                             return getFreshTypeOfLiteralType(getLiteralType(-node.operand.text));
59608                         case 39:
59609                             return getFreshTypeOfLiteralType(getLiteralType(+node.operand.text));
59610                     }
59611                     break;
59612                 case 9:
59613                     if (node.operator === 40) {
59614                         return getFreshTypeOfLiteralType(getLiteralType({
59615                             negative: true,
59616                             base10Value: ts.parsePseudoBigInt(node.operand.text)
59617                         }));
59618                     }
59619             }
59620             switch (node.operator) {
59621                 case 39:
59622                 case 40:
59623                 case 54:
59624                     checkNonNullType(operandType, node.operand);
59625                     if (maybeTypeOfKind(operandType, 12288)) {
59626                         error(node.operand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(node.operator));
59627                     }
59628                     if (node.operator === 39) {
59629                         if (maybeTypeOfKind(operandType, 2112)) {
59630                             error(node.operand, ts.Diagnostics.Operator_0_cannot_be_applied_to_type_1, ts.tokenToString(node.operator), typeToString(getBaseTypeOfLiteralType(operandType)));
59631                         }
59632                         return numberType;
59633                     }
59634                     return getUnaryResultType(operandType);
59635                 case 53:
59636                     checkTruthinessExpression(node.operand);
59637                     var facts = getTypeFacts(operandType) & (4194304 | 8388608);
59638                     return facts === 4194304 ? falseType :
59639                         facts === 8388608 ? trueType :
59640                             booleanType;
59641                 case 45:
59642                 case 46:
59643                     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);
59644                     if (ok) {
59645                         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);
59646                     }
59647                     return getUnaryResultType(operandType);
59648             }
59649             return errorType;
59650         }
59651         function checkPostfixUnaryExpression(node) {
59652             var operandType = checkExpression(node.operand);
59653             if (operandType === silentNeverType) {
59654                 return silentNeverType;
59655             }
59656             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);
59657             if (ok) {
59658                 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);
59659             }
59660             return getUnaryResultType(operandType);
59661         }
59662         function getUnaryResultType(operandType) {
59663             if (maybeTypeOfKind(operandType, 2112)) {
59664                 return isTypeAssignableToKind(operandType, 3) || maybeTypeOfKind(operandType, 296)
59665                     ? numberOrBigIntType
59666                     : bigintType;
59667             }
59668             return numberType;
59669         }
59670         function maybeTypeOfKind(type, kind) {
59671             if (type.flags & kind) {
59672                 return true;
59673             }
59674             if (type.flags & 3145728) {
59675                 var types = type.types;
59676                 for (var _i = 0, types_22 = types; _i < types_22.length; _i++) {
59677                     var t = types_22[_i];
59678                     if (maybeTypeOfKind(t, kind)) {
59679                         return true;
59680                     }
59681                 }
59682             }
59683             return false;
59684         }
59685         function isTypeAssignableToKind(source, kind, strict) {
59686             if (source.flags & kind) {
59687                 return true;
59688             }
59689             if (strict && source.flags & (3 | 16384 | 32768 | 65536)) {
59690                 return false;
59691             }
59692             return !!(kind & 296) && isTypeAssignableTo(source, numberType) ||
59693                 !!(kind & 2112) && isTypeAssignableTo(source, bigintType) ||
59694                 !!(kind & 402653316) && isTypeAssignableTo(source, stringType) ||
59695                 !!(kind & 528) && isTypeAssignableTo(source, booleanType) ||
59696                 !!(kind & 16384) && isTypeAssignableTo(source, voidType) ||
59697                 !!(kind & 131072) && isTypeAssignableTo(source, neverType) ||
59698                 !!(kind & 65536) && isTypeAssignableTo(source, nullType) ||
59699                 !!(kind & 32768) && isTypeAssignableTo(source, undefinedType) ||
59700                 !!(kind & 4096) && isTypeAssignableTo(source, esSymbolType) ||
59701                 !!(kind & 67108864) && isTypeAssignableTo(source, nonPrimitiveType);
59702         }
59703         function allTypesAssignableToKind(source, kind, strict) {
59704             return source.flags & 1048576 ?
59705                 ts.every(source.types, function (subType) { return allTypesAssignableToKind(subType, kind, strict); }) :
59706                 isTypeAssignableToKind(source, kind, strict);
59707         }
59708         function isConstEnumObjectType(type) {
59709             return !!(ts.getObjectFlags(type) & 16) && !!type.symbol && isConstEnumSymbol(type.symbol);
59710         }
59711         function isConstEnumSymbol(symbol) {
59712             return (symbol.flags & 128) !== 0;
59713         }
59714         function checkInstanceOfExpression(left, right, leftType, rightType) {
59715             if (leftType === silentNeverType || rightType === silentNeverType) {
59716                 return silentNeverType;
59717             }
59718             if (!isTypeAny(leftType) &&
59719                 allTypesAssignableToKind(leftType, 131068)) {
59720                 error(left, ts.Diagnostics.The_left_hand_side_of_an_instanceof_expression_must_be_of_type_any_an_object_type_or_a_type_parameter);
59721             }
59722             if (!(isTypeAny(rightType) || typeHasCallOrConstructSignatures(rightType) || isTypeSubtypeOf(rightType, globalFunctionType))) {
59723                 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);
59724             }
59725             return booleanType;
59726         }
59727         function checkInExpression(left, right, leftType, rightType) {
59728             if (leftType === silentNeverType || rightType === silentNeverType) {
59729                 return silentNeverType;
59730             }
59731             leftType = checkNonNullType(leftType, left);
59732             rightType = checkNonNullType(rightType, right);
59733             if (!(allTypesAssignableToKind(leftType, 402653316 | 296 | 12288) ||
59734                 isTypeAssignableToKind(leftType, 4194304 | 134217728 | 268435456 | 262144))) {
59735                 error(left, ts.Diagnostics.The_left_hand_side_of_an_in_expression_must_be_of_type_any_string_number_or_symbol);
59736             }
59737             var rightTypeConstraint = getConstraintOfType(rightType);
59738             if (!allTypesAssignableToKind(rightType, 67108864 | 58982400) ||
59739                 rightTypeConstraint && (isTypeAssignableToKind(rightType, 3145728) && !allTypesAssignableToKind(rightTypeConstraint, 67108864 | 58982400) ||
59740                     !maybeTypeOfKind(rightTypeConstraint, 67108864 | 58982400 | 524288))) {
59741                 error(right, ts.Diagnostics.The_right_hand_side_of_an_in_expression_must_not_be_a_primitive);
59742             }
59743             return booleanType;
59744         }
59745         function checkObjectLiteralAssignment(node, sourceType, rightIsThis) {
59746             var properties = node.properties;
59747             if (strictNullChecks && properties.length === 0) {
59748                 return checkNonNullType(sourceType, node);
59749             }
59750             for (var i = 0; i < properties.length; i++) {
59751                 checkObjectLiteralDestructuringPropertyAssignment(node, sourceType, i, properties, rightIsThis);
59752             }
59753             return sourceType;
59754         }
59755         function checkObjectLiteralDestructuringPropertyAssignment(node, objectLiteralType, propertyIndex, allProperties, rightIsThis) {
59756             if (rightIsThis === void 0) { rightIsThis = false; }
59757             var properties = node.properties;
59758             var property = properties[propertyIndex];
59759             if (property.kind === 288 || property.kind === 289) {
59760                 var name = property.name;
59761                 var exprType = getLiteralTypeFromPropertyName(name);
59762                 if (isTypeUsableAsPropertyName(exprType)) {
59763                     var text = getPropertyNameFromType(exprType);
59764                     var prop = getPropertyOfType(objectLiteralType, text);
59765                     if (prop) {
59766                         markPropertyAsReferenced(prop, property, rightIsThis);
59767                         checkPropertyAccessibility(property, false, objectLiteralType, prop);
59768                     }
59769                 }
59770                 var elementType = getIndexedAccessType(objectLiteralType, exprType, undefined, name, undefined, undefined, 16);
59771                 var type = getFlowTypeOfDestructuring(property, elementType);
59772                 return checkDestructuringAssignment(property.kind === 289 ? property : property.initializer, type);
59773             }
59774             else if (property.kind === 290) {
59775                 if (propertyIndex < properties.length - 1) {
59776                     error(property, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
59777                 }
59778                 else {
59779                     if (languageVersion < 99) {
59780                         checkExternalEmitHelpers(property, 4);
59781                     }
59782                     var nonRestNames = [];
59783                     if (allProperties) {
59784                         for (var _i = 0, allProperties_1 = allProperties; _i < allProperties_1.length; _i++) {
59785                             var otherProperty = allProperties_1[_i];
59786                             if (!ts.isSpreadAssignment(otherProperty)) {
59787                                 nonRestNames.push(otherProperty.name);
59788                             }
59789                         }
59790                     }
59791                     var type = getRestType(objectLiteralType, nonRestNames, objectLiteralType.symbol);
59792                     checkGrammarForDisallowedTrailingComma(allProperties, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
59793                     return checkDestructuringAssignment(property.expression, type);
59794                 }
59795             }
59796             else {
59797                 error(property, ts.Diagnostics.Property_assignment_expected);
59798             }
59799         }
59800         function checkArrayLiteralAssignment(node, sourceType, checkMode) {
59801             var elements = node.elements;
59802             if (languageVersion < 2 && compilerOptions.downlevelIteration) {
59803                 checkExternalEmitHelpers(node, 512);
59804             }
59805             var possiblyOutOfBoundsType = checkIteratedTypeOrElementType(65 | 128, sourceType, undefinedType, node) || errorType;
59806             var inBoundsType = compilerOptions.noUncheckedIndexedAccess ? undefined : possiblyOutOfBoundsType;
59807             for (var i = 0; i < elements.length; i++) {
59808                 var type = possiblyOutOfBoundsType;
59809                 if (node.elements[i].kind === 220) {
59810                     type = inBoundsType = inBoundsType !== null && inBoundsType !== void 0 ? inBoundsType : (checkIteratedTypeOrElementType(65, sourceType, undefinedType, node) || errorType);
59811                 }
59812                 checkArrayLiteralDestructuringElementAssignment(node, sourceType, i, type, checkMode);
59813             }
59814             return sourceType;
59815         }
59816         function checkArrayLiteralDestructuringElementAssignment(node, sourceType, elementIndex, elementType, checkMode) {
59817             var elements = node.elements;
59818             var element = elements[elementIndex];
59819             if (element.kind !== 222) {
59820                 if (element.kind !== 220) {
59821                     var indexType = getLiteralType(elementIndex);
59822                     if (isArrayLikeType(sourceType)) {
59823                         var accessFlags = 16 | (hasDefaultValue(element) ? 8 : 0);
59824                         var elementType_2 = getIndexedAccessTypeOrUndefined(sourceType, indexType, undefined, createSyntheticExpression(element, indexType), accessFlags) || errorType;
59825                         var assignedType = hasDefaultValue(element) ? getTypeWithFacts(elementType_2, 524288) : elementType_2;
59826                         var type = getFlowTypeOfDestructuring(element, assignedType);
59827                         return checkDestructuringAssignment(element, type, checkMode);
59828                     }
59829                     return checkDestructuringAssignment(element, elementType, checkMode);
59830                 }
59831                 if (elementIndex < elements.length - 1) {
59832                     error(element, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
59833                 }
59834                 else {
59835                     var restExpression = element.expression;
59836                     if (restExpression.kind === 216 && restExpression.operatorToken.kind === 62) {
59837                         error(restExpression.operatorToken, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
59838                     }
59839                     else {
59840                         checkGrammarForDisallowedTrailingComma(node.elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
59841                         var type = everyType(sourceType, isTupleType) ?
59842                             mapType(sourceType, function (t) { return sliceTupleType(t, elementIndex); }) :
59843                             createArrayType(elementType);
59844                         return checkDestructuringAssignment(restExpression, type, checkMode);
59845                     }
59846                 }
59847             }
59848             return undefined;
59849         }
59850         function checkDestructuringAssignment(exprOrAssignment, sourceType, checkMode, rightIsThis) {
59851             var target;
59852             if (exprOrAssignment.kind === 289) {
59853                 var prop = exprOrAssignment;
59854                 if (prop.objectAssignmentInitializer) {
59855                     if (strictNullChecks &&
59856                         !(getFalsyFlags(checkExpression(prop.objectAssignmentInitializer)) & 32768)) {
59857                         sourceType = getTypeWithFacts(sourceType, 524288);
59858                     }
59859                     checkBinaryLikeExpression(prop.name, prop.equalsToken, prop.objectAssignmentInitializer, checkMode);
59860                 }
59861                 target = exprOrAssignment.name;
59862             }
59863             else {
59864                 target = exprOrAssignment;
59865             }
59866             if (target.kind === 216 && target.operatorToken.kind === 62) {
59867                 checkBinaryExpression(target, checkMode);
59868                 target = target.left;
59869             }
59870             if (target.kind === 200) {
59871                 return checkObjectLiteralAssignment(target, sourceType, rightIsThis);
59872             }
59873             if (target.kind === 199) {
59874                 return checkArrayLiteralAssignment(target, sourceType, checkMode);
59875             }
59876             return checkReferenceAssignment(target, sourceType, checkMode);
59877         }
59878         function checkReferenceAssignment(target, sourceType, checkMode) {
59879             var targetType = checkExpression(target, checkMode);
59880             var error = target.parent.kind === 290 ?
59881                 ts.Diagnostics.The_target_of_an_object_rest_assignment_must_be_a_variable_or_a_property_access :
59882                 ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_must_be_a_variable_or_a_property_access;
59883             var optionalError = target.parent.kind === 290 ?
59884                 ts.Diagnostics.The_target_of_an_object_rest_assignment_may_not_be_an_optional_property_access :
59885                 ts.Diagnostics.The_left_hand_side_of_an_assignment_expression_may_not_be_an_optional_property_access;
59886             if (checkReferenceExpression(target, error, optionalError)) {
59887                 checkTypeAssignableToAndOptionallyElaborate(sourceType, targetType, target, target);
59888             }
59889             if (ts.isPrivateIdentifierPropertyAccessExpression(target)) {
59890                 checkExternalEmitHelpers(target.parent, 1048576);
59891             }
59892             return sourceType;
59893         }
59894         function isSideEffectFree(node) {
59895             node = ts.skipParentheses(node);
59896             switch (node.kind) {
59897                 case 78:
59898                 case 10:
59899                 case 13:
59900                 case 205:
59901                 case 218:
59902                 case 14:
59903                 case 8:
59904                 case 9:
59905                 case 109:
59906                 case 94:
59907                 case 103:
59908                 case 150:
59909                 case 208:
59910                 case 221:
59911                 case 209:
59912                 case 199:
59913                 case 200:
59914                 case 211:
59915                 case 225:
59916                 case 274:
59917                 case 273:
59918                     return true;
59919                 case 217:
59920                     return isSideEffectFree(node.whenTrue) &&
59921                         isSideEffectFree(node.whenFalse);
59922                 case 216:
59923                     if (ts.isAssignmentOperator(node.operatorToken.kind)) {
59924                         return false;
59925                     }
59926                     return isSideEffectFree(node.left) &&
59927                         isSideEffectFree(node.right);
59928                 case 214:
59929                 case 215:
59930                     switch (node.operator) {
59931                         case 53:
59932                         case 39:
59933                         case 40:
59934                         case 54:
59935                             return true;
59936                     }
59937                     return false;
59938                 case 212:
59939                 case 206:
59940                 case 224:
59941                 default:
59942                     return false;
59943             }
59944         }
59945         function isTypeEqualityComparableTo(source, target) {
59946             return (target.flags & 98304) !== 0 || isTypeComparableTo(source, target);
59947         }
59948         function checkBinaryExpression(node, checkMode) {
59949             var workStacks = {
59950                 expr: [node],
59951                 state: [0],
59952                 leftType: [undefined]
59953             };
59954             var stackIndex = 0;
59955             var lastResult;
59956             while (stackIndex >= 0) {
59957                 node = workStacks.expr[stackIndex];
59958                 switch (workStacks.state[stackIndex]) {
59959                     case 0: {
59960                         if (ts.isInJSFile(node) && ts.getAssignedExpandoInitializer(node)) {
59961                             finishInvocation(checkExpression(node.right, checkMode));
59962                             break;
59963                         }
59964                         checkGrammarNullishCoalesceWithLogicalExpression(node);
59965                         var operator = node.operatorToken.kind;
59966                         if (operator === 62 && (node.left.kind === 200 || node.left.kind === 199)) {
59967                             finishInvocation(checkDestructuringAssignment(node.left, checkExpression(node.right, checkMode), checkMode, node.right.kind === 107));
59968                             break;
59969                         }
59970                         advanceState(1);
59971                         maybeCheckExpression(node.left);
59972                         break;
59973                     }
59974                     case 1: {
59975                         var leftType = lastResult;
59976                         workStacks.leftType[stackIndex] = leftType;
59977                         var operator = node.operatorToken.kind;
59978                         if (operator === 55 || operator === 56 || operator === 60) {
59979                             if (operator === 55) {
59980                                 var parent = ts.walkUpParenthesizedExpressions(node.parent);
59981                                 checkTestingKnownTruthyCallableType(node.left, leftType, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
59982                             }
59983                             checkTruthinessOfType(leftType, node.left);
59984                         }
59985                         advanceState(2);
59986                         maybeCheckExpression(node.right);
59987                         break;
59988                     }
59989                     case 2: {
59990                         var leftType = workStacks.leftType[stackIndex];
59991                         var rightType = lastResult;
59992                         finishInvocation(checkBinaryLikeExpressionWorker(node.left, node.operatorToken, node.right, leftType, rightType, node));
59993                         break;
59994                     }
59995                     default: return ts.Debug.fail("Invalid state " + workStacks.state[stackIndex] + " for checkBinaryExpression");
59996                 }
59997             }
59998             return lastResult;
59999             function finishInvocation(result) {
60000                 lastResult = result;
60001                 stackIndex--;
60002             }
60003             function advanceState(nextState) {
60004                 workStacks.state[stackIndex] = nextState;
60005             }
60006             function maybeCheckExpression(node) {
60007                 if (ts.isBinaryExpression(node)) {
60008                     stackIndex++;
60009                     workStacks.expr[stackIndex] = node;
60010                     workStacks.state[stackIndex] = 0;
60011                     workStacks.leftType[stackIndex] = undefined;
60012                 }
60013                 else {
60014                     lastResult = checkExpression(node, checkMode);
60015                 }
60016             }
60017         }
60018         function checkGrammarNullishCoalesceWithLogicalExpression(node) {
60019             var left = node.left, operatorToken = node.operatorToken, right = node.right;
60020             if (operatorToken.kind === 60) {
60021                 if (ts.isBinaryExpression(left) && (left.operatorToken.kind === 56 || left.operatorToken.kind === 55)) {
60022                     grammarErrorOnNode(left, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(left.operatorToken.kind), ts.tokenToString(operatorToken.kind));
60023                 }
60024                 if (ts.isBinaryExpression(right) && (right.operatorToken.kind === 56 || right.operatorToken.kind === 55)) {
60025                     grammarErrorOnNode(right, ts.Diagnostics._0_and_1_operations_cannot_be_mixed_without_parentheses, ts.tokenToString(right.operatorToken.kind), ts.tokenToString(operatorToken.kind));
60026                 }
60027             }
60028         }
60029         function checkBinaryLikeExpression(left, operatorToken, right, checkMode, errorNode) {
60030             var operator = operatorToken.kind;
60031             if (operator === 62 && (left.kind === 200 || left.kind === 199)) {
60032                 return checkDestructuringAssignment(left, checkExpression(right, checkMode), checkMode, right.kind === 107);
60033             }
60034             var leftType;
60035             if (operator === 55 || operator === 56 || operator === 60) {
60036                 leftType = checkTruthinessExpression(left, checkMode);
60037             }
60038             else {
60039                 leftType = checkExpression(left, checkMode);
60040             }
60041             var rightType = checkExpression(right, checkMode);
60042             return checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode);
60043         }
60044         function checkBinaryLikeExpressionWorker(left, operatorToken, right, leftType, rightType, errorNode) {
60045             var operator = operatorToken.kind;
60046             switch (operator) {
60047                 case 41:
60048                 case 42:
60049                 case 65:
60050                 case 66:
60051                 case 43:
60052                 case 67:
60053                 case 44:
60054                 case 68:
60055                 case 40:
60056                 case 64:
60057                 case 47:
60058                 case 69:
60059                 case 48:
60060                 case 70:
60061                 case 49:
60062                 case 71:
60063                 case 51:
60064                 case 73:
60065                 case 52:
60066                 case 77:
60067                 case 50:
60068                 case 72:
60069                     if (leftType === silentNeverType || rightType === silentNeverType) {
60070                         return silentNeverType;
60071                     }
60072                     leftType = checkNonNullType(leftType, left);
60073                     rightType = checkNonNullType(rightType, right);
60074                     var suggestedOperator = void 0;
60075                     if ((leftType.flags & 528) &&
60076                         (rightType.flags & 528) &&
60077                         (suggestedOperator = getSuggestedBooleanOperator(operatorToken.kind)) !== undefined) {
60078                         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));
60079                         return numberType;
60080                     }
60081                     else {
60082                         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);
60083                         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);
60084                         var resultType_1;
60085                         if ((isTypeAssignableToKind(leftType, 3) && isTypeAssignableToKind(rightType, 3)) ||
60086                             !(maybeTypeOfKind(leftType, 2112) || maybeTypeOfKind(rightType, 2112))) {
60087                             resultType_1 = numberType;
60088                         }
60089                         else if (bothAreBigIntLike(leftType, rightType)) {
60090                             switch (operator) {
60091                                 case 49:
60092                                 case 71:
60093                                     reportOperatorError();
60094                                     break;
60095                                 case 42:
60096                                 case 66:
60097                                     if (languageVersion < 3) {
60098                                         error(errorNode, ts.Diagnostics.Exponentiation_cannot_be_performed_on_bigint_values_unless_the_target_option_is_set_to_es2016_or_later);
60099                                     }
60100                             }
60101                             resultType_1 = bigintType;
60102                         }
60103                         else {
60104                             reportOperatorError(bothAreBigIntLike);
60105                             resultType_1 = errorType;
60106                         }
60107                         if (leftOk && rightOk) {
60108                             checkAssignmentOperator(resultType_1);
60109                         }
60110                         return resultType_1;
60111                     }
60112                 case 39:
60113                 case 63:
60114                     if (leftType === silentNeverType || rightType === silentNeverType) {
60115                         return silentNeverType;
60116                     }
60117                     if (!isTypeAssignableToKind(leftType, 402653316) && !isTypeAssignableToKind(rightType, 402653316)) {
60118                         leftType = checkNonNullType(leftType, left);
60119                         rightType = checkNonNullType(rightType, right);
60120                     }
60121                     var resultType = void 0;
60122                     if (isTypeAssignableToKind(leftType, 296, true) && isTypeAssignableToKind(rightType, 296, true)) {
60123                         resultType = numberType;
60124                     }
60125                     else if (isTypeAssignableToKind(leftType, 2112, true) && isTypeAssignableToKind(rightType, 2112, true)) {
60126                         resultType = bigintType;
60127                     }
60128                     else if (isTypeAssignableToKind(leftType, 402653316, true) || isTypeAssignableToKind(rightType, 402653316, true)) {
60129                         resultType = stringType;
60130                     }
60131                     else if (isTypeAny(leftType) || isTypeAny(rightType)) {
60132                         resultType = leftType === errorType || rightType === errorType ? errorType : anyType;
60133                     }
60134                     if (resultType && !checkForDisallowedESSymbolOperand(operator)) {
60135                         return resultType;
60136                     }
60137                     if (!resultType) {
60138                         var closeEnoughKind_1 = 296 | 2112 | 402653316 | 3;
60139                         reportOperatorError(function (left, right) {
60140                             return isTypeAssignableToKind(left, closeEnoughKind_1) &&
60141                                 isTypeAssignableToKind(right, closeEnoughKind_1);
60142                         });
60143                         return anyType;
60144                     }
60145                     if (operator === 63) {
60146                         checkAssignmentOperator(resultType);
60147                     }
60148                     return resultType;
60149                 case 29:
60150                 case 31:
60151                 case 32:
60152                 case 33:
60153                     if (checkForDisallowedESSymbolOperand(operator)) {
60154                         leftType = getBaseTypeOfLiteralType(checkNonNullType(leftType, left));
60155                         rightType = getBaseTypeOfLiteralType(checkNonNullType(rightType, right));
60156                         reportOperatorErrorUnless(function (left, right) {
60157                             return isTypeComparableTo(left, right) || isTypeComparableTo(right, left) || (isTypeAssignableTo(left, numberOrBigIntType) && isTypeAssignableTo(right, numberOrBigIntType));
60158                         });
60159                     }
60160                     return booleanType;
60161                 case 34:
60162                 case 35:
60163                 case 36:
60164                 case 37:
60165                     reportOperatorErrorUnless(function (left, right) { return isTypeEqualityComparableTo(left, right) || isTypeEqualityComparableTo(right, left); });
60166                     return booleanType;
60167                 case 101:
60168                     return checkInstanceOfExpression(left, right, leftType, rightType);
60169                 case 100:
60170                     return checkInExpression(left, right, leftType, rightType);
60171                 case 55:
60172                 case 75: {
60173                     var resultType_2 = getTypeFacts(leftType) & 4194304 ?
60174                         getUnionType([extractDefinitelyFalsyTypes(strictNullChecks ? leftType : getBaseTypeOfLiteralType(rightType)), rightType]) :
60175                         leftType;
60176                     if (operator === 75) {
60177                         checkAssignmentOperator(rightType);
60178                     }
60179                     return resultType_2;
60180                 }
60181                 case 56:
60182                 case 74: {
60183                     var resultType_3 = getTypeFacts(leftType) & 8388608 ?
60184                         getUnionType([removeDefinitelyFalsyTypes(leftType), rightType], 2) :
60185                         leftType;
60186                     if (operator === 74) {
60187                         checkAssignmentOperator(rightType);
60188                     }
60189                     return resultType_3;
60190                 }
60191                 case 60:
60192                 case 76: {
60193                     var resultType_4 = getTypeFacts(leftType) & 262144 ?
60194                         getUnionType([getNonNullableType(leftType), rightType], 2) :
60195                         leftType;
60196                     if (operator === 76) {
60197                         checkAssignmentOperator(rightType);
60198                     }
60199                     return resultType_4;
60200                 }
60201                 case 62:
60202                     var declKind = ts.isBinaryExpression(left.parent) ? ts.getAssignmentDeclarationKind(left.parent) : 0;
60203                     checkAssignmentDeclaration(declKind, rightType);
60204                     if (isAssignmentDeclaration(declKind)) {
60205                         if (!(rightType.flags & 524288) ||
60206                             declKind !== 2 &&
60207                                 declKind !== 6 &&
60208                                 !isEmptyObjectType(rightType) &&
60209                                 !isFunctionObjectType(rightType) &&
60210                                 !(ts.getObjectFlags(rightType) & 1)) {
60211                             checkAssignmentOperator(rightType);
60212                         }
60213                         return leftType;
60214                     }
60215                     else {
60216                         checkAssignmentOperator(rightType);
60217                         return getRegularTypeOfObjectLiteral(rightType);
60218                     }
60219                 case 27:
60220                     if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right)) {
60221                         var sf = ts.getSourceFileOfNode(left);
60222                         var sourceText = sf.text;
60223                         var start_3 = ts.skipTrivia(sourceText, left.pos);
60224                         var isInDiag2657 = sf.parseDiagnostics.some(function (diag) {
60225                             if (diag.code !== ts.Diagnostics.JSX_expressions_must_have_one_parent_element.code)
60226                                 return false;
60227                             return ts.textSpanContainsPosition(diag, start_3);
60228                         });
60229                         if (!isInDiag2657)
60230                             error(left, ts.Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects);
60231                     }
60232                     return rightType;
60233                 default:
60234                     return ts.Debug.fail();
60235             }
60236             function bothAreBigIntLike(left, right) {
60237                 return isTypeAssignableToKind(left, 2112) && isTypeAssignableToKind(right, 2112);
60238             }
60239             function checkAssignmentDeclaration(kind, rightType) {
60240                 if (kind === 2) {
60241                     for (var _i = 0, _a = getPropertiesOfObjectType(rightType); _i < _a.length; _i++) {
60242                         var prop = _a[_i];
60243                         var propType = getTypeOfSymbol(prop);
60244                         if (propType.symbol && propType.symbol.flags & 32) {
60245                             var name = prop.escapedName;
60246                             var symbol = resolveName(prop.valueDeclaration, name, 788968, undefined, name, false);
60247                             if (symbol && symbol.declarations.some(ts.isJSDocTypedefTag)) {
60248                                 addDuplicateDeclarationErrorsForSymbols(symbol, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), prop);
60249                                 addDuplicateDeclarationErrorsForSymbols(prop, ts.Diagnostics.Duplicate_identifier_0, ts.unescapeLeadingUnderscores(name), symbol);
60250                             }
60251                         }
60252                     }
60253                 }
60254             }
60255             function isEvalNode(node) {
60256                 return node.kind === 78 && node.escapedText === "eval";
60257             }
60258             function checkForDisallowedESSymbolOperand(operator) {
60259                 var offendingSymbolOperand = maybeTypeOfKind(leftType, 12288) ? left :
60260                     maybeTypeOfKind(rightType, 12288) ? right :
60261                         undefined;
60262                 if (offendingSymbolOperand) {
60263                     error(offendingSymbolOperand, ts.Diagnostics.The_0_operator_cannot_be_applied_to_type_symbol, ts.tokenToString(operator));
60264                     return false;
60265                 }
60266                 return true;
60267             }
60268             function getSuggestedBooleanOperator(operator) {
60269                 switch (operator) {
60270                     case 51:
60271                     case 73:
60272                         return 56;
60273                     case 52:
60274                     case 77:
60275                         return 37;
60276                     case 50:
60277                     case 72:
60278                         return 55;
60279                     default:
60280                         return undefined;
60281                 }
60282             }
60283             function checkAssignmentOperator(valueType) {
60284                 if (produceDiagnostics && ts.isAssignmentOperator(operator)) {
60285                     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)
60286                         && (!ts.isIdentifier(left) || ts.unescapeLeadingUnderscores(left.escapedText) !== "exports")) {
60287                         checkTypeAssignableToAndOptionallyElaborate(valueType, leftType, left, right);
60288                     }
60289                 }
60290             }
60291             function isAssignmentDeclaration(kind) {
60292                 var _a;
60293                 switch (kind) {
60294                     case 2:
60295                         return true;
60296                     case 1:
60297                     case 5:
60298                     case 6:
60299                     case 3:
60300                     case 4:
60301                         var symbol = getSymbolOfNode(left);
60302                         var init = ts.getAssignedExpandoInitializer(right);
60303                         return !!init && ts.isObjectLiteralExpression(init) &&
60304                             !!((_a = symbol === null || symbol === void 0 ? void 0 : symbol.exports) === null || _a === void 0 ? void 0 : _a.size);
60305                     default:
60306                         return false;
60307                 }
60308             }
60309             function reportOperatorErrorUnless(typesAreCompatible) {
60310                 if (!typesAreCompatible(leftType, rightType)) {
60311                     reportOperatorError(typesAreCompatible);
60312                     return true;
60313                 }
60314                 return false;
60315             }
60316             function reportOperatorError(isRelated) {
60317                 var _a;
60318                 var wouldWorkWithAwait = false;
60319                 var errNode = errorNode || operatorToken;
60320                 if (isRelated) {
60321                     var awaitedLeftType = getAwaitedType(leftType);
60322                     var awaitedRightType = getAwaitedType(rightType);
60323                     wouldWorkWithAwait = !(awaitedLeftType === leftType && awaitedRightType === rightType)
60324                         && !!(awaitedLeftType && awaitedRightType)
60325                         && isRelated(awaitedLeftType, awaitedRightType);
60326                 }
60327                 var effectiveLeft = leftType;
60328                 var effectiveRight = rightType;
60329                 if (!wouldWorkWithAwait && isRelated) {
60330                     _a = getBaseTypesIfUnrelated(leftType, rightType, isRelated), effectiveLeft = _a[0], effectiveRight = _a[1];
60331                 }
60332                 var _b = getTypeNamesForErrorDisplay(effectiveLeft, effectiveRight), leftStr = _b[0], rightStr = _b[1];
60333                 if (!tryGiveBetterPrimaryError(errNode, wouldWorkWithAwait, leftStr, rightStr)) {
60334                     errorAndMaybeSuggestAwait(errNode, wouldWorkWithAwait, ts.Diagnostics.Operator_0_cannot_be_applied_to_types_1_and_2, ts.tokenToString(operatorToken.kind), leftStr, rightStr);
60335                 }
60336             }
60337             function tryGiveBetterPrimaryError(errNode, maybeMissingAwait, leftStr, rightStr) {
60338                 var typeName;
60339                 switch (operatorToken.kind) {
60340                     case 36:
60341                     case 34:
60342                         typeName = "false";
60343                         break;
60344                     case 37:
60345                     case 35:
60346                         typeName = "true";
60347                 }
60348                 if (typeName) {
60349                     return errorAndMaybeSuggestAwait(errNode, maybeMissingAwait, ts.Diagnostics.This_condition_will_always_return_0_since_the_types_1_and_2_have_no_overlap, typeName, leftStr, rightStr);
60350                 }
60351                 return undefined;
60352             }
60353         }
60354         function getBaseTypesIfUnrelated(leftType, rightType, isRelated) {
60355             var effectiveLeft = leftType;
60356             var effectiveRight = rightType;
60357             var leftBase = getBaseTypeOfLiteralType(leftType);
60358             var rightBase = getBaseTypeOfLiteralType(rightType);
60359             if (!isRelated(leftBase, rightBase)) {
60360                 effectiveLeft = leftBase;
60361                 effectiveRight = rightBase;
60362             }
60363             return [effectiveLeft, effectiveRight];
60364         }
60365         function checkYieldExpression(node) {
60366             if (produceDiagnostics) {
60367                 if (!(node.flags & 8192)) {
60368                     grammarErrorOnFirstToken(node, ts.Diagnostics.A_yield_expression_is_only_allowed_in_a_generator_body);
60369                 }
60370                 if (isInParameterInitializerBeforeContainingFunction(node)) {
60371                     error(node, ts.Diagnostics.yield_expressions_cannot_be_used_in_a_parameter_initializer);
60372                 }
60373             }
60374             var func = ts.getContainingFunction(node);
60375             if (!func)
60376                 return anyType;
60377             var functionFlags = ts.getFunctionFlags(func);
60378             if (!(functionFlags & 1)) {
60379                 return anyType;
60380             }
60381             var isAsync = (functionFlags & 2) !== 0;
60382             if (node.asteriskToken) {
60383                 if (isAsync && languageVersion < 99) {
60384                     checkExternalEmitHelpers(node, 26624);
60385                 }
60386                 if (!isAsync && languageVersion < 2 && compilerOptions.downlevelIteration) {
60387                     checkExternalEmitHelpers(node, 256);
60388                 }
60389             }
60390             var returnType = getReturnTypeFromAnnotation(func);
60391             var iterationTypes = returnType && getIterationTypesOfGeneratorFunctionReturnType(returnType, isAsync);
60392             var signatureYieldType = iterationTypes && iterationTypes.yieldType || anyType;
60393             var signatureNextType = iterationTypes && iterationTypes.nextType || anyType;
60394             var resolvedSignatureNextType = isAsync ? getAwaitedType(signatureNextType) || anyType : signatureNextType;
60395             var yieldExpressionType = node.expression ? checkExpression(node.expression) : undefinedWideningType;
60396             var yieldedType = getYieldedTypeOfYieldExpression(node, yieldExpressionType, resolvedSignatureNextType, isAsync);
60397             if (returnType && yieldedType) {
60398                 checkTypeAssignableToAndOptionallyElaborate(yieldedType, signatureYieldType, node.expression || node, node.expression);
60399             }
60400             if (node.asteriskToken) {
60401                 var use = isAsync ? 19 : 17;
60402                 return getIterationTypeOfIterable(use, 1, yieldExpressionType, node.expression)
60403                     || anyType;
60404             }
60405             else if (returnType) {
60406                 return getIterationTypeOfGeneratorFunctionReturnType(2, returnType, isAsync)
60407                     || anyType;
60408             }
60409             var type = getContextualIterationType(2, func);
60410             if (!type) {
60411                 type = anyType;
60412                 if (produceDiagnostics && noImplicitAny && !ts.expressionResultIsUnused(node)) {
60413                     var contextualType = getContextualType(node);
60414                     if (!contextualType || isTypeAny(contextualType)) {
60415                         error(node, ts.Diagnostics.yield_expression_implicitly_results_in_an_any_type_because_its_containing_generator_lacks_a_return_type_annotation);
60416                     }
60417                 }
60418             }
60419             return type;
60420         }
60421         function checkConditionalExpression(node, checkMode) {
60422             var type = checkTruthinessExpression(node.condition);
60423             checkTestingKnownTruthyCallableType(node.condition, type, node.whenTrue);
60424             var type1 = checkExpression(node.whenTrue, checkMode);
60425             var type2 = checkExpression(node.whenFalse, checkMode);
60426             return getUnionType([type1, type2], 2);
60427         }
60428         function checkTemplateExpression(node) {
60429             var texts = [node.head.text];
60430             var types = [];
60431             for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) {
60432                 var span = _a[_i];
60433                 var type = checkExpression(span.expression);
60434                 if (maybeTypeOfKind(type, 12288)) {
60435                     error(span.expression, ts.Diagnostics.Implicit_conversion_of_a_symbol_to_a_string_will_fail_at_runtime_Consider_wrapping_this_expression_in_String);
60436                 }
60437                 texts.push(span.literal.text);
60438                 types.push(isTypeAssignableTo(type, templateConstraintType) ? type : stringType);
60439             }
60440             return isConstContext(node) ? getTemplateLiteralType(texts, types) : stringType;
60441         }
60442         function getContextNode(node) {
60443             if (node.kind === 281 && !ts.isJsxSelfClosingElement(node.parent)) {
60444                 return node.parent.parent;
60445             }
60446             return node;
60447         }
60448         function checkExpressionWithContextualType(node, contextualType, inferenceContext, checkMode) {
60449             var context = getContextNode(node);
60450             var saveContextualType = context.contextualType;
60451             var saveInferenceContext = context.inferenceContext;
60452             try {
60453                 context.contextualType = contextualType;
60454                 context.inferenceContext = inferenceContext;
60455                 var type = checkExpression(node, checkMode | 1 | (inferenceContext ? 2 : 0));
60456                 var result = maybeTypeOfKind(type, 2944) && isLiteralOfContextualType(type, instantiateContextualType(contextualType, node)) ?
60457                     getRegularTypeOfLiteralType(type) : type;
60458                 return result;
60459             }
60460             finally {
60461                 context.contextualType = saveContextualType;
60462                 context.inferenceContext = saveInferenceContext;
60463             }
60464         }
60465         function checkExpressionCached(node, checkMode) {
60466             var links = getNodeLinks(node);
60467             if (!links.resolvedType) {
60468                 if (checkMode && checkMode !== 0) {
60469                     return checkExpression(node, checkMode);
60470                 }
60471                 var saveFlowLoopStart = flowLoopStart;
60472                 var saveFlowTypeCache = flowTypeCache;
60473                 flowLoopStart = flowLoopCount;
60474                 flowTypeCache = undefined;
60475                 links.resolvedType = checkExpression(node, checkMode);
60476                 flowTypeCache = saveFlowTypeCache;
60477                 flowLoopStart = saveFlowLoopStart;
60478             }
60479             return links.resolvedType;
60480         }
60481         function isTypeAssertion(node) {
60482             node = ts.skipParentheses(node);
60483             return node.kind === 206 || node.kind === 224;
60484         }
60485         function checkDeclarationInitializer(declaration, contextualType) {
60486             var initializer = ts.getEffectiveInitializer(declaration);
60487             var type = getQuickTypeOfExpression(initializer) ||
60488                 (contextualType ? checkExpressionWithContextualType(initializer, contextualType, undefined, 0) : checkExpressionCached(initializer));
60489             return ts.isParameter(declaration) && declaration.name.kind === 197 &&
60490                 isTupleType(type) && !type.target.hasRestElement && getTypeReferenceArity(type) < declaration.name.elements.length ?
60491                 padTupleType(type, declaration.name) : type;
60492         }
60493         function padTupleType(type, pattern) {
60494             var patternElements = pattern.elements;
60495             var elementTypes = getTypeArguments(type).slice();
60496             var elementFlags = type.target.elementFlags.slice();
60497             for (var i = getTypeReferenceArity(type); i < patternElements.length; i++) {
60498                 var e = patternElements[i];
60499                 if (i < patternElements.length - 1 || !(e.kind === 198 && e.dotDotDotToken)) {
60500                     elementTypes.push(!ts.isOmittedExpression(e) && hasDefaultValue(e) ? getTypeFromBindingElement(e, false, false) : anyType);
60501                     elementFlags.push(2);
60502                     if (!ts.isOmittedExpression(e) && !hasDefaultValue(e)) {
60503                         reportImplicitAny(e, anyType);
60504                     }
60505                 }
60506             }
60507             return createTupleType(elementTypes, elementFlags, type.target.readonly);
60508         }
60509         function widenTypeInferredFromInitializer(declaration, type) {
60510             var widened = ts.getCombinedNodeFlags(declaration) & 2 || ts.isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type);
60511             if (ts.isInJSFile(declaration)) {
60512                 if (widened.flags & 98304) {
60513                     reportImplicitAny(declaration, anyType);
60514                     return anyType;
60515                 }
60516                 else if (isEmptyArrayLiteralType(widened)) {
60517                     reportImplicitAny(declaration, anyArrayType);
60518                     return anyArrayType;
60519                 }
60520             }
60521             return widened;
60522         }
60523         function isLiteralOfContextualType(candidateType, contextualType) {
60524             if (contextualType) {
60525                 if (contextualType.flags & 3145728) {
60526                     var types = contextualType.types;
60527                     return ts.some(types, function (t) { return isLiteralOfContextualType(candidateType, t); });
60528                 }
60529                 if (contextualType.flags & 58982400) {
60530                     var constraint = getBaseConstraintOfType(contextualType) || unknownType;
60531                     return maybeTypeOfKind(constraint, 4) && maybeTypeOfKind(candidateType, 128) ||
60532                         maybeTypeOfKind(constraint, 8) && maybeTypeOfKind(candidateType, 256) ||
60533                         maybeTypeOfKind(constraint, 64) && maybeTypeOfKind(candidateType, 2048) ||
60534                         maybeTypeOfKind(constraint, 4096) && maybeTypeOfKind(candidateType, 8192) ||
60535                         isLiteralOfContextualType(candidateType, constraint);
60536                 }
60537                 return !!(contextualType.flags & (128 | 4194304 | 134217728 | 268435456) && maybeTypeOfKind(candidateType, 128) ||
60538                     contextualType.flags & 256 && maybeTypeOfKind(candidateType, 256) ||
60539                     contextualType.flags & 2048 && maybeTypeOfKind(candidateType, 2048) ||
60540                     contextualType.flags & 512 && maybeTypeOfKind(candidateType, 512) ||
60541                     contextualType.flags & 8192 && maybeTypeOfKind(candidateType, 8192));
60542             }
60543             return false;
60544         }
60545         function isConstContext(node) {
60546             var parent = node.parent;
60547             return ts.isAssertionExpression(parent) && ts.isConstTypeReference(parent.type) ||
60548                 (ts.isParenthesizedExpression(parent) || ts.isArrayLiteralExpression(parent) || ts.isSpreadElement(parent)) && isConstContext(parent) ||
60549                 (ts.isPropertyAssignment(parent) || ts.isShorthandPropertyAssignment(parent) || ts.isTemplateSpan(parent)) && isConstContext(parent.parent);
60550         }
60551         function checkExpressionForMutableLocation(node, checkMode, contextualType, forceTuple) {
60552             var type = checkExpression(node, checkMode, forceTuple);
60553             return isConstContext(node) ? getRegularTypeOfLiteralType(type) :
60554                 isTypeAssertion(node) ? type :
60555                     getWidenedLiteralLikeTypeForContextualType(type, instantiateContextualType(arguments.length === 2 ? getContextualType(node) : contextualType, node));
60556         }
60557         function checkPropertyAssignment(node, checkMode) {
60558             if (node.name.kind === 158) {
60559                 checkComputedPropertyName(node.name);
60560             }
60561             return checkExpressionForMutableLocation(node.initializer, checkMode);
60562         }
60563         function checkObjectLiteralMethod(node, checkMode) {
60564             checkGrammarMethod(node);
60565             if (node.name.kind === 158) {
60566                 checkComputedPropertyName(node.name);
60567             }
60568             var uninstantiatedType = checkFunctionExpressionOrObjectLiteralMethod(node, checkMode);
60569             return instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode);
60570         }
60571         function instantiateTypeWithSingleGenericCallSignature(node, type, checkMode) {
60572             if (checkMode && checkMode & (2 | 8)) {
60573                 var callSignature = getSingleSignature(type, 0, true);
60574                 var constructSignature = getSingleSignature(type, 1, true);
60575                 var signature = callSignature || constructSignature;
60576                 if (signature && signature.typeParameters) {
60577                     var contextualType = getApparentTypeOfContextualType(node, 2);
60578                     if (contextualType) {
60579                         var contextualSignature = getSingleSignature(getNonNullableType(contextualType), callSignature ? 0 : 1, false);
60580                         if (contextualSignature && !contextualSignature.typeParameters) {
60581                             if (checkMode & 8) {
60582                                 skippedGenericFunction(node, checkMode);
60583                                 return anyFunctionType;
60584                             }
60585                             var context = getInferenceContext(node);
60586                             var returnType = context.signature && getReturnTypeOfSignature(context.signature);
60587                             var returnSignature = returnType && getSingleCallOrConstructSignature(returnType);
60588                             if (returnSignature && !returnSignature.typeParameters && !ts.every(context.inferences, hasInferenceCandidates)) {
60589                                 var uniqueTypeParameters = getUniqueTypeParameters(context, signature.typeParameters);
60590                                 var instantiatedSignature = getSignatureInstantiationWithoutFillingInTypeArguments(signature, uniqueTypeParameters);
60591                                 var inferences_3 = ts.map(context.inferences, function (info) { return createInferenceInfo(info.typeParameter); });
60592                                 applyToParameterTypes(instantiatedSignature, contextualSignature, function (source, target) {
60593                                     inferTypes(inferences_3, source, target, 0, true);
60594                                 });
60595                                 if (ts.some(inferences_3, hasInferenceCandidates)) {
60596                                     applyToReturnTypes(instantiatedSignature, contextualSignature, function (source, target) {
60597                                         inferTypes(inferences_3, source, target);
60598                                     });
60599                                     if (!hasOverlappingInferences(context.inferences, inferences_3)) {
60600                                         mergeInferences(context.inferences, inferences_3);
60601                                         context.inferredTypeParameters = ts.concatenate(context.inferredTypeParameters, uniqueTypeParameters);
60602                                         return getOrCreateTypeFromSignature(instantiatedSignature);
60603                                     }
60604                                 }
60605                             }
60606                             return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, context));
60607                         }
60608                     }
60609                 }
60610             }
60611             return type;
60612         }
60613         function skippedGenericFunction(node, checkMode) {
60614             if (checkMode & 2) {
60615                 var context = getInferenceContext(node);
60616                 context.flags |= 4;
60617             }
60618         }
60619         function hasInferenceCandidates(info) {
60620             return !!(info.candidates || info.contraCandidates);
60621         }
60622         function hasOverlappingInferences(a, b) {
60623             for (var i = 0; i < a.length; i++) {
60624                 if (hasInferenceCandidates(a[i]) && hasInferenceCandidates(b[i])) {
60625                     return true;
60626                 }
60627             }
60628             return false;
60629         }
60630         function mergeInferences(target, source) {
60631             for (var i = 0; i < target.length; i++) {
60632                 if (!hasInferenceCandidates(target[i]) && hasInferenceCandidates(source[i])) {
60633                     target[i] = source[i];
60634                 }
60635             }
60636         }
60637         function getUniqueTypeParameters(context, typeParameters) {
60638             var result = [];
60639             var oldTypeParameters;
60640             var newTypeParameters;
60641             for (var _i = 0, typeParameters_2 = typeParameters; _i < typeParameters_2.length; _i++) {
60642                 var tp = typeParameters_2[_i];
60643                 var name = tp.symbol.escapedName;
60644                 if (hasTypeParameterByName(context.inferredTypeParameters, name) || hasTypeParameterByName(result, name)) {
60645                     var newName = getUniqueTypeParameterName(ts.concatenate(context.inferredTypeParameters, result), name);
60646                     var symbol = createSymbol(262144, newName);
60647                     var newTypeParameter = createTypeParameter(symbol);
60648                     newTypeParameter.target = tp;
60649                     oldTypeParameters = ts.append(oldTypeParameters, tp);
60650                     newTypeParameters = ts.append(newTypeParameters, newTypeParameter);
60651                     result.push(newTypeParameter);
60652                 }
60653                 else {
60654                     result.push(tp);
60655                 }
60656             }
60657             if (newTypeParameters) {
60658                 var mapper = createTypeMapper(oldTypeParameters, newTypeParameters);
60659                 for (var _a = 0, newTypeParameters_1 = newTypeParameters; _a < newTypeParameters_1.length; _a++) {
60660                     var tp = newTypeParameters_1[_a];
60661                     tp.mapper = mapper;
60662                 }
60663             }
60664             return result;
60665         }
60666         function hasTypeParameterByName(typeParameters, name) {
60667             return ts.some(typeParameters, function (tp) { return tp.symbol.escapedName === name; });
60668         }
60669         function getUniqueTypeParameterName(typeParameters, baseName) {
60670             var len = baseName.length;
60671             while (len > 1 && baseName.charCodeAt(len - 1) >= 48 && baseName.charCodeAt(len - 1) <= 57)
60672                 len--;
60673             var s = baseName.slice(0, len);
60674             for (var index = 1; true; index++) {
60675                 var augmentedName = (s + index);
60676                 if (!hasTypeParameterByName(typeParameters, augmentedName)) {
60677                     return augmentedName;
60678                 }
60679             }
60680         }
60681         function getReturnTypeOfSingleNonGenericCallSignature(funcType) {
60682             var signature = getSingleCallSignature(funcType);
60683             if (signature && !signature.typeParameters) {
60684                 return getReturnTypeOfSignature(signature);
60685             }
60686         }
60687         function getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) {
60688             var funcType = checkExpression(expr.expression);
60689             var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
60690             var returnType = getReturnTypeOfSingleNonGenericCallSignature(funcType);
60691             return returnType && propagateOptionalTypeMarker(returnType, expr, nonOptionalType !== funcType);
60692         }
60693         function getTypeOfExpression(node) {
60694             var quickType = getQuickTypeOfExpression(node);
60695             if (quickType) {
60696                 return quickType;
60697             }
60698             if (node.flags & 67108864 && flowTypeCache) {
60699                 var cachedType = flowTypeCache[getNodeId(node)];
60700                 if (cachedType) {
60701                     return cachedType;
60702                 }
60703             }
60704             var startInvocationCount = flowInvocationCount;
60705             var type = checkExpression(node);
60706             if (flowInvocationCount !== startInvocationCount) {
60707                 var cache = flowTypeCache || (flowTypeCache = []);
60708                 cache[getNodeId(node)] = type;
60709                 ts.setNodeFlags(node, node.flags | 67108864);
60710             }
60711             return type;
60712         }
60713         function getQuickTypeOfExpression(node) {
60714             var expr = ts.skipParentheses(node);
60715             if (ts.isCallExpression(expr) && expr.expression.kind !== 105 && !ts.isRequireCall(expr, true) && !isSymbolOrSymbolForCall(expr)) {
60716                 var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
60717                     getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
60718                 if (type) {
60719                     return type;
60720                 }
60721             }
60722             else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) {
60723                 return getTypeFromTypeNode(expr.type);
60724             }
60725             else if (node.kind === 8 || node.kind === 10 ||
60726                 node.kind === 109 || node.kind === 94) {
60727                 return checkExpression(node);
60728             }
60729             return undefined;
60730         }
60731         function getContextFreeTypeOfExpression(node) {
60732             var links = getNodeLinks(node);
60733             if (links.contextFreeType) {
60734                 return links.contextFreeType;
60735             }
60736             var saveContextualType = node.contextualType;
60737             node.contextualType = anyType;
60738             try {
60739                 var type = links.contextFreeType = checkExpression(node, 4);
60740                 return type;
60741             }
60742             finally {
60743                 node.contextualType = saveContextualType;
60744             }
60745         }
60746         function checkExpression(node, checkMode, forceTuple) {
60747             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check", "checkExpression", { kind: node.kind, pos: node.pos, end: node.end });
60748             var saveCurrentNode = currentNode;
60749             currentNode = node;
60750             instantiationCount = 0;
60751             var uninstantiatedType = checkExpressionWorker(node, checkMode, forceTuple);
60752             var type = instantiateTypeWithSingleGenericCallSignature(node, uninstantiatedType, checkMode);
60753             if (isConstEnumObjectType(type)) {
60754                 checkConstEnumAccess(node, type);
60755             }
60756             currentNode = saveCurrentNode;
60757             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
60758             return type;
60759         }
60760         function checkConstEnumAccess(node, type) {
60761             var ok = (node.parent.kind === 201 && node.parent.expression === node) ||
60762                 (node.parent.kind === 202 && node.parent.expression === node) ||
60763                 ((node.kind === 78 || node.kind === 157) && isInRightSideOfImportOrExportAssignment(node) ||
60764                     (node.parent.kind === 176 && node.parent.exprName === node)) ||
60765                 (node.parent.kind === 270);
60766             if (!ok) {
60767                 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);
60768             }
60769             if (compilerOptions.isolatedModules) {
60770                 ts.Debug.assert(!!(type.symbol.flags & 128));
60771                 var constEnumDeclaration = type.symbol.valueDeclaration;
60772                 if (constEnumDeclaration.flags & 8388608) {
60773                     error(node, ts.Diagnostics.Cannot_access_ambient_const_enums_when_the_isolatedModules_flag_is_provided);
60774                 }
60775             }
60776         }
60777         function checkParenthesizedExpression(node, checkMode) {
60778             var tag = ts.isInJSFile(node) ? ts.getJSDocTypeTag(node) : undefined;
60779             if (tag) {
60780                 return checkAssertionWorker(tag, tag.typeExpression.type, node.expression, checkMode);
60781             }
60782             return checkExpression(node.expression, checkMode);
60783         }
60784         function checkExpressionWorker(node, checkMode, forceTuple) {
60785             var kind = node.kind;
60786             if (cancellationToken) {
60787                 switch (kind) {
60788                     case 221:
60789                     case 208:
60790                     case 209:
60791                         cancellationToken.throwIfCancellationRequested();
60792                 }
60793             }
60794             switch (kind) {
60795                 case 78:
60796                     return checkIdentifier(node);
60797                 case 107:
60798                     return checkThisExpression(node);
60799                 case 105:
60800                     return checkSuperExpression(node);
60801                 case 103:
60802                     return nullWideningType;
60803                 case 14:
60804                 case 10:
60805                     return getFreshTypeOfLiteralType(getLiteralType(node.text));
60806                 case 8:
60807                     checkGrammarNumericLiteral(node);
60808                     return getFreshTypeOfLiteralType(getLiteralType(+node.text));
60809                 case 9:
60810                     checkGrammarBigIntLiteral(node);
60811                     return getFreshTypeOfLiteralType(getBigIntLiteralType(node));
60812                 case 109:
60813                     return trueType;
60814                 case 94:
60815                     return falseType;
60816                 case 218:
60817                     return checkTemplateExpression(node);
60818                 case 13:
60819                     return globalRegExpType;
60820                 case 199:
60821                     return checkArrayLiteral(node, checkMode, forceTuple);
60822                 case 200:
60823                     return checkObjectLiteral(node, checkMode);
60824                 case 201:
60825                     return checkPropertyAccessExpression(node);
60826                 case 157:
60827                     return checkQualifiedName(node);
60828                 case 202:
60829                     return checkIndexedAccess(node);
60830                 case 203:
60831                     if (node.expression.kind === 99) {
60832                         return checkImportCallExpression(node);
60833                     }
60834                 case 204:
60835                     return checkCallExpression(node, checkMode);
60836                 case 205:
60837                     return checkTaggedTemplateExpression(node);
60838                 case 207:
60839                     return checkParenthesizedExpression(node, checkMode);
60840                 case 221:
60841                     return checkClassExpression(node);
60842                 case 208:
60843                 case 209:
60844                     return checkFunctionExpressionOrObjectLiteralMethod(node, checkMode);
60845                 case 211:
60846                     return checkTypeOfExpression(node);
60847                 case 206:
60848                 case 224:
60849                     return checkAssertion(node);
60850                 case 225:
60851                     return checkNonNullAssertion(node);
60852                 case 226:
60853                     return checkMetaProperty(node);
60854                 case 210:
60855                     return checkDeleteExpression(node);
60856                 case 212:
60857                     return checkVoidExpression(node);
60858                 case 213:
60859                     return checkAwaitExpression(node);
60860                 case 214:
60861                     return checkPrefixUnaryExpression(node);
60862                 case 215:
60863                     return checkPostfixUnaryExpression(node);
60864                 case 216:
60865                     return checkBinaryExpression(node, checkMode);
60866                 case 217:
60867                     return checkConditionalExpression(node, checkMode);
60868                 case 220:
60869                     return checkSpreadExpression(node, checkMode);
60870                 case 222:
60871                     return undefinedWideningType;
60872                 case 219:
60873                     return checkYieldExpression(node);
60874                 case 227:
60875                     return checkSyntheticExpression(node);
60876                 case 283:
60877                     return checkJsxExpression(node, checkMode);
60878                 case 273:
60879                     return checkJsxElement(node, checkMode);
60880                 case 274:
60881                     return checkJsxSelfClosingElement(node, checkMode);
60882                 case 277:
60883                     return checkJsxFragment(node);
60884                 case 281:
60885                     return checkJsxAttributes(node, checkMode);
60886                 case 275:
60887                     ts.Debug.fail("Shouldn't ever directly check a JsxOpeningElement");
60888             }
60889             return errorType;
60890         }
60891         function checkTypeParameter(node) {
60892             if (node.expression) {
60893                 grammarErrorOnFirstToken(node.expression, ts.Diagnostics.Type_expected);
60894             }
60895             checkSourceElement(node.constraint);
60896             checkSourceElement(node.default);
60897             var typeParameter = getDeclaredTypeOfTypeParameter(getSymbolOfNode(node));
60898             getBaseConstraintOfType(typeParameter);
60899             if (!hasNonCircularTypeParameterDefault(typeParameter)) {
60900                 error(node.default, ts.Diagnostics.Type_parameter_0_has_a_circular_default, typeToString(typeParameter));
60901             }
60902             var constraintType = getConstraintOfTypeParameter(typeParameter);
60903             var defaultType = getDefaultFromTypeParameter(typeParameter);
60904             if (constraintType && defaultType) {
60905                 checkTypeAssignableTo(defaultType, getTypeWithThisArgument(instantiateType(constraintType, makeUnaryTypeMapper(typeParameter, defaultType)), defaultType), node.default, ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
60906             }
60907             if (produceDiagnostics) {
60908                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_parameter_name_cannot_be_0);
60909             }
60910         }
60911         function checkParameter(node) {
60912             checkGrammarDecoratorsAndModifiers(node);
60913             checkVariableLikeDeclaration(node);
60914             var func = ts.getContainingFunction(node);
60915             if (ts.hasSyntacticModifier(node, 92)) {
60916                 if (!(func.kind === 166 && ts.nodeIsPresent(func.body))) {
60917                     error(node, ts.Diagnostics.A_parameter_property_is_only_allowed_in_a_constructor_implementation);
60918                 }
60919                 if (func.kind === 166 && ts.isIdentifier(node.name) && node.name.escapedText === "constructor") {
60920                     error(node.name, ts.Diagnostics.constructor_cannot_be_used_as_a_parameter_property_name);
60921                 }
60922             }
60923             if (node.questionToken && ts.isBindingPattern(node.name) && func.body) {
60924                 error(node, ts.Diagnostics.A_binding_pattern_parameter_cannot_be_optional_in_an_implementation_signature);
60925             }
60926             if (node.name && ts.isIdentifier(node.name) && (node.name.escapedText === "this" || node.name.escapedText === "new")) {
60927                 if (func.parameters.indexOf(node) !== 0) {
60928                     error(node, ts.Diagnostics.A_0_parameter_must_be_the_first_parameter, node.name.escapedText);
60929                 }
60930                 if (func.kind === 166 || func.kind === 170 || func.kind === 175) {
60931                     error(node, ts.Diagnostics.A_constructor_cannot_have_a_this_parameter);
60932                 }
60933                 if (func.kind === 209) {
60934                     error(node, ts.Diagnostics.An_arrow_function_cannot_have_a_this_parameter);
60935                 }
60936                 if (func.kind === 167 || func.kind === 168) {
60937                     error(node, ts.Diagnostics.get_and_set_accessors_cannot_declare_this_parameters);
60938                 }
60939             }
60940             if (node.dotDotDotToken && !ts.isBindingPattern(node.name) && !isTypeAssignableTo(getReducedType(getTypeOfSymbol(node.symbol)), anyReadonlyArrayType)) {
60941                 error(node, ts.Diagnostics.A_rest_parameter_must_be_of_an_array_type);
60942             }
60943         }
60944         function checkTypePredicate(node) {
60945             var parent = getTypePredicateParent(node);
60946             if (!parent) {
60947                 error(node, ts.Diagnostics.A_type_predicate_is_only_allowed_in_return_type_position_for_functions_and_methods);
60948                 return;
60949             }
60950             var signature = getSignatureFromDeclaration(parent);
60951             var typePredicate = getTypePredicateOfSignature(signature);
60952             if (!typePredicate) {
60953                 return;
60954             }
60955             checkSourceElement(node.type);
60956             var parameterName = node.parameterName;
60957             if (typePredicate.kind === 0 || typePredicate.kind === 2) {
60958                 getTypeFromThisTypeNode(parameterName);
60959             }
60960             else {
60961                 if (typePredicate.parameterIndex >= 0) {
60962                     if (signatureHasRestParameter(signature) && typePredicate.parameterIndex === signature.parameters.length - 1) {
60963                         error(parameterName, ts.Diagnostics.A_type_predicate_cannot_reference_a_rest_parameter);
60964                     }
60965                     else {
60966                         if (typePredicate.type) {
60967                             var leadingError = function () { return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.A_type_predicate_s_type_must_be_assignable_to_its_parameter_s_type); };
60968                             checkTypeAssignableTo(typePredicate.type, getTypeOfSymbol(signature.parameters[typePredicate.parameterIndex]), node.type, undefined, leadingError);
60969                         }
60970                     }
60971                 }
60972                 else if (parameterName) {
60973                     var hasReportedError = false;
60974                     for (var _i = 0, _a = parent.parameters; _i < _a.length; _i++) {
60975                         var name = _a[_i].name;
60976                         if (ts.isBindingPattern(name) &&
60977                             checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, parameterName, typePredicate.parameterName)) {
60978                             hasReportedError = true;
60979                             break;
60980                         }
60981                     }
60982                     if (!hasReportedError) {
60983                         error(node.parameterName, ts.Diagnostics.Cannot_find_parameter_0, typePredicate.parameterName);
60984                     }
60985                 }
60986             }
60987         }
60988         function getTypePredicateParent(node) {
60989             switch (node.parent.kind) {
60990                 case 209:
60991                 case 169:
60992                 case 251:
60993                 case 208:
60994                 case 174:
60995                 case 165:
60996                 case 164:
60997                     var parent = node.parent;
60998                     if (node === parent.type) {
60999                         return parent;
61000                     }
61001             }
61002         }
61003         function checkIfTypePredicateVariableIsDeclaredInBindingPattern(pattern, predicateVariableNode, predicateVariableName) {
61004             for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
61005                 var element = _a[_i];
61006                 if (ts.isOmittedExpression(element)) {
61007                     continue;
61008                 }
61009                 var name = element.name;
61010                 if (name.kind === 78 && name.escapedText === predicateVariableName) {
61011                     error(predicateVariableNode, ts.Diagnostics.A_type_predicate_cannot_reference_element_0_in_a_binding_pattern, predicateVariableName);
61012                     return true;
61013                 }
61014                 else if (name.kind === 197 || name.kind === 196) {
61015                     if (checkIfTypePredicateVariableIsDeclaredInBindingPattern(name, predicateVariableNode, predicateVariableName)) {
61016                         return true;
61017                     }
61018                 }
61019             }
61020         }
61021         function checkSignatureDeclaration(node) {
61022             if (node.kind === 171) {
61023                 checkGrammarIndexSignature(node);
61024             }
61025             else if (node.kind === 174 || node.kind === 251 || node.kind === 175 ||
61026                 node.kind === 169 || node.kind === 166 ||
61027                 node.kind === 170) {
61028                 checkGrammarFunctionLikeDeclaration(node);
61029             }
61030             var functionFlags = ts.getFunctionFlags(node);
61031             if (!(functionFlags & 4)) {
61032                 if ((functionFlags & 3) === 3 && languageVersion < 99) {
61033                     checkExternalEmitHelpers(node, 6144);
61034                 }
61035                 if ((functionFlags & 3) === 2 && languageVersion < 4) {
61036                     checkExternalEmitHelpers(node, 64);
61037                 }
61038                 if ((functionFlags & 3) !== 0 && languageVersion < 2) {
61039                     checkExternalEmitHelpers(node, 128);
61040                 }
61041             }
61042             checkTypeParameters(node.typeParameters);
61043             ts.forEach(node.parameters, checkParameter);
61044             if (node.type) {
61045                 checkSourceElement(node.type);
61046             }
61047             if (produceDiagnostics) {
61048                 checkCollisionWithArgumentsInGeneratedCode(node);
61049                 var returnTypeNode = ts.getEffectiveReturnTypeNode(node);
61050                 if (noImplicitAny && !returnTypeNode) {
61051                     switch (node.kind) {
61052                         case 170:
61053                             error(node, ts.Diagnostics.Construct_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
61054                             break;
61055                         case 169:
61056                             error(node, ts.Diagnostics.Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type);
61057                             break;
61058                     }
61059                 }
61060                 if (returnTypeNode) {
61061                     var functionFlags_1 = ts.getFunctionFlags(node);
61062                     if ((functionFlags_1 & (4 | 1)) === 1) {
61063                         var returnType = getTypeFromTypeNode(returnTypeNode);
61064                         if (returnType === voidType) {
61065                             error(returnTypeNode, ts.Diagnostics.A_generator_cannot_have_a_void_type_annotation);
61066                         }
61067                         else {
61068                             var generatorYieldType = getIterationTypeOfGeneratorFunctionReturnType(0, returnType, (functionFlags_1 & 2) !== 0) || anyType;
61069                             var generatorReturnType = getIterationTypeOfGeneratorFunctionReturnType(1, returnType, (functionFlags_1 & 2) !== 0) || generatorYieldType;
61070                             var generatorNextType = getIterationTypeOfGeneratorFunctionReturnType(2, returnType, (functionFlags_1 & 2) !== 0) || unknownType;
61071                             var generatorInstantiation = createGeneratorReturnType(generatorYieldType, generatorReturnType, generatorNextType, !!(functionFlags_1 & 2));
61072                             checkTypeAssignableTo(generatorInstantiation, returnType, returnTypeNode);
61073                         }
61074                     }
61075                     else if ((functionFlags_1 & 3) === 2) {
61076                         checkAsyncFunctionReturnType(node, returnTypeNode);
61077                     }
61078                 }
61079                 if (node.kind !== 171 && node.kind !== 308) {
61080                     registerForUnusedIdentifiersCheck(node);
61081                 }
61082             }
61083         }
61084         function checkClassForDuplicateDeclarations(node) {
61085             var instanceNames = new ts.Map();
61086             var staticNames = new ts.Map();
61087             var privateIdentifiers = new ts.Map();
61088             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
61089                 var member = _a[_i];
61090                 if (member.kind === 166) {
61091                     for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) {
61092                         var param = _c[_b];
61093                         if (ts.isParameterPropertyDeclaration(param, member) && !ts.isBindingPattern(param.name)) {
61094                             addName(instanceNames, param.name, param.name.escapedText, 3);
61095                         }
61096                     }
61097                 }
61098                 else {
61099                     var isStatic = ts.hasSyntacticModifier(member, 32);
61100                     var name = member.name;
61101                     if (!name) {
61102                         return;
61103                     }
61104                     var names = ts.isPrivateIdentifier(name) ? privateIdentifiers :
61105                         isStatic ? staticNames :
61106                             instanceNames;
61107                     var memberName = name && ts.getPropertyNameForPropertyNameNode(name);
61108                     if (memberName) {
61109                         switch (member.kind) {
61110                             case 167:
61111                                 addName(names, name, memberName, 1);
61112                                 break;
61113                             case 168:
61114                                 addName(names, name, memberName, 2);
61115                                 break;
61116                             case 163:
61117                                 addName(names, name, memberName, 3);
61118                                 break;
61119                             case 165:
61120                                 addName(names, name, memberName, 8);
61121                                 break;
61122                         }
61123                     }
61124                 }
61125             }
61126             function addName(names, location, name, meaning) {
61127                 var prev = names.get(name);
61128                 if (prev) {
61129                     if (prev & 8) {
61130                         if (meaning !== 8) {
61131                             error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location));
61132                         }
61133                     }
61134                     else if (prev & meaning) {
61135                         error(location, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(location));
61136                     }
61137                     else {
61138                         names.set(name, prev | meaning);
61139                     }
61140                 }
61141                 else {
61142                     names.set(name, meaning);
61143                 }
61144             }
61145         }
61146         function checkClassForStaticPropertyNameConflicts(node) {
61147             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
61148                 var member = _a[_i];
61149                 var memberNameNode = member.name;
61150                 var isStatic = ts.hasSyntacticModifier(member, 32);
61151                 if (isStatic && memberNameNode) {
61152                     var memberName = ts.getPropertyNameForPropertyNameNode(memberNameNode);
61153                     switch (memberName) {
61154                         case "name":
61155                         case "length":
61156                         case "caller":
61157                         case "arguments":
61158                         case "prototype":
61159                             var message = ts.Diagnostics.Static_property_0_conflicts_with_built_in_property_Function_0_of_constructor_function_1;
61160                             var className = getNameOfSymbolAsWritten(getSymbolOfNode(node));
61161                             error(memberNameNode, message, memberName, className);
61162                             break;
61163                     }
61164                 }
61165             }
61166         }
61167         function checkObjectTypeForDuplicateDeclarations(node) {
61168             var names = new ts.Map();
61169             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
61170                 var member = _a[_i];
61171                 if (member.kind === 162) {
61172                     var memberName = void 0;
61173                     var name = member.name;
61174                     switch (name.kind) {
61175                         case 10:
61176                         case 8:
61177                             memberName = name.text;
61178                             break;
61179                         case 78:
61180                             memberName = ts.idText(name);
61181                             break;
61182                         default:
61183                             continue;
61184                     }
61185                     if (names.get(memberName)) {
61186                         error(ts.getNameOfDeclaration(member.symbol.valueDeclaration), ts.Diagnostics.Duplicate_identifier_0, memberName);
61187                         error(member.name, ts.Diagnostics.Duplicate_identifier_0, memberName);
61188                     }
61189                     else {
61190                         names.set(memberName, true);
61191                     }
61192                 }
61193             }
61194         }
61195         function checkTypeForDuplicateIndexSignatures(node) {
61196             if (node.kind === 253) {
61197                 var nodeSymbol = getSymbolOfNode(node);
61198                 if (nodeSymbol.declarations.length > 0 && nodeSymbol.declarations[0] !== node) {
61199                     return;
61200                 }
61201             }
61202             var indexSymbol = getIndexSymbol(getSymbolOfNode(node));
61203             if (indexSymbol) {
61204                 var seenNumericIndexer = false;
61205                 var seenStringIndexer = false;
61206                 for (var _i = 0, _a = indexSymbol.declarations; _i < _a.length; _i++) {
61207                     var decl = _a[_i];
61208                     var declaration = decl;
61209                     if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
61210                         switch (declaration.parameters[0].type.kind) {
61211                             case 147:
61212                                 if (!seenStringIndexer) {
61213                                     seenStringIndexer = true;
61214                                 }
61215                                 else {
61216                                     error(declaration, ts.Diagnostics.Duplicate_string_index_signature);
61217                                 }
61218                                 break;
61219                             case 144:
61220                                 if (!seenNumericIndexer) {
61221                                     seenNumericIndexer = true;
61222                                 }
61223                                 else {
61224                                     error(declaration, ts.Diagnostics.Duplicate_number_index_signature);
61225                                 }
61226                                 break;
61227                         }
61228                     }
61229                 }
61230             }
61231         }
61232         function checkPropertyDeclaration(node) {
61233             if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarProperty(node))
61234                 checkGrammarComputedPropertyName(node.name);
61235             checkVariableLikeDeclaration(node);
61236             if (ts.isPrivateIdentifier(node.name) && languageVersion < 99) {
61237                 for (var lexicalScope = ts.getEnclosingBlockScopeContainer(node); !!lexicalScope; lexicalScope = ts.getEnclosingBlockScopeContainer(lexicalScope)) {
61238                     getNodeLinks(lexicalScope).flags |= 67108864;
61239                 }
61240             }
61241         }
61242         function checkPropertySignature(node) {
61243             if (ts.isPrivateIdentifier(node.name)) {
61244                 error(node, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
61245             }
61246             return checkPropertyDeclaration(node);
61247         }
61248         function checkMethodDeclaration(node) {
61249             if (!checkGrammarMethod(node))
61250                 checkGrammarComputedPropertyName(node.name);
61251             if (ts.isPrivateIdentifier(node.name)) {
61252                 error(node, ts.Diagnostics.A_method_cannot_be_named_with_a_private_identifier);
61253             }
61254             checkFunctionOrMethodDeclaration(node);
61255             if (ts.hasSyntacticModifier(node, 128) && node.kind === 165 && node.body) {
61256                 error(node, ts.Diagnostics.Method_0_cannot_have_an_implementation_because_it_is_marked_abstract, ts.declarationNameToString(node.name));
61257             }
61258         }
61259         function checkConstructorDeclaration(node) {
61260             checkSignatureDeclaration(node);
61261             if (!checkGrammarConstructorTypeParameters(node))
61262                 checkGrammarConstructorTypeAnnotation(node);
61263             checkSourceElement(node.body);
61264             var symbol = getSymbolOfNode(node);
61265             var firstDeclaration = ts.getDeclarationOfKind(symbol, node.kind);
61266             if (node === firstDeclaration) {
61267                 checkFunctionOrConstructorSymbol(symbol);
61268             }
61269             if (ts.nodeIsMissing(node.body)) {
61270                 return;
61271             }
61272             if (!produceDiagnostics) {
61273                 return;
61274             }
61275             function isInstancePropertyWithInitializerOrPrivateIdentifierProperty(n) {
61276                 if (ts.isPrivateIdentifierPropertyDeclaration(n)) {
61277                     return true;
61278                 }
61279                 return n.kind === 163 &&
61280                     !ts.hasSyntacticModifier(n, 32) &&
61281                     !!n.initializer;
61282             }
61283             var containingClassDecl = node.parent;
61284             if (ts.getClassExtendsHeritageElement(containingClassDecl)) {
61285                 captureLexicalThis(node.parent, containingClassDecl);
61286                 var classExtendsNull = classDeclarationExtendsNull(containingClassDecl);
61287                 var superCall = findFirstSuperCall(node.body);
61288                 if (superCall) {
61289                     if (classExtendsNull) {
61290                         error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
61291                     }
61292                     var superCallShouldBeFirst = (compilerOptions.target !== 99 || !compilerOptions.useDefineForClassFields) &&
61293                         (ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
61294                             ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 92); }));
61295                     if (superCallShouldBeFirst) {
61296                         var statements = node.body.statements;
61297                         var superCallStatement = void 0;
61298                         for (var _i = 0, statements_4 = statements; _i < statements_4.length; _i++) {
61299                             var statement = statements_4[_i];
61300                             if (statement.kind === 233 && ts.isSuperCall(statement.expression)) {
61301                                 superCallStatement = statement;
61302                                 break;
61303                             }
61304                             if (!ts.isPrologueDirective(statement)) {
61305                                 break;
61306                             }
61307                         }
61308                         if (!superCallStatement) {
61309                             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);
61310                         }
61311                     }
61312                 }
61313                 else if (!classExtendsNull) {
61314                     error(node, ts.Diagnostics.Constructors_for_derived_classes_must_contain_a_super_call);
61315                 }
61316             }
61317         }
61318         function checkAccessorDeclaration(node) {
61319             if (produceDiagnostics) {
61320                 if (!checkGrammarFunctionLikeDeclaration(node) && !checkGrammarAccessor(node))
61321                     checkGrammarComputedPropertyName(node.name);
61322                 checkDecorators(node);
61323                 checkSignatureDeclaration(node);
61324                 if (node.kind === 167) {
61325                     if (!(node.flags & 8388608) && ts.nodeIsPresent(node.body) && (node.flags & 256)) {
61326                         if (!(node.flags & 512)) {
61327                             error(node.name, ts.Diagnostics.A_get_accessor_must_return_a_value);
61328                         }
61329                     }
61330                 }
61331                 if (node.name.kind === 158) {
61332                     checkComputedPropertyName(node.name);
61333                 }
61334                 if (ts.isPrivateIdentifier(node.name)) {
61335                     error(node.name, ts.Diagnostics.An_accessor_cannot_be_named_with_a_private_identifier);
61336                 }
61337                 if (hasBindableName(node)) {
61338                     var otherKind = node.kind === 167 ? 168 : 167;
61339                     var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind);
61340                     if (otherAccessor) {
61341                         var nodeFlags = ts.getEffectiveModifierFlags(node);
61342                         var otherFlags = ts.getEffectiveModifierFlags(otherAccessor);
61343                         if ((nodeFlags & 28) !== (otherFlags & 28)) {
61344                             error(node.name, ts.Diagnostics.Getter_and_setter_accessors_do_not_agree_in_visibility);
61345                         }
61346                         if ((nodeFlags & 128) !== (otherFlags & 128)) {
61347                             error(node.name, ts.Diagnostics.Accessors_must_both_be_abstract_or_non_abstract);
61348                         }
61349                         checkAccessorDeclarationTypesIdentical(node, otherAccessor, getAnnotatedAccessorType, ts.Diagnostics.get_and_set_accessor_must_have_the_same_type);
61350                         checkAccessorDeclarationTypesIdentical(node, otherAccessor, getThisTypeOfDeclaration, ts.Diagnostics.get_and_set_accessor_must_have_the_same_this_type);
61351                     }
61352                 }
61353                 var returnType = getTypeOfAccessors(getSymbolOfNode(node));
61354                 if (node.kind === 167) {
61355                     checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, returnType);
61356                 }
61357             }
61358             checkSourceElement(node.body);
61359         }
61360         function checkAccessorDeclarationTypesIdentical(first, second, getAnnotatedType, message) {
61361             var firstType = getAnnotatedType(first);
61362             var secondType = getAnnotatedType(second);
61363             if (firstType && secondType && !isTypeIdenticalTo(firstType, secondType)) {
61364                 error(first, message);
61365             }
61366         }
61367         function checkMissingDeclaration(node) {
61368             checkDecorators(node);
61369         }
61370         function getEffectiveTypeArguments(node, typeParameters) {
61371             return fillMissingTypeArguments(ts.map(node.typeArguments, getTypeFromTypeNode), typeParameters, getMinTypeArgumentCount(typeParameters), ts.isInJSFile(node));
61372         }
61373         function checkTypeArgumentConstraints(node, typeParameters) {
61374             var typeArguments;
61375             var mapper;
61376             var result = true;
61377             for (var i = 0; i < typeParameters.length; i++) {
61378                 var constraint = getConstraintOfTypeParameter(typeParameters[i]);
61379                 if (constraint) {
61380                     if (!typeArguments) {
61381                         typeArguments = getEffectiveTypeArguments(node, typeParameters);
61382                         mapper = createTypeMapper(typeParameters, typeArguments);
61383                     }
61384                     result = result && checkTypeAssignableTo(typeArguments[i], instantiateType(constraint, mapper), node.typeArguments[i], ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1);
61385                 }
61386             }
61387             return result;
61388         }
61389         function getTypeParametersForTypeReference(node) {
61390             var type = getTypeFromTypeReference(node);
61391             if (type !== errorType) {
61392                 var symbol = getNodeLinks(node).resolvedSymbol;
61393                 if (symbol) {
61394                     return symbol.flags & 524288 && getSymbolLinks(symbol).typeParameters ||
61395                         (ts.getObjectFlags(type) & 4 ? type.target.localTypeParameters : undefined);
61396                 }
61397             }
61398             return undefined;
61399         }
61400         function checkTypeReferenceNode(node) {
61401             checkGrammarTypeArguments(node, node.typeArguments);
61402             if (node.kind === 173 && node.typeName.jsdocDotPos !== undefined && !ts.isInJSFile(node) && !ts.isInJSDoc(node)) {
61403                 grammarErrorAtPos(node, node.typeName.jsdocDotPos, 1, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments);
61404             }
61405             ts.forEach(node.typeArguments, checkSourceElement);
61406             var type = getTypeFromTypeReference(node);
61407             if (type !== errorType) {
61408                 if (node.typeArguments && produceDiagnostics) {
61409                     var typeParameters = getTypeParametersForTypeReference(node);
61410                     if (typeParameters) {
61411                         checkTypeArgumentConstraints(node, typeParameters);
61412                     }
61413                 }
61414                 var symbol = getNodeLinks(node).resolvedSymbol;
61415                 if (symbol) {
61416                     if (ts.some(symbol.declarations, function (d) { return isTypeDeclaration(d) && !!(d.flags & 134217728); })) {
61417                         addDeprecatedSuggestion(getDeprecatedSuggestionNode(node), symbol.declarations, symbol.escapedName);
61418                     }
61419                     if (type.flags & 32 && symbol.flags & 8) {
61420                         error(node, ts.Diagnostics.Enum_type_0_has_members_with_initializers_that_are_not_literals, typeToString(type));
61421                     }
61422                 }
61423             }
61424         }
61425         function getTypeArgumentConstraint(node) {
61426             var typeReferenceNode = ts.tryCast(node.parent, ts.isTypeReferenceType);
61427             if (!typeReferenceNode)
61428                 return undefined;
61429             var typeParameters = getTypeParametersForTypeReference(typeReferenceNode);
61430             var constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments.indexOf(node)]);
61431             return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters)));
61432         }
61433         function checkTypeQuery(node) {
61434             getTypeFromTypeQueryNode(node);
61435         }
61436         function checkTypeLiteral(node) {
61437             ts.forEach(node.members, checkSourceElement);
61438             if (produceDiagnostics) {
61439                 var type = getTypeFromTypeLiteralOrFunctionOrConstructorTypeNode(node);
61440                 checkIndexConstraints(type);
61441                 checkTypeForDuplicateIndexSignatures(node);
61442                 checkObjectTypeForDuplicateDeclarations(node);
61443             }
61444         }
61445         function checkArrayType(node) {
61446             checkSourceElement(node.elementType);
61447         }
61448         function checkTupleType(node) {
61449             var elementTypes = node.elements;
61450             var seenOptionalElement = false;
61451             var seenRestElement = false;
61452             var hasNamedElement = ts.some(elementTypes, ts.isNamedTupleMember);
61453             for (var _i = 0, elementTypes_1 = elementTypes; _i < elementTypes_1.length; _i++) {
61454                 var e = elementTypes_1[_i];
61455                 if (e.kind !== 192 && hasNamedElement) {
61456                     grammarErrorOnNode(e, ts.Diagnostics.Tuple_members_must_all_have_names_or_all_not_have_names);
61457                     break;
61458                 }
61459                 var flags = getTupleElementFlags(e);
61460                 if (flags & 8) {
61461                     var type = getTypeFromTypeNode(e.type);
61462                     if (!isArrayLikeType(type)) {
61463                         error(e, ts.Diagnostics.A_rest_element_type_must_be_an_array_type);
61464                         break;
61465                     }
61466                     if (isArrayType(type) || isTupleType(type) && type.target.combinedFlags & 4) {
61467                         seenRestElement = true;
61468                     }
61469                 }
61470                 else if (flags & 4) {
61471                     if (seenRestElement) {
61472                         grammarErrorOnNode(e, ts.Diagnostics.A_rest_element_cannot_follow_another_rest_element);
61473                         break;
61474                     }
61475                     seenRestElement = true;
61476                 }
61477                 else if (flags & 2) {
61478                     if (seenRestElement) {
61479                         grammarErrorOnNode(e, ts.Diagnostics.An_optional_element_cannot_follow_a_rest_element);
61480                         break;
61481                     }
61482                     seenOptionalElement = true;
61483                 }
61484                 else if (seenOptionalElement) {
61485                     grammarErrorOnNode(e, ts.Diagnostics.A_required_element_cannot_follow_an_optional_element);
61486                     break;
61487                 }
61488             }
61489             ts.forEach(node.elements, checkSourceElement);
61490             getTypeFromTypeNode(node);
61491         }
61492         function checkUnionOrIntersectionType(node) {
61493             ts.forEach(node.types, checkSourceElement);
61494             getTypeFromTypeNode(node);
61495         }
61496         function checkIndexedAccessIndexType(type, accessNode) {
61497             if (!(type.flags & 8388608)) {
61498                 return type;
61499             }
61500             var objectType = type.objectType;
61501             var indexType = type.indexType;
61502             if (isTypeAssignableTo(indexType, getIndexType(objectType, false))) {
61503                 if (accessNode.kind === 202 && ts.isAssignmentTarget(accessNode) &&
61504                     ts.getObjectFlags(objectType) & 32 && getMappedTypeModifiers(objectType) & 1) {
61505                     error(accessNode, ts.Diagnostics.Index_signature_in_type_0_only_permits_reading, typeToString(objectType));
61506                 }
61507                 return type;
61508             }
61509             var apparentObjectType = getApparentType(objectType);
61510             if (getIndexInfoOfType(apparentObjectType, 1) && isTypeAssignableToKind(indexType, 296)) {
61511                 return type;
61512             }
61513             if (isGenericObjectType(objectType)) {
61514                 var propertyName_1 = getPropertyNameFromIndex(indexType, accessNode);
61515                 if (propertyName_1) {
61516                     var propertySymbol = forEachType(apparentObjectType, function (t) { return getPropertyOfType(t, propertyName_1); });
61517                     if (propertySymbol && ts.getDeclarationModifierFlagsFromSymbol(propertySymbol) & 24) {
61518                         error(accessNode, ts.Diagnostics.Private_or_protected_member_0_cannot_be_accessed_on_a_type_parameter, ts.unescapeLeadingUnderscores(propertyName_1));
61519                         return errorType;
61520                     }
61521                 }
61522             }
61523             error(accessNode, ts.Diagnostics.Type_0_cannot_be_used_to_index_type_1, typeToString(indexType), typeToString(objectType));
61524             return errorType;
61525         }
61526         function checkIndexedAccessType(node) {
61527             checkSourceElement(node.objectType);
61528             checkSourceElement(node.indexType);
61529             checkIndexedAccessIndexType(getTypeFromIndexedAccessTypeNode(node), node);
61530         }
61531         function checkMappedType(node) {
61532             checkSourceElement(node.typeParameter);
61533             checkSourceElement(node.nameType);
61534             checkSourceElement(node.type);
61535             if (!node.type) {
61536                 reportImplicitAny(node, anyType);
61537             }
61538             var type = getTypeFromMappedTypeNode(node);
61539             var nameType = getNameTypeFromMappedType(type);
61540             if (nameType) {
61541                 checkTypeAssignableTo(nameType, keyofConstraintType, node.nameType);
61542             }
61543             else {
61544                 var constraintType = getConstraintTypeFromMappedType(type);
61545                 checkTypeAssignableTo(constraintType, keyofConstraintType, ts.getEffectiveConstraintOfTypeParameter(node.typeParameter));
61546             }
61547         }
61548         function checkThisType(node) {
61549             getTypeFromThisTypeNode(node);
61550         }
61551         function checkTypeOperator(node) {
61552             checkGrammarTypeOperatorNode(node);
61553             checkSourceElement(node.type);
61554         }
61555         function checkConditionalType(node) {
61556             ts.forEachChild(node, checkSourceElement);
61557         }
61558         function checkInferType(node) {
61559             if (!ts.findAncestor(node, function (n) { return n.parent && n.parent.kind === 184 && n.parent.extendsType === n; })) {
61560                 grammarErrorOnNode(node, ts.Diagnostics.infer_declarations_are_only_permitted_in_the_extends_clause_of_a_conditional_type);
61561             }
61562             checkSourceElement(node.typeParameter);
61563             registerForUnusedIdentifiersCheck(node);
61564         }
61565         function checkTemplateLiteralType(node) {
61566             for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) {
61567                 var span = _a[_i];
61568                 checkSourceElement(span.type);
61569                 var type = getTypeFromTypeNode(span.type);
61570                 checkTypeAssignableTo(type, templateConstraintType, span.type);
61571             }
61572             getTypeFromTypeNode(node);
61573         }
61574         function checkImportType(node) {
61575             checkSourceElement(node.argument);
61576             getTypeFromTypeNode(node);
61577         }
61578         function checkNamedTupleMember(node) {
61579             if (node.dotDotDotToken && node.questionToken) {
61580                 grammarErrorOnNode(node, ts.Diagnostics.A_tuple_member_cannot_be_both_optional_and_rest);
61581             }
61582             if (node.type.kind === 180) {
61583                 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);
61584             }
61585             if (node.type.kind === 181) {
61586                 grammarErrorOnNode(node.type, ts.Diagnostics.A_labeled_tuple_element_is_declared_as_rest_with_a_before_the_name_rather_than_before_the_type);
61587             }
61588             checkSourceElement(node.type);
61589             getTypeFromTypeNode(node);
61590         }
61591         function isPrivateWithinAmbient(node) {
61592             return (ts.hasEffectiveModifier(node, 8) || ts.isPrivateIdentifierPropertyDeclaration(node)) && !!(node.flags & 8388608);
61593         }
61594         function getEffectiveDeclarationFlags(n, flagsToCheck) {
61595             var flags = ts.getCombinedModifierFlags(n);
61596             if (n.parent.kind !== 253 &&
61597                 n.parent.kind !== 252 &&
61598                 n.parent.kind !== 221 &&
61599                 n.flags & 8388608) {
61600                 if (!(flags & 2) && !(ts.isModuleBlock(n.parent) && ts.isModuleDeclaration(n.parent.parent) && ts.isGlobalScopeAugmentation(n.parent.parent))) {
61601                     flags |= 1;
61602                 }
61603                 flags |= 2;
61604             }
61605             return flags & flagsToCheck;
61606         }
61607         function checkFunctionOrConstructorSymbol(symbol) {
61608             if (!produceDiagnostics) {
61609                 return;
61610             }
61611             function getCanonicalOverload(overloads, implementation) {
61612                 var implementationSharesContainerWithFirstOverload = implementation !== undefined && implementation.parent === overloads[0].parent;
61613                 return implementationSharesContainerWithFirstOverload ? implementation : overloads[0];
61614             }
61615             function checkFlagAgreementBetweenOverloads(overloads, implementation, flagsToCheck, someOverloadFlags, allOverloadFlags) {
61616                 var someButNotAllOverloadFlags = someOverloadFlags ^ allOverloadFlags;
61617                 if (someButNotAllOverloadFlags !== 0) {
61618                     var canonicalFlags_1 = getEffectiveDeclarationFlags(getCanonicalOverload(overloads, implementation), flagsToCheck);
61619                     ts.forEach(overloads, function (o) {
61620                         var deviation = getEffectiveDeclarationFlags(o, flagsToCheck) ^ canonicalFlags_1;
61621                         if (deviation & 1) {
61622                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_exported_or_non_exported);
61623                         }
61624                         else if (deviation & 2) {
61625                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_ambient_or_non_ambient);
61626                         }
61627                         else if (deviation & (8 | 16)) {
61628                             error(ts.getNameOfDeclaration(o) || o, ts.Diagnostics.Overload_signatures_must_all_be_public_private_or_protected);
61629                         }
61630                         else if (deviation & 128) {
61631                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_abstract_or_non_abstract);
61632                         }
61633                     });
61634                 }
61635             }
61636             function checkQuestionTokenAgreementBetweenOverloads(overloads, implementation, someHaveQuestionToken, allHaveQuestionToken) {
61637                 if (someHaveQuestionToken !== allHaveQuestionToken) {
61638                     var canonicalHasQuestionToken_1 = ts.hasQuestionToken(getCanonicalOverload(overloads, implementation));
61639                     ts.forEach(overloads, function (o) {
61640                         var deviation = ts.hasQuestionToken(o) !== canonicalHasQuestionToken_1;
61641                         if (deviation) {
61642                             error(ts.getNameOfDeclaration(o), ts.Diagnostics.Overload_signatures_must_all_be_optional_or_required);
61643                         }
61644                     });
61645                 }
61646             }
61647             var flagsToCheck = 1 | 2 | 8 | 16 | 128;
61648             var someNodeFlags = 0;
61649             var allNodeFlags = flagsToCheck;
61650             var someHaveQuestionToken = false;
61651             var allHaveQuestionToken = true;
61652             var hasOverloads = false;
61653             var bodyDeclaration;
61654             var lastSeenNonAmbientDeclaration;
61655             var previousDeclaration;
61656             var declarations = symbol.declarations;
61657             var isConstructor = (symbol.flags & 16384) !== 0;
61658             function reportImplementationExpectedError(node) {
61659                 if (node.name && ts.nodeIsMissing(node.name)) {
61660                     return;
61661                 }
61662                 var seen = false;
61663                 var subsequentNode = ts.forEachChild(node.parent, function (c) {
61664                     if (seen) {
61665                         return c;
61666                     }
61667                     else {
61668                         seen = c === node;
61669                     }
61670                 });
61671                 if (subsequentNode && subsequentNode.pos === node.end) {
61672                     if (subsequentNode.kind === node.kind) {
61673                         var errorNode_1 = subsequentNode.name || subsequentNode;
61674                         var subsequentName = subsequentNode.name;
61675                         if (node.name && subsequentName && (ts.isPrivateIdentifier(node.name) && ts.isPrivateIdentifier(subsequentName) && node.name.escapedText === subsequentName.escapedText ||
61676                             ts.isComputedPropertyName(node.name) && ts.isComputedPropertyName(subsequentName) ||
61677                             ts.isPropertyNameLiteral(node.name) && ts.isPropertyNameLiteral(subsequentName) &&
61678                                 ts.getEscapedTextOfIdentifierOrLiteral(node.name) === ts.getEscapedTextOfIdentifierOrLiteral(subsequentName))) {
61679                             var reportError = (node.kind === 165 || node.kind === 164) &&
61680                                 ts.hasSyntacticModifier(node, 32) !== ts.hasSyntacticModifier(subsequentNode, 32);
61681                             if (reportError) {
61682                                 var diagnostic = ts.hasSyntacticModifier(node, 32) ? ts.Diagnostics.Function_overload_must_be_static : ts.Diagnostics.Function_overload_must_not_be_static;
61683                                 error(errorNode_1, diagnostic);
61684                             }
61685                             return;
61686                         }
61687                         if (ts.nodeIsPresent(subsequentNode.body)) {
61688                             error(errorNode_1, ts.Diagnostics.Function_implementation_name_must_be_0, ts.declarationNameToString(node.name));
61689                             return;
61690                         }
61691                     }
61692                 }
61693                 var errorNode = node.name || node;
61694                 if (isConstructor) {
61695                     error(errorNode, ts.Diagnostics.Constructor_implementation_is_missing);
61696                 }
61697                 else {
61698                     if (ts.hasSyntacticModifier(node, 128)) {
61699                         error(errorNode, ts.Diagnostics.All_declarations_of_an_abstract_method_must_be_consecutive);
61700                     }
61701                     else {
61702                         error(errorNode, ts.Diagnostics.Function_implementation_is_missing_or_not_immediately_following_the_declaration);
61703                     }
61704                 }
61705             }
61706             var duplicateFunctionDeclaration = false;
61707             var multipleConstructorImplementation = false;
61708             var hasNonAmbientClass = false;
61709             var functionDeclarations = [];
61710             for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
61711                 var current = declarations_4[_i];
61712                 var node = current;
61713                 var inAmbientContext = node.flags & 8388608;
61714                 var inAmbientContextOrInterface = node.parent && (node.parent.kind === 253 || node.parent.kind === 177) || inAmbientContext;
61715                 if (inAmbientContextOrInterface) {
61716                     previousDeclaration = undefined;
61717                 }
61718                 if ((node.kind === 252 || node.kind === 221) && !inAmbientContext) {
61719                     hasNonAmbientClass = true;
61720                 }
61721                 if (node.kind === 251 || node.kind === 165 || node.kind === 164 || node.kind === 166) {
61722                     functionDeclarations.push(node);
61723                     var currentNodeFlags = getEffectiveDeclarationFlags(node, flagsToCheck);
61724                     someNodeFlags |= currentNodeFlags;
61725                     allNodeFlags &= currentNodeFlags;
61726                     someHaveQuestionToken = someHaveQuestionToken || ts.hasQuestionToken(node);
61727                     allHaveQuestionToken = allHaveQuestionToken && ts.hasQuestionToken(node);
61728                     var bodyIsPresent = ts.nodeIsPresent(node.body);
61729                     if (bodyIsPresent && bodyDeclaration) {
61730                         if (isConstructor) {
61731                             multipleConstructorImplementation = true;
61732                         }
61733                         else {
61734                             duplicateFunctionDeclaration = true;
61735                         }
61736                     }
61737                     else if ((previousDeclaration === null || previousDeclaration === void 0 ? void 0 : previousDeclaration.parent) === node.parent && previousDeclaration.end !== node.pos) {
61738                         reportImplementationExpectedError(previousDeclaration);
61739                     }
61740                     if (bodyIsPresent) {
61741                         if (!bodyDeclaration) {
61742                             bodyDeclaration = node;
61743                         }
61744                     }
61745                     else {
61746                         hasOverloads = true;
61747                     }
61748                     previousDeclaration = node;
61749                     if (!inAmbientContextOrInterface) {
61750                         lastSeenNonAmbientDeclaration = node;
61751                     }
61752                 }
61753             }
61754             if (multipleConstructorImplementation) {
61755                 ts.forEach(functionDeclarations, function (declaration) {
61756                     error(declaration, ts.Diagnostics.Multiple_constructor_implementations_are_not_allowed);
61757                 });
61758             }
61759             if (duplicateFunctionDeclaration) {
61760                 ts.forEach(functionDeclarations, function (declaration) {
61761                     error(ts.getNameOfDeclaration(declaration) || declaration, ts.Diagnostics.Duplicate_function_implementation);
61762                 });
61763             }
61764             if (hasNonAmbientClass && !isConstructor && symbol.flags & 16) {
61765                 ts.forEach(declarations, function (declaration) {
61766                     addDuplicateDeclarationError(declaration, ts.Diagnostics.Duplicate_identifier_0, ts.symbolName(symbol), declarations);
61767                 });
61768             }
61769             if (lastSeenNonAmbientDeclaration && !lastSeenNonAmbientDeclaration.body &&
61770                 !ts.hasSyntacticModifier(lastSeenNonAmbientDeclaration, 128) && !lastSeenNonAmbientDeclaration.questionToken) {
61771                 reportImplementationExpectedError(lastSeenNonAmbientDeclaration);
61772             }
61773             if (hasOverloads) {
61774                 checkFlagAgreementBetweenOverloads(declarations, bodyDeclaration, flagsToCheck, someNodeFlags, allNodeFlags);
61775                 checkQuestionTokenAgreementBetweenOverloads(declarations, bodyDeclaration, someHaveQuestionToken, allHaveQuestionToken);
61776                 if (bodyDeclaration) {
61777                     var signatures = getSignaturesOfSymbol(symbol);
61778                     var bodySignature = getSignatureFromDeclaration(bodyDeclaration);
61779                     for (var _a = 0, signatures_10 = signatures; _a < signatures_10.length; _a++) {
61780                         var signature = signatures_10[_a];
61781                         if (!isImplementationCompatibleWithOverload(bodySignature, signature)) {
61782                             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));
61783                             break;
61784                         }
61785                     }
61786                 }
61787             }
61788         }
61789         function checkExportsOnMergedDeclarations(node) {
61790             if (!produceDiagnostics) {
61791                 return;
61792             }
61793             var symbol = node.localSymbol;
61794             if (!symbol) {
61795                 symbol = getSymbolOfNode(node);
61796                 if (!symbol.exportSymbol) {
61797                     return;
61798                 }
61799             }
61800             if (ts.getDeclarationOfKind(symbol, node.kind) !== node) {
61801                 return;
61802             }
61803             var exportedDeclarationSpaces = 0;
61804             var nonExportedDeclarationSpaces = 0;
61805             var defaultExportedDeclarationSpaces = 0;
61806             for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
61807                 var d = _a[_i];
61808                 var declarationSpaces = getDeclarationSpaces(d);
61809                 var effectiveDeclarationFlags = getEffectiveDeclarationFlags(d, 1 | 512);
61810                 if (effectiveDeclarationFlags & 1) {
61811                     if (effectiveDeclarationFlags & 512) {
61812                         defaultExportedDeclarationSpaces |= declarationSpaces;
61813                     }
61814                     else {
61815                         exportedDeclarationSpaces |= declarationSpaces;
61816                     }
61817                 }
61818                 else {
61819                     nonExportedDeclarationSpaces |= declarationSpaces;
61820                 }
61821             }
61822             var nonDefaultExportedDeclarationSpaces = exportedDeclarationSpaces | nonExportedDeclarationSpaces;
61823             var commonDeclarationSpacesForExportsAndLocals = exportedDeclarationSpaces & nonExportedDeclarationSpaces;
61824             var commonDeclarationSpacesForDefaultAndNonDefault = defaultExportedDeclarationSpaces & nonDefaultExportedDeclarationSpaces;
61825             if (commonDeclarationSpacesForExportsAndLocals || commonDeclarationSpacesForDefaultAndNonDefault) {
61826                 for (var _b = 0, _c = symbol.declarations; _b < _c.length; _b++) {
61827                     var d = _c[_b];
61828                     var declarationSpaces = getDeclarationSpaces(d);
61829                     var name = ts.getNameOfDeclaration(d);
61830                     if (declarationSpaces & commonDeclarationSpacesForDefaultAndNonDefault) {
61831                         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));
61832                     }
61833                     else if (declarationSpaces & commonDeclarationSpacesForExportsAndLocals) {
61834                         error(name, ts.Diagnostics.Individual_declarations_in_merged_declaration_0_must_be_all_exported_or_all_local, ts.declarationNameToString(name));
61835                     }
61836                 }
61837             }
61838             function getDeclarationSpaces(decl) {
61839                 var d = decl;
61840                 switch (d.kind) {
61841                     case 253:
61842                     case 254:
61843                     case 331:
61844                     case 324:
61845                     case 325:
61846                         return 2;
61847                     case 256:
61848                         return ts.isAmbientModule(d) || ts.getModuleInstanceState(d) !== 0
61849                             ? 4 | 1
61850                             : 4;
61851                     case 252:
61852                     case 255:
61853                     case 291:
61854                         return 2 | 1;
61855                     case 297:
61856                         return 2 | 1 | 4;
61857                     case 266:
61858                         if (!ts.isEntityNameExpression(d.expression)) {
61859                             return 1;
61860                         }
61861                         d = d.expression;
61862                     case 260:
61863                     case 263:
61864                     case 262:
61865                         var result_12 = 0;
61866                         var target = resolveAlias(getSymbolOfNode(d));
61867                         ts.forEach(target.declarations, function (d) { result_12 |= getDeclarationSpaces(d); });
61868                         return result_12;
61869                     case 249:
61870                     case 198:
61871                     case 251:
61872                     case 265:
61873                     case 78:
61874                         return 1;
61875                     default:
61876                         return ts.Debug.failBadSyntaxKind(d);
61877                 }
61878             }
61879         }
61880         function getAwaitedTypeOfPromise(type, errorNode, diagnosticMessage, arg0) {
61881             var promisedType = getPromisedTypeOfPromise(type, errorNode);
61882             return promisedType && getAwaitedType(promisedType, errorNode, diagnosticMessage, arg0);
61883         }
61884         function getPromisedTypeOfPromise(type, errorNode) {
61885             if (isTypeAny(type)) {
61886                 return undefined;
61887             }
61888             var typeAsPromise = type;
61889             if (typeAsPromise.promisedTypeOfPromise) {
61890                 return typeAsPromise.promisedTypeOfPromise;
61891             }
61892             if (isReferenceToType(type, getGlobalPromiseType(false))) {
61893                 return typeAsPromise.promisedTypeOfPromise = getTypeArguments(type)[0];
61894             }
61895             var thenFunction = getTypeOfPropertyOfType(type, "then");
61896             if (isTypeAny(thenFunction)) {
61897                 return undefined;
61898             }
61899             var thenSignatures = thenFunction ? getSignaturesOfType(thenFunction, 0) : ts.emptyArray;
61900             if (thenSignatures.length === 0) {
61901                 if (errorNode) {
61902                     error(errorNode, ts.Diagnostics.A_promise_must_have_a_then_method);
61903                 }
61904                 return undefined;
61905             }
61906             var onfulfilledParameterType = getTypeWithFacts(getUnionType(ts.map(thenSignatures, getTypeOfFirstParameterOfSignature)), 2097152);
61907             if (isTypeAny(onfulfilledParameterType)) {
61908                 return undefined;
61909             }
61910             var onfulfilledParameterSignatures = getSignaturesOfType(onfulfilledParameterType, 0);
61911             if (onfulfilledParameterSignatures.length === 0) {
61912                 if (errorNode) {
61913                     error(errorNode, ts.Diagnostics.The_first_parameter_of_the_then_method_of_a_promise_must_be_a_callback);
61914                 }
61915                 return undefined;
61916             }
61917             return typeAsPromise.promisedTypeOfPromise = getUnionType(ts.map(onfulfilledParameterSignatures, getTypeOfFirstParameterOfSignature), 2);
61918         }
61919         function checkAwaitedType(type, errorNode, diagnosticMessage, arg0) {
61920             var awaitedType = getAwaitedType(type, errorNode, diagnosticMessage, arg0);
61921             return awaitedType || errorType;
61922         }
61923         function isThenableType(type) {
61924             var thenFunction = getTypeOfPropertyOfType(type, "then");
61925             return !!thenFunction && getSignaturesOfType(getTypeWithFacts(thenFunction, 2097152), 0).length > 0;
61926         }
61927         function getAwaitedType(type, errorNode, diagnosticMessage, arg0) {
61928             if (isTypeAny(type)) {
61929                 return type;
61930             }
61931             var typeAsAwaitable = type;
61932             if (typeAsAwaitable.awaitedTypeOfType) {
61933                 return typeAsAwaitable.awaitedTypeOfType;
61934             }
61935             return typeAsAwaitable.awaitedTypeOfType =
61936                 mapType(type, errorNode ? function (constituentType) { return getAwaitedTypeWorker(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeWorker);
61937         }
61938         function getAwaitedTypeWorker(type, errorNode, diagnosticMessage, arg0) {
61939             var typeAsAwaitable = type;
61940             if (typeAsAwaitable.awaitedTypeOfType) {
61941                 return typeAsAwaitable.awaitedTypeOfType;
61942             }
61943             var promisedType = getPromisedTypeOfPromise(type);
61944             if (promisedType) {
61945                 if (type.id === promisedType.id || awaitedTypeStack.lastIndexOf(promisedType.id) >= 0) {
61946                     if (errorNode) {
61947                         error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method);
61948                     }
61949                     return undefined;
61950                 }
61951                 awaitedTypeStack.push(type.id);
61952                 var awaitedType = getAwaitedType(promisedType, errorNode, diagnosticMessage, arg0);
61953                 awaitedTypeStack.pop();
61954                 if (!awaitedType) {
61955                     return undefined;
61956                 }
61957                 return typeAsAwaitable.awaitedTypeOfType = awaitedType;
61958             }
61959             if (isThenableType(type)) {
61960                 if (errorNode) {
61961                     if (!diagnosticMessage)
61962                         return ts.Debug.fail();
61963                     error(errorNode, diagnosticMessage, arg0);
61964                 }
61965                 return undefined;
61966             }
61967             return typeAsAwaitable.awaitedTypeOfType = type;
61968         }
61969         function checkAsyncFunctionReturnType(node, returnTypeNode) {
61970             var returnType = getTypeFromTypeNode(returnTypeNode);
61971             if (languageVersion >= 2) {
61972                 if (returnType === errorType) {
61973                     return;
61974                 }
61975                 var globalPromiseType = getGlobalPromiseType(true);
61976                 if (globalPromiseType !== emptyGenericType && !isReferenceToType(returnType, globalPromiseType)) {
61977                     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));
61978                     return;
61979                 }
61980             }
61981             else {
61982                 markTypeNodeAsReferenced(returnTypeNode);
61983                 if (returnType === errorType) {
61984                     return;
61985                 }
61986                 var promiseConstructorName = ts.getEntityNameFromTypeNode(returnTypeNode);
61987                 if (promiseConstructorName === undefined) {
61988                     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));
61989                     return;
61990                 }
61991                 var promiseConstructorSymbol = resolveEntityName(promiseConstructorName, 111551, true);
61992                 var promiseConstructorType = promiseConstructorSymbol ? getTypeOfSymbol(promiseConstructorSymbol) : errorType;
61993                 if (promiseConstructorType === errorType) {
61994                     if (promiseConstructorName.kind === 78 && promiseConstructorName.escapedText === "Promise" && getTargetType(returnType) === getGlobalPromiseType(false)) {
61995                         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);
61996                     }
61997                     else {
61998                         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));
61999                     }
62000                     return;
62001                 }
62002                 var globalPromiseConstructorLikeType = getGlobalPromiseConstructorLikeType(true);
62003                 if (globalPromiseConstructorLikeType === emptyObjectType) {
62004                     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));
62005                     return;
62006                 }
62007                 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)) {
62008                     return;
62009                 }
62010                 var rootName = promiseConstructorName && ts.getFirstIdentifier(promiseConstructorName);
62011                 var collidingSymbol = getSymbol(node.locals, rootName.escapedText, 111551);
62012                 if (collidingSymbol) {
62013                     error(collidingSymbol.valueDeclaration, ts.Diagnostics.Duplicate_identifier_0_Compiler_uses_declaration_1_to_support_async_functions, ts.idText(rootName), ts.entityNameToString(promiseConstructorName));
62014                     return;
62015                 }
62016             }
62017             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);
62018         }
62019         function checkDecorator(node) {
62020             var signature = getResolvedSignature(node);
62021             checkDeprecatedSignature(signature, node);
62022             var returnType = getReturnTypeOfSignature(signature);
62023             if (returnType.flags & 1) {
62024                 return;
62025             }
62026             var expectedReturnType;
62027             var headMessage = getDiagnosticHeadMessageForDecoratorResolution(node);
62028             var errorInfo;
62029             switch (node.parent.kind) {
62030                 case 252:
62031                     var classSymbol = getSymbolOfNode(node.parent);
62032                     var classConstructorType = getTypeOfSymbol(classSymbol);
62033                     expectedReturnType = getUnionType([classConstructorType, voidType]);
62034                     break;
62035                 case 160:
62036                     expectedReturnType = voidType;
62037                     errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_parameter_decorator_function_must_be_either_void_or_any);
62038                     break;
62039                 case 163:
62040                     expectedReturnType = voidType;
62041                     errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.The_return_type_of_a_property_decorator_function_must_be_either_void_or_any);
62042                     break;
62043                 case 165:
62044                 case 167:
62045                 case 168:
62046                     var methodType = getTypeOfNode(node.parent);
62047                     var descriptorType = createTypedPropertyDescriptorType(methodType);
62048                     expectedReturnType = getUnionType([descriptorType, voidType]);
62049                     break;
62050                 default:
62051                     return ts.Debug.fail();
62052             }
62053             checkTypeAssignableTo(returnType, expectedReturnType, node, headMessage, function () { return errorInfo; });
62054         }
62055         function markTypeNodeAsReferenced(node) {
62056             markEntityNameOrEntityExpressionAsReference(node && ts.getEntityNameFromTypeNode(node));
62057         }
62058         function markEntityNameOrEntityExpressionAsReference(typeName) {
62059             if (!typeName)
62060                 return;
62061             var rootName = ts.getFirstIdentifier(typeName);
62062             var meaning = (typeName.kind === 78 ? 788968 : 1920) | 2097152;
62063             var rootSymbol = resolveName(rootName, rootName.escapedText, meaning, undefined, undefined, true);
62064             if (rootSymbol
62065                 && rootSymbol.flags & 2097152
62066                 && symbolIsValue(rootSymbol)
62067                 && !isConstEnumOrConstEnumOnlyModule(resolveAlias(rootSymbol))
62068                 && !getTypeOnlyAliasDeclaration(rootSymbol)) {
62069                 markAliasSymbolAsReferenced(rootSymbol);
62070             }
62071         }
62072         function markDecoratorMedataDataTypeNodeAsReferenced(node) {
62073             var entityName = getEntityNameForDecoratorMetadata(node);
62074             if (entityName && ts.isEntityName(entityName)) {
62075                 markEntityNameOrEntityExpressionAsReference(entityName);
62076             }
62077         }
62078         function getEntityNameForDecoratorMetadata(node) {
62079             if (node) {
62080                 switch (node.kind) {
62081                     case 183:
62082                     case 182:
62083                         return getEntityNameForDecoratorMetadataFromTypeList(node.types);
62084                     case 184:
62085                         return getEntityNameForDecoratorMetadataFromTypeList([node.trueType, node.falseType]);
62086                     case 186:
62087                     case 192:
62088                         return getEntityNameForDecoratorMetadata(node.type);
62089                     case 173:
62090                         return node.typeName;
62091                 }
62092             }
62093         }
62094         function getEntityNameForDecoratorMetadataFromTypeList(types) {
62095             var commonEntityName;
62096             for (var _i = 0, types_23 = types; _i < types_23.length; _i++) {
62097                 var typeNode = types_23[_i];
62098                 while (typeNode.kind === 186 || typeNode.kind === 192) {
62099                     typeNode = typeNode.type;
62100                 }
62101                 if (typeNode.kind === 141) {
62102                     continue;
62103                 }
62104                 if (!strictNullChecks && (typeNode.kind === 191 && typeNode.literal.kind === 103 || typeNode.kind === 150)) {
62105                     continue;
62106                 }
62107                 var individualEntityName = getEntityNameForDecoratorMetadata(typeNode);
62108                 if (!individualEntityName) {
62109                     return undefined;
62110                 }
62111                 if (commonEntityName) {
62112                     if (!ts.isIdentifier(commonEntityName) ||
62113                         !ts.isIdentifier(individualEntityName) ||
62114                         commonEntityName.escapedText !== individualEntityName.escapedText) {
62115                         return undefined;
62116                     }
62117                 }
62118                 else {
62119                     commonEntityName = individualEntityName;
62120                 }
62121             }
62122             return commonEntityName;
62123         }
62124         function getParameterTypeNodeForDecoratorCheck(node) {
62125             var typeNode = ts.getEffectiveTypeAnnotationNode(node);
62126             return ts.isRestParameter(node) ? ts.getRestParameterElementType(typeNode) : typeNode;
62127         }
62128         function checkDecorators(node) {
62129             if (!node.decorators) {
62130                 return;
62131             }
62132             if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) {
62133                 return;
62134             }
62135             if (!compilerOptions.experimentalDecorators) {
62136                 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);
62137             }
62138             var firstDecorator = node.decorators[0];
62139             checkExternalEmitHelpers(firstDecorator, 8);
62140             if (node.kind === 160) {
62141                 checkExternalEmitHelpers(firstDecorator, 32);
62142             }
62143             if (compilerOptions.emitDecoratorMetadata) {
62144                 checkExternalEmitHelpers(firstDecorator, 16);
62145                 switch (node.kind) {
62146                     case 252:
62147                         var constructor = ts.getFirstConstructorWithBody(node);
62148                         if (constructor) {
62149                             for (var _i = 0, _a = constructor.parameters; _i < _a.length; _i++) {
62150                                 var parameter = _a[_i];
62151                                 markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
62152                             }
62153                         }
62154                         break;
62155                     case 167:
62156                     case 168:
62157                         var otherKind = node.kind === 167 ? 168 : 167;
62158                         var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(node), otherKind);
62159                         markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor));
62160                         break;
62161                     case 165:
62162                         for (var _b = 0, _c = node.parameters; _b < _c.length; _b++) {
62163                             var parameter = _c[_b];
62164                             markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
62165                         }
62166                         markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveReturnTypeNode(node));
62167                         break;
62168                     case 163:
62169                         markDecoratorMedataDataTypeNodeAsReferenced(ts.getEffectiveTypeAnnotationNode(node));
62170                         break;
62171                     case 160:
62172                         markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node));
62173                         var containingSignature = node.parent;
62174                         for (var _d = 0, _e = containingSignature.parameters; _d < _e.length; _d++) {
62175                             var parameter = _e[_d];
62176                             markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter));
62177                         }
62178                         break;
62179                 }
62180             }
62181             ts.forEach(node.decorators, checkDecorator);
62182         }
62183         function checkFunctionDeclaration(node) {
62184             if (produceDiagnostics) {
62185                 checkFunctionOrMethodDeclaration(node);
62186                 checkGrammarForGenerator(node);
62187                 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
62188                 checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
62189             }
62190         }
62191         function checkJSDocTypeAliasTag(node) {
62192             if (!node.typeExpression) {
62193                 error(node.name, ts.Diagnostics.JSDoc_typedef_tag_should_either_have_a_type_annotation_or_be_followed_by_property_or_member_tags);
62194             }
62195             if (node.name) {
62196                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0);
62197             }
62198             checkSourceElement(node.typeExpression);
62199         }
62200         function checkJSDocTemplateTag(node) {
62201             checkSourceElement(node.constraint);
62202             for (var _i = 0, _a = node.typeParameters; _i < _a.length; _i++) {
62203                 var tp = _a[_i];
62204                 checkSourceElement(tp);
62205             }
62206         }
62207         function checkJSDocTypeTag(node) {
62208             checkSourceElement(node.typeExpression);
62209         }
62210         function checkJSDocParameterTag(node) {
62211             checkSourceElement(node.typeExpression);
62212             if (!ts.getParameterSymbolFromJSDoc(node)) {
62213                 var decl = ts.getHostSignatureFromJSDoc(node);
62214                 if (decl) {
62215                     var i = ts.getJSDocTags(decl).filter(ts.isJSDocParameterTag).indexOf(node);
62216                     if (i > -1 && i < decl.parameters.length && ts.isBindingPattern(decl.parameters[i].name)) {
62217                         return;
62218                     }
62219                     if (!containsArgumentsReference(decl)) {
62220                         if (ts.isQualifiedName(node.name)) {
62221                             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));
62222                         }
62223                         else {
62224                             error(node.name, ts.Diagnostics.JSDoc_param_tag_has_name_0_but_there_is_no_parameter_with_that_name, ts.idText(node.name));
62225                         }
62226                     }
62227                     else if (ts.findLast(ts.getJSDocTags(decl), ts.isJSDocParameterTag) === node &&
62228                         node.typeExpression && node.typeExpression.type &&
62229                         !isArrayType(getTypeFromTypeNode(node.typeExpression.type))) {
62230                         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));
62231                     }
62232                 }
62233             }
62234         }
62235         function checkJSDocPropertyTag(node) {
62236             checkSourceElement(node.typeExpression);
62237         }
62238         function checkJSDocFunctionType(node) {
62239             if (produceDiagnostics && !node.type && !ts.isJSDocConstructSignature(node)) {
62240                 reportImplicitAny(node, anyType);
62241             }
62242             checkSignatureDeclaration(node);
62243         }
62244         function checkJSDocImplementsTag(node) {
62245             var classLike = ts.getEffectiveJSDocHost(node);
62246             if (!classLike || !ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) {
62247                 error(classLike, ts.Diagnostics.JSDoc_0_is_not_attached_to_a_class, ts.idText(node.tagName));
62248             }
62249         }
62250         function checkJSDocAugmentsTag(node) {
62251             var classLike = ts.getEffectiveJSDocHost(node);
62252             if (!classLike || !ts.isClassDeclaration(classLike) && !ts.isClassExpression(classLike)) {
62253                 error(classLike, ts.Diagnostics.JSDoc_0_is_not_attached_to_a_class, ts.idText(node.tagName));
62254                 return;
62255             }
62256             var augmentsTags = ts.getJSDocTags(classLike).filter(ts.isJSDocAugmentsTag);
62257             ts.Debug.assert(augmentsTags.length > 0);
62258             if (augmentsTags.length > 1) {
62259                 error(augmentsTags[1], ts.Diagnostics.Class_declarations_cannot_have_more_than_one_augments_or_extends_tag);
62260             }
62261             var name = getIdentifierFromEntityNameExpression(node.class.expression);
62262             var extend = ts.getClassExtendsHeritageElement(classLike);
62263             if (extend) {
62264                 var className = getIdentifierFromEntityNameExpression(extend.expression);
62265                 if (className && name.escapedText !== className.escapedText) {
62266                     error(name, ts.Diagnostics.JSDoc_0_1_does_not_match_the_extends_2_clause, ts.idText(node.tagName), ts.idText(name), ts.idText(className));
62267                 }
62268             }
62269         }
62270         function getIdentifierFromEntityNameExpression(node) {
62271             switch (node.kind) {
62272                 case 78:
62273                     return node;
62274                 case 201:
62275                     return node.name;
62276                 default:
62277                     return undefined;
62278             }
62279         }
62280         function checkFunctionOrMethodDeclaration(node) {
62281             checkDecorators(node);
62282             checkSignatureDeclaration(node);
62283             var functionFlags = ts.getFunctionFlags(node);
62284             if (node.name && node.name.kind === 158) {
62285                 checkComputedPropertyName(node.name);
62286             }
62287             if (hasBindableName(node)) {
62288                 var symbol = getSymbolOfNode(node);
62289                 var localSymbol = node.localSymbol || symbol;
62290                 var firstDeclaration = ts.find(localSymbol.declarations, function (declaration) { return declaration.kind === node.kind && !(declaration.flags & 131072); });
62291                 if (node === firstDeclaration) {
62292                     checkFunctionOrConstructorSymbol(localSymbol);
62293                 }
62294                 if (symbol.parent) {
62295                     checkFunctionOrConstructorSymbol(symbol);
62296                 }
62297             }
62298             var body = node.kind === 164 ? undefined : node.body;
62299             checkSourceElement(body);
62300             checkAllCodePathsInNonVoidFunctionReturnOrThrow(node, getReturnTypeFromAnnotation(node));
62301             if (produceDiagnostics && !ts.getEffectiveReturnTypeNode(node)) {
62302                 if (ts.nodeIsMissing(body) && !isPrivateWithinAmbient(node)) {
62303                     reportImplicitAny(node, anyType);
62304                 }
62305                 if (functionFlags & 1 && ts.nodeIsPresent(body)) {
62306                     getReturnTypeOfSignature(getSignatureFromDeclaration(node));
62307                 }
62308             }
62309             if (ts.isInJSFile(node)) {
62310                 var typeTag = ts.getJSDocTypeTag(node);
62311                 if (typeTag && typeTag.typeExpression && !getContextualCallSignature(getTypeFromTypeNode(typeTag.typeExpression), node)) {
62312                     error(typeTag.typeExpression.type, ts.Diagnostics.The_type_of_a_function_declaration_must_match_the_function_s_signature);
62313                 }
62314             }
62315         }
62316         function registerForUnusedIdentifiersCheck(node) {
62317             if (produceDiagnostics) {
62318                 var sourceFile = ts.getSourceFileOfNode(node);
62319                 var potentiallyUnusedIdentifiers = allPotentiallyUnusedIdentifiers.get(sourceFile.path);
62320                 if (!potentiallyUnusedIdentifiers) {
62321                     potentiallyUnusedIdentifiers = [];
62322                     allPotentiallyUnusedIdentifiers.set(sourceFile.path, potentiallyUnusedIdentifiers);
62323                 }
62324                 potentiallyUnusedIdentifiers.push(node);
62325             }
62326         }
62327         function checkUnusedIdentifiers(potentiallyUnusedIdentifiers, addDiagnostic) {
62328             for (var _i = 0, potentiallyUnusedIdentifiers_1 = potentiallyUnusedIdentifiers; _i < potentiallyUnusedIdentifiers_1.length; _i++) {
62329                 var node = potentiallyUnusedIdentifiers_1[_i];
62330                 switch (node.kind) {
62331                     case 252:
62332                     case 221:
62333                         checkUnusedClassMembers(node, addDiagnostic);
62334                         checkUnusedTypeParameters(node, addDiagnostic);
62335                         break;
62336                     case 297:
62337                     case 256:
62338                     case 230:
62339                     case 258:
62340                     case 237:
62341                     case 238:
62342                     case 239:
62343                         checkUnusedLocalsAndParameters(node, addDiagnostic);
62344                         break;
62345                     case 166:
62346                     case 208:
62347                     case 251:
62348                     case 209:
62349                     case 165:
62350                     case 167:
62351                     case 168:
62352                         if (node.body) {
62353                             checkUnusedLocalsAndParameters(node, addDiagnostic);
62354                         }
62355                         checkUnusedTypeParameters(node, addDiagnostic);
62356                         break;
62357                     case 164:
62358                     case 169:
62359                     case 170:
62360                     case 174:
62361                     case 175:
62362                     case 254:
62363                     case 253:
62364                         checkUnusedTypeParameters(node, addDiagnostic);
62365                         break;
62366                     case 185:
62367                         checkUnusedInferTypeParameter(node, addDiagnostic);
62368                         break;
62369                     default:
62370                         ts.Debug.assertNever(node, "Node should not have been registered for unused identifiers check");
62371                 }
62372             }
62373         }
62374         function errorUnusedLocal(declaration, name, addDiagnostic) {
62375             var node = ts.getNameOfDeclaration(declaration) || declaration;
62376             var message = isTypeDeclaration(declaration) ? ts.Diagnostics._0_is_declared_but_never_used : ts.Diagnostics._0_is_declared_but_its_value_is_never_read;
62377             addDiagnostic(declaration, 0, ts.createDiagnosticForNode(node, message, name));
62378         }
62379         function isIdentifierThatStartsWithUnderscore(node) {
62380             return ts.isIdentifier(node) && ts.idText(node).charCodeAt(0) === 95;
62381         }
62382         function checkUnusedClassMembers(node, addDiagnostic) {
62383             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
62384                 var member = _a[_i];
62385                 switch (member.kind) {
62386                     case 165:
62387                     case 163:
62388                     case 167:
62389                     case 168:
62390                         if (member.kind === 168 && member.symbol.flags & 32768) {
62391                             break;
62392                         }
62393                         var symbol = getSymbolOfNode(member);
62394                         if (!symbol.isReferenced
62395                             && (ts.hasEffectiveModifier(member, 8) || ts.isNamedDeclaration(member) && ts.isPrivateIdentifier(member.name))
62396                             && !(member.flags & 8388608)) {
62397                             addDiagnostic(member, 0, ts.createDiagnosticForNode(member.name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, symbolToString(symbol)));
62398                         }
62399                         break;
62400                     case 166:
62401                         for (var _b = 0, _c = member.parameters; _b < _c.length; _b++) {
62402                             var parameter = _c[_b];
62403                             if (!parameter.symbol.isReferenced && ts.hasSyntacticModifier(parameter, 8)) {
62404                                 addDiagnostic(parameter, 0, ts.createDiagnosticForNode(parameter.name, ts.Diagnostics.Property_0_is_declared_but_its_value_is_never_read, ts.symbolName(parameter.symbol)));
62405                             }
62406                         }
62407                         break;
62408                     case 171:
62409                     case 229:
62410                         break;
62411                     default:
62412                         ts.Debug.fail();
62413                 }
62414             }
62415         }
62416         function checkUnusedInferTypeParameter(node, addDiagnostic) {
62417             var typeParameter = node.typeParameter;
62418             if (isTypeParameterUnused(typeParameter)) {
62419                 addDiagnostic(node, 1, ts.createDiagnosticForNode(node, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(typeParameter.name)));
62420             }
62421         }
62422         function checkUnusedTypeParameters(node, addDiagnostic) {
62423             if (ts.last(getSymbolOfNode(node).declarations) !== node)
62424                 return;
62425             var typeParameters = ts.getEffectiveTypeParameterDeclarations(node);
62426             var seenParentsWithEveryUnused = new ts.Set();
62427             for (var _i = 0, typeParameters_3 = typeParameters; _i < typeParameters_3.length; _i++) {
62428                 var typeParameter = typeParameters_3[_i];
62429                 if (!isTypeParameterUnused(typeParameter))
62430                     continue;
62431                 var name = ts.idText(typeParameter.name);
62432                 var parent = typeParameter.parent;
62433                 if (parent.kind !== 185 && parent.typeParameters.every(isTypeParameterUnused)) {
62434                     if (ts.tryAddToSet(seenParentsWithEveryUnused, parent)) {
62435                         var sourceFile = ts.getSourceFileOfNode(parent);
62436                         var range = ts.isJSDocTemplateTag(parent)
62437                             ? ts.rangeOfNode(parent)
62438                             : ts.rangeOfTypeParameters(sourceFile, parent.typeParameters);
62439                         var only = parent.typeParameters.length === 1;
62440                         var message = only ? ts.Diagnostics._0_is_declared_but_its_value_is_never_read : ts.Diagnostics.All_type_parameters_are_unused;
62441                         var arg0 = only ? name : undefined;
62442                         addDiagnostic(typeParameter, 1, ts.createFileDiagnostic(sourceFile, range.pos, range.end - range.pos, message, arg0));
62443                     }
62444                 }
62445                 else {
62446                     addDiagnostic(typeParameter, 1, ts.createDiagnosticForNode(typeParameter, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, name));
62447                 }
62448             }
62449         }
62450         function isTypeParameterUnused(typeParameter) {
62451             return !(getMergedSymbol(typeParameter.symbol).isReferenced & 262144) && !isIdentifierThatStartsWithUnderscore(typeParameter.name);
62452         }
62453         function addToGroup(map, key, value, getKey) {
62454             var keyString = String(getKey(key));
62455             var group = map.get(keyString);
62456             if (group) {
62457                 group[1].push(value);
62458             }
62459             else {
62460                 map.set(keyString, [key, [value]]);
62461             }
62462         }
62463         function tryGetRootParameterDeclaration(node) {
62464             return ts.tryCast(ts.getRootDeclaration(node), ts.isParameter);
62465         }
62466         function isValidUnusedLocalDeclaration(declaration) {
62467             if (ts.isBindingElement(declaration)) {
62468                 if (ts.isObjectBindingPattern(declaration.parent)) {
62469                     return !!(declaration.propertyName && isIdentifierThatStartsWithUnderscore(declaration.name));
62470                 }
62471                 return isIdentifierThatStartsWithUnderscore(declaration.name);
62472             }
62473             return ts.isAmbientModule(declaration) ||
62474                 (ts.isVariableDeclaration(declaration) && ts.isForInOrOfStatement(declaration.parent.parent) || isImportedDeclaration(declaration)) && isIdentifierThatStartsWithUnderscore(declaration.name);
62475         }
62476         function checkUnusedLocalsAndParameters(nodeWithLocals, addDiagnostic) {
62477             var unusedImports = new ts.Map();
62478             var unusedDestructures = new ts.Map();
62479             var unusedVariables = new ts.Map();
62480             nodeWithLocals.locals.forEach(function (local) {
62481                 if (local.flags & 262144 ? !(local.flags & 3 && !(local.isReferenced & 3)) : local.isReferenced || local.exportSymbol) {
62482                     return;
62483                 }
62484                 for (var _i = 0, _a = local.declarations; _i < _a.length; _i++) {
62485                     var declaration = _a[_i];
62486                     if (isValidUnusedLocalDeclaration(declaration)) {
62487                         continue;
62488                     }
62489                     if (isImportedDeclaration(declaration)) {
62490                         addToGroup(unusedImports, importClauseFromImported(declaration), declaration, getNodeId);
62491                     }
62492                     else if (ts.isBindingElement(declaration) && ts.isObjectBindingPattern(declaration.parent)) {
62493                         var lastElement = ts.last(declaration.parent.elements);
62494                         if (declaration === lastElement || !ts.last(declaration.parent.elements).dotDotDotToken) {
62495                             addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId);
62496                         }
62497                     }
62498                     else if (ts.isVariableDeclaration(declaration)) {
62499                         addToGroup(unusedVariables, declaration.parent, declaration, getNodeId);
62500                     }
62501                     else {
62502                         var parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration);
62503                         var name = local.valueDeclaration && ts.getNameOfDeclaration(local.valueDeclaration);
62504                         if (parameter && name) {
62505                             if (!ts.isParameterPropertyDeclaration(parameter, parameter.parent) && !ts.parameterIsThisKeyword(parameter) && !isIdentifierThatStartsWithUnderscore(name)) {
62506                                 if (ts.isBindingElement(declaration) && ts.isArrayBindingPattern(declaration.parent)) {
62507                                     addToGroup(unusedDestructures, declaration.parent, declaration, getNodeId);
62508                                 }
62509                                 else {
62510                                     addDiagnostic(parameter, 1, ts.createDiagnosticForNode(name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.symbolName(local)));
62511                                 }
62512                             }
62513                         }
62514                         else {
62515                             errorUnusedLocal(declaration, ts.symbolName(local), addDiagnostic);
62516                         }
62517                     }
62518                 }
62519             });
62520             unusedImports.forEach(function (_a) {
62521                 var importClause = _a[0], unuseds = _a[1];
62522                 var importDecl = importClause.parent;
62523                 var nDeclarations = (importClause.name ? 1 : 0) +
62524                     (importClause.namedBindings ?
62525                         (importClause.namedBindings.kind === 263 ? 1 : importClause.namedBindings.elements.length)
62526                         : 0);
62527                 if (nDeclarations === unuseds.length) {
62528                     addDiagnostic(importDecl, 0, unuseds.length === 1
62529                         ? ts.createDiagnosticForNode(importDecl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, ts.idText(ts.first(unuseds).name))
62530                         : ts.createDiagnosticForNode(importDecl, ts.Diagnostics.All_imports_in_import_declaration_are_unused));
62531                 }
62532                 else {
62533                     for (var _i = 0, unuseds_1 = unuseds; _i < unuseds_1.length; _i++) {
62534                         var unused = unuseds_1[_i];
62535                         errorUnusedLocal(unused, ts.idText(unused.name), addDiagnostic);
62536                     }
62537                 }
62538             });
62539             unusedDestructures.forEach(function (_a) {
62540                 var bindingPattern = _a[0], bindingElements = _a[1];
62541                 var kind = tryGetRootParameterDeclaration(bindingPattern.parent) ? 1 : 0;
62542                 if (bindingPattern.elements.length === bindingElements.length) {
62543                     if (bindingElements.length === 1 && bindingPattern.parent.kind === 249 && bindingPattern.parent.parent.kind === 250) {
62544                         addToGroup(unusedVariables, bindingPattern.parent.parent, bindingPattern.parent, getNodeId);
62545                     }
62546                     else {
62547                         addDiagnostic(bindingPattern, kind, bindingElements.length === 1
62548                             ? ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(bindingElements).name))
62549                             : ts.createDiagnosticForNode(bindingPattern, ts.Diagnostics.All_destructured_elements_are_unused));
62550                     }
62551                 }
62552                 else {
62553                     for (var _i = 0, bindingElements_1 = bindingElements; _i < bindingElements_1.length; _i++) {
62554                         var e = bindingElements_1[_i];
62555                         addDiagnostic(e, kind, ts.createDiagnosticForNode(e, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(e.name)));
62556                     }
62557                 }
62558             });
62559             unusedVariables.forEach(function (_a) {
62560                 var declarationList = _a[0], declarations = _a[1];
62561                 if (declarationList.declarations.length === declarations.length) {
62562                     addDiagnostic(declarationList, 0, declarations.length === 1
62563                         ? ts.createDiagnosticForNode(ts.first(declarations).name, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(ts.first(declarations).name))
62564                         : ts.createDiagnosticForNode(declarationList.parent.kind === 232 ? declarationList.parent : declarationList, ts.Diagnostics.All_variables_are_unused));
62565                 }
62566                 else {
62567                     for (var _i = 0, declarations_5 = declarations; _i < declarations_5.length; _i++) {
62568                         var decl = declarations_5[_i];
62569                         addDiagnostic(decl, 0, ts.createDiagnosticForNode(decl, ts.Diagnostics._0_is_declared_but_its_value_is_never_read, bindingNameText(decl.name)));
62570                     }
62571                 }
62572             });
62573         }
62574         function bindingNameText(name) {
62575             switch (name.kind) {
62576                 case 78:
62577                     return ts.idText(name);
62578                 case 197:
62579                 case 196:
62580                     return bindingNameText(ts.cast(ts.first(name.elements), ts.isBindingElement).name);
62581                 default:
62582                     return ts.Debug.assertNever(name);
62583             }
62584         }
62585         function isImportedDeclaration(node) {
62586             return node.kind === 262 || node.kind === 265 || node.kind === 263;
62587         }
62588         function importClauseFromImported(decl) {
62589             return decl.kind === 262 ? decl : decl.kind === 263 ? decl.parent : decl.parent.parent;
62590         }
62591         function checkBlock(node) {
62592             if (node.kind === 230) {
62593                 checkGrammarStatementInAmbientContext(node);
62594             }
62595             if (ts.isFunctionOrModuleBlock(node)) {
62596                 var saveFlowAnalysisDisabled = flowAnalysisDisabled;
62597                 ts.forEach(node.statements, checkSourceElement);
62598                 flowAnalysisDisabled = saveFlowAnalysisDisabled;
62599             }
62600             else {
62601                 ts.forEach(node.statements, checkSourceElement);
62602             }
62603             if (node.locals) {
62604                 registerForUnusedIdentifiersCheck(node);
62605             }
62606         }
62607         function checkCollisionWithArgumentsInGeneratedCode(node) {
62608             if (languageVersion >= 2 || !ts.hasRestParameter(node) || node.flags & 8388608 || ts.nodeIsMissing(node.body)) {
62609                 return;
62610             }
62611             ts.forEach(node.parameters, function (p) {
62612                 if (p.name && !ts.isBindingPattern(p.name) && p.name.escapedText === argumentsSymbol.escapedName) {
62613                     errorSkippedOn("noEmit", p, ts.Diagnostics.Duplicate_identifier_arguments_Compiler_uses_arguments_to_initialize_rest_parameters);
62614                 }
62615             });
62616         }
62617         function needCollisionCheckForIdentifier(node, identifier, name) {
62618             if (!(identifier && identifier.escapedText === name)) {
62619                 return false;
62620             }
62621             if (node.kind === 163 ||
62622                 node.kind === 162 ||
62623                 node.kind === 165 ||
62624                 node.kind === 164 ||
62625                 node.kind === 167 ||
62626                 node.kind === 168) {
62627                 return false;
62628             }
62629             if (node.flags & 8388608) {
62630                 return false;
62631             }
62632             var root = ts.getRootDeclaration(node);
62633             if (root.kind === 160 && ts.nodeIsMissing(root.parent.body)) {
62634                 return false;
62635             }
62636             return true;
62637         }
62638         function checkIfThisIsCapturedInEnclosingScope(node) {
62639             ts.findAncestor(node, function (current) {
62640                 if (getNodeCheckFlags(current) & 4) {
62641                     var isDeclaration_1 = node.kind !== 78;
62642                     if (isDeclaration_1) {
62643                         error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference);
62644                     }
62645                     else {
62646                         error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference);
62647                     }
62648                     return true;
62649                 }
62650                 return false;
62651             });
62652         }
62653         function checkIfNewTargetIsCapturedInEnclosingScope(node) {
62654             ts.findAncestor(node, function (current) {
62655                 if (getNodeCheckFlags(current) & 8) {
62656                     var isDeclaration_2 = node.kind !== 78;
62657                     if (isDeclaration_2) {
62658                         error(ts.getNameOfDeclaration(node), ts.Diagnostics.Duplicate_identifier_newTarget_Compiler_uses_variable_declaration_newTarget_to_capture_new_target_meta_property_reference);
62659                     }
62660                     else {
62661                         error(node, ts.Diagnostics.Expression_resolves_to_variable_declaration_newTarget_that_compiler_uses_to_capture_new_target_meta_property_reference);
62662                     }
62663                     return true;
62664                 }
62665                 return false;
62666             });
62667         }
62668         function checkWeakMapCollision(node) {
62669             var enclosingBlockScope = ts.getEnclosingBlockScopeContainer(node);
62670             if (getNodeCheckFlags(enclosingBlockScope) & 67108864) {
62671                 errorSkippedOn("noEmit", node, ts.Diagnostics.Compiler_reserves_name_0_when_emitting_private_identifier_downlevel, "WeakMap");
62672             }
62673         }
62674         function checkCollisionWithRequireExportsInGeneratedCode(node, name) {
62675             if (moduleKind >= ts.ModuleKind.ES2015) {
62676                 return;
62677             }
62678             if (!needCollisionCheckForIdentifier(node, name, "require") && !needCollisionCheckForIdentifier(node, name, "exports")) {
62679                 return;
62680             }
62681             if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1) {
62682                 return;
62683             }
62684             var parent = getDeclarationContainer(node);
62685             if (parent.kind === 297 && ts.isExternalOrCommonJsModule(parent)) {
62686                 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));
62687             }
62688         }
62689         function checkCollisionWithGlobalPromiseInGeneratedCode(node, name) {
62690             if (languageVersion >= 4 || !needCollisionCheckForIdentifier(node, name, "Promise")) {
62691                 return;
62692             }
62693             if (ts.isModuleDeclaration(node) && ts.getModuleInstanceState(node) !== 1) {
62694                 return;
62695             }
62696             var parent = getDeclarationContainer(node);
62697             if (parent.kind === 297 && ts.isExternalOrCommonJsModule(parent) && parent.flags & 2048) {
62698                 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));
62699             }
62700         }
62701         function checkVarDeclaredNamesNotShadowed(node) {
62702             if ((ts.getCombinedNodeFlags(node) & 3) !== 0 || ts.isParameterDeclaration(node)) {
62703                 return;
62704             }
62705             if (node.kind === 249 && !node.initializer) {
62706                 return;
62707             }
62708             var symbol = getSymbolOfNode(node);
62709             if (symbol.flags & 1) {
62710                 if (!ts.isIdentifier(node.name))
62711                     return ts.Debug.fail();
62712                 var localDeclarationSymbol = resolveName(node, node.name.escapedText, 3, undefined, undefined, false);
62713                 if (localDeclarationSymbol &&
62714                     localDeclarationSymbol !== symbol &&
62715                     localDeclarationSymbol.flags & 2) {
62716                     if (getDeclarationNodeFlagsFromSymbol(localDeclarationSymbol) & 3) {
62717                         var varDeclList = ts.getAncestor(localDeclarationSymbol.valueDeclaration, 250);
62718                         var container = varDeclList.parent.kind === 232 && varDeclList.parent.parent
62719                             ? varDeclList.parent.parent
62720                             : undefined;
62721                         var namesShareScope = container &&
62722                             (container.kind === 230 && ts.isFunctionLike(container.parent) ||
62723                                 container.kind === 257 ||
62724                                 container.kind === 256 ||
62725                                 container.kind === 297);
62726                         if (!namesShareScope) {
62727                             var name = symbolToString(localDeclarationSymbol);
62728                             error(node, ts.Diagnostics.Cannot_initialize_outer_scoped_variable_0_in_the_same_scope_as_block_scoped_declaration_1, name, name);
62729                         }
62730                     }
62731                 }
62732             }
62733         }
62734         function convertAutoToAny(type) {
62735             return type === autoType ? anyType : type === autoArrayType ? anyArrayType : type;
62736         }
62737         function checkVariableLikeDeclaration(node) {
62738             var _a;
62739             checkDecorators(node);
62740             if (!ts.isBindingElement(node)) {
62741                 checkSourceElement(node.type);
62742             }
62743             if (!node.name) {
62744                 return;
62745             }
62746             if (node.name.kind === 158) {
62747                 checkComputedPropertyName(node.name);
62748                 if (node.initializer) {
62749                     checkExpressionCached(node.initializer);
62750                 }
62751             }
62752             if (node.kind === 198) {
62753                 if (node.parent.kind === 196 && languageVersion < 99) {
62754                     checkExternalEmitHelpers(node, 4);
62755                 }
62756                 if (node.propertyName && node.propertyName.kind === 158) {
62757                     checkComputedPropertyName(node.propertyName);
62758                 }
62759                 var parent = node.parent.parent;
62760                 var parentType = getTypeForBindingElementParent(parent);
62761                 var name = node.propertyName || node.name;
62762                 if (parentType && !ts.isBindingPattern(name)) {
62763                     var exprType = getLiteralTypeFromPropertyName(name);
62764                     if (isTypeUsableAsPropertyName(exprType)) {
62765                         var nameText = getPropertyNameFromType(exprType);
62766                         var property = getPropertyOfType(parentType, nameText);
62767                         if (property) {
62768                             markPropertyAsReferenced(property, undefined, false);
62769                             checkPropertyAccessibility(parent, !!parent.initializer && parent.initializer.kind === 105, parentType, property);
62770                         }
62771                     }
62772                 }
62773             }
62774             if (ts.isBindingPattern(node.name)) {
62775                 if (node.name.kind === 197 && languageVersion < 2 && compilerOptions.downlevelIteration) {
62776                     checkExternalEmitHelpers(node, 512);
62777                 }
62778                 ts.forEach(node.name.elements, checkSourceElement);
62779             }
62780             if (node.initializer && ts.isParameterDeclaration(node) && ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
62781                 error(node, ts.Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation);
62782                 return;
62783             }
62784             if (ts.isBindingPattern(node.name)) {
62785                 var needCheckInitializer = node.initializer && node.parent.parent.kind !== 238;
62786                 var needCheckWidenedType = node.name.elements.length === 0;
62787                 if (needCheckInitializer || needCheckWidenedType) {
62788                     var widenedType = getWidenedTypeForVariableLikeDeclaration(node);
62789                     if (needCheckInitializer) {
62790                         var initializerType = checkExpressionCached(node.initializer);
62791                         if (strictNullChecks && needCheckWidenedType) {
62792                             checkNonNullNonVoidType(initializerType, node);
62793                         }
62794                         else {
62795                             checkTypeAssignableToAndOptionallyElaborate(initializerType, getWidenedTypeForVariableLikeDeclaration(node), node, node.initializer);
62796                         }
62797                     }
62798                     if (needCheckWidenedType) {
62799                         if (ts.isArrayBindingPattern(node.name)) {
62800                             checkIteratedTypeOrElementType(65, widenedType, undefinedType, node);
62801                         }
62802                         else if (strictNullChecks) {
62803                             checkNonNullNonVoidType(widenedType, node);
62804                         }
62805                     }
62806                 }
62807                 return;
62808             }
62809             var symbol = getSymbolOfNode(node);
62810             if (symbol.flags & 2097152 && ts.isRequireVariableDeclaration(node, true)) {
62811                 checkAliasSymbol(node);
62812                 return;
62813             }
62814             var type = convertAutoToAny(getTypeOfSymbol(symbol));
62815             if (node === symbol.valueDeclaration) {
62816                 var initializer = ts.getEffectiveInitializer(node);
62817                 if (initializer) {
62818                     var isJSObjectLiteralInitializer = ts.isInJSFile(node) &&
62819                         ts.isObjectLiteralExpression(initializer) &&
62820                         (initializer.properties.length === 0 || ts.isPrototypeAccess(node.name)) &&
62821                         !!((_a = symbol.exports) === null || _a === void 0 ? void 0 : _a.size);
62822                     if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== 238) {
62823                         checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, undefined);
62824                     }
62825                 }
62826                 if (symbol.declarations.length > 1) {
62827                     if (ts.some(symbol.declarations, function (d) { return d !== node && ts.isVariableLike(d) && !areDeclarationFlagsIdentical(d, node); })) {
62828                         error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name));
62829                     }
62830                 }
62831             }
62832             else {
62833                 var declarationType = convertAutoToAny(getWidenedTypeForVariableLikeDeclaration(node));
62834                 if (type !== errorType && declarationType !== errorType &&
62835                     !isTypeIdenticalTo(type, declarationType) &&
62836                     !(symbol.flags & 67108864)) {
62837                     errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType);
62838                 }
62839                 if (node.initializer) {
62840                     checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, undefined);
62841                 }
62842                 if (!areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) {
62843                     error(node.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_modifiers, ts.declarationNameToString(node.name));
62844                 }
62845             }
62846             if (node.kind !== 163 && node.kind !== 162) {
62847                 checkExportsOnMergedDeclarations(node);
62848                 if (node.kind === 249 || node.kind === 198) {
62849                     checkVarDeclaredNamesNotShadowed(node);
62850                 }
62851                 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
62852                 checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
62853                 if (languageVersion < 99 && needCollisionCheckForIdentifier(node, node.name, "WeakMap")) {
62854                     potentialWeakMapCollisions.push(node);
62855                 }
62856             }
62857         }
62858         function errorNextVariableOrPropertyDeclarationMustHaveSameType(firstDeclaration, firstType, nextDeclaration, nextType) {
62859             var nextDeclarationName = ts.getNameOfDeclaration(nextDeclaration);
62860             var message = nextDeclaration.kind === 163 || nextDeclaration.kind === 162
62861                 ? ts.Diagnostics.Subsequent_property_declarations_must_have_the_same_type_Property_0_must_be_of_type_1_but_here_has_type_2
62862                 : ts.Diagnostics.Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2;
62863             var declName = ts.declarationNameToString(nextDeclarationName);
62864             var err = error(nextDeclarationName, message, declName, typeToString(firstType), typeToString(nextType));
62865             if (firstDeclaration) {
62866                 ts.addRelatedInfo(err, ts.createDiagnosticForNode(firstDeclaration, ts.Diagnostics._0_was_also_declared_here, declName));
62867             }
62868         }
62869         function areDeclarationFlagsIdentical(left, right) {
62870             if ((left.kind === 160 && right.kind === 249) ||
62871                 (left.kind === 249 && right.kind === 160)) {
62872                 return true;
62873             }
62874             if (ts.hasQuestionToken(left) !== ts.hasQuestionToken(right)) {
62875                 return false;
62876             }
62877             var interestingFlags = 8 |
62878                 16 |
62879                 256 |
62880                 128 |
62881                 64 |
62882                 32;
62883             return ts.getSelectedEffectiveModifierFlags(left, interestingFlags) === ts.getSelectedEffectiveModifierFlags(right, interestingFlags);
62884         }
62885         function checkVariableDeclaration(node) {
62886             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check", "checkVariableDeclaration", { kind: node.kind, pos: node.pos, end: node.end });
62887             checkGrammarVariableDeclaration(node);
62888             checkVariableLikeDeclaration(node);
62889             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
62890         }
62891         function checkBindingElement(node) {
62892             checkGrammarBindingElement(node);
62893             return checkVariableLikeDeclaration(node);
62894         }
62895         function checkVariableStatement(node) {
62896             if (!checkGrammarDecoratorsAndModifiers(node) && !checkGrammarVariableDeclarationList(node.declarationList))
62897                 checkGrammarForDisallowedLetOrConstStatement(node);
62898             ts.forEach(node.declarationList.declarations, checkSourceElement);
62899         }
62900         function checkExpressionStatement(node) {
62901             checkGrammarStatementInAmbientContext(node);
62902             checkExpression(node.expression);
62903         }
62904         function checkIfStatement(node) {
62905             checkGrammarStatementInAmbientContext(node);
62906             var type = checkTruthinessExpression(node.expression);
62907             checkTestingKnownTruthyCallableType(node.expression, type, node.thenStatement);
62908             checkSourceElement(node.thenStatement);
62909             if (node.thenStatement.kind === 231) {
62910                 error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement);
62911             }
62912             checkSourceElement(node.elseStatement);
62913         }
62914         function checkTestingKnownTruthyCallableType(condExpr, type, body) {
62915             if (!strictNullChecks) {
62916                 return;
62917             }
62918             var location = ts.isBinaryExpression(condExpr) ? condExpr.right : condExpr;
62919             var testedNode = ts.isIdentifier(location) ? location
62920                 : ts.isPropertyAccessExpression(location) ? location.name
62921                     : ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right
62922                         : undefined;
62923             var isPropertyExpressionCast = ts.isPropertyAccessExpression(location)
62924                 && ts.isAssertionExpression(ts.skipParentheses(location.expression));
62925             if (!testedNode || isPropertyExpressionCast) {
62926                 return;
62927             }
62928             var possiblyFalsy = getFalsyFlags(type);
62929             if (possiblyFalsy) {
62930                 return;
62931             }
62932             var callSignatures = getSignaturesOfType(type, 0);
62933             if (callSignatures.length === 0) {
62934                 return;
62935             }
62936             var testedSymbol = getSymbolAtLocation(testedNode);
62937             if (!testedSymbol) {
62938                 return;
62939             }
62940             var isUsed = ts.isBinaryExpression(condExpr.parent) && isFunctionUsedInBinaryExpressionChain(condExpr.parent, testedSymbol)
62941                 || body && isFunctionUsedInConditionBody(condExpr, body, testedNode, testedSymbol);
62942             if (!isUsed) {
62943                 error(location, ts.Diagnostics.This_condition_will_always_return_true_since_the_function_is_always_defined_Did_you_mean_to_call_it_instead);
62944             }
62945         }
62946         function isFunctionUsedInConditionBody(expr, body, testedNode, testedSymbol) {
62947             return !!ts.forEachChild(body, function check(childNode) {
62948                 if (ts.isIdentifier(childNode)) {
62949                     var childSymbol = getSymbolAtLocation(childNode);
62950                     if (childSymbol && childSymbol === testedSymbol) {
62951                         if (ts.isIdentifier(expr)) {
62952                             return true;
62953                         }
62954                         var testedExpression = testedNode.parent;
62955                         var childExpression = childNode.parent;
62956                         while (testedExpression && childExpression) {
62957                             if (ts.isIdentifier(testedExpression) && ts.isIdentifier(childExpression) ||
62958                                 testedExpression.kind === 107 && childExpression.kind === 107) {
62959                                 return getSymbolAtLocation(testedExpression) === getSymbolAtLocation(childExpression);
62960                             }
62961                             else if (ts.isPropertyAccessExpression(testedExpression) && ts.isPropertyAccessExpression(childExpression)) {
62962                                 if (getSymbolAtLocation(testedExpression.name) !== getSymbolAtLocation(childExpression.name)) {
62963                                     return false;
62964                                 }
62965                                 childExpression = childExpression.expression;
62966                                 testedExpression = testedExpression.expression;
62967                             }
62968                             else if (ts.isCallExpression(testedExpression) && ts.isCallExpression(childExpression)) {
62969                                 childExpression = childExpression.expression;
62970                                 testedExpression = testedExpression.expression;
62971                             }
62972                             else {
62973                                 return false;
62974                             }
62975                         }
62976                     }
62977                 }
62978                 return ts.forEachChild(childNode, check);
62979             });
62980         }
62981         function isFunctionUsedInBinaryExpressionChain(node, testedSymbol) {
62982             while (ts.isBinaryExpression(node) && node.operatorToken.kind === 55) {
62983                 var isUsed = ts.forEachChild(node.right, function visit(child) {
62984                     if (ts.isIdentifier(child)) {
62985                         var symbol = getSymbolAtLocation(child);
62986                         if (symbol && symbol === testedSymbol) {
62987                             return true;
62988                         }
62989                     }
62990                     return ts.forEachChild(child, visit);
62991                 });
62992                 if (isUsed) {
62993                     return true;
62994                 }
62995                 node = node.parent;
62996             }
62997             return false;
62998         }
62999         function checkDoStatement(node) {
63000             checkGrammarStatementInAmbientContext(node);
63001             checkSourceElement(node.statement);
63002             checkTruthinessExpression(node.expression);
63003         }
63004         function checkWhileStatement(node) {
63005             checkGrammarStatementInAmbientContext(node);
63006             checkTruthinessExpression(node.expression);
63007             checkSourceElement(node.statement);
63008         }
63009         function checkTruthinessOfType(type, node) {
63010             if (type.flags & 16384) {
63011                 error(node, ts.Diagnostics.An_expression_of_type_void_cannot_be_tested_for_truthiness);
63012             }
63013             return type;
63014         }
63015         function checkTruthinessExpression(node, checkMode) {
63016             return checkTruthinessOfType(checkExpression(node, checkMode), node);
63017         }
63018         function checkForStatement(node) {
63019             if (!checkGrammarStatementInAmbientContext(node)) {
63020                 if (node.initializer && node.initializer.kind === 250) {
63021                     checkGrammarVariableDeclarationList(node.initializer);
63022                 }
63023             }
63024             if (node.initializer) {
63025                 if (node.initializer.kind === 250) {
63026                     ts.forEach(node.initializer.declarations, checkVariableDeclaration);
63027                 }
63028                 else {
63029                     checkExpression(node.initializer);
63030                 }
63031             }
63032             if (node.condition)
63033                 checkTruthinessExpression(node.condition);
63034             if (node.incrementor)
63035                 checkExpression(node.incrementor);
63036             checkSourceElement(node.statement);
63037             if (node.locals) {
63038                 registerForUnusedIdentifiersCheck(node);
63039             }
63040         }
63041         function checkForOfStatement(node) {
63042             checkGrammarForInOrForOfStatement(node);
63043             if (node.awaitModifier) {
63044                 var functionFlags = ts.getFunctionFlags(ts.getContainingFunction(node));
63045                 if ((functionFlags & (4 | 2)) === 2 && languageVersion < 99) {
63046                     checkExternalEmitHelpers(node, 16384);
63047                 }
63048             }
63049             else if (compilerOptions.downlevelIteration && languageVersion < 2) {
63050                 checkExternalEmitHelpers(node, 256);
63051             }
63052             if (node.initializer.kind === 250) {
63053                 checkForInOrForOfVariableDeclaration(node);
63054             }
63055             else {
63056                 var varExpr = node.initializer;
63057                 var iteratedType = checkRightHandSideOfForOf(node);
63058                 if (varExpr.kind === 199 || varExpr.kind === 200) {
63059                     checkDestructuringAssignment(varExpr, iteratedType || errorType);
63060                 }
63061                 else {
63062                     var leftType = checkExpression(varExpr);
63063                     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);
63064                     if (iteratedType) {
63065                         checkTypeAssignableToAndOptionallyElaborate(iteratedType, leftType, varExpr, node.expression);
63066                     }
63067                 }
63068             }
63069             checkSourceElement(node.statement);
63070             if (node.locals) {
63071                 registerForUnusedIdentifiersCheck(node);
63072             }
63073         }
63074         function checkForInStatement(node) {
63075             checkGrammarForInOrForOfStatement(node);
63076             var rightType = getNonNullableTypeIfNeeded(checkExpression(node.expression));
63077             if (node.initializer.kind === 250) {
63078                 var variable = node.initializer.declarations[0];
63079                 if (variable && ts.isBindingPattern(variable.name)) {
63080                     error(variable.name, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern);
63081                 }
63082                 checkForInOrForOfVariableDeclaration(node);
63083             }
63084             else {
63085                 var varExpr = node.initializer;
63086                 var leftType = checkExpression(varExpr);
63087                 if (varExpr.kind === 199 || varExpr.kind === 200) {
63088                     error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern);
63089                 }
63090                 else if (!isTypeAssignableTo(getIndexTypeOrString(rightType), leftType)) {
63091                     error(varExpr, ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_must_be_of_type_string_or_any);
63092                 }
63093                 else {
63094                     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);
63095                 }
63096             }
63097             if (rightType === neverType || !isTypeAssignableToKind(rightType, 67108864 | 58982400)) {
63098                 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));
63099             }
63100             checkSourceElement(node.statement);
63101             if (node.locals) {
63102                 registerForUnusedIdentifiersCheck(node);
63103             }
63104         }
63105         function checkForInOrForOfVariableDeclaration(iterationStatement) {
63106             var variableDeclarationList = iterationStatement.initializer;
63107             if (variableDeclarationList.declarations.length >= 1) {
63108                 var decl = variableDeclarationList.declarations[0];
63109                 checkVariableDeclaration(decl);
63110             }
63111         }
63112         function checkRightHandSideOfForOf(statement) {
63113             var use = statement.awaitModifier ? 15 : 13;
63114             return checkIteratedTypeOrElementType(use, checkNonNullExpression(statement.expression), undefinedType, statement.expression);
63115         }
63116         function checkIteratedTypeOrElementType(use, inputType, sentType, errorNode) {
63117             if (isTypeAny(inputType)) {
63118                 return inputType;
63119             }
63120             return getIteratedTypeOrElementType(use, inputType, sentType, errorNode, true) || anyType;
63121         }
63122         function getIteratedTypeOrElementType(use, inputType, sentType, errorNode, checkAssignability) {
63123             var allowAsyncIterables = (use & 2) !== 0;
63124             if (inputType === neverType) {
63125                 reportTypeNotIterableError(errorNode, inputType, allowAsyncIterables);
63126                 return undefined;
63127             }
63128             var uplevelIteration = languageVersion >= 2;
63129             var downlevelIteration = !uplevelIteration && compilerOptions.downlevelIteration;
63130             var possibleOutOfBounds = compilerOptions.noUncheckedIndexedAccess && !!(use & 128);
63131             if (uplevelIteration || downlevelIteration || allowAsyncIterables) {
63132                 var iterationTypes = getIterationTypesOfIterable(inputType, use, uplevelIteration ? errorNode : undefined);
63133                 if (checkAssignability) {
63134                     if (iterationTypes) {
63135                         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 :
63136                             use & 32 ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_spread_will_always_send_0 :
63137                                 use & 64 ? ts.Diagnostics.Cannot_iterate_value_because_the_next_method_of_its_iterator_expects_type_1_but_array_destructuring_will_always_send_0 :
63138                                     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 :
63139                                         undefined;
63140                         if (diagnostic) {
63141                             checkTypeAssignableTo(sentType, iterationTypes.nextType, errorNode, diagnostic);
63142                         }
63143                     }
63144                 }
63145                 if (iterationTypes || uplevelIteration) {
63146                     return possibleOutOfBounds ? includeUndefinedInIndexSignature(iterationTypes && iterationTypes.yieldType) : (iterationTypes && iterationTypes.yieldType);
63147                 }
63148             }
63149             var arrayType = inputType;
63150             var reportedError = false;
63151             var hasStringConstituent = false;
63152             if (use & 4) {
63153                 if (arrayType.flags & 1048576) {
63154                     var arrayTypes = inputType.types;
63155                     var filteredTypes = ts.filter(arrayTypes, function (t) { return !(t.flags & 402653316); });
63156                     if (filteredTypes !== arrayTypes) {
63157                         arrayType = getUnionType(filteredTypes, 2);
63158                     }
63159                 }
63160                 else if (arrayType.flags & 402653316) {
63161                     arrayType = neverType;
63162                 }
63163                 hasStringConstituent = arrayType !== inputType;
63164                 if (hasStringConstituent) {
63165                     if (languageVersion < 1) {
63166                         if (errorNode) {
63167                             error(errorNode, ts.Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher);
63168                             reportedError = true;
63169                         }
63170                     }
63171                     if (arrayType.flags & 131072) {
63172                         return possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType;
63173                     }
63174                 }
63175             }
63176             if (!isArrayLikeType(arrayType)) {
63177                 if (errorNode && !reportedError) {
63178                     var yieldType = getIterationTypeOfIterable(use, 0, inputType, undefined);
63179                     var _a = !(use & 4) || hasStringConstituent
63180                         ? downlevelIteration
63181                             ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_does_not_have_a_Symbol_iterator_method_that_returns_an_iterator, true]
63182                             : yieldType
63183                                 ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]
63184                                 : [ts.Diagnostics.Type_0_is_not_an_array_type, true]
63185                         : downlevelIteration
63186                             ? [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]
63187                             : yieldType
63188                                 ? [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type_Use_compiler_option_downlevelIteration_to_allow_iterating_of_iterators, false]
63189                                 : [ts.Diagnostics.Type_0_is_not_an_array_type_or_a_string_type, true], defaultDiagnostic = _a[0], maybeMissingAwait = _a[1];
63190                     errorAndMaybeSuggestAwait(errorNode, maybeMissingAwait && !!getAwaitedTypeOfPromise(arrayType), defaultDiagnostic, typeToString(arrayType));
63191                 }
63192                 return hasStringConstituent ? possibleOutOfBounds ? includeUndefinedInIndexSignature(stringType) : stringType : undefined;
63193             }
63194             var arrayElementType = getIndexTypeOfType(arrayType, 1);
63195             if (hasStringConstituent && arrayElementType) {
63196                 if (arrayElementType.flags & 402653316 && !compilerOptions.noUncheckedIndexedAccess) {
63197                     return stringType;
63198                 }
63199                 return getUnionType(possibleOutOfBounds ? [arrayElementType, stringType, undefinedType] : [arrayElementType, stringType], 2);
63200             }
63201             return (use & 128) ? includeUndefinedInIndexSignature(arrayElementType) : arrayElementType;
63202         }
63203         function getIterationTypeOfIterable(use, typeKind, inputType, errorNode) {
63204             if (isTypeAny(inputType)) {
63205                 return undefined;
63206             }
63207             var iterationTypes = getIterationTypesOfIterable(inputType, use, errorNode);
63208             return iterationTypes && iterationTypes[getIterationTypesKeyFromIterationTypeKind(typeKind)];
63209         }
63210         function createIterationTypes(yieldType, returnType, nextType) {
63211             if (yieldType === void 0) { yieldType = neverType; }
63212             if (returnType === void 0) { returnType = neverType; }
63213             if (nextType === void 0) { nextType = unknownType; }
63214             if (yieldType.flags & 67359327 &&
63215                 returnType.flags & (1 | 131072 | 2 | 16384 | 32768) &&
63216                 nextType.flags & (1 | 131072 | 2 | 16384 | 32768)) {
63217                 var id = getTypeListId([yieldType, returnType, nextType]);
63218                 var iterationTypes = iterationTypesCache.get(id);
63219                 if (!iterationTypes) {
63220                     iterationTypes = { yieldType: yieldType, returnType: returnType, nextType: nextType };
63221                     iterationTypesCache.set(id, iterationTypes);
63222                 }
63223                 return iterationTypes;
63224             }
63225             return { yieldType: yieldType, returnType: returnType, nextType: nextType };
63226         }
63227         function combineIterationTypes(array) {
63228             var yieldTypes;
63229             var returnTypes;
63230             var nextTypes;
63231             for (var _i = 0, array_10 = array; _i < array_10.length; _i++) {
63232                 var iterationTypes = array_10[_i];
63233                 if (iterationTypes === undefined || iterationTypes === noIterationTypes) {
63234                     continue;
63235                 }
63236                 if (iterationTypes === anyIterationTypes) {
63237                     return anyIterationTypes;
63238                 }
63239                 yieldTypes = ts.append(yieldTypes, iterationTypes.yieldType);
63240                 returnTypes = ts.append(returnTypes, iterationTypes.returnType);
63241                 nextTypes = ts.append(nextTypes, iterationTypes.nextType);
63242             }
63243             if (yieldTypes || returnTypes || nextTypes) {
63244                 return createIterationTypes(yieldTypes && getUnionType(yieldTypes), returnTypes && getUnionType(returnTypes), nextTypes && getIntersectionType(nextTypes));
63245             }
63246             return noIterationTypes;
63247         }
63248         function getCachedIterationTypes(type, cacheKey) {
63249             return type[cacheKey];
63250         }
63251         function setCachedIterationTypes(type, cacheKey, cachedTypes) {
63252             return type[cacheKey] = cachedTypes;
63253         }
63254         function getIterationTypesOfIterable(type, use, errorNode) {
63255             if (isTypeAny(type)) {
63256                 return anyIterationTypes;
63257             }
63258             if (!(type.flags & 1048576)) {
63259                 var iterationTypes_1 = getIterationTypesOfIterableWorker(type, use, errorNode);
63260                 if (iterationTypes_1 === noIterationTypes) {
63261                     if (errorNode) {
63262                         reportTypeNotIterableError(errorNode, type, !!(use & 2));
63263                     }
63264                     return undefined;
63265                 }
63266                 return iterationTypes_1;
63267             }
63268             var cacheKey = use & 2 ? "iterationTypesOfAsyncIterable" : "iterationTypesOfIterable";
63269             var cachedTypes = getCachedIterationTypes(type, cacheKey);
63270             if (cachedTypes)
63271                 return cachedTypes === noIterationTypes ? undefined : cachedTypes;
63272             var allIterationTypes;
63273             for (var _i = 0, _a = type.types; _i < _a.length; _i++) {
63274                 var constituent = _a[_i];
63275                 var iterationTypes_2 = getIterationTypesOfIterableWorker(constituent, use, errorNode);
63276                 if (iterationTypes_2 === noIterationTypes) {
63277                     if (errorNode) {
63278                         reportTypeNotIterableError(errorNode, type, !!(use & 2));
63279                     }
63280                     setCachedIterationTypes(type, cacheKey, noIterationTypes);
63281                     return undefined;
63282                 }
63283                 else {
63284                     allIterationTypes = ts.append(allIterationTypes, iterationTypes_2);
63285                 }
63286             }
63287             var iterationTypes = allIterationTypes ? combineIterationTypes(allIterationTypes) : noIterationTypes;
63288             setCachedIterationTypes(type, cacheKey, iterationTypes);
63289             return iterationTypes === noIterationTypes ? undefined : iterationTypes;
63290         }
63291         function getAsyncFromSyncIterationTypes(iterationTypes, errorNode) {
63292             if (iterationTypes === noIterationTypes)
63293                 return noIterationTypes;
63294             if (iterationTypes === anyIterationTypes)
63295                 return anyIterationTypes;
63296             var yieldType = iterationTypes.yieldType, returnType = iterationTypes.returnType, nextType = iterationTypes.nextType;
63297             return createIterationTypes(getAwaitedType(yieldType, errorNode) || anyType, getAwaitedType(returnType, errorNode) || anyType, nextType);
63298         }
63299         function getIterationTypesOfIterableWorker(type, use, errorNode) {
63300             if (isTypeAny(type)) {
63301                 return anyIterationTypes;
63302             }
63303             if (use & 2) {
63304                 var iterationTypes = getIterationTypesOfIterableCached(type, asyncIterationTypesResolver) ||
63305                     getIterationTypesOfIterableFast(type, asyncIterationTypesResolver);
63306                 if (iterationTypes) {
63307                     return iterationTypes;
63308                 }
63309             }
63310             if (use & 1) {
63311                 var iterationTypes = getIterationTypesOfIterableCached(type, syncIterationTypesResolver) ||
63312                     getIterationTypesOfIterableFast(type, syncIterationTypesResolver);
63313                 if (iterationTypes) {
63314                     if (use & 2) {
63315                         if (iterationTypes !== noIterationTypes) {
63316                             return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", getAsyncFromSyncIterationTypes(iterationTypes, errorNode));
63317                         }
63318                     }
63319                     else {
63320                         return iterationTypes;
63321                     }
63322                 }
63323             }
63324             if (use & 2) {
63325                 var iterationTypes = getIterationTypesOfIterableSlow(type, asyncIterationTypesResolver, errorNode);
63326                 if (iterationTypes !== noIterationTypes) {
63327                     return iterationTypes;
63328                 }
63329             }
63330             if (use & 1) {
63331                 var iterationTypes = getIterationTypesOfIterableSlow(type, syncIterationTypesResolver, errorNode);
63332                 if (iterationTypes !== noIterationTypes) {
63333                     if (use & 2) {
63334                         return setCachedIterationTypes(type, "iterationTypesOfAsyncIterable", iterationTypes
63335                             ? getAsyncFromSyncIterationTypes(iterationTypes, errorNode)
63336                             : noIterationTypes);
63337                     }
63338                     else {
63339                         return iterationTypes;
63340                     }
63341                 }
63342             }
63343             return noIterationTypes;
63344         }
63345         function getIterationTypesOfIterableCached(type, resolver) {
63346             return getCachedIterationTypes(type, resolver.iterableCacheKey);
63347         }
63348         function getIterationTypesOfGlobalIterableType(globalType, resolver) {
63349             var globalIterationTypes = getIterationTypesOfIterableCached(globalType, resolver) ||
63350                 getIterationTypesOfIterableSlow(globalType, resolver, undefined);
63351             return globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes;
63352         }
63353         function getIterationTypesOfIterableFast(type, resolver) {
63354             var globalType;
63355             if (isReferenceToType(type, globalType = resolver.getGlobalIterableType(false)) ||
63356                 isReferenceToType(type, globalType = resolver.getGlobalIterableIteratorType(false))) {
63357                 var yieldType = getTypeArguments(type)[0];
63358                 var _a = getIterationTypesOfGlobalIterableType(globalType, resolver), returnType = _a.returnType, nextType = _a.nextType;
63359                 return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType));
63360             }
63361             if (isReferenceToType(type, resolver.getGlobalGeneratorType(false))) {
63362                 var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2];
63363                 return setCachedIterationTypes(type, resolver.iterableCacheKey, createIterationTypes(yieldType, returnType, nextType));
63364             }
63365         }
63366         function getIterationTypesOfIterableSlow(type, resolver, errorNode) {
63367             var _a;
63368             var method = getPropertyOfType(type, ts.getPropertyNameForKnownSymbolName(resolver.iteratorSymbolName));
63369             var methodType = method && !(method.flags & 16777216) ? getTypeOfSymbol(method) : undefined;
63370             if (isTypeAny(methodType)) {
63371                 return setCachedIterationTypes(type, resolver.iterableCacheKey, anyIterationTypes);
63372             }
63373             var signatures = methodType ? getSignaturesOfType(methodType, 0) : undefined;
63374             if (!ts.some(signatures)) {
63375                 return setCachedIterationTypes(type, resolver.iterableCacheKey, noIterationTypes);
63376             }
63377             var iteratorType = getIntersectionType(ts.map(signatures, getReturnTypeOfSignature));
63378             var iterationTypes = (_a = getIterationTypesOfIterator(iteratorType, resolver, errorNode)) !== null && _a !== void 0 ? _a : noIterationTypes;
63379             return setCachedIterationTypes(type, resolver.iterableCacheKey, iterationTypes);
63380         }
63381         function reportTypeNotIterableError(errorNode, type, allowAsyncIterables) {
63382             var message = allowAsyncIterables
63383                 ? ts.Diagnostics.Type_0_must_have_a_Symbol_asyncIterator_method_that_returns_an_async_iterator
63384                 : ts.Diagnostics.Type_0_must_have_a_Symbol_iterator_method_that_returns_an_iterator;
63385             errorAndMaybeSuggestAwait(errorNode, !!getAwaitedTypeOfPromise(type), message, typeToString(type));
63386         }
63387         function getIterationTypesOfIterator(type, resolver, errorNode) {
63388             if (isTypeAny(type)) {
63389                 return anyIterationTypes;
63390             }
63391             var iterationTypes = getIterationTypesOfIteratorCached(type, resolver) ||
63392                 getIterationTypesOfIteratorFast(type, resolver) ||
63393                 getIterationTypesOfIteratorSlow(type, resolver, errorNode);
63394             return iterationTypes === noIterationTypes ? undefined : iterationTypes;
63395         }
63396         function getIterationTypesOfIteratorCached(type, resolver) {
63397             return getCachedIterationTypes(type, resolver.iteratorCacheKey);
63398         }
63399         function getIterationTypesOfIteratorFast(type, resolver) {
63400             var globalType = resolver.getGlobalIterableIteratorType(false);
63401             if (isReferenceToType(type, globalType)) {
63402                 var yieldType = getTypeArguments(type)[0];
63403                 var globalIterationTypes = getIterationTypesOfIteratorCached(globalType, resolver) ||
63404                     getIterationTypesOfIteratorSlow(globalType, resolver, undefined);
63405                 var _a = globalIterationTypes === noIterationTypes ? defaultIterationTypes : globalIterationTypes, returnType = _a.returnType, nextType = _a.nextType;
63406                 return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
63407             }
63408             if (isReferenceToType(type, resolver.getGlobalIteratorType(false)) ||
63409                 isReferenceToType(type, resolver.getGlobalGeneratorType(false))) {
63410                 var _b = getTypeArguments(type), yieldType = _b[0], returnType = _b[1], nextType = _b[2];
63411                 return setCachedIterationTypes(type, resolver.iteratorCacheKey, createIterationTypes(yieldType, returnType, nextType));
63412             }
63413         }
63414         function isIteratorResult(type, kind) {
63415             var doneType = getTypeOfPropertyOfType(type, "done") || falseType;
63416             return isTypeAssignableTo(kind === 0 ? falseType : trueType, doneType);
63417         }
63418         function isYieldIteratorResult(type) {
63419             return isIteratorResult(type, 0);
63420         }
63421         function isReturnIteratorResult(type) {
63422             return isIteratorResult(type, 1);
63423         }
63424         function getIterationTypesOfIteratorResult(type) {
63425             if (isTypeAny(type)) {
63426                 return anyIterationTypes;
63427             }
63428             var cachedTypes = getCachedIterationTypes(type, "iterationTypesOfIteratorResult");
63429             if (cachedTypes) {
63430                 return cachedTypes;
63431             }
63432             if (isReferenceToType(type, getGlobalIteratorYieldResultType(false))) {
63433                 var yieldType_1 = getTypeArguments(type)[0];
63434                 return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(yieldType_1, undefined, undefined));
63435             }
63436             if (isReferenceToType(type, getGlobalIteratorReturnResultType(false))) {
63437                 var returnType_1 = getTypeArguments(type)[0];
63438                 return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(undefined, returnType_1, undefined));
63439             }
63440             var yieldIteratorResult = filterType(type, isYieldIteratorResult);
63441             var yieldType = yieldIteratorResult !== neverType ? getTypeOfPropertyOfType(yieldIteratorResult, "value") : undefined;
63442             var returnIteratorResult = filterType(type, isReturnIteratorResult);
63443             var returnType = returnIteratorResult !== neverType ? getTypeOfPropertyOfType(returnIteratorResult, "value") : undefined;
63444             if (!yieldType && !returnType) {
63445                 return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", noIterationTypes);
63446             }
63447             return setCachedIterationTypes(type, "iterationTypesOfIteratorResult", createIterationTypes(yieldType, returnType || voidType, undefined));
63448         }
63449         function getIterationTypesOfMethod(type, resolver, methodName, errorNode) {
63450             var _a, _b, _c, _d;
63451             var method = getPropertyOfType(type, methodName);
63452             if (!method && methodName !== "next") {
63453                 return undefined;
63454             }
63455             var methodType = method && !(methodName === "next" && (method.flags & 16777216))
63456                 ? methodName === "next" ? getTypeOfSymbol(method) : getTypeWithFacts(getTypeOfSymbol(method), 2097152)
63457                 : undefined;
63458             if (isTypeAny(methodType)) {
63459                 return methodName === "next" ? anyIterationTypes : anyIterationTypesExceptNext;
63460             }
63461             var methodSignatures = methodType ? getSignaturesOfType(methodType, 0) : ts.emptyArray;
63462             if (methodSignatures.length === 0) {
63463                 if (errorNode) {
63464                     var diagnostic = methodName === "next"
63465                         ? resolver.mustHaveANextMethodDiagnostic
63466                         : resolver.mustBeAMethodDiagnostic;
63467                     error(errorNode, diagnostic, methodName);
63468                 }
63469                 return methodName === "next" ? anyIterationTypes : undefined;
63470             }
63471             if ((methodType === null || methodType === void 0 ? void 0 : methodType.symbol) && methodSignatures.length === 1) {
63472                 var globalGeneratorType = resolver.getGlobalGeneratorType(false);
63473                 var globalIteratorType = resolver.getGlobalIteratorType(false);
63474                 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;
63475                 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;
63476                 if (isGeneratorMethod || isIteratorMethod) {
63477                     var globalType = isGeneratorMethod ? globalGeneratorType : globalIteratorType;
63478                     var mapper = methodType.mapper;
63479                     return createIterationTypes(getMappedType(globalType.typeParameters[0], mapper), getMappedType(globalType.typeParameters[1], mapper), methodName === "next" ? getMappedType(globalType.typeParameters[2], mapper) : undefined);
63480                 }
63481             }
63482             var methodParameterTypes;
63483             var methodReturnTypes;
63484             for (var _i = 0, methodSignatures_1 = methodSignatures; _i < methodSignatures_1.length; _i++) {
63485                 var signature = methodSignatures_1[_i];
63486                 if (methodName !== "throw" && ts.some(signature.parameters)) {
63487                     methodParameterTypes = ts.append(methodParameterTypes, getTypeAtPosition(signature, 0));
63488                 }
63489                 methodReturnTypes = ts.append(methodReturnTypes, getReturnTypeOfSignature(signature));
63490             }
63491             var returnTypes;
63492             var nextType;
63493             if (methodName !== "throw") {
63494                 var methodParameterType = methodParameterTypes ? getUnionType(methodParameterTypes) : unknownType;
63495                 if (methodName === "next") {
63496                     nextType = methodParameterType;
63497                 }
63498                 else if (methodName === "return") {
63499                     var resolvedMethodParameterType = resolver.resolveIterationType(methodParameterType, errorNode) || anyType;
63500                     returnTypes = ts.append(returnTypes, resolvedMethodParameterType);
63501                 }
63502             }
63503             var yieldType;
63504             var methodReturnType = methodReturnTypes ? getIntersectionType(methodReturnTypes) : neverType;
63505             var resolvedMethodReturnType = resolver.resolveIterationType(methodReturnType, errorNode) || anyType;
63506             var iterationTypes = getIterationTypesOfIteratorResult(resolvedMethodReturnType);
63507             if (iterationTypes === noIterationTypes) {
63508                 if (errorNode) {
63509                     error(errorNode, resolver.mustHaveAValueDiagnostic, methodName);
63510                 }
63511                 yieldType = anyType;
63512                 returnTypes = ts.append(returnTypes, anyType);
63513             }
63514             else {
63515                 yieldType = iterationTypes.yieldType;
63516                 returnTypes = ts.append(returnTypes, iterationTypes.returnType);
63517             }
63518             return createIterationTypes(yieldType, getUnionType(returnTypes), nextType);
63519         }
63520         function getIterationTypesOfIteratorSlow(type, resolver, errorNode) {
63521             var iterationTypes = combineIterationTypes([
63522                 getIterationTypesOfMethod(type, resolver, "next", errorNode),
63523                 getIterationTypesOfMethod(type, resolver, "return", errorNode),
63524                 getIterationTypesOfMethod(type, resolver, "throw", errorNode),
63525             ]);
63526             return setCachedIterationTypes(type, resolver.iteratorCacheKey, iterationTypes);
63527         }
63528         function getIterationTypeOfGeneratorFunctionReturnType(kind, returnType, isAsyncGenerator) {
63529             if (isTypeAny(returnType)) {
63530                 return undefined;
63531             }
63532             var iterationTypes = getIterationTypesOfGeneratorFunctionReturnType(returnType, isAsyncGenerator);
63533             return iterationTypes && iterationTypes[getIterationTypesKeyFromIterationTypeKind(kind)];
63534         }
63535         function getIterationTypesOfGeneratorFunctionReturnType(type, isAsyncGenerator) {
63536             if (isTypeAny(type)) {
63537                 return anyIterationTypes;
63538             }
63539             var use = isAsyncGenerator ? 2 : 1;
63540             var resolver = isAsyncGenerator ? asyncIterationTypesResolver : syncIterationTypesResolver;
63541             return getIterationTypesOfIterable(type, use, undefined) ||
63542                 getIterationTypesOfIterator(type, resolver, undefined);
63543         }
63544         function checkBreakOrContinueStatement(node) {
63545             if (!checkGrammarStatementInAmbientContext(node))
63546                 checkGrammarBreakOrContinueStatement(node);
63547         }
63548         function unwrapReturnType(returnType, functionFlags) {
63549             var _a, _b;
63550             var isGenerator = !!(functionFlags & 1);
63551             var isAsync = !!(functionFlags & 2);
63552             return isGenerator ? (_a = getIterationTypeOfGeneratorFunctionReturnType(1, returnType, isAsync)) !== null && _a !== void 0 ? _a : errorType :
63553                 isAsync ? (_b = getAwaitedType(returnType)) !== null && _b !== void 0 ? _b : errorType :
63554                     returnType;
63555         }
63556         function isUnwrappedReturnTypeVoidOrAny(func, returnType) {
63557             var unwrappedReturnType = unwrapReturnType(returnType, ts.getFunctionFlags(func));
63558             return !!unwrappedReturnType && maybeTypeOfKind(unwrappedReturnType, 16384 | 3);
63559         }
63560         function checkReturnStatement(node) {
63561             var _a;
63562             if (checkGrammarStatementInAmbientContext(node)) {
63563                 return;
63564             }
63565             var func = ts.getContainingFunction(node);
63566             if (!func) {
63567                 grammarErrorOnFirstToken(node, ts.Diagnostics.A_return_statement_can_only_be_used_within_a_function_body);
63568                 return;
63569             }
63570             var signature = getSignatureFromDeclaration(func);
63571             var returnType = getReturnTypeOfSignature(signature);
63572             var functionFlags = ts.getFunctionFlags(func);
63573             if (strictNullChecks || node.expression || returnType.flags & 131072) {
63574                 var exprType = node.expression ? checkExpressionCached(node.expression) : undefinedType;
63575                 if (func.kind === 168) {
63576                     if (node.expression) {
63577                         error(node, ts.Diagnostics.Setters_cannot_return_a_value);
63578                     }
63579                 }
63580                 else if (func.kind === 166) {
63581                     if (node.expression && !checkTypeAssignableToAndOptionallyElaborate(exprType, returnType, node, node.expression)) {
63582                         error(node, ts.Diagnostics.Return_type_of_constructor_signature_must_be_assignable_to_the_instance_type_of_the_class);
63583                     }
63584                 }
63585                 else if (getReturnTypeFromAnnotation(func)) {
63586                     var unwrappedReturnType = (_a = unwrapReturnType(returnType, functionFlags)) !== null && _a !== void 0 ? _a : returnType;
63587                     var unwrappedExprType = functionFlags & 2
63588                         ? 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)
63589                         : exprType;
63590                     if (unwrappedReturnType) {
63591                         checkTypeAssignableToAndOptionallyElaborate(unwrappedExprType, unwrappedReturnType, node, node.expression);
63592                     }
63593                 }
63594             }
63595             else if (func.kind !== 166 && compilerOptions.noImplicitReturns && !isUnwrappedReturnTypeVoidOrAny(func, returnType)) {
63596                 error(node, ts.Diagnostics.Not_all_code_paths_return_a_value);
63597             }
63598         }
63599         function checkWithStatement(node) {
63600             if (!checkGrammarStatementInAmbientContext(node)) {
63601                 if (node.flags & 32768) {
63602                     grammarErrorOnFirstToken(node, ts.Diagnostics.with_statements_are_not_allowed_in_an_async_function_block);
63603                 }
63604             }
63605             checkExpression(node.expression);
63606             var sourceFile = ts.getSourceFileOfNode(node);
63607             if (!hasParseDiagnostics(sourceFile)) {
63608                 var start = ts.getSpanOfTokenAtPosition(sourceFile, node.pos).start;
63609                 var end = node.statement.pos;
63610                 grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.The_with_statement_is_not_supported_All_symbols_in_a_with_block_will_have_type_any);
63611             }
63612         }
63613         function checkSwitchStatement(node) {
63614             checkGrammarStatementInAmbientContext(node);
63615             var firstDefaultClause;
63616             var hasDuplicateDefaultClause = false;
63617             var expressionType = checkExpression(node.expression);
63618             var expressionIsLiteral = isLiteralType(expressionType);
63619             ts.forEach(node.caseBlock.clauses, function (clause) {
63620                 if (clause.kind === 285 && !hasDuplicateDefaultClause) {
63621                     if (firstDefaultClause === undefined) {
63622                         firstDefaultClause = clause;
63623                     }
63624                     else {
63625                         grammarErrorOnNode(clause, ts.Diagnostics.A_default_clause_cannot_appear_more_than_once_in_a_switch_statement);
63626                         hasDuplicateDefaultClause = true;
63627                     }
63628                 }
63629                 if (produceDiagnostics && clause.kind === 284) {
63630                     var caseType = checkExpression(clause.expression);
63631                     var caseIsLiteral = isLiteralType(caseType);
63632                     var comparedExpressionType = expressionType;
63633                     if (!caseIsLiteral || !expressionIsLiteral) {
63634                         caseType = caseIsLiteral ? getBaseTypeOfLiteralType(caseType) : caseType;
63635                         comparedExpressionType = getBaseTypeOfLiteralType(expressionType);
63636                     }
63637                     if (!isTypeEqualityComparableTo(comparedExpressionType, caseType)) {
63638                         checkTypeComparableTo(caseType, comparedExpressionType, clause.expression, undefined);
63639                     }
63640                 }
63641                 ts.forEach(clause.statements, checkSourceElement);
63642                 if (compilerOptions.noFallthroughCasesInSwitch && clause.fallthroughFlowNode && isReachableFlowNode(clause.fallthroughFlowNode)) {
63643                     error(clause, ts.Diagnostics.Fallthrough_case_in_switch);
63644                 }
63645             });
63646             if (node.caseBlock.locals) {
63647                 registerForUnusedIdentifiersCheck(node.caseBlock);
63648             }
63649         }
63650         function checkLabeledStatement(node) {
63651             if (!checkGrammarStatementInAmbientContext(node)) {
63652                 ts.findAncestor(node.parent, function (current) {
63653                     if (ts.isFunctionLike(current)) {
63654                         return "quit";
63655                     }
63656                     if (current.kind === 245 && current.label.escapedText === node.label.escapedText) {
63657                         grammarErrorOnNode(node.label, ts.Diagnostics.Duplicate_label_0, ts.getTextOfNode(node.label));
63658                         return true;
63659                     }
63660                     return false;
63661                 });
63662             }
63663             checkSourceElement(node.statement);
63664         }
63665         function checkThrowStatement(node) {
63666             if (!checkGrammarStatementInAmbientContext(node)) {
63667                 if (ts.isIdentifier(node.expression) && !node.expression.escapedText) {
63668                     grammarErrorAfterFirstToken(node, ts.Diagnostics.Line_break_not_permitted_here);
63669                 }
63670             }
63671             if (node.expression) {
63672                 checkExpression(node.expression);
63673             }
63674         }
63675         function checkTryStatement(node) {
63676             checkGrammarStatementInAmbientContext(node);
63677             checkBlock(node.tryBlock);
63678             var catchClause = node.catchClause;
63679             if (catchClause) {
63680                 if (catchClause.variableDeclaration) {
63681                     var declaration = catchClause.variableDeclaration;
63682                     if (declaration.type) {
63683                         var type = getTypeForVariableLikeDeclaration(declaration, false);
63684                         if (type && !(type.flags & 3)) {
63685                             grammarErrorOnFirstToken(declaration.type, ts.Diagnostics.Catch_clause_variable_type_annotation_must_be_any_or_unknown_if_specified);
63686                         }
63687                     }
63688                     else if (declaration.initializer) {
63689                         grammarErrorOnFirstToken(declaration.initializer, ts.Diagnostics.Catch_clause_variable_cannot_have_an_initializer);
63690                     }
63691                     else {
63692                         var blockLocals_1 = catchClause.block.locals;
63693                         if (blockLocals_1) {
63694                             ts.forEachKey(catchClause.locals, function (caughtName) {
63695                                 var blockLocal = blockLocals_1.get(caughtName);
63696                                 if (blockLocal && (blockLocal.flags & 2) !== 0) {
63697                                     grammarErrorOnNode(blockLocal.valueDeclaration, ts.Diagnostics.Cannot_redeclare_identifier_0_in_catch_clause, caughtName);
63698                                 }
63699                             });
63700                         }
63701                     }
63702                 }
63703                 checkBlock(catchClause.block);
63704             }
63705             if (node.finallyBlock) {
63706                 checkBlock(node.finallyBlock);
63707             }
63708         }
63709         function checkIndexConstraints(type) {
63710             var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1);
63711             var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0);
63712             var stringIndexType = getIndexTypeOfType(type, 0);
63713             var numberIndexType = getIndexTypeOfType(type, 1);
63714             if (stringIndexType || numberIndexType) {
63715                 ts.forEach(getPropertiesOfObjectType(type), function (prop) {
63716                     var propType = getTypeOfSymbol(prop);
63717                     checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0);
63718                     checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1);
63719                 });
63720                 var classDeclaration = type.symbol.valueDeclaration;
63721                 if (ts.getObjectFlags(type) & 1 && ts.isClassLike(classDeclaration)) {
63722                     for (var _i = 0, _a = classDeclaration.members; _i < _a.length; _i++) {
63723                         var member = _a[_i];
63724                         if (!ts.hasSyntacticModifier(member, 32) && !hasBindableName(member)) {
63725                             var symbol = getSymbolOfNode(member);
63726                             var propType = getTypeOfSymbol(symbol);
63727                             checkIndexConstraintForProperty(symbol, propType, type, declaredStringIndexer, stringIndexType, 0);
63728                             checkIndexConstraintForProperty(symbol, propType, type, declaredNumberIndexer, numberIndexType, 1);
63729                         }
63730                     }
63731                 }
63732             }
63733             var errorNode;
63734             if (stringIndexType && numberIndexType) {
63735                 errorNode = declaredNumberIndexer || declaredStringIndexer;
63736                 if (!errorNode && (ts.getObjectFlags(type) & 2)) {
63737                     var someBaseTypeHasBothIndexers = ts.forEach(getBaseTypes(type), function (base) { return getIndexTypeOfType(base, 0) && getIndexTypeOfType(base, 1); });
63738                     errorNode = someBaseTypeHasBothIndexers ? undefined : type.symbol.declarations[0];
63739                 }
63740             }
63741             if (errorNode && !isTypeAssignableTo(numberIndexType, stringIndexType)) {
63742                 error(errorNode, ts.Diagnostics.Numeric_index_type_0_is_not_assignable_to_string_index_type_1, typeToString(numberIndexType), typeToString(stringIndexType));
63743             }
63744             function checkIndexConstraintForProperty(prop, propertyType, containingType, indexDeclaration, indexType, indexKind) {
63745                 if (!indexType || ts.isKnownSymbol(prop)) {
63746                     return;
63747                 }
63748                 var propDeclaration = prop.valueDeclaration;
63749                 var name = propDeclaration && ts.getNameOfDeclaration(propDeclaration);
63750                 if (name && ts.isPrivateIdentifier(name)) {
63751                     return;
63752                 }
63753                 if (indexKind === 1 && !(name ? isNumericName(name) : isNumericLiteralName(prop.escapedName))) {
63754                     return;
63755                 }
63756                 var errorNode;
63757                 if (propDeclaration && name &&
63758                     (propDeclaration.kind === 216 ||
63759                         name.kind === 158 ||
63760                         prop.parent === containingType.symbol)) {
63761                     errorNode = propDeclaration;
63762                 }
63763                 else if (indexDeclaration) {
63764                     errorNode = indexDeclaration;
63765                 }
63766                 else if (ts.getObjectFlags(containingType) & 2) {
63767                     var someBaseClassHasBothPropertyAndIndexer = ts.forEach(getBaseTypes(containingType), function (base) { return getPropertyOfObjectType(base, prop.escapedName) && getIndexTypeOfType(base, indexKind); });
63768                     errorNode = someBaseClassHasBothPropertyAndIndexer ? undefined : containingType.symbol.declarations[0];
63769                 }
63770                 if (errorNode && !isTypeAssignableTo(propertyType, indexType)) {
63771                     var errorMessage = indexKind === 0
63772                         ? ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_string_index_type_2
63773                         : ts.Diagnostics.Property_0_of_type_1_is_not_assignable_to_numeric_index_type_2;
63774                     error(errorNode, errorMessage, symbolToString(prop), typeToString(propertyType), typeToString(indexType));
63775                 }
63776             }
63777         }
63778         function checkTypeNameIsReserved(name, message) {
63779             switch (name.escapedText) {
63780                 case "any":
63781                 case "unknown":
63782                 case "number":
63783                 case "bigint":
63784                 case "boolean":
63785                 case "string":
63786                 case "symbol":
63787                 case "void":
63788                 case "object":
63789                     error(name, message, name.escapedText);
63790             }
63791         }
63792         function checkClassNameCollisionWithObject(name) {
63793             if (languageVersion === 1 && name.escapedText === "Object"
63794                 && moduleKind < ts.ModuleKind.ES2015) {
63795                 error(name, ts.Diagnostics.Class_name_cannot_be_Object_when_targeting_ES5_with_module_0, ts.ModuleKind[moduleKind]);
63796             }
63797         }
63798         function checkTypeParameters(typeParameterDeclarations) {
63799             if (typeParameterDeclarations) {
63800                 var seenDefault = false;
63801                 for (var i = 0; i < typeParameterDeclarations.length; i++) {
63802                     var node = typeParameterDeclarations[i];
63803                     checkTypeParameter(node);
63804                     if (produceDiagnostics) {
63805                         if (node.default) {
63806                             seenDefault = true;
63807                             checkTypeParametersNotReferenced(node.default, typeParameterDeclarations, i);
63808                         }
63809                         else if (seenDefault) {
63810                             error(node, ts.Diagnostics.Required_type_parameters_may_not_follow_optional_type_parameters);
63811                         }
63812                         for (var j = 0; j < i; j++) {
63813                             if (typeParameterDeclarations[j].symbol === node.symbol) {
63814                                 error(node.name, ts.Diagnostics.Duplicate_identifier_0, ts.declarationNameToString(node.name));
63815                             }
63816                         }
63817                     }
63818                 }
63819             }
63820         }
63821         function checkTypeParametersNotReferenced(root, typeParameters, index) {
63822             visit(root);
63823             function visit(node) {
63824                 if (node.kind === 173) {
63825                     var type = getTypeFromTypeReference(node);
63826                     if (type.flags & 262144) {
63827                         for (var i = index; i < typeParameters.length; i++) {
63828                             if (type.symbol === getSymbolOfNode(typeParameters[i])) {
63829                                 error(node, ts.Diagnostics.Type_parameter_defaults_can_only_reference_previously_declared_type_parameters);
63830                             }
63831                         }
63832                     }
63833                 }
63834                 ts.forEachChild(node, visit);
63835             }
63836         }
63837         function checkTypeParameterListsIdentical(symbol) {
63838             if (symbol.declarations.length === 1) {
63839                 return;
63840             }
63841             var links = getSymbolLinks(symbol);
63842             if (!links.typeParametersChecked) {
63843                 links.typeParametersChecked = true;
63844                 var declarations = getClassOrInterfaceDeclarationsOfSymbol(symbol);
63845                 if (declarations.length <= 1) {
63846                     return;
63847                 }
63848                 var type = getDeclaredTypeOfSymbol(symbol);
63849                 if (!areTypeParametersIdentical(declarations, type.localTypeParameters)) {
63850                     var name = symbolToString(symbol);
63851                     for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
63852                         var declaration = declarations_6[_i];
63853                         error(declaration.name, ts.Diagnostics.All_declarations_of_0_must_have_identical_type_parameters, name);
63854                     }
63855                 }
63856             }
63857         }
63858         function areTypeParametersIdentical(declarations, targetParameters) {
63859             var maxTypeArgumentCount = ts.length(targetParameters);
63860             var minTypeArgumentCount = getMinTypeArgumentCount(targetParameters);
63861             for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
63862                 var declaration = declarations_7[_i];
63863                 var sourceParameters = ts.getEffectiveTypeParameterDeclarations(declaration);
63864                 var numTypeParameters = sourceParameters.length;
63865                 if (numTypeParameters < minTypeArgumentCount || numTypeParameters > maxTypeArgumentCount) {
63866                     return false;
63867                 }
63868                 for (var i = 0; i < numTypeParameters; i++) {
63869                     var source = sourceParameters[i];
63870                     var target = targetParameters[i];
63871                     if (source.name.escapedText !== target.symbol.escapedName) {
63872                         return false;
63873                     }
63874                     var constraint = ts.getEffectiveConstraintOfTypeParameter(source);
63875                     var sourceConstraint = constraint && getTypeFromTypeNode(constraint);
63876                     var targetConstraint = getConstraintOfTypeParameter(target);
63877                     if (sourceConstraint && targetConstraint && !isTypeIdenticalTo(sourceConstraint, targetConstraint)) {
63878                         return false;
63879                     }
63880                     var sourceDefault = source.default && getTypeFromTypeNode(source.default);
63881                     var targetDefault = getDefaultFromTypeParameter(target);
63882                     if (sourceDefault && targetDefault && !isTypeIdenticalTo(sourceDefault, targetDefault)) {
63883                         return false;
63884                     }
63885                 }
63886             }
63887             return true;
63888         }
63889         function checkClassExpression(node) {
63890             checkClassLikeDeclaration(node);
63891             checkNodeDeferred(node);
63892             return getTypeOfSymbol(getSymbolOfNode(node));
63893         }
63894         function checkClassExpressionDeferred(node) {
63895             ts.forEach(node.members, checkSourceElement);
63896             registerForUnusedIdentifiersCheck(node);
63897         }
63898         function checkClassDeclaration(node) {
63899             if (!node.name && !ts.hasSyntacticModifier(node, 512)) {
63900                 grammarErrorOnFirstToken(node, ts.Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name);
63901             }
63902             checkClassLikeDeclaration(node);
63903             ts.forEach(node.members, checkSourceElement);
63904             registerForUnusedIdentifiersCheck(node);
63905         }
63906         function checkClassLikeDeclaration(node) {
63907             checkGrammarClassLikeDeclaration(node);
63908             checkDecorators(node);
63909             if (node.name) {
63910                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Class_name_cannot_be_0);
63911                 checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
63912                 checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
63913                 if (!(node.flags & 8388608)) {
63914                     checkClassNameCollisionWithObject(node.name);
63915                 }
63916             }
63917             checkTypeParameters(ts.getEffectiveTypeParameterDeclarations(node));
63918             checkExportsOnMergedDeclarations(node);
63919             var symbol = getSymbolOfNode(node);
63920             var type = getDeclaredTypeOfSymbol(symbol);
63921             var typeWithThis = getTypeWithThisArgument(type);
63922             var staticType = getTypeOfSymbol(symbol);
63923             checkTypeParameterListsIdentical(symbol);
63924             checkFunctionOrConstructorSymbol(symbol);
63925             checkClassForDuplicateDeclarations(node);
63926             if (!(node.flags & 8388608)) {
63927                 checkClassForStaticPropertyNameConflicts(node);
63928             }
63929             var baseTypeNode = ts.getEffectiveBaseTypeNode(node);
63930             if (baseTypeNode) {
63931                 ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
63932                 if (languageVersion < 2) {
63933                     checkExternalEmitHelpers(baseTypeNode.parent, 1);
63934                 }
63935                 var extendsNode = ts.getClassExtendsHeritageElement(node);
63936                 if (extendsNode && extendsNode !== baseTypeNode) {
63937                     checkExpression(extendsNode.expression);
63938                 }
63939                 var baseTypes = getBaseTypes(type);
63940                 if (baseTypes.length && produceDiagnostics) {
63941                     var baseType_1 = baseTypes[0];
63942                     var baseConstructorType = getBaseConstructorTypeOfClass(type);
63943                     var staticBaseType = getApparentType(baseConstructorType);
63944                     checkBaseTypeAccessibility(staticBaseType, baseTypeNode);
63945                     checkSourceElement(baseTypeNode.expression);
63946                     if (ts.some(baseTypeNode.typeArguments)) {
63947                         ts.forEach(baseTypeNode.typeArguments, checkSourceElement);
63948                         for (var _i = 0, _a = getConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode); _i < _a.length; _i++) {
63949                             var constructor = _a[_i];
63950                             if (!checkTypeArgumentConstraints(baseTypeNode, constructor.typeParameters)) {
63951                                 break;
63952                             }
63953                         }
63954                     }
63955                     var baseWithThis = getTypeWithThisArgument(baseType_1, type.thisType);
63956                     if (!checkTypeAssignableTo(typeWithThis, baseWithThis, undefined)) {
63957                         issueMemberSpecificError(node, typeWithThis, baseWithThis, ts.Diagnostics.Class_0_incorrectly_extends_base_class_1);
63958                     }
63959                     else {
63960                         checkTypeAssignableTo(staticType, getTypeWithoutSignatures(staticBaseType), node.name || node, ts.Diagnostics.Class_static_side_0_incorrectly_extends_base_class_static_side_1);
63961                     }
63962                     if (baseConstructorType.flags & 8650752) {
63963                         if (!isMixinConstructorType(staticType)) {
63964                             error(node.name || node, ts.Diagnostics.A_mixin_class_must_have_a_constructor_with_a_single_rest_parameter_of_type_any);
63965                         }
63966                         else {
63967                             var constructSignatures = getSignaturesOfType(baseConstructorType, 1);
63968                             if (constructSignatures.some(function (signature) { return signature.flags & 4; }) && !ts.hasSyntacticModifier(node, 128)) {
63969                                 error(node.name || node, ts.Diagnostics.A_mixin_class_that_extends_from_a_type_variable_containing_an_abstract_construct_signature_must_also_be_declared_abstract);
63970                             }
63971                         }
63972                     }
63973                     if (!(staticBaseType.symbol && staticBaseType.symbol.flags & 32) && !(baseConstructorType.flags & 8650752)) {
63974                         var constructors = getInstantiatedConstructorsForTypeArguments(staticBaseType, baseTypeNode.typeArguments, baseTypeNode);
63975                         if (ts.forEach(constructors, function (sig) { return !isJSConstructor(sig.declaration) && !isTypeIdenticalTo(getReturnTypeOfSignature(sig), baseType_1); })) {
63976                             error(baseTypeNode.expression, ts.Diagnostics.Base_constructors_must_all_have_the_same_return_type);
63977                         }
63978                     }
63979                     checkKindsOfPropertyMemberOverrides(type, baseType_1);
63980                 }
63981             }
63982             var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node);
63983             if (implementedTypeNodes) {
63984                 for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) {
63985                     var typeRefNode = implementedTypeNodes_1[_b];
63986                     if (!ts.isEntityNameExpression(typeRefNode.expression) || ts.isOptionalChain(typeRefNode.expression)) {
63987                         error(typeRefNode.expression, ts.Diagnostics.A_class_can_only_implement_an_identifier_Slashqualified_name_with_optional_type_arguments);
63988                     }
63989                     checkTypeReferenceNode(typeRefNode);
63990                     if (produceDiagnostics) {
63991                         var t = getReducedType(getTypeFromTypeNode(typeRefNode));
63992                         if (t !== errorType) {
63993                             if (isValidBaseType(t)) {
63994                                 var genericDiag = t.symbol && t.symbol.flags & 32 ?
63995                                     ts.Diagnostics.Class_0_incorrectly_implements_class_1_Did_you_mean_to_extend_1_and_inherit_its_members_as_a_subclass :
63996                                     ts.Diagnostics.Class_0_incorrectly_implements_interface_1;
63997                                 var baseWithThis = getTypeWithThisArgument(t, type.thisType);
63998                                 if (!checkTypeAssignableTo(typeWithThis, baseWithThis, undefined)) {
63999                                     issueMemberSpecificError(node, typeWithThis, baseWithThis, genericDiag);
64000                                 }
64001                             }
64002                             else {
64003                                 error(typeRefNode, ts.Diagnostics.A_class_can_only_implement_an_object_type_or_intersection_of_object_types_with_statically_known_members);
64004                             }
64005                         }
64006                     }
64007                 }
64008             }
64009             if (produceDiagnostics) {
64010                 checkIndexConstraints(type);
64011                 checkTypeForDuplicateIndexSignatures(node);
64012                 checkPropertyInitialization(node);
64013             }
64014         }
64015         function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
64016             var issuedMemberError = false;
64017             var _loop_23 = function (member) {
64018                 if (ts.hasStaticModifier(member)) {
64019                     return "continue";
64020                 }
64021                 var declaredProp = member.name && getSymbolAtLocation(member.name) || getSymbolAtLocation(member);
64022                 if (declaredProp) {
64023                     var prop = getPropertyOfType(typeWithThis, declaredProp.escapedName);
64024                     var baseProp = getPropertyOfType(baseWithThis, declaredProp.escapedName);
64025                     if (prop && baseProp) {
64026                         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)); };
64027                         if (!checkTypeAssignableTo(getTypeOfSymbol(prop), getTypeOfSymbol(baseProp), member.name || member, undefined, rootChain)) {
64028                             issuedMemberError = true;
64029                         }
64030                     }
64031                 }
64032             };
64033             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
64034                 var member = _a[_i];
64035                 _loop_23(member);
64036             }
64037             if (!issuedMemberError) {
64038                 checkTypeAssignableTo(typeWithThis, baseWithThis, node.name || node, broadDiag);
64039             }
64040         }
64041         function checkBaseTypeAccessibility(type, node) {
64042             var signatures = getSignaturesOfType(type, 1);
64043             if (signatures.length) {
64044                 var declaration = signatures[0].declaration;
64045                 if (declaration && ts.hasEffectiveModifier(declaration, 8)) {
64046                     var typeClassDeclaration = ts.getClassLikeDeclarationOfSymbol(type.symbol);
64047                     if (!isNodeWithinClass(node, typeClassDeclaration)) {
64048                         error(node, ts.Diagnostics.Cannot_extend_a_class_0_Class_constructor_is_marked_as_private, getFullyQualifiedName(type.symbol));
64049                     }
64050                 }
64051             }
64052         }
64053         function getTargetSymbol(s) {
64054             return ts.getCheckFlags(s) & 1 ? s.target : s;
64055         }
64056         function getClassOrInterfaceDeclarationsOfSymbol(symbol) {
64057             return ts.filter(symbol.declarations, function (d) {
64058                 return d.kind === 252 || d.kind === 253;
64059             });
64060         }
64061         function checkKindsOfPropertyMemberOverrides(type, baseType) {
64062             var baseProperties = getPropertiesOfType(baseType);
64063             basePropertyCheck: for (var _i = 0, baseProperties_1 = baseProperties; _i < baseProperties_1.length; _i++) {
64064                 var baseProperty = baseProperties_1[_i];
64065                 var base = getTargetSymbol(baseProperty);
64066                 if (base.flags & 4194304) {
64067                     continue;
64068                 }
64069                 var baseSymbol = getPropertyOfObjectType(type, base.escapedName);
64070                 if (!baseSymbol) {
64071                     continue;
64072                 }
64073                 var derived = getTargetSymbol(baseSymbol);
64074                 var baseDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(base);
64075                 ts.Debug.assert(!!derived, "derived should point to something, even if it is the base class' declaration.");
64076                 if (derived === base) {
64077                     var derivedClassDecl = ts.getClassLikeDeclarationOfSymbol(type.symbol);
64078                     if (baseDeclarationFlags & 128 && (!derivedClassDecl || !ts.hasSyntacticModifier(derivedClassDecl, 128))) {
64079                         for (var _a = 0, _b = getBaseTypes(type); _a < _b.length; _a++) {
64080                             var otherBaseType = _b[_a];
64081                             if (otherBaseType === baseType)
64082                                 continue;
64083                             var baseSymbol_1 = getPropertyOfObjectType(otherBaseType, base.escapedName);
64084                             var derivedElsewhere = baseSymbol_1 && getTargetSymbol(baseSymbol_1);
64085                             if (derivedElsewhere && derivedElsewhere !== base) {
64086                                 continue basePropertyCheck;
64087                             }
64088                         }
64089                         if (derivedClassDecl.kind === 221) {
64090                             error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_expression_does_not_implement_inherited_abstract_member_0_from_class_1, symbolToString(baseProperty), typeToString(baseType));
64091                         }
64092                         else {
64093                             error(derivedClassDecl, ts.Diagnostics.Non_abstract_class_0_does_not_implement_inherited_abstract_member_1_from_class_2, typeToString(type), symbolToString(baseProperty), typeToString(baseType));
64094                         }
64095                     }
64096                 }
64097                 else {
64098                     var derivedDeclarationFlags = ts.getDeclarationModifierFlagsFromSymbol(derived);
64099                     if (baseDeclarationFlags & 8 || derivedDeclarationFlags & 8) {
64100                         continue;
64101                     }
64102                     var errorMessage = void 0;
64103                     var basePropertyFlags = base.flags & 98308;
64104                     var derivedPropertyFlags = derived.flags & 98308;
64105                     if (basePropertyFlags && derivedPropertyFlags) {
64106                         if (baseDeclarationFlags & 128 && !(base.valueDeclaration && ts.isPropertyDeclaration(base.valueDeclaration) && base.valueDeclaration.initializer)
64107                             || base.valueDeclaration && base.valueDeclaration.parent.kind === 253
64108                             || derived.valueDeclaration && ts.isBinaryExpression(derived.valueDeclaration)) {
64109                             continue;
64110                         }
64111                         var overriddenInstanceProperty = basePropertyFlags !== 4 && derivedPropertyFlags === 4;
64112                         var overriddenInstanceAccessor = basePropertyFlags === 4 && derivedPropertyFlags !== 4;
64113                         if (overriddenInstanceProperty || overriddenInstanceAccessor) {
64114                             var errorMessage_1 = overriddenInstanceProperty ?
64115                                 ts.Diagnostics._0_is_defined_as_an_accessor_in_class_1_but_is_overridden_here_in_2_as_an_instance_property :
64116                                 ts.Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor;
64117                             error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_1, symbolToString(base), typeToString(baseType), typeToString(type));
64118                         }
64119                         else if (compilerOptions.useDefineForClassFields) {
64120                             var uninitialized = ts.find(derived.declarations, function (d) { return d.kind === 163 && !d.initializer; });
64121                             if (uninitialized
64122                                 && !(derived.flags & 33554432)
64123                                 && !(baseDeclarationFlags & 128)
64124                                 && !(derivedDeclarationFlags & 128)
64125                                 && !derived.declarations.some(function (d) { return !!(d.flags & 8388608); })) {
64126                                 var constructor = findConstructorDeclaration(ts.getClassLikeDeclarationOfSymbol(type.symbol));
64127                                 var propName = uninitialized.name;
64128                                 if (uninitialized.exclamationToken
64129                                     || !constructor
64130                                     || !ts.isIdentifier(propName)
64131                                     || !strictNullChecks
64132                                     || !isPropertyInitializedInConstructor(propName, type, constructor)) {
64133                                     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;
64134                                     error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage_2, symbolToString(base), typeToString(baseType));
64135                                 }
64136                             }
64137                         }
64138                         continue;
64139                     }
64140                     else if (isPrototypeProperty(base)) {
64141                         if (isPrototypeProperty(derived) || derived.flags & 4) {
64142                             continue;
64143                         }
64144                         else {
64145                             ts.Debug.assert(!!(derived.flags & 98304));
64146                             errorMessage = ts.Diagnostics.Class_0_defines_instance_member_function_1_but_extended_class_2_defines_it_as_instance_member_accessor;
64147                         }
64148                     }
64149                     else if (base.flags & 98304) {
64150                         errorMessage = ts.Diagnostics.Class_0_defines_instance_member_accessor_1_but_extended_class_2_defines_it_as_instance_member_function;
64151                     }
64152                     else {
64153                         errorMessage = ts.Diagnostics.Class_0_defines_instance_member_property_1_but_extended_class_2_defines_it_as_instance_member_function;
64154                     }
64155                     error(ts.getNameOfDeclaration(derived.valueDeclaration) || derived.valueDeclaration, errorMessage, typeToString(baseType), symbolToString(base), typeToString(type));
64156                 }
64157             }
64158         }
64159         function getNonInterhitedProperties(type, baseTypes, properties) {
64160             if (!ts.length(baseTypes)) {
64161                 return properties;
64162             }
64163             var seen = new ts.Map();
64164             ts.forEach(properties, function (p) { seen.set(p.escapedName, p); });
64165             for (var _i = 0, baseTypes_2 = baseTypes; _i < baseTypes_2.length; _i++) {
64166                 var base = baseTypes_2[_i];
64167                 var properties_5 = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
64168                 for (var _a = 0, properties_4 = properties_5; _a < properties_4.length; _a++) {
64169                     var prop = properties_4[_a];
64170                     var existing = seen.get(prop.escapedName);
64171                     if (existing && !isPropertyIdenticalTo(existing, prop)) {
64172                         seen.delete(prop.escapedName);
64173                     }
64174                 }
64175             }
64176             return ts.arrayFrom(seen.values());
64177         }
64178         function checkInheritedPropertiesAreIdentical(type, typeNode) {
64179             var baseTypes = getBaseTypes(type);
64180             if (baseTypes.length < 2) {
64181                 return true;
64182             }
64183             var seen = new ts.Map();
64184             ts.forEach(resolveDeclaredMembers(type).declaredProperties, function (p) { seen.set(p.escapedName, { prop: p, containingType: type }); });
64185             var ok = true;
64186             for (var _i = 0, baseTypes_3 = baseTypes; _i < baseTypes_3.length; _i++) {
64187                 var base = baseTypes_3[_i];
64188                 var properties = getPropertiesOfType(getTypeWithThisArgument(base, type.thisType));
64189                 for (var _a = 0, properties_6 = properties; _a < properties_6.length; _a++) {
64190                     var prop = properties_6[_a];
64191                     var existing = seen.get(prop.escapedName);
64192                     if (!existing) {
64193                         seen.set(prop.escapedName, { prop: prop, containingType: base });
64194                     }
64195                     else {
64196                         var isInheritedProperty = existing.containingType !== type;
64197                         if (isInheritedProperty && !isPropertyIdenticalTo(existing.prop, prop)) {
64198                             ok = false;
64199                             var typeName1 = typeToString(existing.containingType);
64200                             var typeName2 = typeToString(base);
64201                             var errorInfo = ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Named_property_0_of_types_1_and_2_are_not_identical, symbolToString(prop), typeName1, typeName2);
64202                             errorInfo = ts.chainDiagnosticMessages(errorInfo, ts.Diagnostics.Interface_0_cannot_simultaneously_extend_types_1_and_2, typeToString(type), typeName1, typeName2);
64203                             diagnostics.add(ts.createDiagnosticForNodeFromMessageChain(typeNode, errorInfo));
64204                         }
64205                     }
64206                 }
64207             }
64208             return ok;
64209         }
64210         function checkPropertyInitialization(node) {
64211             if (!strictNullChecks || !strictPropertyInitialization || node.flags & 8388608) {
64212                 return;
64213             }
64214             var constructor = findConstructorDeclaration(node);
64215             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
64216                 var member = _a[_i];
64217                 if (ts.getEffectiveModifierFlags(member) & 2) {
64218                     continue;
64219                 }
64220                 if (isInstancePropertyWithoutInitializer(member)) {
64221                     var propName = member.name;
64222                     if (ts.isIdentifier(propName) || ts.isPrivateIdentifier(propName)) {
64223                         var type = getTypeOfSymbol(getSymbolOfNode(member));
64224                         if (!(type.flags & 3 || getFalsyFlags(type) & 32768)) {
64225                             if (!constructor || !isPropertyInitializedInConstructor(propName, type, constructor)) {
64226                                 error(member.name, ts.Diagnostics.Property_0_has_no_initializer_and_is_not_definitely_assigned_in_the_constructor, ts.declarationNameToString(propName));
64227                             }
64228                         }
64229                     }
64230                 }
64231             }
64232         }
64233         function isInstancePropertyWithoutInitializer(node) {
64234             return node.kind === 163 &&
64235                 !ts.hasSyntacticModifier(node, 32 | 128) &&
64236                 !node.exclamationToken &&
64237                 !node.initializer;
64238         }
64239         function isPropertyInitializedInConstructor(propName, propType, constructor) {
64240             var reference = ts.factory.createPropertyAccessExpression(ts.factory.createThis(), propName);
64241             ts.setParent(reference.expression, reference);
64242             ts.setParent(reference, constructor);
64243             reference.flowNode = constructor.returnFlowNode;
64244             var flowType = getFlowTypeOfReference(reference, propType, getOptionalType(propType));
64245             return !(getFalsyFlags(flowType) & 32768);
64246         }
64247         function checkInterfaceDeclaration(node) {
64248             if (!checkGrammarDecoratorsAndModifiers(node))
64249                 checkGrammarInterfaceDeclaration(node);
64250             checkTypeParameters(node.typeParameters);
64251             if (produceDiagnostics) {
64252                 checkTypeNameIsReserved(node.name, ts.Diagnostics.Interface_name_cannot_be_0);
64253                 checkExportsOnMergedDeclarations(node);
64254                 var symbol = getSymbolOfNode(node);
64255                 checkTypeParameterListsIdentical(symbol);
64256                 var firstInterfaceDecl = ts.getDeclarationOfKind(symbol, 253);
64257                 if (node === firstInterfaceDecl) {
64258                     var type = getDeclaredTypeOfSymbol(symbol);
64259                     var typeWithThis = getTypeWithThisArgument(type);
64260                     if (checkInheritedPropertiesAreIdentical(type, node.name)) {
64261                         for (var _i = 0, _a = getBaseTypes(type); _i < _a.length; _i++) {
64262                             var baseType = _a[_i];
64263                             checkTypeAssignableTo(typeWithThis, getTypeWithThisArgument(baseType, type.thisType), node.name, ts.Diagnostics.Interface_0_incorrectly_extends_interface_1);
64264                         }
64265                         checkIndexConstraints(type);
64266                     }
64267                 }
64268                 checkObjectTypeForDuplicateDeclarations(node);
64269             }
64270             ts.forEach(ts.getInterfaceBaseTypeNodes(node), function (heritageElement) {
64271                 if (!ts.isEntityNameExpression(heritageElement.expression) || ts.isOptionalChain(heritageElement.expression)) {
64272                     error(heritageElement.expression, ts.Diagnostics.An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments);
64273                 }
64274                 checkTypeReferenceNode(heritageElement);
64275             });
64276             ts.forEach(node.members, checkSourceElement);
64277             if (produceDiagnostics) {
64278                 checkTypeForDuplicateIndexSignatures(node);
64279                 registerForUnusedIdentifiersCheck(node);
64280             }
64281         }
64282         function checkTypeAliasDeclaration(node) {
64283             checkGrammarDecoratorsAndModifiers(node);
64284             checkTypeNameIsReserved(node.name, ts.Diagnostics.Type_alias_name_cannot_be_0);
64285             checkExportsOnMergedDeclarations(node);
64286             checkTypeParameters(node.typeParameters);
64287             if (node.type.kind === 136) {
64288                 if (!intrinsicTypeKinds.has(node.name.escapedText) || ts.length(node.typeParameters) !== 1) {
64289                     error(node.type, ts.Diagnostics.The_intrinsic_keyword_can_only_be_used_to_declare_compiler_provided_intrinsic_types);
64290                 }
64291             }
64292             else {
64293                 checkSourceElement(node.type);
64294                 registerForUnusedIdentifiersCheck(node);
64295             }
64296         }
64297         function computeEnumMemberValues(node) {
64298             var nodeLinks = getNodeLinks(node);
64299             if (!(nodeLinks.flags & 16384)) {
64300                 nodeLinks.flags |= 16384;
64301                 var autoValue = 0;
64302                 for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
64303                     var member = _a[_i];
64304                     var value = computeMemberValue(member, autoValue);
64305                     getNodeLinks(member).enumMemberValue = value;
64306                     autoValue = typeof value === "number" ? value + 1 : undefined;
64307                 }
64308             }
64309         }
64310         function computeMemberValue(member, autoValue) {
64311             if (ts.isComputedNonLiteralName(member.name)) {
64312                 error(member.name, ts.Diagnostics.Computed_property_names_are_not_allowed_in_enums);
64313             }
64314             else {
64315                 var text = ts.getTextOfPropertyName(member.name);
64316                 if (isNumericLiteralName(text) && !isInfinityOrNaNString(text)) {
64317                     error(member.name, ts.Diagnostics.An_enum_member_cannot_have_a_numeric_name);
64318                 }
64319             }
64320             if (member.initializer) {
64321                 return computeConstantValue(member);
64322             }
64323             if (member.parent.flags & 8388608 && !ts.isEnumConst(member.parent) && getEnumKind(getSymbolOfNode(member.parent)) === 0) {
64324                 return undefined;
64325             }
64326             if (autoValue !== undefined) {
64327                 return autoValue;
64328             }
64329             error(member.name, ts.Diagnostics.Enum_member_must_have_initializer);
64330             return undefined;
64331         }
64332         function computeConstantValue(member) {
64333             var enumKind = getEnumKind(getSymbolOfNode(member.parent));
64334             var isConstEnum = ts.isEnumConst(member.parent);
64335             var initializer = member.initializer;
64336             var value = enumKind === 1 && !isLiteralEnumMember(member) ? undefined : evaluate(initializer);
64337             if (value !== undefined) {
64338                 if (isConstEnum && typeof value === "number" && !isFinite(value)) {
64339                     error(initializer, isNaN(value) ?
64340                         ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_disallowed_value_NaN :
64341                         ts.Diagnostics.const_enum_member_initializer_was_evaluated_to_a_non_finite_value);
64342                 }
64343             }
64344             else if (enumKind === 1) {
64345                 error(initializer, ts.Diagnostics.Computed_values_are_not_permitted_in_an_enum_with_string_valued_members);
64346                 return 0;
64347             }
64348             else if (isConstEnum) {
64349                 error(initializer, ts.Diagnostics.const_enum_member_initializers_can_only_contain_literal_values_and_other_computed_enum_values);
64350             }
64351             else if (member.parent.flags & 8388608) {
64352                 error(initializer, ts.Diagnostics.In_ambient_enum_declarations_member_initializer_must_be_constant_expression);
64353             }
64354             else {
64355                 var source = checkExpression(initializer);
64356                 if (!isTypeAssignableToKind(source, 296)) {
64357                     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));
64358                 }
64359                 else {
64360                     checkTypeAssignableTo(source, getDeclaredTypeOfSymbol(getSymbolOfNode(member.parent)), initializer, undefined);
64361                 }
64362             }
64363             return value;
64364             function evaluate(expr) {
64365                 switch (expr.kind) {
64366                     case 214:
64367                         var value_2 = evaluate(expr.operand);
64368                         if (typeof value_2 === "number") {
64369                             switch (expr.operator) {
64370                                 case 39: return value_2;
64371                                 case 40: return -value_2;
64372                                 case 54: return ~value_2;
64373                             }
64374                         }
64375                         break;
64376                     case 216:
64377                         var left = evaluate(expr.left);
64378                         var right = evaluate(expr.right);
64379                         if (typeof left === "number" && typeof right === "number") {
64380                             switch (expr.operatorToken.kind) {
64381                                 case 51: return left | right;
64382                                 case 50: return left & right;
64383                                 case 48: return left >> right;
64384                                 case 49: return left >>> right;
64385                                 case 47: return left << right;
64386                                 case 52: return left ^ right;
64387                                 case 41: return left * right;
64388                                 case 43: return left / right;
64389                                 case 39: return left + right;
64390                                 case 40: return left - right;
64391                                 case 44: return left % right;
64392                                 case 42: return Math.pow(left, right);
64393                             }
64394                         }
64395                         else if (typeof left === "string" && typeof right === "string" && expr.operatorToken.kind === 39) {
64396                             return left + right;
64397                         }
64398                         break;
64399                     case 10:
64400                     case 14:
64401                         return expr.text;
64402                     case 8:
64403                         checkGrammarNumericLiteral(expr);
64404                         return +expr.text;
64405                     case 207:
64406                         return evaluate(expr.expression);
64407                     case 78:
64408                         var identifier = expr;
64409                         if (isInfinityOrNaNString(identifier.escapedText)) {
64410                             return +(identifier.escapedText);
64411                         }
64412                         return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText);
64413                     case 202:
64414                     case 201:
64415                         var ex = expr;
64416                         if (isConstantMemberAccess(ex)) {
64417                             var type = getTypeOfExpression(ex.expression);
64418                             if (type.symbol && type.symbol.flags & 384) {
64419                                 var name = void 0;
64420                                 if (ex.kind === 201) {
64421                                     name = ex.name.escapedText;
64422                                 }
64423                                 else {
64424                                     name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text);
64425                                 }
64426                                 return evaluateEnumMember(expr, type.symbol, name);
64427                             }
64428                         }
64429                         break;
64430                 }
64431                 return undefined;
64432             }
64433             function evaluateEnumMember(expr, enumSymbol, name) {
64434                 var memberSymbol = enumSymbol.exports.get(name);
64435                 if (memberSymbol) {
64436                     var declaration = memberSymbol.valueDeclaration;
64437                     if (declaration !== member) {
64438                         if (isBlockScopedNameDeclaredBeforeUse(declaration, member)) {
64439                             return getEnumMemberValue(declaration);
64440                         }
64441                         error(expr, ts.Diagnostics.A_member_initializer_in_a_enum_declaration_cannot_reference_members_declared_after_it_including_members_defined_in_other_enums);
64442                         return 0;
64443                     }
64444                     else {
64445                         error(expr, ts.Diagnostics.Property_0_is_used_before_being_assigned, symbolToString(memberSymbol));
64446                     }
64447                 }
64448                 return undefined;
64449             }
64450         }
64451         function isConstantMemberAccess(node) {
64452             return node.kind === 78 ||
64453                 node.kind === 201 && isConstantMemberAccess(node.expression) ||
64454                 node.kind === 202 && isConstantMemberAccess(node.expression) &&
64455                     ts.isStringLiteralLike(node.argumentExpression);
64456         }
64457         function checkEnumDeclaration(node) {
64458             if (!produceDiagnostics) {
64459                 return;
64460             }
64461             checkGrammarDecoratorsAndModifiers(node);
64462             checkTypeNameIsReserved(node.name, ts.Diagnostics.Enum_name_cannot_be_0);
64463             checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
64464             checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
64465             checkExportsOnMergedDeclarations(node);
64466             node.members.forEach(checkEnumMember);
64467             computeEnumMemberValues(node);
64468             var enumSymbol = getSymbolOfNode(node);
64469             var firstDeclaration = ts.getDeclarationOfKind(enumSymbol, node.kind);
64470             if (node === firstDeclaration) {
64471                 if (enumSymbol.declarations.length > 1) {
64472                     var enumIsConst_1 = ts.isEnumConst(node);
64473                     ts.forEach(enumSymbol.declarations, function (decl) {
64474                         if (ts.isEnumDeclaration(decl) && ts.isEnumConst(decl) !== enumIsConst_1) {
64475                             error(ts.getNameOfDeclaration(decl), ts.Diagnostics.Enum_declarations_must_all_be_const_or_non_const);
64476                         }
64477                     });
64478                 }
64479                 var seenEnumMissingInitialInitializer_1 = false;
64480                 ts.forEach(enumSymbol.declarations, function (declaration) {
64481                     if (declaration.kind !== 255) {
64482                         return false;
64483                     }
64484                     var enumDeclaration = declaration;
64485                     if (!enumDeclaration.members.length) {
64486                         return false;
64487                     }
64488                     var firstEnumMember = enumDeclaration.members[0];
64489                     if (!firstEnumMember.initializer) {
64490                         if (seenEnumMissingInitialInitializer_1) {
64491                             error(firstEnumMember.name, ts.Diagnostics.In_an_enum_with_multiple_declarations_only_one_declaration_can_omit_an_initializer_for_its_first_enum_element);
64492                         }
64493                         else {
64494                             seenEnumMissingInitialInitializer_1 = true;
64495                         }
64496                     }
64497                 });
64498             }
64499         }
64500         function checkEnumMember(node) {
64501             if (ts.isPrivateIdentifier(node.name)) {
64502                 error(node, ts.Diagnostics.An_enum_member_cannot_be_named_with_a_private_identifier);
64503             }
64504         }
64505         function getFirstNonAmbientClassOrFunctionDeclaration(symbol) {
64506             var declarations = symbol.declarations;
64507             for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
64508                 var declaration = declarations_8[_i];
64509                 if ((declaration.kind === 252 ||
64510                     (declaration.kind === 251 && ts.nodeIsPresent(declaration.body))) &&
64511                     !(declaration.flags & 8388608)) {
64512                     return declaration;
64513                 }
64514             }
64515             return undefined;
64516         }
64517         function inSameLexicalScope(node1, node2) {
64518             var container1 = ts.getEnclosingBlockScopeContainer(node1);
64519             var container2 = ts.getEnclosingBlockScopeContainer(node2);
64520             if (isGlobalSourceFile(container1)) {
64521                 return isGlobalSourceFile(container2);
64522             }
64523             else if (isGlobalSourceFile(container2)) {
64524                 return false;
64525             }
64526             else {
64527                 return container1 === container2;
64528             }
64529         }
64530         function checkModuleDeclaration(node) {
64531             if (produceDiagnostics) {
64532                 var isGlobalAugmentation = ts.isGlobalScopeAugmentation(node);
64533                 var inAmbientContext = node.flags & 8388608;
64534                 if (isGlobalAugmentation && !inAmbientContext) {
64535                     error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_should_have_declare_modifier_unless_they_appear_in_already_ambient_context);
64536                 }
64537                 var isAmbientExternalModule = ts.isAmbientModule(node);
64538                 var contextErrorMessage = isAmbientExternalModule
64539                     ? ts.Diagnostics.An_ambient_module_declaration_is_only_allowed_at_the_top_level_in_a_file
64540                     : ts.Diagnostics.A_namespace_declaration_is_only_allowed_in_a_namespace_or_module;
64541                 if (checkGrammarModuleElementContext(node, contextErrorMessage)) {
64542                     return;
64543                 }
64544                 if (!checkGrammarDecoratorsAndModifiers(node)) {
64545                     if (!inAmbientContext && node.name.kind === 10) {
64546                         grammarErrorOnNode(node.name, ts.Diagnostics.Only_ambient_modules_can_use_quoted_names);
64547                     }
64548                 }
64549                 if (ts.isIdentifier(node.name)) {
64550                     checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
64551                     checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
64552                 }
64553                 checkExportsOnMergedDeclarations(node);
64554                 var symbol = getSymbolOfNode(node);
64555                 if (symbol.flags & 512
64556                     && !inAmbientContext
64557                     && symbol.declarations.length > 1
64558                     && isInstantiatedModule(node, ts.shouldPreserveConstEnums(compilerOptions))) {
64559                     var firstNonAmbientClassOrFunc = getFirstNonAmbientClassOrFunctionDeclaration(symbol);
64560                     if (firstNonAmbientClassOrFunc) {
64561                         if (ts.getSourceFileOfNode(node) !== ts.getSourceFileOfNode(firstNonAmbientClassOrFunc)) {
64562                             error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_in_a_different_file_from_a_class_or_function_with_which_it_is_merged);
64563                         }
64564                         else if (node.pos < firstNonAmbientClassOrFunc.pos) {
64565                             error(node.name, ts.Diagnostics.A_namespace_declaration_cannot_be_located_prior_to_a_class_or_function_with_which_it_is_merged);
64566                         }
64567                     }
64568                     var mergedClass = ts.getDeclarationOfKind(symbol, 252);
64569                     if (mergedClass &&
64570                         inSameLexicalScope(node, mergedClass)) {
64571                         getNodeLinks(node).flags |= 32768;
64572                     }
64573                 }
64574                 if (isAmbientExternalModule) {
64575                     if (ts.isExternalModuleAugmentation(node)) {
64576                         var checkBody = isGlobalAugmentation || (getSymbolOfNode(node).flags & 33554432);
64577                         if (checkBody && node.body) {
64578                             for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
64579                                 var statement = _a[_i];
64580                                 checkModuleAugmentationElement(statement, isGlobalAugmentation);
64581                             }
64582                         }
64583                     }
64584                     else if (isGlobalSourceFile(node.parent)) {
64585                         if (isGlobalAugmentation) {
64586                             error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations);
64587                         }
64588                         else if (ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(node.name))) {
64589                             error(node.name, ts.Diagnostics.Ambient_module_declaration_cannot_specify_relative_module_name);
64590                         }
64591                     }
64592                     else {
64593                         if (isGlobalAugmentation) {
64594                             error(node.name, ts.Diagnostics.Augmentations_for_the_global_scope_can_only_be_directly_nested_in_external_modules_or_ambient_module_declarations);
64595                         }
64596                         else {
64597                             error(node.name, ts.Diagnostics.Ambient_modules_cannot_be_nested_in_other_modules_or_namespaces);
64598                         }
64599                     }
64600                 }
64601             }
64602             if (node.body) {
64603                 checkSourceElement(node.body);
64604                 if (!ts.isGlobalScopeAugmentation(node)) {
64605                     registerForUnusedIdentifiersCheck(node);
64606                 }
64607             }
64608         }
64609         function checkModuleAugmentationElement(node, isGlobalAugmentation) {
64610             switch (node.kind) {
64611                 case 232:
64612                     for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
64613                         var decl = _a[_i];
64614                         checkModuleAugmentationElement(decl, isGlobalAugmentation);
64615                     }
64616                     break;
64617                 case 266:
64618                 case 267:
64619                     grammarErrorOnFirstToken(node, ts.Diagnostics.Exports_and_export_assignments_are_not_permitted_in_module_augmentations);
64620                     break;
64621                 case 260:
64622                 case 261:
64623                     grammarErrorOnFirstToken(node, ts.Diagnostics.Imports_are_not_permitted_in_module_augmentations_Consider_moving_them_to_the_enclosing_external_module);
64624                     break;
64625                 case 198:
64626                 case 249:
64627                     var name = node.name;
64628                     if (ts.isBindingPattern(name)) {
64629                         for (var _b = 0, _c = name.elements; _b < _c.length; _b++) {
64630                             var el = _c[_b];
64631                             checkModuleAugmentationElement(el, isGlobalAugmentation);
64632                         }
64633                         break;
64634                     }
64635                 case 252:
64636                 case 255:
64637                 case 251:
64638                 case 253:
64639                 case 256:
64640                 case 254:
64641                     if (isGlobalAugmentation) {
64642                         return;
64643                     }
64644                     var symbol = getSymbolOfNode(node);
64645                     if (symbol) {
64646                         var reportError = !(symbol.flags & 33554432);
64647                         if (!reportError) {
64648                             reportError = !!symbol.parent && ts.isExternalModuleAugmentation(symbol.parent.declarations[0]);
64649                         }
64650                     }
64651                     break;
64652             }
64653         }
64654         function getFirstNonModuleExportsIdentifier(node) {
64655             switch (node.kind) {
64656                 case 78:
64657                     return node;
64658                 case 157:
64659                     do {
64660                         node = node.left;
64661                     } while (node.kind !== 78);
64662                     return node;
64663                 case 201:
64664                     do {
64665                         if (ts.isModuleExportsAccessExpression(node.expression) && !ts.isPrivateIdentifier(node.name)) {
64666                             return node.name;
64667                         }
64668                         node = node.expression;
64669                     } while (node.kind !== 78);
64670                     return node;
64671             }
64672         }
64673         function checkExternalImportOrExportDeclaration(node) {
64674             var moduleName = ts.getExternalModuleName(node);
64675             if (!moduleName || ts.nodeIsMissing(moduleName)) {
64676                 return false;
64677             }
64678             if (!ts.isStringLiteral(moduleName)) {
64679                 error(moduleName, ts.Diagnostics.String_literal_expected);
64680                 return false;
64681             }
64682             var inAmbientExternalModule = node.parent.kind === 257 && ts.isAmbientModule(node.parent.parent);
64683             if (node.parent.kind !== 297 && !inAmbientExternalModule) {
64684                 error(moduleName, node.kind === 267 ?
64685                     ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace :
64686                     ts.Diagnostics.Import_declarations_in_a_namespace_cannot_reference_a_module);
64687                 return false;
64688             }
64689             if (inAmbientExternalModule && ts.isExternalModuleNameRelative(moduleName.text)) {
64690                 if (!isTopLevelInExternalModuleAugmentation(node)) {
64691                     error(node, ts.Diagnostics.Import_or_export_declaration_in_an_ambient_module_declaration_cannot_reference_module_through_relative_module_name);
64692                     return false;
64693                 }
64694             }
64695             return true;
64696         }
64697         function checkAliasSymbol(node) {
64698             var _a;
64699             var symbol = getSymbolOfNode(node);
64700             var target = resolveAlias(symbol);
64701             if (target !== unknownSymbol) {
64702                 symbol = getMergedSymbol(symbol.exportSymbol || symbol);
64703                 var excludedMeanings = (symbol.flags & (111551 | 1048576) ? 111551 : 0) |
64704                     (symbol.flags & 788968 ? 788968 : 0) |
64705                     (symbol.flags & 1920 ? 1920 : 0);
64706                 if (target.flags & excludedMeanings) {
64707                     var message = node.kind === 270 ?
64708                         ts.Diagnostics.Export_declaration_conflicts_with_exported_declaration_of_0 :
64709                         ts.Diagnostics.Import_declaration_conflicts_with_local_declaration_of_0;
64710                     error(node, message, symbolToString(symbol));
64711                 }
64712                 if (compilerOptions.isolatedModules
64713                     && node.kind === 270
64714                     && !node.parent.parent.isTypeOnly
64715                     && !(target.flags & 111551)
64716                     && !(node.flags & 8388608)) {
64717                     error(node, ts.Diagnostics.Re_exporting_a_type_when_the_isolatedModules_flag_is_provided_requires_using_export_type);
64718                 }
64719                 if (ts.isImportSpecifier(node) && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728); }))) {
64720                     addDeprecatedSuggestion(node.name, target.declarations, symbol.escapedName);
64721                 }
64722             }
64723         }
64724         function checkImportBinding(node) {
64725             checkCollisionWithRequireExportsInGeneratedCode(node, node.name);
64726             checkCollisionWithGlobalPromiseInGeneratedCode(node, node.name);
64727             checkAliasSymbol(node);
64728             if (node.kind === 265 &&
64729                 ts.idText(node.propertyName || node.name) === "default" &&
64730                 compilerOptions.esModuleInterop &&
64731                 moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) {
64732                 checkExternalEmitHelpers(node, 131072);
64733             }
64734         }
64735         function checkImportDeclaration(node) {
64736             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
64737                 return;
64738             }
64739             if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) {
64740                 grammarErrorOnFirstToken(node, ts.Diagnostics.An_import_declaration_cannot_have_modifiers);
64741             }
64742             if (checkExternalImportOrExportDeclaration(node)) {
64743                 var importClause = node.importClause;
64744                 if (importClause && !checkGrammarImportClause(importClause)) {
64745                     if (importClause.name) {
64746                         checkImportBinding(importClause);
64747                     }
64748                     if (importClause.namedBindings) {
64749                         if (importClause.namedBindings.kind === 263) {
64750                             checkImportBinding(importClause.namedBindings);
64751                             if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015 && compilerOptions.esModuleInterop) {
64752                                 checkExternalEmitHelpers(node, 65536);
64753                             }
64754                         }
64755                         else {
64756                             var moduleExisted = resolveExternalModuleName(node, node.moduleSpecifier);
64757                             if (moduleExisted) {
64758                                 ts.forEach(importClause.namedBindings.elements, checkImportBinding);
64759                             }
64760                         }
64761                     }
64762                 }
64763             }
64764         }
64765         function checkImportEqualsDeclaration(node) {
64766             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_import_declaration_can_only_be_used_in_a_namespace_or_module)) {
64767                 return;
64768             }
64769             checkGrammarDecoratorsAndModifiers(node);
64770             if (ts.isInternalModuleImportEqualsDeclaration(node) || checkExternalImportOrExportDeclaration(node)) {
64771                 checkImportBinding(node);
64772                 if (ts.hasSyntacticModifier(node, 1)) {
64773                     markExportAsReferenced(node);
64774                 }
64775                 if (node.moduleReference.kind !== 272) {
64776                     var target = resolveAlias(getSymbolOfNode(node));
64777                     if (target !== unknownSymbol) {
64778                         if (target.flags & 111551) {
64779                             var moduleName = ts.getFirstIdentifier(node.moduleReference);
64780                             if (!(resolveEntityName(moduleName, 111551 | 1920).flags & 1920)) {
64781                                 error(moduleName, ts.Diagnostics.Module_0_is_hidden_by_a_local_declaration_with_the_same_name, ts.declarationNameToString(moduleName));
64782                             }
64783                         }
64784                         if (target.flags & 788968) {
64785                             checkTypeNameIsReserved(node.name, ts.Diagnostics.Import_name_cannot_be_0);
64786                         }
64787                     }
64788                     if (node.isTypeOnly) {
64789                         grammarErrorOnNode(node, ts.Diagnostics.An_import_alias_cannot_use_import_type);
64790                     }
64791                 }
64792                 else {
64793                     if (moduleKind >= ts.ModuleKind.ES2015 && !node.isTypeOnly && !(node.flags & 8388608)) {
64794                         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);
64795                     }
64796                 }
64797             }
64798         }
64799         function checkExportDeclaration(node) {
64800             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_declaration_can_only_be_used_in_a_module)) {
64801                 return;
64802             }
64803             if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) {
64804                 grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_declaration_cannot_have_modifiers);
64805             }
64806             if (node.moduleSpecifier && node.exportClause && ts.isNamedExports(node.exportClause) && ts.length(node.exportClause.elements) && languageVersion === 0) {
64807                 checkExternalEmitHelpers(node, 2097152);
64808             }
64809             checkGrammarExportDeclaration(node);
64810             if (!node.moduleSpecifier || checkExternalImportOrExportDeclaration(node)) {
64811                 if (node.exportClause && !ts.isNamespaceExport(node.exportClause)) {
64812                     ts.forEach(node.exportClause.elements, checkExportSpecifier);
64813                     var inAmbientExternalModule = node.parent.kind === 257 && ts.isAmbientModule(node.parent.parent);
64814                     var inAmbientNamespaceDeclaration = !inAmbientExternalModule && node.parent.kind === 257 &&
64815                         !node.moduleSpecifier && node.flags & 8388608;
64816                     if (node.parent.kind !== 297 && !inAmbientExternalModule && !inAmbientNamespaceDeclaration) {
64817                         error(node, ts.Diagnostics.Export_declarations_are_not_permitted_in_a_namespace);
64818                     }
64819                 }
64820                 else {
64821                     var moduleSymbol = resolveExternalModuleName(node, node.moduleSpecifier);
64822                     if (moduleSymbol && hasExportAssignmentSymbol(moduleSymbol)) {
64823                         error(node.moduleSpecifier, ts.Diagnostics.Module_0_uses_export_and_cannot_be_used_with_export_Asterisk, symbolToString(moduleSymbol));
64824                     }
64825                     else if (node.exportClause) {
64826                         checkAliasSymbol(node.exportClause);
64827                     }
64828                     if (moduleKind !== ts.ModuleKind.System && moduleKind < ts.ModuleKind.ES2015) {
64829                         if (node.exportClause) {
64830                             if (compilerOptions.esModuleInterop) {
64831                                 checkExternalEmitHelpers(node, 65536);
64832                             }
64833                         }
64834                         else {
64835                             checkExternalEmitHelpers(node, 32768);
64836                         }
64837                     }
64838                 }
64839             }
64840         }
64841         function checkGrammarExportDeclaration(node) {
64842             var _a;
64843             var isTypeOnlyExportStar = node.isTypeOnly && ((_a = node.exportClause) === null || _a === void 0 ? void 0 : _a.kind) !== 268;
64844             if (isTypeOnlyExportStar) {
64845                 grammarErrorOnNode(node, ts.Diagnostics.Only_named_exports_may_use_export_type);
64846             }
64847             return !isTypeOnlyExportStar;
64848         }
64849         function checkGrammarModuleElementContext(node, errorMessage) {
64850             var isInAppropriateContext = node.parent.kind === 297 || node.parent.kind === 257 || node.parent.kind === 256;
64851             if (!isInAppropriateContext) {
64852                 grammarErrorOnFirstToken(node, errorMessage);
64853             }
64854             return !isInAppropriateContext;
64855         }
64856         function importClauseContainsReferencedImport(importClause) {
64857             return ts.forEachImportClauseDeclaration(importClause, function (declaration) {
64858                 return !!getSymbolOfNode(declaration).isReferenced;
64859             });
64860         }
64861         function importClauseContainsConstEnumUsedAsValue(importClause) {
64862             return ts.forEachImportClauseDeclaration(importClause, function (declaration) {
64863                 return !!getSymbolLinks(getSymbolOfNode(declaration)).constEnumReferenced;
64864             });
64865         }
64866         function canConvertImportDeclarationToTypeOnly(statement) {
64867             return ts.isImportDeclaration(statement) &&
64868                 statement.importClause &&
64869                 !statement.importClause.isTypeOnly &&
64870                 importClauseContainsReferencedImport(statement.importClause) &&
64871                 !isReferencedAliasDeclaration(statement.importClause, true) &&
64872                 !importClauseContainsConstEnumUsedAsValue(statement.importClause);
64873         }
64874         function canConvertImportEqualsDeclarationToTypeOnly(statement) {
64875             return ts.isImportEqualsDeclaration(statement) &&
64876                 ts.isExternalModuleReference(statement.moduleReference) &&
64877                 !statement.isTypeOnly &&
64878                 getSymbolOfNode(statement).isReferenced &&
64879                 !isReferencedAliasDeclaration(statement, false) &&
64880                 !getSymbolLinks(getSymbolOfNode(statement)).constEnumReferenced;
64881         }
64882         function checkImportsForTypeOnlyConversion(sourceFile) {
64883             for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
64884                 var statement = _a[_i];
64885                 if (canConvertImportDeclarationToTypeOnly(statement) || canConvertImportEqualsDeclarationToTypeOnly(statement)) {
64886                     error(statement, ts.Diagnostics.This_import_is_never_used_as_a_value_and_must_use_import_type_because_importsNotUsedAsValues_is_set_to_error);
64887                 }
64888             }
64889         }
64890         function checkExportSpecifier(node) {
64891             checkAliasSymbol(node);
64892             if (ts.getEmitDeclarations(compilerOptions)) {
64893                 collectLinkedAliases(node.propertyName || node.name, true);
64894             }
64895             if (!node.parent.parent.moduleSpecifier) {
64896                 var exportedName = node.propertyName || node.name;
64897                 var symbol = resolveName(exportedName, exportedName.escapedText, 111551 | 788968 | 1920 | 2097152, undefined, undefined, true);
64898                 if (symbol && (symbol === undefinedSymbol || symbol === globalThisSymbol || isGlobalSourceFile(getDeclarationContainer(symbol.declarations[0])))) {
64899                     error(exportedName, ts.Diagnostics.Cannot_export_0_Only_local_declarations_can_be_exported_from_a_module, ts.idText(exportedName));
64900                 }
64901                 else {
64902                     markExportAsReferenced(node);
64903                     var target = symbol && (symbol.flags & 2097152 ? resolveAlias(symbol) : symbol);
64904                     if (!target || target === unknownSymbol || target.flags & 111551) {
64905                         checkExpressionCached(node.propertyName || node.name);
64906                     }
64907                 }
64908             }
64909             else {
64910                 if (compilerOptions.esModuleInterop &&
64911                     moduleKind !== ts.ModuleKind.System &&
64912                     moduleKind < ts.ModuleKind.ES2015 &&
64913                     ts.idText(node.propertyName || node.name) === "default") {
64914                     checkExternalEmitHelpers(node, 131072);
64915                 }
64916             }
64917         }
64918         function checkExportAssignment(node) {
64919             if (checkGrammarModuleElementContext(node, ts.Diagnostics.An_export_assignment_can_only_be_used_in_a_module)) {
64920                 return;
64921             }
64922             var container = node.parent.kind === 297 ? node.parent : node.parent.parent;
64923             if (container.kind === 256 && !ts.isAmbientModule(container)) {
64924                 if (node.isExportEquals) {
64925                     error(node, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_namespace);
64926                 }
64927                 else {
64928                     error(node, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module);
64929                 }
64930                 return;
64931             }
64932             if (!checkGrammarDecoratorsAndModifiers(node) && ts.hasEffectiveModifiers(node)) {
64933                 grammarErrorOnFirstToken(node, ts.Diagnostics.An_export_assignment_cannot_have_modifiers);
64934             }
64935             if (node.expression.kind === 78) {
64936                 var id = node.expression;
64937                 var sym = resolveEntityName(id, 67108863, true, true, node);
64938                 if (sym) {
64939                     markAliasReferenced(sym, id);
64940                     var target = sym.flags & 2097152 ? resolveAlias(sym) : sym;
64941                     if (target === unknownSymbol || target.flags & 111551) {
64942                         checkExpressionCached(node.expression);
64943                     }
64944                 }
64945                 else {
64946                     checkExpressionCached(node.expression);
64947                 }
64948                 if (ts.getEmitDeclarations(compilerOptions)) {
64949                     collectLinkedAliases(node.expression, true);
64950                 }
64951             }
64952             else {
64953                 checkExpressionCached(node.expression);
64954             }
64955             checkExternalModuleExports(container);
64956             if ((node.flags & 8388608) && !ts.isEntityNameExpression(node.expression)) {
64957                 grammarErrorOnNode(node.expression, ts.Diagnostics.The_expression_of_an_export_assignment_must_be_an_identifier_or_qualified_name_in_an_ambient_context);
64958             }
64959             if (node.isExportEquals && !(node.flags & 8388608)) {
64960                 if (moduleKind >= ts.ModuleKind.ES2015) {
64961                     grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);
64962                 }
64963                 else if (moduleKind === ts.ModuleKind.System) {
64964                     grammarErrorOnNode(node, ts.Diagnostics.Export_assignment_is_not_supported_when_module_flag_is_system);
64965                 }
64966             }
64967         }
64968         function hasExportedMembers(moduleSymbol) {
64969             return ts.forEachEntry(moduleSymbol.exports, function (_, id) { return id !== "export="; });
64970         }
64971         function checkExternalModuleExports(node) {
64972             var moduleSymbol = getSymbolOfNode(node);
64973             var links = getSymbolLinks(moduleSymbol);
64974             if (!links.exportsChecked) {
64975                 var exportEqualsSymbol = moduleSymbol.exports.get("export=");
64976                 if (exportEqualsSymbol && hasExportedMembers(moduleSymbol)) {
64977                     var declaration = getDeclarationOfAliasSymbol(exportEqualsSymbol) || exportEqualsSymbol.valueDeclaration;
64978                     if (!isTopLevelInExternalModuleAugmentation(declaration) && !ts.isInJSFile(declaration)) {
64979                         error(declaration, ts.Diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements);
64980                     }
64981                 }
64982                 var exports_2 = getExportsOfModule(moduleSymbol);
64983                 if (exports_2) {
64984                     exports_2.forEach(function (_a, id) {
64985                         var declarations = _a.declarations, flags = _a.flags;
64986                         if (id === "__export") {
64987                             return;
64988                         }
64989                         if (flags & (1920 | 64 | 384)) {
64990                             return;
64991                         }
64992                         var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor);
64993                         if (flags & 524288 && exportedDeclarationsCount <= 2) {
64994                             return;
64995                         }
64996                         if (exportedDeclarationsCount > 1) {
64997                             for (var _i = 0, declarations_9 = declarations; _i < declarations_9.length; _i++) {
64998                                 var declaration = declarations_9[_i];
64999                                 if (isNotOverload(declaration)) {
65000                                     diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Cannot_redeclare_exported_variable_0, ts.unescapeLeadingUnderscores(id)));
65001                                 }
65002                             }
65003                         }
65004                     });
65005                 }
65006                 links.exportsChecked = true;
65007             }
65008         }
65009         function checkSourceElement(node) {
65010             if (node) {
65011                 var saveCurrentNode = currentNode;
65012                 currentNode = node;
65013                 instantiationCount = 0;
65014                 checkSourceElementWorker(node);
65015                 currentNode = saveCurrentNode;
65016             }
65017         }
65018         function checkSourceElementWorker(node) {
65019             if (ts.isInJSFile(node)) {
65020                 ts.forEach(node.jsDoc, function (_a) {
65021                     var tags = _a.tags;
65022                     return ts.forEach(tags, checkSourceElement);
65023                 });
65024             }
65025             var kind = node.kind;
65026             if (cancellationToken) {
65027                 switch (kind) {
65028                     case 256:
65029                     case 252:
65030                     case 253:
65031                     case 251:
65032                         cancellationToken.throwIfCancellationRequested();
65033                 }
65034             }
65035             if (kind >= 232 && kind <= 248 && node.flowNode && !isReachableFlowNode(node.flowNode)) {
65036                 errorOrSuggestion(compilerOptions.allowUnreachableCode === false, node, ts.Diagnostics.Unreachable_code_detected);
65037             }
65038             switch (kind) {
65039                 case 159:
65040                     return checkTypeParameter(node);
65041                 case 160:
65042                     return checkParameter(node);
65043                 case 163:
65044                     return checkPropertyDeclaration(node);
65045                 case 162:
65046                     return checkPropertySignature(node);
65047                 case 175:
65048                 case 174:
65049                 case 169:
65050                 case 170:
65051                 case 171:
65052                     return checkSignatureDeclaration(node);
65053                 case 165:
65054                 case 164:
65055                     return checkMethodDeclaration(node);
65056                 case 166:
65057                     return checkConstructorDeclaration(node);
65058                 case 167:
65059                 case 168:
65060                     return checkAccessorDeclaration(node);
65061                 case 173:
65062                     return checkTypeReferenceNode(node);
65063                 case 172:
65064                     return checkTypePredicate(node);
65065                 case 176:
65066                     return checkTypeQuery(node);
65067                 case 177:
65068                     return checkTypeLiteral(node);
65069                 case 178:
65070                     return checkArrayType(node);
65071                 case 179:
65072                     return checkTupleType(node);
65073                 case 182:
65074                 case 183:
65075                     return checkUnionOrIntersectionType(node);
65076                 case 186:
65077                 case 180:
65078                 case 181:
65079                     return checkSourceElement(node.type);
65080                 case 187:
65081                     return checkThisType(node);
65082                 case 188:
65083                     return checkTypeOperator(node);
65084                 case 184:
65085                     return checkConditionalType(node);
65086                 case 185:
65087                     return checkInferType(node);
65088                 case 193:
65089                     return checkTemplateLiteralType(node);
65090                 case 195:
65091                     return checkImportType(node);
65092                 case 192:
65093                     return checkNamedTupleMember(node);
65094                 case 315:
65095                     return checkJSDocAugmentsTag(node);
65096                 case 316:
65097                     return checkJSDocImplementsTag(node);
65098                 case 331:
65099                 case 324:
65100                 case 325:
65101                     return checkJSDocTypeAliasTag(node);
65102                 case 330:
65103                     return checkJSDocTemplateTag(node);
65104                 case 329:
65105                     return checkJSDocTypeTag(node);
65106                 case 326:
65107                     return checkJSDocParameterTag(node);
65108                 case 333:
65109                     return checkJSDocPropertyTag(node);
65110                 case 308:
65111                     checkJSDocFunctionType(node);
65112                 case 306:
65113                 case 305:
65114                 case 303:
65115                 case 304:
65116                 case 312:
65117                     checkJSDocTypeIsInJsFile(node);
65118                     ts.forEachChild(node, checkSourceElement);
65119                     return;
65120                 case 309:
65121                     checkJSDocVariadicType(node);
65122                     return;
65123                 case 301:
65124                     return checkSourceElement(node.type);
65125                 case 189:
65126                     return checkIndexedAccessType(node);
65127                 case 190:
65128                     return checkMappedType(node);
65129                 case 251:
65130                     return checkFunctionDeclaration(node);
65131                 case 230:
65132                 case 257:
65133                     return checkBlock(node);
65134                 case 232:
65135                     return checkVariableStatement(node);
65136                 case 233:
65137                     return checkExpressionStatement(node);
65138                 case 234:
65139                     return checkIfStatement(node);
65140                 case 235:
65141                     return checkDoStatement(node);
65142                 case 236:
65143                     return checkWhileStatement(node);
65144                 case 237:
65145                     return checkForStatement(node);
65146                 case 238:
65147                     return checkForInStatement(node);
65148                 case 239:
65149                     return checkForOfStatement(node);
65150                 case 240:
65151                 case 241:
65152                     return checkBreakOrContinueStatement(node);
65153                 case 242:
65154                     return checkReturnStatement(node);
65155                 case 243:
65156                     return checkWithStatement(node);
65157                 case 244:
65158                     return checkSwitchStatement(node);
65159                 case 245:
65160                     return checkLabeledStatement(node);
65161                 case 246:
65162                     return checkThrowStatement(node);
65163                 case 247:
65164                     return checkTryStatement(node);
65165                 case 249:
65166                     return checkVariableDeclaration(node);
65167                 case 198:
65168                     return checkBindingElement(node);
65169                 case 252:
65170                     return checkClassDeclaration(node);
65171                 case 253:
65172                     return checkInterfaceDeclaration(node);
65173                 case 254:
65174                     return checkTypeAliasDeclaration(node);
65175                 case 255:
65176                     return checkEnumDeclaration(node);
65177                 case 256:
65178                     return checkModuleDeclaration(node);
65179                 case 261:
65180                     return checkImportDeclaration(node);
65181                 case 260:
65182                     return checkImportEqualsDeclaration(node);
65183                 case 267:
65184                     return checkExportDeclaration(node);
65185                 case 266:
65186                     return checkExportAssignment(node);
65187                 case 231:
65188                 case 248:
65189                     checkGrammarStatementInAmbientContext(node);
65190                     return;
65191                 case 271:
65192                     return checkMissingDeclaration(node);
65193             }
65194         }
65195         function checkJSDocTypeIsInJsFile(node) {
65196             if (!ts.isInJSFile(node)) {
65197                 grammarErrorOnNode(node, ts.Diagnostics.JSDoc_types_can_only_be_used_inside_documentation_comments);
65198             }
65199         }
65200         function checkJSDocVariadicType(node) {
65201             checkJSDocTypeIsInJsFile(node);
65202             checkSourceElement(node.type);
65203             var parent = node.parent;
65204             if (ts.isParameter(parent) && ts.isJSDocFunctionType(parent.parent)) {
65205                 if (ts.last(parent.parent.parameters) !== parent) {
65206                     error(node, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
65207                 }
65208                 return;
65209             }
65210             if (!ts.isJSDocTypeExpression(parent)) {
65211                 error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature);
65212             }
65213             var paramTag = node.parent.parent;
65214             if (!ts.isJSDocParameterTag(paramTag)) {
65215                 error(node, ts.Diagnostics.JSDoc_may_only_appear_in_the_last_parameter_of_a_signature);
65216                 return;
65217             }
65218             var param = ts.getParameterSymbolFromJSDoc(paramTag);
65219             if (!param) {
65220                 return;
65221             }
65222             var host = ts.getHostSignatureFromJSDoc(paramTag);
65223             if (!host || ts.last(host.parameters).symbol !== param) {
65224                 error(node, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
65225             }
65226         }
65227         function getTypeFromJSDocVariadicType(node) {
65228             var type = getTypeFromTypeNode(node.type);
65229             var parent = node.parent;
65230             var paramTag = node.parent.parent;
65231             if (ts.isJSDocTypeExpression(node.parent) && ts.isJSDocParameterTag(paramTag)) {
65232                 var host_1 = ts.getHostSignatureFromJSDoc(paramTag);
65233                 if (host_1) {
65234                     var lastParamDeclaration = ts.lastOrUndefined(host_1.parameters);
65235                     var symbol = ts.getParameterSymbolFromJSDoc(paramTag);
65236                     if (!lastParamDeclaration ||
65237                         symbol && lastParamDeclaration.symbol === symbol && ts.isRestParameter(lastParamDeclaration)) {
65238                         return createArrayType(type);
65239                     }
65240                 }
65241             }
65242             if (ts.isParameter(parent) && ts.isJSDocFunctionType(parent.parent)) {
65243                 return createArrayType(type);
65244             }
65245             return addOptionality(type);
65246         }
65247         function checkNodeDeferred(node) {
65248             var enclosingFile = ts.getSourceFileOfNode(node);
65249             var links = getNodeLinks(enclosingFile);
65250             if (!(links.flags & 1)) {
65251                 links.deferredNodes = links.deferredNodes || new ts.Map();
65252                 var id = getNodeId(node);
65253                 links.deferredNodes.set(id, node);
65254             }
65255         }
65256         function checkDeferredNodes(context) {
65257             var links = getNodeLinks(context);
65258             if (links.deferredNodes) {
65259                 links.deferredNodes.forEach(checkDeferredNode);
65260             }
65261         }
65262         function checkDeferredNode(node) {
65263             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check", "checkDeferredNode", { kind: node.kind, pos: node.pos, end: node.end });
65264             var saveCurrentNode = currentNode;
65265             currentNode = node;
65266             instantiationCount = 0;
65267             switch (node.kind) {
65268                 case 203:
65269                 case 204:
65270                 case 205:
65271                 case 161:
65272                 case 275:
65273                     resolveUntypedCall(node);
65274                     break;
65275                 case 208:
65276                 case 209:
65277                 case 165:
65278                 case 164:
65279                     checkFunctionExpressionOrObjectLiteralMethodDeferred(node);
65280                     break;
65281                 case 167:
65282                 case 168:
65283                     checkAccessorDeclaration(node);
65284                     break;
65285                 case 221:
65286                     checkClassExpressionDeferred(node);
65287                     break;
65288                 case 274:
65289                     checkJsxSelfClosingElementDeferred(node);
65290                     break;
65291                 case 273:
65292                     checkJsxElementDeferred(node);
65293                     break;
65294             }
65295             currentNode = saveCurrentNode;
65296             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
65297         }
65298         function checkSourceFile(node) {
65299             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("check", "checkSourceFile", { path: node.path }, true);
65300             ts.performance.mark("beforeCheck");
65301             checkSourceFileWorker(node);
65302             ts.performance.mark("afterCheck");
65303             ts.performance.measure("Check", "beforeCheck", "afterCheck");
65304             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
65305         }
65306         function unusedIsError(kind, isAmbient) {
65307             if (isAmbient) {
65308                 return false;
65309             }
65310             switch (kind) {
65311                 case 0:
65312                     return !!compilerOptions.noUnusedLocals;
65313                 case 1:
65314                     return !!compilerOptions.noUnusedParameters;
65315                 default:
65316                     return ts.Debug.assertNever(kind);
65317             }
65318         }
65319         function getPotentiallyUnusedIdentifiers(sourceFile) {
65320             return allPotentiallyUnusedIdentifiers.get(sourceFile.path) || ts.emptyArray;
65321         }
65322         function checkSourceFileWorker(node) {
65323             var links = getNodeLinks(node);
65324             if (!(links.flags & 1)) {
65325                 if (ts.skipTypeChecking(node, compilerOptions, host)) {
65326                     return;
65327                 }
65328                 checkGrammarSourceFile(node);
65329                 ts.clear(potentialThisCollisions);
65330                 ts.clear(potentialNewTargetCollisions);
65331                 ts.clear(potentialWeakMapCollisions);
65332                 ts.forEach(node.statements, checkSourceElement);
65333                 checkSourceElement(node.endOfFileToken);
65334                 checkDeferredNodes(node);
65335                 if (ts.isExternalOrCommonJsModule(node)) {
65336                     registerForUnusedIdentifiersCheck(node);
65337                 }
65338                 if (!node.isDeclarationFile && (compilerOptions.noUnusedLocals || compilerOptions.noUnusedParameters)) {
65339                     checkUnusedIdentifiers(getPotentiallyUnusedIdentifiers(node), function (containingNode, kind, diag) {
65340                         if (!ts.containsParseError(containingNode) && unusedIsError(kind, !!(containingNode.flags & 8388608))) {
65341                             diagnostics.add(diag);
65342                         }
65343                     });
65344                 }
65345                 if (compilerOptions.importsNotUsedAsValues === 2 &&
65346                     !node.isDeclarationFile &&
65347                     ts.isExternalModule(node)) {
65348                     checkImportsForTypeOnlyConversion(node);
65349                 }
65350                 if (ts.isExternalOrCommonJsModule(node)) {
65351                     checkExternalModuleExports(node);
65352                 }
65353                 if (potentialThisCollisions.length) {
65354                     ts.forEach(potentialThisCollisions, checkIfThisIsCapturedInEnclosingScope);
65355                     ts.clear(potentialThisCollisions);
65356                 }
65357                 if (potentialNewTargetCollisions.length) {
65358                     ts.forEach(potentialNewTargetCollisions, checkIfNewTargetIsCapturedInEnclosingScope);
65359                     ts.clear(potentialNewTargetCollisions);
65360                 }
65361                 if (potentialWeakMapCollisions.length) {
65362                     ts.forEach(potentialWeakMapCollisions, checkWeakMapCollision);
65363                     ts.clear(potentialWeakMapCollisions);
65364                 }
65365                 links.flags |= 1;
65366             }
65367         }
65368         function getDiagnostics(sourceFile, ct) {
65369             try {
65370                 cancellationToken = ct;
65371                 return getDiagnosticsWorker(sourceFile);
65372             }
65373             finally {
65374                 cancellationToken = undefined;
65375             }
65376         }
65377         function getDiagnosticsWorker(sourceFile) {
65378             throwIfNonDiagnosticsProducing();
65379             if (sourceFile) {
65380                 var previousGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
65381                 var previousGlobalDiagnosticsSize = previousGlobalDiagnostics.length;
65382                 checkSourceFile(sourceFile);
65383                 var semanticDiagnostics = diagnostics.getDiagnostics(sourceFile.fileName);
65384                 var currentGlobalDiagnostics = diagnostics.getGlobalDiagnostics();
65385                 if (currentGlobalDiagnostics !== previousGlobalDiagnostics) {
65386                     var deferredGlobalDiagnostics = ts.relativeComplement(previousGlobalDiagnostics, currentGlobalDiagnostics, ts.compareDiagnostics);
65387                     return ts.concatenate(deferredGlobalDiagnostics, semanticDiagnostics);
65388                 }
65389                 else if (previousGlobalDiagnosticsSize === 0 && currentGlobalDiagnostics.length > 0) {
65390                     return ts.concatenate(currentGlobalDiagnostics, semanticDiagnostics);
65391                 }
65392                 return semanticDiagnostics;
65393             }
65394             ts.forEach(host.getSourceFiles(), checkSourceFile);
65395             return diagnostics.getDiagnostics();
65396         }
65397         function getGlobalDiagnostics() {
65398             throwIfNonDiagnosticsProducing();
65399             return diagnostics.getGlobalDiagnostics();
65400         }
65401         function throwIfNonDiagnosticsProducing() {
65402             if (!produceDiagnostics) {
65403                 throw new Error("Trying to get diagnostics from a type checker that does not produce them.");
65404             }
65405         }
65406         function getSymbolsInScope(location, meaning) {
65407             if (location.flags & 16777216) {
65408                 return [];
65409             }
65410             var symbols = ts.createSymbolTable();
65411             var isStatic = false;
65412             populateSymbols();
65413             symbols.delete("this");
65414             return symbolsToArray(symbols);
65415             function populateSymbols() {
65416                 while (location) {
65417                     if (location.locals && !isGlobalSourceFile(location)) {
65418                         copySymbols(location.locals, meaning);
65419                     }
65420                     switch (location.kind) {
65421                         case 297:
65422                             if (!ts.isExternalOrCommonJsModule(location))
65423                                 break;
65424                         case 256:
65425                             copySymbols(getSymbolOfNode(location).exports, meaning & 2623475);
65426                             break;
65427                         case 255:
65428                             copySymbols(getSymbolOfNode(location).exports, meaning & 8);
65429                             break;
65430                         case 221:
65431                             var className = location.name;
65432                             if (className) {
65433                                 copySymbol(location.symbol, meaning);
65434                             }
65435                         case 252:
65436                         case 253:
65437                             if (!isStatic) {
65438                                 copySymbols(getMembersOfSymbol(getSymbolOfNode(location)), meaning & 788968);
65439                             }
65440                             break;
65441                         case 208:
65442                             var funcName = location.name;
65443                             if (funcName) {
65444                                 copySymbol(location.symbol, meaning);
65445                             }
65446                             break;
65447                     }
65448                     if (ts.introducesArgumentsExoticObject(location)) {
65449                         copySymbol(argumentsSymbol, meaning);
65450                     }
65451                     isStatic = ts.hasSyntacticModifier(location, 32);
65452                     location = location.parent;
65453                 }
65454                 copySymbols(globals, meaning);
65455             }
65456             function copySymbol(symbol, meaning) {
65457                 if (ts.getCombinedLocalAndExportSymbolFlags(symbol) & meaning) {
65458                     var id = symbol.escapedName;
65459                     if (!symbols.has(id)) {
65460                         symbols.set(id, symbol);
65461                     }
65462                 }
65463             }
65464             function copySymbols(source, meaning) {
65465                 if (meaning) {
65466                     source.forEach(function (symbol) {
65467                         copySymbol(symbol, meaning);
65468                     });
65469                 }
65470             }
65471         }
65472         function isTypeDeclarationName(name) {
65473             return name.kind === 78 &&
65474                 isTypeDeclaration(name.parent) &&
65475                 ts.getNameOfDeclaration(name.parent) === name;
65476         }
65477         function isTypeDeclaration(node) {
65478             switch (node.kind) {
65479                 case 159:
65480                 case 252:
65481                 case 253:
65482                 case 254:
65483                 case 255:
65484                 case 331:
65485                 case 324:
65486                 case 325:
65487                     return true;
65488                 case 262:
65489                     return node.isTypeOnly;
65490                 case 265:
65491                 case 270:
65492                     return node.parent.parent.isTypeOnly;
65493                 default:
65494                     return false;
65495             }
65496         }
65497         function isTypeReferenceIdentifier(node) {
65498             while (node.parent.kind === 157) {
65499                 node = node.parent;
65500             }
65501             return node.parent.kind === 173;
65502         }
65503         function isHeritageClauseElementIdentifier(node) {
65504             while (node.parent.kind === 201) {
65505                 node = node.parent;
65506             }
65507             return node.parent.kind === 223;
65508         }
65509         function isJSDocEntryNameReference(node) {
65510             while (node.parent.kind === 157) {
65511                 node = node.parent;
65512             }
65513             while (node.parent.kind === 201) {
65514                 node = node.parent;
65515             }
65516             return node.parent.kind === 302;
65517         }
65518         function forEachEnclosingClass(node, callback) {
65519             var result;
65520             while (true) {
65521                 node = ts.getContainingClass(node);
65522                 if (!node)
65523                     break;
65524                 if (result = callback(node))
65525                     break;
65526             }
65527             return result;
65528         }
65529         function isNodeUsedDuringClassInitialization(node) {
65530             return !!ts.findAncestor(node, function (element) {
65531                 if (ts.isConstructorDeclaration(element) && ts.nodeIsPresent(element.body) || ts.isPropertyDeclaration(element)) {
65532                     return true;
65533                 }
65534                 else if (ts.isClassLike(element) || ts.isFunctionLikeDeclaration(element)) {
65535                     return "quit";
65536                 }
65537                 return false;
65538             });
65539         }
65540         function isNodeWithinClass(node, classDeclaration) {
65541             return !!forEachEnclosingClass(node, function (n) { return n === classDeclaration; });
65542         }
65543         function getLeftSideOfImportEqualsOrExportAssignment(nodeOnRightSide) {
65544             while (nodeOnRightSide.parent.kind === 157) {
65545                 nodeOnRightSide = nodeOnRightSide.parent;
65546             }
65547             if (nodeOnRightSide.parent.kind === 260) {
65548                 return nodeOnRightSide.parent.moduleReference === nodeOnRightSide ? nodeOnRightSide.parent : undefined;
65549             }
65550             if (nodeOnRightSide.parent.kind === 266) {
65551                 return nodeOnRightSide.parent.expression === nodeOnRightSide ? nodeOnRightSide.parent : undefined;
65552             }
65553             return undefined;
65554         }
65555         function isInRightSideOfImportOrExportAssignment(node) {
65556             return getLeftSideOfImportEqualsOrExportAssignment(node) !== undefined;
65557         }
65558         function getSpecialPropertyAssignmentSymbolFromEntityName(entityName) {
65559             var specialPropertyAssignmentKind = ts.getAssignmentDeclarationKind(entityName.parent.parent);
65560             switch (specialPropertyAssignmentKind) {
65561                 case 1:
65562                 case 3:
65563                     return getSymbolOfNode(entityName.parent);
65564                 case 4:
65565                 case 2:
65566                 case 5:
65567                     return getSymbolOfNode(entityName.parent.parent);
65568             }
65569         }
65570         function isImportTypeQualifierPart(node) {
65571             var parent = node.parent;
65572             while (ts.isQualifiedName(parent)) {
65573                 node = parent;
65574                 parent = parent.parent;
65575             }
65576             if (parent && parent.kind === 195 && parent.qualifier === node) {
65577                 return parent;
65578             }
65579             return undefined;
65580         }
65581         function getSymbolOfNameOrPropertyAccessExpression(name) {
65582             if (ts.isDeclarationName(name)) {
65583                 return getSymbolOfNode(name.parent);
65584             }
65585             if (ts.isInJSFile(name) &&
65586                 name.parent.kind === 201 &&
65587                 name.parent === name.parent.parent.left) {
65588                 if (!ts.isPrivateIdentifier(name)) {
65589                     var specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(name);
65590                     if (specialPropertyAssignmentSymbol) {
65591                         return specialPropertyAssignmentSymbol;
65592                     }
65593                 }
65594             }
65595             if (name.parent.kind === 266 && ts.isEntityNameExpression(name)) {
65596                 var success = resolveEntityName(name, 111551 | 788968 | 1920 | 2097152, true);
65597                 if (success && success !== unknownSymbol) {
65598                     return success;
65599                 }
65600             }
65601             else if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name) && isInRightSideOfImportOrExportAssignment(name)) {
65602                 var importEqualsDeclaration = ts.getAncestor(name, 260);
65603                 ts.Debug.assert(importEqualsDeclaration !== undefined);
65604                 return getSymbolOfPartOfRightHandSideOfImportEquals(name, true);
65605             }
65606             if (!ts.isPropertyAccessExpression(name) && !ts.isPrivateIdentifier(name)) {
65607                 var possibleImportNode = isImportTypeQualifierPart(name);
65608                 if (possibleImportNode) {
65609                     getTypeFromTypeNode(possibleImportNode);
65610                     var sym = getNodeLinks(name).resolvedSymbol;
65611                     return sym === unknownSymbol ? undefined : sym;
65612                 }
65613             }
65614             while (ts.isRightSideOfQualifiedNameOrPropertyAccess(name)) {
65615                 name = name.parent;
65616             }
65617             if (isHeritageClauseElementIdentifier(name)) {
65618                 var meaning = 0;
65619                 if (name.parent.kind === 223) {
65620                     meaning = 788968;
65621                     if (ts.isExpressionWithTypeArgumentsInClassExtendsClause(name.parent)) {
65622                         meaning |= 111551;
65623                     }
65624                 }
65625                 else {
65626                     meaning = 1920;
65627                 }
65628                 meaning |= 2097152;
65629                 var entityNameSymbol = ts.isEntityNameExpression(name) ? resolveEntityName(name, meaning) : undefined;
65630                 if (entityNameSymbol) {
65631                     return entityNameSymbol;
65632                 }
65633             }
65634             if (name.parent.kind === 326) {
65635                 return ts.getParameterSymbolFromJSDoc(name.parent);
65636             }
65637             if (name.parent.kind === 159 && name.parent.parent.kind === 330) {
65638                 ts.Debug.assert(!ts.isInJSFile(name));
65639                 var typeParameter = ts.getTypeParameterFromJsDoc(name.parent);
65640                 return typeParameter && typeParameter.symbol;
65641             }
65642             if (ts.isExpressionNode(name)) {
65643                 if (ts.nodeIsMissing(name)) {
65644                     return undefined;
65645                 }
65646                 if (name.kind === 78) {
65647                     if (ts.isJSXTagName(name) && isJsxIntrinsicIdentifier(name)) {
65648                         var symbol = getIntrinsicTagSymbol(name.parent);
65649                         return symbol === unknownSymbol ? undefined : symbol;
65650                     }
65651                     return resolveEntityName(name, 111551, false, true);
65652                 }
65653                 else if (name.kind === 201 || name.kind === 157) {
65654                     var links = getNodeLinks(name);
65655                     if (links.resolvedSymbol) {
65656                         return links.resolvedSymbol;
65657                     }
65658                     if (name.kind === 201) {
65659                         checkPropertyAccessExpression(name);
65660                     }
65661                     else {
65662                         checkQualifiedName(name);
65663                     }
65664                     return links.resolvedSymbol;
65665                 }
65666             }
65667             else if (isTypeReferenceIdentifier(name)) {
65668                 var meaning = name.parent.kind === 173 ? 788968 : 1920;
65669                 return resolveEntityName(name, meaning, false, true);
65670             }
65671             else if (isJSDocEntryNameReference(name)) {
65672                 var meaning = 788968 | 1920 | 111551;
65673                 return resolveEntityName(name, meaning, false, true, ts.getHostSignatureFromJSDoc(name));
65674             }
65675             if (name.parent.kind === 172) {
65676                 return resolveEntityName(name, 1);
65677             }
65678             return undefined;
65679         }
65680         function getSymbolAtLocation(node, ignoreErrors) {
65681             if (node.kind === 297) {
65682                 return ts.isExternalModule(node) ? getMergedSymbol(node.symbol) : undefined;
65683             }
65684             var parent = node.parent;
65685             var grandParent = parent.parent;
65686             if (node.flags & 16777216) {
65687                 return undefined;
65688             }
65689             if (isDeclarationNameOrImportPropertyName(node)) {
65690                 var parentSymbol = getSymbolOfNode(parent);
65691                 return ts.isImportOrExportSpecifier(node.parent) && node.parent.propertyName === node
65692                     ? getImmediateAliasedSymbol(parentSymbol)
65693                     : parentSymbol;
65694             }
65695             else if (ts.isLiteralComputedPropertyDeclarationName(node)) {
65696                 return getSymbolOfNode(parent.parent);
65697             }
65698             if (node.kind === 78) {
65699                 if (isInRightSideOfImportOrExportAssignment(node)) {
65700                     return getSymbolOfNameOrPropertyAccessExpression(node);
65701                 }
65702                 else if (parent.kind === 198 &&
65703                     grandParent.kind === 196 &&
65704                     node === parent.propertyName) {
65705                     var typeOfPattern = getTypeOfNode(grandParent);
65706                     var propertyDeclaration = getPropertyOfType(typeOfPattern, node.escapedText);
65707                     if (propertyDeclaration) {
65708                         return propertyDeclaration;
65709                     }
65710                 }
65711             }
65712             switch (node.kind) {
65713                 case 78:
65714                 case 79:
65715                 case 201:
65716                 case 157:
65717                     return getSymbolOfNameOrPropertyAccessExpression(node);
65718                 case 107:
65719                     var container = ts.getThisContainer(node, false);
65720                     if (ts.isFunctionLike(container)) {
65721                         var sig = getSignatureFromDeclaration(container);
65722                         if (sig.thisParameter) {
65723                             return sig.thisParameter;
65724                         }
65725                     }
65726                     if (ts.isInExpressionContext(node)) {
65727                         return checkExpression(node).symbol;
65728                     }
65729                 case 187:
65730                     return getTypeFromThisTypeNode(node).symbol;
65731                 case 105:
65732                     return checkExpression(node).symbol;
65733                 case 132:
65734                     var constructorDeclaration = node.parent;
65735                     if (constructorDeclaration && constructorDeclaration.kind === 166) {
65736                         return constructorDeclaration.parent.symbol;
65737                     }
65738                     return undefined;
65739                 case 10:
65740                 case 14:
65741                     if ((ts.isExternalModuleImportEqualsDeclaration(node.parent.parent) && ts.getExternalModuleImportEqualsDeclarationExpression(node.parent.parent) === node) ||
65742                         ((node.parent.kind === 261 || node.parent.kind === 267) && node.parent.moduleSpecifier === node) ||
65743                         ((ts.isInJSFile(node) && ts.isRequireCall(node.parent, false)) || ts.isImportCall(node.parent)) ||
65744                         (ts.isLiteralTypeNode(node.parent) && ts.isLiteralImportTypeNode(node.parent.parent) && node.parent.parent.argument === node.parent)) {
65745                         return resolveExternalModuleName(node, node, ignoreErrors);
65746                     }
65747                     if (ts.isCallExpression(parent) && ts.isBindableObjectDefinePropertyCall(parent) && parent.arguments[1] === node) {
65748                         return getSymbolOfNode(parent);
65749                     }
65750                 case 8:
65751                     var objectType = ts.isElementAccessExpression(parent)
65752                         ? parent.argumentExpression === node ? getTypeOfExpression(parent.expression) : undefined
65753                         : ts.isLiteralTypeNode(parent) && ts.isIndexedAccessTypeNode(grandParent)
65754                             ? getTypeFromTypeNode(grandParent.objectType)
65755                             : undefined;
65756                     return objectType && getPropertyOfType(objectType, ts.escapeLeadingUnderscores(node.text));
65757                 case 87:
65758                 case 97:
65759                 case 38:
65760                 case 83:
65761                     return getSymbolOfNode(node.parent);
65762                 case 195:
65763                     return ts.isLiteralImportTypeNode(node) ? getSymbolAtLocation(node.argument.literal, ignoreErrors) : undefined;
65764                 case 92:
65765                     return ts.isExportAssignment(node.parent) ? ts.Debug.checkDefined(node.parent.symbol) : undefined;
65766                 default:
65767                     return undefined;
65768             }
65769         }
65770         function getShorthandAssignmentValueSymbol(location) {
65771             if (location && location.kind === 289) {
65772                 return resolveEntityName(location.name, 111551 | 2097152);
65773             }
65774             return undefined;
65775         }
65776         function getExportSpecifierLocalTargetSymbol(node) {
65777             if (ts.isExportSpecifier(node)) {
65778                 return node.parent.parent.moduleSpecifier ?
65779                     getExternalModuleMember(node.parent.parent, node) :
65780                     resolveEntityName(node.propertyName || node.name, 111551 | 788968 | 1920 | 2097152);
65781             }
65782             else {
65783                 return resolveEntityName(node, 111551 | 788968 | 1920 | 2097152);
65784             }
65785         }
65786         function getTypeOfNode(node) {
65787             if (ts.isSourceFile(node) && !ts.isExternalModule(node)) {
65788                 return errorType;
65789             }
65790             if (node.flags & 16777216) {
65791                 return errorType;
65792             }
65793             var classDecl = ts.tryGetClassImplementingOrExtendingExpressionWithTypeArguments(node);
65794             var classType = classDecl && getDeclaredTypeOfClassOrInterface(getSymbolOfNode(classDecl.class));
65795             if (ts.isPartOfTypeNode(node)) {
65796                 var typeFromTypeNode = getTypeFromTypeNode(node);
65797                 return classType ? getTypeWithThisArgument(typeFromTypeNode, classType.thisType) : typeFromTypeNode;
65798             }
65799             if (ts.isExpressionNode(node)) {
65800                 return getRegularTypeOfExpression(node);
65801             }
65802             if (classType && !classDecl.isImplements) {
65803                 var baseType = ts.firstOrUndefined(getBaseTypes(classType));
65804                 return baseType ? getTypeWithThisArgument(baseType, classType.thisType) : errorType;
65805             }
65806             if (isTypeDeclaration(node)) {
65807                 var symbol = getSymbolOfNode(node);
65808                 return getDeclaredTypeOfSymbol(symbol);
65809             }
65810             if (isTypeDeclarationName(node)) {
65811                 var symbol = getSymbolAtLocation(node);
65812                 return symbol ? getDeclaredTypeOfSymbol(symbol) : errorType;
65813             }
65814             if (ts.isDeclaration(node)) {
65815                 var symbol = getSymbolOfNode(node);
65816                 return getTypeOfSymbol(symbol);
65817             }
65818             if (isDeclarationNameOrImportPropertyName(node)) {
65819                 var symbol = getSymbolAtLocation(node);
65820                 if (symbol) {
65821                     return getTypeOfSymbol(symbol);
65822                 }
65823                 return errorType;
65824             }
65825             if (ts.isBindingPattern(node)) {
65826                 return getTypeForVariableLikeDeclaration(node.parent, true) || errorType;
65827             }
65828             if (isInRightSideOfImportOrExportAssignment(node)) {
65829                 var symbol = getSymbolAtLocation(node);
65830                 if (symbol) {
65831                     var declaredType = getDeclaredTypeOfSymbol(symbol);
65832                     return declaredType !== errorType ? declaredType : getTypeOfSymbol(symbol);
65833                 }
65834             }
65835             return errorType;
65836         }
65837         function getTypeOfAssignmentPattern(expr) {
65838             ts.Debug.assert(expr.kind === 200 || expr.kind === 199);
65839             if (expr.parent.kind === 239) {
65840                 var iteratedType = checkRightHandSideOfForOf(expr.parent);
65841                 return checkDestructuringAssignment(expr, iteratedType || errorType);
65842             }
65843             if (expr.parent.kind === 216) {
65844                 var iteratedType = getTypeOfExpression(expr.parent.right);
65845                 return checkDestructuringAssignment(expr, iteratedType || errorType);
65846             }
65847             if (expr.parent.kind === 288) {
65848                 var node_2 = ts.cast(expr.parent.parent, ts.isObjectLiteralExpression);
65849                 var typeOfParentObjectLiteral = getTypeOfAssignmentPattern(node_2) || errorType;
65850                 var propertyIndex = ts.indexOfNode(node_2.properties, expr.parent);
65851                 return checkObjectLiteralDestructuringPropertyAssignment(node_2, typeOfParentObjectLiteral, propertyIndex);
65852             }
65853             var node = ts.cast(expr.parent, ts.isArrayLiteralExpression);
65854             var typeOfArrayLiteral = getTypeOfAssignmentPattern(node) || errorType;
65855             var elementType = checkIteratedTypeOrElementType(65, typeOfArrayLiteral, undefinedType, expr.parent) || errorType;
65856             return checkArrayLiteralDestructuringElementAssignment(node, typeOfArrayLiteral, node.elements.indexOf(expr), elementType);
65857         }
65858         function getPropertySymbolOfDestructuringAssignment(location) {
65859             var typeOfObjectLiteral = getTypeOfAssignmentPattern(ts.cast(location.parent.parent, ts.isAssignmentPattern));
65860             return typeOfObjectLiteral && getPropertyOfType(typeOfObjectLiteral, location.escapedText);
65861         }
65862         function getRegularTypeOfExpression(expr) {
65863             if (ts.isRightSideOfQualifiedNameOrPropertyAccess(expr)) {
65864                 expr = expr.parent;
65865             }
65866             return getRegularTypeOfLiteralType(getTypeOfExpression(expr));
65867         }
65868         function getParentTypeOfClassElement(node) {
65869             var classSymbol = getSymbolOfNode(node.parent);
65870             return ts.hasSyntacticModifier(node, 32)
65871                 ? getTypeOfSymbol(classSymbol)
65872                 : getDeclaredTypeOfSymbol(classSymbol);
65873         }
65874         function getClassElementPropertyKeyType(element) {
65875             var name = element.name;
65876             switch (name.kind) {
65877                 case 78:
65878                     return getLiteralType(ts.idText(name));
65879                 case 8:
65880                 case 10:
65881                     return getLiteralType(name.text);
65882                 case 158:
65883                     var nameType = checkComputedPropertyName(name);
65884                     return isTypeAssignableToKind(nameType, 12288) ? nameType : stringType;
65885                 default:
65886                     return ts.Debug.fail("Unsupported property name.");
65887             }
65888         }
65889         function getAugmentedPropertiesOfType(type) {
65890             type = getApparentType(type);
65891             var propsByName = ts.createSymbolTable(getPropertiesOfType(type));
65892             var functionType = getSignaturesOfType(type, 0).length ? globalCallableFunctionType :
65893                 getSignaturesOfType(type, 1).length ? globalNewableFunctionType :
65894                     undefined;
65895             if (functionType) {
65896                 ts.forEach(getPropertiesOfType(functionType), function (p) {
65897                     if (!propsByName.has(p.escapedName)) {
65898                         propsByName.set(p.escapedName, p);
65899                     }
65900                 });
65901             }
65902             return getNamedMembers(propsByName);
65903         }
65904         function typeHasCallOrConstructSignatures(type) {
65905             return ts.typeHasCallOrConstructSignatures(type, checker);
65906         }
65907         function getRootSymbols(symbol) {
65908             var roots = getImmediateRootSymbols(symbol);
65909             return roots ? ts.flatMap(roots, getRootSymbols) : [symbol];
65910         }
65911         function getImmediateRootSymbols(symbol) {
65912             if (ts.getCheckFlags(symbol) & 6) {
65913                 return ts.mapDefined(getSymbolLinks(symbol).containingType.types, function (type) { return getPropertyOfType(type, symbol.escapedName); });
65914             }
65915             else if (symbol.flags & 33554432) {
65916                 var _a = symbol, leftSpread = _a.leftSpread, rightSpread = _a.rightSpread, syntheticOrigin = _a.syntheticOrigin;
65917                 return leftSpread ? [leftSpread, rightSpread]
65918                     : syntheticOrigin ? [syntheticOrigin]
65919                         : ts.singleElementArray(tryGetAliasTarget(symbol));
65920             }
65921             return undefined;
65922         }
65923         function tryGetAliasTarget(symbol) {
65924             var target;
65925             var next = symbol;
65926             while (next = getSymbolLinks(next).target) {
65927                 target = next;
65928             }
65929             return target;
65930         }
65931         function isArgumentsLocalBinding(nodeIn) {
65932             if (ts.isGeneratedIdentifier(nodeIn))
65933                 return false;
65934             var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
65935             if (!node)
65936                 return false;
65937             var parent = node.parent;
65938             if (!parent)
65939                 return false;
65940             var isPropertyName = ((ts.isPropertyAccessExpression(parent)
65941                 || ts.isPropertyAssignment(parent))
65942                 && parent.name === node);
65943             return !isPropertyName && getReferencedValueSymbol(node) === argumentsSymbol;
65944         }
65945         function moduleExportsSomeValue(moduleReferenceExpression) {
65946             var moduleSymbol = resolveExternalModuleName(moduleReferenceExpression.parent, moduleReferenceExpression);
65947             if (!moduleSymbol || ts.isShorthandAmbientModuleSymbol(moduleSymbol)) {
65948                 return true;
65949             }
65950             var hasExportAssignment = hasExportAssignmentSymbol(moduleSymbol);
65951             moduleSymbol = resolveExternalModuleSymbol(moduleSymbol);
65952             var symbolLinks = getSymbolLinks(moduleSymbol);
65953             if (symbolLinks.exportsSomeValue === undefined) {
65954                 symbolLinks.exportsSomeValue = hasExportAssignment
65955                     ? !!(moduleSymbol.flags & 111551)
65956                     : ts.forEachEntry(getExportsOfModule(moduleSymbol), isValue);
65957             }
65958             return symbolLinks.exportsSomeValue;
65959             function isValue(s) {
65960                 s = resolveSymbol(s);
65961                 return s && !!(s.flags & 111551);
65962             }
65963         }
65964         function isNameOfModuleOrEnumDeclaration(node) {
65965             return ts.isModuleOrEnumDeclaration(node.parent) && node === node.parent.name;
65966         }
65967         function getReferencedExportContainer(nodeIn, prefixLocals) {
65968             var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
65969             if (node) {
65970                 var symbol = getReferencedValueSymbol(node, isNameOfModuleOrEnumDeclaration(node));
65971                 if (symbol) {
65972                     if (symbol.flags & 1048576) {
65973                         var exportSymbol = getMergedSymbol(symbol.exportSymbol);
65974                         if (!prefixLocals && exportSymbol.flags & 944 && !(exportSymbol.flags & 3)) {
65975                             return undefined;
65976                         }
65977                         symbol = exportSymbol;
65978                     }
65979                     var parentSymbol_1 = getParentOfSymbol(symbol);
65980                     if (parentSymbol_1) {
65981                         if (parentSymbol_1.flags & 512 && parentSymbol_1.valueDeclaration.kind === 297) {
65982                             var symbolFile = parentSymbol_1.valueDeclaration;
65983                             var referenceFile = ts.getSourceFileOfNode(node);
65984                             var symbolIsUmdExport = symbolFile !== referenceFile;
65985                             return symbolIsUmdExport ? undefined : symbolFile;
65986                         }
65987                         return ts.findAncestor(node.parent, function (n) { return ts.isModuleOrEnumDeclaration(n) && getSymbolOfNode(n) === parentSymbol_1; });
65988                     }
65989                 }
65990             }
65991         }
65992         function getReferencedImportDeclaration(nodeIn) {
65993             if (nodeIn.generatedImportReference) {
65994                 return nodeIn.generatedImportReference;
65995             }
65996             var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
65997             if (node) {
65998                 var symbol = getReferencedValueSymbol(node);
65999                 if (isNonLocalAlias(symbol, 111551) && !getTypeOnlyAliasDeclaration(symbol)) {
66000                     return getDeclarationOfAliasSymbol(symbol);
66001                 }
66002             }
66003             return undefined;
66004         }
66005         function isSymbolOfDestructuredElementOfCatchBinding(symbol) {
66006             return ts.isBindingElement(symbol.valueDeclaration)
66007                 && ts.walkUpBindingElementsAndPatterns(symbol.valueDeclaration).parent.kind === 287;
66008         }
66009         function isSymbolOfDeclarationWithCollidingName(symbol) {
66010             if (symbol.flags & 418 && !ts.isSourceFile(symbol.valueDeclaration)) {
66011                 var links = getSymbolLinks(symbol);
66012                 if (links.isDeclarationWithCollidingName === undefined) {
66013                     var container = ts.getEnclosingBlockScopeContainer(symbol.valueDeclaration);
66014                     if (ts.isStatementWithLocals(container) || isSymbolOfDestructuredElementOfCatchBinding(symbol)) {
66015                         var nodeLinks_1 = getNodeLinks(symbol.valueDeclaration);
66016                         if (resolveName(container.parent, symbol.escapedName, 111551, undefined, undefined, false)) {
66017                             links.isDeclarationWithCollidingName = true;
66018                         }
66019                         else if (nodeLinks_1.flags & 262144) {
66020                             var isDeclaredInLoop = nodeLinks_1.flags & 524288;
66021                             var inLoopInitializer = ts.isIterationStatement(container, false);
66022                             var inLoopBodyBlock = container.kind === 230 && ts.isIterationStatement(container.parent, false);
66023                             links.isDeclarationWithCollidingName = !ts.isBlockScopedContainerTopLevel(container) && (!isDeclaredInLoop || (!inLoopInitializer && !inLoopBodyBlock));
66024                         }
66025                         else {
66026                             links.isDeclarationWithCollidingName = false;
66027                         }
66028                     }
66029                 }
66030                 return links.isDeclarationWithCollidingName;
66031             }
66032             return false;
66033         }
66034         function getReferencedDeclarationWithCollidingName(nodeIn) {
66035             if (!ts.isGeneratedIdentifier(nodeIn)) {
66036                 var node = ts.getParseTreeNode(nodeIn, ts.isIdentifier);
66037                 if (node) {
66038                     var symbol = getReferencedValueSymbol(node);
66039                     if (symbol && isSymbolOfDeclarationWithCollidingName(symbol)) {
66040                         return symbol.valueDeclaration;
66041                     }
66042                 }
66043             }
66044             return undefined;
66045         }
66046         function isDeclarationWithCollidingName(nodeIn) {
66047             var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration);
66048             if (node) {
66049                 var symbol = getSymbolOfNode(node);
66050                 if (symbol) {
66051                     return isSymbolOfDeclarationWithCollidingName(symbol);
66052                 }
66053             }
66054             return false;
66055         }
66056         function isValueAliasDeclaration(node) {
66057             switch (node.kind) {
66058                 case 260:
66059                     return isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol);
66060                 case 262:
66061                 case 263:
66062                 case 265:
66063                 case 270:
66064                     var symbol = getSymbolOfNode(node) || unknownSymbol;
66065                     return isAliasResolvedToValue(symbol) && !getTypeOnlyAliasDeclaration(symbol);
66066                 case 267:
66067                     var exportClause = node.exportClause;
66068                     return !!exportClause && (ts.isNamespaceExport(exportClause) ||
66069                         ts.some(exportClause.elements, isValueAliasDeclaration));
66070                 case 266:
66071                     return node.expression && node.expression.kind === 78 ?
66072                         isAliasResolvedToValue(getSymbolOfNode(node) || unknownSymbol) :
66073                         true;
66074             }
66075             return false;
66076         }
66077         function isTopLevelValueImportEqualsWithEntityName(nodeIn) {
66078             var node = ts.getParseTreeNode(nodeIn, ts.isImportEqualsDeclaration);
66079             if (node === undefined || node.parent.kind !== 297 || !ts.isInternalModuleImportEqualsDeclaration(node)) {
66080                 return false;
66081             }
66082             var isValue = isAliasResolvedToValue(getSymbolOfNode(node));
66083             return isValue && node.moduleReference && !ts.nodeIsMissing(node.moduleReference);
66084         }
66085         function isAliasResolvedToValue(symbol) {
66086             var target = resolveAlias(symbol);
66087             if (target === unknownSymbol) {
66088                 return true;
66089             }
66090             return !!(target.flags & 111551) &&
66091                 (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target));
66092         }
66093         function isConstEnumOrConstEnumOnlyModule(s) {
66094             return isConstEnumSymbol(s) || !!s.constEnumOnlyModule;
66095         }
66096         function isReferencedAliasDeclaration(node, checkChildren) {
66097             if (isAliasSymbolDeclaration(node)) {
66098                 var symbol = getSymbolOfNode(node);
66099                 var links = symbol && getSymbolLinks(symbol);
66100                 if (links === null || links === void 0 ? void 0 : links.referenced) {
66101                     return true;
66102                 }
66103                 var target = getSymbolLinks(symbol).target;
66104                 if (target && ts.getEffectiveModifierFlags(node) & 1 &&
66105                     target.flags & 111551 &&
66106                     (ts.shouldPreserveConstEnums(compilerOptions) || !isConstEnumOrConstEnumOnlyModule(target))) {
66107                     return true;
66108                 }
66109             }
66110             if (checkChildren) {
66111                 return !!ts.forEachChild(node, function (node) { return isReferencedAliasDeclaration(node, checkChildren); });
66112             }
66113             return false;
66114         }
66115         function isImplementationOfOverload(node) {
66116             if (ts.nodeIsPresent(node.body)) {
66117                 if (ts.isGetAccessor(node) || ts.isSetAccessor(node))
66118                     return false;
66119                 var symbol = getSymbolOfNode(node);
66120                 var signaturesOfSymbol = getSignaturesOfSymbol(symbol);
66121                 return signaturesOfSymbol.length > 1 ||
66122                     (signaturesOfSymbol.length === 1 && signaturesOfSymbol[0].declaration !== node);
66123             }
66124             return false;
66125         }
66126         function isRequiredInitializedParameter(parameter) {
66127             return !!strictNullChecks &&
66128                 !isOptionalParameter(parameter) &&
66129                 !ts.isJSDocParameterTag(parameter) &&
66130                 !!parameter.initializer &&
66131                 !ts.hasSyntacticModifier(parameter, 92);
66132         }
66133         function isOptionalUninitializedParameterProperty(parameter) {
66134             return strictNullChecks &&
66135                 isOptionalParameter(parameter) &&
66136                 !parameter.initializer &&
66137                 ts.hasSyntacticModifier(parameter, 92);
66138         }
66139         function isOptionalUninitializedParameter(parameter) {
66140             return !!strictNullChecks &&
66141                 isOptionalParameter(parameter) &&
66142                 !parameter.initializer;
66143         }
66144         function isExpandoFunctionDeclaration(node) {
66145             var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
66146             if (!declaration) {
66147                 return false;
66148             }
66149             var symbol = getSymbolOfNode(declaration);
66150             if (!symbol || !(symbol.flags & 16)) {
66151                 return false;
66152             }
66153             return !!ts.forEachEntry(getExportsOfSymbol(symbol), function (p) { return p.flags & 111551 && p.valueDeclaration && ts.isPropertyAccessExpression(p.valueDeclaration); });
66154         }
66155         function getPropertiesOfContainerFunction(node) {
66156             var declaration = ts.getParseTreeNode(node, ts.isFunctionDeclaration);
66157             if (!declaration) {
66158                 return ts.emptyArray;
66159             }
66160             var symbol = getSymbolOfNode(declaration);
66161             return symbol && getPropertiesOfType(getTypeOfSymbol(symbol)) || ts.emptyArray;
66162         }
66163         function getNodeCheckFlags(node) {
66164             return getNodeLinks(node).flags || 0;
66165         }
66166         function getEnumMemberValue(node) {
66167             computeEnumMemberValues(node.parent);
66168             return getNodeLinks(node).enumMemberValue;
66169         }
66170         function canHaveConstantValue(node) {
66171             switch (node.kind) {
66172                 case 291:
66173                 case 201:
66174                 case 202:
66175                     return true;
66176             }
66177             return false;
66178         }
66179         function getConstantValue(node) {
66180             if (node.kind === 291) {
66181                 return getEnumMemberValue(node);
66182             }
66183             var symbol = getNodeLinks(node).resolvedSymbol;
66184             if (symbol && (symbol.flags & 8)) {
66185                 var member = symbol.valueDeclaration;
66186                 if (ts.isEnumConst(member.parent)) {
66187                     return getEnumMemberValue(member);
66188                 }
66189             }
66190             return undefined;
66191         }
66192         function isFunctionType(type) {
66193             return !!(type.flags & 524288) && getSignaturesOfType(type, 0).length > 0;
66194         }
66195         function getTypeReferenceSerializationKind(typeNameIn, location) {
66196             var _a;
66197             var typeName = ts.getParseTreeNode(typeNameIn, ts.isEntityName);
66198             if (!typeName)
66199                 return ts.TypeReferenceSerializationKind.Unknown;
66200             if (location) {
66201                 location = ts.getParseTreeNode(location);
66202                 if (!location)
66203                     return ts.TypeReferenceSerializationKind.Unknown;
66204             }
66205             var valueSymbol = resolveEntityName(typeName, 111551, true, true, location);
66206             var isTypeOnly = ((_a = valueSymbol === null || valueSymbol === void 0 ? void 0 : valueSymbol.declarations) === null || _a === void 0 ? void 0 : _a.every(ts.isTypeOnlyImportOrExportDeclaration)) || false;
66207             var resolvedSymbol = valueSymbol && valueSymbol.flags & 2097152 ? resolveAlias(valueSymbol) : valueSymbol;
66208             var typeSymbol = resolveEntityName(typeName, 788968, true, false, location);
66209             if (resolvedSymbol && resolvedSymbol === typeSymbol) {
66210                 var globalPromiseSymbol = getGlobalPromiseConstructorSymbol(false);
66211                 if (globalPromiseSymbol && resolvedSymbol === globalPromiseSymbol) {
66212                     return ts.TypeReferenceSerializationKind.Promise;
66213                 }
66214                 var constructorType = getTypeOfSymbol(resolvedSymbol);
66215                 if (constructorType && isConstructorType(constructorType)) {
66216                     return isTypeOnly ? ts.TypeReferenceSerializationKind.TypeWithCallSignature : ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue;
66217                 }
66218             }
66219             if (!typeSymbol) {
66220                 return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown;
66221             }
66222             var type = getDeclaredTypeOfSymbol(typeSymbol);
66223             if (type === errorType) {
66224                 return isTypeOnly ? ts.TypeReferenceSerializationKind.ObjectType : ts.TypeReferenceSerializationKind.Unknown;
66225             }
66226             else if (type.flags & 3) {
66227                 return ts.TypeReferenceSerializationKind.ObjectType;
66228             }
66229             else if (isTypeAssignableToKind(type, 16384 | 98304 | 131072)) {
66230                 return ts.TypeReferenceSerializationKind.VoidNullableOrNeverType;
66231             }
66232             else if (isTypeAssignableToKind(type, 528)) {
66233                 return ts.TypeReferenceSerializationKind.BooleanType;
66234             }
66235             else if (isTypeAssignableToKind(type, 296)) {
66236                 return ts.TypeReferenceSerializationKind.NumberLikeType;
66237             }
66238             else if (isTypeAssignableToKind(type, 2112)) {
66239                 return ts.TypeReferenceSerializationKind.BigIntLikeType;
66240             }
66241             else if (isTypeAssignableToKind(type, 402653316)) {
66242                 return ts.TypeReferenceSerializationKind.StringLikeType;
66243             }
66244             else if (isTupleType(type)) {
66245                 return ts.TypeReferenceSerializationKind.ArrayLikeType;
66246             }
66247             else if (isTypeAssignableToKind(type, 12288)) {
66248                 return ts.TypeReferenceSerializationKind.ESSymbolType;
66249             }
66250             else if (isFunctionType(type)) {
66251                 return ts.TypeReferenceSerializationKind.TypeWithCallSignature;
66252             }
66253             else if (isArrayType(type)) {
66254                 return ts.TypeReferenceSerializationKind.ArrayLikeType;
66255             }
66256             else {
66257                 return ts.TypeReferenceSerializationKind.ObjectType;
66258             }
66259         }
66260         function createTypeOfDeclaration(declarationIn, enclosingDeclaration, flags, tracker, addUndefined) {
66261             var declaration = ts.getParseTreeNode(declarationIn, ts.isVariableLikeOrAccessor);
66262             if (!declaration) {
66263                 return ts.factory.createToken(128);
66264             }
66265             var symbol = getSymbolOfNode(declaration);
66266             var type = symbol && !(symbol.flags & (2048 | 131072))
66267                 ? getWidenedLiteralType(getTypeOfSymbol(symbol))
66268                 : errorType;
66269             if (type.flags & 8192 &&
66270                 type.symbol === symbol) {
66271                 flags |= 1048576;
66272             }
66273             if (addUndefined) {
66274                 type = getOptionalType(type);
66275             }
66276             return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024, tracker);
66277         }
66278         function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) {
66279             var signatureDeclaration = ts.getParseTreeNode(signatureDeclarationIn, ts.isFunctionLike);
66280             if (!signatureDeclaration) {
66281                 return ts.factory.createToken(128);
66282             }
66283             var signature = getSignatureFromDeclaration(signatureDeclaration);
66284             return nodeBuilder.typeToTypeNode(getReturnTypeOfSignature(signature), enclosingDeclaration, flags | 1024, tracker);
66285         }
66286         function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) {
66287             var expr = ts.getParseTreeNode(exprIn, ts.isExpression);
66288             if (!expr) {
66289                 return ts.factory.createToken(128);
66290             }
66291             var type = getWidenedType(getRegularTypeOfExpression(expr));
66292             return nodeBuilder.typeToTypeNode(type, enclosingDeclaration, flags | 1024, tracker);
66293         }
66294         function hasGlobalName(name) {
66295             return globals.has(ts.escapeLeadingUnderscores(name));
66296         }
66297         function getReferencedValueSymbol(reference, startInDeclarationContainer) {
66298             var resolvedSymbol = getNodeLinks(reference).resolvedSymbol;
66299             if (resolvedSymbol) {
66300                 return resolvedSymbol;
66301             }
66302             var location = reference;
66303             if (startInDeclarationContainer) {
66304                 var parent = reference.parent;
66305                 if (ts.isDeclaration(parent) && reference === parent.name) {
66306                     location = getDeclarationContainer(parent);
66307                 }
66308             }
66309             return resolveName(location, reference.escapedText, 111551 | 1048576 | 2097152, undefined, undefined, true);
66310         }
66311         function getReferencedValueDeclaration(referenceIn) {
66312             if (!ts.isGeneratedIdentifier(referenceIn)) {
66313                 var reference = ts.getParseTreeNode(referenceIn, ts.isIdentifier);
66314                 if (reference) {
66315                     var symbol = getReferencedValueSymbol(reference);
66316                     if (symbol) {
66317                         return getExportSymbolOfValueSymbolIfExported(symbol).valueDeclaration;
66318                     }
66319                 }
66320             }
66321             return undefined;
66322         }
66323         function isLiteralConstDeclaration(node) {
66324             if (ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) {
66325                 return isFreshLiteralType(getTypeOfSymbol(getSymbolOfNode(node)));
66326             }
66327             return false;
66328         }
66329         function literalTypeToNode(type, enclosing, tracker) {
66330             var enumResult = type.flags & 1024 ? nodeBuilder.symbolToExpression(type.symbol, 111551, enclosing, undefined, tracker)
66331                 : type === trueType ? ts.factory.createTrue() : type === falseType && ts.factory.createFalse();
66332             if (enumResult)
66333                 return enumResult;
66334             var literalValue = type.value;
66335             return typeof literalValue === "object" ? ts.factory.createBigIntLiteral(literalValue) :
66336                 typeof literalValue === "number" ? ts.factory.createNumericLiteral(literalValue) :
66337                     ts.factory.createStringLiteral(literalValue);
66338         }
66339         function createLiteralConstValue(node, tracker) {
66340             var type = getTypeOfSymbol(getSymbolOfNode(node));
66341             return literalTypeToNode(type, node, tracker);
66342         }
66343         function getJsxFactoryEntity(location) {
66344             return location ? (getJsxNamespace(location), (ts.getSourceFileOfNode(location).localJsxFactory || _jsxFactoryEntity)) : _jsxFactoryEntity;
66345         }
66346         function getJsxFragmentFactoryEntity(location) {
66347             if (location) {
66348                 var file = ts.getSourceFileOfNode(location);
66349                 if (file) {
66350                     if (file.localJsxFragmentFactory) {
66351                         return file.localJsxFragmentFactory;
66352                     }
66353                     var jsxFragPragmas = file.pragmas.get("jsxfrag");
66354                     var jsxFragPragma = ts.isArray(jsxFragPragmas) ? jsxFragPragmas[0] : jsxFragPragmas;
66355                     if (jsxFragPragma) {
66356                         file.localJsxFragmentFactory = ts.parseIsolatedEntityName(jsxFragPragma.arguments.factory, languageVersion);
66357                         return file.localJsxFragmentFactory;
66358                     }
66359                 }
66360             }
66361             if (compilerOptions.jsxFragmentFactory) {
66362                 return ts.parseIsolatedEntityName(compilerOptions.jsxFragmentFactory, languageVersion);
66363             }
66364         }
66365         function createResolver() {
66366             var resolvedTypeReferenceDirectives = host.getResolvedTypeReferenceDirectives();
66367             var fileToDirective;
66368             if (resolvedTypeReferenceDirectives) {
66369                 fileToDirective = new ts.Map();
66370                 resolvedTypeReferenceDirectives.forEach(function (resolvedDirective, key) {
66371                     if (!resolvedDirective || !resolvedDirective.resolvedFileName) {
66372                         return;
66373                     }
66374                     var file = host.getSourceFile(resolvedDirective.resolvedFileName);
66375                     if (file) {
66376                         addReferencedFilesToTypeDirective(file, key);
66377                     }
66378                 });
66379             }
66380             return {
66381                 getReferencedExportContainer: getReferencedExportContainer,
66382                 getReferencedImportDeclaration: getReferencedImportDeclaration,
66383                 getReferencedDeclarationWithCollidingName: getReferencedDeclarationWithCollidingName,
66384                 isDeclarationWithCollidingName: isDeclarationWithCollidingName,
66385                 isValueAliasDeclaration: function (nodeIn) {
66386                     var node = ts.getParseTreeNode(nodeIn);
66387                     return node ? isValueAliasDeclaration(node) : true;
66388                 },
66389                 hasGlobalName: hasGlobalName,
66390                 isReferencedAliasDeclaration: function (nodeIn, checkChildren) {
66391                     var node = ts.getParseTreeNode(nodeIn);
66392                     return node ? isReferencedAliasDeclaration(node, checkChildren) : true;
66393                 },
66394                 getNodeCheckFlags: function (nodeIn) {
66395                     var node = ts.getParseTreeNode(nodeIn);
66396                     return node ? getNodeCheckFlags(node) : 0;
66397                 },
66398                 isTopLevelValueImportEqualsWithEntityName: isTopLevelValueImportEqualsWithEntityName,
66399                 isDeclarationVisible: isDeclarationVisible,
66400                 isImplementationOfOverload: isImplementationOfOverload,
66401                 isRequiredInitializedParameter: isRequiredInitializedParameter,
66402                 isOptionalUninitializedParameterProperty: isOptionalUninitializedParameterProperty,
66403                 isExpandoFunctionDeclaration: isExpandoFunctionDeclaration,
66404                 getPropertiesOfContainerFunction: getPropertiesOfContainerFunction,
66405                 createTypeOfDeclaration: createTypeOfDeclaration,
66406                 createReturnTypeOfSignatureDeclaration: createReturnTypeOfSignatureDeclaration,
66407                 createTypeOfExpression: createTypeOfExpression,
66408                 createLiteralConstValue: createLiteralConstValue,
66409                 isSymbolAccessible: isSymbolAccessible,
66410                 isEntityNameVisible: isEntityNameVisible,
66411                 getConstantValue: function (nodeIn) {
66412                     var node = ts.getParseTreeNode(nodeIn, canHaveConstantValue);
66413                     return node ? getConstantValue(node) : undefined;
66414                 },
66415                 collectLinkedAliases: collectLinkedAliases,
66416                 getReferencedValueDeclaration: getReferencedValueDeclaration,
66417                 getTypeReferenceSerializationKind: getTypeReferenceSerializationKind,
66418                 isOptionalParameter: isOptionalParameter,
66419                 moduleExportsSomeValue: moduleExportsSomeValue,
66420                 isArgumentsLocalBinding: isArgumentsLocalBinding,
66421                 getExternalModuleFileFromDeclaration: function (nodeIn) {
66422                     var node = ts.getParseTreeNode(nodeIn, ts.hasPossibleExternalModuleReference);
66423                     return node && getExternalModuleFileFromDeclaration(node);
66424                 },
66425                 getTypeReferenceDirectivesForEntityName: getTypeReferenceDirectivesForEntityName,
66426                 getTypeReferenceDirectivesForSymbol: getTypeReferenceDirectivesForSymbol,
66427                 isLiteralConstDeclaration: isLiteralConstDeclaration,
66428                 isLateBound: function (nodeIn) {
66429                     var node = ts.getParseTreeNode(nodeIn, ts.isDeclaration);
66430                     var symbol = node && getSymbolOfNode(node);
66431                     return !!(symbol && ts.getCheckFlags(symbol) & 4096);
66432                 },
66433                 getJsxFactoryEntity: getJsxFactoryEntity,
66434                 getJsxFragmentFactoryEntity: getJsxFragmentFactoryEntity,
66435                 getAllAccessorDeclarations: function (accessor) {
66436                     accessor = ts.getParseTreeNode(accessor, ts.isGetOrSetAccessorDeclaration);
66437                     var otherKind = accessor.kind === 168 ? 167 : 168;
66438                     var otherAccessor = ts.getDeclarationOfKind(getSymbolOfNode(accessor), otherKind);
66439                     var firstAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? otherAccessor : accessor;
66440                     var secondAccessor = otherAccessor && (otherAccessor.pos < accessor.pos) ? accessor : otherAccessor;
66441                     var setAccessor = accessor.kind === 168 ? accessor : otherAccessor;
66442                     var getAccessor = accessor.kind === 167 ? accessor : otherAccessor;
66443                     return {
66444                         firstAccessor: firstAccessor,
66445                         secondAccessor: secondAccessor,
66446                         setAccessor: setAccessor,
66447                         getAccessor: getAccessor
66448                     };
66449                 },
66450                 getSymbolOfExternalModuleSpecifier: function (moduleName) { return resolveExternalModuleNameWorker(moduleName, moduleName, undefined); },
66451                 isBindingCapturedByNode: function (node, decl) {
66452                     var parseNode = ts.getParseTreeNode(node);
66453                     var parseDecl = ts.getParseTreeNode(decl);
66454                     return !!parseNode && !!parseDecl && (ts.isVariableDeclaration(parseDecl) || ts.isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl);
66455                 },
66456                 getDeclarationStatementsForSourceFile: function (node, flags, tracker, bundled) {
66457                     var n = ts.getParseTreeNode(node);
66458                     ts.Debug.assert(n && n.kind === 297, "Non-sourcefile node passed into getDeclarationsForSourceFile");
66459                     var sym = getSymbolOfNode(node);
66460                     if (!sym) {
66461                         return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker, bundled);
66462                     }
66463                     return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker, bundled);
66464                 },
66465                 isImportRequiredByAugmentation: isImportRequiredByAugmentation,
66466             };
66467             function isImportRequiredByAugmentation(node) {
66468                 var file = ts.getSourceFileOfNode(node);
66469                 if (!file.symbol)
66470                     return false;
66471                 var importTarget = getExternalModuleFileFromDeclaration(node);
66472                 if (!importTarget)
66473                     return false;
66474                 if (importTarget === file)
66475                     return false;
66476                 var exports = getExportsOfModule(file.symbol);
66477                 for (var _i = 0, _a = ts.arrayFrom(exports.values()); _i < _a.length; _i++) {
66478                     var s = _a[_i];
66479                     if (s.mergeId) {
66480                         var merged = getMergedSymbol(s);
66481                         for (var _b = 0, _c = merged.declarations; _b < _c.length; _b++) {
66482                             var d = _c[_b];
66483                             var declFile = ts.getSourceFileOfNode(d);
66484                             if (declFile === importTarget) {
66485                                 return true;
66486                             }
66487                         }
66488                     }
66489                 }
66490                 return false;
66491             }
66492             function isInHeritageClause(node) {
66493                 return node.parent && node.parent.kind === 223 && node.parent.parent && node.parent.parent.kind === 286;
66494             }
66495             function getTypeReferenceDirectivesForEntityName(node) {
66496                 if (!fileToDirective) {
66497                     return undefined;
66498                 }
66499                 var meaning = 788968 | 1920;
66500                 if ((node.kind === 78 && isInTypeQuery(node)) || (node.kind === 201 && !isInHeritageClause(node))) {
66501                     meaning = 111551 | 1048576;
66502                 }
66503                 var symbol = resolveEntityName(node, meaning, true);
66504                 return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined;
66505             }
66506             function getTypeReferenceDirectivesForSymbol(symbol, meaning) {
66507                 if (!fileToDirective) {
66508                     return undefined;
66509                 }
66510                 if (!isSymbolFromTypeDeclarationFile(symbol)) {
66511                     return undefined;
66512                 }
66513                 var typeReferenceDirectives;
66514                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
66515                     var decl = _a[_i];
66516                     if (decl.symbol && decl.symbol.flags & meaning) {
66517                         var file = ts.getSourceFileOfNode(decl);
66518                         var typeReferenceDirective = fileToDirective.get(file.path);
66519                         if (typeReferenceDirective) {
66520                             (typeReferenceDirectives || (typeReferenceDirectives = [])).push(typeReferenceDirective);
66521                         }
66522                         else {
66523                             return undefined;
66524                         }
66525                     }
66526                 }
66527                 return typeReferenceDirectives;
66528             }
66529             function isSymbolFromTypeDeclarationFile(symbol) {
66530                 if (!symbol.declarations) {
66531                     return false;
66532                 }
66533                 var current = symbol;
66534                 while (true) {
66535                     var parent = getParentOfSymbol(current);
66536                     if (parent) {
66537                         current = parent;
66538                     }
66539                     else {
66540                         break;
66541                     }
66542                 }
66543                 if (current.valueDeclaration && current.valueDeclaration.kind === 297 && current.flags & 512) {
66544                     return false;
66545                 }
66546                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
66547                     var decl = _a[_i];
66548                     var file = ts.getSourceFileOfNode(decl);
66549                     if (fileToDirective.has(file.path)) {
66550                         return true;
66551                     }
66552                 }
66553                 return false;
66554             }
66555             function addReferencedFilesToTypeDirective(file, key) {
66556                 if (fileToDirective.has(file.path))
66557                     return;
66558                 fileToDirective.set(file.path, key);
66559                 for (var _i = 0, _a = file.referencedFiles; _i < _a.length; _i++) {
66560                     var fileName = _a[_i].fileName;
66561                     var resolvedFile = ts.resolveTripleslashReference(fileName, file.fileName);
66562                     var referencedFile = host.getSourceFile(resolvedFile);
66563                     if (referencedFile) {
66564                         addReferencedFilesToTypeDirective(referencedFile, key);
66565                     }
66566                 }
66567             }
66568         }
66569         function getExternalModuleFileFromDeclaration(declaration) {
66570             var specifier = declaration.kind === 256 ? ts.tryCast(declaration.name, ts.isStringLiteral) : ts.getExternalModuleName(declaration);
66571             var moduleSymbol = resolveExternalModuleNameWorker(specifier, specifier, undefined);
66572             if (!moduleSymbol) {
66573                 return undefined;
66574             }
66575             return ts.getDeclarationOfKind(moduleSymbol, 297);
66576         }
66577         function initializeTypeChecker() {
66578             for (var _i = 0, _a = host.getSourceFiles(); _i < _a.length; _i++) {
66579                 var file = _a[_i];
66580                 ts.bindSourceFile(file, compilerOptions);
66581             }
66582             amalgamatedDuplicates = new ts.Map();
66583             var augmentations;
66584             for (var _b = 0, _c = host.getSourceFiles(); _b < _c.length; _b++) {
66585                 var file = _c[_b];
66586                 if (file.redirectInfo) {
66587                     continue;
66588                 }
66589                 if (!ts.isExternalOrCommonJsModule(file)) {
66590                     var fileGlobalThisSymbol = file.locals.get("globalThis");
66591                     if (fileGlobalThisSymbol) {
66592                         for (var _d = 0, _e = fileGlobalThisSymbol.declarations; _d < _e.length; _d++) {
66593                             var declaration = _e[_d];
66594                             diagnostics.add(ts.createDiagnosticForNode(declaration, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0, "globalThis"));
66595                         }
66596                     }
66597                     mergeSymbolTable(globals, file.locals);
66598                 }
66599                 if (file.jsGlobalAugmentations) {
66600                     mergeSymbolTable(globals, file.jsGlobalAugmentations);
66601                 }
66602                 if (file.patternAmbientModules && file.patternAmbientModules.length) {
66603                     patternAmbientModules = ts.concatenate(patternAmbientModules, file.patternAmbientModules);
66604                 }
66605                 if (file.moduleAugmentations.length) {
66606                     (augmentations || (augmentations = [])).push(file.moduleAugmentations);
66607                 }
66608                 if (file.symbol && file.symbol.globalExports) {
66609                     var source = file.symbol.globalExports;
66610                     source.forEach(function (sourceSymbol, id) {
66611                         if (!globals.has(id)) {
66612                             globals.set(id, sourceSymbol);
66613                         }
66614                     });
66615                 }
66616             }
66617             if (augmentations) {
66618                 for (var _f = 0, augmentations_1 = augmentations; _f < augmentations_1.length; _f++) {
66619                     var list = augmentations_1[_f];
66620                     for (var _g = 0, list_1 = list; _g < list_1.length; _g++) {
66621                         var augmentation = list_1[_g];
66622                         if (!ts.isGlobalScopeAugmentation(augmentation.parent))
66623                             continue;
66624                         mergeModuleAugmentation(augmentation);
66625                     }
66626                 }
66627             }
66628             addToSymbolTable(globals, builtinGlobals, ts.Diagnostics.Declaration_name_conflicts_with_built_in_global_identifier_0);
66629             getSymbolLinks(undefinedSymbol).type = undefinedWideningType;
66630             getSymbolLinks(argumentsSymbol).type = getGlobalType("IArguments", 0, true);
66631             getSymbolLinks(unknownSymbol).type = errorType;
66632             getSymbolLinks(globalThisSymbol).type = createObjectType(16, globalThisSymbol);
66633             globalArrayType = getGlobalType("Array", 1, true);
66634             globalObjectType = getGlobalType("Object", 0, true);
66635             globalFunctionType = getGlobalType("Function", 0, true);
66636             globalCallableFunctionType = strictBindCallApply && getGlobalType("CallableFunction", 0, true) || globalFunctionType;
66637             globalNewableFunctionType = strictBindCallApply && getGlobalType("NewableFunction", 0, true) || globalFunctionType;
66638             globalStringType = getGlobalType("String", 0, true);
66639             globalNumberType = getGlobalType("Number", 0, true);
66640             globalBooleanType = getGlobalType("Boolean", 0, true);
66641             globalRegExpType = getGlobalType("RegExp", 0, true);
66642             anyArrayType = createArrayType(anyType);
66643             autoArrayType = createArrayType(autoType);
66644             if (autoArrayType === emptyObjectType) {
66645                 autoArrayType = createAnonymousType(undefined, emptySymbols, ts.emptyArray, ts.emptyArray, undefined, undefined);
66646             }
66647             globalReadonlyArrayType = getGlobalTypeOrUndefined("ReadonlyArray", 1) || globalArrayType;
66648             anyReadonlyArrayType = globalReadonlyArrayType ? createTypeFromGenericGlobalType(globalReadonlyArrayType, [anyType]) : anyArrayType;
66649             globalThisType = getGlobalTypeOrUndefined("ThisType", 1);
66650             if (augmentations) {
66651                 for (var _h = 0, augmentations_2 = augmentations; _h < augmentations_2.length; _h++) {
66652                     var list = augmentations_2[_h];
66653                     for (var _j = 0, list_2 = list; _j < list_2.length; _j++) {
66654                         var augmentation = list_2[_j];
66655                         if (ts.isGlobalScopeAugmentation(augmentation.parent))
66656                             continue;
66657                         mergeModuleAugmentation(augmentation);
66658                     }
66659                 }
66660             }
66661             amalgamatedDuplicates.forEach(function (_a) {
66662                 var firstFile = _a.firstFile, secondFile = _a.secondFile, conflictingSymbols = _a.conflictingSymbols;
66663                 if (conflictingSymbols.size < 8) {
66664                     conflictingSymbols.forEach(function (_a, symbolName) {
66665                         var isBlockScoped = _a.isBlockScoped, firstFileLocations = _a.firstFileLocations, secondFileLocations = _a.secondFileLocations;
66666                         var message = isBlockScoped ? ts.Diagnostics.Cannot_redeclare_block_scoped_variable_0 : ts.Diagnostics.Duplicate_identifier_0;
66667                         for (var _i = 0, firstFileLocations_1 = firstFileLocations; _i < firstFileLocations_1.length; _i++) {
66668                             var node = firstFileLocations_1[_i];
66669                             addDuplicateDeclarationError(node, message, symbolName, secondFileLocations);
66670                         }
66671                         for (var _b = 0, secondFileLocations_1 = secondFileLocations; _b < secondFileLocations_1.length; _b++) {
66672                             var node = secondFileLocations_1[_b];
66673                             addDuplicateDeclarationError(node, message, symbolName, firstFileLocations);
66674                         }
66675                     });
66676                 }
66677                 else {
66678                     var list = ts.arrayFrom(conflictingSymbols.keys()).join(", ");
66679                     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)));
66680                     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)));
66681                 }
66682             });
66683             amalgamatedDuplicates = undefined;
66684         }
66685         function checkExternalEmitHelpers(location, helpers) {
66686             if ((requestedExternalEmitHelpers & helpers) !== helpers && compilerOptions.importHelpers) {
66687                 var sourceFile = ts.getSourceFileOfNode(location);
66688                 if (ts.isEffectiveExternalModule(sourceFile, compilerOptions) && !(location.flags & 8388608)) {
66689                     var helpersModule = resolveHelpersModule(sourceFile, location);
66690                     if (helpersModule !== unknownSymbol) {
66691                         var uncheckedHelpers = helpers & ~requestedExternalEmitHelpers;
66692                         for (var helper = 1; helper <= 2097152; helper <<= 1) {
66693                             if (uncheckedHelpers & helper) {
66694                                 var name = getHelperName(helper);
66695                                 var symbol = getSymbol(helpersModule.exports, ts.escapeLeadingUnderscores(name), 111551);
66696                                 if (!symbol) {
66697                                     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);
66698                                 }
66699                             }
66700                         }
66701                     }
66702                     requestedExternalEmitHelpers |= helpers;
66703                 }
66704             }
66705         }
66706         function getHelperName(helper) {
66707             switch (helper) {
66708                 case 1: return "__extends";
66709                 case 2: return "__assign";
66710                 case 4: return "__rest";
66711                 case 8: return "__decorate";
66712                 case 16: return "__metadata";
66713                 case 32: return "__param";
66714                 case 64: return "__awaiter";
66715                 case 128: return "__generator";
66716                 case 256: return "__values";
66717                 case 512: return "__read";
66718                 case 1024: return "__spreadArray";
66719                 case 2048: return "__await";
66720                 case 4096: return "__asyncGenerator";
66721                 case 8192: return "__asyncDelegator";
66722                 case 16384: return "__asyncValues";
66723                 case 32768: return "__exportStar";
66724                 case 65536: return "__importStar";
66725                 case 131072: return "__importDefault";
66726                 case 262144: return "__makeTemplateObject";
66727                 case 524288: return "__classPrivateFieldGet";
66728                 case 1048576: return "__classPrivateFieldSet";
66729                 case 2097152: return "__createBinding";
66730                 default: return ts.Debug.fail("Unrecognized helper");
66731             }
66732         }
66733         function resolveHelpersModule(node, errorNode) {
66734             if (!externalHelpersModule) {
66735                 externalHelpersModule = resolveExternalModule(node, ts.externalHelpersModuleNameText, ts.Diagnostics.This_syntax_requires_an_imported_helper_but_module_0_cannot_be_found, errorNode) || unknownSymbol;
66736             }
66737             return externalHelpersModule;
66738         }
66739         function checkGrammarDecoratorsAndModifiers(node) {
66740             return checkGrammarDecorators(node) || checkGrammarModifiers(node);
66741         }
66742         function checkGrammarDecorators(node) {
66743             if (!node.decorators) {
66744                 return false;
66745             }
66746             if (!ts.nodeCanBeDecorated(node, node.parent, node.parent.parent)) {
66747                 if (node.kind === 165 && !ts.nodeIsPresent(node.body)) {
66748                     return grammarErrorOnFirstToken(node, ts.Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload);
66749                 }
66750                 else {
66751                     return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_are_not_valid_here);
66752                 }
66753             }
66754             else if (node.kind === 167 || node.kind === 168) {
66755                 var accessors = ts.getAllAccessorDeclarations(node.parent.members, node);
66756                 if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) {
66757                     return grammarErrorOnFirstToken(node, ts.Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name);
66758                 }
66759             }
66760             return false;
66761         }
66762         function checkGrammarModifiers(node) {
66763             var quickResult = reportObviousModifierErrors(node);
66764             if (quickResult !== undefined) {
66765                 return quickResult;
66766             }
66767             var lastStatic, lastDeclare, lastAsync, lastReadonly;
66768             var flags = 0;
66769             for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
66770                 var modifier = _a[_i];
66771                 if (modifier.kind !== 142) {
66772                     if (node.kind === 162 || node.kind === 164) {
66773                         return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_type_member, ts.tokenToString(modifier.kind));
66774                     }
66775                     if (node.kind === 171) {
66776                         return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_an_index_signature, ts.tokenToString(modifier.kind));
66777                     }
66778                 }
66779                 switch (modifier.kind) {
66780                     case 84:
66781                         if (node.kind !== 255) {
66782                             return grammarErrorOnNode(node, ts.Diagnostics.A_class_member_cannot_have_the_0_keyword, ts.tokenToString(84));
66783                         }
66784                         break;
66785                     case 122:
66786                     case 121:
66787                     case 120:
66788                         var text = visibilityToString(ts.modifierToFlag(modifier.kind));
66789                         if (flags & 28) {
66790                             return grammarErrorOnNode(modifier, ts.Diagnostics.Accessibility_modifier_already_seen);
66791                         }
66792                         else if (flags & 32) {
66793                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "static");
66794                         }
66795                         else if (flags & 64) {
66796                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "readonly");
66797                         }
66798                         else if (flags & 256) {
66799                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "async");
66800                         }
66801                         else if (node.parent.kind === 257 || node.parent.kind === 297) {
66802                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, text);
66803                         }
66804                         else if (flags & 128) {
66805                             if (modifier.kind === 120) {
66806                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, text, "abstract");
66807                             }
66808                             else {
66809                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, text, "abstract");
66810                             }
66811                         }
66812                         else if (ts.isPrivateIdentifierPropertyDeclaration(node)) {
66813                             return grammarErrorOnNode(modifier, ts.Diagnostics.An_accessibility_modifier_cannot_be_used_with_a_private_identifier);
66814                         }
66815                         flags |= ts.modifierToFlag(modifier.kind);
66816                         break;
66817                     case 123:
66818                         if (flags & 32) {
66819                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "static");
66820                         }
66821                         else if (flags & 64) {
66822                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "readonly");
66823                         }
66824                         else if (flags & 256) {
66825                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "static", "async");
66826                         }
66827                         else if (node.parent.kind === 257 || node.parent.kind === 297) {
66828                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_module_or_namespace_element, "static");
66829                         }
66830                         else if (node.kind === 160) {
66831                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "static");
66832                         }
66833                         else if (flags & 128) {
66834                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract");
66835                         }
66836                         else if (ts.isPrivateIdentifierPropertyDeclaration(node)) {
66837                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "static");
66838                         }
66839                         flags |= 32;
66840                         lastStatic = modifier;
66841                         break;
66842                     case 142:
66843                         if (flags & 64) {
66844                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "readonly");
66845                         }
66846                         else if (node.kind !== 163 && node.kind !== 162 && node.kind !== 171 && node.kind !== 160) {
66847                             return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature);
66848                         }
66849                         flags |= 64;
66850                         lastReadonly = modifier;
66851                         break;
66852                     case 92:
66853                         if (flags & 1) {
66854                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "export");
66855                         }
66856                         else if (flags & 2) {
66857                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "declare");
66858                         }
66859                         else if (flags & 128) {
66860                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "abstract");
66861                         }
66862                         else if (flags & 256) {
66863                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_must_precede_1_modifier, "export", "async");
66864                         }
66865                         else if (ts.isClassLike(node.parent)) {
66866                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "export");
66867                         }
66868                         else if (node.kind === 160) {
66869                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export");
66870                         }
66871                         flags |= 1;
66872                         break;
66873                     case 87:
66874                         var container = node.parent.kind === 297 ? node.parent : node.parent.parent;
66875                         if (container.kind === 256 && !ts.isAmbientModule(container)) {
66876                             return grammarErrorOnNode(modifier, ts.Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module);
66877                         }
66878                         flags |= 512;
66879                         break;
66880                     case 133:
66881                         if (flags & 2) {
66882                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "declare");
66883                         }
66884                         else if (flags & 256) {
66885                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
66886                         }
66887                         else if (ts.isClassLike(node.parent) && !ts.isPropertyDeclaration(node)) {
66888                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind, "declare");
66889                         }
66890                         else if (node.kind === 160) {
66891                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare");
66892                         }
66893                         else if ((node.parent.flags & 8388608) && node.parent.kind === 257) {
66894                             return grammarErrorOnNode(modifier, ts.Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context);
66895                         }
66896                         else if (ts.isPrivateIdentifierPropertyDeclaration(node)) {
66897                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "declare");
66898                         }
66899                         flags |= 2;
66900                         lastDeclare = modifier;
66901                         break;
66902                     case 125:
66903                         if (flags & 128) {
66904                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "abstract");
66905                         }
66906                         if (node.kind !== 252 &&
66907                             node.kind !== 175) {
66908                             if (node.kind !== 165 &&
66909                                 node.kind !== 163 &&
66910                                 node.kind !== 167 &&
66911                                 node.kind !== 168) {
66912                                 return grammarErrorOnNode(modifier, ts.Diagnostics.abstract_modifier_can_only_appear_on_a_class_method_or_property_declaration);
66913                             }
66914                             if (!(node.parent.kind === 252 && ts.hasSyntacticModifier(node.parent, 128))) {
66915                                 return grammarErrorOnNode(modifier, ts.Diagnostics.Abstract_methods_can_only_appear_within_an_abstract_class);
66916                             }
66917                             if (flags & 32) {
66918                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "static", "abstract");
66919                             }
66920                             if (flags & 8) {
66921                                 return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "private", "abstract");
66922                             }
66923                             if (flags & 256 && lastAsync) {
66924                                 return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract");
66925                             }
66926                         }
66927                         if (ts.isNamedDeclaration(node) && node.name.kind === 79) {
66928                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_a_private_identifier, "abstract");
66929                         }
66930                         flags |= 128;
66931                         break;
66932                     case 129:
66933                         if (flags & 256) {
66934                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_already_seen, "async");
66935                         }
66936                         else if (flags & 2 || node.parent.flags & 8388608) {
66937                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_in_an_ambient_context, "async");
66938                         }
66939                         else if (node.kind === 160) {
66940                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_appear_on_a_parameter, "async");
66941                         }
66942                         if (flags & 128) {
66943                             return grammarErrorOnNode(modifier, ts.Diagnostics._0_modifier_cannot_be_used_with_1_modifier, "async", "abstract");
66944                         }
66945                         flags |= 256;
66946                         lastAsync = modifier;
66947                         break;
66948                 }
66949             }
66950             if (node.kind === 166) {
66951                 if (flags & 32) {
66952                     return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static");
66953                 }
66954                 if (flags & 128) {
66955                     return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract");
66956                 }
66957                 else if (flags & 256) {
66958                     return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async");
66959                 }
66960                 else if (flags & 64) {
66961                     return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly");
66962                 }
66963                 return false;
66964             }
66965             else if ((node.kind === 261 || node.kind === 260) && flags & 2) {
66966                 return grammarErrorOnNode(lastDeclare, ts.Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare");
66967             }
66968             else if (node.kind === 160 && (flags & 92) && ts.isBindingPattern(node.name)) {
66969                 return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern);
66970             }
66971             else if (node.kind === 160 && (flags & 92) && node.dotDotDotToken) {
66972                 return grammarErrorOnNode(node, ts.Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter);
66973             }
66974             if (flags & 256) {
66975                 return checkGrammarAsyncModifier(node, lastAsync);
66976             }
66977             return false;
66978         }
66979         function reportObviousModifierErrors(node) {
66980             return !node.modifiers
66981                 ? false
66982                 : shouldReportBadModifier(node)
66983                     ? grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here)
66984                     : undefined;
66985         }
66986         function shouldReportBadModifier(node) {
66987             switch (node.kind) {
66988                 case 167:
66989                 case 168:
66990                 case 166:
66991                 case 163:
66992                 case 162:
66993                 case 165:
66994                 case 164:
66995                 case 171:
66996                 case 256:
66997                 case 261:
66998                 case 260:
66999                 case 267:
67000                 case 266:
67001                 case 208:
67002                 case 209:
67003                 case 160:
67004                     return false;
67005                 default:
67006                     if (node.parent.kind === 257 || node.parent.kind === 297) {
67007                         return false;
67008                     }
67009                     switch (node.kind) {
67010                         case 251:
67011                             return nodeHasAnyModifiersExcept(node, 129);
67012                         case 252:
67013                         case 175:
67014                             return nodeHasAnyModifiersExcept(node, 125);
67015                         case 253:
67016                         case 232:
67017                         case 254:
67018                             return true;
67019                         case 255:
67020                             return nodeHasAnyModifiersExcept(node, 84);
67021                         default:
67022                             ts.Debug.fail();
67023                     }
67024             }
67025         }
67026         function nodeHasAnyModifiersExcept(node, allowedModifier) {
67027             return node.modifiers.length > 1 || node.modifiers[0].kind !== allowedModifier;
67028         }
67029         function checkGrammarAsyncModifier(node, asyncModifier) {
67030             switch (node.kind) {
67031                 case 165:
67032                 case 251:
67033                 case 208:
67034                 case 209:
67035                     return false;
67036             }
67037             return grammarErrorOnNode(asyncModifier, ts.Diagnostics._0_modifier_cannot_be_used_here, "async");
67038         }
67039         function checkGrammarForDisallowedTrailingComma(list, diag) {
67040             if (diag === void 0) { diag = ts.Diagnostics.Trailing_comma_not_allowed; }
67041             if (list && list.hasTrailingComma) {
67042                 return grammarErrorAtPos(list[0], list.end - ",".length, ",".length, diag);
67043             }
67044             return false;
67045         }
67046         function checkGrammarTypeParameterList(typeParameters, file) {
67047             if (typeParameters && typeParameters.length === 0) {
67048                 var start = typeParameters.pos - "<".length;
67049                 var end = ts.skipTrivia(file.text, typeParameters.end) + ">".length;
67050                 return grammarErrorAtPos(file, start, end - start, ts.Diagnostics.Type_parameter_list_cannot_be_empty);
67051             }
67052             return false;
67053         }
67054         function checkGrammarParameterList(parameters) {
67055             var seenOptionalParameter = false;
67056             var parameterCount = parameters.length;
67057             for (var i = 0; i < parameterCount; i++) {
67058                 var parameter = parameters[i];
67059                 if (parameter.dotDotDotToken) {
67060                     if (i !== (parameterCount - 1)) {
67061                         return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_rest_parameter_must_be_last_in_a_parameter_list);
67062                     }
67063                     if (!(parameter.flags & 8388608)) {
67064                         checkGrammarForDisallowedTrailingComma(parameters, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
67065                     }
67066                     if (parameter.questionToken) {
67067                         return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_rest_parameter_cannot_be_optional);
67068                     }
67069                     if (parameter.initializer) {
67070                         return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_rest_parameter_cannot_have_an_initializer);
67071                     }
67072                 }
67073                 else if (isOptionalParameter(parameter)) {
67074                     seenOptionalParameter = true;
67075                     if (parameter.questionToken && parameter.initializer) {
67076                         return grammarErrorOnNode(parameter.name, ts.Diagnostics.Parameter_cannot_have_question_mark_and_initializer);
67077                     }
67078                 }
67079                 else if (seenOptionalParameter && !parameter.initializer) {
67080                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.A_required_parameter_cannot_follow_an_optional_parameter);
67081                 }
67082             }
67083         }
67084         function getNonSimpleParameters(parameters) {
67085             return ts.filter(parameters, function (parameter) { return !!parameter.initializer || ts.isBindingPattern(parameter.name) || ts.isRestParameter(parameter); });
67086         }
67087         function checkGrammarForUseStrictSimpleParameterList(node) {
67088             if (languageVersion >= 3) {
67089                 var useStrictDirective_1 = node.body && ts.isBlock(node.body) && ts.findUseStrictPrologue(node.body.statements);
67090                 if (useStrictDirective_1) {
67091                     var nonSimpleParameters = getNonSimpleParameters(node.parameters);
67092                     if (ts.length(nonSimpleParameters)) {
67093                         ts.forEach(nonSimpleParameters, function (parameter) {
67094                             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));
67095                         });
67096                         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)); });
67097                         ts.addRelatedInfo.apply(void 0, __spreadArray([error(useStrictDirective_1, ts.Diagnostics.use_strict_directive_cannot_be_used_with_non_simple_parameter_list)], diagnostics_2));
67098                         return true;
67099                     }
67100                 }
67101             }
67102             return false;
67103         }
67104         function checkGrammarFunctionLikeDeclaration(node) {
67105             var file = ts.getSourceFileOfNode(node);
67106             return checkGrammarDecoratorsAndModifiers(node) ||
67107                 checkGrammarTypeParameterList(node.typeParameters, file) ||
67108                 checkGrammarParameterList(node.parameters) ||
67109                 checkGrammarArrowFunction(node, file) ||
67110                 (ts.isFunctionLikeDeclaration(node) && checkGrammarForUseStrictSimpleParameterList(node));
67111         }
67112         function checkGrammarClassLikeDeclaration(node) {
67113             var file = ts.getSourceFileOfNode(node);
67114             return checkGrammarClassDeclarationHeritageClauses(node) ||
67115                 checkGrammarTypeParameterList(node.typeParameters, file);
67116         }
67117         function checkGrammarArrowFunction(node, file) {
67118             if (!ts.isArrowFunction(node)) {
67119                 return false;
67120             }
67121             var equalsGreaterThanToken = node.equalsGreaterThanToken;
67122             var startLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.pos).line;
67123             var endLine = ts.getLineAndCharacterOfPosition(file, equalsGreaterThanToken.end).line;
67124             return startLine !== endLine && grammarErrorOnNode(equalsGreaterThanToken, ts.Diagnostics.Line_terminator_not_permitted_before_arrow);
67125         }
67126         function checkGrammarIndexSignatureParameters(node) {
67127             var parameter = node.parameters[0];
67128             if (node.parameters.length !== 1) {
67129                 if (parameter) {
67130                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter);
67131                 }
67132                 else {
67133                     return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_exactly_one_parameter);
67134                 }
67135             }
67136             checkGrammarForDisallowedTrailingComma(node.parameters, ts.Diagnostics.An_index_signature_cannot_have_a_trailing_comma);
67137             if (parameter.dotDotDotToken) {
67138                 return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.An_index_signature_cannot_have_a_rest_parameter);
67139             }
67140             if (ts.hasEffectiveModifiers(parameter)) {
67141                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_accessibility_modifier);
67142             }
67143             if (parameter.questionToken) {
67144                 return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.An_index_signature_parameter_cannot_have_a_question_mark);
67145             }
67146             if (parameter.initializer) {
67147                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_cannot_have_an_initializer);
67148             }
67149             if (!parameter.type) {
67150                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_must_have_a_type_annotation);
67151             }
67152             if (parameter.type.kind !== 147 && parameter.type.kind !== 144) {
67153                 var type = getTypeFromTypeNode(parameter.type);
67154                 if (type.flags & 4 || type.flags & 8) {
67155                     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));
67156                 }
67157                 if (type.flags & 1048576 && allTypesAssignableToKind(type, 384, true)) {
67158                     return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_cannot_be_a_union_type_Consider_using_a_mapped_object_type_instead);
67159                 }
67160                 return grammarErrorOnNode(parameter.name, ts.Diagnostics.An_index_signature_parameter_type_must_be_either_string_or_number);
67161             }
67162             if (!node.type) {
67163                 return grammarErrorOnNode(node, ts.Diagnostics.An_index_signature_must_have_a_type_annotation);
67164             }
67165             return false;
67166         }
67167         function checkGrammarIndexSignature(node) {
67168             return checkGrammarDecoratorsAndModifiers(node) || checkGrammarIndexSignatureParameters(node);
67169         }
67170         function checkGrammarForAtLeastOneTypeArgument(node, typeArguments) {
67171             if (typeArguments && typeArguments.length === 0) {
67172                 var sourceFile = ts.getSourceFileOfNode(node);
67173                 var start = typeArguments.pos - "<".length;
67174                 var end = ts.skipTrivia(sourceFile.text, typeArguments.end) + ">".length;
67175                 return grammarErrorAtPos(sourceFile, start, end - start, ts.Diagnostics.Type_argument_list_cannot_be_empty);
67176             }
67177             return false;
67178         }
67179         function checkGrammarTypeArguments(node, typeArguments) {
67180             return checkGrammarForDisallowedTrailingComma(typeArguments) ||
67181                 checkGrammarForAtLeastOneTypeArgument(node, typeArguments);
67182         }
67183         function checkGrammarTaggedTemplateChain(node) {
67184             if (node.questionDotToken || node.flags & 32) {
67185                 return grammarErrorOnNode(node.template, ts.Diagnostics.Tagged_template_expressions_are_not_permitted_in_an_optional_chain);
67186             }
67187             return false;
67188         }
67189         function checkGrammarForOmittedArgument(args) {
67190             if (args) {
67191                 for (var _i = 0, args_4 = args; _i < args_4.length; _i++) {
67192                     var arg = args_4[_i];
67193                     if (arg.kind === 222) {
67194                         return grammarErrorAtPos(arg, arg.pos, 0, ts.Diagnostics.Argument_expression_expected);
67195                     }
67196                 }
67197             }
67198             return false;
67199         }
67200         function checkGrammarArguments(args) {
67201             return checkGrammarForOmittedArgument(args);
67202         }
67203         function checkGrammarHeritageClause(node) {
67204             var types = node.types;
67205             if (checkGrammarForDisallowedTrailingComma(types)) {
67206                 return true;
67207             }
67208             if (types && types.length === 0) {
67209                 var listType = ts.tokenToString(node.token);
67210                 return grammarErrorAtPos(node, types.pos, 0, ts.Diagnostics._0_list_cannot_be_empty, listType);
67211             }
67212             return ts.some(types, checkGrammarExpressionWithTypeArguments);
67213         }
67214         function checkGrammarExpressionWithTypeArguments(node) {
67215             return checkGrammarTypeArguments(node, node.typeArguments);
67216         }
67217         function checkGrammarClassDeclarationHeritageClauses(node) {
67218             var seenExtendsClause = false;
67219             var seenImplementsClause = false;
67220             if (!checkGrammarDecoratorsAndModifiers(node) && node.heritageClauses) {
67221                 for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) {
67222                     var heritageClause = _a[_i];
67223                     if (heritageClause.token === 93) {
67224                         if (seenExtendsClause) {
67225                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen);
67226                         }
67227                         if (seenImplementsClause) {
67228                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_must_precede_implements_clause);
67229                         }
67230                         if (heritageClause.types.length > 1) {
67231                             return grammarErrorOnFirstToken(heritageClause.types[1], ts.Diagnostics.Classes_can_only_extend_a_single_class);
67232                         }
67233                         seenExtendsClause = true;
67234                     }
67235                     else {
67236                         ts.Debug.assert(heritageClause.token === 116);
67237                         if (seenImplementsClause) {
67238                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.implements_clause_already_seen);
67239                         }
67240                         seenImplementsClause = true;
67241                     }
67242                     checkGrammarHeritageClause(heritageClause);
67243                 }
67244             }
67245         }
67246         function checkGrammarInterfaceDeclaration(node) {
67247             var seenExtendsClause = false;
67248             if (node.heritageClauses) {
67249                 for (var _i = 0, _a = node.heritageClauses; _i < _a.length; _i++) {
67250                     var heritageClause = _a[_i];
67251                     if (heritageClause.token === 93) {
67252                         if (seenExtendsClause) {
67253                             return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.extends_clause_already_seen);
67254                         }
67255                         seenExtendsClause = true;
67256                     }
67257                     else {
67258                         ts.Debug.assert(heritageClause.token === 116);
67259                         return grammarErrorOnFirstToken(heritageClause, ts.Diagnostics.Interface_declaration_cannot_have_implements_clause);
67260                     }
67261                     checkGrammarHeritageClause(heritageClause);
67262                 }
67263             }
67264             return false;
67265         }
67266         function checkGrammarComputedPropertyName(node) {
67267             if (node.kind !== 158) {
67268                 return false;
67269             }
67270             var computedPropertyName = node;
67271             if (computedPropertyName.expression.kind === 216 && computedPropertyName.expression.operatorToken.kind === 27) {
67272                 return grammarErrorOnNode(computedPropertyName.expression, ts.Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name);
67273             }
67274             return false;
67275         }
67276         function checkGrammarForGenerator(node) {
67277             if (node.asteriskToken) {
67278                 ts.Debug.assert(node.kind === 251 ||
67279                     node.kind === 208 ||
67280                     node.kind === 165);
67281                 if (node.flags & 8388608) {
67282                     return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.Generators_are_not_allowed_in_an_ambient_context);
67283                 }
67284                 if (!node.body) {
67285                     return grammarErrorOnNode(node.asteriskToken, ts.Diagnostics.An_overload_signature_cannot_be_declared_as_a_generator);
67286                 }
67287             }
67288         }
67289         function checkGrammarForInvalidQuestionMark(questionToken, message) {
67290             return !!questionToken && grammarErrorOnNode(questionToken, message);
67291         }
67292         function checkGrammarForInvalidExclamationToken(exclamationToken, message) {
67293             return !!exclamationToken && grammarErrorOnNode(exclamationToken, message);
67294         }
67295         function checkGrammarObjectLiteralExpression(node, inDestructuring) {
67296             var seen = new ts.Map();
67297             for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
67298                 var prop = _a[_i];
67299                 if (prop.kind === 290) {
67300                     if (inDestructuring) {
67301                         var expression = ts.skipParentheses(prop.expression);
67302                         if (ts.isArrayLiteralExpression(expression) || ts.isObjectLiteralExpression(expression)) {
67303                             return grammarErrorOnNode(prop.expression, ts.Diagnostics.A_rest_element_cannot_contain_a_binding_pattern);
67304                         }
67305                     }
67306                     continue;
67307                 }
67308                 var name = prop.name;
67309                 if (name.kind === 158) {
67310                     checkGrammarComputedPropertyName(name);
67311                 }
67312                 if (prop.kind === 289 && !inDestructuring && prop.objectAssignmentInitializer) {
67313                     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);
67314                 }
67315                 if (name.kind === 79) {
67316                     return grammarErrorOnNode(name, ts.Diagnostics.Private_identifiers_are_not_allowed_outside_class_bodies);
67317                 }
67318                 if (prop.modifiers) {
67319                     for (var _b = 0, _c = prop.modifiers; _b < _c.length; _b++) {
67320                         var mod = _c[_b];
67321                         if (mod.kind !== 129 || prop.kind !== 165) {
67322                             grammarErrorOnNode(mod, ts.Diagnostics._0_modifier_cannot_be_used_here, ts.getTextOfNode(mod));
67323                         }
67324                     }
67325                 }
67326                 var currentKind = void 0;
67327                 switch (prop.kind) {
67328                     case 289:
67329                         checkGrammarForInvalidExclamationToken(prop.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context);
67330                     case 288:
67331                         checkGrammarForInvalidQuestionMark(prop.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional);
67332                         if (name.kind === 8) {
67333                             checkGrammarNumericLiteral(name);
67334                         }
67335                         currentKind = 4;
67336                         break;
67337                     case 165:
67338                         currentKind = 8;
67339                         break;
67340                     case 167:
67341                         currentKind = 1;
67342                         break;
67343                     case 168:
67344                         currentKind = 2;
67345                         break;
67346                     default:
67347                         throw ts.Debug.assertNever(prop, "Unexpected syntax kind:" + prop.kind);
67348                 }
67349                 if (!inDestructuring) {
67350                     var effectiveName = ts.getPropertyNameForPropertyNameNode(name);
67351                     if (effectiveName === undefined) {
67352                         continue;
67353                     }
67354                     var existingKind = seen.get(effectiveName);
67355                     if (!existingKind) {
67356                         seen.set(effectiveName, currentKind);
67357                     }
67358                     else {
67359                         if ((currentKind & 12) && (existingKind & 12)) {
67360                             grammarErrorOnNode(name, ts.Diagnostics.Duplicate_identifier_0, ts.getTextOfNode(name));
67361                         }
67362                         else if ((currentKind & 3) && (existingKind & 3)) {
67363                             if (existingKind !== 3 && currentKind !== existingKind) {
67364                                 seen.set(effectiveName, currentKind | existingKind);
67365                             }
67366                             else {
67367                                 return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_multiple_get_Slashset_accessors_with_the_same_name);
67368                             }
67369                         }
67370                         else {
67371                             return grammarErrorOnNode(name, ts.Diagnostics.An_object_literal_cannot_have_property_and_accessor_with_the_same_name);
67372                         }
67373                     }
67374                 }
67375             }
67376         }
67377         function checkGrammarJsxElement(node) {
67378             checkGrammarTypeArguments(node, node.typeArguments);
67379             var seen = new ts.Map();
67380             for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) {
67381                 var attr = _a[_i];
67382                 if (attr.kind === 282) {
67383                     continue;
67384                 }
67385                 var name = attr.name, initializer = attr.initializer;
67386                 if (!seen.get(name.escapedText)) {
67387                     seen.set(name.escapedText, true);
67388                 }
67389                 else {
67390                     return grammarErrorOnNode(name, ts.Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name);
67391                 }
67392                 if (initializer && initializer.kind === 283 && !initializer.expression) {
67393                     return grammarErrorOnNode(initializer, ts.Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression);
67394                 }
67395             }
67396         }
67397         function checkGrammarJsxExpression(node) {
67398             if (node.expression && ts.isCommaSequence(node.expression)) {
67399                 return grammarErrorOnNode(node.expression, ts.Diagnostics.JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array);
67400             }
67401         }
67402         function checkGrammarForInOrForOfStatement(forInOrOfStatement) {
67403             if (checkGrammarStatementInAmbientContext(forInOrOfStatement)) {
67404                 return true;
67405             }
67406             if (forInOrOfStatement.kind === 239 && forInOrOfStatement.awaitModifier) {
67407                 if (!(forInOrOfStatement.flags & 32768)) {
67408                     var sourceFile = ts.getSourceFileOfNode(forInOrOfStatement);
67409                     if (ts.isInTopLevelContext(forInOrOfStatement)) {
67410                         if (!hasParseDiagnostics(sourceFile)) {
67411                             if (!ts.isEffectiveExternalModule(sourceFile, compilerOptions)) {
67412                                 diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_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));
67413                             }
67414                             if ((moduleKind !== ts.ModuleKind.ESNext && moduleKind !== ts.ModuleKind.System) || languageVersion < 4) {
67415                                 diagnostics.add(ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_esnext_or_system_and_the_target_option_is_set_to_es2017_or_higher));
67416                             }
67417                         }
67418                     }
67419                     else {
67420                         if (!hasParseDiagnostics(sourceFile)) {
67421                             var diagnostic = ts.createDiagnosticForNode(forInOrOfStatement.awaitModifier, ts.Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules);
67422                             var func = ts.getContainingFunction(forInOrOfStatement);
67423                             if (func && func.kind !== 166) {
67424                                 ts.Debug.assert((ts.getFunctionFlags(func) & 2) === 0, "Enclosing function should never be an async function.");
67425                                 var relatedInfo = ts.createDiagnosticForNode(func, ts.Diagnostics.Did_you_mean_to_mark_this_function_as_async);
67426                                 ts.addRelatedInfo(diagnostic, relatedInfo);
67427                             }
67428                             diagnostics.add(diagnostic);
67429                             return true;
67430                         }
67431                     }
67432                     return false;
67433                 }
67434             }
67435             if (forInOrOfStatement.initializer.kind === 250) {
67436                 var variableList = forInOrOfStatement.initializer;
67437                 if (!checkGrammarVariableDeclarationList(variableList)) {
67438                     var declarations = variableList.declarations;
67439                     if (!declarations.length) {
67440                         return false;
67441                     }
67442                     if (declarations.length > 1) {
67443                         var diagnostic = forInOrOfStatement.kind === 238
67444                             ? ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_in_statement
67445                             : ts.Diagnostics.Only_a_single_variable_declaration_is_allowed_in_a_for_of_statement;
67446                         return grammarErrorOnFirstToken(variableList.declarations[1], diagnostic);
67447                     }
67448                     var firstDeclaration = declarations[0];
67449                     if (firstDeclaration.initializer) {
67450                         var diagnostic = forInOrOfStatement.kind === 238
67451                             ? ts.Diagnostics.The_variable_declaration_of_a_for_in_statement_cannot_have_an_initializer
67452                             : ts.Diagnostics.The_variable_declaration_of_a_for_of_statement_cannot_have_an_initializer;
67453                         return grammarErrorOnNode(firstDeclaration.name, diagnostic);
67454                     }
67455                     if (firstDeclaration.type) {
67456                         var diagnostic = forInOrOfStatement.kind === 238
67457                             ? ts.Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation
67458                             : ts.Diagnostics.The_left_hand_side_of_a_for_of_statement_cannot_use_a_type_annotation;
67459                         return grammarErrorOnNode(firstDeclaration, diagnostic);
67460                     }
67461                 }
67462             }
67463             return false;
67464         }
67465         function checkGrammarAccessor(accessor) {
67466             if (!(accessor.flags & 8388608)) {
67467                 if (languageVersion < 1) {
67468                     return grammarErrorOnNode(accessor.name, ts.Diagnostics.Accessors_are_only_available_when_targeting_ECMAScript_5_and_higher);
67469                 }
67470                 if (accessor.body === undefined && !ts.hasSyntacticModifier(accessor, 128)) {
67471                     return grammarErrorAtPos(accessor, accessor.end - 1, ";".length, ts.Diagnostics._0_expected, "{");
67472                 }
67473             }
67474             if (accessor.body && ts.hasSyntacticModifier(accessor, 128)) {
67475                 return grammarErrorOnNode(accessor, ts.Diagnostics.An_abstract_accessor_cannot_have_an_implementation);
67476             }
67477             if (accessor.typeParameters) {
67478                 return grammarErrorOnNode(accessor.name, ts.Diagnostics.An_accessor_cannot_have_type_parameters);
67479             }
67480             if (!doesAccessorHaveCorrectParameterCount(accessor)) {
67481                 return grammarErrorOnNode(accessor.name, accessor.kind === 167 ?
67482                     ts.Diagnostics.A_get_accessor_cannot_have_parameters :
67483                     ts.Diagnostics.A_set_accessor_must_have_exactly_one_parameter);
67484             }
67485             if (accessor.kind === 168) {
67486                 if (accessor.type) {
67487                     return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation);
67488                 }
67489                 var parameter = ts.Debug.checkDefined(ts.getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion.");
67490                 if (parameter.dotDotDotToken) {
67491                     return grammarErrorOnNode(parameter.dotDotDotToken, ts.Diagnostics.A_set_accessor_cannot_have_rest_parameter);
67492                 }
67493                 if (parameter.questionToken) {
67494                     return grammarErrorOnNode(parameter.questionToken, ts.Diagnostics.A_set_accessor_cannot_have_an_optional_parameter);
67495                 }
67496                 if (parameter.initializer) {
67497                     return grammarErrorOnNode(accessor.name, ts.Diagnostics.A_set_accessor_parameter_cannot_have_an_initializer);
67498                 }
67499             }
67500             return false;
67501         }
67502         function doesAccessorHaveCorrectParameterCount(accessor) {
67503             return getAccessorThisParameter(accessor) || accessor.parameters.length === (accessor.kind === 167 ? 0 : 1);
67504         }
67505         function getAccessorThisParameter(accessor) {
67506             if (accessor.parameters.length === (accessor.kind === 167 ? 1 : 2)) {
67507                 return ts.getThisParameter(accessor);
67508             }
67509         }
67510         function checkGrammarTypeOperatorNode(node) {
67511             if (node.operator === 151) {
67512                 if (node.type.kind !== 148) {
67513                     return grammarErrorOnNode(node.type, ts.Diagnostics._0_expected, ts.tokenToString(148));
67514                 }
67515                 var parent = ts.walkUpParenthesizedTypes(node.parent);
67516                 if (ts.isInJSFile(parent) && ts.isJSDocTypeExpression(parent)) {
67517                     parent = parent.parent;
67518                     if (ts.isJSDocTypeTag(parent)) {
67519                         parent = parent.parent.parent;
67520                     }
67521                 }
67522                 switch (parent.kind) {
67523                     case 249:
67524                         var decl = parent;
67525                         if (decl.name.kind !== 78) {
67526                             return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_may_not_be_used_on_a_variable_declaration_with_a_binding_name);
67527                         }
67528                         if (!ts.isVariableDeclarationInVariableStatement(decl)) {
67529                             return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_only_allowed_on_variables_in_a_variable_statement);
67530                         }
67531                         if (!(decl.parent.flags & 2)) {
67532                             return grammarErrorOnNode(parent.name, ts.Diagnostics.A_variable_whose_type_is_a_unique_symbol_type_must_be_const);
67533                         }
67534                         break;
67535                     case 163:
67536                         if (!ts.hasSyntacticModifier(parent, 32) ||
67537                             !ts.hasEffectiveModifier(parent, 64)) {
67538                             return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_a_class_whose_type_is_a_unique_symbol_type_must_be_both_static_and_readonly);
67539                         }
67540                         break;
67541                     case 162:
67542                         if (!ts.hasSyntacticModifier(parent, 64)) {
67543                             return grammarErrorOnNode(parent.name, ts.Diagnostics.A_property_of_an_interface_or_type_literal_whose_type_is_a_unique_symbol_type_must_be_readonly);
67544                         }
67545                         break;
67546                     default:
67547                         return grammarErrorOnNode(node, ts.Diagnostics.unique_symbol_types_are_not_allowed_here);
67548                 }
67549             }
67550             else if (node.operator === 142) {
67551                 if (node.type.kind !== 178 && node.type.kind !== 179) {
67552                     return grammarErrorOnFirstToken(node, ts.Diagnostics.readonly_type_modifier_is_only_permitted_on_array_and_tuple_literal_types, ts.tokenToString(148));
67553                 }
67554             }
67555         }
67556         function checkGrammarForInvalidDynamicName(node, message) {
67557             if (isNonBindableDynamicName(node)) {
67558                 return grammarErrorOnNode(node, message);
67559             }
67560         }
67561         function checkGrammarMethod(node) {
67562             if (checkGrammarFunctionLikeDeclaration(node)) {
67563                 return true;
67564             }
67565             if (node.kind === 165) {
67566                 if (node.parent.kind === 200) {
67567                     if (node.modifiers && !(node.modifiers.length === 1 && ts.first(node.modifiers).kind === 129)) {
67568                         return grammarErrorOnFirstToken(node, ts.Diagnostics.Modifiers_cannot_appear_here);
67569                     }
67570                     else if (checkGrammarForInvalidQuestionMark(node.questionToken, ts.Diagnostics.An_object_member_cannot_be_declared_optional)) {
67571                         return true;
67572                     }
67573                     else if (checkGrammarForInvalidExclamationToken(node.exclamationToken, ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context)) {
67574                         return true;
67575                     }
67576                     else if (node.body === undefined) {
67577                         return grammarErrorAtPos(node, node.end - 1, ";".length, ts.Diagnostics._0_expected, "{");
67578                     }
67579                 }
67580                 if (checkGrammarForGenerator(node)) {
67581                     return true;
67582                 }
67583             }
67584             if (ts.isClassLike(node.parent)) {
67585                 if (node.flags & 8388608) {
67586                     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);
67587                 }
67588                 else if (node.kind === 165 && !node.body) {
67589                     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);
67590                 }
67591             }
67592             else if (node.parent.kind === 253) {
67593                 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);
67594             }
67595             else if (node.parent.kind === 177) {
67596                 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);
67597             }
67598         }
67599         function checkGrammarBreakOrContinueStatement(node) {
67600             var current = node;
67601             while (current) {
67602                 if (ts.isFunctionLike(current)) {
67603                     return grammarErrorOnNode(node, ts.Diagnostics.Jump_target_cannot_cross_function_boundary);
67604                 }
67605                 switch (current.kind) {
67606                     case 245:
67607                         if (node.label && current.label.escapedText === node.label.escapedText) {
67608                             var isMisplacedContinueLabel = node.kind === 240
67609                                 && !ts.isIterationStatement(current.statement, true);
67610                             if (isMisplacedContinueLabel) {
67611                                 return grammarErrorOnNode(node, ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement);
67612                             }
67613                             return false;
67614                         }
67615                         break;
67616                     case 244:
67617                         if (node.kind === 241 && !node.label) {
67618                             return false;
67619                         }
67620                         break;
67621                     default:
67622                         if (ts.isIterationStatement(current, false) && !node.label) {
67623                             return false;
67624                         }
67625                         break;
67626                 }
67627                 current = current.parent;
67628             }
67629             if (node.label) {
67630                 var message = node.kind === 241
67631                     ? ts.Diagnostics.A_break_statement_can_only_jump_to_a_label_of_an_enclosing_statement
67632                     : ts.Diagnostics.A_continue_statement_can_only_jump_to_a_label_of_an_enclosing_iteration_statement;
67633                 return grammarErrorOnNode(node, message);
67634             }
67635             else {
67636                 var message = node.kind === 241
67637                     ? ts.Diagnostics.A_break_statement_can_only_be_used_within_an_enclosing_iteration_or_switch_statement
67638                     : ts.Diagnostics.A_continue_statement_can_only_be_used_within_an_enclosing_iteration_statement;
67639                 return grammarErrorOnNode(node, message);
67640             }
67641         }
67642         function checkGrammarBindingElement(node) {
67643             if (node.dotDotDotToken) {
67644                 var elements = node.parent.elements;
67645                 if (node !== ts.last(elements)) {
67646                     return grammarErrorOnNode(node, ts.Diagnostics.A_rest_element_must_be_last_in_a_destructuring_pattern);
67647                 }
67648                 checkGrammarForDisallowedTrailingComma(elements, ts.Diagnostics.A_rest_parameter_or_binding_pattern_may_not_have_a_trailing_comma);
67649                 if (node.propertyName) {
67650                     return grammarErrorOnNode(node.name, ts.Diagnostics.A_rest_element_cannot_have_a_property_name);
67651                 }
67652             }
67653             if (node.dotDotDotToken && node.initializer) {
67654                 return grammarErrorAtPos(node, node.initializer.pos - 1, 1, ts.Diagnostics.A_rest_element_cannot_have_an_initializer);
67655             }
67656         }
67657         function isStringOrNumberLiteralExpression(expr) {
67658             return ts.isStringOrNumericLiteralLike(expr) ||
67659                 expr.kind === 214 && expr.operator === 40 &&
67660                     expr.operand.kind === 8;
67661         }
67662         function isBigIntLiteralExpression(expr) {
67663             return expr.kind === 9 ||
67664                 expr.kind === 214 && expr.operator === 40 &&
67665                     expr.operand.kind === 9;
67666         }
67667         function isSimpleLiteralEnumReference(expr) {
67668             if ((ts.isPropertyAccessExpression(expr) || (ts.isElementAccessExpression(expr) && isStringOrNumberLiteralExpression(expr.argumentExpression))) &&
67669                 ts.isEntityNameExpression(expr.expression)) {
67670                 return !!(checkExpressionCached(expr).flags & 1024);
67671             }
67672         }
67673         function checkAmbientInitializer(node) {
67674             var initializer = node.initializer;
67675             if (initializer) {
67676                 var isInvalidInitializer = !(isStringOrNumberLiteralExpression(initializer) ||
67677                     isSimpleLiteralEnumReference(initializer) ||
67678                     initializer.kind === 109 || initializer.kind === 94 ||
67679                     isBigIntLiteralExpression(initializer));
67680                 var isConstOrReadonly = ts.isDeclarationReadonly(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node);
67681                 if (isConstOrReadonly && !node.type) {
67682                     if (isInvalidInitializer) {
67683                         return grammarErrorOnNode(initializer, ts.Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference);
67684                     }
67685                 }
67686                 else {
67687                     return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
67688                 }
67689                 if (!isConstOrReadonly || isInvalidInitializer) {
67690                     return grammarErrorOnNode(initializer, ts.Diagnostics.Initializers_are_not_allowed_in_ambient_contexts);
67691                 }
67692             }
67693         }
67694         function checkGrammarVariableDeclaration(node) {
67695             if (node.parent.parent.kind !== 238 && node.parent.parent.kind !== 239) {
67696                 if (node.flags & 8388608) {
67697                     checkAmbientInitializer(node);
67698                 }
67699                 else if (!node.initializer) {
67700                     if (ts.isBindingPattern(node.name) && !ts.isBindingPattern(node.parent)) {
67701                         return grammarErrorOnNode(node, ts.Diagnostics.A_destructuring_declaration_must_have_an_initializer);
67702                     }
67703                     if (ts.isVarConst(node)) {
67704                         return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_must_be_initialized);
67705                     }
67706                 }
67707             }
67708             if (node.exclamationToken && (node.parent.parent.kind !== 232 || !node.type || node.initializer || node.flags & 8388608)) {
67709                 var message = node.initializer
67710                     ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
67711                     : !node.type
67712                         ? ts.Diagnostics.Declarations_with_definite_assignment_assertions_must_also_have_type_annotations
67713                         : ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context;
67714                 return grammarErrorOnNode(node.exclamationToken, message);
67715             }
67716             var moduleKind = ts.getEmitModuleKind(compilerOptions);
67717             if (moduleKind < ts.ModuleKind.ES2015 && moduleKind !== ts.ModuleKind.System &&
67718                 !(node.parent.parent.flags & 8388608) && ts.hasSyntacticModifier(node.parent.parent, 1)) {
67719                 checkESModuleMarker(node.name);
67720             }
67721             var checkLetConstNames = (ts.isLet(node) || ts.isVarConst(node));
67722             return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name);
67723         }
67724         function checkESModuleMarker(name) {
67725             if (name.kind === 78) {
67726                 if (ts.idText(name) === "__esModule") {
67727                     return grammarErrorOnNodeSkippedOn("noEmit", name, ts.Diagnostics.Identifier_expected_esModule_is_reserved_as_an_exported_marker_when_transforming_ECMAScript_modules);
67728                 }
67729             }
67730             else {
67731                 var elements = name.elements;
67732                 for (var _i = 0, elements_1 = elements; _i < elements_1.length; _i++) {
67733                     var element = elements_1[_i];
67734                     if (!ts.isOmittedExpression(element)) {
67735                         return checkESModuleMarker(element.name);
67736                     }
67737                 }
67738             }
67739             return false;
67740         }
67741         function checkGrammarNameInLetOrConstDeclarations(name) {
67742             if (name.kind === 78) {
67743                 if (name.originalKeywordKind === 118) {
67744                     return grammarErrorOnNode(name, ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations);
67745                 }
67746             }
67747             else {
67748                 var elements = name.elements;
67749                 for (var _i = 0, elements_2 = elements; _i < elements_2.length; _i++) {
67750                     var element = elements_2[_i];
67751                     if (!ts.isOmittedExpression(element)) {
67752                         checkGrammarNameInLetOrConstDeclarations(element.name);
67753                     }
67754                 }
67755             }
67756             return false;
67757         }
67758         function checkGrammarVariableDeclarationList(declarationList) {
67759             var declarations = declarationList.declarations;
67760             if (checkGrammarForDisallowedTrailingComma(declarationList.declarations)) {
67761                 return true;
67762             }
67763             if (!declarationList.declarations.length) {
67764                 return grammarErrorAtPos(declarationList, declarations.pos, declarations.end - declarations.pos, ts.Diagnostics.Variable_declaration_list_cannot_be_empty);
67765             }
67766             return false;
67767         }
67768         function allowLetAndConstDeclarations(parent) {
67769             switch (parent.kind) {
67770                 case 234:
67771                 case 235:
67772                 case 236:
67773                 case 243:
67774                 case 237:
67775                 case 238:
67776                 case 239:
67777                     return false;
67778                 case 245:
67779                     return allowLetAndConstDeclarations(parent.parent);
67780             }
67781             return true;
67782         }
67783         function checkGrammarForDisallowedLetOrConstStatement(node) {
67784             if (!allowLetAndConstDeclarations(node.parent)) {
67785                 if (ts.isLet(node.declarationList)) {
67786                     return grammarErrorOnNode(node, ts.Diagnostics.let_declarations_can_only_be_declared_inside_a_block);
67787                 }
67788                 else if (ts.isVarConst(node.declarationList)) {
67789                     return grammarErrorOnNode(node, ts.Diagnostics.const_declarations_can_only_be_declared_inside_a_block);
67790                 }
67791             }
67792         }
67793         function checkGrammarMetaProperty(node) {
67794             var escapedText = node.name.escapedText;
67795             switch (node.keywordToken) {
67796                 case 102:
67797                     if (escapedText !== "target") {
67798                         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");
67799                     }
67800                     break;
67801                 case 99:
67802                     if (escapedText !== "meta") {
67803                         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");
67804                     }
67805                     break;
67806             }
67807         }
67808         function hasParseDiagnostics(sourceFile) {
67809             return sourceFile.parseDiagnostics.length > 0;
67810         }
67811         function grammarErrorOnFirstToken(node, message, arg0, arg1, arg2) {
67812             var sourceFile = ts.getSourceFileOfNode(node);
67813             if (!hasParseDiagnostics(sourceFile)) {
67814                 var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
67815                 diagnostics.add(ts.createFileDiagnostic(sourceFile, span.start, span.length, message, arg0, arg1, arg2));
67816                 return true;
67817             }
67818             return false;
67819         }
67820         function grammarErrorAtPos(nodeForSourceFile, start, length, message, arg0, arg1, arg2) {
67821             var sourceFile = ts.getSourceFileOfNode(nodeForSourceFile);
67822             if (!hasParseDiagnostics(sourceFile)) {
67823                 diagnostics.add(ts.createFileDiagnostic(sourceFile, start, length, message, arg0, arg1, arg2));
67824                 return true;
67825             }
67826             return false;
67827         }
67828         function grammarErrorOnNodeSkippedOn(key, node, message, arg0, arg1, arg2) {
67829             var sourceFile = ts.getSourceFileOfNode(node);
67830             if (!hasParseDiagnostics(sourceFile)) {
67831                 errorSkippedOn(key, node, message, arg0, arg1, arg2);
67832                 return true;
67833             }
67834             return false;
67835         }
67836         function grammarErrorOnNode(node, message, arg0, arg1, arg2) {
67837             var sourceFile = ts.getSourceFileOfNode(node);
67838             if (!hasParseDiagnostics(sourceFile)) {
67839                 diagnostics.add(ts.createDiagnosticForNode(node, message, arg0, arg1, arg2));
67840                 return true;
67841             }
67842             return false;
67843         }
67844         function checkGrammarConstructorTypeParameters(node) {
67845             var jsdocTypeParameters = ts.isInJSFile(node) ? ts.getJSDocTypeParameterDeclarations(node) : undefined;
67846             var range = node.typeParameters || jsdocTypeParameters && ts.firstOrUndefined(jsdocTypeParameters);
67847             if (range) {
67848                 var pos = range.pos === range.end ? range.pos : ts.skipTrivia(ts.getSourceFileOfNode(node).text, range.pos);
67849                 return grammarErrorAtPos(node, pos, range.end - pos, ts.Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration);
67850             }
67851         }
67852         function checkGrammarConstructorTypeAnnotation(node) {
67853             var type = ts.getEffectiveReturnTypeNode(node);
67854             if (type) {
67855                 return grammarErrorOnNode(type, ts.Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration);
67856             }
67857         }
67858         function checkGrammarProperty(node) {
67859             if (ts.isClassLike(node.parent)) {
67860                 if (ts.isStringLiteral(node.name) && node.name.text === "constructor") {
67861                     return grammarErrorOnNode(node.name, ts.Diagnostics.Classes_may_not_have_a_field_named_constructor);
67862                 }
67863                 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)) {
67864                     return true;
67865                 }
67866                 if (languageVersion < 2 && ts.isPrivateIdentifier(node.name)) {
67867                     return grammarErrorOnNode(node.name, ts.Diagnostics.Private_identifiers_are_only_available_when_targeting_ECMAScript_2015_and_higher);
67868                 }
67869             }
67870             else if (node.parent.kind === 253) {
67871                 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)) {
67872                     return true;
67873                 }
67874                 if (node.initializer) {
67875                     return grammarErrorOnNode(node.initializer, ts.Diagnostics.An_interface_property_cannot_have_an_initializer);
67876                 }
67877             }
67878             else if (node.parent.kind === 177) {
67879                 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)) {
67880                     return true;
67881                 }
67882                 if (node.initializer) {
67883                     return grammarErrorOnNode(node.initializer, ts.Diagnostics.A_type_literal_property_cannot_have_an_initializer);
67884                 }
67885             }
67886             if (node.flags & 8388608) {
67887                 checkAmbientInitializer(node);
67888             }
67889             if (ts.isPropertyDeclaration(node) && node.exclamationToken && (!ts.isClassLike(node.parent) || !node.type || node.initializer ||
67890                 node.flags & 8388608 || ts.hasSyntacticModifier(node, 32 | 128))) {
67891                 var message = node.initializer
67892                     ? ts.Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions
67893                     : !node.type
67894                         ? ts.Diagnostics.Declarations_with_definite_assignment_assertions_must_also_have_type_annotations
67895                         : ts.Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context;
67896                 return grammarErrorOnNode(node.exclamationToken, message);
67897             }
67898         }
67899         function checkGrammarTopLevelElementForRequiredDeclareModifier(node) {
67900             if (node.kind === 253 ||
67901                 node.kind === 254 ||
67902                 node.kind === 261 ||
67903                 node.kind === 260 ||
67904                 node.kind === 267 ||
67905                 node.kind === 266 ||
67906                 node.kind === 259 ||
67907                 ts.hasSyntacticModifier(node, 2 | 1 | 512)) {
67908                 return false;
67909             }
67910             return grammarErrorOnFirstToken(node, ts.Diagnostics.Top_level_declarations_in_d_ts_files_must_start_with_either_a_declare_or_export_modifier);
67911         }
67912         function checkGrammarTopLevelElementsForRequiredDeclareModifier(file) {
67913             for (var _i = 0, _a = file.statements; _i < _a.length; _i++) {
67914                 var decl = _a[_i];
67915                 if (ts.isDeclaration(decl) || decl.kind === 232) {
67916                     if (checkGrammarTopLevelElementForRequiredDeclareModifier(decl)) {
67917                         return true;
67918                     }
67919                 }
67920             }
67921             return false;
67922         }
67923         function checkGrammarSourceFile(node) {
67924             return !!(node.flags & 8388608) && checkGrammarTopLevelElementsForRequiredDeclareModifier(node);
67925         }
67926         function checkGrammarStatementInAmbientContext(node) {
67927             if (node.flags & 8388608) {
67928                 var links = getNodeLinks(node);
67929                 if (!links.hasReportedStatementInAmbientContext && (ts.isFunctionLike(node.parent) || ts.isAccessor(node.parent))) {
67930                     return getNodeLinks(node).hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts);
67931                 }
67932                 if (node.parent.kind === 230 || node.parent.kind === 257 || node.parent.kind === 297) {
67933                     var links_2 = getNodeLinks(node.parent);
67934                     if (!links_2.hasReportedStatementInAmbientContext) {
67935                         return links_2.hasReportedStatementInAmbientContext = grammarErrorOnFirstToken(node, ts.Diagnostics.Statements_are_not_allowed_in_ambient_contexts);
67936                     }
67937                 }
67938                 else {
67939                 }
67940             }
67941             return false;
67942         }
67943         function checkGrammarNumericLiteral(node) {
67944             if (node.numericLiteralFlags & 32) {
67945                 var diagnosticMessage = void 0;
67946                 if (languageVersion >= 1) {
67947                     diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_available_when_targeting_ECMAScript_5_and_higher_Use_the_syntax_0;
67948                 }
67949                 else if (ts.isChildOfNodeWithKind(node, 191)) {
67950                     diagnosticMessage = ts.Diagnostics.Octal_literal_types_must_use_ES2015_syntax_Use_the_syntax_0;
67951                 }
67952                 else if (ts.isChildOfNodeWithKind(node, 291)) {
67953                     diagnosticMessage = ts.Diagnostics.Octal_literals_are_not_allowed_in_enums_members_initializer_Use_the_syntax_0;
67954                 }
67955                 if (diagnosticMessage) {
67956                     var withMinus = ts.isPrefixUnaryExpression(node.parent) && node.parent.operator === 40;
67957                     var literal = (withMinus ? "-" : "") + "0o" + node.text;
67958                     return grammarErrorOnNode(withMinus ? node.parent : node, diagnosticMessage, literal);
67959                 }
67960             }
67961             checkNumericLiteralValueSize(node);
67962             return false;
67963         }
67964         function checkNumericLiteralValueSize(node) {
67965             if (node.numericLiteralFlags & 16 || node.text.length <= 15 || node.text.indexOf(".") !== -1) {
67966                 return;
67967             }
67968             var apparentValue = +ts.getTextOfNode(node);
67969             if (apparentValue <= Math.pow(2, 53) - 1 && apparentValue + 1 > apparentValue) {
67970                 return;
67971             }
67972             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));
67973         }
67974         function checkGrammarBigIntLiteral(node) {
67975             var literalType = ts.isLiteralTypeNode(node.parent) ||
67976                 ts.isPrefixUnaryExpression(node.parent) && ts.isLiteralTypeNode(node.parent.parent);
67977             if (!literalType) {
67978                 if (languageVersion < 7) {
67979                     if (grammarErrorOnNode(node, ts.Diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020)) {
67980                         return true;
67981                     }
67982                 }
67983             }
67984             return false;
67985         }
67986         function grammarErrorAfterFirstToken(node, message, arg0, arg1, arg2) {
67987             var sourceFile = ts.getSourceFileOfNode(node);
67988             if (!hasParseDiagnostics(sourceFile)) {
67989                 var span = ts.getSpanOfTokenAtPosition(sourceFile, node.pos);
67990                 diagnostics.add(ts.createFileDiagnostic(sourceFile, ts.textSpanEnd(span), 0, message, arg0, arg1, arg2));
67991                 return true;
67992             }
67993             return false;
67994         }
67995         function getAmbientModules() {
67996             if (!ambientModulesCache) {
67997                 ambientModulesCache = [];
67998                 globals.forEach(function (global, sym) {
67999                     if (ambientModuleSymbolRegex.test(sym)) {
68000                         ambientModulesCache.push(global);
68001                     }
68002                 });
68003             }
68004             return ambientModulesCache;
68005         }
68006         function checkGrammarImportClause(node) {
68007             if (node.isTypeOnly && node.name && node.namedBindings) {
68008                 return grammarErrorOnNode(node, ts.Diagnostics.A_type_only_import_can_specify_a_default_import_or_named_bindings_but_not_both);
68009             }
68010             return false;
68011         }
68012         function checkGrammarImportCallExpression(node) {
68013             if (moduleKind === ts.ModuleKind.ES2015) {
68014                 return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_imports_are_only_supported_when_the_module_flag_is_set_to_es2020_esnext_commonjs_amd_system_or_umd);
68015             }
68016             if (node.typeArguments) {
68017                 return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_cannot_have_type_arguments);
68018             }
68019             var nodeArguments = node.arguments;
68020             if (nodeArguments.length !== 1) {
68021                 return grammarErrorOnNode(node, ts.Diagnostics.Dynamic_import_must_have_one_specifier_as_an_argument);
68022             }
68023             checkGrammarForDisallowedTrailingComma(nodeArguments);
68024             if (ts.isSpreadElement(nodeArguments[0])) {
68025                 return grammarErrorOnNode(nodeArguments[0], ts.Diagnostics.Specifier_of_dynamic_import_cannot_be_spread_element);
68026             }
68027             return false;
68028         }
68029         function findMatchingTypeReferenceOrTypeAliasReference(source, unionTarget) {
68030             var sourceObjectFlags = ts.getObjectFlags(source);
68031             if (sourceObjectFlags & (4 | 16) && unionTarget.flags & 1048576) {
68032                 return ts.find(unionTarget.types, function (target) {
68033                     if (target.flags & 524288) {
68034                         var overlapObjFlags = sourceObjectFlags & ts.getObjectFlags(target);
68035                         if (overlapObjFlags & 4) {
68036                             return source.target === target.target;
68037                         }
68038                         if (overlapObjFlags & 16) {
68039                             return !!source.aliasSymbol && source.aliasSymbol === target.aliasSymbol;
68040                         }
68041                     }
68042                     return false;
68043                 });
68044             }
68045         }
68046         function findBestTypeForObjectLiteral(source, unionTarget) {
68047             if (ts.getObjectFlags(source) & 128 && forEachType(unionTarget, isArrayLikeType)) {
68048                 return ts.find(unionTarget.types, function (t) { return !isArrayLikeType(t); });
68049             }
68050         }
68051         function findBestTypeForInvokable(source, unionTarget) {
68052             var signatureKind = 0;
68053             var hasSignatures = getSignaturesOfType(source, signatureKind).length > 0 ||
68054                 (signatureKind = 1, getSignaturesOfType(source, signatureKind).length > 0);
68055             if (hasSignatures) {
68056                 return ts.find(unionTarget.types, function (t) { return getSignaturesOfType(t, signatureKind).length > 0; });
68057             }
68058         }
68059         function findMostOverlappyType(source, unionTarget) {
68060             var bestMatch;
68061             var matchingCount = 0;
68062             for (var _i = 0, _a = unionTarget.types; _i < _a.length; _i++) {
68063                 var target = _a[_i];
68064                 var overlap = getIntersectionType([getIndexType(source), getIndexType(target)]);
68065                 if (overlap.flags & 4194304) {
68066                     bestMatch = target;
68067                     matchingCount = Infinity;
68068                 }
68069                 else if (overlap.flags & 1048576) {
68070                     var len = ts.length(ts.filter(overlap.types, isUnitType));
68071                     if (len >= matchingCount) {
68072                         bestMatch = target;
68073                         matchingCount = len;
68074                     }
68075                 }
68076                 else if (isUnitType(overlap) && 1 >= matchingCount) {
68077                     bestMatch = target;
68078                     matchingCount = 1;
68079                 }
68080             }
68081             return bestMatch;
68082         }
68083         function filterPrimitivesIfContainsNonPrimitive(type) {
68084             if (maybeTypeOfKind(type, 67108864)) {
68085                 var result = filterType(type, function (t) { return !(t.flags & 131068); });
68086                 if (!(result.flags & 131072)) {
68087                     return result;
68088                 }
68089             }
68090             return type;
68091         }
68092         function findMatchingDiscriminantType(source, target, isRelatedTo, skipPartial) {
68093             if (target.flags & 1048576 && source.flags & (2097152 | 524288)) {
68094                 var sourceProperties = getPropertiesOfType(source);
68095                 if (sourceProperties) {
68096                     var sourcePropertiesFiltered = findDiscriminantProperties(sourceProperties, target);
68097                     if (sourcePropertiesFiltered) {
68098                         return discriminateTypeByDiscriminableItems(target, ts.map(sourcePropertiesFiltered, function (p) { return [function () { return getTypeOfSymbol(p); }, p.escapedName]; }), isRelatedTo, undefined, skipPartial);
68099                     }
68100                 }
68101             }
68102             return undefined;
68103         }
68104     }
68105     ts.createTypeChecker = createTypeChecker;
68106     function isNotAccessor(declaration) {
68107         return !ts.isAccessor(declaration);
68108     }
68109     function isNotOverload(declaration) {
68110         return (declaration.kind !== 251 && declaration.kind !== 165) ||
68111             !!declaration.body;
68112     }
68113     function isDeclarationNameOrImportPropertyName(name) {
68114         switch (name.parent.kind) {
68115             case 265:
68116             case 270:
68117                 return ts.isIdentifier(name);
68118             default:
68119                 return ts.isDeclarationName(name);
68120         }
68121     }
68122     function isSomeImportDeclaration(decl) {
68123         switch (decl.kind) {
68124             case 262:
68125             case 260:
68126             case 263:
68127             case 265:
68128                 return true;
68129             case 78:
68130                 return decl.parent.kind === 265;
68131             default:
68132                 return false;
68133         }
68134     }
68135     var JsxNames;
68136     (function (JsxNames) {
68137         JsxNames.JSX = "JSX";
68138         JsxNames.IntrinsicElements = "IntrinsicElements";
68139         JsxNames.ElementClass = "ElementClass";
68140         JsxNames.ElementAttributesPropertyNameContainer = "ElementAttributesProperty";
68141         JsxNames.ElementChildrenAttributeNameContainer = "ElementChildrenAttribute";
68142         JsxNames.Element = "Element";
68143         JsxNames.IntrinsicAttributes = "IntrinsicAttributes";
68144         JsxNames.IntrinsicClassAttributes = "IntrinsicClassAttributes";
68145         JsxNames.LibraryManagedAttributes = "LibraryManagedAttributes";
68146     })(JsxNames || (JsxNames = {}));
68147     function getIterationTypesKeyFromIterationTypeKind(typeKind) {
68148         switch (typeKind) {
68149             case 0: return "yieldType";
68150             case 1: return "returnType";
68151             case 2: return "nextType";
68152         }
68153     }
68154     function signatureHasRestParameter(s) {
68155         return !!(s.flags & 1);
68156     }
68157     ts.signatureHasRestParameter = signatureHasRestParameter;
68158     function signatureHasLiteralTypes(s) {
68159         return !!(s.flags & 2);
68160     }
68161     ts.signatureHasLiteralTypes = signatureHasLiteralTypes;
68162 })(ts || (ts = {}));
68163 var ts;
68164 (function (ts) {
68165     var isTypeNodeOrTypeParameterDeclaration = ts.or(ts.isTypeNode, ts.isTypeParameterDeclaration);
68166     function visitNode(node, visitor, test, lift) {
68167         if (node === undefined || visitor === undefined) {
68168             return node;
68169         }
68170         var visited = visitor(node);
68171         if (visited === node) {
68172             return node;
68173         }
68174         var visitedNode;
68175         if (visited === undefined) {
68176             return undefined;
68177         }
68178         else if (ts.isArray(visited)) {
68179             visitedNode = (lift || extractSingleNode)(visited);
68180         }
68181         else {
68182             visitedNode = visited;
68183         }
68184         ts.Debug.assertNode(visitedNode, test);
68185         return visitedNode;
68186     }
68187     ts.visitNode = visitNode;
68188     function visitNodes(nodes, visitor, test, start, count) {
68189         if (nodes === undefined || visitor === undefined) {
68190             return nodes;
68191         }
68192         var updated;
68193         var length = nodes.length;
68194         if (start === undefined || start < 0) {
68195             start = 0;
68196         }
68197         if (count === undefined || count > length - start) {
68198             count = length - start;
68199         }
68200         var hasTrailingComma;
68201         var pos = -1;
68202         var end = -1;
68203         if (start > 0 || count < length) {
68204             updated = [];
68205             hasTrailingComma = nodes.hasTrailingComma && start + count === length;
68206         }
68207         for (var i = 0; i < count; i++) {
68208             var node = nodes[i + start];
68209             var visited = node !== undefined ? visitor(node) : undefined;
68210             if (updated !== undefined || visited === undefined || visited !== node) {
68211                 if (updated === undefined) {
68212                     updated = nodes.slice(0, i);
68213                     hasTrailingComma = nodes.hasTrailingComma;
68214                     pos = nodes.pos;
68215                     end = nodes.end;
68216                 }
68217                 if (visited) {
68218                     if (ts.isArray(visited)) {
68219                         for (var _i = 0, visited_1 = visited; _i < visited_1.length; _i++) {
68220                             var visitedNode = visited_1[_i];
68221                             void ts.Debug.assertNode(visitedNode, test);
68222                             updated.push(visitedNode);
68223                         }
68224                     }
68225                     else {
68226                         void ts.Debug.assertNode(visited, test);
68227                         updated.push(visited);
68228                     }
68229                 }
68230             }
68231         }
68232         if (updated) {
68233             var updatedArray = ts.factory.createNodeArray(updated, hasTrailingComma);
68234             ts.setTextRangePosEnd(updatedArray, pos, end);
68235             return updatedArray;
68236         }
68237         return nodes;
68238     }
68239     ts.visitNodes = visitNodes;
68240     function visitLexicalEnvironment(statements, visitor, context, start, ensureUseStrict, nodesVisitor) {
68241         if (nodesVisitor === void 0) { nodesVisitor = visitNodes; }
68242         context.startLexicalEnvironment();
68243         statements = nodesVisitor(statements, visitor, ts.isStatement, start);
68244         if (ensureUseStrict)
68245             statements = context.factory.ensureUseStrict(statements);
68246         return ts.factory.mergeLexicalEnvironment(statements, context.endLexicalEnvironment());
68247     }
68248     ts.visitLexicalEnvironment = visitLexicalEnvironment;
68249     function visitParameterList(nodes, visitor, context, nodesVisitor) {
68250         if (nodesVisitor === void 0) { nodesVisitor = visitNodes; }
68251         var updated;
68252         context.startLexicalEnvironment();
68253         if (nodes) {
68254             context.setLexicalEnvironmentFlags(1, true);
68255             updated = nodesVisitor(nodes, visitor, ts.isParameterDeclaration);
68256             if (context.getLexicalEnvironmentFlags() & 2 &&
68257                 ts.getEmitScriptTarget(context.getCompilerOptions()) >= 2) {
68258                 updated = addDefaultValueAssignmentsIfNeeded(updated, context);
68259             }
68260             context.setLexicalEnvironmentFlags(1, false);
68261         }
68262         context.suspendLexicalEnvironment();
68263         return updated;
68264     }
68265     ts.visitParameterList = visitParameterList;
68266     function addDefaultValueAssignmentsIfNeeded(parameters, context) {
68267         var result;
68268         for (var i = 0; i < parameters.length; i++) {
68269             var parameter = parameters[i];
68270             var updated = addDefaultValueAssignmentIfNeeded(parameter, context);
68271             if (result || updated !== parameter) {
68272                 if (!result)
68273                     result = parameters.slice(0, i);
68274                 result[i] = updated;
68275             }
68276         }
68277         if (result) {
68278             return ts.setTextRange(context.factory.createNodeArray(result, parameters.hasTrailingComma), parameters);
68279         }
68280         return parameters;
68281     }
68282     function addDefaultValueAssignmentIfNeeded(parameter, context) {
68283         return parameter.dotDotDotToken ? parameter :
68284             ts.isBindingPattern(parameter.name) ? addDefaultValueAssignmentForBindingPattern(parameter, context) :
68285                 parameter.initializer ? addDefaultValueAssignmentForInitializer(parameter, parameter.name, parameter.initializer, context) :
68286                     parameter;
68287     }
68288     function addDefaultValueAssignmentForBindingPattern(parameter, context) {
68289         var factory = context.factory;
68290         context.addInitializationStatement(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
68291             factory.createVariableDeclaration(parameter.name, undefined, parameter.type, parameter.initializer ?
68292                 factory.createConditionalExpression(factory.createStrictEquality(factory.getGeneratedNameForNode(parameter), factory.createVoidZero()), undefined, parameter.initializer, undefined, factory.getGeneratedNameForNode(parameter)) :
68293                 factory.getGeneratedNameForNode(parameter)),
68294         ])));
68295         return factory.updateParameterDeclaration(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, factory.getGeneratedNameForNode(parameter), parameter.questionToken, parameter.type, undefined);
68296     }
68297     function addDefaultValueAssignmentForInitializer(parameter, name, initializer, context) {
68298         var factory = context.factory;
68299         context.addInitializationStatement(factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([
68300             factory.createExpressionStatement(ts.setEmitFlags(ts.setTextRange(factory.createAssignment(ts.setEmitFlags(factory.cloneNode(name), 48), ts.setEmitFlags(initializer, 48 | ts.getEmitFlags(initializer) | 1536)), parameter), 1536))
68301         ]), parameter), 1 | 32 | 384 | 1536)));
68302         return factory.updateParameterDeclaration(parameter, parameter.decorators, parameter.modifiers, parameter.dotDotDotToken, parameter.name, parameter.questionToken, parameter.type, undefined);
68303     }
68304     function visitFunctionBody(node, visitor, context, nodeVisitor) {
68305         if (nodeVisitor === void 0) { nodeVisitor = visitNode; }
68306         context.resumeLexicalEnvironment();
68307         var updated = nodeVisitor(node, visitor, ts.isConciseBody);
68308         var declarations = context.endLexicalEnvironment();
68309         if (ts.some(declarations)) {
68310             if (!updated) {
68311                 return context.factory.createBlock(declarations);
68312             }
68313             var block = context.factory.converters.convertToFunctionBlock(updated);
68314             var statements = ts.factory.mergeLexicalEnvironment(block.statements, declarations);
68315             return context.factory.updateBlock(block, statements);
68316         }
68317         return updated;
68318     }
68319     ts.visitFunctionBody = visitFunctionBody;
68320     function visitEachChild(node, visitor, context, nodesVisitor, tokenVisitor, nodeVisitor) {
68321         if (nodesVisitor === void 0) { nodesVisitor = visitNodes; }
68322         if (nodeVisitor === void 0) { nodeVisitor = visitNode; }
68323         if (node === undefined) {
68324             return undefined;
68325         }
68326         var kind = node.kind;
68327         if ((kind > 0 && kind <= 156) || kind === 187) {
68328             return node;
68329         }
68330         var factory = context.factory;
68331         switch (kind) {
68332             case 78:
68333                 return factory.updateIdentifier(node, nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration));
68334             case 157:
68335                 return factory.updateQualifiedName(node, nodeVisitor(node.left, visitor, ts.isEntityName), nodeVisitor(node.right, visitor, ts.isIdentifier));
68336             case 158:
68337                 return factory.updateComputedPropertyName(node, nodeVisitor(node.expression, visitor, ts.isExpression));
68338             case 159:
68339                 return factory.updateTypeParameterDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.constraint, visitor, ts.isTypeNode), nodeVisitor(node.default, visitor, ts.isTypeNode));
68340             case 160:
68341                 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));
68342             case 161:
68343                 return factory.updateDecorator(node, nodeVisitor(node.expression, visitor, ts.isExpression));
68344             case 162:
68345                 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));
68346             case 163:
68347                 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));
68348             case 164:
68349                 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));
68350             case 165:
68351                 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));
68352             case 166:
68353                 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));
68354             case 167:
68355                 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));
68356             case 168:
68357                 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));
68358             case 169:
68359                 return factory.updateCallSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode));
68360             case 170:
68361                 return factory.updateConstructSignature(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode));
68362             case 171:
68363                 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));
68364             case 172:
68365                 return factory.updateTypePredicateNode(node, nodeVisitor(node.assertsModifier, visitor), nodeVisitor(node.parameterName, visitor), nodeVisitor(node.type, visitor, ts.isTypeNode));
68366             case 173:
68367                 return factory.updateTypeReferenceNode(node, nodeVisitor(node.typeName, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode));
68368             case 174:
68369                 return factory.updateFunctionTypeNode(node, nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode));
68370             case 175:
68371                 return factory.updateConstructorTypeNode(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodesVisitor(node.typeParameters, visitor, ts.isTypeParameterDeclaration), nodesVisitor(node.parameters, visitor, ts.isParameterDeclaration), nodeVisitor(node.type, visitor, ts.isTypeNode));
68372             case 176:
68373                 return factory.updateTypeQueryNode(node, nodeVisitor(node.exprName, visitor, ts.isEntityName));
68374             case 177:
68375                 return factory.updateTypeLiteralNode(node, nodesVisitor(node.members, visitor, ts.isTypeElement));
68376             case 178:
68377                 return factory.updateArrayTypeNode(node, nodeVisitor(node.elementType, visitor, ts.isTypeNode));
68378             case 179:
68379                 return factory.updateTupleTypeNode(node, nodesVisitor(node.elements, visitor, ts.isTypeNode));
68380             case 180:
68381                 return factory.updateOptionalTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
68382             case 181:
68383                 return factory.updateRestTypeNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
68384             case 182:
68385                 return factory.updateUnionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode));
68386             case 183:
68387                 return factory.updateIntersectionTypeNode(node, nodesVisitor(node.types, visitor, ts.isTypeNode));
68388             case 184:
68389                 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));
68390             case 185:
68391                 return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration));
68392             case 195:
68393                 return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), visitNodes(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf);
68394             case 192:
68395                 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));
68396             case 186:
68397                 return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
68398             case 188:
68399                 return factory.updateTypeOperatorNode(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
68400             case 189:
68401                 return factory.updateIndexedAccessTypeNode(node, nodeVisitor(node.objectType, visitor, ts.isTypeNode), nodeVisitor(node.indexType, visitor, ts.isTypeNode));
68402             case 190:
68403                 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));
68404             case 191:
68405                 return factory.updateLiteralTypeNode(node, nodeVisitor(node.literal, visitor, ts.isExpression));
68406             case 193:
68407                 return factory.updateTemplateLiteralType(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateLiteralTypeSpan));
68408             case 194:
68409                 return factory.updateTemplateLiteralTypeSpan(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail));
68410             case 196:
68411                 return factory.updateObjectBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isBindingElement));
68412             case 197:
68413                 return factory.updateArrayBindingPattern(node, nodesVisitor(node.elements, visitor, ts.isArrayBindingElement));
68414             case 198:
68415                 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));
68416             case 199:
68417                 return factory.updateArrayLiteralExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression));
68418             case 200:
68419                 return factory.updateObjectLiteralExpression(node, nodesVisitor(node.properties, visitor, ts.isObjectLiteralElementLike));
68420             case 201:
68421                 if (node.flags & 32) {
68422                     return factory.updatePropertyAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.name, visitor, ts.isIdentifier));
68423                 }
68424                 return factory.updatePropertyAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.name, visitor, ts.isIdentifierOrPrivateIdentifier));
68425             case 202:
68426                 if (node.flags & 32) {
68427                     return factory.updateElementAccessChain(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.questionDotToken, tokenVisitor, ts.isToken), nodeVisitor(node.argumentExpression, visitor, ts.isExpression));
68428                 }
68429                 return factory.updateElementAccessExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.argumentExpression, visitor, ts.isExpression));
68430             case 203:
68431                 if (node.flags & 32) {
68432                     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));
68433                 }
68434                 return factory.updateCallExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
68435             case 204:
68436                 return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
68437             case 205:
68438                 return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), visitNodes(node.typeArguments, visitor, ts.isExpression), nodeVisitor(node.template, visitor, ts.isTemplateLiteral));
68439             case 206:
68440                 return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression));
68441             case 207:
68442                 return factory.updateParenthesizedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
68443             case 208:
68444                 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));
68445             case 209:
68446                 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));
68447             case 210:
68448                 return factory.updateDeleteExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
68449             case 211:
68450                 return factory.updateTypeOfExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
68451             case 212:
68452                 return factory.updateVoidExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
68453             case 213:
68454                 return factory.updateAwaitExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
68455             case 214:
68456                 return factory.updatePrefixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression));
68457             case 215:
68458                 return factory.updatePostfixUnaryExpression(node, nodeVisitor(node.operand, visitor, ts.isExpression));
68459             case 216:
68460                 return factory.updateBinaryExpression(node, nodeVisitor(node.left, visitor, ts.isExpression), nodeVisitor(node.operatorToken, tokenVisitor, ts.isToken), nodeVisitor(node.right, visitor, ts.isExpression));
68461             case 217:
68462                 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));
68463             case 218:
68464                 return factory.updateTemplateExpression(node, nodeVisitor(node.head, visitor, ts.isTemplateHead), nodesVisitor(node.templateSpans, visitor, ts.isTemplateSpan));
68465             case 219:
68466                 return factory.updateYieldExpression(node, nodeVisitor(node.asteriskToken, tokenVisitor, ts.isToken), nodeVisitor(node.expression, visitor, ts.isExpression));
68467             case 220:
68468                 return factory.updateSpreadElement(node, nodeVisitor(node.expression, visitor, ts.isExpression));
68469             case 221:
68470                 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));
68471             case 223:
68472                 return factory.updateExpressionWithTypeArguments(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode));
68473             case 224:
68474                 return factory.updateAsExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.type, visitor, ts.isTypeNode));
68475             case 225:
68476                 if (node.flags & 32) {
68477                     return factory.updateNonNullChain(node, nodeVisitor(node.expression, visitor, ts.isExpression));
68478                 }
68479                 return factory.updateNonNullExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
68480             case 226:
68481                 return factory.updateMetaProperty(node, nodeVisitor(node.name, visitor, ts.isIdentifier));
68482             case 228:
68483                 return factory.updateTemplateSpan(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.literal, visitor, ts.isTemplateMiddleOrTemplateTail));
68484             case 230:
68485                 return factory.updateBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement));
68486             case 232:
68487                 return factory.updateVariableStatement(node, nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.declarationList, visitor, ts.isVariableDeclarationList));
68488             case 233:
68489                 return factory.updateExpressionStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression));
68490             case 234:
68491                 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));
68492             case 235:
68493                 return factory.updateDoStatement(node, nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock), nodeVisitor(node.expression, visitor, ts.isExpression));
68494             case 236:
68495                 return factory.updateWhileStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock));
68496             case 237:
68497                 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));
68498             case 238:
68499                 return factory.updateForInStatement(node, nodeVisitor(node.initializer, visitor, ts.isForInitializer), nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock));
68500             case 239:
68501                 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));
68502             case 240:
68503                 return factory.updateContinueStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier));
68504             case 241:
68505                 return factory.updateBreakStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier));
68506             case 242:
68507                 return factory.updateReturnStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression));
68508             case 243:
68509                 return factory.updateWithStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock));
68510             case 244:
68511                 return factory.updateSwitchStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodeVisitor(node.caseBlock, visitor, ts.isCaseBlock));
68512             case 245:
68513                 return factory.updateLabeledStatement(node, nodeVisitor(node.label, visitor, ts.isIdentifier), nodeVisitor(node.statement, visitor, ts.isStatement, factory.liftToBlock));
68514             case 246:
68515                 return factory.updateThrowStatement(node, nodeVisitor(node.expression, visitor, ts.isExpression));
68516             case 247:
68517                 return factory.updateTryStatement(node, nodeVisitor(node.tryBlock, visitor, ts.isBlock), nodeVisitor(node.catchClause, visitor, ts.isCatchClause), nodeVisitor(node.finallyBlock, visitor, ts.isBlock));
68518             case 249:
68519                 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));
68520             case 250:
68521                 return factory.updateVariableDeclarationList(node, nodesVisitor(node.declarations, visitor, ts.isVariableDeclaration));
68522             case 251:
68523                 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));
68524             case 252:
68525                 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));
68526             case 253:
68527                 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));
68528             case 254:
68529                 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));
68530             case 255:
68531                 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));
68532             case 256:
68533                 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));
68534             case 257:
68535                 return factory.updateModuleBlock(node, nodesVisitor(node.statements, visitor, ts.isStatement));
68536             case 258:
68537                 return factory.updateCaseBlock(node, nodesVisitor(node.clauses, visitor, ts.isCaseOrDefaultClause));
68538             case 259:
68539                 return factory.updateNamespaceExportDeclaration(node, nodeVisitor(node.name, visitor, ts.isIdentifier));
68540             case 260:
68541                 return factory.updateImportEqualsDeclaration(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.moduleReference, visitor, ts.isModuleReference));
68542             case 261:
68543                 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));
68544             case 262:
68545                 return factory.updateImportClause(node, node.isTypeOnly, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.namedBindings, visitor, ts.isNamedImportBindings));
68546             case 263:
68547                 return factory.updateNamespaceImport(node, nodeVisitor(node.name, visitor, ts.isIdentifier));
68548             case 269:
68549                 return factory.updateNamespaceExport(node, nodeVisitor(node.name, visitor, ts.isIdentifier));
68550             case 264:
68551                 return factory.updateNamedImports(node, nodesVisitor(node.elements, visitor, ts.isImportSpecifier));
68552             case 265:
68553                 return factory.updateImportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier));
68554             case 266:
68555                 return factory.updateExportAssignment(node, nodesVisitor(node.decorators, visitor, ts.isDecorator), nodesVisitor(node.modifiers, visitor, ts.isModifier), nodeVisitor(node.expression, visitor, ts.isExpression));
68556             case 267:
68557                 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));
68558             case 268:
68559                 return factory.updateNamedExports(node, nodesVisitor(node.elements, visitor, ts.isExportSpecifier));
68560             case 270:
68561                 return factory.updateExportSpecifier(node, nodeVisitor(node.propertyName, visitor, ts.isIdentifier), nodeVisitor(node.name, visitor, ts.isIdentifier));
68562             case 272:
68563                 return factory.updateExternalModuleReference(node, nodeVisitor(node.expression, visitor, ts.isExpression));
68564             case 273:
68565                 return factory.updateJsxElement(node, nodeVisitor(node.openingElement, visitor, ts.isJsxOpeningElement), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingElement, visitor, ts.isJsxClosingElement));
68566             case 274:
68567                 return factory.updateJsxSelfClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes));
68568             case 275:
68569                 return factory.updateJsxOpeningElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.attributes, visitor, ts.isJsxAttributes));
68570             case 276:
68571                 return factory.updateJsxClosingElement(node, nodeVisitor(node.tagName, visitor, ts.isJsxTagNameExpression));
68572             case 277:
68573                 return factory.updateJsxFragment(node, nodeVisitor(node.openingFragment, visitor, ts.isJsxOpeningFragment), nodesVisitor(node.children, visitor, ts.isJsxChild), nodeVisitor(node.closingFragment, visitor, ts.isJsxClosingFragment));
68574             case 280:
68575                 return factory.updateJsxAttribute(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.initializer, visitor, ts.isStringLiteralOrJsxExpression));
68576             case 281:
68577                 return factory.updateJsxAttributes(node, nodesVisitor(node.properties, visitor, ts.isJsxAttributeLike));
68578             case 282:
68579                 return factory.updateJsxSpreadAttribute(node, nodeVisitor(node.expression, visitor, ts.isExpression));
68580             case 283:
68581                 return factory.updateJsxExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
68582             case 284:
68583                 return factory.updateCaseClause(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.statements, visitor, ts.isStatement));
68584             case 285:
68585                 return factory.updateDefaultClause(node, nodesVisitor(node.statements, visitor, ts.isStatement));
68586             case 286:
68587                 return factory.updateHeritageClause(node, nodesVisitor(node.types, visitor, ts.isExpressionWithTypeArguments));
68588             case 287:
68589                 return factory.updateCatchClause(node, nodeVisitor(node.variableDeclaration, visitor, ts.isVariableDeclaration), nodeVisitor(node.block, visitor, ts.isBlock));
68590             case 288:
68591                 return factory.updatePropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression));
68592             case 289:
68593                 return factory.updateShorthandPropertyAssignment(node, nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.objectAssignmentInitializer, visitor, ts.isExpression));
68594             case 290:
68595                 return factory.updateSpreadAssignment(node, nodeVisitor(node.expression, visitor, ts.isExpression));
68596             case 291:
68597                 return factory.updateEnumMember(node, nodeVisitor(node.name, visitor, ts.isPropertyName), nodeVisitor(node.initializer, visitor, ts.isExpression));
68598             case 297:
68599                 return factory.updateSourceFile(node, visitLexicalEnvironment(node.statements, visitor, context));
68600             case 336:
68601                 return factory.updatePartiallyEmittedExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression));
68602             case 337:
68603                 return factory.updateCommaListExpression(node, nodesVisitor(node.elements, visitor, ts.isExpression));
68604             default:
68605                 return node;
68606         }
68607     }
68608     ts.visitEachChild = visitEachChild;
68609     function extractSingleNode(nodes) {
68610         ts.Debug.assert(nodes.length <= 1, "Too many nodes written to output.");
68611         return ts.singleOrUndefined(nodes);
68612     }
68613 })(ts || (ts = {}));
68614 var ts;
68615 (function (ts) {
68616     function createSourceMapGenerator(host, file, sourceRoot, sourcesDirectoryPath, generatorOptions) {
68617         var _a = generatorOptions.extendedDiagnostics
68618             ? ts.performance.createTimer("Source Map", "beforeSourcemap", "afterSourcemap")
68619             : ts.performance.nullTimer, enter = _a.enter, exit = _a.exit;
68620         var rawSources = [];
68621         var sources = [];
68622         var sourceToSourceIndexMap = new ts.Map();
68623         var sourcesContent;
68624         var names = [];
68625         var nameToNameIndexMap;
68626         var mappings = "";
68627         var lastGeneratedLine = 0;
68628         var lastGeneratedCharacter = 0;
68629         var lastSourceIndex = 0;
68630         var lastSourceLine = 0;
68631         var lastSourceCharacter = 0;
68632         var lastNameIndex = 0;
68633         var hasLast = false;
68634         var pendingGeneratedLine = 0;
68635         var pendingGeneratedCharacter = 0;
68636         var pendingSourceIndex = 0;
68637         var pendingSourceLine = 0;
68638         var pendingSourceCharacter = 0;
68639         var pendingNameIndex = 0;
68640         var hasPending = false;
68641         var hasPendingSource = false;
68642         var hasPendingName = false;
68643         return {
68644             getSources: function () { return rawSources; },
68645             addSource: addSource,
68646             setSourceContent: setSourceContent,
68647             addName: addName,
68648             addMapping: addMapping,
68649             appendSourceMap: appendSourceMap,
68650             toJSON: toJSON,
68651             toString: function () { return JSON.stringify(toJSON()); }
68652         };
68653         function addSource(fileName) {
68654             enter();
68655             var source = ts.getRelativePathToDirectoryOrUrl(sourcesDirectoryPath, fileName, host.getCurrentDirectory(), host.getCanonicalFileName, true);
68656             var sourceIndex = sourceToSourceIndexMap.get(source);
68657             if (sourceIndex === undefined) {
68658                 sourceIndex = sources.length;
68659                 sources.push(source);
68660                 rawSources.push(fileName);
68661                 sourceToSourceIndexMap.set(source, sourceIndex);
68662             }
68663             exit();
68664             return sourceIndex;
68665         }
68666         function setSourceContent(sourceIndex, content) {
68667             enter();
68668             if (content !== null) {
68669                 if (!sourcesContent)
68670                     sourcesContent = [];
68671                 while (sourcesContent.length < sourceIndex) {
68672                     sourcesContent.push(null);
68673                 }
68674                 sourcesContent[sourceIndex] = content;
68675             }
68676             exit();
68677         }
68678         function addName(name) {
68679             enter();
68680             if (!nameToNameIndexMap)
68681                 nameToNameIndexMap = new ts.Map();
68682             var nameIndex = nameToNameIndexMap.get(name);
68683             if (nameIndex === undefined) {
68684                 nameIndex = names.length;
68685                 names.push(name);
68686                 nameToNameIndexMap.set(name, nameIndex);
68687             }
68688             exit();
68689             return nameIndex;
68690         }
68691         function isNewGeneratedPosition(generatedLine, generatedCharacter) {
68692             return !hasPending
68693                 || pendingGeneratedLine !== generatedLine
68694                 || pendingGeneratedCharacter !== generatedCharacter;
68695         }
68696         function isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter) {
68697             return sourceIndex !== undefined
68698                 && sourceLine !== undefined
68699                 && sourceCharacter !== undefined
68700                 && pendingSourceIndex === sourceIndex
68701                 && (pendingSourceLine > sourceLine
68702                     || pendingSourceLine === sourceLine && pendingSourceCharacter > sourceCharacter);
68703         }
68704         function addMapping(generatedLine, generatedCharacter, sourceIndex, sourceLine, sourceCharacter, nameIndex) {
68705             ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack");
68706             ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative");
68707             ts.Debug.assert(sourceIndex === undefined || sourceIndex >= 0, "sourceIndex cannot be negative");
68708             ts.Debug.assert(sourceLine === undefined || sourceLine >= 0, "sourceLine cannot be negative");
68709             ts.Debug.assert(sourceCharacter === undefined || sourceCharacter >= 0, "sourceCharacter cannot be negative");
68710             enter();
68711             if (isNewGeneratedPosition(generatedLine, generatedCharacter) ||
68712                 isBacktrackingSourcePosition(sourceIndex, sourceLine, sourceCharacter)) {
68713                 commitPendingMapping();
68714                 pendingGeneratedLine = generatedLine;
68715                 pendingGeneratedCharacter = generatedCharacter;
68716                 hasPendingSource = false;
68717                 hasPendingName = false;
68718                 hasPending = true;
68719             }
68720             if (sourceIndex !== undefined && sourceLine !== undefined && sourceCharacter !== undefined) {
68721                 pendingSourceIndex = sourceIndex;
68722                 pendingSourceLine = sourceLine;
68723                 pendingSourceCharacter = sourceCharacter;
68724                 hasPendingSource = true;
68725                 if (nameIndex !== undefined) {
68726                     pendingNameIndex = nameIndex;
68727                     hasPendingName = true;
68728                 }
68729             }
68730             exit();
68731         }
68732         function appendSourceMap(generatedLine, generatedCharacter, map, sourceMapPath, start, end) {
68733             ts.Debug.assert(generatedLine >= pendingGeneratedLine, "generatedLine cannot backtrack");
68734             ts.Debug.assert(generatedCharacter >= 0, "generatedCharacter cannot be negative");
68735             enter();
68736             var sourceIndexToNewSourceIndexMap = [];
68737             var nameIndexToNewNameIndexMap;
68738             var mappingIterator = decodeMappings(map.mappings);
68739             for (var iterResult = mappingIterator.next(); !iterResult.done; iterResult = mappingIterator.next()) {
68740                 var raw = iterResult.value;
68741                 if (end && (raw.generatedLine > end.line ||
68742                     (raw.generatedLine === end.line && raw.generatedCharacter > end.character))) {
68743                     break;
68744                 }
68745                 if (start && (raw.generatedLine < start.line ||
68746                     (start.line === raw.generatedLine && raw.generatedCharacter < start.character))) {
68747                     continue;
68748                 }
68749                 var newSourceIndex = void 0;
68750                 var newSourceLine = void 0;
68751                 var newSourceCharacter = void 0;
68752                 var newNameIndex = void 0;
68753                 if (raw.sourceIndex !== undefined) {
68754                     newSourceIndex = sourceIndexToNewSourceIndexMap[raw.sourceIndex];
68755                     if (newSourceIndex === undefined) {
68756                         var rawPath = map.sources[raw.sourceIndex];
68757                         var relativePath = map.sourceRoot ? ts.combinePaths(map.sourceRoot, rawPath) : rawPath;
68758                         var combinedPath = ts.combinePaths(ts.getDirectoryPath(sourceMapPath), relativePath);
68759                         sourceIndexToNewSourceIndexMap[raw.sourceIndex] = newSourceIndex = addSource(combinedPath);
68760                         if (map.sourcesContent && typeof map.sourcesContent[raw.sourceIndex] === "string") {
68761                             setSourceContent(newSourceIndex, map.sourcesContent[raw.sourceIndex]);
68762                         }
68763                     }
68764                     newSourceLine = raw.sourceLine;
68765                     newSourceCharacter = raw.sourceCharacter;
68766                     if (map.names && raw.nameIndex !== undefined) {
68767                         if (!nameIndexToNewNameIndexMap)
68768                             nameIndexToNewNameIndexMap = [];
68769                         newNameIndex = nameIndexToNewNameIndexMap[raw.nameIndex];
68770                         if (newNameIndex === undefined) {
68771                             nameIndexToNewNameIndexMap[raw.nameIndex] = newNameIndex = addName(map.names[raw.nameIndex]);
68772                         }
68773                     }
68774                 }
68775                 var rawGeneratedLine = raw.generatedLine - (start ? start.line : 0);
68776                 var newGeneratedLine = rawGeneratedLine + generatedLine;
68777                 var rawGeneratedCharacter = start && start.line === raw.generatedLine ? raw.generatedCharacter - start.character : raw.generatedCharacter;
68778                 var newGeneratedCharacter = rawGeneratedLine === 0 ? rawGeneratedCharacter + generatedCharacter : rawGeneratedCharacter;
68779                 addMapping(newGeneratedLine, newGeneratedCharacter, newSourceIndex, newSourceLine, newSourceCharacter, newNameIndex);
68780             }
68781             exit();
68782         }
68783         function shouldCommitMapping() {
68784             return !hasLast
68785                 || lastGeneratedLine !== pendingGeneratedLine
68786                 || lastGeneratedCharacter !== pendingGeneratedCharacter
68787                 || lastSourceIndex !== pendingSourceIndex
68788                 || lastSourceLine !== pendingSourceLine
68789                 || lastSourceCharacter !== pendingSourceCharacter
68790                 || lastNameIndex !== pendingNameIndex;
68791         }
68792         function commitPendingMapping() {
68793             if (!hasPending || !shouldCommitMapping()) {
68794                 return;
68795             }
68796             enter();
68797             if (lastGeneratedLine < pendingGeneratedLine) {
68798                 do {
68799                     mappings += ";";
68800                     lastGeneratedLine++;
68801                     lastGeneratedCharacter = 0;
68802                 } while (lastGeneratedLine < pendingGeneratedLine);
68803             }
68804             else {
68805                 ts.Debug.assertEqual(lastGeneratedLine, pendingGeneratedLine, "generatedLine cannot backtrack");
68806                 if (hasLast) {
68807                     mappings += ",";
68808                 }
68809             }
68810             mappings += base64VLQFormatEncode(pendingGeneratedCharacter - lastGeneratedCharacter);
68811             lastGeneratedCharacter = pendingGeneratedCharacter;
68812             if (hasPendingSource) {
68813                 mappings += base64VLQFormatEncode(pendingSourceIndex - lastSourceIndex);
68814                 lastSourceIndex = pendingSourceIndex;
68815                 mappings += base64VLQFormatEncode(pendingSourceLine - lastSourceLine);
68816                 lastSourceLine = pendingSourceLine;
68817                 mappings += base64VLQFormatEncode(pendingSourceCharacter - lastSourceCharacter);
68818                 lastSourceCharacter = pendingSourceCharacter;
68819                 if (hasPendingName) {
68820                     mappings += base64VLQFormatEncode(pendingNameIndex - lastNameIndex);
68821                     lastNameIndex = pendingNameIndex;
68822                 }
68823             }
68824             hasLast = true;
68825             exit();
68826         }
68827         function toJSON() {
68828             commitPendingMapping();
68829             return {
68830                 version: 3,
68831                 file: file,
68832                 sourceRoot: sourceRoot,
68833                 sources: sources,
68834                 names: names,
68835                 mappings: mappings,
68836                 sourcesContent: sourcesContent,
68837             };
68838         }
68839     }
68840     ts.createSourceMapGenerator = createSourceMapGenerator;
68841     var sourceMapCommentRegExp = /^\/\/[@#] source[M]appingURL=(.+)\s*$/;
68842     var whitespaceOrMapCommentRegExp = /^\s*(\/\/[@#] .*)?$/;
68843     function getLineInfo(text, lineStarts) {
68844         return {
68845             getLineCount: function () { return lineStarts.length; },
68846             getLineText: function (line) { return text.substring(lineStarts[line], lineStarts[line + 1]); }
68847         };
68848     }
68849     ts.getLineInfo = getLineInfo;
68850     function tryGetSourceMappingURL(lineInfo) {
68851         for (var index = lineInfo.getLineCount() - 1; index >= 0; index--) {
68852             var line = lineInfo.getLineText(index);
68853             var comment = sourceMapCommentRegExp.exec(line);
68854             if (comment) {
68855                 return comment[1];
68856             }
68857             else if (!line.match(whitespaceOrMapCommentRegExp)) {
68858                 break;
68859             }
68860         }
68861     }
68862     ts.tryGetSourceMappingURL = tryGetSourceMappingURL;
68863     function isStringOrNull(x) {
68864         return typeof x === "string" || x === null;
68865     }
68866     function isRawSourceMap(x) {
68867         return x !== null
68868             && typeof x === "object"
68869             && x.version === 3
68870             && typeof x.file === "string"
68871             && typeof x.mappings === "string"
68872             && ts.isArray(x.sources) && ts.every(x.sources, ts.isString)
68873             && (x.sourceRoot === undefined || x.sourceRoot === null || typeof x.sourceRoot === "string")
68874             && (x.sourcesContent === undefined || x.sourcesContent === null || ts.isArray(x.sourcesContent) && ts.every(x.sourcesContent, isStringOrNull))
68875             && (x.names === undefined || x.names === null || ts.isArray(x.names) && ts.every(x.names, ts.isString));
68876     }
68877     ts.isRawSourceMap = isRawSourceMap;
68878     function tryParseRawSourceMap(text) {
68879         try {
68880             var parsed = JSON.parse(text);
68881             if (isRawSourceMap(parsed)) {
68882                 return parsed;
68883             }
68884         }
68885         catch (_a) {
68886         }
68887         return undefined;
68888     }
68889     ts.tryParseRawSourceMap = tryParseRawSourceMap;
68890     function decodeMappings(mappings) {
68891         var done = false;
68892         var pos = 0;
68893         var generatedLine = 0;
68894         var generatedCharacter = 0;
68895         var sourceIndex = 0;
68896         var sourceLine = 0;
68897         var sourceCharacter = 0;
68898         var nameIndex = 0;
68899         var error;
68900         return {
68901             get pos() { return pos; },
68902             get error() { return error; },
68903             get state() { return captureMapping(true, true); },
68904             next: function () {
68905                 while (!done && pos < mappings.length) {
68906                     var ch = mappings.charCodeAt(pos);
68907                     if (ch === 59) {
68908                         generatedLine++;
68909                         generatedCharacter = 0;
68910                         pos++;
68911                         continue;
68912                     }
68913                     if (ch === 44) {
68914                         pos++;
68915                         continue;
68916                     }
68917                     var hasSource = false;
68918                     var hasName = false;
68919                     generatedCharacter += base64VLQFormatDecode();
68920                     if (hasReportedError())
68921                         return stopIterating();
68922                     if (generatedCharacter < 0)
68923                         return setErrorAndStopIterating("Invalid generatedCharacter found");
68924                     if (!isSourceMappingSegmentEnd()) {
68925                         hasSource = true;
68926                         sourceIndex += base64VLQFormatDecode();
68927                         if (hasReportedError())
68928                             return stopIterating();
68929                         if (sourceIndex < 0)
68930                             return setErrorAndStopIterating("Invalid sourceIndex found");
68931                         if (isSourceMappingSegmentEnd())
68932                             return setErrorAndStopIterating("Unsupported Format: No entries after sourceIndex");
68933                         sourceLine += base64VLQFormatDecode();
68934                         if (hasReportedError())
68935                             return stopIterating();
68936                         if (sourceLine < 0)
68937                             return setErrorAndStopIterating("Invalid sourceLine found");
68938                         if (isSourceMappingSegmentEnd())
68939                             return setErrorAndStopIterating("Unsupported Format: No entries after sourceLine");
68940                         sourceCharacter += base64VLQFormatDecode();
68941                         if (hasReportedError())
68942                             return stopIterating();
68943                         if (sourceCharacter < 0)
68944                             return setErrorAndStopIterating("Invalid sourceCharacter found");
68945                         if (!isSourceMappingSegmentEnd()) {
68946                             hasName = true;
68947                             nameIndex += base64VLQFormatDecode();
68948                             if (hasReportedError())
68949                                 return stopIterating();
68950                             if (nameIndex < 0)
68951                                 return setErrorAndStopIterating("Invalid nameIndex found");
68952                             if (!isSourceMappingSegmentEnd())
68953                                 return setErrorAndStopIterating("Unsupported Error Format: Entries after nameIndex");
68954                         }
68955                     }
68956                     return { value: captureMapping(hasSource, hasName), done: done };
68957                 }
68958                 return stopIterating();
68959             }
68960         };
68961         function captureMapping(hasSource, hasName) {
68962             return {
68963                 generatedLine: generatedLine,
68964                 generatedCharacter: generatedCharacter,
68965                 sourceIndex: hasSource ? sourceIndex : undefined,
68966                 sourceLine: hasSource ? sourceLine : undefined,
68967                 sourceCharacter: hasSource ? sourceCharacter : undefined,
68968                 nameIndex: hasName ? nameIndex : undefined
68969             };
68970         }
68971         function stopIterating() {
68972             done = true;
68973             return { value: undefined, done: true };
68974         }
68975         function setError(message) {
68976             if (error === undefined) {
68977                 error = message;
68978             }
68979         }
68980         function setErrorAndStopIterating(message) {
68981             setError(message);
68982             return stopIterating();
68983         }
68984         function hasReportedError() {
68985             return error !== undefined;
68986         }
68987         function isSourceMappingSegmentEnd() {
68988             return (pos === mappings.length ||
68989                 mappings.charCodeAt(pos) === 44 ||
68990                 mappings.charCodeAt(pos) === 59);
68991         }
68992         function base64VLQFormatDecode() {
68993             var moreDigits = true;
68994             var shiftCount = 0;
68995             var value = 0;
68996             for (; moreDigits; pos++) {
68997                 if (pos >= mappings.length)
68998                     return setError("Error in decoding base64VLQFormatDecode, past the mapping string"), -1;
68999                 var currentByte = base64FormatDecode(mappings.charCodeAt(pos));
69000                 if (currentByte === -1)
69001                     return setError("Invalid character in VLQ"), -1;
69002                 moreDigits = (currentByte & 32) !== 0;
69003                 value = value | ((currentByte & 31) << shiftCount);
69004                 shiftCount += 5;
69005             }
69006             if ((value & 1) === 0) {
69007                 value = value >> 1;
69008             }
69009             else {
69010                 value = value >> 1;
69011                 value = -value;
69012             }
69013             return value;
69014         }
69015     }
69016     ts.decodeMappings = decodeMappings;
69017     function sameMapping(left, right) {
69018         return left === right
69019             || left.generatedLine === right.generatedLine
69020                 && left.generatedCharacter === right.generatedCharacter
69021                 && left.sourceIndex === right.sourceIndex
69022                 && left.sourceLine === right.sourceLine
69023                 && left.sourceCharacter === right.sourceCharacter
69024                 && left.nameIndex === right.nameIndex;
69025     }
69026     ts.sameMapping = sameMapping;
69027     function isSourceMapping(mapping) {
69028         return mapping.sourceIndex !== undefined
69029             && mapping.sourceLine !== undefined
69030             && mapping.sourceCharacter !== undefined;
69031     }
69032     ts.isSourceMapping = isSourceMapping;
69033     function base64FormatEncode(value) {
69034         return value >= 0 && value < 26 ? 65 + value :
69035             value >= 26 && value < 52 ? 97 + value - 26 :
69036                 value >= 52 && value < 62 ? 48 + value - 52 :
69037                     value === 62 ? 43 :
69038                         value === 63 ? 47 :
69039                             ts.Debug.fail(value + ": not a base64 value");
69040     }
69041     function base64FormatDecode(ch) {
69042         return ch >= 65 && ch <= 90 ? ch - 65 :
69043             ch >= 97 && ch <= 122 ? ch - 97 + 26 :
69044                 ch >= 48 && ch <= 57 ? ch - 48 + 52 :
69045                     ch === 43 ? 62 :
69046                         ch === 47 ? 63 :
69047                             -1;
69048     }
69049     function base64VLQFormatEncode(inValue) {
69050         if (inValue < 0) {
69051             inValue = ((-inValue) << 1) + 1;
69052         }
69053         else {
69054             inValue = inValue << 1;
69055         }
69056         var encodedStr = "";
69057         do {
69058             var currentDigit = inValue & 31;
69059             inValue = inValue >> 5;
69060             if (inValue > 0) {
69061                 currentDigit = currentDigit | 32;
69062             }
69063             encodedStr = encodedStr + String.fromCharCode(base64FormatEncode(currentDigit));
69064         } while (inValue > 0);
69065         return encodedStr;
69066     }
69067     function isSourceMappedPosition(value) {
69068         return value.sourceIndex !== undefined
69069             && value.sourcePosition !== undefined;
69070     }
69071     function sameMappedPosition(left, right) {
69072         return left.generatedPosition === right.generatedPosition
69073             && left.sourceIndex === right.sourceIndex
69074             && left.sourcePosition === right.sourcePosition;
69075     }
69076     function compareSourcePositions(left, right) {
69077         ts.Debug.assert(left.sourceIndex === right.sourceIndex);
69078         return ts.compareValues(left.sourcePosition, right.sourcePosition);
69079     }
69080     function compareGeneratedPositions(left, right) {
69081         return ts.compareValues(left.generatedPosition, right.generatedPosition);
69082     }
69083     function getSourcePositionOfMapping(value) {
69084         return value.sourcePosition;
69085     }
69086     function getGeneratedPositionOfMapping(value) {
69087         return value.generatedPosition;
69088     }
69089     function createDocumentPositionMapper(host, map, mapPath) {
69090         var mapDirectory = ts.getDirectoryPath(mapPath);
69091         var sourceRoot = map.sourceRoot ? ts.getNormalizedAbsolutePath(map.sourceRoot, mapDirectory) : mapDirectory;
69092         var generatedAbsoluteFilePath = ts.getNormalizedAbsolutePath(map.file, mapDirectory);
69093         var generatedFile = host.getSourceFileLike(generatedAbsoluteFilePath);
69094         var sourceFileAbsolutePaths = map.sources.map(function (source) { return ts.getNormalizedAbsolutePath(source, sourceRoot); });
69095         var sourceToSourceIndexMap = new ts.Map(sourceFileAbsolutePaths.map(function (source, i) { return [host.getCanonicalFileName(source), i]; }));
69096         var decodedMappings;
69097         var generatedMappings;
69098         var sourceMappings;
69099         return {
69100             getSourcePosition: getSourcePosition,
69101             getGeneratedPosition: getGeneratedPosition
69102         };
69103         function processMapping(mapping) {
69104             var generatedPosition = generatedFile !== undefined
69105                 ? ts.getPositionOfLineAndCharacter(generatedFile, mapping.generatedLine, mapping.generatedCharacter, true)
69106                 : -1;
69107             var source;
69108             var sourcePosition;
69109             if (isSourceMapping(mapping)) {
69110                 var sourceFile = host.getSourceFileLike(sourceFileAbsolutePaths[mapping.sourceIndex]);
69111                 source = map.sources[mapping.sourceIndex];
69112                 sourcePosition = sourceFile !== undefined
69113                     ? ts.getPositionOfLineAndCharacter(sourceFile, mapping.sourceLine, mapping.sourceCharacter, true)
69114                     : -1;
69115             }
69116             return {
69117                 generatedPosition: generatedPosition,
69118                 source: source,
69119                 sourceIndex: mapping.sourceIndex,
69120                 sourcePosition: sourcePosition,
69121                 nameIndex: mapping.nameIndex
69122             };
69123         }
69124         function getDecodedMappings() {
69125             if (decodedMappings === undefined) {
69126                 var decoder = decodeMappings(map.mappings);
69127                 var mappings = ts.arrayFrom(decoder, processMapping);
69128                 if (decoder.error !== undefined) {
69129                     if (host.log) {
69130                         host.log("Encountered error while decoding sourcemap: " + decoder.error);
69131                     }
69132                     decodedMappings = ts.emptyArray;
69133                 }
69134                 else {
69135                     decodedMappings = mappings;
69136                 }
69137             }
69138             return decodedMappings;
69139         }
69140         function getSourceMappings(sourceIndex) {
69141             if (sourceMappings === undefined) {
69142                 var lists = [];
69143                 for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) {
69144                     var mapping = _a[_i];
69145                     if (!isSourceMappedPosition(mapping))
69146                         continue;
69147                     var list = lists[mapping.sourceIndex];
69148                     if (!list)
69149                         lists[mapping.sourceIndex] = list = [];
69150                     list.push(mapping);
69151                 }
69152                 sourceMappings = lists.map(function (list) { return ts.sortAndDeduplicate(list, compareSourcePositions, sameMappedPosition); });
69153             }
69154             return sourceMappings[sourceIndex];
69155         }
69156         function getGeneratedMappings() {
69157             if (generatedMappings === undefined) {
69158                 var list = [];
69159                 for (var _i = 0, _a = getDecodedMappings(); _i < _a.length; _i++) {
69160                     var mapping = _a[_i];
69161                     list.push(mapping);
69162                 }
69163                 generatedMappings = ts.sortAndDeduplicate(list, compareGeneratedPositions, sameMappedPosition);
69164             }
69165             return generatedMappings;
69166         }
69167         function getGeneratedPosition(loc) {
69168             var sourceIndex = sourceToSourceIndexMap.get(host.getCanonicalFileName(loc.fileName));
69169             if (sourceIndex === undefined)
69170                 return loc;
69171             var sourceMappings = getSourceMappings(sourceIndex);
69172             if (!ts.some(sourceMappings))
69173                 return loc;
69174             var targetIndex = ts.binarySearchKey(sourceMappings, loc.pos, getSourcePositionOfMapping, ts.compareValues);
69175             if (targetIndex < 0) {
69176                 targetIndex = ~targetIndex;
69177             }
69178             var mapping = sourceMappings[targetIndex];
69179             if (mapping === undefined || mapping.sourceIndex !== sourceIndex) {
69180                 return loc;
69181             }
69182             return { fileName: generatedAbsoluteFilePath, pos: mapping.generatedPosition };
69183         }
69184         function getSourcePosition(loc) {
69185             var generatedMappings = getGeneratedMappings();
69186             if (!ts.some(generatedMappings))
69187                 return loc;
69188             var targetIndex = ts.binarySearchKey(generatedMappings, loc.pos, getGeneratedPositionOfMapping, ts.compareValues);
69189             if (targetIndex < 0) {
69190                 targetIndex = ~targetIndex;
69191             }
69192             var mapping = generatedMappings[targetIndex];
69193             if (mapping === undefined || !isSourceMappedPosition(mapping)) {
69194                 return loc;
69195             }
69196             return { fileName: sourceFileAbsolutePaths[mapping.sourceIndex], pos: mapping.sourcePosition };
69197         }
69198     }
69199     ts.createDocumentPositionMapper = createDocumentPositionMapper;
69200     ts.identitySourceMapConsumer = {
69201         getSourcePosition: ts.identity,
69202         getGeneratedPosition: ts.identity
69203     };
69204 })(ts || (ts = {}));
69205 var ts;
69206 (function (ts) {
69207     function getOriginalNodeId(node) {
69208         node = ts.getOriginalNode(node);
69209         return node ? ts.getNodeId(node) : 0;
69210     }
69211     ts.getOriginalNodeId = getOriginalNodeId;
69212     function containsDefaultReference(node) {
69213         if (!node)
69214             return false;
69215         if (!ts.isNamedImports(node))
69216             return false;
69217         return ts.some(node.elements, isNamedDefaultReference);
69218     }
69219     function isNamedDefaultReference(e) {
69220         return e.propertyName !== undefined && e.propertyName.escapedText === "default";
69221     }
69222     function chainBundle(context, transformSourceFile) {
69223         return transformSourceFileOrBundle;
69224         function transformSourceFileOrBundle(node) {
69225             return node.kind === 297 ? transformSourceFile(node) : transformBundle(node);
69226         }
69227         function transformBundle(node) {
69228             return context.factory.createBundle(ts.map(node.sourceFiles, transformSourceFile), node.prepends);
69229         }
69230     }
69231     ts.chainBundle = chainBundle;
69232     function getExportNeedsImportStarHelper(node) {
69233         return !!ts.getNamespaceDeclarationNode(node);
69234     }
69235     ts.getExportNeedsImportStarHelper = getExportNeedsImportStarHelper;
69236     function getImportNeedsImportStarHelper(node) {
69237         if (!!ts.getNamespaceDeclarationNode(node)) {
69238             return true;
69239         }
69240         var bindings = node.importClause && node.importClause.namedBindings;
69241         if (!bindings) {
69242             return false;
69243         }
69244         if (!ts.isNamedImports(bindings))
69245             return false;
69246         var defaultRefCount = 0;
69247         for (var _i = 0, _a = bindings.elements; _i < _a.length; _i++) {
69248             var binding = _a[_i];
69249             if (isNamedDefaultReference(binding)) {
69250                 defaultRefCount++;
69251             }
69252         }
69253         return (defaultRefCount > 0 && defaultRefCount !== bindings.elements.length) || (!!(bindings.elements.length - defaultRefCount) && ts.isDefaultImport(node));
69254     }
69255     ts.getImportNeedsImportStarHelper = getImportNeedsImportStarHelper;
69256     function getImportNeedsImportDefaultHelper(node) {
69257         return !getImportNeedsImportStarHelper(node) && (ts.isDefaultImport(node) || (!!node.importClause && ts.isNamedImports(node.importClause.namedBindings) && containsDefaultReference(node.importClause.namedBindings)));
69258     }
69259     ts.getImportNeedsImportDefaultHelper = getImportNeedsImportDefaultHelper;
69260     function collectExternalModuleInfo(context, sourceFile, resolver, compilerOptions) {
69261         var externalImports = [];
69262         var exportSpecifiers = ts.createMultiMap();
69263         var exportedBindings = [];
69264         var uniqueExports = new ts.Map();
69265         var exportedNames;
69266         var hasExportDefault = false;
69267         var exportEquals;
69268         var hasExportStarsToExportValues = false;
69269         var hasImportStar = false;
69270         var hasImportDefault = false;
69271         for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
69272             var node = _a[_i];
69273             switch (node.kind) {
69274                 case 261:
69275                     externalImports.push(node);
69276                     if (!hasImportStar && getImportNeedsImportStarHelper(node)) {
69277                         hasImportStar = true;
69278                     }
69279                     if (!hasImportDefault && getImportNeedsImportDefaultHelper(node)) {
69280                         hasImportDefault = true;
69281                     }
69282                     break;
69283                 case 260:
69284                     if (node.moduleReference.kind === 272) {
69285                         externalImports.push(node);
69286                     }
69287                     break;
69288                 case 267:
69289                     if (node.moduleSpecifier) {
69290                         if (!node.exportClause) {
69291                             externalImports.push(node);
69292                             hasExportStarsToExportValues = true;
69293                         }
69294                         else {
69295                             externalImports.push(node);
69296                             if (ts.isNamedExports(node.exportClause)) {
69297                                 addExportedNamesForExportDeclaration(node);
69298                             }
69299                             else {
69300                                 var name = node.exportClause.name;
69301                                 if (!uniqueExports.get(ts.idText(name))) {
69302                                     multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
69303                                     uniqueExports.set(ts.idText(name), true);
69304                                     exportedNames = ts.append(exportedNames, name);
69305                                 }
69306                                 hasImportStar = true;
69307                             }
69308                         }
69309                     }
69310                     else {
69311                         addExportedNamesForExportDeclaration(node);
69312                     }
69313                     break;
69314                 case 266:
69315                     if (node.isExportEquals && !exportEquals) {
69316                         exportEquals = node;
69317                     }
69318                     break;
69319                 case 232:
69320                     if (ts.hasSyntacticModifier(node, 1)) {
69321                         for (var _b = 0, _c = node.declarationList.declarations; _b < _c.length; _b++) {
69322                             var decl = _c[_b];
69323                             exportedNames = collectExportedVariableInfo(decl, uniqueExports, exportedNames);
69324                         }
69325                     }
69326                     break;
69327                 case 251:
69328                     if (ts.hasSyntacticModifier(node, 1)) {
69329                         if (ts.hasSyntacticModifier(node, 512)) {
69330                             if (!hasExportDefault) {
69331                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node));
69332                                 hasExportDefault = true;
69333                             }
69334                         }
69335                         else {
69336                             var name = node.name;
69337                             if (!uniqueExports.get(ts.idText(name))) {
69338                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
69339                                 uniqueExports.set(ts.idText(name), true);
69340                                 exportedNames = ts.append(exportedNames, name);
69341                             }
69342                         }
69343                     }
69344                     break;
69345                 case 252:
69346                     if (ts.hasSyntacticModifier(node, 1)) {
69347                         if (ts.hasSyntacticModifier(node, 512)) {
69348                             if (!hasExportDefault) {
69349                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), context.factory.getDeclarationName(node));
69350                                 hasExportDefault = true;
69351                             }
69352                         }
69353                         else {
69354                             var name = node.name;
69355                             if (name && !uniqueExports.get(ts.idText(name))) {
69356                                 multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(node), name);
69357                                 uniqueExports.set(ts.idText(name), true);
69358                                 exportedNames = ts.append(exportedNames, name);
69359                             }
69360                         }
69361                     }
69362                     break;
69363             }
69364         }
69365         var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(context.factory, context.getEmitHelperFactory(), sourceFile, compilerOptions, hasExportStarsToExportValues, hasImportStar, hasImportDefault);
69366         if (externalHelpersImportDeclaration) {
69367             externalImports.unshift(externalHelpersImportDeclaration);
69368         }
69369         return { externalImports: externalImports, exportSpecifiers: exportSpecifiers, exportEquals: exportEquals, hasExportStarsToExportValues: hasExportStarsToExportValues, exportedBindings: exportedBindings, exportedNames: exportedNames, externalHelpersImportDeclaration: externalHelpersImportDeclaration };
69370         function addExportedNamesForExportDeclaration(node) {
69371             for (var _i = 0, _a = ts.cast(node.exportClause, ts.isNamedExports).elements; _i < _a.length; _i++) {
69372                 var specifier = _a[_i];
69373                 if (!uniqueExports.get(ts.idText(specifier.name))) {
69374                     var name = specifier.propertyName || specifier.name;
69375                     if (!node.moduleSpecifier) {
69376                         exportSpecifiers.add(ts.idText(name), specifier);
69377                     }
69378                     var decl = resolver.getReferencedImportDeclaration(name)
69379                         || resolver.getReferencedValueDeclaration(name);
69380                     if (decl) {
69381                         multiMapSparseArrayAdd(exportedBindings, getOriginalNodeId(decl), specifier.name);
69382                     }
69383                     uniqueExports.set(ts.idText(specifier.name), true);
69384                     exportedNames = ts.append(exportedNames, specifier.name);
69385                 }
69386             }
69387         }
69388     }
69389     ts.collectExternalModuleInfo = collectExternalModuleInfo;
69390     function collectExportedVariableInfo(decl, uniqueExports, exportedNames) {
69391         if (ts.isBindingPattern(decl.name)) {
69392             for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) {
69393                 var element = _a[_i];
69394                 if (!ts.isOmittedExpression(element)) {
69395                     exportedNames = collectExportedVariableInfo(element, uniqueExports, exportedNames);
69396                 }
69397             }
69398         }
69399         else if (!ts.isGeneratedIdentifier(decl.name)) {
69400             var text = ts.idText(decl.name);
69401             if (!uniqueExports.get(text)) {
69402                 uniqueExports.set(text, true);
69403                 exportedNames = ts.append(exportedNames, decl.name);
69404             }
69405         }
69406         return exportedNames;
69407     }
69408     function multiMapSparseArrayAdd(map, key, value) {
69409         var values = map[key];
69410         if (values) {
69411             values.push(value);
69412         }
69413         else {
69414             map[key] = values = [value];
69415         }
69416         return values;
69417     }
69418     function isSimpleCopiableExpression(expression) {
69419         return ts.isStringLiteralLike(expression) ||
69420             expression.kind === 8 ||
69421             ts.isKeyword(expression.kind) ||
69422             ts.isIdentifier(expression);
69423     }
69424     ts.isSimpleCopiableExpression = isSimpleCopiableExpression;
69425     function isSimpleInlineableExpression(expression) {
69426         return !ts.isIdentifier(expression) && isSimpleCopiableExpression(expression) ||
69427             ts.isWellKnownSymbolSyntactically(expression);
69428     }
69429     ts.isSimpleInlineableExpression = isSimpleInlineableExpression;
69430     function isCompoundAssignment(kind) {
69431         return kind >= 63
69432             && kind <= 77;
69433     }
69434     ts.isCompoundAssignment = isCompoundAssignment;
69435     function getNonAssignmentOperatorForCompoundAssignment(kind) {
69436         switch (kind) {
69437             case 63: return 39;
69438             case 64: return 40;
69439             case 65: return 41;
69440             case 66: return 42;
69441             case 67: return 43;
69442             case 68: return 44;
69443             case 69: return 47;
69444             case 70: return 48;
69445             case 71: return 49;
69446             case 72: return 50;
69447             case 73: return 51;
69448             case 77: return 52;
69449             case 74: return 56;
69450             case 75: return 55;
69451             case 76: return 60;
69452         }
69453     }
69454     ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment;
69455     function addPrologueDirectivesAndInitialSuperCall(factory, ctor, result, visitor) {
69456         if (ctor.body) {
69457             var statements = ctor.body.statements;
69458             var index = factory.copyPrologue(statements, result, false, visitor);
69459             if (index === statements.length) {
69460                 return index;
69461             }
69462             var superIndex = ts.findIndex(statements, function (s) { return ts.isExpressionStatement(s) && ts.isSuperCall(s.expression); }, index);
69463             if (superIndex > -1) {
69464                 for (var i = index; i <= superIndex; i++) {
69465                     result.push(ts.visitNode(statements[i], visitor, ts.isStatement));
69466                 }
69467                 return superIndex + 1;
69468             }
69469             return index;
69470         }
69471         return 0;
69472     }
69473     ts.addPrologueDirectivesAndInitialSuperCall = addPrologueDirectivesAndInitialSuperCall;
69474     function getProperties(node, requireInitializer, isStatic) {
69475         return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); });
69476     }
69477     ts.getProperties = getProperties;
69478     function isInitializedOrStaticProperty(member, requireInitializer, isStatic) {
69479         return ts.isPropertyDeclaration(member)
69480             && (!!member.initializer || !requireInitializer)
69481             && ts.hasStaticModifier(member) === isStatic;
69482     }
69483     function isInitializedProperty(member) {
69484         return member.kind === 163
69485             && member.initializer !== undefined;
69486     }
69487     ts.isInitializedProperty = isInitializedProperty;
69488 })(ts || (ts = {}));
69489 var ts;
69490 (function (ts) {
69491     function flattenDestructuringAssignment(node, visitor, context, level, needsValue, createAssignmentCallback) {
69492         var location = node;
69493         var value;
69494         if (ts.isDestructuringAssignment(node)) {
69495             value = node.right;
69496             while (ts.isEmptyArrayLiteral(node.left) || ts.isEmptyObjectLiteral(node.left)) {
69497                 if (ts.isDestructuringAssignment(value)) {
69498                     location = node = value;
69499                     value = node.right;
69500                 }
69501                 else {
69502                     return ts.visitNode(value, visitor, ts.isExpression);
69503                 }
69504             }
69505         }
69506         var expressions;
69507         var flattenContext = {
69508             context: context,
69509             level: level,
69510             downlevelIteration: !!context.getCompilerOptions().downlevelIteration,
69511             hoistTempVariables: true,
69512             emitExpression: emitExpression,
69513             emitBindingOrAssignment: emitBindingOrAssignment,
69514             createArrayBindingOrAssignmentPattern: function (elements) { return makeArrayAssignmentPattern(context.factory, elements); },
69515             createObjectBindingOrAssignmentPattern: function (elements) { return makeObjectAssignmentPattern(context.factory, elements); },
69516             createArrayBindingOrAssignmentElement: makeAssignmentElement,
69517             visitor: visitor
69518         };
69519         if (value) {
69520             value = ts.visitNode(value, visitor, ts.isExpression);
69521             if (ts.isIdentifier(value) && bindingOrAssignmentElementAssignsToName(node, value.escapedText) ||
69522                 bindingOrAssignmentElementContainsNonLiteralComputedName(node)) {
69523                 value = ensureIdentifier(flattenContext, value, false, location);
69524             }
69525             else if (needsValue) {
69526                 value = ensureIdentifier(flattenContext, value, true, location);
69527             }
69528             else if (ts.nodeIsSynthesized(node)) {
69529                 location = value;
69530             }
69531         }
69532         flattenBindingOrAssignmentElement(flattenContext, node, value, location, ts.isDestructuringAssignment(node));
69533         if (value && needsValue) {
69534             if (!ts.some(expressions)) {
69535                 return value;
69536             }
69537             expressions.push(value);
69538         }
69539         return context.factory.inlineExpressions(expressions) || context.factory.createOmittedExpression();
69540         function emitExpression(expression) {
69541             expressions = ts.append(expressions, expression);
69542         }
69543         function emitBindingOrAssignment(target, value, location, original) {
69544             ts.Debug.assertNode(target, createAssignmentCallback ? ts.isIdentifier : ts.isExpression);
69545             var expression = createAssignmentCallback
69546                 ? createAssignmentCallback(target, value, location)
69547                 : ts.setTextRange(context.factory.createAssignment(ts.visitNode(target, visitor, ts.isExpression), value), location);
69548             expression.original = original;
69549             emitExpression(expression);
69550         }
69551     }
69552     ts.flattenDestructuringAssignment = flattenDestructuringAssignment;
69553     function bindingOrAssignmentElementAssignsToName(element, escapedName) {
69554         var target = ts.getTargetOfBindingOrAssignmentElement(element);
69555         if (ts.isBindingOrAssignmentPattern(target)) {
69556             return bindingOrAssignmentPatternAssignsToName(target, escapedName);
69557         }
69558         else if (ts.isIdentifier(target)) {
69559             return target.escapedText === escapedName;
69560         }
69561         return false;
69562     }
69563     function bindingOrAssignmentPatternAssignsToName(pattern, escapedName) {
69564         var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
69565         for (var _i = 0, elements_3 = elements; _i < elements_3.length; _i++) {
69566             var element = elements_3[_i];
69567             if (bindingOrAssignmentElementAssignsToName(element, escapedName)) {
69568                 return true;
69569             }
69570         }
69571         return false;
69572     }
69573     function bindingOrAssignmentElementContainsNonLiteralComputedName(element) {
69574         var propertyName = ts.tryGetPropertyNameOfBindingOrAssignmentElement(element);
69575         if (propertyName && ts.isComputedPropertyName(propertyName) && !ts.isLiteralExpression(propertyName.expression)) {
69576             return true;
69577         }
69578         var target = ts.getTargetOfBindingOrAssignmentElement(element);
69579         return !!target && ts.isBindingOrAssignmentPattern(target) && bindingOrAssignmentPatternContainsNonLiteralComputedName(target);
69580     }
69581     function bindingOrAssignmentPatternContainsNonLiteralComputedName(pattern) {
69582         return !!ts.forEach(ts.getElementsOfBindingOrAssignmentPattern(pattern), bindingOrAssignmentElementContainsNonLiteralComputedName);
69583     }
69584     function flattenDestructuringBinding(node, visitor, context, level, rval, hoistTempVariables, skipInitializer) {
69585         if (hoistTempVariables === void 0) { hoistTempVariables = false; }
69586         var pendingExpressions;
69587         var pendingDeclarations = [];
69588         var declarations = [];
69589         var flattenContext = {
69590             context: context,
69591             level: level,
69592             downlevelIteration: !!context.getCompilerOptions().downlevelIteration,
69593             hoistTempVariables: hoistTempVariables,
69594             emitExpression: emitExpression,
69595             emitBindingOrAssignment: emitBindingOrAssignment,
69596             createArrayBindingOrAssignmentPattern: function (elements) { return makeArrayBindingPattern(context.factory, elements); },
69597             createObjectBindingOrAssignmentPattern: function (elements) { return makeObjectBindingPattern(context.factory, elements); },
69598             createArrayBindingOrAssignmentElement: function (name) { return makeBindingElement(context.factory, name); },
69599             visitor: visitor
69600         };
69601         if (ts.isVariableDeclaration(node)) {
69602             var initializer = ts.getInitializerOfBindingOrAssignmentElement(node);
69603             if (initializer && (ts.isIdentifier(initializer) && bindingOrAssignmentElementAssignsToName(node, initializer.escapedText) ||
69604                 bindingOrAssignmentElementContainsNonLiteralComputedName(node))) {
69605                 initializer = ensureIdentifier(flattenContext, ts.visitNode(initializer, flattenContext.visitor), false, initializer);
69606                 node = context.factory.updateVariableDeclaration(node, node.name, undefined, undefined, initializer);
69607             }
69608         }
69609         flattenBindingOrAssignmentElement(flattenContext, node, rval, node, skipInitializer);
69610         if (pendingExpressions) {
69611             var temp = context.factory.createTempVariable(undefined);
69612             if (hoistTempVariables) {
69613                 var value = context.factory.inlineExpressions(pendingExpressions);
69614                 pendingExpressions = undefined;
69615                 emitBindingOrAssignment(temp, value, undefined, undefined);
69616             }
69617             else {
69618                 context.hoistVariableDeclaration(temp);
69619                 var pendingDeclaration = ts.last(pendingDeclarations);
69620                 pendingDeclaration.pendingExpressions = ts.append(pendingDeclaration.pendingExpressions, context.factory.createAssignment(temp, pendingDeclaration.value));
69621                 ts.addRange(pendingDeclaration.pendingExpressions, pendingExpressions);
69622                 pendingDeclaration.value = temp;
69623             }
69624         }
69625         for (var _i = 0, pendingDeclarations_1 = pendingDeclarations; _i < pendingDeclarations_1.length; _i++) {
69626             var _a = pendingDeclarations_1[_i], pendingExpressions_1 = _a.pendingExpressions, name = _a.name, value = _a.value, location = _a.location, original = _a.original;
69627             var variable = context.factory.createVariableDeclaration(name, undefined, undefined, pendingExpressions_1 ? context.factory.inlineExpressions(ts.append(pendingExpressions_1, value)) : value);
69628             variable.original = original;
69629             ts.setTextRange(variable, location);
69630             declarations.push(variable);
69631         }
69632         return declarations;
69633         function emitExpression(value) {
69634             pendingExpressions = ts.append(pendingExpressions, value);
69635         }
69636         function emitBindingOrAssignment(target, value, location, original) {
69637             ts.Debug.assertNode(target, ts.isBindingName);
69638             if (pendingExpressions) {
69639                 value = context.factory.inlineExpressions(ts.append(pendingExpressions, value));
69640                 pendingExpressions = undefined;
69641             }
69642             pendingDeclarations.push({ pendingExpressions: pendingExpressions, name: target, value: value, location: location, original: original });
69643         }
69644     }
69645     ts.flattenDestructuringBinding = flattenDestructuringBinding;
69646     function flattenBindingOrAssignmentElement(flattenContext, element, value, location, skipInitializer) {
69647         var bindingTarget = ts.getTargetOfBindingOrAssignmentElement(element);
69648         if (!skipInitializer) {
69649             var initializer = ts.visitNode(ts.getInitializerOfBindingOrAssignmentElement(element), flattenContext.visitor, ts.isExpression);
69650             if (initializer) {
69651                 if (value) {
69652                     value = createDefaultValueCheck(flattenContext, value, initializer, location);
69653                     if (!ts.isSimpleInlineableExpression(initializer) && ts.isBindingOrAssignmentPattern(bindingTarget)) {
69654                         value = ensureIdentifier(flattenContext, value, true, location);
69655                     }
69656                 }
69657                 else {
69658                     value = initializer;
69659                 }
69660             }
69661             else if (!value) {
69662                 value = flattenContext.context.factory.createVoidZero();
69663             }
69664         }
69665         if (ts.isObjectBindingOrAssignmentPattern(bindingTarget)) {
69666             flattenObjectBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location);
69667         }
69668         else if (ts.isArrayBindingOrAssignmentPattern(bindingTarget)) {
69669             flattenArrayBindingOrAssignmentPattern(flattenContext, element, bindingTarget, value, location);
69670         }
69671         else {
69672             flattenContext.emitBindingOrAssignment(bindingTarget, value, location, element);
69673         }
69674     }
69675     function flattenObjectBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) {
69676         var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
69677         var numElements = elements.length;
69678         if (numElements !== 1) {
69679             var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0;
69680             value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location);
69681         }
69682         var bindingElements;
69683         var computedTempVariables;
69684         for (var i = 0; i < numElements; i++) {
69685             var element = elements[i];
69686             if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
69687                 var propertyName = ts.getPropertyNameOfBindingOrAssignmentElement(element);
69688                 if (flattenContext.level >= 1
69689                     && !(element.transformFlags & (8192 | 16384))
69690                     && !(ts.getTargetOfBindingOrAssignmentElement(element).transformFlags & (8192 | 16384))
69691                     && !ts.isComputedPropertyName(propertyName)) {
69692                     bindingElements = ts.append(bindingElements, ts.visitNode(element, flattenContext.visitor));
69693                 }
69694                 else {
69695                     if (bindingElements) {
69696                         flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
69697                         bindingElements = undefined;
69698                     }
69699                     var rhsValue = createDestructuringPropertyAccess(flattenContext, value, propertyName);
69700                     if (ts.isComputedPropertyName(propertyName)) {
69701                         computedTempVariables = ts.append(computedTempVariables, rhsValue.argumentExpression);
69702                     }
69703                     flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
69704                 }
69705             }
69706             else if (i === numElements - 1) {
69707                 if (bindingElements) {
69708                     flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
69709                     bindingElements = undefined;
69710                 }
69711                 var rhsValue = flattenContext.context.getEmitHelperFactory().createRestHelper(value, elements, computedTempVariables, pattern);
69712                 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
69713             }
69714         }
69715         if (bindingElements) {
69716             flattenContext.emitBindingOrAssignment(flattenContext.createObjectBindingOrAssignmentPattern(bindingElements), value, location, pattern);
69717         }
69718     }
69719     function flattenArrayBindingOrAssignmentPattern(flattenContext, parent, pattern, value, location) {
69720         var elements = ts.getElementsOfBindingOrAssignmentPattern(pattern);
69721         var numElements = elements.length;
69722         if (flattenContext.level < 1 && flattenContext.downlevelIteration) {
69723             value = ensureIdentifier(flattenContext, ts.setTextRange(flattenContext.context.getEmitHelperFactory().createReadHelper(value, numElements > 0 && ts.getRestIndicatorOfBindingOrAssignmentElement(elements[numElements - 1])
69724                 ? undefined
69725                 : numElements), location), false, location);
69726         }
69727         else if (numElements !== 1 && (flattenContext.level < 1 || numElements === 0)
69728             || ts.every(elements, ts.isOmittedExpression)) {
69729             var reuseIdentifierExpressions = !ts.isDeclarationBindingElement(parent) || numElements !== 0;
69730             value = ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location);
69731         }
69732         var bindingElements;
69733         var restContainingElements;
69734         for (var i = 0; i < numElements; i++) {
69735             var element = elements[i];
69736             if (flattenContext.level >= 1) {
69737                 if (element.transformFlags & 16384 || flattenContext.hasTransformedPriorElement && !isSimpleBindingOrAssignmentElement(element)) {
69738                     flattenContext.hasTransformedPriorElement = true;
69739                     var temp = flattenContext.context.factory.createTempVariable(undefined);
69740                     if (flattenContext.hoistTempVariables) {
69741                         flattenContext.context.hoistVariableDeclaration(temp);
69742                     }
69743                     restContainingElements = ts.append(restContainingElements, [temp, element]);
69744                     bindingElements = ts.append(bindingElements, flattenContext.createArrayBindingOrAssignmentElement(temp));
69745                 }
69746                 else {
69747                     bindingElements = ts.append(bindingElements, element);
69748                 }
69749             }
69750             else if (ts.isOmittedExpression(element)) {
69751                 continue;
69752             }
69753             else if (!ts.getRestIndicatorOfBindingOrAssignmentElement(element)) {
69754                 var rhsValue = flattenContext.context.factory.createElementAccessExpression(value, i);
69755                 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
69756             }
69757             else if (i === numElements - 1) {
69758                 var rhsValue = flattenContext.context.factory.createArraySliceCall(value, i);
69759                 flattenBindingOrAssignmentElement(flattenContext, element, rhsValue, element);
69760             }
69761         }
69762         if (bindingElements) {
69763             flattenContext.emitBindingOrAssignment(flattenContext.createArrayBindingOrAssignmentPattern(bindingElements), value, location, pattern);
69764         }
69765         if (restContainingElements) {
69766             for (var _i = 0, restContainingElements_1 = restContainingElements; _i < restContainingElements_1.length; _i++) {
69767                 var _a = restContainingElements_1[_i], id = _a[0], element = _a[1];
69768                 flattenBindingOrAssignmentElement(flattenContext, element, id, element);
69769             }
69770         }
69771     }
69772     function isSimpleBindingOrAssignmentElement(element) {
69773         var target = ts.getTargetOfBindingOrAssignmentElement(element);
69774         if (!target || ts.isOmittedExpression(target))
69775             return true;
69776         var propertyName = ts.tryGetPropertyNameOfBindingOrAssignmentElement(element);
69777         if (propertyName && !ts.isPropertyNameLiteral(propertyName))
69778             return false;
69779         var initializer = ts.getInitializerOfBindingOrAssignmentElement(element);
69780         if (initializer && !ts.isSimpleInlineableExpression(initializer))
69781             return false;
69782         if (ts.isBindingOrAssignmentPattern(target))
69783             return ts.every(ts.getElementsOfBindingOrAssignmentPattern(target), isSimpleBindingOrAssignmentElement);
69784         return ts.isIdentifier(target);
69785     }
69786     function createDefaultValueCheck(flattenContext, value, defaultValue, location) {
69787         value = ensureIdentifier(flattenContext, value, true, location);
69788         return flattenContext.context.factory.createConditionalExpression(flattenContext.context.factory.createTypeCheck(value, "undefined"), undefined, defaultValue, undefined, value);
69789     }
69790     function createDestructuringPropertyAccess(flattenContext, value, propertyName) {
69791         if (ts.isComputedPropertyName(propertyName)) {
69792             var argumentExpression = ensureIdentifier(flattenContext, ts.visitNode(propertyName.expression, flattenContext.visitor), false, propertyName);
69793             return flattenContext.context.factory.createElementAccessExpression(value, argumentExpression);
69794         }
69795         else if (ts.isStringOrNumericLiteralLike(propertyName)) {
69796             var argumentExpression = ts.factory.cloneNode(propertyName);
69797             return flattenContext.context.factory.createElementAccessExpression(value, argumentExpression);
69798         }
69799         else {
69800             var name = flattenContext.context.factory.createIdentifier(ts.idText(propertyName));
69801             return flattenContext.context.factory.createPropertyAccessExpression(value, name);
69802         }
69803     }
69804     function ensureIdentifier(flattenContext, value, reuseIdentifierExpressions, location) {
69805         if (ts.isIdentifier(value) && reuseIdentifierExpressions) {
69806             return value;
69807         }
69808         else {
69809             var temp = flattenContext.context.factory.createTempVariable(undefined);
69810             if (flattenContext.hoistTempVariables) {
69811                 flattenContext.context.hoistVariableDeclaration(temp);
69812                 flattenContext.emitExpression(ts.setTextRange(flattenContext.context.factory.createAssignment(temp, value), location));
69813             }
69814             else {
69815                 flattenContext.emitBindingOrAssignment(temp, value, location, undefined);
69816             }
69817             return temp;
69818         }
69819     }
69820     function makeArrayBindingPattern(factory, elements) {
69821         ts.Debug.assertEachNode(elements, ts.isArrayBindingElement);
69822         return factory.createArrayBindingPattern(elements);
69823     }
69824     function makeArrayAssignmentPattern(factory, elements) {
69825         return factory.createArrayLiteralExpression(ts.map(elements, factory.converters.convertToArrayAssignmentElement));
69826     }
69827     function makeObjectBindingPattern(factory, elements) {
69828         ts.Debug.assertEachNode(elements, ts.isBindingElement);
69829         return factory.createObjectBindingPattern(elements);
69830     }
69831     function makeObjectAssignmentPattern(factory, elements) {
69832         return factory.createObjectLiteralExpression(ts.map(elements, factory.converters.convertToObjectAssignmentElement));
69833     }
69834     function makeBindingElement(factory, name) {
69835         return factory.createBindingElement(undefined, undefined, name);
69836     }
69837     function makeAssignmentElement(name) {
69838         return name;
69839     }
69840 })(ts || (ts = {}));
69841 var ts;
69842 (function (ts) {
69843     var ProcessLevel;
69844     (function (ProcessLevel) {
69845         ProcessLevel[ProcessLevel["LiftRestriction"] = 0] = "LiftRestriction";
69846         ProcessLevel[ProcessLevel["All"] = 1] = "All";
69847     })(ProcessLevel = ts.ProcessLevel || (ts.ProcessLevel = {}));
69848     function processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, level) {
69849         var tag = ts.visitNode(node.tag, visitor, ts.isExpression);
69850         var templateArguments = [undefined];
69851         var cookedStrings = [];
69852         var rawStrings = [];
69853         var template = node.template;
69854         if (level === ProcessLevel.LiftRestriction && !ts.hasInvalidEscape(template)) {
69855             return ts.visitEachChild(node, visitor, context);
69856         }
69857         if (ts.isNoSubstitutionTemplateLiteral(template)) {
69858             cookedStrings.push(createTemplateCooked(template));
69859             rawStrings.push(getRawLiteral(template, currentSourceFile));
69860         }
69861         else {
69862             cookedStrings.push(createTemplateCooked(template.head));
69863             rawStrings.push(getRawLiteral(template.head, currentSourceFile));
69864             for (var _i = 0, _a = template.templateSpans; _i < _a.length; _i++) {
69865                 var templateSpan = _a[_i];
69866                 cookedStrings.push(createTemplateCooked(templateSpan.literal));
69867                 rawStrings.push(getRawLiteral(templateSpan.literal, currentSourceFile));
69868                 templateArguments.push(ts.visitNode(templateSpan.expression, visitor, ts.isExpression));
69869             }
69870         }
69871         var helperCall = context.getEmitHelperFactory().createTemplateObjectHelper(ts.factory.createArrayLiteralExpression(cookedStrings), ts.factory.createArrayLiteralExpression(rawStrings));
69872         if (ts.isExternalModule(currentSourceFile)) {
69873             var tempVar = ts.factory.createUniqueName("templateObject");
69874             recordTaggedTemplateString(tempVar);
69875             templateArguments[0] = ts.factory.createLogicalOr(tempVar, ts.factory.createAssignment(tempVar, helperCall));
69876         }
69877         else {
69878             templateArguments[0] = helperCall;
69879         }
69880         return ts.factory.createCallExpression(tag, undefined, templateArguments);
69881     }
69882     ts.processTaggedTemplateExpression = processTaggedTemplateExpression;
69883     function createTemplateCooked(template) {
69884         return template.templateFlags ? ts.factory.createVoidZero() : ts.factory.createStringLiteral(template.text);
69885     }
69886     function getRawLiteral(node, currentSourceFile) {
69887         var text = node.rawText;
69888         if (text === undefined) {
69889             text = ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node);
69890             var isLast = node.kind === 14 || node.kind === 17;
69891             text = text.substring(1, text.length - (isLast ? 1 : 2));
69892         }
69893         text = text.replace(/\r\n?/g, "\n");
69894         return ts.setTextRange(ts.factory.createStringLiteral(text), node);
69895     }
69896 })(ts || (ts = {}));
69897 var ts;
69898 (function (ts) {
69899     var USE_NEW_TYPE_METADATA_FORMAT = false;
69900     function transformTypeScript(context) {
69901         var factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
69902         var resolver = context.getEmitResolver();
69903         var compilerOptions = context.getCompilerOptions();
69904         var strictNullChecks = ts.getStrictOptionValue(compilerOptions, "strictNullChecks");
69905         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
69906         var moduleKind = ts.getEmitModuleKind(compilerOptions);
69907         var previousOnEmitNode = context.onEmitNode;
69908         var previousOnSubstituteNode = context.onSubstituteNode;
69909         context.onEmitNode = onEmitNode;
69910         context.onSubstituteNode = onSubstituteNode;
69911         context.enableSubstitution(201);
69912         context.enableSubstitution(202);
69913         var currentSourceFile;
69914         var currentNamespace;
69915         var currentNamespaceContainerName;
69916         var currentLexicalScope;
69917         var currentNameScope;
69918         var currentScopeFirstDeclarationsOfName;
69919         var currentClassHasParameterProperties;
69920         var enabledSubstitutions;
69921         var classAliases;
69922         var applicableSubstitutions;
69923         return transformSourceFileOrBundle;
69924         function transformSourceFileOrBundle(node) {
69925             if (node.kind === 298) {
69926                 return transformBundle(node);
69927             }
69928             return transformSourceFile(node);
69929         }
69930         function transformBundle(node) {
69931             return factory.createBundle(node.sourceFiles.map(transformSourceFile), ts.mapDefined(node.prepends, function (prepend) {
69932                 if (prepend.kind === 300) {
69933                     return ts.createUnparsedSourceFile(prepend, "js");
69934                 }
69935                 return prepend;
69936             }));
69937         }
69938         function transformSourceFile(node) {
69939             if (node.isDeclarationFile) {
69940                 return node;
69941             }
69942             currentSourceFile = node;
69943             var visited = saveStateAndInvoke(node, visitSourceFile);
69944             ts.addEmitHelpers(visited, context.readEmitHelpers());
69945             currentSourceFile = undefined;
69946             return visited;
69947         }
69948         function saveStateAndInvoke(node, f) {
69949             var savedCurrentScope = currentLexicalScope;
69950             var savedCurrentNameScope = currentNameScope;
69951             var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
69952             var savedCurrentClassHasParameterProperties = currentClassHasParameterProperties;
69953             onBeforeVisitNode(node);
69954             var visited = f(node);
69955             if (currentLexicalScope !== savedCurrentScope) {
69956                 currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
69957             }
69958             currentLexicalScope = savedCurrentScope;
69959             currentNameScope = savedCurrentNameScope;
69960             currentClassHasParameterProperties = savedCurrentClassHasParameterProperties;
69961             return visited;
69962         }
69963         function onBeforeVisitNode(node) {
69964             switch (node.kind) {
69965                 case 297:
69966                 case 258:
69967                 case 257:
69968                 case 230:
69969                     currentLexicalScope = node;
69970                     currentNameScope = undefined;
69971                     currentScopeFirstDeclarationsOfName = undefined;
69972                     break;
69973                 case 252:
69974                 case 251:
69975                     if (ts.hasSyntacticModifier(node, 2)) {
69976                         break;
69977                     }
69978                     if (node.name) {
69979                         recordEmittedDeclarationInScope(node);
69980                     }
69981                     else {
69982                         ts.Debug.assert(node.kind === 252 || ts.hasSyntacticModifier(node, 512));
69983                     }
69984                     if (ts.isClassDeclaration(node)) {
69985                         currentNameScope = node;
69986                     }
69987                     break;
69988             }
69989         }
69990         function visitor(node) {
69991             return saveStateAndInvoke(node, visitorWorker);
69992         }
69993         function visitorWorker(node) {
69994             if (node.transformFlags & 1) {
69995                 return visitTypeScript(node);
69996             }
69997             return node;
69998         }
69999         function sourceElementVisitor(node) {
70000             return saveStateAndInvoke(node, sourceElementVisitorWorker);
70001         }
70002         function sourceElementVisitorWorker(node) {
70003             switch (node.kind) {
70004                 case 261:
70005                 case 260:
70006                 case 266:
70007                 case 267:
70008                     return visitElidableStatement(node);
70009                 default:
70010                     return visitorWorker(node);
70011             }
70012         }
70013         function visitElidableStatement(node) {
70014             var parsed = ts.getParseTreeNode(node);
70015             if (parsed !== node) {
70016                 if (node.transformFlags & 1) {
70017                     return ts.visitEachChild(node, visitor, context);
70018                 }
70019                 return node;
70020             }
70021             switch (node.kind) {
70022                 case 261:
70023                     return visitImportDeclaration(node);
70024                 case 260:
70025                     return visitImportEqualsDeclaration(node);
70026                 case 266:
70027                     return visitExportAssignment(node);
70028                 case 267:
70029                     return visitExportDeclaration(node);
70030                 default:
70031                     ts.Debug.fail("Unhandled ellided statement");
70032             }
70033         }
70034         function namespaceElementVisitor(node) {
70035             return saveStateAndInvoke(node, namespaceElementVisitorWorker);
70036         }
70037         function namespaceElementVisitorWorker(node) {
70038             if (node.kind === 267 ||
70039                 node.kind === 261 ||
70040                 node.kind === 262 ||
70041                 (node.kind === 260 &&
70042                     node.moduleReference.kind === 272)) {
70043                 return undefined;
70044             }
70045             else if (node.transformFlags & 1 || ts.hasSyntacticModifier(node, 1)) {
70046                 return visitTypeScript(node);
70047             }
70048             return node;
70049         }
70050         function classElementVisitor(node) {
70051             return saveStateAndInvoke(node, classElementVisitorWorker);
70052         }
70053         function classElementVisitorWorker(node) {
70054             switch (node.kind) {
70055                 case 166:
70056                     return visitConstructor(node);
70057                 case 163:
70058                     return visitPropertyDeclaration(node);
70059                 case 171:
70060                 case 167:
70061                 case 168:
70062                 case 165:
70063                     return visitorWorker(node);
70064                 case 229:
70065                     return node;
70066                 default:
70067                     return ts.Debug.failBadSyntaxKind(node);
70068             }
70069         }
70070         function modifierVisitor(node) {
70071             if (ts.modifierToFlag(node.kind) & 2270) {
70072                 return undefined;
70073             }
70074             else if (currentNamespace && node.kind === 92) {
70075                 return undefined;
70076             }
70077             return node;
70078         }
70079         function visitTypeScript(node) {
70080             if (ts.isStatement(node) && ts.hasSyntacticModifier(node, 2)) {
70081                 return factory.createNotEmittedStatement(node);
70082             }
70083             switch (node.kind) {
70084                 case 92:
70085                 case 87:
70086                     return currentNamespace ? undefined : node;
70087                 case 122:
70088                 case 120:
70089                 case 121:
70090                 case 125:
70091                 case 84:
70092                 case 133:
70093                 case 142:
70094                 case 178:
70095                 case 179:
70096                 case 180:
70097                 case 181:
70098                 case 177:
70099                 case 172:
70100                 case 159:
70101                 case 128:
70102                 case 152:
70103                 case 131:
70104                 case 147:
70105                 case 144:
70106                 case 141:
70107                 case 113:
70108                 case 148:
70109                 case 175:
70110                 case 174:
70111                 case 176:
70112                 case 173:
70113                 case 182:
70114                 case 183:
70115                 case 184:
70116                 case 186:
70117                 case 187:
70118                 case 188:
70119                 case 189:
70120                 case 190:
70121                 case 191:
70122                 case 171:
70123                 case 161:
70124                 case 254:
70125                     return undefined;
70126                 case 163:
70127                     return visitPropertyDeclaration(node);
70128                 case 259:
70129                     return undefined;
70130                 case 166:
70131                     return visitConstructor(node);
70132                 case 253:
70133                     return factory.createNotEmittedStatement(node);
70134                 case 252:
70135                     return visitClassDeclaration(node);
70136                 case 221:
70137                     return visitClassExpression(node);
70138                 case 286:
70139                     return visitHeritageClause(node);
70140                 case 223:
70141                     return visitExpressionWithTypeArguments(node);
70142                 case 165:
70143                     return visitMethodDeclaration(node);
70144                 case 167:
70145                     return visitGetAccessor(node);
70146                 case 168:
70147                     return visitSetAccessor(node);
70148                 case 251:
70149                     return visitFunctionDeclaration(node);
70150                 case 208:
70151                     return visitFunctionExpression(node);
70152                 case 209:
70153                     return visitArrowFunction(node);
70154                 case 160:
70155                     return visitParameter(node);
70156                 case 207:
70157                     return visitParenthesizedExpression(node);
70158                 case 206:
70159                 case 224:
70160                     return visitAssertionExpression(node);
70161                 case 203:
70162                     return visitCallExpression(node);
70163                 case 204:
70164                     return visitNewExpression(node);
70165                 case 205:
70166                     return visitTaggedTemplateExpression(node);
70167                 case 225:
70168                     return visitNonNullExpression(node);
70169                 case 255:
70170                     return visitEnumDeclaration(node);
70171                 case 232:
70172                     return visitVariableStatement(node);
70173                 case 249:
70174                     return visitVariableDeclaration(node);
70175                 case 256:
70176                     return visitModuleDeclaration(node);
70177                 case 260:
70178                     return visitImportEqualsDeclaration(node);
70179                 case 274:
70180                     return visitJsxSelfClosingElement(node);
70181                 case 275:
70182                     return visitJsxJsxOpeningElement(node);
70183                 default:
70184                     return ts.visitEachChild(node, visitor, context);
70185             }
70186         }
70187         function visitSourceFile(node) {
70188             var alwaysStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") &&
70189                 !(ts.isExternalModule(node) && moduleKind >= ts.ModuleKind.ES2015) &&
70190                 !ts.isJsonSourceFile(node);
70191             return factory.updateSourceFile(node, ts.visitLexicalEnvironment(node.statements, sourceElementVisitor, context, 0, alwaysStrict));
70192         }
70193         function shouldEmitDecorateCallForClass(node) {
70194             if (node.decorators && node.decorators.length > 0) {
70195                 return true;
70196             }
70197             var constructor = ts.getFirstConstructorWithBody(node);
70198             if (constructor) {
70199                 return ts.forEach(constructor.parameters, shouldEmitDecorateCallForParameter);
70200             }
70201             return false;
70202         }
70203         function shouldEmitDecorateCallForParameter(parameter) {
70204             return parameter.decorators !== undefined && parameter.decorators.length > 0;
70205         }
70206         function getClassFacts(node, staticProperties) {
70207             var facts = 0;
70208             if (ts.some(staticProperties))
70209                 facts |= 1;
70210             var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
70211             if (extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103)
70212                 facts |= 64;
70213             if (shouldEmitDecorateCallForClass(node))
70214                 facts |= 2;
70215             if (ts.childIsDecorated(node))
70216                 facts |= 4;
70217             if (isExportOfNamespace(node))
70218                 facts |= 8;
70219             else if (isDefaultExternalModuleExport(node))
70220                 facts |= 32;
70221             else if (isNamedExternalModuleExport(node))
70222                 facts |= 16;
70223             if (languageVersion <= 1 && (facts & 7))
70224                 facts |= 128;
70225             return facts;
70226         }
70227         function hasTypeScriptClassSyntax(node) {
70228             return !!(node.transformFlags & 2048);
70229         }
70230         function isClassLikeDeclarationWithTypeScriptSyntax(node) {
70231             return ts.some(node.decorators)
70232                 || ts.some(node.typeParameters)
70233                 || ts.some(node.heritageClauses, hasTypeScriptClassSyntax)
70234                 || ts.some(node.members, hasTypeScriptClassSyntax);
70235         }
70236         function visitClassDeclaration(node) {
70237             if (!isClassLikeDeclarationWithTypeScriptSyntax(node) && !(currentNamespace && ts.hasSyntacticModifier(node, 1))) {
70238                 return ts.visitEachChild(node, visitor, context);
70239             }
70240             var staticProperties = ts.getProperties(node, true, true);
70241             var facts = getClassFacts(node, staticProperties);
70242             if (facts & 128) {
70243                 context.startLexicalEnvironment();
70244             }
70245             var name = node.name || (facts & 5 ? factory.getGeneratedNameForNode(node) : undefined);
70246             var classStatement = facts & 2
70247                 ? createClassDeclarationHeadWithDecorators(node, name)
70248                 : createClassDeclarationHeadWithoutDecorators(node, name, facts);
70249             var statements = [classStatement];
70250             addClassElementDecorationStatements(statements, node, false);
70251             addClassElementDecorationStatements(statements, node, true);
70252             addConstructorDecorationStatement(statements, node);
70253             if (facts & 128) {
70254                 var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentSourceFile.text, node.members.end), 19);
70255                 var localName = factory.getInternalName(node);
70256                 var outer = factory.createPartiallyEmittedExpression(localName);
70257                 ts.setTextRangeEnd(outer, closingBraceLocation.end);
70258                 ts.setEmitFlags(outer, 1536);
70259                 var statement = factory.createReturnStatement(outer);
70260                 ts.setTextRangePos(statement, closingBraceLocation.pos);
70261                 ts.setEmitFlags(statement, 1536 | 384);
70262                 statements.push(statement);
70263                 ts.insertStatementsAfterStandardPrologue(statements, context.endLexicalEnvironment());
70264                 var iife = factory.createImmediatelyInvokedArrowFunction(statements);
70265                 ts.setEmitFlags(iife, 33554432);
70266                 var varStatement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
70267                     factory.createVariableDeclaration(factory.getLocalName(node, false, false), undefined, undefined, iife)
70268                 ]));
70269                 ts.setOriginalNode(varStatement, node);
70270                 ts.setCommentRange(varStatement, node);
70271                 ts.setSourceMapRange(varStatement, ts.moveRangePastDecorators(node));
70272                 ts.startOnNewLine(varStatement);
70273                 statements = [varStatement];
70274             }
70275             if (facts & 8) {
70276                 addExportMemberAssignment(statements, node);
70277             }
70278             else if (facts & 128 || facts & 2) {
70279                 if (facts & 32) {
70280                     statements.push(factory.createExportDefault(factory.getLocalName(node, false, true)));
70281                 }
70282                 else if (facts & 16) {
70283                     statements.push(factory.createExternalModuleExport(factory.getLocalName(node, false, true)));
70284                 }
70285             }
70286             if (statements.length > 1) {
70287                 statements.push(factory.createEndOfDeclarationMarker(node));
70288                 ts.setEmitFlags(classStatement, ts.getEmitFlags(classStatement) | 4194304);
70289             }
70290             return ts.singleOrMany(statements);
70291         }
70292         function createClassDeclarationHeadWithoutDecorators(node, name, facts) {
70293             var modifiers = !(facts & 128)
70294                 ? ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier)
70295                 : undefined;
70296             var classDeclaration = factory.createClassDeclaration(undefined, modifiers, name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
70297             var emitFlags = ts.getEmitFlags(node);
70298             if (facts & 1) {
70299                 emitFlags |= 32;
70300             }
70301             ts.setTextRange(classDeclaration, node);
70302             ts.setOriginalNode(classDeclaration, node);
70303             ts.setEmitFlags(classDeclaration, emitFlags);
70304             return classDeclaration;
70305         }
70306         function createClassDeclarationHeadWithDecorators(node, name) {
70307             var location = ts.moveRangePastDecorators(node);
70308             var classAlias = getClassAliasIfNeeded(node);
70309             var declName = factory.getLocalName(node, false, true);
70310             var heritageClauses = ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause);
70311             var members = transformClassMembers(node);
70312             var classExpression = factory.createClassExpression(undefined, undefined, name, undefined, heritageClauses, members);
70313             ts.setOriginalNode(classExpression, node);
70314             ts.setTextRange(classExpression, location);
70315             var statement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
70316                 factory.createVariableDeclaration(declName, undefined, undefined, classAlias ? factory.createAssignment(classAlias, classExpression) : classExpression)
70317             ], 1));
70318             ts.setOriginalNode(statement, node);
70319             ts.setTextRange(statement, location);
70320             ts.setCommentRange(statement, node);
70321             return statement;
70322         }
70323         function visitClassExpression(node) {
70324             if (!isClassLikeDeclarationWithTypeScriptSyntax(node)) {
70325                 return ts.visitEachChild(node, visitor, context);
70326             }
70327             var classExpression = factory.createClassExpression(undefined, undefined, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node));
70328             ts.setOriginalNode(classExpression, node);
70329             ts.setTextRange(classExpression, node);
70330             return classExpression;
70331         }
70332         function transformClassMembers(node) {
70333             var members = [];
70334             var constructor = ts.getFirstConstructorWithBody(node);
70335             var parametersWithPropertyAssignments = constructor &&
70336                 ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); });
70337             if (parametersWithPropertyAssignments) {
70338                 for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) {
70339                     var parameter = parametersWithPropertyAssignments_1[_i];
70340                     if (ts.isIdentifier(parameter.name)) {
70341                         members.push(ts.setOriginalNode(factory.createPropertyDeclaration(undefined, undefined, parameter.name, undefined, undefined, undefined), parameter));
70342                     }
70343                 }
70344             }
70345             ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
70346             return ts.setTextRange(factory.createNodeArray(members), node.members);
70347         }
70348         function getDecoratedClassElements(node, isStatic) {
70349             return ts.filter(node.members, isStatic ? function (m) { return isStaticDecoratedClassElement(m, node); } : function (m) { return isInstanceDecoratedClassElement(m, node); });
70350         }
70351         function isStaticDecoratedClassElement(member, parent) {
70352             return isDecoratedClassElement(member, true, parent);
70353         }
70354         function isInstanceDecoratedClassElement(member, parent) {
70355             return isDecoratedClassElement(member, false, parent);
70356         }
70357         function isDecoratedClassElement(member, isStatic, parent) {
70358             return ts.nodeOrChildIsDecorated(member, parent)
70359                 && isStatic === ts.hasSyntacticModifier(member, 32);
70360         }
70361         function getDecoratorsOfParameters(node) {
70362             var decorators;
70363             if (node) {
70364                 var parameters = node.parameters;
70365                 var firstParameterIsThis = parameters.length > 0 && ts.parameterIsThisKeyword(parameters[0]);
70366                 var firstParameterOffset = firstParameterIsThis ? 1 : 0;
70367                 var numParameters = firstParameterIsThis ? parameters.length - 1 : parameters.length;
70368                 for (var i = 0; i < numParameters; i++) {
70369                     var parameter = parameters[i + firstParameterOffset];
70370                     if (decorators || parameter.decorators) {
70371                         if (!decorators) {
70372                             decorators = new Array(numParameters);
70373                         }
70374                         decorators[i] = parameter.decorators;
70375                     }
70376                 }
70377             }
70378             return decorators;
70379         }
70380         function getAllDecoratorsOfConstructor(node) {
70381             var decorators = node.decorators;
70382             var parameters = getDecoratorsOfParameters(ts.getFirstConstructorWithBody(node));
70383             if (!decorators && !parameters) {
70384                 return undefined;
70385             }
70386             return {
70387                 decorators: decorators,
70388                 parameters: parameters
70389             };
70390         }
70391         function getAllDecoratorsOfClassElement(node, member) {
70392             switch (member.kind) {
70393                 case 167:
70394                 case 168:
70395                     return getAllDecoratorsOfAccessors(node, member);
70396                 case 165:
70397                     return getAllDecoratorsOfMethod(member);
70398                 case 163:
70399                     return getAllDecoratorsOfProperty(member);
70400                 default:
70401                     return undefined;
70402             }
70403         }
70404         function getAllDecoratorsOfAccessors(node, accessor) {
70405             if (!accessor.body) {
70406                 return undefined;
70407             }
70408             var _a = ts.getAllAccessorDeclarations(node.members, accessor), firstAccessor = _a.firstAccessor, secondAccessor = _a.secondAccessor, setAccessor = _a.setAccessor;
70409             var firstAccessorWithDecorators = firstAccessor.decorators ? firstAccessor : secondAccessor && secondAccessor.decorators ? secondAccessor : undefined;
70410             if (!firstAccessorWithDecorators || accessor !== firstAccessorWithDecorators) {
70411                 return undefined;
70412             }
70413             var decorators = firstAccessorWithDecorators.decorators;
70414             var parameters = getDecoratorsOfParameters(setAccessor);
70415             if (!decorators && !parameters) {
70416                 return undefined;
70417             }
70418             return { decorators: decorators, parameters: parameters };
70419         }
70420         function getAllDecoratorsOfMethod(method) {
70421             if (!method.body) {
70422                 return undefined;
70423             }
70424             var decorators = method.decorators;
70425             var parameters = getDecoratorsOfParameters(method);
70426             if (!decorators && !parameters) {
70427                 return undefined;
70428             }
70429             return { decorators: decorators, parameters: parameters };
70430         }
70431         function getAllDecoratorsOfProperty(property) {
70432             var decorators = property.decorators;
70433             if (!decorators) {
70434                 return undefined;
70435             }
70436             return { decorators: decorators };
70437         }
70438         function transformAllDecoratorsOfDeclaration(node, container, allDecorators) {
70439             if (!allDecorators) {
70440                 return undefined;
70441             }
70442             var decoratorExpressions = [];
70443             ts.addRange(decoratorExpressions, ts.map(allDecorators.decorators, transformDecorator));
70444             ts.addRange(decoratorExpressions, ts.flatMap(allDecorators.parameters, transformDecoratorsOfParameter));
70445             addTypeMetadata(node, container, decoratorExpressions);
70446             return decoratorExpressions;
70447         }
70448         function addClassElementDecorationStatements(statements, node, isStatic) {
70449             ts.addRange(statements, ts.map(generateClassElementDecorationExpressions(node, isStatic), expressionToStatement));
70450         }
70451         function generateClassElementDecorationExpressions(node, isStatic) {
70452             var members = getDecoratedClassElements(node, isStatic);
70453             var expressions;
70454             for (var _i = 0, members_6 = members; _i < members_6.length; _i++) {
70455                 var member = members_6[_i];
70456                 var expression = generateClassElementDecorationExpression(node, member);
70457                 if (expression) {
70458                     if (!expressions) {
70459                         expressions = [expression];
70460                     }
70461                     else {
70462                         expressions.push(expression);
70463                     }
70464                 }
70465             }
70466             return expressions;
70467         }
70468         function generateClassElementDecorationExpression(node, member) {
70469             var allDecorators = getAllDecoratorsOfClassElement(node, member);
70470             var decoratorExpressions = transformAllDecoratorsOfDeclaration(member, node, allDecorators);
70471             if (!decoratorExpressions) {
70472                 return undefined;
70473             }
70474             var prefix = getClassMemberPrefix(node, member);
70475             var memberName = getExpressionForPropertyName(member, true);
70476             var descriptor = languageVersion > 0
70477                 ? member.kind === 163
70478                     ? factory.createVoidZero()
70479                     : factory.createNull()
70480                 : undefined;
70481             var helper = emitHelpers().createDecorateHelper(decoratorExpressions, prefix, memberName, descriptor);
70482             ts.setTextRange(helper, ts.moveRangePastDecorators(member));
70483             ts.setEmitFlags(helper, 1536);
70484             return helper;
70485         }
70486         function addConstructorDecorationStatement(statements, node) {
70487             var expression = generateConstructorDecorationExpression(node);
70488             if (expression) {
70489                 statements.push(ts.setOriginalNode(factory.createExpressionStatement(expression), node));
70490             }
70491         }
70492         function generateConstructorDecorationExpression(node) {
70493             var allDecorators = getAllDecoratorsOfConstructor(node);
70494             var decoratorExpressions = transformAllDecoratorsOfDeclaration(node, node, allDecorators);
70495             if (!decoratorExpressions) {
70496                 return undefined;
70497             }
70498             var classAlias = classAliases && classAliases[ts.getOriginalNodeId(node)];
70499             var localName = factory.getLocalName(node, false, true);
70500             var decorate = emitHelpers().createDecorateHelper(decoratorExpressions, localName);
70501             var expression = factory.createAssignment(localName, classAlias ? factory.createAssignment(classAlias, decorate) : decorate);
70502             ts.setEmitFlags(expression, 1536);
70503             ts.setSourceMapRange(expression, ts.moveRangePastDecorators(node));
70504             return expression;
70505         }
70506         function transformDecorator(decorator) {
70507             return ts.visitNode(decorator.expression, visitor, ts.isExpression);
70508         }
70509         function transformDecoratorsOfParameter(decorators, parameterOffset) {
70510             var expressions;
70511             if (decorators) {
70512                 expressions = [];
70513                 for (var _i = 0, decorators_1 = decorators; _i < decorators_1.length; _i++) {
70514                     var decorator = decorators_1[_i];
70515                     var helper = emitHelpers().createParamHelper(transformDecorator(decorator), parameterOffset);
70516                     ts.setTextRange(helper, decorator.expression);
70517                     ts.setEmitFlags(helper, 1536);
70518                     expressions.push(helper);
70519                 }
70520             }
70521             return expressions;
70522         }
70523         function addTypeMetadata(node, container, decoratorExpressions) {
70524             if (USE_NEW_TYPE_METADATA_FORMAT) {
70525                 addNewTypeMetadata(node, container, decoratorExpressions);
70526             }
70527             else {
70528                 addOldTypeMetadata(node, container, decoratorExpressions);
70529             }
70530         }
70531         function addOldTypeMetadata(node, container, decoratorExpressions) {
70532             if (compilerOptions.emitDecoratorMetadata) {
70533                 if (shouldAddTypeMetadata(node)) {
70534                     decoratorExpressions.push(emitHelpers().createMetadataHelper("design:type", serializeTypeOfNode(node)));
70535                 }
70536                 if (shouldAddParamTypesMetadata(node)) {
70537                     decoratorExpressions.push(emitHelpers().createMetadataHelper("design:paramtypes", serializeParameterTypesOfNode(node, container)));
70538                 }
70539                 if (shouldAddReturnTypeMetadata(node)) {
70540                     decoratorExpressions.push(emitHelpers().createMetadataHelper("design:returntype", serializeReturnTypeOfNode(node)));
70541                 }
70542             }
70543         }
70544         function addNewTypeMetadata(node, container, decoratorExpressions) {
70545             if (compilerOptions.emitDecoratorMetadata) {
70546                 var properties = void 0;
70547                 if (shouldAddTypeMetadata(node)) {
70548                     (properties || (properties = [])).push(factory.createPropertyAssignment("type", factory.createArrowFunction(undefined, undefined, [], undefined, factory.createToken(38), serializeTypeOfNode(node))));
70549                 }
70550                 if (shouldAddParamTypesMetadata(node)) {
70551                     (properties || (properties = [])).push(factory.createPropertyAssignment("paramTypes", factory.createArrowFunction(undefined, undefined, [], undefined, factory.createToken(38), serializeParameterTypesOfNode(node, container))));
70552                 }
70553                 if (shouldAddReturnTypeMetadata(node)) {
70554                     (properties || (properties = [])).push(factory.createPropertyAssignment("returnType", factory.createArrowFunction(undefined, undefined, [], undefined, factory.createToken(38), serializeReturnTypeOfNode(node))));
70555                 }
70556                 if (properties) {
70557                     decoratorExpressions.push(emitHelpers().createMetadataHelper("design:typeinfo", factory.createObjectLiteralExpression(properties, true)));
70558                 }
70559             }
70560         }
70561         function shouldAddTypeMetadata(node) {
70562             var kind = node.kind;
70563             return kind === 165
70564                 || kind === 167
70565                 || kind === 168
70566                 || kind === 163;
70567         }
70568         function shouldAddReturnTypeMetadata(node) {
70569             return node.kind === 165;
70570         }
70571         function shouldAddParamTypesMetadata(node) {
70572             switch (node.kind) {
70573                 case 252:
70574                 case 221:
70575                     return ts.getFirstConstructorWithBody(node) !== undefined;
70576                 case 165:
70577                 case 167:
70578                 case 168:
70579                     return true;
70580             }
70581             return false;
70582         }
70583         function getAccessorTypeNode(node) {
70584             var accessors = resolver.getAllAccessorDeclarations(node);
70585             return accessors.setAccessor && ts.getSetAccessorTypeAnnotationNode(accessors.setAccessor)
70586                 || accessors.getAccessor && ts.getEffectiveReturnTypeNode(accessors.getAccessor);
70587         }
70588         function serializeTypeOfNode(node) {
70589             switch (node.kind) {
70590                 case 163:
70591                 case 160:
70592                     return serializeTypeNode(node.type);
70593                 case 168:
70594                 case 167:
70595                     return serializeTypeNode(getAccessorTypeNode(node));
70596                 case 252:
70597                 case 221:
70598                 case 165:
70599                     return factory.createIdentifier("Function");
70600                 default:
70601                     return factory.createVoidZero();
70602             }
70603         }
70604         function serializeParameterTypesOfNode(node, container) {
70605             var valueDeclaration = ts.isClassLike(node)
70606                 ? ts.getFirstConstructorWithBody(node)
70607                 : ts.isFunctionLike(node) && ts.nodeIsPresent(node.body)
70608                     ? node
70609                     : undefined;
70610             var expressions = [];
70611             if (valueDeclaration) {
70612                 var parameters = getParametersOfDecoratedDeclaration(valueDeclaration, container);
70613                 var numParameters = parameters.length;
70614                 for (var i = 0; i < numParameters; i++) {
70615                     var parameter = parameters[i];
70616                     if (i === 0 && ts.isIdentifier(parameter.name) && parameter.name.escapedText === "this") {
70617                         continue;
70618                     }
70619                     if (parameter.dotDotDotToken) {
70620                         expressions.push(serializeTypeNode(ts.getRestParameterElementType(parameter.type)));
70621                     }
70622                     else {
70623                         expressions.push(serializeTypeOfNode(parameter));
70624                     }
70625                 }
70626             }
70627             return factory.createArrayLiteralExpression(expressions);
70628         }
70629         function getParametersOfDecoratedDeclaration(node, container) {
70630             if (container && node.kind === 167) {
70631                 var setAccessor = ts.getAllAccessorDeclarations(container.members, node).setAccessor;
70632                 if (setAccessor) {
70633                     return setAccessor.parameters;
70634                 }
70635             }
70636             return node.parameters;
70637         }
70638         function serializeReturnTypeOfNode(node) {
70639             if (ts.isFunctionLike(node) && node.type) {
70640                 return serializeTypeNode(node.type);
70641             }
70642             else if (ts.isAsyncFunction(node)) {
70643                 return factory.createIdentifier("Promise");
70644             }
70645             return factory.createVoidZero();
70646         }
70647         function serializeTypeNode(node) {
70648             if (node === undefined) {
70649                 return factory.createIdentifier("Object");
70650             }
70651             switch (node.kind) {
70652                 case 113:
70653                 case 150:
70654                 case 141:
70655                     return factory.createVoidZero();
70656                 case 186:
70657                     return serializeTypeNode(node.type);
70658                 case 174:
70659                 case 175:
70660                     return factory.createIdentifier("Function");
70661                 case 178:
70662                 case 179:
70663                     return factory.createIdentifier("Array");
70664                 case 172:
70665                 case 131:
70666                     return factory.createIdentifier("Boolean");
70667                 case 147:
70668                     return factory.createIdentifier("String");
70669                 case 145:
70670                     return factory.createIdentifier("Object");
70671                 case 191:
70672                     switch (node.literal.kind) {
70673                         case 10:
70674                         case 14:
70675                             return factory.createIdentifier("String");
70676                         case 214:
70677                         case 8:
70678                             return factory.createIdentifier("Number");
70679                         case 9:
70680                             return getGlobalBigIntNameWithFallback();
70681                         case 109:
70682                         case 94:
70683                             return factory.createIdentifier("Boolean");
70684                         case 103:
70685                             return factory.createVoidZero();
70686                         default:
70687                             return ts.Debug.failBadSyntaxKind(node.literal);
70688                     }
70689                 case 144:
70690                     return factory.createIdentifier("Number");
70691                 case 155:
70692                     return getGlobalBigIntNameWithFallback();
70693                 case 148:
70694                     return languageVersion < 2
70695                         ? getGlobalSymbolNameWithFallback()
70696                         : factory.createIdentifier("Symbol");
70697                 case 173:
70698                     return serializeTypeReferenceNode(node);
70699                 case 183:
70700                 case 182:
70701                     return serializeTypeList(node.types);
70702                 case 184:
70703                     return serializeTypeList([node.trueType, node.falseType]);
70704                 case 188:
70705                     if (node.operator === 142) {
70706                         return serializeTypeNode(node.type);
70707                     }
70708                     break;
70709                 case 176:
70710                 case 189:
70711                 case 190:
70712                 case 177:
70713                 case 128:
70714                 case 152:
70715                 case 187:
70716                 case 195:
70717                     break;
70718                 case 303:
70719                 case 304:
70720                 case 308:
70721                 case 309:
70722                 case 310:
70723                     break;
70724                 case 305:
70725                 case 306:
70726                 case 307:
70727                     return serializeTypeNode(node.type);
70728                 default:
70729                     return ts.Debug.failBadSyntaxKind(node);
70730             }
70731             return factory.createIdentifier("Object");
70732         }
70733         function serializeTypeList(types) {
70734             var serializedUnion;
70735             for (var _i = 0, types_24 = types; _i < types_24.length; _i++) {
70736                 var typeNode = types_24[_i];
70737                 while (typeNode.kind === 186) {
70738                     typeNode = typeNode.type;
70739                 }
70740                 if (typeNode.kind === 141) {
70741                     continue;
70742                 }
70743                 if (!strictNullChecks && (typeNode.kind === 191 && typeNode.literal.kind === 103 || typeNode.kind === 150)) {
70744                     continue;
70745                 }
70746                 var serializedIndividual = serializeTypeNode(typeNode);
70747                 if (ts.isIdentifier(serializedIndividual) && serializedIndividual.escapedText === "Object") {
70748                     return serializedIndividual;
70749                 }
70750                 else if (serializedUnion) {
70751                     if (!ts.isIdentifier(serializedUnion) ||
70752                         !ts.isIdentifier(serializedIndividual) ||
70753                         serializedUnion.escapedText !== serializedIndividual.escapedText) {
70754                         return factory.createIdentifier("Object");
70755                     }
70756                 }
70757                 else {
70758                     serializedUnion = serializedIndividual;
70759                 }
70760             }
70761             return serializedUnion || factory.createVoidZero();
70762         }
70763         function serializeTypeReferenceNode(node) {
70764             var kind = resolver.getTypeReferenceSerializationKind(node.typeName, currentNameScope || currentLexicalScope);
70765             switch (kind) {
70766                 case ts.TypeReferenceSerializationKind.Unknown:
70767                     if (ts.findAncestor(node, function (n) { return n.parent && ts.isConditionalTypeNode(n.parent) && (n.parent.trueType === n || n.parent.falseType === n); })) {
70768                         return factory.createIdentifier("Object");
70769                     }
70770                     var serialized = serializeEntityNameAsExpressionFallback(node.typeName);
70771                     var temp = factory.createTempVariable(hoistVariableDeclaration);
70772                     return factory.createConditionalExpression(factory.createTypeCheck(factory.createAssignment(temp, serialized), "function"), undefined, temp, undefined, factory.createIdentifier("Object"));
70773                 case ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue:
70774                     return serializeEntityNameAsExpression(node.typeName);
70775                 case ts.TypeReferenceSerializationKind.VoidNullableOrNeverType:
70776                     return factory.createVoidZero();
70777                 case ts.TypeReferenceSerializationKind.BigIntLikeType:
70778                     return getGlobalBigIntNameWithFallback();
70779                 case ts.TypeReferenceSerializationKind.BooleanType:
70780                     return factory.createIdentifier("Boolean");
70781                 case ts.TypeReferenceSerializationKind.NumberLikeType:
70782                     return factory.createIdentifier("Number");
70783                 case ts.TypeReferenceSerializationKind.StringLikeType:
70784                     return factory.createIdentifier("String");
70785                 case ts.TypeReferenceSerializationKind.ArrayLikeType:
70786                     return factory.createIdentifier("Array");
70787                 case ts.TypeReferenceSerializationKind.ESSymbolType:
70788                     return languageVersion < 2
70789                         ? getGlobalSymbolNameWithFallback()
70790                         : factory.createIdentifier("Symbol");
70791                 case ts.TypeReferenceSerializationKind.TypeWithCallSignature:
70792                     return factory.createIdentifier("Function");
70793                 case ts.TypeReferenceSerializationKind.Promise:
70794                     return factory.createIdentifier("Promise");
70795                 case ts.TypeReferenceSerializationKind.ObjectType:
70796                     return factory.createIdentifier("Object");
70797                 default:
70798                     return ts.Debug.assertNever(kind);
70799             }
70800         }
70801         function createCheckedValue(left, right) {
70802             return factory.createLogicalAnd(factory.createStrictInequality(factory.createTypeOfExpression(left), factory.createStringLiteral("undefined")), right);
70803         }
70804         function serializeEntityNameAsExpressionFallback(node) {
70805             if (node.kind === 78) {
70806                 var copied = serializeEntityNameAsExpression(node);
70807                 return createCheckedValue(copied, copied);
70808             }
70809             if (node.left.kind === 78) {
70810                 return createCheckedValue(serializeEntityNameAsExpression(node.left), serializeEntityNameAsExpression(node));
70811             }
70812             var left = serializeEntityNameAsExpressionFallback(node.left);
70813             var temp = factory.createTempVariable(hoistVariableDeclaration);
70814             return factory.createLogicalAnd(factory.createLogicalAnd(left.left, factory.createStrictInequality(factory.createAssignment(temp, left.right), factory.createVoidZero())), factory.createPropertyAccessExpression(temp, node.right));
70815         }
70816         function serializeEntityNameAsExpression(node) {
70817             switch (node.kind) {
70818                 case 78:
70819                     var name = ts.setParent(ts.setTextRange(ts.parseNodeFactory.cloneNode(node), node), node.parent);
70820                     name.original = undefined;
70821                     ts.setParent(name, ts.getParseTreeNode(currentLexicalScope));
70822                     return name;
70823                 case 157:
70824                     return serializeQualifiedNameAsExpression(node);
70825             }
70826         }
70827         function serializeQualifiedNameAsExpression(node) {
70828             return factory.createPropertyAccessExpression(serializeEntityNameAsExpression(node.left), node.right);
70829         }
70830         function getGlobalSymbolNameWithFallback() {
70831             return factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("Symbol"), "function"), undefined, factory.createIdentifier("Symbol"), undefined, factory.createIdentifier("Object"));
70832         }
70833         function getGlobalBigIntNameWithFallback() {
70834             return languageVersion < 99
70835                 ? factory.createConditionalExpression(factory.createTypeCheck(factory.createIdentifier("BigInt"), "function"), undefined, factory.createIdentifier("BigInt"), undefined, factory.createIdentifier("Object"))
70836                 : factory.createIdentifier("BigInt");
70837         }
70838         function getExpressionForPropertyName(member, generateNameForComputedPropertyName) {
70839             var name = member.name;
70840             if (ts.isPrivateIdentifier(name)) {
70841                 return factory.createIdentifier("");
70842             }
70843             else if (ts.isComputedPropertyName(name)) {
70844                 return generateNameForComputedPropertyName && !ts.isSimpleInlineableExpression(name.expression)
70845                     ? factory.getGeneratedNameForNode(name)
70846                     : name.expression;
70847             }
70848             else if (ts.isIdentifier(name)) {
70849                 return factory.createStringLiteral(ts.idText(name));
70850             }
70851             else {
70852                 return factory.cloneNode(name);
70853             }
70854         }
70855         function visitPropertyNameOfClassElement(member) {
70856             var name = member.name;
70857             if (ts.isComputedPropertyName(name) && ((!ts.hasStaticModifier(member) && currentClassHasParameterProperties) || ts.some(member.decorators))) {
70858                 var expression = ts.visitNode(name.expression, visitor, ts.isExpression);
70859                 var innerExpression = ts.skipPartiallyEmittedExpressions(expression);
70860                 if (!ts.isSimpleInlineableExpression(innerExpression)) {
70861                     var generatedName = factory.getGeneratedNameForNode(name);
70862                     hoistVariableDeclaration(generatedName);
70863                     return factory.updateComputedPropertyName(name, factory.createAssignment(generatedName, expression));
70864                 }
70865             }
70866             return ts.visitNode(name, visitor, ts.isPropertyName);
70867         }
70868         function visitHeritageClause(node) {
70869             if (node.token === 116) {
70870                 return undefined;
70871             }
70872             return ts.visitEachChild(node, visitor, context);
70873         }
70874         function visitExpressionWithTypeArguments(node) {
70875             return factory.updateExpressionWithTypeArguments(node, ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression), undefined);
70876         }
70877         function shouldEmitFunctionLikeDeclaration(node) {
70878             return !ts.nodeIsMissing(node.body);
70879         }
70880         function visitPropertyDeclaration(node) {
70881             if (node.flags & 8388608 || ts.hasSyntacticModifier(node, 128)) {
70882                 return undefined;
70883             }
70884             var updated = factory.updatePropertyDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), undefined, undefined, ts.visitNode(node.initializer, visitor));
70885             if (updated !== node) {
70886                 ts.setCommentRange(updated, node);
70887                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
70888             }
70889             return updated;
70890         }
70891         function visitConstructor(node) {
70892             if (!shouldEmitFunctionLikeDeclaration(node)) {
70893                 return undefined;
70894             }
70895             return factory.updateConstructorDeclaration(node, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node));
70896         }
70897         function transformConstructorBody(body, constructor) {
70898             var parametersWithPropertyAssignments = constructor &&
70899                 ts.filter(constructor.parameters, function (p) { return ts.isParameterPropertyDeclaration(p, constructor); });
70900             if (!ts.some(parametersWithPropertyAssignments)) {
70901                 return ts.visitFunctionBody(body, visitor, context);
70902             }
70903             var statements = [];
70904             var indexOfFirstStatement = 0;
70905             resumeLexicalEnvironment();
70906             indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(factory, constructor, statements, visitor);
70907             ts.addRange(statements, ts.map(parametersWithPropertyAssignments, transformParameterWithPropertyAssignment));
70908             ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexOfFirstStatement));
70909             statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
70910             var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), true);
70911             ts.setTextRange(block, body);
70912             ts.setOriginalNode(block, body);
70913             return block;
70914         }
70915         function transformParameterWithPropertyAssignment(node) {
70916             var name = node.name;
70917             if (!ts.isIdentifier(name)) {
70918                 return undefined;
70919             }
70920             var propertyName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent);
70921             ts.setEmitFlags(propertyName, 1536 | 48);
70922             var localName = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent);
70923             ts.setEmitFlags(localName, 1536);
70924             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))));
70925         }
70926         function visitMethodDeclaration(node) {
70927             if (!shouldEmitFunctionLikeDeclaration(node)) {
70928                 return undefined;
70929             }
70930             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));
70931             if (updated !== node) {
70932                 ts.setCommentRange(updated, node);
70933                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
70934             }
70935             return updated;
70936         }
70937         function shouldEmitAccessorDeclaration(node) {
70938             return !(ts.nodeIsMissing(node.body) && ts.hasSyntacticModifier(node, 128));
70939         }
70940         function visitGetAccessor(node) {
70941             if (!shouldEmitAccessorDeclaration(node)) {
70942                 return undefined;
70943             }
70944             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([]));
70945             if (updated !== node) {
70946                 ts.setCommentRange(updated, node);
70947                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
70948             }
70949             return updated;
70950         }
70951         function visitSetAccessor(node) {
70952             if (!shouldEmitAccessorDeclaration(node)) {
70953                 return undefined;
70954             }
70955             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([]));
70956             if (updated !== node) {
70957                 ts.setCommentRange(updated, node);
70958                 ts.setSourceMapRange(updated, ts.moveRangePastDecorators(node));
70959             }
70960             return updated;
70961         }
70962         function visitFunctionDeclaration(node) {
70963             if (!shouldEmitFunctionLikeDeclaration(node)) {
70964                 return factory.createNotEmittedStatement(node);
70965             }
70966             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([]));
70967             if (isExportOfNamespace(node)) {
70968                 var statements = [updated];
70969                 addExportMemberAssignment(statements, node);
70970                 return statements;
70971             }
70972             return updated;
70973         }
70974         function visitFunctionExpression(node) {
70975             if (!shouldEmitFunctionLikeDeclaration(node)) {
70976                 return factory.createOmittedExpression();
70977             }
70978             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([]));
70979             return updated;
70980         }
70981         function visitArrowFunction(node) {
70982             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));
70983             return updated;
70984         }
70985         function visitParameter(node) {
70986             if (ts.parameterIsThisKeyword(node)) {
70987                 return undefined;
70988             }
70989             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));
70990             if (updated !== node) {
70991                 ts.setCommentRange(updated, node);
70992                 ts.setTextRange(updated, ts.moveRangePastModifiers(node));
70993                 ts.setSourceMapRange(updated, ts.moveRangePastModifiers(node));
70994                 ts.setEmitFlags(updated.name, 32);
70995             }
70996             return updated;
70997         }
70998         function visitVariableStatement(node) {
70999             if (isExportOfNamespace(node)) {
71000                 var variables = ts.getInitializedVariables(node.declarationList);
71001                 if (variables.length === 0) {
71002                     return undefined;
71003                 }
71004                 return ts.setTextRange(factory.createExpressionStatement(factory.inlineExpressions(ts.map(variables, transformInitializedVariable))), node);
71005             }
71006             else {
71007                 return ts.visitEachChild(node, visitor, context);
71008             }
71009         }
71010         function transformInitializedVariable(node) {
71011             var name = node.name;
71012             if (ts.isBindingPattern(name)) {
71013                 return ts.flattenDestructuringAssignment(node, visitor, context, 0, false, createNamespaceExportExpression);
71014             }
71015             else {
71016                 return ts.setTextRange(factory.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(name), ts.visitNode(node.initializer, visitor, ts.isExpression)), node);
71017             }
71018         }
71019         function visitVariableDeclaration(node) {
71020             return factory.updateVariableDeclaration(node, ts.visitNode(node.name, visitor, ts.isBindingName), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
71021         }
71022         function visitParenthesizedExpression(node) {
71023             var innerExpression = ts.skipOuterExpressions(node.expression, ~6);
71024             if (ts.isAssertionExpression(innerExpression)) {
71025                 var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
71026                 if (ts.length(ts.getLeadingCommentRangesOfNode(expression, currentSourceFile))) {
71027                     return factory.updateParenthesizedExpression(node, expression);
71028                 }
71029                 return factory.createPartiallyEmittedExpression(expression, node);
71030             }
71031             return ts.visitEachChild(node, visitor, context);
71032         }
71033         function visitAssertionExpression(node) {
71034             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
71035             return factory.createPartiallyEmittedExpression(expression, node);
71036         }
71037         function visitNonNullExpression(node) {
71038             var expression = ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression);
71039             return factory.createPartiallyEmittedExpression(expression, node);
71040         }
71041         function visitCallExpression(node) {
71042             return factory.updateCallExpression(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression));
71043         }
71044         function visitNewExpression(node) {
71045             return factory.updateNewExpression(node, ts.visitNode(node.expression, visitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression));
71046         }
71047         function visitTaggedTemplateExpression(node) {
71048             return factory.updateTaggedTemplateExpression(node, ts.visitNode(node.tag, visitor, ts.isExpression), undefined, ts.visitNode(node.template, visitor, ts.isExpression));
71049         }
71050         function visitJsxSelfClosingElement(node) {
71051             return factory.updateJsxSelfClosingElement(node, ts.visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), undefined, ts.visitNode(node.attributes, visitor, ts.isJsxAttributes));
71052         }
71053         function visitJsxJsxOpeningElement(node) {
71054             return factory.updateJsxOpeningElement(node, ts.visitNode(node.tagName, visitor, ts.isJsxTagNameExpression), undefined, ts.visitNode(node.attributes, visitor, ts.isJsxAttributes));
71055         }
71056         function shouldEmitEnumDeclaration(node) {
71057             return !ts.isEnumConst(node)
71058                 || ts.shouldPreserveConstEnums(compilerOptions);
71059         }
71060         function visitEnumDeclaration(node) {
71061             if (!shouldEmitEnumDeclaration(node)) {
71062                 return factory.createNotEmittedStatement(node);
71063             }
71064             var statements = [];
71065             var emitFlags = 2;
71066             var varAdded = addVarForEnumOrModuleDeclaration(statements, node);
71067             if (varAdded) {
71068                 if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) {
71069                     emitFlags |= 512;
71070                 }
71071             }
71072             var parameterName = getNamespaceParameterName(node);
71073             var containerName = getNamespaceContainerName(node);
71074             var exportName = ts.hasSyntacticModifier(node, 1)
71075                 ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true)
71076                 : factory.getLocalName(node, false, true);
71077             var moduleArg = factory.createLogicalOr(exportName, factory.createAssignment(exportName, factory.createObjectLiteralExpression()));
71078             if (hasNamespaceQualifiedExportName(node)) {
71079                 var localName = factory.getLocalName(node, false, true);
71080                 moduleArg = factory.createAssignment(localName, moduleArg);
71081             }
71082             var enumStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, parameterName)], undefined, transformEnumBody(node, containerName)), undefined, [moduleArg]));
71083             ts.setOriginalNode(enumStatement, node);
71084             if (varAdded) {
71085                 ts.setSyntheticLeadingComments(enumStatement, undefined);
71086                 ts.setSyntheticTrailingComments(enumStatement, undefined);
71087             }
71088             ts.setTextRange(enumStatement, node);
71089             ts.addEmitFlags(enumStatement, emitFlags);
71090             statements.push(enumStatement);
71091             statements.push(factory.createEndOfDeclarationMarker(node));
71092             return statements;
71093         }
71094         function transformEnumBody(node, localName) {
71095             var savedCurrentNamespaceLocalName = currentNamespaceContainerName;
71096             currentNamespaceContainerName = localName;
71097             var statements = [];
71098             startLexicalEnvironment();
71099             var members = ts.map(node.members, transformEnumMember);
71100             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
71101             ts.addRange(statements, members);
71102             currentNamespaceContainerName = savedCurrentNamespaceLocalName;
71103             return factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), node.members), true);
71104         }
71105         function transformEnumMember(member) {
71106             var name = getExpressionForPropertyName(member, false);
71107             var valueExpression = transformEnumMemberDeclarationValue(member);
71108             var innerAssignment = factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, name), valueExpression);
71109             var outerAssignment = valueExpression.kind === 10 ?
71110                 innerAssignment :
71111                 factory.createAssignment(factory.createElementAccessExpression(currentNamespaceContainerName, innerAssignment), name);
71112             return ts.setTextRange(factory.createExpressionStatement(ts.setTextRange(outerAssignment, member)), member);
71113         }
71114         function transformEnumMemberDeclarationValue(member) {
71115             var value = resolver.getConstantValue(member);
71116             if (value !== undefined) {
71117                 return typeof value === "string" ? factory.createStringLiteral(value) : factory.createNumericLiteral(value);
71118             }
71119             else {
71120                 enableSubstitutionForNonQualifiedEnumMembers();
71121                 if (member.initializer) {
71122                     return ts.visitNode(member.initializer, visitor, ts.isExpression);
71123                 }
71124                 else {
71125                     return factory.createVoidZero();
71126                 }
71127             }
71128         }
71129         function shouldEmitModuleDeclaration(nodeIn) {
71130             var node = ts.getParseTreeNode(nodeIn, ts.isModuleDeclaration);
71131             if (!node) {
71132                 return true;
71133             }
71134             return ts.isInstantiatedModule(node, ts.shouldPreserveConstEnums(compilerOptions));
71135         }
71136         function hasNamespaceQualifiedExportName(node) {
71137             return isExportOfNamespace(node)
71138                 || (isExternalModuleExport(node)
71139                     && moduleKind !== ts.ModuleKind.ES2015
71140                     && moduleKind !== ts.ModuleKind.ES2020
71141                     && moduleKind !== ts.ModuleKind.ESNext
71142                     && moduleKind !== ts.ModuleKind.System);
71143         }
71144         function recordEmittedDeclarationInScope(node) {
71145             if (!currentScopeFirstDeclarationsOfName) {
71146                 currentScopeFirstDeclarationsOfName = new ts.Map();
71147             }
71148             var name = declaredNameInScope(node);
71149             if (!currentScopeFirstDeclarationsOfName.has(name)) {
71150                 currentScopeFirstDeclarationsOfName.set(name, node);
71151             }
71152         }
71153         function isFirstEmittedDeclarationInScope(node) {
71154             if (currentScopeFirstDeclarationsOfName) {
71155                 var name = declaredNameInScope(node);
71156                 return currentScopeFirstDeclarationsOfName.get(name) === node;
71157             }
71158             return true;
71159         }
71160         function declaredNameInScope(node) {
71161             ts.Debug.assertNode(node.name, ts.isIdentifier);
71162             return node.name.escapedText;
71163         }
71164         function addVarForEnumOrModuleDeclaration(statements, node) {
71165             var statement = factory.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.createVariableDeclarationList([
71166                 factory.createVariableDeclaration(factory.getLocalName(node, false, true))
71167             ], currentLexicalScope.kind === 297 ? 0 : 1));
71168             ts.setOriginalNode(statement, node);
71169             recordEmittedDeclarationInScope(node);
71170             if (isFirstEmittedDeclarationInScope(node)) {
71171                 if (node.kind === 255) {
71172                     ts.setSourceMapRange(statement.declarationList, node);
71173                 }
71174                 else {
71175                     ts.setSourceMapRange(statement, node);
71176                 }
71177                 ts.setCommentRange(statement, node);
71178                 ts.addEmitFlags(statement, 1024 | 4194304);
71179                 statements.push(statement);
71180                 return true;
71181             }
71182             else {
71183                 var mergeMarker = factory.createMergeDeclarationMarker(statement);
71184                 ts.setEmitFlags(mergeMarker, 1536 | 4194304);
71185                 statements.push(mergeMarker);
71186                 return false;
71187             }
71188         }
71189         function visitModuleDeclaration(node) {
71190             if (!shouldEmitModuleDeclaration(node)) {
71191                 return factory.createNotEmittedStatement(node);
71192             }
71193             ts.Debug.assertNode(node.name, ts.isIdentifier, "A TypeScript namespace should have an Identifier name.");
71194             enableSubstitutionForNamespaceExports();
71195             var statements = [];
71196             var emitFlags = 2;
71197             var varAdded = addVarForEnumOrModuleDeclaration(statements, node);
71198             if (varAdded) {
71199                 if (moduleKind !== ts.ModuleKind.System || currentLexicalScope !== currentSourceFile) {
71200                     emitFlags |= 512;
71201                 }
71202             }
71203             var parameterName = getNamespaceParameterName(node);
71204             var containerName = getNamespaceContainerName(node);
71205             var exportName = ts.hasSyntacticModifier(node, 1)
71206                 ? factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true)
71207                 : factory.getLocalName(node, false, true);
71208             var moduleArg = factory.createLogicalOr(exportName, factory.createAssignment(exportName, factory.createObjectLiteralExpression()));
71209             if (hasNamespaceQualifiedExportName(node)) {
71210                 var localName = factory.getLocalName(node, false, true);
71211                 moduleArg = factory.createAssignment(localName, moduleArg);
71212             }
71213             var moduleStatement = factory.createExpressionStatement(factory.createCallExpression(factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, parameterName)], undefined, transformModuleBody(node, containerName)), undefined, [moduleArg]));
71214             ts.setOriginalNode(moduleStatement, node);
71215             if (varAdded) {
71216                 ts.setSyntheticLeadingComments(moduleStatement, undefined);
71217                 ts.setSyntheticTrailingComments(moduleStatement, undefined);
71218             }
71219             ts.setTextRange(moduleStatement, node);
71220             ts.addEmitFlags(moduleStatement, emitFlags);
71221             statements.push(moduleStatement);
71222             statements.push(factory.createEndOfDeclarationMarker(node));
71223             return statements;
71224         }
71225         function transformModuleBody(node, namespaceLocalName) {
71226             var savedCurrentNamespaceContainerName = currentNamespaceContainerName;
71227             var savedCurrentNamespace = currentNamespace;
71228             var savedCurrentScopeFirstDeclarationsOfName = currentScopeFirstDeclarationsOfName;
71229             currentNamespaceContainerName = namespaceLocalName;
71230             currentNamespace = node;
71231             currentScopeFirstDeclarationsOfName = undefined;
71232             var statements = [];
71233             startLexicalEnvironment();
71234             var statementsLocation;
71235             var blockLocation;
71236             if (node.body) {
71237                 if (node.body.kind === 257) {
71238                     saveStateAndInvoke(node.body, function (body) { return ts.addRange(statements, ts.visitNodes(body.statements, namespaceElementVisitor, ts.isStatement)); });
71239                     statementsLocation = node.body.statements;
71240                     blockLocation = node.body;
71241                 }
71242                 else {
71243                     var result = visitModuleDeclaration(node.body);
71244                     if (result) {
71245                         if (ts.isArray(result)) {
71246                             ts.addRange(statements, result);
71247                         }
71248                         else {
71249                             statements.push(result);
71250                         }
71251                     }
71252                     var moduleBlock = getInnerMostModuleDeclarationFromDottedModule(node).body;
71253                     statementsLocation = ts.moveRangePos(moduleBlock.statements, -1);
71254                 }
71255             }
71256             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
71257             currentNamespaceContainerName = savedCurrentNamespaceContainerName;
71258             currentNamespace = savedCurrentNamespace;
71259             currentScopeFirstDeclarationsOfName = savedCurrentScopeFirstDeclarationsOfName;
71260             var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), true);
71261             ts.setTextRange(block, blockLocation);
71262             if (!node.body || node.body.kind !== 257) {
71263                 ts.setEmitFlags(block, ts.getEmitFlags(block) | 1536);
71264             }
71265             return block;
71266         }
71267         function getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration) {
71268             if (moduleDeclaration.body.kind === 256) {
71269                 var recursiveInnerModule = getInnerMostModuleDeclarationFromDottedModule(moduleDeclaration.body);
71270                 return recursiveInnerModule || moduleDeclaration.body;
71271             }
71272         }
71273         function visitImportDeclaration(node) {
71274             if (!node.importClause) {
71275                 return node;
71276             }
71277             if (node.importClause.isTypeOnly) {
71278                 return undefined;
71279             }
71280             var importClause = ts.visitNode(node.importClause, visitImportClause, ts.isImportClause);
71281             return importClause ||
71282                 compilerOptions.importsNotUsedAsValues === 1 ||
71283                 compilerOptions.importsNotUsedAsValues === 2
71284                 ? factory.updateImportDeclaration(node, undefined, undefined, importClause, node.moduleSpecifier)
71285                 : undefined;
71286         }
71287         function visitImportClause(node) {
71288             if (node.isTypeOnly) {
71289                 return undefined;
71290             }
71291             var name = resolver.isReferencedAliasDeclaration(node) ? node.name : undefined;
71292             var namedBindings = ts.visitNode(node.namedBindings, visitNamedImportBindings, ts.isNamedImportBindings);
71293             return (name || namedBindings) ? factory.updateImportClause(node, false, name, namedBindings) : undefined;
71294         }
71295         function visitNamedImportBindings(node) {
71296             if (node.kind === 263) {
71297                 return resolver.isReferencedAliasDeclaration(node) ? node : undefined;
71298             }
71299             else {
71300                 var elements = ts.visitNodes(node.elements, visitImportSpecifier, ts.isImportSpecifier);
71301                 return ts.some(elements) ? factory.updateNamedImports(node, elements) : undefined;
71302             }
71303         }
71304         function visitImportSpecifier(node) {
71305             return resolver.isReferencedAliasDeclaration(node) ? node : undefined;
71306         }
71307         function visitExportAssignment(node) {
71308             return resolver.isValueAliasDeclaration(node)
71309                 ? ts.visitEachChild(node, visitor, context)
71310                 : undefined;
71311         }
71312         function visitExportDeclaration(node) {
71313             if (node.isTypeOnly) {
71314                 return undefined;
71315             }
71316             if (!node.exportClause || ts.isNamespaceExport(node.exportClause)) {
71317                 return node;
71318             }
71319             if (!resolver.isValueAliasDeclaration(node)) {
71320                 return undefined;
71321             }
71322             var exportClause = ts.visitNode(node.exportClause, visitNamedExportBindings, ts.isNamedExportBindings);
71323             return exportClause
71324                 ? factory.updateExportDeclaration(node, undefined, undefined, node.isTypeOnly, exportClause, node.moduleSpecifier)
71325                 : undefined;
71326         }
71327         function visitNamedExports(node) {
71328             var elements = ts.visitNodes(node.elements, visitExportSpecifier, ts.isExportSpecifier);
71329             return ts.some(elements) ? factory.updateNamedExports(node, elements) : undefined;
71330         }
71331         function visitNamespaceExports(node) {
71332             return factory.updateNamespaceExport(node, ts.visitNode(node.name, visitor, ts.isIdentifier));
71333         }
71334         function visitNamedExportBindings(node) {
71335             return ts.isNamespaceExport(node) ? visitNamespaceExports(node) : visitNamedExports(node);
71336         }
71337         function visitExportSpecifier(node) {
71338             return resolver.isValueAliasDeclaration(node) ? node : undefined;
71339         }
71340         function shouldEmitImportEqualsDeclaration(node) {
71341             return resolver.isReferencedAliasDeclaration(node)
71342                 || (!ts.isExternalModule(currentSourceFile)
71343                     && resolver.isTopLevelValueImportEqualsWithEntityName(node));
71344         }
71345         function visitImportEqualsDeclaration(node) {
71346             if (node.isTypeOnly) {
71347                 return undefined;
71348             }
71349             if (ts.isExternalModuleImportEqualsDeclaration(node)) {
71350                 var isReferenced = resolver.isReferencedAliasDeclaration(node);
71351                 if (!isReferenced && compilerOptions.importsNotUsedAsValues === 1) {
71352                     return ts.setOriginalNode(ts.setTextRange(factory.createImportDeclaration(undefined, undefined, undefined, node.moduleReference.expression), node), node);
71353                 }
71354                 return isReferenced ? ts.visitEachChild(node, visitor, context) : undefined;
71355             }
71356             if (!shouldEmitImportEqualsDeclaration(node)) {
71357                 return undefined;
71358             }
71359             var moduleReference = ts.createExpressionFromEntityName(factory, node.moduleReference);
71360             ts.setEmitFlags(moduleReference, 1536 | 2048);
71361             if (isNamedExternalModuleExport(node) || !isExportOfNamespace(node)) {
71362                 return ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement(ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier), factory.createVariableDeclarationList([
71363                     ts.setOriginalNode(factory.createVariableDeclaration(node.name, undefined, undefined, moduleReference), node)
71364                 ])), node), node);
71365             }
71366             else {
71367                 return ts.setOriginalNode(createNamespaceExport(node.name, moduleReference, node), node);
71368             }
71369         }
71370         function isExportOfNamespace(node) {
71371             return currentNamespace !== undefined && ts.hasSyntacticModifier(node, 1);
71372         }
71373         function isExternalModuleExport(node) {
71374             return currentNamespace === undefined && ts.hasSyntacticModifier(node, 1);
71375         }
71376         function isNamedExternalModuleExport(node) {
71377             return isExternalModuleExport(node)
71378                 && !ts.hasSyntacticModifier(node, 512);
71379         }
71380         function isDefaultExternalModuleExport(node) {
71381             return isExternalModuleExport(node)
71382                 && ts.hasSyntacticModifier(node, 512);
71383         }
71384         function expressionToStatement(expression) {
71385             return factory.createExpressionStatement(expression);
71386         }
71387         function addExportMemberAssignment(statements, node) {
71388             var expression = factory.createAssignment(factory.getExternalModuleOrNamespaceExportName(currentNamespaceContainerName, node, false, true), factory.getLocalName(node));
71389             ts.setSourceMapRange(expression, ts.createRange(node.name ? node.name.pos : node.pos, node.end));
71390             var statement = factory.createExpressionStatement(expression);
71391             ts.setSourceMapRange(statement, ts.createRange(-1, node.end));
71392             statements.push(statement);
71393         }
71394         function createNamespaceExport(exportName, exportValue, location) {
71395             return ts.setTextRange(factory.createExpressionStatement(factory.createAssignment(factory.getNamespaceMemberName(currentNamespaceContainerName, exportName, false, true), exportValue)), location);
71396         }
71397         function createNamespaceExportExpression(exportName, exportValue, location) {
71398             return ts.setTextRange(factory.createAssignment(getNamespaceMemberNameWithSourceMapsAndWithoutComments(exportName), exportValue), location);
71399         }
71400         function getNamespaceMemberNameWithSourceMapsAndWithoutComments(name) {
71401             return factory.getNamespaceMemberName(currentNamespaceContainerName, name, false, true);
71402         }
71403         function getNamespaceParameterName(node) {
71404             var name = factory.getGeneratedNameForNode(node);
71405             ts.setSourceMapRange(name, node.name);
71406             return name;
71407         }
71408         function getNamespaceContainerName(node) {
71409             return factory.getGeneratedNameForNode(node);
71410         }
71411         function getClassAliasIfNeeded(node) {
71412             if (resolver.getNodeCheckFlags(node) & 16777216) {
71413                 enableSubstitutionForClassAliases();
71414                 var classAlias = factory.createUniqueName(node.name && !ts.isGeneratedIdentifier(node.name) ? ts.idText(node.name) : "default");
71415                 classAliases[ts.getOriginalNodeId(node)] = classAlias;
71416                 hoistVariableDeclaration(classAlias);
71417                 return classAlias;
71418             }
71419         }
71420         function getClassPrototype(node) {
71421             return factory.createPropertyAccessExpression(factory.getDeclarationName(node), "prototype");
71422         }
71423         function getClassMemberPrefix(node, member) {
71424             return ts.hasSyntacticModifier(member, 32)
71425                 ? factory.getDeclarationName(node)
71426                 : getClassPrototype(node);
71427         }
71428         function enableSubstitutionForNonQualifiedEnumMembers() {
71429             if ((enabledSubstitutions & 8) === 0) {
71430                 enabledSubstitutions |= 8;
71431                 context.enableSubstitution(78);
71432             }
71433         }
71434         function enableSubstitutionForClassAliases() {
71435             if ((enabledSubstitutions & 1) === 0) {
71436                 enabledSubstitutions |= 1;
71437                 context.enableSubstitution(78);
71438                 classAliases = [];
71439             }
71440         }
71441         function enableSubstitutionForNamespaceExports() {
71442             if ((enabledSubstitutions & 2) === 0) {
71443                 enabledSubstitutions |= 2;
71444                 context.enableSubstitution(78);
71445                 context.enableSubstitution(289);
71446                 context.enableEmitNotification(256);
71447             }
71448         }
71449         function isTransformedModuleDeclaration(node) {
71450             return ts.getOriginalNode(node).kind === 256;
71451         }
71452         function isTransformedEnumDeclaration(node) {
71453             return ts.getOriginalNode(node).kind === 255;
71454         }
71455         function onEmitNode(hint, node, emitCallback) {
71456             var savedApplicableSubstitutions = applicableSubstitutions;
71457             var savedCurrentSourceFile = currentSourceFile;
71458             if (ts.isSourceFile(node)) {
71459                 currentSourceFile = node;
71460             }
71461             if (enabledSubstitutions & 2 && isTransformedModuleDeclaration(node)) {
71462                 applicableSubstitutions |= 2;
71463             }
71464             if (enabledSubstitutions & 8 && isTransformedEnumDeclaration(node)) {
71465                 applicableSubstitutions |= 8;
71466             }
71467             previousOnEmitNode(hint, node, emitCallback);
71468             applicableSubstitutions = savedApplicableSubstitutions;
71469             currentSourceFile = savedCurrentSourceFile;
71470         }
71471         function onSubstituteNode(hint, node) {
71472             node = previousOnSubstituteNode(hint, node);
71473             if (hint === 1) {
71474                 return substituteExpression(node);
71475             }
71476             else if (ts.isShorthandPropertyAssignment(node)) {
71477                 return substituteShorthandPropertyAssignment(node);
71478             }
71479             return node;
71480         }
71481         function substituteShorthandPropertyAssignment(node) {
71482             if (enabledSubstitutions & 2) {
71483                 var name = node.name;
71484                 var exportedName = trySubstituteNamespaceExportedName(name);
71485                 if (exportedName) {
71486                     if (node.objectAssignmentInitializer) {
71487                         var initializer = factory.createAssignment(exportedName, node.objectAssignmentInitializer);
71488                         return ts.setTextRange(factory.createPropertyAssignment(name, initializer), node);
71489                     }
71490                     return ts.setTextRange(factory.createPropertyAssignment(name, exportedName), node);
71491                 }
71492             }
71493             return node;
71494         }
71495         function substituteExpression(node) {
71496             switch (node.kind) {
71497                 case 78:
71498                     return substituteExpressionIdentifier(node);
71499                 case 201:
71500                     return substitutePropertyAccessExpression(node);
71501                 case 202:
71502                     return substituteElementAccessExpression(node);
71503             }
71504             return node;
71505         }
71506         function substituteExpressionIdentifier(node) {
71507             return trySubstituteClassAlias(node)
71508                 || trySubstituteNamespaceExportedName(node)
71509                 || node;
71510         }
71511         function trySubstituteClassAlias(node) {
71512             if (enabledSubstitutions & 1) {
71513                 if (resolver.getNodeCheckFlags(node) & 33554432) {
71514                     var declaration = resolver.getReferencedValueDeclaration(node);
71515                     if (declaration) {
71516                         var classAlias = classAliases[declaration.id];
71517                         if (classAlias) {
71518                             var clone_1 = factory.cloneNode(classAlias);
71519                             ts.setSourceMapRange(clone_1, node);
71520                             ts.setCommentRange(clone_1, node);
71521                             return clone_1;
71522                         }
71523                     }
71524                 }
71525             }
71526             return undefined;
71527         }
71528         function trySubstituteNamespaceExportedName(node) {
71529             if (enabledSubstitutions & applicableSubstitutions && !ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
71530                 var container = resolver.getReferencedExportContainer(node, false);
71531                 if (container && container.kind !== 297) {
71532                     var substitute = (applicableSubstitutions & 2 && container.kind === 256) ||
71533                         (applicableSubstitutions & 8 && container.kind === 255);
71534                     if (substitute) {
71535                         return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(container), node), node);
71536                     }
71537                 }
71538             }
71539             return undefined;
71540         }
71541         function substitutePropertyAccessExpression(node) {
71542             return substituteConstantValue(node);
71543         }
71544         function substituteElementAccessExpression(node) {
71545             return substituteConstantValue(node);
71546         }
71547         function substituteConstantValue(node) {
71548             var constantValue = tryGetConstEnumValue(node);
71549             if (constantValue !== undefined) {
71550                 ts.setConstantValue(node, constantValue);
71551                 var substitute = typeof constantValue === "string" ? factory.createStringLiteral(constantValue) : factory.createNumericLiteral(constantValue);
71552                 if (!compilerOptions.removeComments) {
71553                     var originalNode = ts.getOriginalNode(node, ts.isAccessExpression);
71554                     var propertyName = ts.isPropertyAccessExpression(originalNode)
71555                         ? ts.declarationNameToString(originalNode.name)
71556                         : ts.getTextOfNode(originalNode.argumentExpression);
71557                     ts.addSyntheticTrailingComment(substitute, 3, " " + propertyName + " ");
71558                 }
71559                 return substitute;
71560             }
71561             return node;
71562         }
71563         function tryGetConstEnumValue(node) {
71564             if (compilerOptions.isolatedModules) {
71565                 return undefined;
71566             }
71567             return ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node) ? resolver.getConstantValue(node) : undefined;
71568         }
71569     }
71570     ts.transformTypeScript = transformTypeScript;
71571 })(ts || (ts = {}));
71572 var ts;
71573 (function (ts) {
71574     function transformClassFields(context) {
71575         var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment;
71576         var resolver = context.getEmitResolver();
71577         var compilerOptions = context.getCompilerOptions();
71578         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
71579         var shouldTransformPrivateFields = languageVersion < 99;
71580         var previousOnSubstituteNode = context.onSubstituteNode;
71581         context.onSubstituteNode = onSubstituteNode;
71582         var enabledSubstitutions;
71583         var classAliases;
71584         var pendingExpressions;
71585         var pendingStatements;
71586         var privateIdentifierEnvironmentStack = [];
71587         var currentPrivateIdentifierEnvironment;
71588         return ts.chainBundle(context, transformSourceFile);
71589         function transformSourceFile(node) {
71590             var options = context.getCompilerOptions();
71591             if (node.isDeclarationFile
71592                 || options.useDefineForClassFields && options.target === 99) {
71593                 return node;
71594             }
71595             var visited = ts.visitEachChild(node, visitor, context);
71596             ts.addEmitHelpers(visited, context.readEmitHelpers());
71597             return visited;
71598         }
71599         function visitor(node) {
71600             if (!(node.transformFlags & 4194304))
71601                 return node;
71602             switch (node.kind) {
71603                 case 221:
71604                 case 252:
71605                     return visitClassLike(node);
71606                 case 163:
71607                     return visitPropertyDeclaration(node);
71608                 case 232:
71609                     return visitVariableStatement(node);
71610                 case 201:
71611                     return visitPropertyAccessExpression(node);
71612                 case 214:
71613                     return visitPrefixUnaryExpression(node);
71614                 case 215:
71615                     return visitPostfixUnaryExpression(node, false);
71616                 case 203:
71617                     return visitCallExpression(node);
71618                 case 216:
71619                     return visitBinaryExpression(node);
71620                 case 79:
71621                     return visitPrivateIdentifier(node);
71622                 case 233:
71623                     return visitExpressionStatement(node);
71624                 case 237:
71625                     return visitForStatement(node);
71626                 case 205:
71627                     return visitTaggedTemplateExpression(node);
71628             }
71629             return ts.visitEachChild(node, visitor, context);
71630         }
71631         function visitorDestructuringTarget(node) {
71632             switch (node.kind) {
71633                 case 200:
71634                 case 199:
71635                     return visitAssignmentPattern(node);
71636                 default:
71637                     return visitor(node);
71638             }
71639         }
71640         function visitPrivateIdentifier(node) {
71641             if (!shouldTransformPrivateFields) {
71642                 return node;
71643             }
71644             return ts.setOriginalNode(factory.createIdentifier(""), node);
71645         }
71646         function classElementVisitor(node) {
71647             switch (node.kind) {
71648                 case 166:
71649                     return undefined;
71650                 case 167:
71651                 case 168:
71652                 case 165:
71653                     return ts.visitEachChild(node, classElementVisitor, context);
71654                 case 163:
71655                     return visitPropertyDeclaration(node);
71656                 case 158:
71657                     return visitComputedPropertyName(node);
71658                 case 229:
71659                     return node;
71660                 default:
71661                     return visitor(node);
71662             }
71663         }
71664         function visitVariableStatement(node) {
71665             var savedPendingStatements = pendingStatements;
71666             pendingStatements = [];
71667             var visitedNode = ts.visitEachChild(node, visitor, context);
71668             var statement = ts.some(pendingStatements) ? __spreadArray([visitedNode], pendingStatements) :
71669                 visitedNode;
71670             pendingStatements = savedPendingStatements;
71671             return statement;
71672         }
71673         function visitComputedPropertyName(name) {
71674             var node = ts.visitEachChild(name, visitor, context);
71675             if (ts.some(pendingExpressions)) {
71676                 var expressions = pendingExpressions;
71677                 expressions.push(node.expression);
71678                 pendingExpressions = [];
71679                 node = factory.updateComputedPropertyName(node, factory.inlineExpressions(expressions));
71680             }
71681             return node;
71682         }
71683         function visitPropertyDeclaration(node) {
71684             ts.Debug.assert(!ts.some(node.decorators));
71685             if (!shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) {
71686                 return factory.updatePropertyDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name, undefined, undefined, undefined);
71687             }
71688             var expr = getPropertyNameExpressionIfNeeded(node.name, !!node.initializer || !!context.getCompilerOptions().useDefineForClassFields);
71689             if (expr && !ts.isSimpleInlineableExpression(expr)) {
71690                 getPendingExpressions().push(expr);
71691             }
71692             return undefined;
71693         }
71694         function createPrivateIdentifierAccess(info, receiver) {
71695             receiver = ts.visitNode(receiver, visitor, ts.isExpression);
71696             switch (info.placement) {
71697                 case 0:
71698                     return context.getEmitHelperFactory().createClassPrivateFieldGetHelper(ts.nodeIsSynthesized(receiver) ? receiver : factory.cloneNode(receiver), info.weakMapName);
71699                 default: return ts.Debug.fail("Unexpected private identifier placement");
71700             }
71701         }
71702         function visitPropertyAccessExpression(node) {
71703             if (shouldTransformPrivateFields && ts.isPrivateIdentifier(node.name)) {
71704                 var privateIdentifierInfo = accessPrivateIdentifier(node.name);
71705                 if (privateIdentifierInfo) {
71706                     return ts.setOriginalNode(createPrivateIdentifierAccess(privateIdentifierInfo, node.expression), node);
71707                 }
71708             }
71709             return ts.visitEachChild(node, visitor, context);
71710         }
71711         function visitPrefixUnaryExpression(node) {
71712             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) {
71713                 var operator = node.operator === 45 ?
71714                     39 : node.operator === 46 ?
71715                     40 : undefined;
71716                 var info = void 0;
71717                 if (operator && (info = accessPrivateIdentifier(node.operand.name))) {
71718                     var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression);
71719                     var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
71720                     var existingValue = factory.createPrefixUnaryExpression(39, createPrivateIdentifierAccess(info, readExpression));
71721                     return ts.setOriginalNode(createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(existingValue, operator, factory.createNumericLiteral(1)), 62), node);
71722                 }
71723             }
71724             return ts.visitEachChild(node, visitor, context);
71725         }
71726         function visitPostfixUnaryExpression(node, valueIsDiscarded) {
71727             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.operand)) {
71728                 var operator = node.operator === 45 ?
71729                     39 : node.operator === 46 ?
71730                     40 : undefined;
71731                 var info = void 0;
71732                 if (operator && (info = accessPrivateIdentifier(node.operand.name))) {
71733                     var receiver = ts.visitNode(node.operand.expression, visitor, ts.isExpression);
71734                     var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
71735                     var existingValue = factory.createPrefixUnaryExpression(39, createPrivateIdentifierAccess(info, readExpression));
71736                     var returnValue = valueIsDiscarded ? undefined : factory.createTempVariable(hoistVariableDeclaration);
71737                     return ts.setOriginalNode(factory.inlineExpressions(ts.compact([
71738                         createPrivateIdentifierAssignment(info, initializeExpression || readExpression, factory.createBinaryExpression(returnValue ? factory.createAssignment(returnValue, existingValue) : existingValue, operator, factory.createNumericLiteral(1)), 62),
71739                         returnValue
71740                     ])), node);
71741                 }
71742             }
71743             return ts.visitEachChild(node, visitor, context);
71744         }
71745         function visitForStatement(node) {
71746             if (node.incrementor && ts.isPostfixUnaryExpression(node.incrementor)) {
71747                 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));
71748             }
71749             return ts.visitEachChild(node, visitor, context);
71750         }
71751         function visitExpressionStatement(node) {
71752             if (ts.isPostfixUnaryExpression(node.expression)) {
71753                 return factory.updateExpressionStatement(node, visitPostfixUnaryExpression(node.expression, true));
71754             }
71755             return ts.visitEachChild(node, visitor, context);
71756         }
71757         function createCopiableReceiverExpr(receiver) {
71758             var clone = ts.nodeIsSynthesized(receiver) ? receiver : factory.cloneNode(receiver);
71759             if (ts.isSimpleInlineableExpression(receiver)) {
71760                 return { readExpression: clone, initializeExpression: undefined };
71761             }
71762             var readExpression = factory.createTempVariable(hoistVariableDeclaration);
71763             var initializeExpression = factory.createAssignment(readExpression, clone);
71764             return { readExpression: readExpression, initializeExpression: initializeExpression };
71765         }
71766         function visitCallExpression(node) {
71767             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.expression)) {
71768                 var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target;
71769                 if (ts.isCallChain(node)) {
71770                     return factory.updateCallChain(node, factory.createPropertyAccessChain(ts.visitNode(target, visitor), node.questionDotToken, "call"), undefined, undefined, __spreadArray([ts.visitNode(thisArg, visitor, ts.isExpression)], ts.visitNodes(node.arguments, visitor, ts.isExpression)));
71771                 }
71772                 return factory.updateCallExpression(node, factory.createPropertyAccessExpression(ts.visitNode(target, visitor), "call"), undefined, __spreadArray([ts.visitNode(thisArg, visitor, ts.isExpression)], ts.visitNodes(node.arguments, visitor, ts.isExpression)));
71773             }
71774             return ts.visitEachChild(node, visitor, context);
71775         }
71776         function visitTaggedTemplateExpression(node) {
71777             if (shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyAccessExpression(node.tag)) {
71778                 var _a = factory.createCallBinding(node.tag, hoistVariableDeclaration, languageVersion), thisArg = _a.thisArg, target = _a.target;
71779                 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));
71780             }
71781             return ts.visitEachChild(node, visitor, context);
71782         }
71783         function visitBinaryExpression(node) {
71784             if (shouldTransformPrivateFields) {
71785                 if (ts.isDestructuringAssignment(node)) {
71786                     var savedPendingExpressions = pendingExpressions;
71787                     pendingExpressions = undefined;
71788                     node = factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorDestructuringTarget), node.operatorToken, ts.visitNode(node.right, visitor));
71789                     var expr = ts.some(pendingExpressions) ?
71790                         factory.inlineExpressions(ts.compact(__spreadArray(__spreadArray([], pendingExpressions), [node]))) :
71791                         node;
71792                     pendingExpressions = savedPendingExpressions;
71793                     return expr;
71794                 }
71795                 if (ts.isAssignmentExpression(node) && ts.isPrivateIdentifierPropertyAccessExpression(node.left)) {
71796                     var info = accessPrivateIdentifier(node.left.name);
71797                     if (info) {
71798                         return ts.setOriginalNode(createPrivateIdentifierAssignment(info, node.left.expression, node.right, node.operatorToken.kind), node);
71799                     }
71800                 }
71801             }
71802             return ts.visitEachChild(node, visitor, context);
71803         }
71804         function createPrivateIdentifierAssignment(info, receiver, right, operator) {
71805             switch (info.placement) {
71806                 case 0: {
71807                     return createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator);
71808                 }
71809                 default: return ts.Debug.fail("Unexpected private identifier placement");
71810             }
71811         }
71812         function createPrivateIdentifierInstanceFieldAssignment(info, receiver, right, operator) {
71813             receiver = ts.visitNode(receiver, visitor, ts.isExpression);
71814             right = ts.visitNode(right, visitor, ts.isExpression);
71815             if (ts.isCompoundAssignment(operator)) {
71816                 var _a = createCopiableReceiverExpr(receiver), readExpression = _a.readExpression, initializeExpression = _a.initializeExpression;
71817                 return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(initializeExpression || readExpression, info.weakMapName, factory.createBinaryExpression(context.getEmitHelperFactory().createClassPrivateFieldGetHelper(readExpression, info.weakMapName), ts.getNonAssignmentOperatorForCompoundAssignment(operator), right));
71818             }
71819             else {
71820                 return context.getEmitHelperFactory().createClassPrivateFieldSetHelper(receiver, info.weakMapName, right);
71821             }
71822         }
71823         function visitClassLike(node) {
71824             var savedPendingExpressions = pendingExpressions;
71825             pendingExpressions = undefined;
71826             if (shouldTransformPrivateFields) {
71827                 startPrivateIdentifierEnvironment();
71828             }
71829             var result = ts.isClassDeclaration(node) ?
71830                 visitClassDeclaration(node) :
71831                 visitClassExpression(node);
71832             if (shouldTransformPrivateFields) {
71833                 endPrivateIdentifierEnvironment();
71834             }
71835             pendingExpressions = savedPendingExpressions;
71836             return result;
71837         }
71838         function doesClassElementNeedTransform(node) {
71839             return ts.isPropertyDeclaration(node) || (shouldTransformPrivateFields && node.name && ts.isPrivateIdentifier(node.name));
71840         }
71841         function visitClassDeclaration(node) {
71842             if (!ts.forEach(node.members, doesClassElementNeedTransform)) {
71843                 return ts.visitEachChild(node, visitor, context);
71844             }
71845             var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
71846             var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103);
71847             var statements = [
71848                 factory.updateClassDeclaration(node, undefined, node.modifiers, node.name, undefined, ts.visitNodes(node.heritageClauses, visitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass))
71849             ];
71850             if (ts.some(pendingExpressions)) {
71851                 statements.push(factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions)));
71852             }
71853             var staticProperties = ts.getProperties(node, true, true);
71854             if (ts.some(staticProperties)) {
71855                 addPropertyStatements(statements, staticProperties, factory.getInternalName(node));
71856             }
71857             return statements;
71858         }
71859         function visitClassExpression(node) {
71860             if (!ts.forEach(node.members, doesClassElementNeedTransform)) {
71861                 return ts.visitEachChild(node, visitor, context);
71862             }
71863             var isDecoratedClassDeclaration = ts.isClassDeclaration(ts.getOriginalNode(node));
71864             var staticProperties = ts.getProperties(node, true, true);
71865             var extendsClauseElement = ts.getEffectiveBaseTypeNode(node);
71866             var isDerivedClass = !!(extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103);
71867             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));
71868             if (ts.some(staticProperties) || ts.some(pendingExpressions)) {
71869                 if (isDecoratedClassDeclaration) {
71870                     ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration.");
71871                     if (pendingStatements && pendingExpressions && ts.some(pendingExpressions)) {
71872                         pendingStatements.push(factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions)));
71873                     }
71874                     if (pendingStatements && ts.some(staticProperties)) {
71875                         addPropertyStatements(pendingStatements, staticProperties, factory.getInternalName(node));
71876                     }
71877                     return classExpression;
71878                 }
71879                 else {
71880                     var expressions = [];
71881                     var isClassWithConstructorReference = resolver.getNodeCheckFlags(node) & 16777216;
71882                     var temp = factory.createTempVariable(hoistVariableDeclaration, !!isClassWithConstructorReference);
71883                     if (isClassWithConstructorReference) {
71884                         enableSubstitutionForClassAliases();
71885                         var alias = factory.cloneNode(temp);
71886                         alias.autoGenerateFlags &= ~8;
71887                         classAliases[ts.getOriginalNodeId(node)] = alias;
71888                     }
71889                     ts.setEmitFlags(classExpression, 65536 | ts.getEmitFlags(classExpression));
71890                     expressions.push(ts.startOnNewLine(factory.createAssignment(temp, classExpression)));
71891                     ts.addRange(expressions, ts.map(pendingExpressions, ts.startOnNewLine));
71892                     ts.addRange(expressions, generateInitializedPropertyExpressions(staticProperties, temp));
71893                     expressions.push(ts.startOnNewLine(temp));
71894                     return factory.inlineExpressions(expressions);
71895                 }
71896             }
71897             return classExpression;
71898         }
71899         function transformClassMembers(node, isDerivedClass) {
71900             if (shouldTransformPrivateFields) {
71901                 for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
71902                     var member = _a[_i];
71903                     if (ts.isPrivateIdentifierPropertyDeclaration(member)) {
71904                         addPrivateIdentifierToEnvironment(member.name);
71905                     }
71906                 }
71907             }
71908             var members = [];
71909             var constructor = transformConstructor(node, isDerivedClass);
71910             if (constructor) {
71911                 members.push(constructor);
71912             }
71913             ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
71914             return ts.setTextRange(factory.createNodeArray(members), node.members);
71915         }
71916         function isPropertyDeclarationThatRequiresConstructorStatement(member) {
71917             if (!ts.isPropertyDeclaration(member) || ts.hasStaticModifier(member) || ts.hasSyntacticModifier(ts.getOriginalNode(member), 128)) {
71918                 return false;
71919             }
71920             if (context.getCompilerOptions().useDefineForClassFields) {
71921                 return languageVersion < 99;
71922             }
71923             return ts.isInitializedProperty(member) || shouldTransformPrivateFields && ts.isPrivateIdentifierPropertyDeclaration(member);
71924         }
71925         function transformConstructor(node, isDerivedClass) {
71926             var constructor = ts.visitNode(ts.getFirstConstructorWithBody(node), visitor, ts.isConstructorDeclaration);
71927             var properties = node.members.filter(isPropertyDeclarationThatRequiresConstructorStatement);
71928             if (!ts.some(properties)) {
71929                 return constructor;
71930             }
71931             var parameters = ts.visitParameterList(constructor ? constructor.parameters : undefined, visitor, context);
71932             var body = transformConstructorBody(node, constructor, isDerivedClass);
71933             if (!body) {
71934                 return undefined;
71935             }
71936             return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(factory.createConstructorDeclaration(undefined, undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor));
71937         }
71938         function transformConstructorBody(node, constructor, isDerivedClass) {
71939             var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields;
71940             var properties = ts.getProperties(node, false, false);
71941             if (!useDefineForClassFields) {
71942                 properties = ts.filter(properties, function (property) { return !!property.initializer || ts.isPrivateIdentifier(property.name); });
71943             }
71944             if (!constructor && !ts.some(properties)) {
71945                 return ts.visitFunctionBody(undefined, visitor, context);
71946             }
71947             resumeLexicalEnvironment();
71948             var indexOfFirstStatement = 0;
71949             var statements = [];
71950             if (!constructor && isDerivedClass) {
71951                 statements.push(factory.createExpressionStatement(factory.createCallExpression(factory.createSuper(), undefined, [factory.createSpreadElement(factory.createIdentifier("arguments"))])));
71952             }
71953             if (constructor) {
71954                 indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(factory, constructor, statements, visitor);
71955             }
71956             if (constructor === null || constructor === void 0 ? void 0 : constructor.body) {
71957                 var afterParameterProperties = ts.findIndex(constructor.body.statements, function (s) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(s), constructor); }, indexOfFirstStatement);
71958                 if (afterParameterProperties === -1) {
71959                     afterParameterProperties = constructor.body.statements.length;
71960                 }
71961                 if (afterParameterProperties > indexOfFirstStatement) {
71962                     if (!useDefineForClassFields) {
71963                         ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, afterParameterProperties - indexOfFirstStatement));
71964                     }
71965                     indexOfFirstStatement = afterParameterProperties;
71966                 }
71967             }
71968             addPropertyStatements(statements, properties, factory.createThis());
71969             if (constructor) {
71970                 ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement));
71971             }
71972             statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
71973             return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined);
71974         }
71975         function addPropertyStatements(statements, properties, receiver) {
71976             for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
71977                 var property = properties_7[_i];
71978                 var expression = transformProperty(property, receiver);
71979                 if (!expression) {
71980                     continue;
71981                 }
71982                 var statement = factory.createExpressionStatement(expression);
71983                 ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
71984                 ts.setCommentRange(statement, property);
71985                 ts.setOriginalNode(statement, property);
71986                 statements.push(statement);
71987             }
71988         }
71989         function generateInitializedPropertyExpressions(properties, receiver) {
71990             var expressions = [];
71991             for (var _i = 0, properties_8 = properties; _i < properties_8.length; _i++) {
71992                 var property = properties_8[_i];
71993                 var expression = transformProperty(property, receiver);
71994                 if (!expression) {
71995                     continue;
71996                 }
71997                 ts.startOnNewLine(expression);
71998                 ts.setSourceMapRange(expression, ts.moveRangePastModifiers(property));
71999                 ts.setCommentRange(expression, property);
72000                 ts.setOriginalNode(expression, property);
72001                 expressions.push(expression);
72002             }
72003             return expressions;
72004         }
72005         function transformProperty(property, receiver) {
72006             var _a;
72007             var emitAssignment = !context.getCompilerOptions().useDefineForClassFields;
72008             var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression)
72009                 ? factory.updateComputedPropertyName(property.name, factory.getGeneratedNameForNode(property.name))
72010                 : property.name;
72011             if (shouldTransformPrivateFields && ts.isPrivateIdentifier(propertyName)) {
72012                 var privateIdentifierInfo = accessPrivateIdentifier(propertyName);
72013                 if (privateIdentifierInfo) {
72014                     switch (privateIdentifierInfo.placement) {
72015                         case 0: {
72016                             return createPrivateInstanceFieldInitializer(receiver, ts.visitNode(property.initializer, visitor, ts.isExpression), privateIdentifierInfo.weakMapName);
72017                         }
72018                     }
72019                 }
72020                 else {
72021                     ts.Debug.fail("Undeclared private name for property declaration.");
72022                 }
72023             }
72024             if (ts.isPrivateIdentifier(propertyName) && !property.initializer) {
72025                 return undefined;
72026             }
72027             if (ts.isPrivateIdentifier(propertyName) && !property.initializer) {
72028                 return undefined;
72029             }
72030             var propertyOriginalNode = ts.getOriginalNode(property);
72031             if (ts.hasSyntacticModifier(propertyOriginalNode, 128)) {
72032                 return undefined;
72033             }
72034             var initializer = property.initializer || emitAssignment ? (_a = ts.visitNode(property.initializer, visitor, ts.isExpression)) !== null && _a !== void 0 ? _a : factory.createVoidZero()
72035                 : ts.isParameterPropertyDeclaration(propertyOriginalNode, propertyOriginalNode.parent) && ts.isIdentifier(propertyName) ? propertyName
72036                     : factory.createVoidZero();
72037             if (emitAssignment || ts.isPrivateIdentifier(propertyName)) {
72038                 var memberAccess = ts.createMemberAccessForPropertyName(factory, receiver, propertyName, propertyName);
72039                 return factory.createAssignment(memberAccess, initializer);
72040             }
72041             else {
72042                 var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression
72043                     : ts.isIdentifier(propertyName) ? factory.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText))
72044                         : propertyName;
72045                 var descriptor = factory.createPropertyDescriptor({ value: initializer, configurable: true, writable: true, enumerable: true });
72046                 return factory.createObjectDefinePropertyCall(receiver, name, descriptor);
72047             }
72048         }
72049         function enableSubstitutionForClassAliases() {
72050             if ((enabledSubstitutions & 1) === 0) {
72051                 enabledSubstitutions |= 1;
72052                 context.enableSubstitution(78);
72053                 classAliases = [];
72054             }
72055         }
72056         function onSubstituteNode(hint, node) {
72057             node = previousOnSubstituteNode(hint, node);
72058             if (hint === 1) {
72059                 return substituteExpression(node);
72060             }
72061             return node;
72062         }
72063         function substituteExpression(node) {
72064             switch (node.kind) {
72065                 case 78:
72066                     return substituteExpressionIdentifier(node);
72067             }
72068             return node;
72069         }
72070         function substituteExpressionIdentifier(node) {
72071             return trySubstituteClassAlias(node) || node;
72072         }
72073         function trySubstituteClassAlias(node) {
72074             if (enabledSubstitutions & 1) {
72075                 if (resolver.getNodeCheckFlags(node) & 33554432) {
72076                     var declaration = resolver.getReferencedValueDeclaration(node);
72077                     if (declaration) {
72078                         var classAlias = classAliases[declaration.id];
72079                         if (classAlias) {
72080                             var clone_2 = factory.cloneNode(classAlias);
72081                             ts.setSourceMapRange(clone_2, node);
72082                             ts.setCommentRange(clone_2, node);
72083                             return clone_2;
72084                         }
72085                     }
72086                 }
72087             }
72088             return undefined;
72089         }
72090         function getPropertyNameExpressionIfNeeded(name, shouldHoist) {
72091             if (ts.isComputedPropertyName(name)) {
72092                 var expression = ts.visitNode(name.expression, visitor, ts.isExpression);
72093                 var innerExpression = ts.skipPartiallyEmittedExpressions(expression);
72094                 var inlinable = ts.isSimpleInlineableExpression(innerExpression);
72095                 var alreadyTransformed = ts.isAssignmentExpression(innerExpression) && ts.isGeneratedIdentifier(innerExpression.left);
72096                 if (!alreadyTransformed && !inlinable && shouldHoist) {
72097                     var generatedName = factory.getGeneratedNameForNode(name);
72098                     hoistVariableDeclaration(generatedName);
72099                     return factory.createAssignment(generatedName, expression);
72100                 }
72101                 return (inlinable || ts.isIdentifier(innerExpression)) ? undefined : expression;
72102             }
72103         }
72104         function startPrivateIdentifierEnvironment() {
72105             privateIdentifierEnvironmentStack.push(currentPrivateIdentifierEnvironment);
72106             currentPrivateIdentifierEnvironment = undefined;
72107         }
72108         function endPrivateIdentifierEnvironment() {
72109             currentPrivateIdentifierEnvironment = privateIdentifierEnvironmentStack.pop();
72110         }
72111         function getPrivateIdentifierEnvironment() {
72112             return currentPrivateIdentifierEnvironment || (currentPrivateIdentifierEnvironment = new ts.Map());
72113         }
72114         function getPendingExpressions() {
72115             return pendingExpressions || (pendingExpressions = []);
72116         }
72117         function addPrivateIdentifierToEnvironment(name) {
72118             var text = ts.getTextOfPropertyName(name);
72119             var weakMapName = factory.createUniqueName("_" + text.substring(1), 16 | 8);
72120             hoistVariableDeclaration(weakMapName);
72121             getPrivateIdentifierEnvironment().set(name.escapedText, { placement: 0, weakMapName: weakMapName });
72122             getPendingExpressions().push(factory.createAssignment(weakMapName, factory.createNewExpression(factory.createIdentifier("WeakMap"), undefined, [])));
72123         }
72124         function accessPrivateIdentifier(name) {
72125             if (currentPrivateIdentifierEnvironment) {
72126                 var info = currentPrivateIdentifierEnvironment.get(name.escapedText);
72127                 if (info) {
72128                     return info;
72129                 }
72130             }
72131             for (var i = privateIdentifierEnvironmentStack.length - 1; i >= 0; --i) {
72132                 var env = privateIdentifierEnvironmentStack[i];
72133                 if (!env) {
72134                     continue;
72135                 }
72136                 var info = env.get(name.escapedText);
72137                 if (info) {
72138                     return info;
72139                 }
72140             }
72141             return undefined;
72142         }
72143         function wrapPrivateIdentifierForDestructuringTarget(node) {
72144             var parameter = factory.getGeneratedNameForNode(node);
72145             var info = accessPrivateIdentifier(node.name);
72146             if (!info) {
72147                 return ts.visitEachChild(node, visitor, context);
72148             }
72149             var receiver = node.expression;
72150             if (ts.isThisProperty(node) || ts.isSuperProperty(node) || !ts.isSimpleCopiableExpression(node.expression)) {
72151                 receiver = factory.createTempVariable(hoistVariableDeclaration, true);
72152                 getPendingExpressions().push(factory.createBinaryExpression(receiver, 62, node.expression));
72153             }
72154             return factory.createPropertyAccessExpression(factory.createParenthesizedExpression(factory.createObjectLiteralExpression([
72155                 factory.createSetAccessorDeclaration(undefined, undefined, "value", [factory.createParameterDeclaration(undefined, undefined, undefined, parameter, undefined, undefined, undefined)], factory.createBlock([factory.createExpressionStatement(createPrivateIdentifierAssignment(info, receiver, parameter, 62))]))
72156             ])), "value");
72157         }
72158         function visitArrayAssignmentTarget(node) {
72159             var target = ts.getTargetOfBindingOrAssignmentElement(node);
72160             if (target && ts.isPrivateIdentifierPropertyAccessExpression(target)) {
72161                 var wrapped = wrapPrivateIdentifierForDestructuringTarget(target);
72162                 if (ts.isAssignmentExpression(node)) {
72163                     return factory.updateBinaryExpression(node, wrapped, node.operatorToken, ts.visitNode(node.right, visitor, ts.isExpression));
72164                 }
72165                 else if (ts.isSpreadElement(node)) {
72166                     return factory.updateSpreadElement(node, wrapped);
72167                 }
72168                 else {
72169                     return wrapped;
72170                 }
72171             }
72172             return ts.visitNode(node, visitorDestructuringTarget);
72173         }
72174         function visitObjectAssignmentTarget(node) {
72175             if (ts.isPropertyAssignment(node)) {
72176                 var target = ts.getTargetOfBindingOrAssignmentElement(node);
72177                 if (target && ts.isPrivateIdentifierPropertyAccessExpression(target)) {
72178                     var initializer = ts.getInitializerOfBindingOrAssignmentElement(node);
72179                     var wrapped = wrapPrivateIdentifierForDestructuringTarget(target);
72180                     return factory.updatePropertyAssignment(node, ts.visitNode(node.name, visitor), initializer ? factory.createAssignment(wrapped, ts.visitNode(initializer, visitor)) : wrapped);
72181                 }
72182                 return factory.updatePropertyAssignment(node, ts.visitNode(node.name, visitor), ts.visitNode(node.initializer, visitorDestructuringTarget));
72183             }
72184             return ts.visitNode(node, visitor);
72185         }
72186         function visitAssignmentPattern(node) {
72187             if (ts.isArrayLiteralExpression(node)) {
72188                 return factory.updateArrayLiteralExpression(node, ts.visitNodes(node.elements, visitArrayAssignmentTarget, ts.isExpression));
72189             }
72190             else {
72191                 return factory.updateObjectLiteralExpression(node, ts.visitNodes(node.properties, visitObjectAssignmentTarget, ts.isObjectLiteralElementLike));
72192             }
72193         }
72194     }
72195     ts.transformClassFields = transformClassFields;
72196     function createPrivateInstanceFieldInitializer(receiver, initializer, weakMapName) {
72197         return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(weakMapName, "set"), undefined, [receiver, initializer || ts.factory.createVoidZero()]);
72198     }
72199 })(ts || (ts = {}));
72200 var ts;
72201 (function (ts) {
72202     function transformES2017(context) {
72203         var factory = context.factory, emitHelpers = context.getEmitHelperFactory, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
72204         var resolver = context.getEmitResolver();
72205         var compilerOptions = context.getCompilerOptions();
72206         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
72207         var enabledSubstitutions;
72208         var enclosingSuperContainerFlags = 0;
72209         var enclosingFunctionParameterNames;
72210         var capturedSuperProperties;
72211         var hasSuperElementAccess;
72212         var substitutedSuperAccessors = [];
72213         var contextFlags = 0;
72214         var previousOnEmitNode = context.onEmitNode;
72215         var previousOnSubstituteNode = context.onSubstituteNode;
72216         context.onEmitNode = onEmitNode;
72217         context.onSubstituteNode = onSubstituteNode;
72218         return ts.chainBundle(context, transformSourceFile);
72219         function transformSourceFile(node) {
72220             if (node.isDeclarationFile) {
72221                 return node;
72222             }
72223             setContextFlag(1, false);
72224             setContextFlag(2, !ts.isEffectiveStrictModeSourceFile(node, compilerOptions));
72225             var visited = ts.visitEachChild(node, visitor, context);
72226             ts.addEmitHelpers(visited, context.readEmitHelpers());
72227             return visited;
72228         }
72229         function setContextFlag(flag, val) {
72230             contextFlags = val ? contextFlags | flag : contextFlags & ~flag;
72231         }
72232         function inContext(flags) {
72233             return (contextFlags & flags) !== 0;
72234         }
72235         function inTopLevelContext() {
72236             return !inContext(1);
72237         }
72238         function inHasLexicalThisContext() {
72239             return inContext(2);
72240         }
72241         function doWithContext(flags, cb, value) {
72242             var contextFlagsToSet = flags & ~contextFlags;
72243             if (contextFlagsToSet) {
72244                 setContextFlag(contextFlagsToSet, true);
72245                 var result = cb(value);
72246                 setContextFlag(contextFlagsToSet, false);
72247                 return result;
72248             }
72249             return cb(value);
72250         }
72251         function visitDefault(node) {
72252             return ts.visitEachChild(node, visitor, context);
72253         }
72254         function visitor(node) {
72255             if ((node.transformFlags & 64) === 0) {
72256                 return node;
72257             }
72258             switch (node.kind) {
72259                 case 129:
72260                     return undefined;
72261                 case 213:
72262                     return visitAwaitExpression(node);
72263                 case 165:
72264                     return doWithContext(1 | 2, visitMethodDeclaration, node);
72265                 case 251:
72266                     return doWithContext(1 | 2, visitFunctionDeclaration, node);
72267                 case 208:
72268                     return doWithContext(1 | 2, visitFunctionExpression, node);
72269                 case 209:
72270                     return doWithContext(1, visitArrowFunction, node);
72271                 case 201:
72272                     if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105) {
72273                         capturedSuperProperties.add(node.name.escapedText);
72274                     }
72275                     return ts.visitEachChild(node, visitor, context);
72276                 case 202:
72277                     if (capturedSuperProperties && node.expression.kind === 105) {
72278                         hasSuperElementAccess = true;
72279                     }
72280                     return ts.visitEachChild(node, visitor, context);
72281                 case 167:
72282                 case 168:
72283                 case 166:
72284                 case 252:
72285                 case 221:
72286                     return doWithContext(1 | 2, visitDefault, node);
72287                 default:
72288                     return ts.visitEachChild(node, visitor, context);
72289             }
72290         }
72291         function asyncBodyVisitor(node) {
72292             if (ts.isNodeWithPossibleHoistedDeclaration(node)) {
72293                 switch (node.kind) {
72294                     case 232:
72295                         return visitVariableStatementInAsyncBody(node);
72296                     case 237:
72297                         return visitForStatementInAsyncBody(node);
72298                     case 238:
72299                         return visitForInStatementInAsyncBody(node);
72300                     case 239:
72301                         return visitForOfStatementInAsyncBody(node);
72302                     case 287:
72303                         return visitCatchClauseInAsyncBody(node);
72304                     case 230:
72305                     case 244:
72306                     case 258:
72307                     case 284:
72308                     case 285:
72309                     case 247:
72310                     case 235:
72311                     case 236:
72312                     case 234:
72313                     case 243:
72314                     case 245:
72315                         return ts.visitEachChild(node, asyncBodyVisitor, context);
72316                     default:
72317                         return ts.Debug.assertNever(node, "Unhandled node.");
72318                 }
72319             }
72320             return visitor(node);
72321         }
72322         function visitCatchClauseInAsyncBody(node) {
72323             var catchClauseNames = new ts.Set();
72324             recordDeclarationName(node.variableDeclaration, catchClauseNames);
72325             var catchClauseUnshadowedNames;
72326             catchClauseNames.forEach(function (_, escapedName) {
72327                 if (enclosingFunctionParameterNames.has(escapedName)) {
72328                     if (!catchClauseUnshadowedNames) {
72329                         catchClauseUnshadowedNames = new ts.Set(enclosingFunctionParameterNames);
72330                     }
72331                     catchClauseUnshadowedNames.delete(escapedName);
72332                 }
72333             });
72334             if (catchClauseUnshadowedNames) {
72335                 var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames;
72336                 enclosingFunctionParameterNames = catchClauseUnshadowedNames;
72337                 var result = ts.visitEachChild(node, asyncBodyVisitor, context);
72338                 enclosingFunctionParameterNames = savedEnclosingFunctionParameterNames;
72339                 return result;
72340             }
72341             else {
72342                 return ts.visitEachChild(node, asyncBodyVisitor, context);
72343             }
72344         }
72345         function visitVariableStatementInAsyncBody(node) {
72346             if (isVariableDeclarationListWithCollidingName(node.declarationList)) {
72347                 var expression = visitVariableDeclarationListWithCollidingNames(node.declarationList, false);
72348                 return expression ? factory.createExpressionStatement(expression) : undefined;
72349             }
72350             return ts.visitEachChild(node, visitor, context);
72351         }
72352         function visitForInStatementInAsyncBody(node) {
72353             return factory.updateForInStatement(node, isVariableDeclarationListWithCollidingName(node.initializer)
72354                 ? visitVariableDeclarationListWithCollidingNames(node.initializer, true)
72355                 : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock));
72356         }
72357         function visitForOfStatementInAsyncBody(node) {
72358             return factory.updateForOfStatement(node, ts.visitNode(node.awaitModifier, visitor, ts.isToken), isVariableDeclarationListWithCollidingName(node.initializer)
72359                 ? visitVariableDeclarationListWithCollidingNames(node.initializer, true)
72360                 : ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, asyncBodyVisitor, ts.isStatement, factory.liftToBlock));
72361         }
72362         function visitForStatementInAsyncBody(node) {
72363             var initializer = node.initializer;
72364             return factory.updateForStatement(node, isVariableDeclarationListWithCollidingName(initializer)
72365                 ? visitVariableDeclarationListWithCollidingNames(initializer, false)
72366                 : 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));
72367         }
72368         function visitAwaitExpression(node) {
72369             if (inTopLevelContext()) {
72370                 return ts.visitEachChild(node, visitor, context);
72371             }
72372             return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(undefined, ts.visitNode(node.expression, visitor, ts.isExpression)), node), node);
72373         }
72374         function visitMethodDeclaration(node) {
72375             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
72376                 ? transformAsyncFunctionBody(node)
72377                 : ts.visitFunctionBody(node.body, visitor, context));
72378         }
72379         function visitFunctionDeclaration(node) {
72380             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
72381                 ? transformAsyncFunctionBody(node)
72382                 : ts.visitFunctionBody(node.body, visitor, context));
72383         }
72384         function visitFunctionExpression(node) {
72385             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
72386                 ? transformAsyncFunctionBody(node)
72387                 : ts.visitFunctionBody(node.body, visitor, context));
72388         }
72389         function visitArrowFunction(node) {
72390             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
72391                 ? transformAsyncFunctionBody(node)
72392                 : ts.visitFunctionBody(node.body, visitor, context));
72393         }
72394         function recordDeclarationName(_a, names) {
72395             var name = _a.name;
72396             if (ts.isIdentifier(name)) {
72397                 names.add(name.escapedText);
72398             }
72399             else {
72400                 for (var _i = 0, _b = name.elements; _i < _b.length; _i++) {
72401                     var element = _b[_i];
72402                     if (!ts.isOmittedExpression(element)) {
72403                         recordDeclarationName(element, names);
72404                     }
72405                 }
72406             }
72407         }
72408         function isVariableDeclarationListWithCollidingName(node) {
72409             return !!node
72410                 && ts.isVariableDeclarationList(node)
72411                 && !(node.flags & 3)
72412                 && node.declarations.some(collidesWithParameterName);
72413         }
72414         function visitVariableDeclarationListWithCollidingNames(node, hasReceiver) {
72415             hoistVariableDeclarationList(node);
72416             var variables = ts.getInitializedVariables(node);
72417             if (variables.length === 0) {
72418                 if (hasReceiver) {
72419                     return ts.visitNode(factory.converters.convertToAssignmentElementTarget(node.declarations[0].name), visitor, ts.isExpression);
72420                 }
72421                 return undefined;
72422             }
72423             return factory.inlineExpressions(ts.map(variables, transformInitializedVariable));
72424         }
72425         function hoistVariableDeclarationList(node) {
72426             ts.forEach(node.declarations, hoistVariable);
72427         }
72428         function hoistVariable(_a) {
72429             var name = _a.name;
72430             if (ts.isIdentifier(name)) {
72431                 hoistVariableDeclaration(name);
72432             }
72433             else {
72434                 for (var _i = 0, _b = name.elements; _i < _b.length; _i++) {
72435                     var element = _b[_i];
72436                     if (!ts.isOmittedExpression(element)) {
72437                         hoistVariable(element);
72438                     }
72439                 }
72440             }
72441         }
72442         function transformInitializedVariable(node) {
72443             var converted = ts.setSourceMapRange(factory.createAssignment(factory.converters.convertToAssignmentElementTarget(node.name), node.initializer), node);
72444             return ts.visitNode(converted, visitor, ts.isExpression);
72445         }
72446         function collidesWithParameterName(_a) {
72447             var name = _a.name;
72448             if (ts.isIdentifier(name)) {
72449                 return enclosingFunctionParameterNames.has(name.escapedText);
72450             }
72451             else {
72452                 for (var _i = 0, _b = name.elements; _i < _b.length; _i++) {
72453                     var element = _b[_i];
72454                     if (!ts.isOmittedExpression(element) && collidesWithParameterName(element)) {
72455                         return true;
72456                     }
72457                 }
72458             }
72459             return false;
72460         }
72461         function transformAsyncFunctionBody(node) {
72462             resumeLexicalEnvironment();
72463             var original = ts.getOriginalNode(node, ts.isFunctionLike);
72464             var nodeType = original.type;
72465             var promiseConstructor = languageVersion < 2 ? getPromiseConstructor(nodeType) : undefined;
72466             var isArrowFunction = node.kind === 209;
72467             var hasLexicalArguments = (resolver.getNodeCheckFlags(node) & 8192) !== 0;
72468             var savedEnclosingFunctionParameterNames = enclosingFunctionParameterNames;
72469             enclosingFunctionParameterNames = new ts.Set();
72470             for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
72471                 var parameter = _a[_i];
72472                 recordDeclarationName(parameter, enclosingFunctionParameterNames);
72473             }
72474             var savedCapturedSuperProperties = capturedSuperProperties;
72475             var savedHasSuperElementAccess = hasSuperElementAccess;
72476             if (!isArrowFunction) {
72477                 capturedSuperProperties = new ts.Set();
72478                 hasSuperElementAccess = false;
72479             }
72480             var result;
72481             if (!isArrowFunction) {
72482                 var statements = [];
72483                 var statementOffset = factory.copyPrologue(node.body.statements, statements, false, visitor);
72484                 statements.push(factory.createReturnStatement(emitHelpers().createAwaiterHelper(inHasLexicalThisContext(), hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body, statementOffset))));
72485                 ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
72486                 var emitSuperHelpers = languageVersion >= 2 && resolver.getNodeCheckFlags(node) & (4096 | 2048);
72487                 if (emitSuperHelpers) {
72488                     enableSubstitutionForAsyncMethodsWithSuper();
72489                     if (capturedSuperProperties.size) {
72490                         var variableStatement = createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
72491                         substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
72492                         ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
72493                     }
72494                 }
72495                 var block = factory.createBlock(statements, true);
72496                 ts.setTextRange(block, node.body);
72497                 if (emitSuperHelpers && hasSuperElementAccess) {
72498                     if (resolver.getNodeCheckFlags(node) & 4096) {
72499                         ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
72500                     }
72501                     else if (resolver.getNodeCheckFlags(node) & 2048) {
72502                         ts.addEmitHelper(block, ts.asyncSuperHelper);
72503                     }
72504                 }
72505                 result = block;
72506             }
72507             else {
72508                 var expression = emitHelpers().createAwaiterHelper(inHasLexicalThisContext(), hasLexicalArguments, promiseConstructor, transformAsyncFunctionBodyWorker(node.body));
72509                 var declarations = endLexicalEnvironment();
72510                 if (ts.some(declarations)) {
72511                     var block = factory.converters.convertToFunctionBlock(expression);
72512                     result = factory.updateBlock(block, ts.setTextRange(factory.createNodeArray(ts.concatenate(declarations, block.statements)), block.statements));
72513                 }
72514                 else {
72515                     result = expression;
72516                 }
72517             }
72518             enclosingFunctionParameterNames = savedEnclosingFunctionParameterNames;
72519             if (!isArrowFunction) {
72520                 capturedSuperProperties = savedCapturedSuperProperties;
72521                 hasSuperElementAccess = savedHasSuperElementAccess;
72522             }
72523             return result;
72524         }
72525         function transformAsyncFunctionBodyWorker(body, start) {
72526             if (ts.isBlock(body)) {
72527                 return factory.updateBlock(body, ts.visitNodes(body.statements, asyncBodyVisitor, ts.isStatement, start));
72528             }
72529             else {
72530                 return factory.converters.convertToFunctionBlock(ts.visitNode(body, asyncBodyVisitor, ts.isConciseBody));
72531             }
72532         }
72533         function getPromiseConstructor(type) {
72534             var typeName = type && ts.getEntityNameFromTypeNode(type);
72535             if (typeName && ts.isEntityName(typeName)) {
72536                 var serializationKind = resolver.getTypeReferenceSerializationKind(typeName);
72537                 if (serializationKind === ts.TypeReferenceSerializationKind.TypeWithConstructSignatureAndValue
72538                     || serializationKind === ts.TypeReferenceSerializationKind.Unknown) {
72539                     return typeName;
72540                 }
72541             }
72542             return undefined;
72543         }
72544         function enableSubstitutionForAsyncMethodsWithSuper() {
72545             if ((enabledSubstitutions & 1) === 0) {
72546                 enabledSubstitutions |= 1;
72547                 context.enableSubstitution(203);
72548                 context.enableSubstitution(201);
72549                 context.enableSubstitution(202);
72550                 context.enableEmitNotification(252);
72551                 context.enableEmitNotification(165);
72552                 context.enableEmitNotification(167);
72553                 context.enableEmitNotification(168);
72554                 context.enableEmitNotification(166);
72555                 context.enableEmitNotification(232);
72556             }
72557         }
72558         function onEmitNode(hint, node, emitCallback) {
72559             if (enabledSubstitutions & 1 && isSuperContainer(node)) {
72560                 var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 | 4096);
72561                 if (superContainerFlags !== enclosingSuperContainerFlags) {
72562                     var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
72563                     enclosingSuperContainerFlags = superContainerFlags;
72564                     previousOnEmitNode(hint, node, emitCallback);
72565                     enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
72566                     return;
72567                 }
72568             }
72569             else if (enabledSubstitutions && substitutedSuperAccessors[ts.getNodeId(node)]) {
72570                 var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
72571                 enclosingSuperContainerFlags = 0;
72572                 previousOnEmitNode(hint, node, emitCallback);
72573                 enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
72574                 return;
72575             }
72576             previousOnEmitNode(hint, node, emitCallback);
72577         }
72578         function onSubstituteNode(hint, node) {
72579             node = previousOnSubstituteNode(hint, node);
72580             if (hint === 1 && enclosingSuperContainerFlags) {
72581                 return substituteExpression(node);
72582             }
72583             return node;
72584         }
72585         function substituteExpression(node) {
72586             switch (node.kind) {
72587                 case 201:
72588                     return substitutePropertyAccessExpression(node);
72589                 case 202:
72590                     return substituteElementAccessExpression(node);
72591                 case 203:
72592                     return substituteCallExpression(node);
72593             }
72594             return node;
72595         }
72596         function substitutePropertyAccessExpression(node) {
72597             if (node.expression.kind === 105) {
72598                 return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 | 32), node.name), node);
72599             }
72600             return node;
72601         }
72602         function substituteElementAccessExpression(node) {
72603             if (node.expression.kind === 105) {
72604                 return createSuperElementAccessInAsyncMethod(node.argumentExpression, node);
72605             }
72606             return node;
72607         }
72608         function substituteCallExpression(node) {
72609             var expression = node.expression;
72610             if (ts.isSuperProperty(expression)) {
72611                 var argumentExpression = ts.isPropertyAccessExpression(expression)
72612                     ? substitutePropertyAccessExpression(expression)
72613                     : substituteElementAccessExpression(expression);
72614                 return factory.createCallExpression(factory.createPropertyAccessExpression(argumentExpression, "call"), undefined, __spreadArray([
72615                     factory.createThis()
72616                 ], node.arguments));
72617             }
72618             return node;
72619         }
72620         function isSuperContainer(node) {
72621             var kind = node.kind;
72622             return kind === 252
72623                 || kind === 166
72624                 || kind === 165
72625                 || kind === 167
72626                 || kind === 168;
72627         }
72628         function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
72629             if (enclosingSuperContainerFlags & 4096) {
72630                 return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 | 32), undefined, [argumentExpression]), "value"), location);
72631             }
72632             else {
72633                 return ts.setTextRange(factory.createCallExpression(factory.createUniqueName("_superIndex", 16 | 32), undefined, [argumentExpression]), location);
72634             }
72635         }
72636     }
72637     ts.transformES2017 = transformES2017;
72638     function createSuperAccessVariableStatement(factory, resolver, node, names) {
72639         var hasBinding = (resolver.getNodeCheckFlags(node) & 4096) !== 0;
72640         var accessors = [];
72641         names.forEach(function (_, key) {
72642             var name = ts.unescapeLeadingUnderscores(key);
72643             var getterAndSetter = [];
72644             getterAndSetter.push(factory.createPropertyAssignment("get", factory.createArrowFunction(undefined, undefined, [], undefined, undefined, ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4), name), 4))));
72645             if (hasBinding) {
72646                 getterAndSetter.push(factory.createPropertyAssignment("set", factory.createArrowFunction(undefined, undefined, [
72647                     factory.createParameterDeclaration(undefined, undefined, undefined, "v", undefined, undefined, undefined)
72648                 ], undefined, undefined, factory.createAssignment(ts.setEmitFlags(factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createSuper(), 4), name), 4), factory.createIdentifier("v")))));
72649             }
72650             accessors.push(factory.createPropertyAssignment(name, factory.createObjectLiteralExpression(getterAndSetter)));
72651         });
72652         return factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
72653             factory.createVariableDeclaration(factory.createUniqueName("_super", 16 | 32), undefined, undefined, factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "create"), undefined, [
72654                 factory.createNull(),
72655                 factory.createObjectLiteralExpression(accessors, true)
72656             ]))
72657         ], 2));
72658     }
72659     ts.createSuperAccessVariableStatement = createSuperAccessVariableStatement;
72660 })(ts || (ts = {}));
72661 var ts;
72662 (function (ts) {
72663     function transformES2018(context) {
72664         var factory = context.factory, emitHelpers = context.getEmitHelperFactory, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
72665         var resolver = context.getEmitResolver();
72666         var compilerOptions = context.getCompilerOptions();
72667         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
72668         var previousOnEmitNode = context.onEmitNode;
72669         context.onEmitNode = onEmitNode;
72670         var previousOnSubstituteNode = context.onSubstituteNode;
72671         context.onSubstituteNode = onSubstituteNode;
72672         var exportedVariableStatement = false;
72673         var enabledSubstitutions;
72674         var enclosingFunctionFlags;
72675         var enclosingSuperContainerFlags = 0;
72676         var hierarchyFacts = 0;
72677         var currentSourceFile;
72678         var taggedTemplateStringDeclarations;
72679         var capturedSuperProperties;
72680         var hasSuperElementAccess;
72681         var substitutedSuperAccessors = [];
72682         return ts.chainBundle(context, transformSourceFile);
72683         function affectsSubtree(excludeFacts, includeFacts) {
72684             return hierarchyFacts !== (hierarchyFacts & ~excludeFacts | includeFacts);
72685         }
72686         function enterSubtree(excludeFacts, includeFacts) {
72687             var ancestorFacts = hierarchyFacts;
72688             hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 3;
72689             return ancestorFacts;
72690         }
72691         function exitSubtree(ancestorFacts) {
72692             hierarchyFacts = ancestorFacts;
72693         }
72694         function recordTaggedTemplateString(temp) {
72695             taggedTemplateStringDeclarations = ts.append(taggedTemplateStringDeclarations, factory.createVariableDeclaration(temp));
72696         }
72697         function transformSourceFile(node) {
72698             if (node.isDeclarationFile) {
72699                 return node;
72700             }
72701             currentSourceFile = node;
72702             var visited = visitSourceFile(node);
72703             ts.addEmitHelpers(visited, context.readEmitHelpers());
72704             currentSourceFile = undefined;
72705             taggedTemplateStringDeclarations = undefined;
72706             return visited;
72707         }
72708         function visitor(node) {
72709             return visitorWorker(node, false);
72710         }
72711         function visitorWithUnusedExpressionResult(node) {
72712             return visitorWorker(node, true);
72713         }
72714         function visitorNoAsyncModifier(node) {
72715             if (node.kind === 129) {
72716                 return undefined;
72717             }
72718             return node;
72719         }
72720         function doWithHierarchyFacts(cb, value, excludeFacts, includeFacts) {
72721             if (affectsSubtree(excludeFacts, includeFacts)) {
72722                 var ancestorFacts = enterSubtree(excludeFacts, includeFacts);
72723                 var result = cb(value);
72724                 exitSubtree(ancestorFacts);
72725                 return result;
72726             }
72727             return cb(value);
72728         }
72729         function visitDefault(node) {
72730             return ts.visitEachChild(node, visitor, context);
72731         }
72732         function visitorWorker(node, expressionResultIsUnused) {
72733             if ((node.transformFlags & 32) === 0) {
72734                 return node;
72735             }
72736             switch (node.kind) {
72737                 case 213:
72738                     return visitAwaitExpression(node);
72739                 case 219:
72740                     return visitYieldExpression(node);
72741                 case 242:
72742                     return visitReturnStatement(node);
72743                 case 245:
72744                     return visitLabeledStatement(node);
72745                 case 200:
72746                     return visitObjectLiteralExpression(node);
72747                 case 216:
72748                     return visitBinaryExpression(node, expressionResultIsUnused);
72749                 case 337:
72750                     return visitCommaListExpression(node, expressionResultIsUnused);
72751                 case 287:
72752                     return visitCatchClause(node);
72753                 case 232:
72754                     return visitVariableStatement(node);
72755                 case 249:
72756                     return visitVariableDeclaration(node);
72757                 case 235:
72758                 case 236:
72759                 case 238:
72760                     return doWithHierarchyFacts(visitDefault, node, 0, 2);
72761                 case 239:
72762                     return visitForOfStatement(node, undefined);
72763                 case 237:
72764                     return doWithHierarchyFacts(visitForStatement, node, 0, 2);
72765                 case 212:
72766                     return visitVoidExpression(node);
72767                 case 166:
72768                     return doWithHierarchyFacts(visitConstructorDeclaration, node, 2, 1);
72769                 case 165:
72770                     return doWithHierarchyFacts(visitMethodDeclaration, node, 2, 1);
72771                 case 167:
72772                     return doWithHierarchyFacts(visitGetAccessorDeclaration, node, 2, 1);
72773                 case 168:
72774                     return doWithHierarchyFacts(visitSetAccessorDeclaration, node, 2, 1);
72775                 case 251:
72776                     return doWithHierarchyFacts(visitFunctionDeclaration, node, 2, 1);
72777                 case 208:
72778                     return doWithHierarchyFacts(visitFunctionExpression, node, 2, 1);
72779                 case 209:
72780                     return doWithHierarchyFacts(visitArrowFunction, node, 2, 0);
72781                 case 160:
72782                     return visitParameter(node);
72783                 case 233:
72784                     return visitExpressionStatement(node);
72785                 case 207:
72786                     return visitParenthesizedExpression(node, expressionResultIsUnused);
72787                 case 205:
72788                     return visitTaggedTemplateExpression(node);
72789                 case 201:
72790                     if (capturedSuperProperties && ts.isPropertyAccessExpression(node) && node.expression.kind === 105) {
72791                         capturedSuperProperties.add(node.name.escapedText);
72792                     }
72793                     return ts.visitEachChild(node, visitor, context);
72794                 case 202:
72795                     if (capturedSuperProperties && node.expression.kind === 105) {
72796                         hasSuperElementAccess = true;
72797                     }
72798                     return ts.visitEachChild(node, visitor, context);
72799                 case 252:
72800                 case 221:
72801                     return doWithHierarchyFacts(visitDefault, node, 2, 1);
72802                 default:
72803                     return ts.visitEachChild(node, visitor, context);
72804             }
72805         }
72806         function visitAwaitExpression(node) {
72807             if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) {
72808                 return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(undefined, emitHelpers().createAwaitHelper(ts.visitNode(node.expression, visitor, ts.isExpression))), node), node);
72809             }
72810             return ts.visitEachChild(node, visitor, context);
72811         }
72812         function visitYieldExpression(node) {
72813             if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) {
72814                 if (node.asteriskToken) {
72815                     var expression = ts.visitNode(ts.Debug.assertDefined(node.expression), visitor, ts.isExpression);
72816                     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);
72817                 }
72818                 return ts.setOriginalNode(ts.setTextRange(factory.createYieldExpression(undefined, createDownlevelAwait(node.expression
72819                     ? ts.visitNode(node.expression, visitor, ts.isExpression)
72820                     : factory.createVoidZero())), node), node);
72821             }
72822             return ts.visitEachChild(node, visitor, context);
72823         }
72824         function visitReturnStatement(node) {
72825             if (enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1) {
72826                 return factory.updateReturnStatement(node, createDownlevelAwait(node.expression ? ts.visitNode(node.expression, visitor, ts.isExpression) : factory.createVoidZero()));
72827             }
72828             return ts.visitEachChild(node, visitor, context);
72829         }
72830         function visitLabeledStatement(node) {
72831             if (enclosingFunctionFlags & 2) {
72832                 var statement = ts.unwrapInnermostStatementOfLabel(node);
72833                 if (statement.kind === 239 && statement.awaitModifier) {
72834                     return visitForOfStatement(statement, node);
72835                 }
72836                 return factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node);
72837             }
72838             return ts.visitEachChild(node, visitor, context);
72839         }
72840         function chunkObjectLiteralElements(elements) {
72841             var chunkObject;
72842             var objects = [];
72843             for (var _i = 0, elements_4 = elements; _i < elements_4.length; _i++) {
72844                 var e = elements_4[_i];
72845                 if (e.kind === 290) {
72846                     if (chunkObject) {
72847                         objects.push(factory.createObjectLiteralExpression(chunkObject));
72848                         chunkObject = undefined;
72849                     }
72850                     var target = e.expression;
72851                     objects.push(ts.visitNode(target, visitor, ts.isExpression));
72852                 }
72853                 else {
72854                     chunkObject = ts.append(chunkObject, e.kind === 288
72855                         ? factory.createPropertyAssignment(e.name, ts.visitNode(e.initializer, visitor, ts.isExpression))
72856                         : ts.visitNode(e, visitor, ts.isObjectLiteralElementLike));
72857                 }
72858             }
72859             if (chunkObject) {
72860                 objects.push(factory.createObjectLiteralExpression(chunkObject));
72861             }
72862             return objects;
72863         }
72864         function visitObjectLiteralExpression(node) {
72865             if (node.transformFlags & 16384) {
72866                 var objects = chunkObjectLiteralElements(node.properties);
72867                 if (objects.length && objects[0].kind !== 200) {
72868                     objects.unshift(factory.createObjectLiteralExpression());
72869                 }
72870                 var expression = objects[0];
72871                 if (objects.length > 1) {
72872                     for (var i = 1; i < objects.length; i++) {
72873                         expression = emitHelpers().createAssignHelper([expression, objects[i]]);
72874                     }
72875                     return expression;
72876                 }
72877                 else {
72878                     return emitHelpers().createAssignHelper(objects);
72879                 }
72880             }
72881             return ts.visitEachChild(node, visitor, context);
72882         }
72883         function visitExpressionStatement(node) {
72884             return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
72885         }
72886         function visitParenthesizedExpression(node, expressionResultIsUnused) {
72887             return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context);
72888         }
72889         function visitSourceFile(node) {
72890             var ancestorFacts = enterSubtree(2, ts.isEffectiveStrictModeSourceFile(node, compilerOptions) ?
72891                 0 :
72892                 1);
72893             exportedVariableStatement = false;
72894             var visited = ts.visitEachChild(node, visitor, context);
72895             var statement = ts.concatenate(visited.statements, taggedTemplateStringDeclarations && [
72896                 factory.createVariableStatement(undefined, factory.createVariableDeclarationList(taggedTemplateStringDeclarations))
72897             ]);
72898             var result = factory.updateSourceFile(visited, ts.setTextRange(factory.createNodeArray(statement), node.statements));
72899             exitSubtree(ancestorFacts);
72900             return result;
72901         }
72902         function visitTaggedTemplateExpression(node) {
72903             return ts.processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, ts.ProcessLevel.LiftRestriction);
72904         }
72905         function visitBinaryExpression(node, expressionResultIsUnused) {
72906             if (ts.isDestructuringAssignment(node) && node.left.transformFlags & 16384) {
72907                 return ts.flattenDestructuringAssignment(node, visitor, context, 1, !expressionResultIsUnused);
72908             }
72909             if (node.operatorToken.kind === 27) {
72910                 return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression));
72911             }
72912             return ts.visitEachChild(node, visitor, context);
72913         }
72914         function visitCommaListExpression(node, expressionResultIsUnused) {
72915             if (expressionResultIsUnused) {
72916                 return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
72917             }
72918             var result;
72919             for (var i = 0; i < node.elements.length; i++) {
72920                 var element = node.elements[i];
72921                 var visited = ts.visitNode(element, i < node.elements.length - 1 ? visitorWithUnusedExpressionResult : visitor, ts.isExpression);
72922                 if (result || visited !== element) {
72923                     result || (result = node.elements.slice(0, i));
72924                     result.push(visited);
72925                 }
72926             }
72927             var elements = result ? ts.setTextRange(factory.createNodeArray(result), node.elements) : node.elements;
72928             return factory.updateCommaListExpression(node, elements);
72929         }
72930         function visitCatchClause(node) {
72931             if (node.variableDeclaration &&
72932                 ts.isBindingPattern(node.variableDeclaration.name) &&
72933                 node.variableDeclaration.name.transformFlags & 16384) {
72934                 var name = factory.getGeneratedNameForNode(node.variableDeclaration.name);
72935                 var updatedDecl = factory.updateVariableDeclaration(node.variableDeclaration, node.variableDeclaration.name, undefined, undefined, name);
72936                 var visitedBindings = ts.flattenDestructuringBinding(updatedDecl, visitor, context, 1);
72937                 var block = ts.visitNode(node.block, visitor, ts.isBlock);
72938                 if (ts.some(visitedBindings)) {
72939                     block = factory.updateBlock(block, __spreadArray([
72940                         factory.createVariableStatement(undefined, visitedBindings)
72941                     ], block.statements));
72942                 }
72943                 return factory.updateCatchClause(node, factory.updateVariableDeclaration(node.variableDeclaration, name, undefined, undefined, undefined), block);
72944             }
72945             return ts.visitEachChild(node, visitor, context);
72946         }
72947         function visitVariableStatement(node) {
72948             if (ts.hasSyntacticModifier(node, 1)) {
72949                 var savedExportedVariableStatement = exportedVariableStatement;
72950                 exportedVariableStatement = true;
72951                 var visited = ts.visitEachChild(node, visitor, context);
72952                 exportedVariableStatement = savedExportedVariableStatement;
72953                 return visited;
72954             }
72955             return ts.visitEachChild(node, visitor, context);
72956         }
72957         function visitVariableDeclaration(node) {
72958             if (exportedVariableStatement) {
72959                 var savedExportedVariableStatement = exportedVariableStatement;
72960                 exportedVariableStatement = false;
72961                 var visited = visitVariableDeclarationWorker(node, true);
72962                 exportedVariableStatement = savedExportedVariableStatement;
72963                 return visited;
72964             }
72965             return visitVariableDeclarationWorker(node, false);
72966         }
72967         function visitVariableDeclarationWorker(node, exportedVariableStatement) {
72968             if (ts.isBindingPattern(node.name) && node.name.transformFlags & 16384) {
72969                 return ts.flattenDestructuringBinding(node, visitor, context, 1, undefined, exportedVariableStatement);
72970             }
72971             return ts.visitEachChild(node, visitor, context);
72972         }
72973         function visitForStatement(node) {
72974             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));
72975         }
72976         function visitVoidExpression(node) {
72977             return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
72978         }
72979         function visitForOfStatement(node, outermostLabeledStatement) {
72980             var ancestorFacts = enterSubtree(0, 2);
72981             if (node.initializer.transformFlags & 16384) {
72982                 node = transformForOfStatementWithObjectRest(node);
72983             }
72984             var result = node.awaitModifier ?
72985                 transformForAwaitOfStatement(node, outermostLabeledStatement, ancestorFacts) :
72986                 factory.restoreEnclosingLabel(ts.visitEachChild(node, visitor, context), outermostLabeledStatement);
72987             exitSubtree(ancestorFacts);
72988             return result;
72989         }
72990         function transformForOfStatementWithObjectRest(node) {
72991             var initializerWithoutParens = ts.skipParentheses(node.initializer);
72992             if (ts.isVariableDeclarationList(initializerWithoutParens) || ts.isAssignmentPattern(initializerWithoutParens)) {
72993                 var bodyLocation = void 0;
72994                 var statementsLocation = void 0;
72995                 var temp = factory.createTempVariable(undefined);
72996                 var statements = [ts.createForOfBindingStatement(factory, initializerWithoutParens, temp)];
72997                 if (ts.isBlock(node.statement)) {
72998                     ts.addRange(statements, node.statement.statements);
72999                     bodyLocation = node.statement;
73000                     statementsLocation = node.statement.statements;
73001                 }
73002                 else if (node.statement) {
73003                     ts.append(statements, node.statement);
73004                     bodyLocation = node.statement;
73005                     statementsLocation = node.statement;
73006                 }
73007                 return factory.updateForOfStatement(node, node.awaitModifier, ts.setTextRange(factory.createVariableDeclarationList([
73008                     ts.setTextRange(factory.createVariableDeclaration(temp), node.initializer)
73009                 ], 1), node.initializer), node.expression, ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), true), bodyLocation));
73010             }
73011             return node;
73012         }
73013         function convertForOfStatementHead(node, boundValue) {
73014             var binding = ts.createForOfBindingStatement(factory, node.initializer, boundValue);
73015             var bodyLocation;
73016             var statementsLocation;
73017             var statements = [ts.visitNode(binding, visitor, ts.isStatement)];
73018             var statement = ts.visitNode(node.statement, visitor, ts.isStatement);
73019             if (ts.isBlock(statement)) {
73020                 ts.addRange(statements, statement.statements);
73021                 bodyLocation = statement;
73022                 statementsLocation = statement.statements;
73023             }
73024             else {
73025                 statements.push(statement);
73026             }
73027             return ts.setEmitFlags(ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), true), bodyLocation), 48 | 384);
73028         }
73029         function createDownlevelAwait(expression) {
73030             return enclosingFunctionFlags & 1
73031                 ? factory.createYieldExpression(undefined, emitHelpers().createAwaitHelper(expression))
73032                 : factory.createAwaitExpression(expression);
73033         }
73034         function transformForAwaitOfStatement(node, outermostLabeledStatement, ancestorFacts) {
73035             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
73036             var iterator = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(undefined);
73037             var result = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(iterator) : factory.createTempVariable(undefined);
73038             var errorRecord = factory.createUniqueName("e");
73039             var catchVariable = factory.getGeneratedNameForNode(errorRecord);
73040             var returnMethod = factory.createTempVariable(undefined);
73041             var callValues = ts.setTextRange(emitHelpers().createAsyncValuesHelper(expression), node.expression);
73042             var callNext = factory.createCallExpression(factory.createPropertyAccessExpression(iterator, "next"), undefined, []);
73043             var getDone = factory.createPropertyAccessExpression(result, "done");
73044             var getValue = factory.createPropertyAccessExpression(result, "value");
73045             var callReturn = factory.createFunctionCallCall(returnMethod, iterator, []);
73046             hoistVariableDeclaration(errorRecord);
73047             hoistVariableDeclaration(returnMethod);
73048             var initializer = ancestorFacts & 2 ?
73049                 factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), callValues]) :
73050                 callValues;
73051             var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement(ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([
73052                 ts.setTextRange(factory.createVariableDeclaration(iterator, undefined, undefined, initializer), node.expression),
73053                 factory.createVariableDeclaration(result)
73054             ]), node.expression), 2097152), factory.createComma(factory.createAssignment(result, createDownlevelAwait(callNext)), factory.createLogicalNot(getDone)), undefined, convertForOfStatementHead(node, getValue)), node), 256);
73055             return factory.createTryStatement(factory.createBlock([
73056                 factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement)
73057             ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([
73058                 factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([
73059                     factory.createPropertyAssignment("error", catchVariable)
73060                 ])))
73061             ]), 1)), factory.createBlock([
73062                 factory.createTryStatement(factory.createBlock([
73063                     ts.setEmitFlags(factory.createIfStatement(factory.createLogicalAnd(factory.createLogicalAnd(result, factory.createLogicalNot(getDone)), factory.createAssignment(returnMethod, factory.createPropertyAccessExpression(iterator, "return"))), factory.createExpressionStatement(createDownlevelAwait(callReturn))), 1)
73064                 ]), undefined, ts.setEmitFlags(factory.createBlock([
73065                     ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1)
73066                 ]), 1))
73067             ]));
73068         }
73069         function visitParameter(node) {
73070             if (node.transformFlags & 16384) {
73071                 return factory.updateParameterDeclaration(node, undefined, undefined, node.dotDotDotToken, factory.getGeneratedNameForNode(node), undefined, undefined, ts.visitNode(node.initializer, visitor, ts.isExpression));
73072             }
73073             return ts.visitEachChild(node, visitor, context);
73074         }
73075         function visitConstructorDeclaration(node) {
73076             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
73077             enclosingFunctionFlags = 0;
73078             var updated = factory.updateConstructorDeclaration(node, undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
73079             enclosingFunctionFlags = savedEnclosingFunctionFlags;
73080             return updated;
73081         }
73082         function visitGetAccessorDeclaration(node) {
73083             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
73084             enclosingFunctionFlags = 0;
73085             var updated = factory.updateGetAccessorDeclaration(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node));
73086             enclosingFunctionFlags = savedEnclosingFunctionFlags;
73087             return updated;
73088         }
73089         function visitSetAccessorDeclaration(node) {
73090             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
73091             enclosingFunctionFlags = 0;
73092             var updated = factory.updateSetAccessorDeclaration(node, undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
73093             enclosingFunctionFlags = savedEnclosingFunctionFlags;
73094             return updated;
73095         }
73096         function visitMethodDeclaration(node) {
73097             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
73098             enclosingFunctionFlags = ts.getFunctionFlags(node);
73099             var updated = factory.updateMethodDeclaration(node, undefined, enclosingFunctionFlags & 1
73100                 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
73101                 : node.modifiers, enclosingFunctionFlags & 2
73102                 ? undefined
73103                 : 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
73104                 ? transformAsyncGeneratorFunctionBody(node)
73105                 : transformFunctionBody(node));
73106             enclosingFunctionFlags = savedEnclosingFunctionFlags;
73107             return updated;
73108         }
73109         function visitFunctionDeclaration(node) {
73110             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
73111             enclosingFunctionFlags = ts.getFunctionFlags(node);
73112             var updated = factory.updateFunctionDeclaration(node, undefined, enclosingFunctionFlags & 1
73113                 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
73114                 : node.modifiers, enclosingFunctionFlags & 2
73115                 ? undefined
73116                 : node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1
73117                 ? transformAsyncGeneratorFunctionBody(node)
73118                 : transformFunctionBody(node));
73119             enclosingFunctionFlags = savedEnclosingFunctionFlags;
73120             return updated;
73121         }
73122         function visitArrowFunction(node) {
73123             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
73124             enclosingFunctionFlags = ts.getFunctionFlags(node);
73125             var updated = factory.updateArrowFunction(node, node.modifiers, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, node.equalsGreaterThanToken, transformFunctionBody(node));
73126             enclosingFunctionFlags = savedEnclosingFunctionFlags;
73127             return updated;
73128         }
73129         function visitFunctionExpression(node) {
73130             var savedEnclosingFunctionFlags = enclosingFunctionFlags;
73131             enclosingFunctionFlags = ts.getFunctionFlags(node);
73132             var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1
73133                 ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
73134                 : node.modifiers, enclosingFunctionFlags & 2
73135                 ? undefined
73136                 : node.asteriskToken, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, enclosingFunctionFlags & 2 && enclosingFunctionFlags & 1
73137                 ? transformAsyncGeneratorFunctionBody(node)
73138                 : transformFunctionBody(node));
73139             enclosingFunctionFlags = savedEnclosingFunctionFlags;
73140             return updated;
73141         }
73142         function transformAsyncGeneratorFunctionBody(node) {
73143             resumeLexicalEnvironment();
73144             var statements = [];
73145             var statementOffset = factory.copyPrologue(node.body.statements, statements, false, visitor);
73146             appendObjectRestAssignmentsIfNeeded(statements, node);
73147             var savedCapturedSuperProperties = capturedSuperProperties;
73148             var savedHasSuperElementAccess = hasSuperElementAccess;
73149             capturedSuperProperties = new ts.Set();
73150             hasSuperElementAccess = false;
73151             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)));
73152             var emitSuperHelpers = languageVersion >= 2 && resolver.getNodeCheckFlags(node) & (4096 | 2048);
73153             if (emitSuperHelpers) {
73154                 enableSubstitutionForAsyncMethodsWithSuper();
73155                 var variableStatement = ts.createSuperAccessVariableStatement(factory, resolver, node, capturedSuperProperties);
73156                 substitutedSuperAccessors[ts.getNodeId(variableStatement)] = true;
73157                 ts.insertStatementsAfterStandardPrologue(statements, [variableStatement]);
73158             }
73159             statements.push(returnStatement);
73160             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
73161             var block = factory.updateBlock(node.body, statements);
73162             if (emitSuperHelpers && hasSuperElementAccess) {
73163                 if (resolver.getNodeCheckFlags(node) & 4096) {
73164                     ts.addEmitHelper(block, ts.advancedAsyncSuperHelper);
73165                 }
73166                 else if (resolver.getNodeCheckFlags(node) & 2048) {
73167                     ts.addEmitHelper(block, ts.asyncSuperHelper);
73168                 }
73169             }
73170             capturedSuperProperties = savedCapturedSuperProperties;
73171             hasSuperElementAccess = savedHasSuperElementAccess;
73172             return block;
73173         }
73174         function transformFunctionBody(node) {
73175             var _a;
73176             resumeLexicalEnvironment();
73177             var statementOffset = 0;
73178             var statements = [];
73179             var body = (_a = ts.visitNode(node.body, visitor, ts.isConciseBody)) !== null && _a !== void 0 ? _a : factory.createBlock([]);
73180             if (ts.isBlock(body)) {
73181                 statementOffset = factory.copyPrologue(body.statements, statements, false, visitor);
73182             }
73183             ts.addRange(statements, appendObjectRestAssignmentsIfNeeded(undefined, node));
73184             var leadingStatements = endLexicalEnvironment();
73185             if (statementOffset > 0 || ts.some(statements) || ts.some(leadingStatements)) {
73186                 var block = factory.converters.convertToFunctionBlock(body, true);
73187                 ts.insertStatementsAfterStandardPrologue(statements, leadingStatements);
73188                 ts.addRange(statements, block.statements.slice(statementOffset));
73189                 return factory.updateBlock(block, ts.setTextRange(factory.createNodeArray(statements), block.statements));
73190             }
73191             return body;
73192         }
73193         function appendObjectRestAssignmentsIfNeeded(statements, node) {
73194             for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
73195                 var parameter = _a[_i];
73196                 if (parameter.transformFlags & 16384) {
73197                     var temp = factory.getGeneratedNameForNode(parameter);
73198                     var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1, temp, false, true);
73199                     if (ts.some(declarations)) {
73200                         var statement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList(declarations));
73201                         ts.setEmitFlags(statement, 1048576);
73202                         statements = ts.append(statements, statement);
73203                     }
73204                 }
73205             }
73206             return statements;
73207         }
73208         function enableSubstitutionForAsyncMethodsWithSuper() {
73209             if ((enabledSubstitutions & 1) === 0) {
73210                 enabledSubstitutions |= 1;
73211                 context.enableSubstitution(203);
73212                 context.enableSubstitution(201);
73213                 context.enableSubstitution(202);
73214                 context.enableEmitNotification(252);
73215                 context.enableEmitNotification(165);
73216                 context.enableEmitNotification(167);
73217                 context.enableEmitNotification(168);
73218                 context.enableEmitNotification(166);
73219                 context.enableEmitNotification(232);
73220             }
73221         }
73222         function onEmitNode(hint, node, emitCallback) {
73223             if (enabledSubstitutions & 1 && isSuperContainer(node)) {
73224                 var superContainerFlags = resolver.getNodeCheckFlags(node) & (2048 | 4096);
73225                 if (superContainerFlags !== enclosingSuperContainerFlags) {
73226                     var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
73227                     enclosingSuperContainerFlags = superContainerFlags;
73228                     previousOnEmitNode(hint, node, emitCallback);
73229                     enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
73230                     return;
73231                 }
73232             }
73233             else if (enabledSubstitutions && substitutedSuperAccessors[ts.getNodeId(node)]) {
73234                 var savedEnclosingSuperContainerFlags = enclosingSuperContainerFlags;
73235                 enclosingSuperContainerFlags = 0;
73236                 previousOnEmitNode(hint, node, emitCallback);
73237                 enclosingSuperContainerFlags = savedEnclosingSuperContainerFlags;
73238                 return;
73239             }
73240             previousOnEmitNode(hint, node, emitCallback);
73241         }
73242         function onSubstituteNode(hint, node) {
73243             node = previousOnSubstituteNode(hint, node);
73244             if (hint === 1 && enclosingSuperContainerFlags) {
73245                 return substituteExpression(node);
73246             }
73247             return node;
73248         }
73249         function substituteExpression(node) {
73250             switch (node.kind) {
73251                 case 201:
73252                     return substitutePropertyAccessExpression(node);
73253                 case 202:
73254                     return substituteElementAccessExpression(node);
73255                 case 203:
73256                     return substituteCallExpression(node);
73257             }
73258             return node;
73259         }
73260         function substitutePropertyAccessExpression(node) {
73261             if (node.expression.kind === 105) {
73262                 return ts.setTextRange(factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 | 32), node.name), node);
73263             }
73264             return node;
73265         }
73266         function substituteElementAccessExpression(node) {
73267             if (node.expression.kind === 105) {
73268                 return createSuperElementAccessInAsyncMethod(node.argumentExpression, node);
73269             }
73270             return node;
73271         }
73272         function substituteCallExpression(node) {
73273             var expression = node.expression;
73274             if (ts.isSuperProperty(expression)) {
73275                 var argumentExpression = ts.isPropertyAccessExpression(expression)
73276                     ? substitutePropertyAccessExpression(expression)
73277                     : substituteElementAccessExpression(expression);
73278                 return factory.createCallExpression(factory.createPropertyAccessExpression(argumentExpression, "call"), undefined, __spreadArray([
73279                     factory.createThis()
73280                 ], node.arguments));
73281             }
73282             return node;
73283         }
73284         function isSuperContainer(node) {
73285             var kind = node.kind;
73286             return kind === 252
73287                 || kind === 166
73288                 || kind === 165
73289                 || kind === 167
73290                 || kind === 168;
73291         }
73292         function createSuperElementAccessInAsyncMethod(argumentExpression, location) {
73293             if (enclosingSuperContainerFlags & 4096) {
73294                 return ts.setTextRange(factory.createPropertyAccessExpression(factory.createCallExpression(factory.createIdentifier("_superIndex"), undefined, [argumentExpression]), "value"), location);
73295             }
73296             else {
73297                 return ts.setTextRange(factory.createCallExpression(factory.createIdentifier("_superIndex"), undefined, [argumentExpression]), location);
73298             }
73299         }
73300     }
73301     ts.transformES2018 = transformES2018;
73302 })(ts || (ts = {}));
73303 var ts;
73304 (function (ts) {
73305     function transformES2019(context) {
73306         var factory = context.factory;
73307         return ts.chainBundle(context, transformSourceFile);
73308         function transformSourceFile(node) {
73309             if (node.isDeclarationFile) {
73310                 return node;
73311             }
73312             return ts.visitEachChild(node, visitor, context);
73313         }
73314         function visitor(node) {
73315             if ((node.transformFlags & 16) === 0) {
73316                 return node;
73317             }
73318             switch (node.kind) {
73319                 case 287:
73320                     return visitCatchClause(node);
73321                 default:
73322                     return ts.visitEachChild(node, visitor, context);
73323             }
73324         }
73325         function visitCatchClause(node) {
73326             if (!node.variableDeclaration) {
73327                 return factory.updateCatchClause(node, factory.createVariableDeclaration(factory.createTempVariable(undefined)), ts.visitNode(node.block, visitor, ts.isBlock));
73328             }
73329             return ts.visitEachChild(node, visitor, context);
73330         }
73331     }
73332     ts.transformES2019 = transformES2019;
73333 })(ts || (ts = {}));
73334 var ts;
73335 (function (ts) {
73336     function transformES2020(context) {
73337         var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration;
73338         return ts.chainBundle(context, transformSourceFile);
73339         function transformSourceFile(node) {
73340             if (node.isDeclarationFile) {
73341                 return node;
73342             }
73343             return ts.visitEachChild(node, visitor, context);
73344         }
73345         function visitor(node) {
73346             if ((node.transformFlags & 8) === 0) {
73347                 return node;
73348             }
73349             switch (node.kind) {
73350                 case 201:
73351                 case 202:
73352                 case 203:
73353                     if (node.flags & 32) {
73354                         var updated = visitOptionalExpression(node, false, false);
73355                         ts.Debug.assertNotNode(updated, ts.isSyntheticReference);
73356                         return updated;
73357                     }
73358                     return ts.visitEachChild(node, visitor, context);
73359                 case 216:
73360                     if (node.operatorToken.kind === 60) {
73361                         return transformNullishCoalescingExpression(node);
73362                     }
73363                     return ts.visitEachChild(node, visitor, context);
73364                 case 210:
73365                     return visitDeleteExpression(node);
73366                 default:
73367                     return ts.visitEachChild(node, visitor, context);
73368             }
73369         }
73370         function flattenChain(chain) {
73371             ts.Debug.assertNotNode(chain, ts.isNonNullChain);
73372             var links = [chain];
73373             while (!chain.questionDotToken && !ts.isTaggedTemplateExpression(chain)) {
73374                 chain = ts.cast(ts.skipPartiallyEmittedExpressions(chain.expression), ts.isOptionalChain);
73375                 ts.Debug.assertNotNode(chain, ts.isNonNullChain);
73376                 links.unshift(chain);
73377             }
73378             return { expression: chain.expression, chain: links };
73379         }
73380         function visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete) {
73381             var expression = visitNonOptionalExpression(node.expression, captureThisArg, isDelete);
73382             if (ts.isSyntheticReference(expression)) {
73383                 return factory.createSyntheticReferenceExpression(factory.updateParenthesizedExpression(node, expression.expression), expression.thisArg);
73384             }
73385             return factory.updateParenthesizedExpression(node, expression);
73386         }
73387         function visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete) {
73388             if (ts.isOptionalChain(node)) {
73389                 return visitOptionalExpression(node, captureThisArg, isDelete);
73390             }
73391             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
73392             ts.Debug.assertNotNode(expression, ts.isSyntheticReference);
73393             var thisArg;
73394             if (captureThisArg) {
73395                 if (!ts.isSimpleCopiableExpression(expression)) {
73396                     thisArg = factory.createTempVariable(hoistVariableDeclaration);
73397                     expression = factory.createAssignment(thisArg, expression);
73398                 }
73399                 else {
73400                     thisArg = expression;
73401                 }
73402             }
73403             expression = node.kind === 201
73404                 ? factory.updatePropertyAccessExpression(node, expression, ts.visitNode(node.name, visitor, ts.isIdentifier))
73405                 : factory.updateElementAccessExpression(node, expression, ts.visitNode(node.argumentExpression, visitor, ts.isExpression));
73406             return thisArg ? factory.createSyntheticReferenceExpression(expression, thisArg) : expression;
73407         }
73408         function visitNonOptionalCallExpression(node, captureThisArg) {
73409             if (ts.isOptionalChain(node)) {
73410                 return visitOptionalExpression(node, captureThisArg, false);
73411             }
73412             return ts.visitEachChild(node, visitor, context);
73413         }
73414         function visitNonOptionalExpression(node, captureThisArg, isDelete) {
73415             switch (node.kind) {
73416                 case 207: return visitNonOptionalParenthesizedExpression(node, captureThisArg, isDelete);
73417                 case 201:
73418                 case 202: return visitNonOptionalPropertyOrElementAccessExpression(node, captureThisArg, isDelete);
73419                 case 203: return visitNonOptionalCallExpression(node, captureThisArg);
73420                 default: return ts.visitNode(node, visitor, ts.isExpression);
73421             }
73422         }
73423         function visitOptionalExpression(node, captureThisArg, isDelete) {
73424             var _a = flattenChain(node), expression = _a.expression, chain = _a.chain;
73425             var left = visitNonOptionalExpression(expression, ts.isCallChain(chain[0]), false);
73426             var leftThisArg = ts.isSyntheticReference(left) ? left.thisArg : undefined;
73427             var leftExpression = ts.isSyntheticReference(left) ? left.expression : left;
73428             var capturedLeft = leftExpression;
73429             if (!ts.isSimpleCopiableExpression(leftExpression)) {
73430                 capturedLeft = factory.createTempVariable(hoistVariableDeclaration);
73431                 leftExpression = factory.createAssignment(capturedLeft, leftExpression);
73432             }
73433             var rightExpression = capturedLeft;
73434             var thisArg;
73435             for (var i = 0; i < chain.length; i++) {
73436                 var segment = chain[i];
73437                 switch (segment.kind) {
73438                     case 201:
73439                     case 202:
73440                         if (i === chain.length - 1 && captureThisArg) {
73441                             if (!ts.isSimpleCopiableExpression(rightExpression)) {
73442                                 thisArg = factory.createTempVariable(hoistVariableDeclaration);
73443                                 rightExpression = factory.createAssignment(thisArg, rightExpression);
73444                             }
73445                             else {
73446                                 thisArg = rightExpression;
73447                             }
73448                         }
73449                         rightExpression = segment.kind === 201
73450                             ? factory.createPropertyAccessExpression(rightExpression, ts.visitNode(segment.name, visitor, ts.isIdentifier))
73451                             : factory.createElementAccessExpression(rightExpression, ts.visitNode(segment.argumentExpression, visitor, ts.isExpression));
73452                         break;
73453                     case 203:
73454                         if (i === 0 && leftThisArg) {
73455                             rightExpression = factory.createFunctionCallCall(rightExpression, leftThisArg.kind === 105 ? factory.createThis() : leftThisArg, ts.visitNodes(segment.arguments, visitor, ts.isExpression));
73456                         }
73457                         else {
73458                             rightExpression = factory.createCallExpression(rightExpression, undefined, ts.visitNodes(segment.arguments, visitor, ts.isExpression));
73459                         }
73460                         break;
73461                 }
73462                 ts.setOriginalNode(rightExpression, segment);
73463             }
73464             var target = isDelete
73465                 ? factory.createConditionalExpression(createNotNullCondition(leftExpression, capturedLeft, true), undefined, factory.createTrue(), undefined, factory.createDeleteExpression(rightExpression))
73466                 : factory.createConditionalExpression(createNotNullCondition(leftExpression, capturedLeft, true), undefined, factory.createVoidZero(), undefined, rightExpression);
73467             ts.setTextRange(target, node);
73468             return thisArg ? factory.createSyntheticReferenceExpression(target, thisArg) : target;
73469         }
73470         function createNotNullCondition(left, right, invert) {
73471             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()));
73472         }
73473         function transformNullishCoalescingExpression(node) {
73474             var left = ts.visitNode(node.left, visitor, ts.isExpression);
73475             var right = left;
73476             if (!ts.isSimpleCopiableExpression(left)) {
73477                 right = factory.createTempVariable(hoistVariableDeclaration);
73478                 left = factory.createAssignment(right, left);
73479             }
73480             return ts.setTextRange(factory.createConditionalExpression(createNotNullCondition(left, right), undefined, right, undefined, ts.visitNode(node.right, visitor, ts.isExpression)), node);
73481         }
73482         function visitDeleteExpression(node) {
73483             return ts.isOptionalChain(ts.skipParentheses(node.expression))
73484                 ? ts.setOriginalNode(visitNonOptionalExpression(node.expression, false, true), node)
73485                 : factory.updateDeleteExpression(node, ts.visitNode(node.expression, visitor, ts.isExpression));
73486         }
73487     }
73488     ts.transformES2020 = transformES2020;
73489 })(ts || (ts = {}));
73490 var ts;
73491 (function (ts) {
73492     function transformESNext(context) {
73493         var hoistVariableDeclaration = context.hoistVariableDeclaration, factory = context.factory;
73494         return ts.chainBundle(context, transformSourceFile);
73495         function transformSourceFile(node) {
73496             if (node.isDeclarationFile) {
73497                 return node;
73498             }
73499             return ts.visitEachChild(node, visitor, context);
73500         }
73501         function visitor(node) {
73502             if ((node.transformFlags & 4) === 0) {
73503                 return node;
73504             }
73505             switch (node.kind) {
73506                 case 216:
73507                     var binaryExpression = node;
73508                     if (ts.isLogicalOrCoalescingAssignmentExpression(binaryExpression)) {
73509                         return transformLogicalAssignment(binaryExpression);
73510                     }
73511                 default:
73512                     return ts.visitEachChild(node, visitor, context);
73513             }
73514         }
73515         function transformLogicalAssignment(binaryExpression) {
73516             var operator = binaryExpression.operatorToken;
73517             var nonAssignmentOperator = ts.getNonAssignmentOperatorForCompoundAssignment(operator.kind);
73518             var left = ts.skipParentheses(ts.visitNode(binaryExpression.left, visitor, ts.isLeftHandSideExpression));
73519             var assignmentTarget = left;
73520             var right = ts.skipParentheses(ts.visitNode(binaryExpression.right, visitor, ts.isExpression));
73521             if (ts.isAccessExpression(left)) {
73522                 var propertyAccessTargetSimpleCopiable = ts.isSimpleCopiableExpression(left.expression);
73523                 var propertyAccessTarget = propertyAccessTargetSimpleCopiable ? left.expression :
73524                     factory.createTempVariable(hoistVariableDeclaration);
73525                 var propertyAccessTargetAssignment = propertyAccessTargetSimpleCopiable ? left.expression : factory.createAssignment(propertyAccessTarget, left.expression);
73526                 if (ts.isPropertyAccessExpression(left)) {
73527                     assignmentTarget = factory.createPropertyAccessExpression(propertyAccessTarget, left.name);
73528                     left = factory.createPropertyAccessExpression(propertyAccessTargetAssignment, left.name);
73529                 }
73530                 else {
73531                     var elementAccessArgumentSimpleCopiable = ts.isSimpleCopiableExpression(left.argumentExpression);
73532                     var elementAccessArgument = elementAccessArgumentSimpleCopiable ? left.argumentExpression :
73533                         factory.createTempVariable(hoistVariableDeclaration);
73534                     assignmentTarget = factory.createElementAccessExpression(propertyAccessTarget, elementAccessArgument);
73535                     left = factory.createElementAccessExpression(propertyAccessTargetAssignment, elementAccessArgumentSimpleCopiable ? left.argumentExpression : factory.createAssignment(elementAccessArgument, left.argumentExpression));
73536                 }
73537             }
73538             return factory.createBinaryExpression(left, nonAssignmentOperator, factory.createParenthesizedExpression(factory.createAssignment(assignmentTarget, right)));
73539         }
73540     }
73541     ts.transformESNext = transformESNext;
73542 })(ts || (ts = {}));
73543 var ts;
73544 (function (ts) {
73545     function transformJsx(context) {
73546         var factory = context.factory, emitHelpers = context.getEmitHelperFactory;
73547         var compilerOptions = context.getCompilerOptions();
73548         var currentSourceFile;
73549         var currentFileState;
73550         return ts.chainBundle(context, transformSourceFile);
73551         function getCurrentFileNameExpression() {
73552             if (currentFileState.filenameDeclaration) {
73553                 return currentFileState.filenameDeclaration.name;
73554             }
73555             var declaration = factory.createVariableDeclaration(factory.createUniqueName("_jsxFileName", 16 | 32), undefined, undefined, factory.createStringLiteral(currentSourceFile.fileName));
73556             currentFileState.filenameDeclaration = declaration;
73557             return currentFileState.filenameDeclaration.name;
73558         }
73559         function getJsxFactoryCalleePrimitive(childrenLength) {
73560             return compilerOptions.jsx === 5 ? "jsxDEV" : childrenLength > 1 ? "jsxs" : "jsx";
73561         }
73562         function getJsxFactoryCallee(childrenLength) {
73563             var type = getJsxFactoryCalleePrimitive(childrenLength);
73564             return getImplicitImportForName(type);
73565         }
73566         function getImplicitJsxFragmentReference() {
73567             return getImplicitImportForName("Fragment");
73568         }
73569         function getImplicitImportForName(name) {
73570             var _a, _b;
73571             var importSource = name === "createElement"
73572                 ? currentFileState.importSpecifier
73573                 : ts.getJSXRuntimeImport(currentFileState.importSpecifier, compilerOptions);
73574             var existing = (_b = (_a = currentFileState.utilizedImplicitRuntimeImports) === null || _a === void 0 ? void 0 : _a.get(importSource)) === null || _b === void 0 ? void 0 : _b.get(name);
73575             if (existing) {
73576                 return existing.name;
73577             }
73578             if (!currentFileState.utilizedImplicitRuntimeImports) {
73579                 currentFileState.utilizedImplicitRuntimeImports = ts.createMap();
73580             }
73581             var specifierSourceImports = currentFileState.utilizedImplicitRuntimeImports.get(importSource);
73582             if (!specifierSourceImports) {
73583                 specifierSourceImports = ts.createMap();
73584                 currentFileState.utilizedImplicitRuntimeImports.set(importSource, specifierSourceImports);
73585             }
73586             var generatedName = factory.createUniqueName("_" + name, 16 | 32 | 64);
73587             var specifier = factory.createImportSpecifier(factory.createIdentifier(name), generatedName);
73588             generatedName.generatedImportReference = specifier;
73589             specifierSourceImports.set(name, specifier);
73590             return generatedName;
73591         }
73592         function transformSourceFile(node) {
73593             if (node.isDeclarationFile) {
73594                 return node;
73595             }
73596             currentSourceFile = node;
73597             currentFileState = {};
73598             currentFileState.importSpecifier = ts.getJSXImplicitImportBase(compilerOptions, node);
73599             var visited = ts.visitEachChild(node, visitor, context);
73600             ts.addEmitHelpers(visited, context.readEmitHelpers());
73601             var statements = visited.statements;
73602             if (currentFileState.filenameDeclaration) {
73603                 statements = ts.insertStatementAfterCustomPrologue(statements.slice(), factory.createVariableStatement(undefined, factory.createVariableDeclarationList([currentFileState.filenameDeclaration], 2)));
73604             }
73605             if (currentFileState.utilizedImplicitRuntimeImports) {
73606                 for (var _i = 0, _a = ts.arrayFrom(currentFileState.utilizedImplicitRuntimeImports.entries()); _i < _a.length; _i++) {
73607                     var _b = _a[_i], importSource = _b[0], importSpecifiersMap = _b[1];
73608                     if (ts.isExternalModule(node)) {
73609                         var importStatement = factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamedImports(ts.arrayFrom(importSpecifiersMap.values()))), factory.createStringLiteral(importSource));
73610                         ts.setParentRecursive(importStatement, false);
73611                         statements = ts.insertStatementAfterCustomPrologue(statements.slice(), importStatement);
73612                     }
73613                     else if (ts.isExternalOrCommonJsModule(node)) {
73614                         var requireStatement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
73615                             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)]))
73616                         ], 2));
73617                         ts.setParentRecursive(requireStatement, false);
73618                         statements = ts.insertStatementAfterCustomPrologue(statements.slice(), requireStatement);
73619                     }
73620                     else {
73621                     }
73622                 }
73623             }
73624             if (statements !== visited.statements) {
73625                 visited = factory.updateSourceFile(visited, statements);
73626             }
73627             currentFileState = undefined;
73628             return visited;
73629         }
73630         function visitor(node) {
73631             if (node.transformFlags & 2) {
73632                 return visitorWorker(node);
73633             }
73634             else {
73635                 return node;
73636             }
73637         }
73638         function visitorWorker(node) {
73639             switch (node.kind) {
73640                 case 273:
73641                     return visitJsxElement(node, false);
73642                 case 274:
73643                     return visitJsxSelfClosingElement(node, false);
73644                 case 277:
73645                     return visitJsxFragment(node, false);
73646                 case 283:
73647                     return visitJsxExpression(node);
73648                 default:
73649                     return ts.visitEachChild(node, visitor, context);
73650             }
73651         }
73652         function transformJsxChildToExpression(node) {
73653             switch (node.kind) {
73654                 case 11:
73655                     return visitJsxText(node);
73656                 case 283:
73657                     return visitJsxExpression(node);
73658                 case 273:
73659                     return visitJsxElement(node, true);
73660                 case 274:
73661                     return visitJsxSelfClosingElement(node, true);
73662                 case 277:
73663                     return visitJsxFragment(node, true);
73664                 default:
73665                     return ts.Debug.failBadSyntaxKind(node);
73666             }
73667         }
73668         function hasKeyAfterPropsSpread(node) {
73669             var spread = false;
73670             for (var _i = 0, _a = node.attributes.properties; _i < _a.length; _i++) {
73671                 var elem = _a[_i];
73672                 if (ts.isJsxSpreadAttribute(elem)) {
73673                     spread = true;
73674                 }
73675                 else if (spread && ts.isJsxAttribute(elem) && elem.name.escapedText === "key") {
73676                     return true;
73677                 }
73678             }
73679             return false;
73680         }
73681         function shouldUseCreateElement(node) {
73682             return currentFileState.importSpecifier === undefined || hasKeyAfterPropsSpread(node);
73683         }
73684         function visitJsxElement(node, isChild) {
73685             var tagTransform = shouldUseCreateElement(node.openingElement) ? visitJsxOpeningLikeElementCreateElement : visitJsxOpeningLikeElementJSX;
73686             return tagTransform(node.openingElement, node.children, isChild, node);
73687         }
73688         function visitJsxSelfClosingElement(node, isChild) {
73689             var tagTransform = shouldUseCreateElement(node) ? visitJsxOpeningLikeElementCreateElement : visitJsxOpeningLikeElementJSX;
73690             return tagTransform(node, undefined, isChild, node);
73691         }
73692         function visitJsxFragment(node, isChild) {
73693             var tagTransform = currentFileState.importSpecifier === undefined ? visitJsxOpeningFragmentCreateElement : visitJsxOpeningFragmentJSX;
73694             return tagTransform(node.openingFragment, node.children, isChild, node);
73695         }
73696         function convertJsxChildrenToChildrenPropObject(children) {
73697             var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
73698             if (ts.length(nonWhitespaceChildren) === 1) {
73699                 var result_13 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
73700                 return result_13 && factory.createObjectLiteralExpression([
73701                     factory.createPropertyAssignment("children", result_13)
73702                 ]);
73703             }
73704             var result = ts.mapDefined(children, transformJsxChildToExpression);
73705             return !result.length ? undefined : factory.createObjectLiteralExpression([
73706                 factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result))
73707             ]);
73708         }
73709         function visitJsxOpeningLikeElementJSX(node, children, isChild, location) {
73710             var tagName = getTagName(node);
73711             var objectProperties;
73712             var keyAttr = ts.find(node.attributes.properties, function (p) { return !!p.name && ts.isIdentifier(p.name) && p.name.escapedText === "key"; });
73713             var attrs = keyAttr ? ts.filter(node.attributes.properties, function (p) { return p !== keyAttr; }) : node.attributes.properties;
73714             var segments = [];
73715             if (attrs.length) {
73716                 segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
73717                     ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
73718                     : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
73719                 if (ts.isJsxSpreadAttribute(attrs[0])) {
73720                     segments.unshift(factory.createObjectLiteralExpression());
73721                 }
73722             }
73723             if (children && children.length) {
73724                 var result = convertJsxChildrenToChildrenPropObject(children);
73725                 if (result) {
73726                     segments.push(result);
73727                 }
73728             }
73729             if (segments.length === 0) {
73730                 objectProperties = factory.createObjectLiteralExpression([]);
73731             }
73732             else {
73733                 objectProperties = ts.singleOrUndefined(segments) || emitHelpers().createAssignHelper(segments);
73734             }
73735             return visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, ts.length(ts.getSemanticJsxChildren(children || ts.emptyArray)), isChild, location);
73736         }
73737         function visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, childrenLength, isChild, location) {
73738             var args = [tagName, objectProperties, !keyAttr ? factory.createVoidZero() : transformJsxAttributeInitializer(keyAttr.initializer)];
73739             if (compilerOptions.jsx === 5) {
73740                 var originalFile = ts.getOriginalNode(currentSourceFile);
73741                 if (originalFile && ts.isSourceFile(originalFile)) {
73742                     args.push(childrenLength > 1 ? factory.createTrue() : factory.createFalse());
73743                     var lineCol = ts.getLineAndCharacterOfPosition(originalFile, location.pos);
73744                     args.push(factory.createObjectLiteralExpression([
73745                         factory.createPropertyAssignment("fileName", getCurrentFileNameExpression()),
73746                         factory.createPropertyAssignment("lineNumber", factory.createNumericLiteral(lineCol.line + 1)),
73747                         factory.createPropertyAssignment("columnNumber", factory.createNumericLiteral(lineCol.character + 1))
73748                     ]));
73749                     args.push(factory.createThis());
73750                 }
73751             }
73752             var element = ts.setTextRange(factory.createCallExpression(getJsxFactoryCallee(childrenLength), undefined, args), location);
73753             if (isChild) {
73754                 ts.startOnNewLine(element);
73755             }
73756             return element;
73757         }
73758         function visitJsxOpeningLikeElementCreateElement(node, children, isChild, location) {
73759             var tagName = getTagName(node);
73760             var objectProperties;
73761             var attrs = node.attributes.properties;
73762             if (attrs.length === 0) {
73763                 objectProperties = factory.createNull();
73764             }
73765             else {
73766                 var segments = ts.flatten(ts.spanMap(attrs, ts.isJsxSpreadAttribute, function (attrs, isSpread) { return isSpread
73767                     ? ts.map(attrs, transformJsxSpreadAttributeToExpression)
73768                     : factory.createObjectLiteralExpression(ts.map(attrs, transformJsxAttributeToObjectLiteralElement)); }));
73769                 if (ts.isJsxSpreadAttribute(attrs[0])) {
73770                     segments.unshift(factory.createObjectLiteralExpression());
73771                 }
73772                 objectProperties = ts.singleOrUndefined(segments);
73773                 if (!objectProperties) {
73774                     objectProperties = emitHelpers().createAssignHelper(segments);
73775                 }
73776             }
73777             var callee = currentFileState.importSpecifier === undefined
73778                 ? ts.createJsxFactoryExpression(factory, context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, node)
73779                 : getImplicitImportForName("createElement");
73780             var element = ts.createExpressionForJsxElement(factory, callee, tagName, objectProperties, ts.mapDefined(children, transformJsxChildToExpression), location);
73781             if (isChild) {
73782                 ts.startOnNewLine(element);
73783             }
73784             return element;
73785         }
73786         function visitJsxOpeningFragmentJSX(_node, children, isChild, location) {
73787             var childrenProps;
73788             if (children && children.length) {
73789                 var result = convertJsxChildrenToChildrenPropObject(children);
73790                 if (result) {
73791                     childrenProps = result;
73792                 }
73793             }
73794             return visitJsxOpeningLikeElementOrFragmentJSX(getImplicitJsxFragmentReference(), childrenProps || factory.createObjectLiteralExpression([]), undefined, ts.length(ts.getSemanticJsxChildren(children)), isChild, location);
73795         }
73796         function visitJsxOpeningFragmentCreateElement(node, children, isChild, location) {
73797             var element = ts.createExpressionForJsxFragment(factory, context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), context.getEmitResolver().getJsxFragmentFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, ts.mapDefined(children, transformJsxChildToExpression), node, location);
73798             if (isChild) {
73799                 ts.startOnNewLine(element);
73800             }
73801             return element;
73802         }
73803         function transformJsxSpreadAttributeToExpression(node) {
73804             return ts.visitNode(node.expression, visitor, ts.isExpression);
73805         }
73806         function transformJsxAttributeToObjectLiteralElement(node) {
73807             var name = getAttributeName(node);
73808             var expression = transformJsxAttributeInitializer(node.initializer);
73809             return factory.createPropertyAssignment(name, expression);
73810         }
73811         function transformJsxAttributeInitializer(node) {
73812             if (node === undefined) {
73813                 return factory.createTrue();
73814             }
73815             else if (node.kind === 10) {
73816                 var singleQuote = node.singleQuote !== undefined ? node.singleQuote : !ts.isStringDoubleQuoted(node, currentSourceFile);
73817                 var literal = factory.createStringLiteral(tryDecodeEntities(node.text) || node.text, singleQuote);
73818                 return ts.setTextRange(literal, node);
73819             }
73820             else if (node.kind === 283) {
73821                 if (node.expression === undefined) {
73822                     return factory.createTrue();
73823                 }
73824                 return ts.visitNode(node.expression, visitor, ts.isExpression);
73825             }
73826             else {
73827                 return ts.Debug.failBadSyntaxKind(node);
73828             }
73829         }
73830         function visitJsxText(node) {
73831             var fixed = fixupWhitespaceAndDecodeEntities(node.text);
73832             return fixed === undefined ? undefined : factory.createStringLiteral(fixed);
73833         }
73834         function fixupWhitespaceAndDecodeEntities(text) {
73835             var acc;
73836             var firstNonWhitespace = 0;
73837             var lastNonWhitespace = -1;
73838             for (var i = 0; i < text.length; i++) {
73839                 var c = text.charCodeAt(i);
73840                 if (ts.isLineBreak(c)) {
73841                     if (firstNonWhitespace !== -1 && lastNonWhitespace !== -1) {
73842                         acc = addLineOfJsxText(acc, text.substr(firstNonWhitespace, lastNonWhitespace - firstNonWhitespace + 1));
73843                     }
73844                     firstNonWhitespace = -1;
73845                 }
73846                 else if (!ts.isWhiteSpaceSingleLine(c)) {
73847                     lastNonWhitespace = i;
73848                     if (firstNonWhitespace === -1) {
73849                         firstNonWhitespace = i;
73850                     }
73851                 }
73852             }
73853             return firstNonWhitespace !== -1
73854                 ? addLineOfJsxText(acc, text.substr(firstNonWhitespace))
73855                 : acc;
73856         }
73857         function addLineOfJsxText(acc, trimmedLine) {
73858             var decoded = decodeEntities(trimmedLine);
73859             return acc === undefined ? decoded : acc + " " + decoded;
73860         }
73861         function decodeEntities(text) {
73862             return text.replace(/&((#((\d+)|x([\da-fA-F]+)))|(\w+));/g, function (match, _all, _number, _digits, decimal, hex, word) {
73863                 if (decimal) {
73864                     return ts.utf16EncodeAsString(parseInt(decimal, 10));
73865                 }
73866                 else if (hex) {
73867                     return ts.utf16EncodeAsString(parseInt(hex, 16));
73868                 }
73869                 else {
73870                     var ch = entities.get(word);
73871                     return ch ? ts.utf16EncodeAsString(ch) : match;
73872                 }
73873             });
73874         }
73875         function tryDecodeEntities(text) {
73876             var decoded = decodeEntities(text);
73877             return decoded === text ? undefined : decoded;
73878         }
73879         function getTagName(node) {
73880             if (node.kind === 273) {
73881                 return getTagName(node.openingElement);
73882             }
73883             else {
73884                 var name = node.tagName;
73885                 if (ts.isIdentifier(name) && ts.isIntrinsicJsxName(name.escapedText)) {
73886                     return factory.createStringLiteral(ts.idText(name));
73887                 }
73888                 else {
73889                     return ts.createExpressionFromEntityName(factory, name);
73890                 }
73891             }
73892         }
73893         function getAttributeName(node) {
73894             var name = node.name;
73895             var text = ts.idText(name);
73896             if (/^[A-Za-z_]\w*$/.test(text)) {
73897                 return name;
73898             }
73899             else {
73900                 return factory.createStringLiteral(text);
73901             }
73902         }
73903         function visitJsxExpression(node) {
73904             return ts.visitNode(node.expression, visitor, ts.isExpression);
73905         }
73906     }
73907     ts.transformJsx = transformJsx;
73908     var entities = new ts.Map(ts.getEntries({
73909         quot: 0x0022,
73910         amp: 0x0026,
73911         apos: 0x0027,
73912         lt: 0x003C,
73913         gt: 0x003E,
73914         nbsp: 0x00A0,
73915         iexcl: 0x00A1,
73916         cent: 0x00A2,
73917         pound: 0x00A3,
73918         curren: 0x00A4,
73919         yen: 0x00A5,
73920         brvbar: 0x00A6,
73921         sect: 0x00A7,
73922         uml: 0x00A8,
73923         copy: 0x00A9,
73924         ordf: 0x00AA,
73925         laquo: 0x00AB,
73926         not: 0x00AC,
73927         shy: 0x00AD,
73928         reg: 0x00AE,
73929         macr: 0x00AF,
73930         deg: 0x00B0,
73931         plusmn: 0x00B1,
73932         sup2: 0x00B2,
73933         sup3: 0x00B3,
73934         acute: 0x00B4,
73935         micro: 0x00B5,
73936         para: 0x00B6,
73937         middot: 0x00B7,
73938         cedil: 0x00B8,
73939         sup1: 0x00B9,
73940         ordm: 0x00BA,
73941         raquo: 0x00BB,
73942         frac14: 0x00BC,
73943         frac12: 0x00BD,
73944         frac34: 0x00BE,
73945         iquest: 0x00BF,
73946         Agrave: 0x00C0,
73947         Aacute: 0x00C1,
73948         Acirc: 0x00C2,
73949         Atilde: 0x00C3,
73950         Auml: 0x00C4,
73951         Aring: 0x00C5,
73952         AElig: 0x00C6,
73953         Ccedil: 0x00C7,
73954         Egrave: 0x00C8,
73955         Eacute: 0x00C9,
73956         Ecirc: 0x00CA,
73957         Euml: 0x00CB,
73958         Igrave: 0x00CC,
73959         Iacute: 0x00CD,
73960         Icirc: 0x00CE,
73961         Iuml: 0x00CF,
73962         ETH: 0x00D0,
73963         Ntilde: 0x00D1,
73964         Ograve: 0x00D2,
73965         Oacute: 0x00D3,
73966         Ocirc: 0x00D4,
73967         Otilde: 0x00D5,
73968         Ouml: 0x00D6,
73969         times: 0x00D7,
73970         Oslash: 0x00D8,
73971         Ugrave: 0x00D9,
73972         Uacute: 0x00DA,
73973         Ucirc: 0x00DB,
73974         Uuml: 0x00DC,
73975         Yacute: 0x00DD,
73976         THORN: 0x00DE,
73977         szlig: 0x00DF,
73978         agrave: 0x00E0,
73979         aacute: 0x00E1,
73980         acirc: 0x00E2,
73981         atilde: 0x00E3,
73982         auml: 0x00E4,
73983         aring: 0x00E5,
73984         aelig: 0x00E6,
73985         ccedil: 0x00E7,
73986         egrave: 0x00E8,
73987         eacute: 0x00E9,
73988         ecirc: 0x00EA,
73989         euml: 0x00EB,
73990         igrave: 0x00EC,
73991         iacute: 0x00ED,
73992         icirc: 0x00EE,
73993         iuml: 0x00EF,
73994         eth: 0x00F0,
73995         ntilde: 0x00F1,
73996         ograve: 0x00F2,
73997         oacute: 0x00F3,
73998         ocirc: 0x00F4,
73999         otilde: 0x00F5,
74000         ouml: 0x00F6,
74001         divide: 0x00F7,
74002         oslash: 0x00F8,
74003         ugrave: 0x00F9,
74004         uacute: 0x00FA,
74005         ucirc: 0x00FB,
74006         uuml: 0x00FC,
74007         yacute: 0x00FD,
74008         thorn: 0x00FE,
74009         yuml: 0x00FF,
74010         OElig: 0x0152,
74011         oelig: 0x0153,
74012         Scaron: 0x0160,
74013         scaron: 0x0161,
74014         Yuml: 0x0178,
74015         fnof: 0x0192,
74016         circ: 0x02C6,
74017         tilde: 0x02DC,
74018         Alpha: 0x0391,
74019         Beta: 0x0392,
74020         Gamma: 0x0393,
74021         Delta: 0x0394,
74022         Epsilon: 0x0395,
74023         Zeta: 0x0396,
74024         Eta: 0x0397,
74025         Theta: 0x0398,
74026         Iota: 0x0399,
74027         Kappa: 0x039A,
74028         Lambda: 0x039B,
74029         Mu: 0x039C,
74030         Nu: 0x039D,
74031         Xi: 0x039E,
74032         Omicron: 0x039F,
74033         Pi: 0x03A0,
74034         Rho: 0x03A1,
74035         Sigma: 0x03A3,
74036         Tau: 0x03A4,
74037         Upsilon: 0x03A5,
74038         Phi: 0x03A6,
74039         Chi: 0x03A7,
74040         Psi: 0x03A8,
74041         Omega: 0x03A9,
74042         alpha: 0x03B1,
74043         beta: 0x03B2,
74044         gamma: 0x03B3,
74045         delta: 0x03B4,
74046         epsilon: 0x03B5,
74047         zeta: 0x03B6,
74048         eta: 0x03B7,
74049         theta: 0x03B8,
74050         iota: 0x03B9,
74051         kappa: 0x03BA,
74052         lambda: 0x03BB,
74053         mu: 0x03BC,
74054         nu: 0x03BD,
74055         xi: 0x03BE,
74056         omicron: 0x03BF,
74057         pi: 0x03C0,
74058         rho: 0x03C1,
74059         sigmaf: 0x03C2,
74060         sigma: 0x03C3,
74061         tau: 0x03C4,
74062         upsilon: 0x03C5,
74063         phi: 0x03C6,
74064         chi: 0x03C7,
74065         psi: 0x03C8,
74066         omega: 0x03C9,
74067         thetasym: 0x03D1,
74068         upsih: 0x03D2,
74069         piv: 0x03D6,
74070         ensp: 0x2002,
74071         emsp: 0x2003,
74072         thinsp: 0x2009,
74073         zwnj: 0x200C,
74074         zwj: 0x200D,
74075         lrm: 0x200E,
74076         rlm: 0x200F,
74077         ndash: 0x2013,
74078         mdash: 0x2014,
74079         lsquo: 0x2018,
74080         rsquo: 0x2019,
74081         sbquo: 0x201A,
74082         ldquo: 0x201C,
74083         rdquo: 0x201D,
74084         bdquo: 0x201E,
74085         dagger: 0x2020,
74086         Dagger: 0x2021,
74087         bull: 0x2022,
74088         hellip: 0x2026,
74089         permil: 0x2030,
74090         prime: 0x2032,
74091         Prime: 0x2033,
74092         lsaquo: 0x2039,
74093         rsaquo: 0x203A,
74094         oline: 0x203E,
74095         frasl: 0x2044,
74096         euro: 0x20AC,
74097         image: 0x2111,
74098         weierp: 0x2118,
74099         real: 0x211C,
74100         trade: 0x2122,
74101         alefsym: 0x2135,
74102         larr: 0x2190,
74103         uarr: 0x2191,
74104         rarr: 0x2192,
74105         darr: 0x2193,
74106         harr: 0x2194,
74107         crarr: 0x21B5,
74108         lArr: 0x21D0,
74109         uArr: 0x21D1,
74110         rArr: 0x21D2,
74111         dArr: 0x21D3,
74112         hArr: 0x21D4,
74113         forall: 0x2200,
74114         part: 0x2202,
74115         exist: 0x2203,
74116         empty: 0x2205,
74117         nabla: 0x2207,
74118         isin: 0x2208,
74119         notin: 0x2209,
74120         ni: 0x220B,
74121         prod: 0x220F,
74122         sum: 0x2211,
74123         minus: 0x2212,
74124         lowast: 0x2217,
74125         radic: 0x221A,
74126         prop: 0x221D,
74127         infin: 0x221E,
74128         ang: 0x2220,
74129         and: 0x2227,
74130         or: 0x2228,
74131         cap: 0x2229,
74132         cup: 0x222A,
74133         int: 0x222B,
74134         there4: 0x2234,
74135         sim: 0x223C,
74136         cong: 0x2245,
74137         asymp: 0x2248,
74138         ne: 0x2260,
74139         equiv: 0x2261,
74140         le: 0x2264,
74141         ge: 0x2265,
74142         sub: 0x2282,
74143         sup: 0x2283,
74144         nsub: 0x2284,
74145         sube: 0x2286,
74146         supe: 0x2287,
74147         oplus: 0x2295,
74148         otimes: 0x2297,
74149         perp: 0x22A5,
74150         sdot: 0x22C5,
74151         lceil: 0x2308,
74152         rceil: 0x2309,
74153         lfloor: 0x230A,
74154         rfloor: 0x230B,
74155         lang: 0x2329,
74156         rang: 0x232A,
74157         loz: 0x25CA,
74158         spades: 0x2660,
74159         clubs: 0x2663,
74160         hearts: 0x2665,
74161         diams: 0x2666
74162     }));
74163 })(ts || (ts = {}));
74164 var ts;
74165 (function (ts) {
74166     function transformES2016(context) {
74167         var factory = context.factory, hoistVariableDeclaration = context.hoistVariableDeclaration;
74168         return ts.chainBundle(context, transformSourceFile);
74169         function transformSourceFile(node) {
74170             if (node.isDeclarationFile) {
74171                 return node;
74172             }
74173             return ts.visitEachChild(node, visitor, context);
74174         }
74175         function visitor(node) {
74176             if ((node.transformFlags & 128) === 0) {
74177                 return node;
74178             }
74179             switch (node.kind) {
74180                 case 216:
74181                     return visitBinaryExpression(node);
74182                 default:
74183                     return ts.visitEachChild(node, visitor, context);
74184             }
74185         }
74186         function visitBinaryExpression(node) {
74187             switch (node.operatorToken.kind) {
74188                 case 66:
74189                     return visitExponentiationAssignmentExpression(node);
74190                 case 42:
74191                     return visitExponentiationExpression(node);
74192                 default:
74193                     return ts.visitEachChild(node, visitor, context);
74194             }
74195         }
74196         function visitExponentiationAssignmentExpression(node) {
74197             var target;
74198             var value;
74199             var left = ts.visitNode(node.left, visitor, ts.isExpression);
74200             var right = ts.visitNode(node.right, visitor, ts.isExpression);
74201             if (ts.isElementAccessExpression(left)) {
74202                 var expressionTemp = factory.createTempVariable(hoistVariableDeclaration);
74203                 var argumentExpressionTemp = factory.createTempVariable(hoistVariableDeclaration);
74204                 target = ts.setTextRange(factory.createElementAccessExpression(ts.setTextRange(factory.createAssignment(expressionTemp, left.expression), left.expression), ts.setTextRange(factory.createAssignment(argumentExpressionTemp, left.argumentExpression), left.argumentExpression)), left);
74205                 value = ts.setTextRange(factory.createElementAccessExpression(expressionTemp, argumentExpressionTemp), left);
74206             }
74207             else if (ts.isPropertyAccessExpression(left)) {
74208                 var expressionTemp = factory.createTempVariable(hoistVariableDeclaration);
74209                 target = ts.setTextRange(factory.createPropertyAccessExpression(ts.setTextRange(factory.createAssignment(expressionTemp, left.expression), left.expression), left.name), left);
74210                 value = ts.setTextRange(factory.createPropertyAccessExpression(expressionTemp, left.name), left);
74211             }
74212             else {
74213                 target = left;
74214                 value = left;
74215             }
74216             return ts.setTextRange(factory.createAssignment(target, ts.setTextRange(factory.createGlobalMethodCall("Math", "pow", [value, right]), node)), node);
74217         }
74218         function visitExponentiationExpression(node) {
74219             var left = ts.visitNode(node.left, visitor, ts.isExpression);
74220             var right = ts.visitNode(node.right, visitor, ts.isExpression);
74221             return ts.setTextRange(factory.createGlobalMethodCall("Math", "pow", [left, right]), node);
74222         }
74223     }
74224     ts.transformES2016 = transformES2016;
74225 })(ts || (ts = {}));
74226 var ts;
74227 (function (ts) {
74228     function transformES2015(context) {
74229         var factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
74230         var compilerOptions = context.getCompilerOptions();
74231         var resolver = context.getEmitResolver();
74232         var previousOnSubstituteNode = context.onSubstituteNode;
74233         var previousOnEmitNode = context.onEmitNode;
74234         context.onEmitNode = onEmitNode;
74235         context.onSubstituteNode = onSubstituteNode;
74236         var currentSourceFile;
74237         var currentText;
74238         var hierarchyFacts;
74239         var taggedTemplateStringDeclarations;
74240         function recordTaggedTemplateString(temp) {
74241             taggedTemplateStringDeclarations = ts.append(taggedTemplateStringDeclarations, factory.createVariableDeclaration(temp));
74242         }
74243         var convertedLoopState;
74244         var enabledSubstitutions;
74245         return ts.chainBundle(context, transformSourceFile);
74246         function transformSourceFile(node) {
74247             if (node.isDeclarationFile) {
74248                 return node;
74249             }
74250             currentSourceFile = node;
74251             currentText = node.text;
74252             var visited = visitSourceFile(node);
74253             ts.addEmitHelpers(visited, context.readEmitHelpers());
74254             currentSourceFile = undefined;
74255             currentText = undefined;
74256             taggedTemplateStringDeclarations = undefined;
74257             hierarchyFacts = 0;
74258             return visited;
74259         }
74260         function enterSubtree(excludeFacts, includeFacts) {
74261             var ancestorFacts = hierarchyFacts;
74262             hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & 16383;
74263             return ancestorFacts;
74264         }
74265         function exitSubtree(ancestorFacts, excludeFacts, includeFacts) {
74266             hierarchyFacts = (hierarchyFacts & ~excludeFacts | includeFacts) & -16384 | ancestorFacts;
74267         }
74268         function isReturnVoidStatementInConstructorWithCapturedSuper(node) {
74269             return (hierarchyFacts & 8192) !== 0
74270                 && node.kind === 242
74271                 && !node.expression;
74272         }
74273         function isOrMayContainReturnCompletion(node) {
74274             return node.transformFlags & 1048576
74275                 && (ts.isReturnStatement(node)
74276                     || ts.isIfStatement(node)
74277                     || ts.isWithStatement(node)
74278                     || ts.isSwitchStatement(node)
74279                     || ts.isCaseBlock(node)
74280                     || ts.isCaseClause(node)
74281                     || ts.isDefaultClause(node)
74282                     || ts.isTryStatement(node)
74283                     || ts.isCatchClause(node)
74284                     || ts.isLabeledStatement(node)
74285                     || ts.isIterationStatement(node, false)
74286                     || ts.isBlock(node));
74287         }
74288         function shouldVisitNode(node) {
74289             return (node.transformFlags & 256) !== 0
74290                 || convertedLoopState !== undefined
74291                 || (hierarchyFacts & 8192 && isOrMayContainReturnCompletion(node))
74292                 || (ts.isIterationStatement(node, false) && shouldConvertIterationStatement(node))
74293                 || (ts.getEmitFlags(node) & 33554432) !== 0;
74294         }
74295         function visitor(node) {
74296             return shouldVisitNode(node) ? visitorWorker(node, false) : node;
74297         }
74298         function visitorWithUnusedExpressionResult(node) {
74299             return shouldVisitNode(node) ? visitorWorker(node, true) : node;
74300         }
74301         function callExpressionVisitor(node) {
74302             if (node.kind === 105) {
74303                 return visitSuperKeyword(true);
74304             }
74305             return visitor(node);
74306         }
74307         function visitorWorker(node, expressionResultIsUnused) {
74308             switch (node.kind) {
74309                 case 123:
74310                     return undefined;
74311                 case 252:
74312                     return visitClassDeclaration(node);
74313                 case 221:
74314                     return visitClassExpression(node);
74315                 case 160:
74316                     return visitParameter(node);
74317                 case 251:
74318                     return visitFunctionDeclaration(node);
74319                 case 209:
74320                     return visitArrowFunction(node);
74321                 case 208:
74322                     return visitFunctionExpression(node);
74323                 case 249:
74324                     return visitVariableDeclaration(node);
74325                 case 78:
74326                     return visitIdentifier(node);
74327                 case 250:
74328                     return visitVariableDeclarationList(node);
74329                 case 244:
74330                     return visitSwitchStatement(node);
74331                 case 258:
74332                     return visitCaseBlock(node);
74333                 case 230:
74334                     return visitBlock(node, false);
74335                 case 241:
74336                 case 240:
74337                     return visitBreakOrContinueStatement(node);
74338                 case 245:
74339                     return visitLabeledStatement(node);
74340                 case 235:
74341                 case 236:
74342                     return visitDoOrWhileStatement(node, undefined);
74343                 case 237:
74344                     return visitForStatement(node, undefined);
74345                 case 238:
74346                     return visitForInStatement(node, undefined);
74347                 case 239:
74348                     return visitForOfStatement(node, undefined);
74349                 case 233:
74350                     return visitExpressionStatement(node);
74351                 case 200:
74352                     return visitObjectLiteralExpression(node);
74353                 case 287:
74354                     return visitCatchClause(node);
74355                 case 289:
74356                     return visitShorthandPropertyAssignment(node);
74357                 case 158:
74358                     return visitComputedPropertyName(node);
74359                 case 199:
74360                     return visitArrayLiteralExpression(node);
74361                 case 203:
74362                     return visitCallExpression(node);
74363                 case 204:
74364                     return visitNewExpression(node);
74365                 case 207:
74366                     return visitParenthesizedExpression(node, expressionResultIsUnused);
74367                 case 216:
74368                     return visitBinaryExpression(node, expressionResultIsUnused);
74369                 case 337:
74370                     return visitCommaListExpression(node, expressionResultIsUnused);
74371                 case 14:
74372                 case 15:
74373                 case 16:
74374                 case 17:
74375                     return visitTemplateLiteral(node);
74376                 case 10:
74377                     return visitStringLiteral(node);
74378                 case 8:
74379                     return visitNumericLiteral(node);
74380                 case 205:
74381                     return visitTaggedTemplateExpression(node);
74382                 case 218:
74383                     return visitTemplateExpression(node);
74384                 case 219:
74385                     return visitYieldExpression(node);
74386                 case 220:
74387                     return visitSpreadElement(node);
74388                 case 105:
74389                     return visitSuperKeyword(false);
74390                 case 107:
74391                     return visitThisKeyword(node);
74392                 case 226:
74393                     return visitMetaProperty(node);
74394                 case 165:
74395                     return visitMethodDeclaration(node);
74396                 case 167:
74397                 case 168:
74398                     return visitAccessorDeclaration(node);
74399                 case 232:
74400                     return visitVariableStatement(node);
74401                 case 242:
74402                     return visitReturnStatement(node);
74403                 case 212:
74404                     return visitVoidExpression(node);
74405                 default:
74406                     return ts.visitEachChild(node, visitor, context);
74407             }
74408         }
74409         function visitSourceFile(node) {
74410             var ancestorFacts = enterSubtree(8064, 64);
74411             var prologue = [];
74412             var statements = [];
74413             startLexicalEnvironment();
74414             var statementOffset = factory.copyPrologue(node.statements, prologue, false, visitor);
74415             ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset));
74416             if (taggedTemplateStringDeclarations) {
74417                 statements.push(factory.createVariableStatement(undefined, factory.createVariableDeclarationList(taggedTemplateStringDeclarations)));
74418             }
74419             factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
74420             insertCaptureThisForNodeIfNeeded(prologue, node);
74421             exitSubtree(ancestorFacts, 0, 0);
74422             return factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(ts.concatenate(prologue, statements)), node.statements));
74423         }
74424         function visitSwitchStatement(node) {
74425             if (convertedLoopState !== undefined) {
74426                 var savedAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps;
74427                 convertedLoopState.allowedNonLabeledJumps |= 2;
74428                 var result = ts.visitEachChild(node, visitor, context);
74429                 convertedLoopState.allowedNonLabeledJumps = savedAllowedNonLabeledJumps;
74430                 return result;
74431             }
74432             return ts.visitEachChild(node, visitor, context);
74433         }
74434         function visitCaseBlock(node) {
74435             var ancestorFacts = enterSubtree(7104, 0);
74436             var updated = ts.visitEachChild(node, visitor, context);
74437             exitSubtree(ancestorFacts, 0, 0);
74438             return updated;
74439         }
74440         function returnCapturedThis(node) {
74441             return ts.setOriginalNode(factory.createReturnStatement(factory.createUniqueName("_this", 16 | 32)), node);
74442         }
74443         function visitReturnStatement(node) {
74444             if (convertedLoopState) {
74445                 convertedLoopState.nonLocalJumps |= 8;
74446                 if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) {
74447                     node = returnCapturedThis(node);
74448                 }
74449                 return factory.createReturnStatement(factory.createObjectLiteralExpression([
74450                     factory.createPropertyAssignment(factory.createIdentifier("value"), node.expression
74451                         ? ts.visitNode(node.expression, visitor, ts.isExpression)
74452                         : factory.createVoidZero())
74453                 ]));
74454             }
74455             else if (isReturnVoidStatementInConstructorWithCapturedSuper(node)) {
74456                 return returnCapturedThis(node);
74457             }
74458             return ts.visitEachChild(node, visitor, context);
74459         }
74460         function visitThisKeyword(node) {
74461             if (hierarchyFacts & 2) {
74462                 hierarchyFacts |= 32768;
74463             }
74464             if (convertedLoopState) {
74465                 if (hierarchyFacts & 2) {
74466                     convertedLoopState.containsLexicalThis = true;
74467                     return node;
74468                 }
74469                 return convertedLoopState.thisName || (convertedLoopState.thisName = factory.createUniqueName("this"));
74470             }
74471             return node;
74472         }
74473         function visitVoidExpression(node) {
74474             return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
74475         }
74476         function visitIdentifier(node) {
74477             if (!convertedLoopState) {
74478                 return node;
74479             }
74480             if (resolver.isArgumentsLocalBinding(node)) {
74481                 return convertedLoopState.argumentsName || (convertedLoopState.argumentsName = factory.createUniqueName("arguments"));
74482             }
74483             return node;
74484         }
74485         function visitBreakOrContinueStatement(node) {
74486             if (convertedLoopState) {
74487                 var jump = node.kind === 241 ? 2 : 4;
74488                 var canUseBreakOrContinue = (node.label && convertedLoopState.labels && convertedLoopState.labels.get(ts.idText(node.label))) ||
74489                     (!node.label && (convertedLoopState.allowedNonLabeledJumps & jump));
74490                 if (!canUseBreakOrContinue) {
74491                     var labelMarker = void 0;
74492                     var label = node.label;
74493                     if (!label) {
74494                         if (node.kind === 241) {
74495                             convertedLoopState.nonLocalJumps |= 2;
74496                             labelMarker = "break";
74497                         }
74498                         else {
74499                             convertedLoopState.nonLocalJumps |= 4;
74500                             labelMarker = "continue";
74501                         }
74502                     }
74503                     else {
74504                         if (node.kind === 241) {
74505                             labelMarker = "break-" + label.escapedText;
74506                             setLabeledJump(convertedLoopState, true, ts.idText(label), labelMarker);
74507                         }
74508                         else {
74509                             labelMarker = "continue-" + label.escapedText;
74510                             setLabeledJump(convertedLoopState, false, ts.idText(label), labelMarker);
74511                         }
74512                     }
74513                     var returnExpression = factory.createStringLiteral(labelMarker);
74514                     if (convertedLoopState.loopOutParameters.length) {
74515                         var outParams = convertedLoopState.loopOutParameters;
74516                         var expr = void 0;
74517                         for (var i = 0; i < outParams.length; i++) {
74518                             var copyExpr = copyOutParameter(outParams[i], 1);
74519                             if (i === 0) {
74520                                 expr = copyExpr;
74521                             }
74522                             else {
74523                                 expr = factory.createBinaryExpression(expr, 27, copyExpr);
74524                             }
74525                         }
74526                         returnExpression = factory.createBinaryExpression(expr, 27, returnExpression);
74527                     }
74528                     return factory.createReturnStatement(returnExpression);
74529                 }
74530             }
74531             return ts.visitEachChild(node, visitor, context);
74532         }
74533         function visitClassDeclaration(node) {
74534             var variable = factory.createVariableDeclaration(factory.getLocalName(node, true), undefined, undefined, transformClassLikeDeclarationToExpression(node));
74535             ts.setOriginalNode(variable, node);
74536             var statements = [];
74537             var statement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([variable]));
74538             ts.setOriginalNode(statement, node);
74539             ts.setTextRange(statement, node);
74540             ts.startOnNewLine(statement);
74541             statements.push(statement);
74542             if (ts.hasSyntacticModifier(node, 1)) {
74543                 var exportStatement = ts.hasSyntacticModifier(node, 512)
74544                     ? factory.createExportDefault(factory.getLocalName(node))
74545                     : factory.createExternalModuleExport(factory.getLocalName(node));
74546                 ts.setOriginalNode(exportStatement, statement);
74547                 statements.push(exportStatement);
74548             }
74549             var emitFlags = ts.getEmitFlags(node);
74550             if ((emitFlags & 4194304) === 0) {
74551                 statements.push(factory.createEndOfDeclarationMarker(node));
74552                 ts.setEmitFlags(statement, emitFlags | 4194304);
74553             }
74554             return ts.singleOrMany(statements);
74555         }
74556         function visitClassExpression(node) {
74557             return transformClassLikeDeclarationToExpression(node);
74558         }
74559         function transformClassLikeDeclarationToExpression(node) {
74560             if (node.name) {
74561                 enableSubstitutionsForBlockScopedBindings();
74562             }
74563             var extendsClauseElement = ts.getClassExtendsHeritageElement(node);
74564             var classFunction = factory.createFunctionExpression(undefined, undefined, undefined, undefined, extendsClauseElement ? [factory.createParameterDeclaration(undefined, undefined, undefined, factory.createUniqueName("_super", 16 | 32))] : [], undefined, transformClassBody(node, extendsClauseElement));
74565             ts.setEmitFlags(classFunction, (ts.getEmitFlags(node) & 65536) | 524288);
74566             var inner = factory.createPartiallyEmittedExpression(classFunction);
74567             ts.setTextRangeEnd(inner, node.end);
74568             ts.setEmitFlags(inner, 1536);
74569             var outer = factory.createPartiallyEmittedExpression(inner);
74570             ts.setTextRangeEnd(outer, ts.skipTrivia(currentText, node.pos));
74571             ts.setEmitFlags(outer, 1536);
74572             var result = factory.createParenthesizedExpression(factory.createCallExpression(outer, undefined, extendsClauseElement
74573                 ? [ts.visitNode(extendsClauseElement.expression, visitor, ts.isExpression)]
74574                 : []));
74575             ts.addSyntheticLeadingComment(result, 3, "* @class ");
74576             return result;
74577         }
74578         function transformClassBody(node, extendsClauseElement) {
74579             var statements = [];
74580             var name = factory.getInternalName(node);
74581             var constructorLikeName = ts.isIdentifierANonContextualKeyword(name) ? factory.getGeneratedNameForNode(name) : name;
74582             startLexicalEnvironment();
74583             addExtendsHelperIfNeeded(statements, node, extendsClauseElement);
74584             addConstructor(statements, node, constructorLikeName, extendsClauseElement);
74585             addClassMembers(statements, node);
74586             var closingBraceLocation = ts.createTokenRange(ts.skipTrivia(currentText, node.members.end), 19);
74587             var outer = factory.createPartiallyEmittedExpression(constructorLikeName);
74588             ts.setTextRangeEnd(outer, closingBraceLocation.end);
74589             ts.setEmitFlags(outer, 1536);
74590             var statement = factory.createReturnStatement(outer);
74591             ts.setTextRangePos(statement, closingBraceLocation.pos);
74592             ts.setEmitFlags(statement, 1536 | 384);
74593             statements.push(statement);
74594             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
74595             var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), node.members), true);
74596             ts.setEmitFlags(block, 1536);
74597             return block;
74598         }
74599         function addExtendsHelperIfNeeded(statements, node, extendsClauseElement) {
74600             if (extendsClauseElement) {
74601                 statements.push(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createExtendsHelper(factory.getInternalName(node))), extendsClauseElement));
74602             }
74603         }
74604         function addConstructor(statements, node, name, extendsClauseElement) {
74605             var savedConvertedLoopState = convertedLoopState;
74606             convertedLoopState = undefined;
74607             var ancestorFacts = enterSubtree(16278, 73);
74608             var constructor = ts.getFirstConstructorWithBody(node);
74609             var hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined);
74610             var constructorFunction = factory.createFunctionDeclaration(undefined, undefined, undefined, name, undefined, transformConstructorParameters(constructor, hasSynthesizedSuper), undefined, transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper));
74611             ts.setTextRange(constructorFunction, constructor || node);
74612             if (extendsClauseElement) {
74613                 ts.setEmitFlags(constructorFunction, 8);
74614             }
74615             statements.push(constructorFunction);
74616             exitSubtree(ancestorFacts, 49152, 0);
74617             convertedLoopState = savedConvertedLoopState;
74618         }
74619         function transformConstructorParameters(constructor, hasSynthesizedSuper) {
74620             return ts.visitParameterList(constructor && !hasSynthesizedSuper ? constructor.parameters : undefined, visitor, context)
74621                 || [];
74622         }
74623         function createDefaultConstructorBody(node, isDerivedClass) {
74624             var statements = [];
74625             resumeLexicalEnvironment();
74626             factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
74627             if (isDerivedClass) {
74628                 statements.push(factory.createReturnStatement(createDefaultSuperCallOrThis()));
74629             }
74630             var statementsArray = factory.createNodeArray(statements);
74631             ts.setTextRange(statementsArray, node.members);
74632             var block = factory.createBlock(statementsArray, true);
74633             ts.setTextRange(block, node);
74634             ts.setEmitFlags(block, 1536);
74635             return block;
74636         }
74637         function transformConstructorBody(constructor, node, extendsClauseElement, hasSynthesizedSuper) {
74638             var isDerivedClass = !!extendsClauseElement && ts.skipOuterExpressions(extendsClauseElement.expression).kind !== 103;
74639             if (!constructor)
74640                 return createDefaultConstructorBody(node, isDerivedClass);
74641             var prologue = [];
74642             var statements = [];
74643             resumeLexicalEnvironment();
74644             var statementOffset = 0;
74645             if (!hasSynthesizedSuper)
74646                 statementOffset = factory.copyStandardPrologue(constructor.body.statements, prologue, false);
74647             addDefaultValueAssignmentsIfNeeded(statements, constructor);
74648             addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper);
74649             if (!hasSynthesizedSuper)
74650                 statementOffset = factory.copyCustomPrologue(constructor.body.statements, statements, statementOffset, visitor);
74651             var superCallExpression;
74652             if (hasSynthesizedSuper) {
74653                 superCallExpression = createDefaultSuperCallOrThis();
74654             }
74655             else if (isDerivedClass && statementOffset < constructor.body.statements.length) {
74656                 var firstStatement = constructor.body.statements[statementOffset];
74657                 if (ts.isExpressionStatement(firstStatement) && ts.isSuperCall(firstStatement.expression)) {
74658                     superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression);
74659                 }
74660             }
74661             if (superCallExpression) {
74662                 hierarchyFacts |= 8192;
74663                 statementOffset++;
74664             }
74665             ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, statementOffset));
74666             factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
74667             insertCaptureNewTargetIfNeeded(prologue, constructor, false);
74668             if (isDerivedClass) {
74669                 if (superCallExpression && statementOffset === constructor.body.statements.length && !(constructor.body.transformFlags & 4096)) {
74670                     var superCall = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression);
74671                     var returnStatement = factory.createReturnStatement(superCallExpression);
74672                     ts.setCommentRange(returnStatement, ts.getCommentRange(superCall));
74673                     ts.setEmitFlags(superCall, 1536);
74674                     statements.push(returnStatement);
74675                 }
74676                 else {
74677                     insertCaptureThisForNode(statements, constructor, superCallExpression || createActualThis());
74678                     if (!isSufficientlyCoveredByReturnStatements(constructor.body)) {
74679                         statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 | 32)));
74680                     }
74681                 }
74682             }
74683             else {
74684                 insertCaptureThisForNodeIfNeeded(prologue, constructor);
74685             }
74686             var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(ts.concatenate(prologue, statements)), constructor.body.statements), true);
74687             ts.setTextRange(block, constructor.body);
74688             return block;
74689         }
74690         function isSufficientlyCoveredByReturnStatements(statement) {
74691             if (statement.kind === 242) {
74692                 return true;
74693             }
74694             else if (statement.kind === 234) {
74695                 var ifStatement = statement;
74696                 if (ifStatement.elseStatement) {
74697                     return isSufficientlyCoveredByReturnStatements(ifStatement.thenStatement) &&
74698                         isSufficientlyCoveredByReturnStatements(ifStatement.elseStatement);
74699                 }
74700             }
74701             else if (statement.kind === 230) {
74702                 var lastStatement = ts.lastOrUndefined(statement.statements);
74703                 if (lastStatement && isSufficientlyCoveredByReturnStatements(lastStatement)) {
74704                     return true;
74705                 }
74706             }
74707             return false;
74708         }
74709         function createActualThis() {
74710             return ts.setEmitFlags(factory.createThis(), 4);
74711         }
74712         function createDefaultSuperCallOrThis() {
74713             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());
74714         }
74715         function visitParameter(node) {
74716             if (node.dotDotDotToken) {
74717                 return undefined;
74718             }
74719             else if (ts.isBindingPattern(node.name)) {
74720                 return ts.setOriginalNode(ts.setTextRange(factory.createParameterDeclaration(undefined, undefined, undefined, factory.getGeneratedNameForNode(node), undefined, undefined, undefined), node), node);
74721             }
74722             else if (node.initializer) {
74723                 return ts.setOriginalNode(ts.setTextRange(factory.createParameterDeclaration(undefined, undefined, undefined, node.name, undefined, undefined, undefined), node), node);
74724             }
74725             else {
74726                 return node;
74727             }
74728         }
74729         function hasDefaultValueOrBindingPattern(node) {
74730             return node.initializer !== undefined
74731                 || ts.isBindingPattern(node.name);
74732         }
74733         function addDefaultValueAssignmentsIfNeeded(statements, node) {
74734             if (!ts.some(node.parameters, hasDefaultValueOrBindingPattern)) {
74735                 return false;
74736             }
74737             var added = false;
74738             for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
74739                 var parameter = _a[_i];
74740                 var name = parameter.name, initializer = parameter.initializer, dotDotDotToken = parameter.dotDotDotToken;
74741                 if (dotDotDotToken) {
74742                     continue;
74743                 }
74744                 if (ts.isBindingPattern(name)) {
74745                     added = insertDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) || added;
74746                 }
74747                 else if (initializer) {
74748                     insertDefaultValueAssignmentForInitializer(statements, parameter, name, initializer);
74749                     added = true;
74750                 }
74751             }
74752             return added;
74753         }
74754         function insertDefaultValueAssignmentForBindingPattern(statements, parameter, name, initializer) {
74755             if (name.elements.length > 0) {
74756                 ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createVariableStatement(undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, factory.getGeneratedNameForNode(parameter)))), 1048576));
74757                 return true;
74758             }
74759             else if (initializer) {
74760                 ts.insertStatementAfterCustomPrologue(statements, ts.setEmitFlags(factory.createExpressionStatement(factory.createAssignment(factory.getGeneratedNameForNode(parameter), ts.visitNode(initializer, visitor, ts.isExpression))), 1048576));
74761                 return true;
74762             }
74763             return false;
74764         }
74765         function insertDefaultValueAssignmentForInitializer(statements, parameter, name, initializer) {
74766             initializer = ts.visitNode(initializer, visitor, ts.isExpression);
74767             var statement = factory.createIfStatement(factory.createTypeCheck(factory.cloneNode(name), "undefined"), ts.setEmitFlags(ts.setTextRange(factory.createBlock([
74768                 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))
74769             ]), parameter), 1 | 32 | 384 | 1536));
74770             ts.startOnNewLine(statement);
74771             ts.setTextRange(statement, parameter);
74772             ts.setEmitFlags(statement, 384 | 32 | 1048576 | 1536);
74773             ts.insertStatementAfterCustomPrologue(statements, statement);
74774         }
74775         function shouldAddRestParameter(node, inConstructorWithSynthesizedSuper) {
74776             return !!(node && node.dotDotDotToken && !inConstructorWithSynthesizedSuper);
74777         }
74778         function addRestParameterIfNeeded(statements, node, inConstructorWithSynthesizedSuper) {
74779             var prologueStatements = [];
74780             var parameter = ts.lastOrUndefined(node.parameters);
74781             if (!shouldAddRestParameter(parameter, inConstructorWithSynthesizedSuper)) {
74782                 return false;
74783             }
74784             var declarationName = parameter.name.kind === 78 ? ts.setParent(ts.setTextRange(factory.cloneNode(parameter.name), parameter.name), parameter.name.parent) : factory.createTempVariable(undefined);
74785             ts.setEmitFlags(declarationName, 48);
74786             var expressionName = parameter.name.kind === 78 ? factory.cloneNode(parameter.name) : declarationName;
74787             var restIndex = node.parameters.length - 1;
74788             var temp = factory.createLoopVariable();
74789             prologueStatements.push(ts.setEmitFlags(ts.setTextRange(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
74790                 factory.createVariableDeclaration(declarationName, undefined, undefined, factory.createArrayLiteralExpression([]))
74791             ])), parameter), 1048576));
74792             var forStatement = factory.createForStatement(ts.setTextRange(factory.createVariableDeclarationList([
74793                 factory.createVariableDeclaration(temp, undefined, undefined, factory.createNumericLiteral(restIndex))
74794             ]), parameter), ts.setTextRange(factory.createLessThan(temp, factory.createPropertyAccessExpression(factory.createIdentifier("arguments"), "length")), parameter), ts.setTextRange(factory.createPostfixIncrement(temp), parameter), factory.createBlock([
74795                 ts.startOnNewLine(ts.setTextRange(factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(expressionName, restIndex === 0
74796                     ? temp
74797                     : factory.createSubtract(temp, factory.createNumericLiteral(restIndex))), factory.createElementAccessExpression(factory.createIdentifier("arguments"), temp))), parameter))
74798             ]));
74799             ts.setEmitFlags(forStatement, 1048576);
74800             ts.startOnNewLine(forStatement);
74801             prologueStatements.push(forStatement);
74802             if (parameter.name.kind !== 78) {
74803                 prologueStatements.push(ts.setEmitFlags(ts.setTextRange(factory.createVariableStatement(undefined, factory.createVariableDeclarationList(ts.flattenDestructuringBinding(parameter, visitor, context, 0, expressionName))), parameter), 1048576));
74804             }
74805             ts.insertStatementsAfterCustomPrologue(statements, prologueStatements);
74806             return true;
74807         }
74808         function insertCaptureThisForNodeIfNeeded(statements, node) {
74809             if (hierarchyFacts & 32768 && node.kind !== 209) {
74810                 insertCaptureThisForNode(statements, node, factory.createThis());
74811                 return true;
74812             }
74813             return false;
74814         }
74815         function insertCaptureThisForNode(statements, node, initializer) {
74816             enableSubstitutionsForCapturedThis();
74817             var captureThisStatement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
74818                 factory.createVariableDeclaration(factory.createUniqueName("_this", 16 | 32), undefined, undefined, initializer)
74819             ]));
74820             ts.setEmitFlags(captureThisStatement, 1536 | 1048576);
74821             ts.setSourceMapRange(captureThisStatement, node);
74822             ts.insertStatementAfterCustomPrologue(statements, captureThisStatement);
74823         }
74824         function insertCaptureNewTargetIfNeeded(statements, node, copyOnWrite) {
74825             if (hierarchyFacts & 16384) {
74826                 var newTarget = void 0;
74827                 switch (node.kind) {
74828                     case 209:
74829                         return statements;
74830                     case 165:
74831                     case 167:
74832                     case 168:
74833                         newTarget = factory.createVoidZero();
74834                         break;
74835                     case 166:
74836                         newTarget = factory.createPropertyAccessExpression(ts.setEmitFlags(factory.createThis(), 4), "constructor");
74837                         break;
74838                     case 251:
74839                     case 208:
74840                         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());
74841                         break;
74842                     default:
74843                         return ts.Debug.failBadSyntaxKind(node);
74844                 }
74845                 var captureNewTargetStatement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
74846                     factory.createVariableDeclaration(factory.createUniqueName("_newTarget", 16 | 32), undefined, undefined, newTarget)
74847                 ]));
74848                 ts.setEmitFlags(captureNewTargetStatement, 1536 | 1048576);
74849                 if (copyOnWrite) {
74850                     statements = statements.slice();
74851                 }
74852                 ts.insertStatementAfterCustomPrologue(statements, captureNewTargetStatement);
74853             }
74854             return statements;
74855         }
74856         function addClassMembers(statements, node) {
74857             for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
74858                 var member = _a[_i];
74859                 switch (member.kind) {
74860                     case 229:
74861                         statements.push(transformSemicolonClassElementToStatement(member));
74862                         break;
74863                     case 165:
74864                         statements.push(transformClassMethodDeclarationToStatement(getClassMemberPrefix(node, member), member, node));
74865                         break;
74866                     case 167:
74867                     case 168:
74868                         var accessors = ts.getAllAccessorDeclarations(node.members, member);
74869                         if (member === accessors.firstAccessor) {
74870                             statements.push(transformAccessorsToStatement(getClassMemberPrefix(node, member), accessors, node));
74871                         }
74872                         break;
74873                     case 166:
74874                         break;
74875                     default:
74876                         ts.Debug.failBadSyntaxKind(member, currentSourceFile && currentSourceFile.fileName);
74877                         break;
74878                 }
74879             }
74880         }
74881         function transformSemicolonClassElementToStatement(member) {
74882             return ts.setTextRange(factory.createEmptyStatement(), member);
74883         }
74884         function transformClassMethodDeclarationToStatement(receiver, member, container) {
74885             var commentRange = ts.getCommentRange(member);
74886             var sourceMapRange = ts.getSourceMapRange(member);
74887             var memberFunction = transformFunctionLikeToExpression(member, member, undefined, container);
74888             var propertyName = ts.visitNode(member.name, visitor, ts.isPropertyName);
74889             var e;
74890             if (!ts.isPrivateIdentifier(propertyName) && context.getCompilerOptions().useDefineForClassFields) {
74891                 var name = ts.isComputedPropertyName(propertyName) ? propertyName.expression
74892                     : ts.isIdentifier(propertyName) ? factory.createStringLiteral(ts.unescapeLeadingUnderscores(propertyName.escapedText))
74893                         : propertyName;
74894                 e = factory.createObjectDefinePropertyCall(receiver, name, factory.createPropertyDescriptor({ value: memberFunction, enumerable: false, writable: true, configurable: true }));
74895             }
74896             else {
74897                 var memberName = ts.createMemberAccessForPropertyName(factory, receiver, propertyName, member.name);
74898                 e = factory.createAssignment(memberName, memberFunction);
74899             }
74900             ts.setEmitFlags(memberFunction, 1536);
74901             ts.setSourceMapRange(memberFunction, sourceMapRange);
74902             var statement = ts.setTextRange(factory.createExpressionStatement(e), member);
74903             ts.setOriginalNode(statement, member);
74904             ts.setCommentRange(statement, commentRange);
74905             ts.setEmitFlags(statement, 48);
74906             return statement;
74907         }
74908         function transformAccessorsToStatement(receiver, accessors, container) {
74909             var statement = factory.createExpressionStatement(transformAccessorsToExpression(receiver, accessors, container, false));
74910             ts.setEmitFlags(statement, 1536);
74911             ts.setSourceMapRange(statement, ts.getSourceMapRange(accessors.firstAccessor));
74912             return statement;
74913         }
74914         function transformAccessorsToExpression(receiver, _a, container, startsOnNewLine) {
74915             var firstAccessor = _a.firstAccessor, getAccessor = _a.getAccessor, setAccessor = _a.setAccessor;
74916             var target = ts.setParent(ts.setTextRange(factory.cloneNode(receiver), receiver), receiver.parent);
74917             ts.setEmitFlags(target, 1536 | 32);
74918             ts.setSourceMapRange(target, firstAccessor.name);
74919             var visitedAccessorName = ts.visitNode(firstAccessor.name, visitor, ts.isPropertyName);
74920             if (ts.isPrivateIdentifier(visitedAccessorName)) {
74921                 return ts.Debug.failBadSyntaxKind(visitedAccessorName, "Encountered unhandled private identifier while transforming ES2015.");
74922             }
74923             var propertyName = ts.createExpressionForPropertyName(factory, visitedAccessorName);
74924             ts.setEmitFlags(propertyName, 1536 | 16);
74925             ts.setSourceMapRange(propertyName, firstAccessor.name);
74926             var properties = [];
74927             if (getAccessor) {
74928                 var getterFunction = transformFunctionLikeToExpression(getAccessor, undefined, undefined, container);
74929                 ts.setSourceMapRange(getterFunction, ts.getSourceMapRange(getAccessor));
74930                 ts.setEmitFlags(getterFunction, 512);
74931                 var getter = factory.createPropertyAssignment("get", getterFunction);
74932                 ts.setCommentRange(getter, ts.getCommentRange(getAccessor));
74933                 properties.push(getter);
74934             }
74935             if (setAccessor) {
74936                 var setterFunction = transformFunctionLikeToExpression(setAccessor, undefined, undefined, container);
74937                 ts.setSourceMapRange(setterFunction, ts.getSourceMapRange(setAccessor));
74938                 ts.setEmitFlags(setterFunction, 512);
74939                 var setter = factory.createPropertyAssignment("set", setterFunction);
74940                 ts.setCommentRange(setter, ts.getCommentRange(setAccessor));
74941                 properties.push(setter);
74942             }
74943             properties.push(factory.createPropertyAssignment("enumerable", getAccessor || setAccessor ? factory.createFalse() : factory.createTrue()), factory.createPropertyAssignment("configurable", factory.createTrue()));
74944             var call = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), undefined, [
74945                 target,
74946                 propertyName,
74947                 factory.createObjectLiteralExpression(properties, true)
74948             ]);
74949             if (startsOnNewLine) {
74950                 ts.startOnNewLine(call);
74951             }
74952             return call;
74953         }
74954         function visitArrowFunction(node) {
74955             if (node.transformFlags & 4096) {
74956                 hierarchyFacts |= 32768;
74957             }
74958             var savedConvertedLoopState = convertedLoopState;
74959             convertedLoopState = undefined;
74960             var ancestorFacts = enterSubtree(15232, 66);
74961             var func = factory.createFunctionExpression(undefined, undefined, undefined, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformFunctionBody(node));
74962             ts.setTextRange(func, node);
74963             ts.setOriginalNode(func, node);
74964             ts.setEmitFlags(func, 8);
74965             if (hierarchyFacts & 32768) {
74966                 enableSubstitutionsForCapturedThis();
74967             }
74968             exitSubtree(ancestorFacts, 0, 0);
74969             convertedLoopState = savedConvertedLoopState;
74970             return func;
74971         }
74972         function visitFunctionExpression(node) {
74973             var ancestorFacts = ts.getEmitFlags(node) & 262144
74974                 ? enterSubtree(16278, 69)
74975                 : enterSubtree(16286, 65);
74976             var savedConvertedLoopState = convertedLoopState;
74977             convertedLoopState = undefined;
74978             var parameters = ts.visitParameterList(node.parameters, visitor, context);
74979             var body = transformFunctionBody(node);
74980             var name = hierarchyFacts & 16384
74981                 ? factory.getLocalName(node)
74982                 : node.name;
74983             exitSubtree(ancestorFacts, 49152, 0);
74984             convertedLoopState = savedConvertedLoopState;
74985             return factory.updateFunctionExpression(node, undefined, node.asteriskToken, name, undefined, parameters, undefined, body);
74986         }
74987         function visitFunctionDeclaration(node) {
74988             var savedConvertedLoopState = convertedLoopState;
74989             convertedLoopState = undefined;
74990             var ancestorFacts = enterSubtree(16286, 65);
74991             var parameters = ts.visitParameterList(node.parameters, visitor, context);
74992             var body = transformFunctionBody(node);
74993             var name = hierarchyFacts & 16384
74994                 ? factory.getLocalName(node)
74995                 : node.name;
74996             exitSubtree(ancestorFacts, 49152, 0);
74997             convertedLoopState = savedConvertedLoopState;
74998             return factory.updateFunctionDeclaration(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.asteriskToken, name, undefined, parameters, undefined, body);
74999         }
75000         function transformFunctionLikeToExpression(node, location, name, container) {
75001             var savedConvertedLoopState = convertedLoopState;
75002             convertedLoopState = undefined;
75003             var ancestorFacts = container && ts.isClassLike(container) && !ts.hasSyntacticModifier(node, 32)
75004                 ? enterSubtree(16286, 65 | 8)
75005                 : enterSubtree(16286, 65);
75006             var parameters = ts.visitParameterList(node.parameters, visitor, context);
75007             var body = transformFunctionBody(node);
75008             if (hierarchyFacts & 16384 && !name && (node.kind === 251 || node.kind === 208)) {
75009                 name = factory.getGeneratedNameForNode(node);
75010             }
75011             exitSubtree(ancestorFacts, 49152, 0);
75012             convertedLoopState = savedConvertedLoopState;
75013             return ts.setOriginalNode(ts.setTextRange(factory.createFunctionExpression(undefined, node.asteriskToken, name, undefined, parameters, undefined, body), location), node);
75014         }
75015         function transformFunctionBody(node) {
75016             var multiLine = false;
75017             var singleLine = false;
75018             var statementsLocation;
75019             var closeBraceLocation;
75020             var prologue = [];
75021             var statements = [];
75022             var body = node.body;
75023             var statementOffset;
75024             resumeLexicalEnvironment();
75025             if (ts.isBlock(body)) {
75026                 statementOffset = factory.copyStandardPrologue(body.statements, prologue, false);
75027                 statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor, ts.isHoistedFunction);
75028                 statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor, ts.isHoistedVariableStatement);
75029             }
75030             multiLine = addDefaultValueAssignmentsIfNeeded(statements, node) || multiLine;
75031             multiLine = addRestParameterIfNeeded(statements, node, false) || multiLine;
75032             if (ts.isBlock(body)) {
75033                 statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor);
75034                 statementsLocation = body.statements;
75035                 ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, statementOffset));
75036                 if (!multiLine && body.multiLine) {
75037                     multiLine = true;
75038                 }
75039             }
75040             else {
75041                 ts.Debug.assert(node.kind === 209);
75042                 statementsLocation = ts.moveRangeEnd(body, -1);
75043                 var equalsGreaterThanToken = node.equalsGreaterThanToken;
75044                 if (!ts.nodeIsSynthesized(equalsGreaterThanToken) && !ts.nodeIsSynthesized(body)) {
75045                     if (ts.rangeEndIsOnSameLineAsRangeStart(equalsGreaterThanToken, body, currentSourceFile)) {
75046                         singleLine = true;
75047                     }
75048                     else {
75049                         multiLine = true;
75050                     }
75051                 }
75052                 var expression = ts.visitNode(body, visitor, ts.isExpression);
75053                 var returnStatement = factory.createReturnStatement(expression);
75054                 ts.setTextRange(returnStatement, body);
75055                 ts.moveSyntheticComments(returnStatement, body);
75056                 ts.setEmitFlags(returnStatement, 384 | 32 | 1024);
75057                 statements.push(returnStatement);
75058                 closeBraceLocation = body;
75059             }
75060             factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
75061             insertCaptureNewTargetIfNeeded(prologue, node, false);
75062             insertCaptureThisForNodeIfNeeded(prologue, node);
75063             if (ts.some(prologue)) {
75064                 multiLine = true;
75065             }
75066             statements.unshift.apply(statements, prologue);
75067             if (ts.isBlock(body) && ts.arrayIsEqualTo(statements, body.statements)) {
75068                 return body;
75069             }
75070             var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), statementsLocation), multiLine);
75071             ts.setTextRange(block, node.body);
75072             if (!multiLine && singleLine) {
75073                 ts.setEmitFlags(block, 1);
75074             }
75075             if (closeBraceLocation) {
75076                 ts.setTokenSourceMapRange(block, 19, closeBraceLocation);
75077             }
75078             ts.setOriginalNode(block, node.body);
75079             return block;
75080         }
75081         function visitBlock(node, isFunctionBody) {
75082             if (isFunctionBody) {
75083                 return ts.visitEachChild(node, visitor, context);
75084             }
75085             var ancestorFacts = hierarchyFacts & 256
75086                 ? enterSubtree(7104, 512)
75087                 : enterSubtree(6976, 128);
75088             var updated = ts.visitEachChild(node, visitor, context);
75089             exitSubtree(ancestorFacts, 0, 0);
75090             return updated;
75091         }
75092         function visitExpressionStatement(node) {
75093             return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
75094         }
75095         function visitParenthesizedExpression(node, expressionResultIsUnused) {
75096             return ts.visitEachChild(node, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, context);
75097         }
75098         function visitBinaryExpression(node, expressionResultIsUnused) {
75099             if (ts.isDestructuringAssignment(node)) {
75100                 return ts.flattenDestructuringAssignment(node, visitor, context, 0, !expressionResultIsUnused);
75101             }
75102             if (node.operatorToken.kind === 27) {
75103                 return factory.updateBinaryExpression(node, ts.visitNode(node.left, visitorWithUnusedExpressionResult, ts.isExpression), node.operatorToken, ts.visitNode(node.right, expressionResultIsUnused ? visitorWithUnusedExpressionResult : visitor, ts.isExpression));
75104             }
75105             return ts.visitEachChild(node, visitor, context);
75106         }
75107         function visitCommaListExpression(node, expressionResultIsUnused) {
75108             if (expressionResultIsUnused) {
75109                 return ts.visitEachChild(node, visitorWithUnusedExpressionResult, context);
75110             }
75111             var result;
75112             for (var i = 0; i < node.elements.length; i++) {
75113                 var element = node.elements[i];
75114                 var visited = ts.visitNode(element, i < node.elements.length - 1 ? visitorWithUnusedExpressionResult : visitor, ts.isExpression);
75115                 if (result || visited !== element) {
75116                     result || (result = node.elements.slice(0, i));
75117                     result.push(visited);
75118                 }
75119             }
75120             var elements = result ? ts.setTextRange(factory.createNodeArray(result), node.elements) : node.elements;
75121             return factory.updateCommaListExpression(node, elements);
75122         }
75123         function isVariableStatementOfTypeScriptClassWrapper(node) {
75124             return node.declarationList.declarations.length === 1
75125                 && !!node.declarationList.declarations[0].initializer
75126                 && !!(ts.getEmitFlags(node.declarationList.declarations[0].initializer) & 33554432);
75127         }
75128         function visitVariableStatement(node) {
75129             var ancestorFacts = enterSubtree(0, ts.hasSyntacticModifier(node, 1) ? 32 : 0);
75130             var updated;
75131             if (convertedLoopState && (node.declarationList.flags & 3) === 0 && !isVariableStatementOfTypeScriptClassWrapper(node)) {
75132                 var assignments = void 0;
75133                 for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
75134                     var decl = _a[_i];
75135                     hoistVariableDeclarationDeclaredInConvertedLoop(convertedLoopState, decl);
75136                     if (decl.initializer) {
75137                         var assignment = void 0;
75138                         if (ts.isBindingPattern(decl.name)) {
75139                             assignment = ts.flattenDestructuringAssignment(decl, visitor, context, 0);
75140                         }
75141                         else {
75142                             assignment = factory.createBinaryExpression(decl.name, 62, ts.visitNode(decl.initializer, visitor, ts.isExpression));
75143                             ts.setTextRange(assignment, decl);
75144                         }
75145                         assignments = ts.append(assignments, assignment);
75146                     }
75147                 }
75148                 if (assignments) {
75149                     updated = ts.setTextRange(factory.createExpressionStatement(factory.inlineExpressions(assignments)), node);
75150                 }
75151                 else {
75152                     updated = undefined;
75153                 }
75154             }
75155             else {
75156                 updated = ts.visitEachChild(node, visitor, context);
75157             }
75158             exitSubtree(ancestorFacts, 0, 0);
75159             return updated;
75160         }
75161         function visitVariableDeclarationList(node) {
75162             if (node.flags & 3 || node.transformFlags & 131072) {
75163                 if (node.flags & 3) {
75164                     enableSubstitutionsForBlockScopedBindings();
75165                 }
75166                 var declarations = ts.flatMap(node.declarations, node.flags & 1
75167                     ? visitVariableDeclarationInLetDeclarationList
75168                     : visitVariableDeclaration);
75169                 var declarationList = factory.createVariableDeclarationList(declarations);
75170                 ts.setOriginalNode(declarationList, node);
75171                 ts.setTextRange(declarationList, node);
75172                 ts.setCommentRange(declarationList, node);
75173                 if (node.transformFlags & 131072
75174                     && (ts.isBindingPattern(node.declarations[0].name) || ts.isBindingPattern(ts.last(node.declarations).name))) {
75175                     ts.setSourceMapRange(declarationList, getRangeUnion(declarations));
75176                 }
75177                 return declarationList;
75178             }
75179             return ts.visitEachChild(node, visitor, context);
75180         }
75181         function getRangeUnion(declarations) {
75182             var pos = -1, end = -1;
75183             for (var _i = 0, declarations_10 = declarations; _i < declarations_10.length; _i++) {
75184                 var node = declarations_10[_i];
75185                 pos = pos === -1 ? node.pos : node.pos === -1 ? pos : Math.min(pos, node.pos);
75186                 end = Math.max(end, node.end);
75187             }
75188             return ts.createRange(pos, end);
75189         }
75190         function shouldEmitExplicitInitializerForLetDeclaration(node) {
75191             var flags = resolver.getNodeCheckFlags(node);
75192             var isCapturedInFunction = flags & 262144;
75193             var isDeclaredInLoop = flags & 524288;
75194             var emittedAsTopLevel = (hierarchyFacts & 64) !== 0
75195                 || (isCapturedInFunction
75196                     && isDeclaredInLoop
75197                     && (hierarchyFacts & 512) !== 0);
75198             var emitExplicitInitializer = !emittedAsTopLevel
75199                 && (hierarchyFacts & 4096) === 0
75200                 && (!resolver.isDeclarationWithCollidingName(node)
75201                     || (isDeclaredInLoop
75202                         && !isCapturedInFunction
75203                         && (hierarchyFacts & (2048 | 4096)) === 0));
75204             return emitExplicitInitializer;
75205         }
75206         function visitVariableDeclarationInLetDeclarationList(node) {
75207             var name = node.name;
75208             if (ts.isBindingPattern(name)) {
75209                 return visitVariableDeclaration(node);
75210             }
75211             if (!node.initializer && shouldEmitExplicitInitializerForLetDeclaration(node)) {
75212                 return factory.updateVariableDeclaration(node, node.name, undefined, undefined, factory.createVoidZero());
75213             }
75214             return ts.visitEachChild(node, visitor, context);
75215         }
75216         function visitVariableDeclaration(node) {
75217             var ancestorFacts = enterSubtree(32, 0);
75218             var updated;
75219             if (ts.isBindingPattern(node.name)) {
75220                 updated = ts.flattenDestructuringBinding(node, visitor, context, 0, undefined, (ancestorFacts & 32) !== 0);
75221             }
75222             else {
75223                 updated = ts.visitEachChild(node, visitor, context);
75224             }
75225             exitSubtree(ancestorFacts, 0, 0);
75226             return updated;
75227         }
75228         function recordLabel(node) {
75229             convertedLoopState.labels.set(ts.idText(node.label), true);
75230         }
75231         function resetLabel(node) {
75232             convertedLoopState.labels.set(ts.idText(node.label), false);
75233         }
75234         function visitLabeledStatement(node) {
75235             if (convertedLoopState && !convertedLoopState.labels) {
75236                 convertedLoopState.labels = new ts.Map();
75237             }
75238             var statement = ts.unwrapInnermostStatementOfLabel(node, convertedLoopState && recordLabel);
75239             return ts.isIterationStatement(statement, false)
75240                 ? visitIterationStatement(statement, node)
75241                 : factory.restoreEnclosingLabel(ts.visitNode(statement, visitor, ts.isStatement, factory.liftToBlock), node, convertedLoopState && resetLabel);
75242         }
75243         function visitIterationStatement(node, outermostLabeledStatement) {
75244             switch (node.kind) {
75245                 case 235:
75246                 case 236:
75247                     return visitDoOrWhileStatement(node, outermostLabeledStatement);
75248                 case 237:
75249                     return visitForStatement(node, outermostLabeledStatement);
75250                 case 238:
75251                     return visitForInStatement(node, outermostLabeledStatement);
75252                 case 239:
75253                     return visitForOfStatement(node, outermostLabeledStatement);
75254             }
75255         }
75256         function visitIterationStatementWithFacts(excludeFacts, includeFacts, node, outermostLabeledStatement, convert) {
75257             var ancestorFacts = enterSubtree(excludeFacts, includeFacts);
75258             var updated = convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert);
75259             exitSubtree(ancestorFacts, 0, 0);
75260             return updated;
75261         }
75262         function visitDoOrWhileStatement(node, outermostLabeledStatement) {
75263             return visitIterationStatementWithFacts(0, 1280, node, outermostLabeledStatement);
75264         }
75265         function visitForStatement(node, outermostLabeledStatement) {
75266             return visitIterationStatementWithFacts(5056, 3328, node, outermostLabeledStatement);
75267         }
75268         function visitEachChildOfForStatement(node) {
75269             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));
75270         }
75271         function visitForInStatement(node, outermostLabeledStatement) {
75272             return visitIterationStatementWithFacts(3008, 5376, node, outermostLabeledStatement);
75273         }
75274         function visitForOfStatement(node, outermostLabeledStatement) {
75275             return visitIterationStatementWithFacts(3008, 5376, node, outermostLabeledStatement, compilerOptions.downlevelIteration ? convertForOfStatementForIterable : convertForOfStatementForArray);
75276         }
75277         function convertForOfStatementHead(node, boundValue, convertedLoopBodyStatements) {
75278             var statements = [];
75279             var initializer = node.initializer;
75280             if (ts.isVariableDeclarationList(initializer)) {
75281                 if (node.initializer.flags & 3) {
75282                     enableSubstitutionsForBlockScopedBindings();
75283                 }
75284                 var firstOriginalDeclaration = ts.firstOrUndefined(initializer.declarations);
75285                 if (firstOriginalDeclaration && ts.isBindingPattern(firstOriginalDeclaration.name)) {
75286                     var declarations = ts.flattenDestructuringBinding(firstOriginalDeclaration, visitor, context, 0, boundValue);
75287                     var declarationList = ts.setTextRange(factory.createVariableDeclarationList(declarations), node.initializer);
75288                     ts.setOriginalNode(declarationList, node.initializer);
75289                     ts.setSourceMapRange(declarationList, ts.createRange(declarations[0].pos, ts.last(declarations).end));
75290                     statements.push(factory.createVariableStatement(undefined, declarationList));
75291                 }
75292                 else {
75293                     statements.push(ts.setTextRange(factory.createVariableStatement(undefined, ts.setOriginalNode(ts.setTextRange(factory.createVariableDeclarationList([
75294                         factory.createVariableDeclaration(firstOriginalDeclaration ? firstOriginalDeclaration.name : factory.createTempVariable(undefined), undefined, undefined, boundValue)
75295                     ]), ts.moveRangePos(initializer, -1)), initializer)), ts.moveRangeEnd(initializer, -1)));
75296                 }
75297             }
75298             else {
75299                 var assignment = factory.createAssignment(initializer, boundValue);
75300                 if (ts.isDestructuringAssignment(assignment)) {
75301                     statements.push(factory.createExpressionStatement(visitBinaryExpression(assignment, true)));
75302                 }
75303                 else {
75304                     ts.setTextRangeEnd(assignment, initializer.end);
75305                     statements.push(ts.setTextRange(factory.createExpressionStatement(ts.visitNode(assignment, visitor, ts.isExpression)), ts.moveRangeEnd(initializer, -1)));
75306                 }
75307             }
75308             if (convertedLoopBodyStatements) {
75309                 return createSyntheticBlockForConvertedStatements(ts.addRange(statements, convertedLoopBodyStatements));
75310             }
75311             else {
75312                 var statement = ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock);
75313                 if (ts.isBlock(statement)) {
75314                     return factory.updateBlock(statement, ts.setTextRange(factory.createNodeArray(ts.concatenate(statements, statement.statements)), statement.statements));
75315                 }
75316                 else {
75317                     statements.push(statement);
75318                     return createSyntheticBlockForConvertedStatements(statements);
75319                 }
75320             }
75321         }
75322         function createSyntheticBlockForConvertedStatements(statements) {
75323             return ts.setEmitFlags(factory.createBlock(factory.createNodeArray(statements), true), 48 | 384);
75324         }
75325         function convertForOfStatementForArray(node, outermostLabeledStatement, convertedLoopBodyStatements) {
75326             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
75327             var counter = factory.createLoopVariable();
75328             var rhsReference = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(undefined);
75329             ts.setEmitFlags(expression, 48 | ts.getEmitFlags(expression));
75330             var forStatement = ts.setTextRange(factory.createForStatement(ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([
75331                 ts.setTextRange(factory.createVariableDeclaration(counter, undefined, undefined, factory.createNumericLiteral(0)), ts.moveRangePos(node.expression, -1)),
75332                 ts.setTextRange(factory.createVariableDeclaration(rhsReference, undefined, undefined, expression), node.expression)
75333             ]), 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);
75334             ts.setEmitFlags(forStatement, 256);
75335             ts.setTextRange(forStatement, node);
75336             return factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel);
75337         }
75338         function convertForOfStatementForIterable(node, outermostLabeledStatement, convertedLoopBodyStatements, ancestorFacts) {
75339             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
75340             var iterator = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(expression) : factory.createTempVariable(undefined);
75341             var result = ts.isIdentifier(expression) ? factory.getGeneratedNameForNode(iterator) : factory.createTempVariable(undefined);
75342             var errorRecord = factory.createUniqueName("e");
75343             var catchVariable = factory.getGeneratedNameForNode(errorRecord);
75344             var returnMethod = factory.createTempVariable(undefined);
75345             var values = ts.setTextRange(emitHelpers().createValuesHelper(expression), node.expression);
75346             var next = factory.createCallExpression(factory.createPropertyAccessExpression(iterator, "next"), undefined, []);
75347             hoistVariableDeclaration(errorRecord);
75348             hoistVariableDeclaration(returnMethod);
75349             var initializer = ancestorFacts & 1024
75350                 ? factory.inlineExpressions([factory.createAssignment(errorRecord, factory.createVoidZero()), values])
75351                 : values;
75352             var forStatement = ts.setEmitFlags(ts.setTextRange(factory.createForStatement(ts.setEmitFlags(ts.setTextRange(factory.createVariableDeclarationList([
75353                 ts.setTextRange(factory.createVariableDeclaration(iterator, undefined, undefined, initializer), node.expression),
75354                 factory.createVariableDeclaration(result, undefined, undefined, next)
75355             ]), node.expression), 2097152), factory.createLogicalNot(factory.createPropertyAccessExpression(result, "done")), factory.createAssignment(result, next), convertForOfStatementHead(node, factory.createPropertyAccessExpression(result, "value"), convertedLoopBodyStatements)), node), 256);
75356             return factory.createTryStatement(factory.createBlock([
75357                 factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement, convertedLoopState && resetLabel)
75358             ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([
75359                 factory.createExpressionStatement(factory.createAssignment(errorRecord, factory.createObjectLiteralExpression([
75360                     factory.createPropertyAssignment("error", catchVariable)
75361                 ])))
75362             ]), 1)), factory.createBlock([
75363                 factory.createTryStatement(factory.createBlock([
75364                     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),
75365                 ]), undefined, ts.setEmitFlags(factory.createBlock([
75366                     ts.setEmitFlags(factory.createIfStatement(errorRecord, factory.createThrowStatement(factory.createPropertyAccessExpression(errorRecord, "error"))), 1)
75367                 ]), 1))
75368             ]));
75369         }
75370         function visitObjectLiteralExpression(node) {
75371             var properties = node.properties;
75372             var numInitialProperties = -1, hasComputed = false;
75373             for (var i = 0; i < properties.length; i++) {
75374                 var property = properties[i];
75375                 if ((property.transformFlags & 262144 &&
75376                     hierarchyFacts & 4)
75377                     || (hasComputed = ts.Debug.checkDefined(property.name).kind === 158)) {
75378                     numInitialProperties = i;
75379                     break;
75380                 }
75381             }
75382             if (numInitialProperties < 0) {
75383                 return ts.visitEachChild(node, visitor, context);
75384             }
75385             var temp = factory.createTempVariable(hoistVariableDeclaration);
75386             var expressions = [];
75387             var assignment = factory.createAssignment(temp, ts.setEmitFlags(factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), node.multiLine), hasComputed ? 65536 : 0));
75388             if (node.multiLine) {
75389                 ts.startOnNewLine(assignment);
75390             }
75391             expressions.push(assignment);
75392             addObjectLiteralMembers(expressions, node, temp, numInitialProperties);
75393             expressions.push(node.multiLine ? ts.startOnNewLine(ts.setParent(ts.setTextRange(factory.cloneNode(temp), temp), temp.parent)) : temp);
75394             return factory.inlineExpressions(expressions);
75395         }
75396         function shouldConvertPartOfIterationStatement(node) {
75397             return (resolver.getNodeCheckFlags(node) & 131072) !== 0;
75398         }
75399         function shouldConvertInitializerOfForStatement(node) {
75400             return ts.isForStatement(node) && !!node.initializer && shouldConvertPartOfIterationStatement(node.initializer);
75401         }
75402         function shouldConvertConditionOfForStatement(node) {
75403             return ts.isForStatement(node) && !!node.condition && shouldConvertPartOfIterationStatement(node.condition);
75404         }
75405         function shouldConvertIncrementorOfForStatement(node) {
75406             return ts.isForStatement(node) && !!node.incrementor && shouldConvertPartOfIterationStatement(node.incrementor);
75407         }
75408         function shouldConvertIterationStatement(node) {
75409             return shouldConvertBodyOfIterationStatement(node)
75410                 || shouldConvertInitializerOfForStatement(node);
75411         }
75412         function shouldConvertBodyOfIterationStatement(node) {
75413             return (resolver.getNodeCheckFlags(node) & 65536) !== 0;
75414         }
75415         function hoistVariableDeclarationDeclaredInConvertedLoop(state, node) {
75416             if (!state.hoistedLocalVariables) {
75417                 state.hoistedLocalVariables = [];
75418             }
75419             visit(node.name);
75420             function visit(node) {
75421                 if (node.kind === 78) {
75422                     state.hoistedLocalVariables.push(node);
75423                 }
75424                 else {
75425                     for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
75426                         var element = _a[_i];
75427                         if (!ts.isOmittedExpression(element)) {
75428                             visit(element.name);
75429                         }
75430                     }
75431                 }
75432             }
75433         }
75434         function convertIterationStatementBodyIfNecessary(node, outermostLabeledStatement, ancestorFacts, convert) {
75435             if (!shouldConvertIterationStatement(node)) {
75436                 var saveAllowedNonLabeledJumps = void 0;
75437                 if (convertedLoopState) {
75438                     saveAllowedNonLabeledJumps = convertedLoopState.allowedNonLabeledJumps;
75439                     convertedLoopState.allowedNonLabeledJumps = 2 | 4;
75440                 }
75441                 var result = convert
75442                     ? convert(node, outermostLabeledStatement, undefined, ancestorFacts)
75443                     : factory.restoreEnclosingLabel(ts.isForStatement(node) ? visitEachChildOfForStatement(node) : ts.visitEachChild(node, visitor, context), outermostLabeledStatement, convertedLoopState && resetLabel);
75444                 if (convertedLoopState) {
75445                     convertedLoopState.allowedNonLabeledJumps = saveAllowedNonLabeledJumps;
75446                 }
75447                 return result;
75448             }
75449             var currentState = createConvertedLoopState(node);
75450             var statements = [];
75451             var outerConvertedLoopState = convertedLoopState;
75452             convertedLoopState = currentState;
75453             var initializerFunction = shouldConvertInitializerOfForStatement(node) ? createFunctionForInitializerOfForStatement(node, currentState) : undefined;
75454             var bodyFunction = shouldConvertBodyOfIterationStatement(node) ? createFunctionForBodyOfIterationStatement(node, currentState, outerConvertedLoopState) : undefined;
75455             convertedLoopState = outerConvertedLoopState;
75456             if (initializerFunction)
75457                 statements.push(initializerFunction.functionDeclaration);
75458             if (bodyFunction)
75459                 statements.push(bodyFunction.functionDeclaration);
75460             addExtraDeclarationsForConvertedLoop(statements, currentState, outerConvertedLoopState);
75461             if (initializerFunction) {
75462                 statements.push(generateCallToConvertedLoopInitializer(initializerFunction.functionName, initializerFunction.containsYield));
75463             }
75464             var loop;
75465             if (bodyFunction) {
75466                 if (convert) {
75467                     loop = convert(node, outermostLabeledStatement, bodyFunction.part, ancestorFacts);
75468                 }
75469                 else {
75470                     var clone_3 = convertIterationStatementCore(node, initializerFunction, factory.createBlock(bodyFunction.part, true));
75471                     loop = factory.restoreEnclosingLabel(clone_3, outermostLabeledStatement, convertedLoopState && resetLabel);
75472                 }
75473             }
75474             else {
75475                 var clone_4 = convertIterationStatementCore(node, initializerFunction, ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock));
75476                 loop = factory.restoreEnclosingLabel(clone_4, outermostLabeledStatement, convertedLoopState && resetLabel);
75477             }
75478             statements.push(loop);
75479             return statements;
75480         }
75481         function convertIterationStatementCore(node, initializerFunction, convertedLoopBody) {
75482             switch (node.kind) {
75483                 case 237: return convertForStatement(node, initializerFunction, convertedLoopBody);
75484                 case 238: return convertForInStatement(node, convertedLoopBody);
75485                 case 239: return convertForOfStatement(node, convertedLoopBody);
75486                 case 235: return convertDoStatement(node, convertedLoopBody);
75487                 case 236: return convertWhileStatement(node, convertedLoopBody);
75488                 default: return ts.Debug.failBadSyntaxKind(node, "IterationStatement expected");
75489             }
75490         }
75491         function convertForStatement(node, initializerFunction, convertedLoopBody) {
75492             var shouldConvertCondition = node.condition && shouldConvertPartOfIterationStatement(node.condition);
75493             var shouldConvertIncrementor = shouldConvertCondition || node.incrementor && shouldConvertPartOfIterationStatement(node.incrementor);
75494             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);
75495         }
75496         function convertForOfStatement(node, convertedLoopBody) {
75497             return factory.updateForOfStatement(node, undefined, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody);
75498         }
75499         function convertForInStatement(node, convertedLoopBody) {
75500             return factory.updateForInStatement(node, ts.visitNode(node.initializer, visitor, ts.isForInitializer), ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody);
75501         }
75502         function convertDoStatement(node, convertedLoopBody) {
75503             return factory.updateDoStatement(node, convertedLoopBody, ts.visitNode(node.expression, visitor, ts.isExpression));
75504         }
75505         function convertWhileStatement(node, convertedLoopBody) {
75506             return factory.updateWhileStatement(node, ts.visitNode(node.expression, visitor, ts.isExpression), convertedLoopBody);
75507         }
75508         function createConvertedLoopState(node) {
75509             var loopInitializer;
75510             switch (node.kind) {
75511                 case 237:
75512                 case 238:
75513                 case 239:
75514                     var initializer = node.initializer;
75515                     if (initializer && initializer.kind === 250) {
75516                         loopInitializer = initializer;
75517                     }
75518                     break;
75519             }
75520             var loopParameters = [];
75521             var loopOutParameters = [];
75522             if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3)) {
75523                 var hasCapturedBindingsInForInitializer = shouldConvertInitializerOfForStatement(node);
75524                 for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) {
75525                     var decl = _a[_i];
75526                     processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
75527                 }
75528             }
75529             var currentState = { loopParameters: loopParameters, loopOutParameters: loopOutParameters };
75530             if (convertedLoopState) {
75531                 if (convertedLoopState.argumentsName) {
75532                     currentState.argumentsName = convertedLoopState.argumentsName;
75533                 }
75534                 if (convertedLoopState.thisName) {
75535                     currentState.thisName = convertedLoopState.thisName;
75536                 }
75537                 if (convertedLoopState.hoistedLocalVariables) {
75538                     currentState.hoistedLocalVariables = convertedLoopState.hoistedLocalVariables;
75539                 }
75540             }
75541             return currentState;
75542         }
75543         function addExtraDeclarationsForConvertedLoop(statements, state, outerState) {
75544             var extraVariableDeclarations;
75545             if (state.argumentsName) {
75546                 if (outerState) {
75547                     outerState.argumentsName = state.argumentsName;
75548                 }
75549                 else {
75550                     (extraVariableDeclarations || (extraVariableDeclarations = [])).push(factory.createVariableDeclaration(state.argumentsName, undefined, undefined, factory.createIdentifier("arguments")));
75551                 }
75552             }
75553             if (state.thisName) {
75554                 if (outerState) {
75555                     outerState.thisName = state.thisName;
75556                 }
75557                 else {
75558                     (extraVariableDeclarations || (extraVariableDeclarations = [])).push(factory.createVariableDeclaration(state.thisName, undefined, undefined, factory.createIdentifier("this")));
75559                 }
75560             }
75561             if (state.hoistedLocalVariables) {
75562                 if (outerState) {
75563                     outerState.hoistedLocalVariables = state.hoistedLocalVariables;
75564                 }
75565                 else {
75566                     if (!extraVariableDeclarations) {
75567                         extraVariableDeclarations = [];
75568                     }
75569                     for (var _i = 0, _a = state.hoistedLocalVariables; _i < _a.length; _i++) {
75570                         var identifier = _a[_i];
75571                         extraVariableDeclarations.push(factory.createVariableDeclaration(identifier));
75572                     }
75573                 }
75574             }
75575             if (state.loopOutParameters.length) {
75576                 if (!extraVariableDeclarations) {
75577                     extraVariableDeclarations = [];
75578                 }
75579                 for (var _b = 0, _c = state.loopOutParameters; _b < _c.length; _b++) {
75580                     var outParam = _c[_b];
75581                     extraVariableDeclarations.push(factory.createVariableDeclaration(outParam.outParamName));
75582                 }
75583             }
75584             if (state.conditionVariable) {
75585                 if (!extraVariableDeclarations) {
75586                     extraVariableDeclarations = [];
75587                 }
75588                 extraVariableDeclarations.push(factory.createVariableDeclaration(state.conditionVariable, undefined, undefined, factory.createFalse()));
75589             }
75590             if (extraVariableDeclarations) {
75591                 statements.push(factory.createVariableStatement(undefined, factory.createVariableDeclarationList(extraVariableDeclarations)));
75592             }
75593         }
75594         function createOutVariable(p) {
75595             return factory.createVariableDeclaration(p.originalName, undefined, undefined, p.outParamName);
75596         }
75597         function createFunctionForInitializerOfForStatement(node, currentState) {
75598             var functionName = factory.createUniqueName("_loop_init");
75599             var containsYield = (node.initializer.transformFlags & 262144) !== 0;
75600             var emitFlags = 0;
75601             if (currentState.containsLexicalThis)
75602                 emitFlags |= 8;
75603             if (containsYield && hierarchyFacts & 4)
75604                 emitFlags |= 262144;
75605             var statements = [];
75606             statements.push(factory.createVariableStatement(undefined, node.initializer));
75607             copyOutParameters(currentState.loopOutParameters, 2, 1, statements);
75608             var functionDeclaration = factory.createVariableStatement(undefined, ts.setEmitFlags(factory.createVariableDeclarationList([
75609                 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))
75610             ]), 2097152));
75611             var part = factory.createVariableDeclarationList(ts.map(currentState.loopOutParameters, createOutVariable));
75612             return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part };
75613         }
75614         function createFunctionForBodyOfIterationStatement(node, currentState, outerState) {
75615             var functionName = factory.createUniqueName("_loop");
75616             startLexicalEnvironment();
75617             var statement = ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock);
75618             var lexicalEnvironment = endLexicalEnvironment();
75619             var statements = [];
75620             if (shouldConvertConditionOfForStatement(node) || shouldConvertIncrementorOfForStatement(node)) {
75621                 currentState.conditionVariable = factory.createUniqueName("inc");
75622                 if (node.incrementor) {
75623                     statements.push(factory.createIfStatement(currentState.conditionVariable, factory.createExpressionStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), factory.createExpressionStatement(factory.createAssignment(currentState.conditionVariable, factory.createTrue()))));
75624                 }
75625                 else {
75626                     statements.push(factory.createIfStatement(factory.createLogicalNot(currentState.conditionVariable), factory.createExpressionStatement(factory.createAssignment(currentState.conditionVariable, factory.createTrue()))));
75627                 }
75628                 if (shouldConvertConditionOfForStatement(node)) {
75629                     statements.push(factory.createIfStatement(factory.createPrefixUnaryExpression(53, ts.visitNode(node.condition, visitor, ts.isExpression)), ts.visitNode(factory.createBreakStatement(), visitor, ts.isStatement)));
75630                 }
75631             }
75632             if (ts.isBlock(statement)) {
75633                 ts.addRange(statements, statement.statements);
75634             }
75635             else {
75636                 statements.push(statement);
75637             }
75638             copyOutParameters(currentState.loopOutParameters, 1, 1, statements);
75639             ts.insertStatementsAfterStandardPrologue(statements, lexicalEnvironment);
75640             var loopBody = factory.createBlock(statements, true);
75641             if (ts.isBlock(statement))
75642                 ts.setOriginalNode(loopBody, statement);
75643             var containsYield = (node.statement.transformFlags & 262144) !== 0;
75644             var emitFlags = 524288;
75645             if (currentState.containsLexicalThis)
75646                 emitFlags |= 8;
75647             if (containsYield && (hierarchyFacts & 4) !== 0)
75648                 emitFlags |= 262144;
75649             var functionDeclaration = factory.createVariableStatement(undefined, ts.setEmitFlags(factory.createVariableDeclarationList([
75650                 factory.createVariableDeclaration(functionName, undefined, undefined, ts.setEmitFlags(factory.createFunctionExpression(undefined, containsYield ? factory.createToken(41) : undefined, undefined, undefined, currentState.loopParameters, undefined, loopBody), emitFlags))
75651             ]), 2097152));
75652             var part = generateCallToConvertedLoop(functionName, currentState, outerState, containsYield);
75653             return { functionName: functionName, containsYield: containsYield, functionDeclaration: functionDeclaration, part: part };
75654         }
75655         function copyOutParameter(outParam, copyDirection) {
75656             var source = copyDirection === 0 ? outParam.outParamName : outParam.originalName;
75657             var target = copyDirection === 0 ? outParam.originalName : outParam.outParamName;
75658             return factory.createBinaryExpression(target, 62, source);
75659         }
75660         function copyOutParameters(outParams, partFlags, copyDirection, statements) {
75661             for (var _i = 0, outParams_1 = outParams; _i < outParams_1.length; _i++) {
75662                 var outParam = outParams_1[_i];
75663                 if (outParam.flags & partFlags) {
75664                     statements.push(factory.createExpressionStatement(copyOutParameter(outParam, copyDirection)));
75665                 }
75666             }
75667         }
75668         function generateCallToConvertedLoopInitializer(initFunctionExpressionName, containsYield) {
75669             var call = factory.createCallExpression(initFunctionExpressionName, undefined, []);
75670             var callResult = containsYield
75671                 ? factory.createYieldExpression(factory.createToken(41), ts.setEmitFlags(call, 8388608))
75672                 : call;
75673             return factory.createExpressionStatement(callResult);
75674         }
75675         function generateCallToConvertedLoop(loopFunctionExpressionName, state, outerState, containsYield) {
75676             var statements = [];
75677             var isSimpleLoop = !(state.nonLocalJumps & ~4) &&
75678                 !state.labeledNonLocalBreaks &&
75679                 !state.labeledNonLocalContinues;
75680             var call = factory.createCallExpression(loopFunctionExpressionName, undefined, ts.map(state.loopParameters, function (p) { return p.name; }));
75681             var callResult = containsYield
75682                 ? factory.createYieldExpression(factory.createToken(41), ts.setEmitFlags(call, 8388608))
75683                 : call;
75684             if (isSimpleLoop) {
75685                 statements.push(factory.createExpressionStatement(callResult));
75686                 copyOutParameters(state.loopOutParameters, 1, 0, statements);
75687             }
75688             else {
75689                 var loopResultName = factory.createUniqueName("state");
75690                 var stateVariable = factory.createVariableStatement(undefined, factory.createVariableDeclarationList([factory.createVariableDeclaration(loopResultName, undefined, undefined, callResult)]));
75691                 statements.push(stateVariable);
75692                 copyOutParameters(state.loopOutParameters, 1, 0, statements);
75693                 if (state.nonLocalJumps & 8) {
75694                     var returnStatement = void 0;
75695                     if (outerState) {
75696                         outerState.nonLocalJumps |= 8;
75697                         returnStatement = factory.createReturnStatement(loopResultName);
75698                     }
75699                     else {
75700                         returnStatement = factory.createReturnStatement(factory.createPropertyAccessExpression(loopResultName, "value"));
75701                     }
75702                     statements.push(factory.createIfStatement(factory.createTypeCheck(loopResultName, "object"), returnStatement));
75703                 }
75704                 if (state.nonLocalJumps & 2) {
75705                     statements.push(factory.createIfStatement(factory.createStrictEquality(loopResultName, factory.createStringLiteral("break")), factory.createBreakStatement()));
75706                 }
75707                 if (state.labeledNonLocalBreaks || state.labeledNonLocalContinues) {
75708                     var caseClauses = [];
75709                     processLabeledJumps(state.labeledNonLocalBreaks, true, loopResultName, outerState, caseClauses);
75710                     processLabeledJumps(state.labeledNonLocalContinues, false, loopResultName, outerState, caseClauses);
75711                     statements.push(factory.createSwitchStatement(loopResultName, factory.createCaseBlock(caseClauses)));
75712                 }
75713             }
75714             return statements;
75715         }
75716         function setLabeledJump(state, isBreak, labelText, labelMarker) {
75717             if (isBreak) {
75718                 if (!state.labeledNonLocalBreaks) {
75719                     state.labeledNonLocalBreaks = new ts.Map();
75720                 }
75721                 state.labeledNonLocalBreaks.set(labelText, labelMarker);
75722             }
75723             else {
75724                 if (!state.labeledNonLocalContinues) {
75725                     state.labeledNonLocalContinues = new ts.Map();
75726                 }
75727                 state.labeledNonLocalContinues.set(labelText, labelMarker);
75728             }
75729         }
75730         function processLabeledJumps(table, isBreak, loopResultName, outerLoop, caseClauses) {
75731             if (!table) {
75732                 return;
75733             }
75734             table.forEach(function (labelMarker, labelText) {
75735                 var statements = [];
75736                 if (!outerLoop || (outerLoop.labels && outerLoop.labels.get(labelText))) {
75737                     var label = factory.createIdentifier(labelText);
75738                     statements.push(isBreak ? factory.createBreakStatement(label) : factory.createContinueStatement(label));
75739                 }
75740                 else {
75741                     setLabeledJump(outerLoop, isBreak, labelText, labelMarker);
75742                     statements.push(factory.createReturnStatement(loopResultName));
75743                 }
75744                 caseClauses.push(factory.createCaseClause(factory.createStringLiteral(labelMarker), statements));
75745             });
75746         }
75747         function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer) {
75748             var name = decl.name;
75749             if (ts.isBindingPattern(name)) {
75750                 for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
75751                     var element = _a[_i];
75752                     if (!ts.isOmittedExpression(element)) {
75753                         processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
75754                     }
75755                 }
75756             }
75757             else {
75758                 loopParameters.push(factory.createParameterDeclaration(undefined, undefined, undefined, name));
75759                 var checkFlags = resolver.getNodeCheckFlags(decl);
75760                 if (checkFlags & 4194304 || hasCapturedBindingsInForInitializer) {
75761                     var outParamName = factory.createUniqueName("out_" + ts.idText(name));
75762                     var flags = 0;
75763                     if (checkFlags & 4194304) {
75764                         flags |= 1;
75765                     }
75766                     if (ts.isForStatement(container) && container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
75767                         flags |= 2;
75768                     }
75769                     loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName });
75770                 }
75771             }
75772         }
75773         function addObjectLiteralMembers(expressions, node, receiver, start) {
75774             var properties = node.properties;
75775             var numProperties = properties.length;
75776             for (var i = start; i < numProperties; i++) {
75777                 var property = properties[i];
75778                 switch (property.kind) {
75779                     case 167:
75780                     case 168:
75781                         var accessors = ts.getAllAccessorDeclarations(node.properties, property);
75782                         if (property === accessors.firstAccessor) {
75783                             expressions.push(transformAccessorsToExpression(receiver, accessors, node, !!node.multiLine));
75784                         }
75785                         break;
75786                     case 165:
75787                         expressions.push(transformObjectLiteralMethodDeclarationToExpression(property, receiver, node, node.multiLine));
75788                         break;
75789                     case 288:
75790                         expressions.push(transformPropertyAssignmentToExpression(property, receiver, node.multiLine));
75791                         break;
75792                     case 289:
75793                         expressions.push(transformShorthandPropertyAssignmentToExpression(property, receiver, node.multiLine));
75794                         break;
75795                     default:
75796                         ts.Debug.failBadSyntaxKind(node);
75797                         break;
75798                 }
75799             }
75800         }
75801         function transformPropertyAssignmentToExpression(property, receiver, startsOnNewLine) {
75802             var expression = factory.createAssignment(ts.createMemberAccessForPropertyName(factory, receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), ts.visitNode(property.initializer, visitor, ts.isExpression));
75803             ts.setTextRange(expression, property);
75804             if (startsOnNewLine) {
75805                 ts.startOnNewLine(expression);
75806             }
75807             return expression;
75808         }
75809         function transformShorthandPropertyAssignmentToExpression(property, receiver, startsOnNewLine) {
75810             var expression = factory.createAssignment(ts.createMemberAccessForPropertyName(factory, receiver, ts.visitNode(property.name, visitor, ts.isPropertyName)), factory.cloneNode(property.name));
75811             ts.setTextRange(expression, property);
75812             if (startsOnNewLine) {
75813                 ts.startOnNewLine(expression);
75814             }
75815             return expression;
75816         }
75817         function transformObjectLiteralMethodDeclarationToExpression(method, receiver, container, startsOnNewLine) {
75818             var expression = factory.createAssignment(ts.createMemberAccessForPropertyName(factory, receiver, ts.visitNode(method.name, visitor, ts.isPropertyName)), transformFunctionLikeToExpression(method, method, undefined, container));
75819             ts.setTextRange(expression, method);
75820             if (startsOnNewLine) {
75821                 ts.startOnNewLine(expression);
75822             }
75823             return expression;
75824         }
75825         function visitCatchClause(node) {
75826             var ancestorFacts = enterSubtree(7104, 0);
75827             var updated;
75828             ts.Debug.assert(!!node.variableDeclaration, "Catch clause variable should always be present when downleveling ES2015.");
75829             if (ts.isBindingPattern(node.variableDeclaration.name)) {
75830                 var temp = factory.createTempVariable(undefined);
75831                 var newVariableDeclaration = factory.createVariableDeclaration(temp);
75832                 ts.setTextRange(newVariableDeclaration, node.variableDeclaration);
75833                 var vars = ts.flattenDestructuringBinding(node.variableDeclaration, visitor, context, 0, temp);
75834                 var list = factory.createVariableDeclarationList(vars);
75835                 ts.setTextRange(list, node.variableDeclaration);
75836                 var destructure = factory.createVariableStatement(undefined, list);
75837                 updated = factory.updateCatchClause(node, newVariableDeclaration, addStatementToStartOfBlock(node.block, destructure));
75838             }
75839             else {
75840                 updated = ts.visitEachChild(node, visitor, context);
75841             }
75842             exitSubtree(ancestorFacts, 0, 0);
75843             return updated;
75844         }
75845         function addStatementToStartOfBlock(block, statement) {
75846             var transformedStatements = ts.visitNodes(block.statements, visitor, ts.isStatement);
75847             return factory.updateBlock(block, __spreadArray([statement], transformedStatements));
75848         }
75849         function visitMethodDeclaration(node) {
75850             ts.Debug.assert(!ts.isComputedPropertyName(node.name));
75851             var functionExpression = transformFunctionLikeToExpression(node, ts.moveRangePos(node, -1), undefined, undefined);
75852             ts.setEmitFlags(functionExpression, 512 | ts.getEmitFlags(functionExpression));
75853             return ts.setTextRange(factory.createPropertyAssignment(node.name, functionExpression), node);
75854         }
75855         function visitAccessorDeclaration(node) {
75856             ts.Debug.assert(!ts.isComputedPropertyName(node.name));
75857             var savedConvertedLoopState = convertedLoopState;
75858             convertedLoopState = undefined;
75859             var ancestorFacts = enterSubtree(16286, 65);
75860             var updated;
75861             var parameters = ts.visitParameterList(node.parameters, visitor, context);
75862             var body = transformFunctionBody(node);
75863             if (node.kind === 167) {
75864                 updated = factory.updateGetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, node.type, body);
75865             }
75866             else {
75867                 updated = factory.updateSetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, body);
75868             }
75869             exitSubtree(ancestorFacts, 49152, 0);
75870             convertedLoopState = savedConvertedLoopState;
75871             return updated;
75872         }
75873         function visitShorthandPropertyAssignment(node) {
75874             return ts.setTextRange(factory.createPropertyAssignment(node.name, visitIdentifier(factory.cloneNode(node.name))), node);
75875         }
75876         function visitComputedPropertyName(node) {
75877             return ts.visitEachChild(node, visitor, context);
75878         }
75879         function visitYieldExpression(node) {
75880             return ts.visitEachChild(node, visitor, context);
75881         }
75882         function visitArrayLiteralExpression(node) {
75883             if (ts.some(node.elements, ts.isSpreadElement)) {
75884                 return transformAndSpreadElements(node.elements, true, !!node.multiLine, !!node.elements.hasTrailingComma);
75885             }
75886             return ts.visitEachChild(node, visitor, context);
75887         }
75888         function visitCallExpression(node) {
75889             if (ts.getEmitFlags(node) & 33554432) {
75890                 return visitTypeScriptClassWrapper(node);
75891             }
75892             var expression = ts.skipOuterExpressions(node.expression);
75893             if (expression.kind === 105 ||
75894                 ts.isSuperProperty(expression) ||
75895                 ts.some(node.arguments, ts.isSpreadElement)) {
75896                 return visitCallExpressionWithPotentialCapturedThisAssignment(node, true);
75897             }
75898             return factory.updateCallExpression(node, ts.visitNode(node.expression, callExpressionVisitor, ts.isExpression), undefined, ts.visitNodes(node.arguments, visitor, ts.isExpression));
75899         }
75900         function visitTypeScriptClassWrapper(node) {
75901             var body = ts.cast(ts.cast(ts.skipOuterExpressions(node.expression), ts.isArrowFunction).body, ts.isBlock);
75902             var isVariableStatementWithInitializer = function (stmt) { return ts.isVariableStatement(stmt) && !!ts.first(stmt.declarationList.declarations).initializer; };
75903             var savedConvertedLoopState = convertedLoopState;
75904             convertedLoopState = undefined;
75905             var bodyStatements = ts.visitNodes(body.statements, visitor, ts.isStatement);
75906             convertedLoopState = savedConvertedLoopState;
75907             var classStatements = ts.filter(bodyStatements, isVariableStatementWithInitializer);
75908             var remainingStatements = ts.filter(bodyStatements, function (stmt) { return !isVariableStatementWithInitializer(stmt); });
75909             var varStatement = ts.cast(ts.first(classStatements), ts.isVariableStatement);
75910             var variable = varStatement.declarationList.declarations[0];
75911             var initializer = ts.skipOuterExpressions(variable.initializer);
75912             var aliasAssignment = ts.tryCast(initializer, ts.isAssignmentExpression);
75913             var call = ts.cast(aliasAssignment ? ts.skipOuterExpressions(aliasAssignment.right) : initializer, ts.isCallExpression);
75914             var func = ts.cast(ts.skipOuterExpressions(call.expression), ts.isFunctionExpression);
75915             var funcStatements = func.body.statements;
75916             var classBodyStart = 0;
75917             var classBodyEnd = -1;
75918             var statements = [];
75919             if (aliasAssignment) {
75920                 var extendsCall = ts.tryCast(funcStatements[classBodyStart], ts.isExpressionStatement);
75921                 if (extendsCall) {
75922                     statements.push(extendsCall);
75923                     classBodyStart++;
75924                 }
75925                 statements.push(funcStatements[classBodyStart]);
75926                 classBodyStart++;
75927                 statements.push(factory.createExpressionStatement(factory.createAssignment(aliasAssignment.left, ts.cast(variable.name, ts.isIdentifier))));
75928             }
75929             while (!ts.isReturnStatement(ts.elementAt(funcStatements, classBodyEnd))) {
75930                 classBodyEnd--;
75931             }
75932             ts.addRange(statements, funcStatements, classBodyStart, classBodyEnd);
75933             if (classBodyEnd < -1) {
75934                 ts.addRange(statements, funcStatements, classBodyEnd + 1);
75935             }
75936             ts.addRange(statements, remainingStatements);
75937             ts.addRange(statements, classStatements, 1);
75938             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))));
75939         }
75940         function visitImmediateSuperCallInBody(node) {
75941             return visitCallExpressionWithPotentialCapturedThisAssignment(node, false);
75942         }
75943         function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
75944             if (node.transformFlags & 8192 ||
75945                 node.expression.kind === 105 ||
75946                 ts.isSuperProperty(ts.skipOuterExpressions(node.expression))) {
75947                 var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
75948                 if (node.expression.kind === 105) {
75949                     ts.setEmitFlags(thisArg, 4);
75950                 }
75951                 var resultingCall = void 0;
75952                 if (node.transformFlags & 8192) {
75953                     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));
75954                 }
75955                 else {
75956                     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);
75957                 }
75958                 if (node.expression.kind === 105) {
75959                     var initializer = factory.createLogicalOr(resultingCall, createActualThis());
75960                     resultingCall = assignToCapturedThis
75961                         ? factory.createAssignment(factory.createUniqueName("_this", 16 | 32), initializer)
75962                         : initializer;
75963                 }
75964                 return ts.setOriginalNode(resultingCall, node);
75965             }
75966             return ts.visitEachChild(node, visitor, context);
75967         }
75968         function visitNewExpression(node) {
75969             if (ts.some(node.arguments, ts.isSpreadElement)) {
75970                 var _a = factory.createCallBinding(factory.createPropertyAccessExpression(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
75971                 return factory.createNewExpression(factory.createFunctionApplyCall(ts.visitNode(target, visitor, ts.isExpression), thisArg, transformAndSpreadElements(factory.createNodeArray(__spreadArray([factory.createVoidZero()], node.arguments)), false, false, false)), undefined, []);
75972             }
75973             return ts.visitEachChild(node, visitor, context);
75974         }
75975         function transformAndSpreadElements(elements, needsUniqueCopy, multiLine, hasTrailingComma) {
75976             var numElements = elements.length;
75977             var segments = ts.flatten(ts.spanMap(elements, partitionSpread, function (partition, visitPartition, _start, end) {
75978                 return visitPartition(partition, multiLine, hasTrailingComma && end === numElements);
75979             }));
75980             if (segments.length === 1) {
75981                 var firstSegment = segments[0];
75982                 if (!needsUniqueCopy && !compilerOptions.downlevelIteration
75983                     || ts.isPackedArrayLiteral(firstSegment)
75984                     || ts.isCallToHelper(firstSegment, "___spreadArray")) {
75985                     return segments[0];
75986                 }
75987             }
75988             var helpers = emitHelpers();
75989             var startsWithSpread = ts.isSpreadElement(elements[0]);
75990             var expression = startsWithSpread ? factory.createArrayLiteralExpression() :
75991                 segments[0];
75992             for (var i = startsWithSpread ? 0 : 1; i < segments.length; i++) {
75993                 expression = helpers.createSpreadArrayHelper(expression, compilerOptions.downlevelIteration && !ts.isPackedArrayLiteral(segments[i]) ?
75994                     helpers.createReadHelper(segments[i], undefined) :
75995                     segments[i]);
75996             }
75997             return expression;
75998         }
75999         function partitionSpread(node) {
76000             return ts.isSpreadElement(node)
76001                 ? visitSpanOfSpreads
76002                 : visitSpanOfNonSpreads;
76003         }
76004         function visitSpanOfSpreads(chunk) {
76005             return ts.map(chunk, visitExpressionOfSpread);
76006         }
76007         function visitSpanOfNonSpreads(chunk, multiLine, hasTrailingComma) {
76008             return factory.createArrayLiteralExpression(ts.visitNodes(factory.createNodeArray(chunk, hasTrailingComma), visitor, ts.isExpression), multiLine);
76009         }
76010         function visitSpreadElement(node) {
76011             return ts.visitNode(node.expression, visitor, ts.isExpression);
76012         }
76013         function visitExpressionOfSpread(node) {
76014             return ts.visitNode(node.expression, visitor, ts.isExpression);
76015         }
76016         function visitTemplateLiteral(node) {
76017             return ts.setTextRange(factory.createStringLiteral(node.text), node);
76018         }
76019         function visitStringLiteral(node) {
76020             if (node.hasExtendedUnicodeEscape) {
76021                 return ts.setTextRange(factory.createStringLiteral(node.text), node);
76022             }
76023             return node;
76024         }
76025         function visitNumericLiteral(node) {
76026             if (node.numericLiteralFlags & 384) {
76027                 return ts.setTextRange(factory.createNumericLiteral(node.text), node);
76028             }
76029             return node;
76030         }
76031         function visitTaggedTemplateExpression(node) {
76032             return ts.processTaggedTemplateExpression(context, node, visitor, currentSourceFile, recordTaggedTemplateString, ts.ProcessLevel.All);
76033         }
76034         function visitTemplateExpression(node) {
76035             var expressions = [];
76036             addTemplateHead(expressions, node);
76037             addTemplateSpans(expressions, node);
76038             var expression = ts.reduceLeft(expressions, factory.createAdd);
76039             if (ts.nodeIsSynthesized(expression)) {
76040                 ts.setTextRange(expression, node);
76041             }
76042             return expression;
76043         }
76044         function shouldAddTemplateHead(node) {
76045             ts.Debug.assert(node.templateSpans.length !== 0);
76046             return node.head.text.length !== 0 || node.templateSpans[0].literal.text.length === 0;
76047         }
76048         function addTemplateHead(expressions, node) {
76049             if (!shouldAddTemplateHead(node)) {
76050                 return;
76051             }
76052             expressions.push(factory.createStringLiteral(node.head.text));
76053         }
76054         function addTemplateSpans(expressions, node) {
76055             for (var _i = 0, _a = node.templateSpans; _i < _a.length; _i++) {
76056                 var span = _a[_i];
76057                 expressions.push(ts.visitNode(span.expression, visitor, ts.isExpression));
76058                 if (span.literal.text.length !== 0) {
76059                     expressions.push(factory.createStringLiteral(span.literal.text));
76060                 }
76061             }
76062         }
76063         function visitSuperKeyword(isExpressionOfCall) {
76064             return hierarchyFacts & 8
76065                 && !isExpressionOfCall
76066                 ? factory.createPropertyAccessExpression(factory.createUniqueName("_super", 16 | 32), "prototype")
76067                 : factory.createUniqueName("_super", 16 | 32);
76068         }
76069         function visitMetaProperty(node) {
76070             if (node.keywordToken === 102 && node.name.escapedText === "target") {
76071                 hierarchyFacts |= 16384;
76072                 return factory.createUniqueName("_newTarget", 16 | 32);
76073             }
76074             return node;
76075         }
76076         function onEmitNode(hint, node, emitCallback) {
76077             if (enabledSubstitutions & 1 && ts.isFunctionLike(node)) {
76078                 var ancestorFacts = enterSubtree(16286, ts.getEmitFlags(node) & 8
76079                     ? 65 | 16
76080                     : 65);
76081                 previousOnEmitNode(hint, node, emitCallback);
76082                 exitSubtree(ancestorFacts, 0, 0);
76083                 return;
76084             }
76085             previousOnEmitNode(hint, node, emitCallback);
76086         }
76087         function enableSubstitutionsForBlockScopedBindings() {
76088             if ((enabledSubstitutions & 2) === 0) {
76089                 enabledSubstitutions |= 2;
76090                 context.enableSubstitution(78);
76091             }
76092         }
76093         function enableSubstitutionsForCapturedThis() {
76094             if ((enabledSubstitutions & 1) === 0) {
76095                 enabledSubstitutions |= 1;
76096                 context.enableSubstitution(107);
76097                 context.enableEmitNotification(166);
76098                 context.enableEmitNotification(165);
76099                 context.enableEmitNotification(167);
76100                 context.enableEmitNotification(168);
76101                 context.enableEmitNotification(209);
76102                 context.enableEmitNotification(208);
76103                 context.enableEmitNotification(251);
76104             }
76105         }
76106         function onSubstituteNode(hint, node) {
76107             node = previousOnSubstituteNode(hint, node);
76108             if (hint === 1) {
76109                 return substituteExpression(node);
76110             }
76111             if (ts.isIdentifier(node)) {
76112                 return substituteIdentifier(node);
76113             }
76114             return node;
76115         }
76116         function substituteIdentifier(node) {
76117             if (enabledSubstitutions & 2 && !ts.isInternalName(node)) {
76118                 var original = ts.getParseTreeNode(node, ts.isIdentifier);
76119                 if (original && isNameOfDeclarationWithCollidingName(original)) {
76120                     return ts.setTextRange(factory.getGeneratedNameForNode(original), node);
76121                 }
76122             }
76123             return node;
76124         }
76125         function isNameOfDeclarationWithCollidingName(node) {
76126             switch (node.parent.kind) {
76127                 case 198:
76128                 case 252:
76129                 case 255:
76130                 case 249:
76131                     return node.parent.name === node
76132                         && resolver.isDeclarationWithCollidingName(node.parent);
76133             }
76134             return false;
76135         }
76136         function substituteExpression(node) {
76137             switch (node.kind) {
76138                 case 78:
76139                     return substituteExpressionIdentifier(node);
76140                 case 107:
76141                     return substituteThisKeyword(node);
76142             }
76143             return node;
76144         }
76145         function substituteExpressionIdentifier(node) {
76146             if (enabledSubstitutions & 2 && !ts.isInternalName(node)) {
76147                 var declaration = resolver.getReferencedDeclarationWithCollidingName(node);
76148                 if (declaration && !(ts.isClassLike(declaration) && isPartOfClassBody(declaration, node))) {
76149                     return ts.setTextRange(factory.getGeneratedNameForNode(ts.getNameOfDeclaration(declaration)), node);
76150                 }
76151             }
76152             return node;
76153         }
76154         function isPartOfClassBody(declaration, node) {
76155             var currentNode = ts.getParseTreeNode(node);
76156             if (!currentNode || currentNode === declaration || currentNode.end <= declaration.pos || currentNode.pos >= declaration.end) {
76157                 return false;
76158             }
76159             var blockScope = ts.getEnclosingBlockScopeContainer(declaration);
76160             while (currentNode) {
76161                 if (currentNode === blockScope || currentNode === declaration) {
76162                     return false;
76163                 }
76164                 if (ts.isClassElement(currentNode) && currentNode.parent === declaration) {
76165                     return true;
76166                 }
76167                 currentNode = currentNode.parent;
76168             }
76169             return false;
76170         }
76171         function substituteThisKeyword(node) {
76172             if (enabledSubstitutions & 1
76173                 && hierarchyFacts & 16) {
76174                 return ts.setTextRange(factory.createUniqueName("_this", 16 | 32), node);
76175             }
76176             return node;
76177         }
76178         function getClassMemberPrefix(node, member) {
76179             return ts.hasSyntacticModifier(member, 32)
76180                 ? factory.getInternalName(node)
76181                 : factory.createPropertyAccessExpression(factory.getInternalName(node), "prototype");
76182         }
76183         function hasSynthesizedDefaultSuperCall(constructor, hasExtendsClause) {
76184             if (!constructor || !hasExtendsClause) {
76185                 return false;
76186             }
76187             if (ts.some(constructor.parameters)) {
76188                 return false;
76189             }
76190             var statement = ts.firstOrUndefined(constructor.body.statements);
76191             if (!statement || !ts.nodeIsSynthesized(statement) || statement.kind !== 233) {
76192                 return false;
76193             }
76194             var statementExpression = statement.expression;
76195             if (!ts.nodeIsSynthesized(statementExpression) || statementExpression.kind !== 203) {
76196                 return false;
76197             }
76198             var callTarget = statementExpression.expression;
76199             if (!ts.nodeIsSynthesized(callTarget) || callTarget.kind !== 105) {
76200                 return false;
76201             }
76202             var callArgument = ts.singleOrUndefined(statementExpression.arguments);
76203             if (!callArgument || !ts.nodeIsSynthesized(callArgument) || callArgument.kind !== 220) {
76204                 return false;
76205             }
76206             var expression = callArgument.expression;
76207             return ts.isIdentifier(expression) && expression.escapedText === "arguments";
76208         }
76209     }
76210     ts.transformES2015 = transformES2015;
76211 })(ts || (ts = {}));
76212 var ts;
76213 (function (ts) {
76214     function transformES5(context) {
76215         var factory = context.factory;
76216         var compilerOptions = context.getCompilerOptions();
76217         var previousOnEmitNode;
76218         var noSubstitution;
76219         if (compilerOptions.jsx === 1 || compilerOptions.jsx === 3) {
76220             previousOnEmitNode = context.onEmitNode;
76221             context.onEmitNode = onEmitNode;
76222             context.enableEmitNotification(275);
76223             context.enableEmitNotification(276);
76224             context.enableEmitNotification(274);
76225             noSubstitution = [];
76226         }
76227         var previousOnSubstituteNode = context.onSubstituteNode;
76228         context.onSubstituteNode = onSubstituteNode;
76229         context.enableSubstitution(201);
76230         context.enableSubstitution(288);
76231         return ts.chainBundle(context, transformSourceFile);
76232         function transformSourceFile(node) {
76233             return node;
76234         }
76235         function onEmitNode(hint, node, emitCallback) {
76236             switch (node.kind) {
76237                 case 275:
76238                 case 276:
76239                 case 274:
76240                     var tagName = node.tagName;
76241                     noSubstitution[ts.getOriginalNodeId(tagName)] = true;
76242                     break;
76243             }
76244             previousOnEmitNode(hint, node, emitCallback);
76245         }
76246         function onSubstituteNode(hint, node) {
76247             if (node.id && noSubstitution && noSubstitution[node.id]) {
76248                 return previousOnSubstituteNode(hint, node);
76249             }
76250             node = previousOnSubstituteNode(hint, node);
76251             if (ts.isPropertyAccessExpression(node)) {
76252                 return substitutePropertyAccessExpression(node);
76253             }
76254             else if (ts.isPropertyAssignment(node)) {
76255                 return substitutePropertyAssignment(node);
76256             }
76257             return node;
76258         }
76259         function substitutePropertyAccessExpression(node) {
76260             if (ts.isPrivateIdentifier(node.name)) {
76261                 return node;
76262             }
76263             var literalName = trySubstituteReservedName(node.name);
76264             if (literalName) {
76265                 return ts.setTextRange(factory.createElementAccessExpression(node.expression, literalName), node);
76266             }
76267             return node;
76268         }
76269         function substitutePropertyAssignment(node) {
76270             var literalName = ts.isIdentifier(node.name) && trySubstituteReservedName(node.name);
76271             if (literalName) {
76272                 return factory.updatePropertyAssignment(node, literalName, node.initializer);
76273             }
76274             return node;
76275         }
76276         function trySubstituteReservedName(name) {
76277             var token = name.originalKeywordKind || (ts.nodeIsSynthesized(name) ? ts.stringToToken(ts.idText(name)) : undefined);
76278             if (token !== undefined && token >= 80 && token <= 115) {
76279                 return ts.setTextRange(factory.createStringLiteralFromNode(name), name);
76280             }
76281             return undefined;
76282         }
76283     }
76284     ts.transformES5 = transformES5;
76285 })(ts || (ts = {}));
76286 var ts;
76287 (function (ts) {
76288     function getInstructionName(instruction) {
76289         switch (instruction) {
76290             case 2: return "return";
76291             case 3: return "break";
76292             case 4: return "yield";
76293             case 5: return "yield*";
76294             case 7: return "endfinally";
76295             default: return undefined;
76296         }
76297     }
76298     function transformGenerators(context) {
76299         var factory = context.factory, emitHelpers = context.getEmitHelperFactory, resumeLexicalEnvironment = context.resumeLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistFunctionDeclaration = context.hoistFunctionDeclaration, hoistVariableDeclaration = context.hoistVariableDeclaration;
76300         var compilerOptions = context.getCompilerOptions();
76301         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
76302         var resolver = context.getEmitResolver();
76303         var previousOnSubstituteNode = context.onSubstituteNode;
76304         context.onSubstituteNode = onSubstituteNode;
76305         var renamedCatchVariables;
76306         var renamedCatchVariableDeclarations;
76307         var inGeneratorFunctionBody;
76308         var inStatementContainingYield;
76309         var blocks;
76310         var blockOffsets;
76311         var blockActions;
76312         var blockStack;
76313         var labelOffsets;
76314         var labelExpressions;
76315         var nextLabelId = 1;
76316         var operations;
76317         var operationArguments;
76318         var operationLocations;
76319         var state;
76320         var blockIndex = 0;
76321         var labelNumber = 0;
76322         var labelNumbers;
76323         var lastOperationWasAbrupt;
76324         var lastOperationWasCompletion;
76325         var clauses;
76326         var statements;
76327         var exceptionBlockStack;
76328         var currentExceptionBlock;
76329         var withBlockStack;
76330         return ts.chainBundle(context, transformSourceFile);
76331         function transformSourceFile(node) {
76332             if (node.isDeclarationFile || (node.transformFlags & 512) === 0) {
76333                 return node;
76334             }
76335             var visited = ts.visitEachChild(node, visitor, context);
76336             ts.addEmitHelpers(visited, context.readEmitHelpers());
76337             return visited;
76338         }
76339         function visitor(node) {
76340             var transformFlags = node.transformFlags;
76341             if (inStatementContainingYield) {
76342                 return visitJavaScriptInStatementContainingYield(node);
76343             }
76344             else if (inGeneratorFunctionBody) {
76345                 return visitJavaScriptInGeneratorFunctionBody(node);
76346             }
76347             else if (ts.isFunctionLikeDeclaration(node) && node.asteriskToken) {
76348                 return visitGenerator(node);
76349             }
76350             else if (transformFlags & 512) {
76351                 return ts.visitEachChild(node, visitor, context);
76352             }
76353             else {
76354                 return node;
76355             }
76356         }
76357         function visitJavaScriptInStatementContainingYield(node) {
76358             switch (node.kind) {
76359                 case 235:
76360                     return visitDoStatement(node);
76361                 case 236:
76362                     return visitWhileStatement(node);
76363                 case 244:
76364                     return visitSwitchStatement(node);
76365                 case 245:
76366                     return visitLabeledStatement(node);
76367                 default:
76368                     return visitJavaScriptInGeneratorFunctionBody(node);
76369             }
76370         }
76371         function visitJavaScriptInGeneratorFunctionBody(node) {
76372             switch (node.kind) {
76373                 case 251:
76374                     return visitFunctionDeclaration(node);
76375                 case 208:
76376                     return visitFunctionExpression(node);
76377                 case 167:
76378                 case 168:
76379                     return visitAccessorDeclaration(node);
76380                 case 232:
76381                     return visitVariableStatement(node);
76382                 case 237:
76383                     return visitForStatement(node);
76384                 case 238:
76385                     return visitForInStatement(node);
76386                 case 241:
76387                     return visitBreakStatement(node);
76388                 case 240:
76389                     return visitContinueStatement(node);
76390                 case 242:
76391                     return visitReturnStatement(node);
76392                 default:
76393                     if (node.transformFlags & 262144) {
76394                         return visitJavaScriptContainingYield(node);
76395                     }
76396                     else if (node.transformFlags & (512 | 1048576)) {
76397                         return ts.visitEachChild(node, visitor, context);
76398                     }
76399                     else {
76400                         return node;
76401                     }
76402             }
76403         }
76404         function visitJavaScriptContainingYield(node) {
76405             switch (node.kind) {
76406                 case 216:
76407                     return visitBinaryExpression(node);
76408                 case 337:
76409                     return visitCommaListExpression(node);
76410                 case 217:
76411                     return visitConditionalExpression(node);
76412                 case 219:
76413                     return visitYieldExpression(node);
76414                 case 199:
76415                     return visitArrayLiteralExpression(node);
76416                 case 200:
76417                     return visitObjectLiteralExpression(node);
76418                 case 202:
76419                     return visitElementAccessExpression(node);
76420                 case 203:
76421                     return visitCallExpression(node);
76422                 case 204:
76423                     return visitNewExpression(node);
76424                 default:
76425                     return ts.visitEachChild(node, visitor, context);
76426             }
76427         }
76428         function visitGenerator(node) {
76429             switch (node.kind) {
76430                 case 251:
76431                     return visitFunctionDeclaration(node);
76432                 case 208:
76433                     return visitFunctionExpression(node);
76434                 default:
76435                     return ts.Debug.failBadSyntaxKind(node);
76436             }
76437         }
76438         function visitFunctionDeclaration(node) {
76439             if (node.asteriskToken) {
76440                 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);
76441             }
76442             else {
76443                 var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
76444                 var savedInStatementContainingYield = inStatementContainingYield;
76445                 inGeneratorFunctionBody = false;
76446                 inStatementContainingYield = false;
76447                 node = ts.visitEachChild(node, visitor, context);
76448                 inGeneratorFunctionBody = savedInGeneratorFunctionBody;
76449                 inStatementContainingYield = savedInStatementContainingYield;
76450             }
76451             if (inGeneratorFunctionBody) {
76452                 hoistFunctionDeclaration(node);
76453                 return undefined;
76454             }
76455             else {
76456                 return node;
76457             }
76458         }
76459         function visitFunctionExpression(node) {
76460             if (node.asteriskToken) {
76461                 node = ts.setOriginalNode(ts.setTextRange(factory.createFunctionExpression(undefined, undefined, node.name, undefined, ts.visitParameterList(node.parameters, visitor, context), undefined, transformGeneratorFunctionBody(node.body)), node), node);
76462             }
76463             else {
76464                 var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
76465                 var savedInStatementContainingYield = inStatementContainingYield;
76466                 inGeneratorFunctionBody = false;
76467                 inStatementContainingYield = false;
76468                 node = ts.visitEachChild(node, visitor, context);
76469                 inGeneratorFunctionBody = savedInGeneratorFunctionBody;
76470                 inStatementContainingYield = savedInStatementContainingYield;
76471             }
76472             return node;
76473         }
76474         function visitAccessorDeclaration(node) {
76475             var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
76476             var savedInStatementContainingYield = inStatementContainingYield;
76477             inGeneratorFunctionBody = false;
76478             inStatementContainingYield = false;
76479             node = ts.visitEachChild(node, visitor, context);
76480             inGeneratorFunctionBody = savedInGeneratorFunctionBody;
76481             inStatementContainingYield = savedInStatementContainingYield;
76482             return node;
76483         }
76484         function transformGeneratorFunctionBody(body) {
76485             var statements = [];
76486             var savedInGeneratorFunctionBody = inGeneratorFunctionBody;
76487             var savedInStatementContainingYield = inStatementContainingYield;
76488             var savedBlocks = blocks;
76489             var savedBlockOffsets = blockOffsets;
76490             var savedBlockActions = blockActions;
76491             var savedBlockStack = blockStack;
76492             var savedLabelOffsets = labelOffsets;
76493             var savedLabelExpressions = labelExpressions;
76494             var savedNextLabelId = nextLabelId;
76495             var savedOperations = operations;
76496             var savedOperationArguments = operationArguments;
76497             var savedOperationLocations = operationLocations;
76498             var savedState = state;
76499             inGeneratorFunctionBody = true;
76500             inStatementContainingYield = false;
76501             blocks = undefined;
76502             blockOffsets = undefined;
76503             blockActions = undefined;
76504             blockStack = undefined;
76505             labelOffsets = undefined;
76506             labelExpressions = undefined;
76507             nextLabelId = 1;
76508             operations = undefined;
76509             operationArguments = undefined;
76510             operationLocations = undefined;
76511             state = factory.createTempVariable(undefined);
76512             resumeLexicalEnvironment();
76513             var statementOffset = factory.copyPrologue(body.statements, statements, false, visitor);
76514             transformAndEmitStatements(body.statements, statementOffset);
76515             var buildResult = build();
76516             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
76517             statements.push(factory.createReturnStatement(buildResult));
76518             inGeneratorFunctionBody = savedInGeneratorFunctionBody;
76519             inStatementContainingYield = savedInStatementContainingYield;
76520             blocks = savedBlocks;
76521             blockOffsets = savedBlockOffsets;
76522             blockActions = savedBlockActions;
76523             blockStack = savedBlockStack;
76524             labelOffsets = savedLabelOffsets;
76525             labelExpressions = savedLabelExpressions;
76526             nextLabelId = savedNextLabelId;
76527             operations = savedOperations;
76528             operationArguments = savedOperationArguments;
76529             operationLocations = savedOperationLocations;
76530             state = savedState;
76531             return ts.setTextRange(factory.createBlock(statements, body.multiLine), body);
76532         }
76533         function visitVariableStatement(node) {
76534             if (node.transformFlags & 262144) {
76535                 transformAndEmitVariableDeclarationList(node.declarationList);
76536                 return undefined;
76537             }
76538             else {
76539                 if (ts.getEmitFlags(node) & 1048576) {
76540                     return node;
76541                 }
76542                 for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
76543                     var variable = _a[_i];
76544                     hoistVariableDeclaration(variable.name);
76545                 }
76546                 var variables = ts.getInitializedVariables(node.declarationList);
76547                 if (variables.length === 0) {
76548                     return undefined;
76549                 }
76550                 return ts.setSourceMapRange(factory.createExpressionStatement(factory.inlineExpressions(ts.map(variables, transformInitializedVariable))), node);
76551             }
76552         }
76553         function visitBinaryExpression(node) {
76554             var assoc = ts.getExpressionAssociativity(node);
76555             switch (assoc) {
76556                 case 0:
76557                     return visitLeftAssociativeBinaryExpression(node);
76558                 case 1:
76559                     return visitRightAssociativeBinaryExpression(node);
76560                 default:
76561                     return ts.Debug.assertNever(assoc);
76562             }
76563         }
76564         function visitRightAssociativeBinaryExpression(node) {
76565             var left = node.left, right = node.right;
76566             if (containsYield(right)) {
76567                 var target = void 0;
76568                 switch (left.kind) {
76569                     case 201:
76570                         target = factory.updatePropertyAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), left.name);
76571                         break;
76572                     case 202:
76573                         target = factory.updateElementAccessExpression(left, cacheExpression(ts.visitNode(left.expression, visitor, ts.isLeftHandSideExpression)), cacheExpression(ts.visitNode(left.argumentExpression, visitor, ts.isExpression)));
76574                         break;
76575                     default:
76576                         target = ts.visitNode(left, visitor, ts.isExpression);
76577                         break;
76578                 }
76579                 var operator = node.operatorToken.kind;
76580                 if (ts.isCompoundAssignment(operator)) {
76581                     return ts.setTextRange(factory.createAssignment(target, ts.setTextRange(factory.createBinaryExpression(cacheExpression(target), ts.getNonAssignmentOperatorForCompoundAssignment(operator), ts.visitNode(right, visitor, ts.isExpression)), node)), node);
76582                 }
76583                 else {
76584                     return factory.updateBinaryExpression(node, target, node.operatorToken, ts.visitNode(right, visitor, ts.isExpression));
76585                 }
76586             }
76587             return ts.visitEachChild(node, visitor, context);
76588         }
76589         function visitLeftAssociativeBinaryExpression(node) {
76590             if (containsYield(node.right)) {
76591                 if (ts.isLogicalOperator(node.operatorToken.kind)) {
76592                     return visitLogicalBinaryExpression(node);
76593                 }
76594                 else if (node.operatorToken.kind === 27) {
76595                     return visitCommaExpression(node);
76596                 }
76597                 return factory.updateBinaryExpression(node, cacheExpression(ts.visitNode(node.left, visitor, ts.isExpression)), node.operatorToken, ts.visitNode(node.right, visitor, ts.isExpression));
76598             }
76599             return ts.visitEachChild(node, visitor, context);
76600         }
76601         function visitCommaExpression(node) {
76602             var pendingExpressions = [];
76603             visit(node.left);
76604             visit(node.right);
76605             return factory.inlineExpressions(pendingExpressions);
76606             function visit(node) {
76607                 if (ts.isBinaryExpression(node) && node.operatorToken.kind === 27) {
76608                     visit(node.left);
76609                     visit(node.right);
76610                 }
76611                 else {
76612                     if (containsYield(node) && pendingExpressions.length > 0) {
76613                         emitWorker(1, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]);
76614                         pendingExpressions = [];
76615                     }
76616                     pendingExpressions.push(ts.visitNode(node, visitor, ts.isExpression));
76617                 }
76618             }
76619         }
76620         function visitCommaListExpression(node) {
76621             var pendingExpressions = [];
76622             for (var _i = 0, _a = node.elements; _i < _a.length; _i++) {
76623                 var elem = _a[_i];
76624                 if (ts.isBinaryExpression(elem) && elem.operatorToken.kind === 27) {
76625                     pendingExpressions.push(visitCommaExpression(elem));
76626                 }
76627                 else {
76628                     if (containsYield(elem) && pendingExpressions.length > 0) {
76629                         emitWorker(1, [factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))]);
76630                         pendingExpressions = [];
76631                     }
76632                     pendingExpressions.push(ts.visitNode(elem, visitor, ts.isExpression));
76633                 }
76634             }
76635             return factory.inlineExpressions(pendingExpressions);
76636         }
76637         function visitLogicalBinaryExpression(node) {
76638             var resultLabel = defineLabel();
76639             var resultLocal = declareLocal();
76640             emitAssignment(resultLocal, ts.visitNode(node.left, visitor, ts.isExpression), node.left);
76641             if (node.operatorToken.kind === 55) {
76642                 emitBreakWhenFalse(resultLabel, resultLocal, node.left);
76643             }
76644             else {
76645                 emitBreakWhenTrue(resultLabel, resultLocal, node.left);
76646             }
76647             emitAssignment(resultLocal, ts.visitNode(node.right, visitor, ts.isExpression), node.right);
76648             markLabel(resultLabel);
76649             return resultLocal;
76650         }
76651         function visitConditionalExpression(node) {
76652             if (containsYield(node.whenTrue) || containsYield(node.whenFalse)) {
76653                 var whenFalseLabel = defineLabel();
76654                 var resultLabel = defineLabel();
76655                 var resultLocal = declareLocal();
76656                 emitBreakWhenFalse(whenFalseLabel, ts.visitNode(node.condition, visitor, ts.isExpression), node.condition);
76657                 emitAssignment(resultLocal, ts.visitNode(node.whenTrue, visitor, ts.isExpression), node.whenTrue);
76658                 emitBreak(resultLabel);
76659                 markLabel(whenFalseLabel);
76660                 emitAssignment(resultLocal, ts.visitNode(node.whenFalse, visitor, ts.isExpression), node.whenFalse);
76661                 markLabel(resultLabel);
76662                 return resultLocal;
76663             }
76664             return ts.visitEachChild(node, visitor, context);
76665         }
76666         function visitYieldExpression(node) {
76667             var resumeLabel = defineLabel();
76668             var expression = ts.visitNode(node.expression, visitor, ts.isExpression);
76669             if (node.asteriskToken) {
76670                 var iterator = (ts.getEmitFlags(node.expression) & 8388608) === 0
76671                     ? ts.setTextRange(emitHelpers().createValuesHelper(expression), node)
76672                     : expression;
76673                 emitYieldStar(iterator, node);
76674             }
76675             else {
76676                 emitYield(expression, node);
76677             }
76678             markLabel(resumeLabel);
76679             return createGeneratorResume(node);
76680         }
76681         function visitArrayLiteralExpression(node) {
76682             return visitElements(node.elements, undefined, undefined, node.multiLine);
76683         }
76684         function visitElements(elements, leadingElement, location, multiLine) {
76685             var numInitialElements = countInitialNodesWithoutYield(elements);
76686             var temp;
76687             if (numInitialElements > 0) {
76688                 temp = declareLocal();
76689                 var initialElements = ts.visitNodes(elements, visitor, ts.isExpression, 0, numInitialElements);
76690                 emitAssignment(temp, factory.createArrayLiteralExpression(leadingElement
76691                     ? __spreadArray([leadingElement], initialElements) : initialElements));
76692                 leadingElement = undefined;
76693             }
76694             var expressions = ts.reduceLeft(elements, reduceElement, [], numInitialElements);
76695             return temp
76696                 ? factory.createArrayConcatCall(temp, [factory.createArrayLiteralExpression(expressions, multiLine)])
76697                 : ts.setTextRange(factory.createArrayLiteralExpression(leadingElement ? __spreadArray([leadingElement], expressions) : expressions, multiLine), location);
76698             function reduceElement(expressions, element) {
76699                 if (containsYield(element) && expressions.length > 0) {
76700                     var hasAssignedTemp = temp !== undefined;
76701                     if (!temp) {
76702                         temp = declareLocal();
76703                     }
76704                     emitAssignment(temp, hasAssignedTemp
76705                         ? factory.createArrayConcatCall(temp, [factory.createArrayLiteralExpression(expressions, multiLine)])
76706                         : factory.createArrayLiteralExpression(leadingElement ? __spreadArray([leadingElement], expressions) : expressions, multiLine));
76707                     leadingElement = undefined;
76708                     expressions = [];
76709                 }
76710                 expressions.push(ts.visitNode(element, visitor, ts.isExpression));
76711                 return expressions;
76712             }
76713         }
76714         function visitObjectLiteralExpression(node) {
76715             var properties = node.properties;
76716             var multiLine = node.multiLine;
76717             var numInitialProperties = countInitialNodesWithoutYield(properties);
76718             var temp = declareLocal();
76719             emitAssignment(temp, factory.createObjectLiteralExpression(ts.visitNodes(properties, visitor, ts.isObjectLiteralElementLike, 0, numInitialProperties), multiLine));
76720             var expressions = ts.reduceLeft(properties, reduceProperty, [], numInitialProperties);
76721             expressions.push(multiLine ? ts.startOnNewLine(ts.setParent(ts.setTextRange(factory.cloneNode(temp), temp), temp.parent)) : temp);
76722             return factory.inlineExpressions(expressions);
76723             function reduceProperty(expressions, property) {
76724                 if (containsYield(property) && expressions.length > 0) {
76725                     emitStatement(factory.createExpressionStatement(factory.inlineExpressions(expressions)));
76726                     expressions = [];
76727                 }
76728                 var expression = ts.createExpressionForObjectLiteralElementLike(factory, node, property, temp);
76729                 var visited = ts.visitNode(expression, visitor, ts.isExpression);
76730                 if (visited) {
76731                     if (multiLine) {
76732                         ts.startOnNewLine(visited);
76733                     }
76734                     expressions.push(visited);
76735                 }
76736                 return expressions;
76737             }
76738         }
76739         function visitElementAccessExpression(node) {
76740             if (containsYield(node.argumentExpression)) {
76741                 return factory.updateElementAccessExpression(node, cacheExpression(ts.visitNode(node.expression, visitor, ts.isLeftHandSideExpression)), ts.visitNode(node.argumentExpression, visitor, ts.isExpression));
76742             }
76743             return ts.visitEachChild(node, visitor, context);
76744         }
76745         function visitCallExpression(node) {
76746             if (!ts.isImportCall(node) && ts.forEach(node.arguments, containsYield)) {
76747                 var _a = factory.createCallBinding(node.expression, hoistVariableDeclaration, languageVersion, true), target = _a.target, thisArg = _a.thisArg;
76748                 return ts.setOriginalNode(ts.setTextRange(factory.createFunctionApplyCall(cacheExpression(ts.visitNode(target, visitor, ts.isLeftHandSideExpression)), thisArg, visitElements(node.arguments)), node), node);
76749             }
76750             return ts.visitEachChild(node, visitor, context);
76751         }
76752         function visitNewExpression(node) {
76753             if (ts.forEach(node.arguments, containsYield)) {
76754                 var _a = factory.createCallBinding(factory.createPropertyAccessExpression(node.expression, "bind"), hoistVariableDeclaration), target = _a.target, thisArg = _a.thisArg;
76755                 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);
76756             }
76757             return ts.visitEachChild(node, visitor, context);
76758         }
76759         function transformAndEmitStatements(statements, start) {
76760             if (start === void 0) { start = 0; }
76761             var numStatements = statements.length;
76762             for (var i = start; i < numStatements; i++) {
76763                 transformAndEmitStatement(statements[i]);
76764             }
76765         }
76766         function transformAndEmitEmbeddedStatement(node) {
76767             if (ts.isBlock(node)) {
76768                 transformAndEmitStatements(node.statements);
76769             }
76770             else {
76771                 transformAndEmitStatement(node);
76772             }
76773         }
76774         function transformAndEmitStatement(node) {
76775             var savedInStatementContainingYield = inStatementContainingYield;
76776             if (!inStatementContainingYield) {
76777                 inStatementContainingYield = containsYield(node);
76778             }
76779             transformAndEmitStatementWorker(node);
76780             inStatementContainingYield = savedInStatementContainingYield;
76781         }
76782         function transformAndEmitStatementWorker(node) {
76783             switch (node.kind) {
76784                 case 230:
76785                     return transformAndEmitBlock(node);
76786                 case 233:
76787                     return transformAndEmitExpressionStatement(node);
76788                 case 234:
76789                     return transformAndEmitIfStatement(node);
76790                 case 235:
76791                     return transformAndEmitDoStatement(node);
76792                 case 236:
76793                     return transformAndEmitWhileStatement(node);
76794                 case 237:
76795                     return transformAndEmitForStatement(node);
76796                 case 238:
76797                     return transformAndEmitForInStatement(node);
76798                 case 240:
76799                     return transformAndEmitContinueStatement(node);
76800                 case 241:
76801                     return transformAndEmitBreakStatement(node);
76802                 case 242:
76803                     return transformAndEmitReturnStatement(node);
76804                 case 243:
76805                     return transformAndEmitWithStatement(node);
76806                 case 244:
76807                     return transformAndEmitSwitchStatement(node);
76808                 case 245:
76809                     return transformAndEmitLabeledStatement(node);
76810                 case 246:
76811                     return transformAndEmitThrowStatement(node);
76812                 case 247:
76813                     return transformAndEmitTryStatement(node);
76814                 default:
76815                     return emitStatement(ts.visitNode(node, visitor, ts.isStatement));
76816             }
76817         }
76818         function transformAndEmitBlock(node) {
76819             if (containsYield(node)) {
76820                 transformAndEmitStatements(node.statements);
76821             }
76822             else {
76823                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
76824             }
76825         }
76826         function transformAndEmitExpressionStatement(node) {
76827             emitStatement(ts.visitNode(node, visitor, ts.isStatement));
76828         }
76829         function transformAndEmitVariableDeclarationList(node) {
76830             for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) {
76831                 var variable = _a[_i];
76832                 var name = factory.cloneNode(variable.name);
76833                 ts.setCommentRange(name, variable.name);
76834                 hoistVariableDeclaration(name);
76835             }
76836             var variables = ts.getInitializedVariables(node);
76837             var numVariables = variables.length;
76838             var variablesWritten = 0;
76839             var pendingExpressions = [];
76840             while (variablesWritten < numVariables) {
76841                 for (var i = variablesWritten; i < numVariables; i++) {
76842                     var variable = variables[i];
76843                     if (containsYield(variable.initializer) && pendingExpressions.length > 0) {
76844                         break;
76845                     }
76846                     pendingExpressions.push(transformInitializedVariable(variable));
76847                 }
76848                 if (pendingExpressions.length) {
76849                     emitStatement(factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions)));
76850                     variablesWritten += pendingExpressions.length;
76851                     pendingExpressions = [];
76852                 }
76853             }
76854             return undefined;
76855         }
76856         function transformInitializedVariable(node) {
76857             return ts.setSourceMapRange(factory.createAssignment(ts.setSourceMapRange(factory.cloneNode(node.name), node.name), ts.visitNode(node.initializer, visitor, ts.isExpression)), node);
76858         }
76859         function transformAndEmitIfStatement(node) {
76860             if (containsYield(node)) {
76861                 if (containsYield(node.thenStatement) || containsYield(node.elseStatement)) {
76862                     var endLabel = defineLabel();
76863                     var elseLabel = node.elseStatement ? defineLabel() : undefined;
76864                     emitBreakWhenFalse(node.elseStatement ? elseLabel : endLabel, ts.visitNode(node.expression, visitor, ts.isExpression), node.expression);
76865                     transformAndEmitEmbeddedStatement(node.thenStatement);
76866                     if (node.elseStatement) {
76867                         emitBreak(endLabel);
76868                         markLabel(elseLabel);
76869                         transformAndEmitEmbeddedStatement(node.elseStatement);
76870                     }
76871                     markLabel(endLabel);
76872                 }
76873                 else {
76874                     emitStatement(ts.visitNode(node, visitor, ts.isStatement));
76875                 }
76876             }
76877             else {
76878                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
76879             }
76880         }
76881         function transformAndEmitDoStatement(node) {
76882             if (containsYield(node)) {
76883                 var conditionLabel = defineLabel();
76884                 var loopLabel = defineLabel();
76885                 beginLoopBlock(conditionLabel);
76886                 markLabel(loopLabel);
76887                 transformAndEmitEmbeddedStatement(node.statement);
76888                 markLabel(conditionLabel);
76889                 emitBreakWhenTrue(loopLabel, ts.visitNode(node.expression, visitor, ts.isExpression));
76890                 endLoopBlock();
76891             }
76892             else {
76893                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
76894             }
76895         }
76896         function visitDoStatement(node) {
76897             if (inStatementContainingYield) {
76898                 beginScriptLoopBlock();
76899                 node = ts.visitEachChild(node, visitor, context);
76900                 endLoopBlock();
76901                 return node;
76902             }
76903             else {
76904                 return ts.visitEachChild(node, visitor, context);
76905             }
76906         }
76907         function transformAndEmitWhileStatement(node) {
76908             if (containsYield(node)) {
76909                 var loopLabel = defineLabel();
76910                 var endLabel = beginLoopBlock(loopLabel);
76911                 markLabel(loopLabel);
76912                 emitBreakWhenFalse(endLabel, ts.visitNode(node.expression, visitor, ts.isExpression));
76913                 transformAndEmitEmbeddedStatement(node.statement);
76914                 emitBreak(loopLabel);
76915                 endLoopBlock();
76916             }
76917             else {
76918                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
76919             }
76920         }
76921         function visitWhileStatement(node) {
76922             if (inStatementContainingYield) {
76923                 beginScriptLoopBlock();
76924                 node = ts.visitEachChild(node, visitor, context);
76925                 endLoopBlock();
76926                 return node;
76927             }
76928             else {
76929                 return ts.visitEachChild(node, visitor, context);
76930             }
76931         }
76932         function transformAndEmitForStatement(node) {
76933             if (containsYield(node)) {
76934                 var conditionLabel = defineLabel();
76935                 var incrementLabel = defineLabel();
76936                 var endLabel = beginLoopBlock(incrementLabel);
76937                 if (node.initializer) {
76938                     var initializer = node.initializer;
76939                     if (ts.isVariableDeclarationList(initializer)) {
76940                         transformAndEmitVariableDeclarationList(initializer);
76941                     }
76942                     else {
76943                         emitStatement(ts.setTextRange(factory.createExpressionStatement(ts.visitNode(initializer, visitor, ts.isExpression)), initializer));
76944                     }
76945                 }
76946                 markLabel(conditionLabel);
76947                 if (node.condition) {
76948                     emitBreakWhenFalse(endLabel, ts.visitNode(node.condition, visitor, ts.isExpression));
76949                 }
76950                 transformAndEmitEmbeddedStatement(node.statement);
76951                 markLabel(incrementLabel);
76952                 if (node.incrementor) {
76953                     emitStatement(ts.setTextRange(factory.createExpressionStatement(ts.visitNode(node.incrementor, visitor, ts.isExpression)), node.incrementor));
76954                 }
76955                 emitBreak(conditionLabel);
76956                 endLoopBlock();
76957             }
76958             else {
76959                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
76960             }
76961         }
76962         function visitForStatement(node) {
76963             if (inStatementContainingYield) {
76964                 beginScriptLoopBlock();
76965             }
76966             var initializer = node.initializer;
76967             if (initializer && ts.isVariableDeclarationList(initializer)) {
76968                 for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
76969                     var variable = _a[_i];
76970                     hoistVariableDeclaration(variable.name);
76971                 }
76972                 var variables = ts.getInitializedVariables(initializer);
76973                 node = factory.updateForStatement(node, variables.length > 0
76974                     ? factory.inlineExpressions(ts.map(variables, transformInitializedVariable))
76975                     : undefined, ts.visitNode(node.condition, visitor, ts.isExpression), ts.visitNode(node.incrementor, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock));
76976             }
76977             else {
76978                 node = ts.visitEachChild(node, visitor, context);
76979             }
76980             if (inStatementContainingYield) {
76981                 endLoopBlock();
76982             }
76983             return node;
76984         }
76985         function transformAndEmitForInStatement(node) {
76986             if (containsYield(node)) {
76987                 var keysArray = declareLocal();
76988                 var key = declareLocal();
76989                 var keysIndex = factory.createLoopVariable();
76990                 var initializer = node.initializer;
76991                 hoistVariableDeclaration(keysIndex);
76992                 emitAssignment(keysArray, factory.createArrayLiteralExpression());
76993                 emitStatement(factory.createForInStatement(key, ts.visitNode(node.expression, visitor, ts.isExpression), factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(keysArray, "push"), undefined, [key]))));
76994                 emitAssignment(keysIndex, factory.createNumericLiteral(0));
76995                 var conditionLabel = defineLabel();
76996                 var incrementLabel = defineLabel();
76997                 var endLabel = beginLoopBlock(incrementLabel);
76998                 markLabel(conditionLabel);
76999                 emitBreakWhenFalse(endLabel, factory.createLessThan(keysIndex, factory.createPropertyAccessExpression(keysArray, "length")));
77000                 var variable = void 0;
77001                 if (ts.isVariableDeclarationList(initializer)) {
77002                     for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
77003                         var variable_1 = _a[_i];
77004                         hoistVariableDeclaration(variable_1.name);
77005                     }
77006                     variable = factory.cloneNode(initializer.declarations[0].name);
77007                 }
77008                 else {
77009                     variable = ts.visitNode(initializer, visitor, ts.isExpression);
77010                     ts.Debug.assert(ts.isLeftHandSideExpression(variable));
77011                 }
77012                 emitAssignment(variable, factory.createElementAccessExpression(keysArray, keysIndex));
77013                 transformAndEmitEmbeddedStatement(node.statement);
77014                 markLabel(incrementLabel);
77015                 emitStatement(factory.createExpressionStatement(factory.createPostfixIncrement(keysIndex)));
77016                 emitBreak(conditionLabel);
77017                 endLoopBlock();
77018             }
77019             else {
77020                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
77021             }
77022         }
77023         function visitForInStatement(node) {
77024             if (inStatementContainingYield) {
77025                 beginScriptLoopBlock();
77026             }
77027             var initializer = node.initializer;
77028             if (ts.isVariableDeclarationList(initializer)) {
77029                 for (var _i = 0, _a = initializer.declarations; _i < _a.length; _i++) {
77030                     var variable = _a[_i];
77031                     hoistVariableDeclaration(variable.name);
77032                 }
77033                 node = factory.updateForInStatement(node, initializer.declarations[0].name, ts.visitNode(node.expression, visitor, ts.isExpression), ts.visitNode(node.statement, visitor, ts.isStatement, factory.liftToBlock));
77034             }
77035             else {
77036                 node = ts.visitEachChild(node, visitor, context);
77037             }
77038             if (inStatementContainingYield) {
77039                 endLoopBlock();
77040             }
77041             return node;
77042         }
77043         function transformAndEmitContinueStatement(node) {
77044             var label = findContinueTarget(node.label ? ts.idText(node.label) : undefined);
77045             if (label > 0) {
77046                 emitBreak(label, node);
77047             }
77048             else {
77049                 emitStatement(node);
77050             }
77051         }
77052         function visitContinueStatement(node) {
77053             if (inStatementContainingYield) {
77054                 var label = findContinueTarget(node.label && ts.idText(node.label));
77055                 if (label > 0) {
77056                     return createInlineBreak(label, node);
77057                 }
77058             }
77059             return ts.visitEachChild(node, visitor, context);
77060         }
77061         function transformAndEmitBreakStatement(node) {
77062             var label = findBreakTarget(node.label ? ts.idText(node.label) : undefined);
77063             if (label > 0) {
77064                 emitBreak(label, node);
77065             }
77066             else {
77067                 emitStatement(node);
77068             }
77069         }
77070         function visitBreakStatement(node) {
77071             if (inStatementContainingYield) {
77072                 var label = findBreakTarget(node.label && ts.idText(node.label));
77073                 if (label > 0) {
77074                     return createInlineBreak(label, node);
77075                 }
77076             }
77077             return ts.visitEachChild(node, visitor, context);
77078         }
77079         function transformAndEmitReturnStatement(node) {
77080             emitReturn(ts.visitNode(node.expression, visitor, ts.isExpression), node);
77081         }
77082         function visitReturnStatement(node) {
77083             return createInlineReturn(ts.visitNode(node.expression, visitor, ts.isExpression), node);
77084         }
77085         function transformAndEmitWithStatement(node) {
77086             if (containsYield(node)) {
77087                 beginWithBlock(cacheExpression(ts.visitNode(node.expression, visitor, ts.isExpression)));
77088                 transformAndEmitEmbeddedStatement(node.statement);
77089                 endWithBlock();
77090             }
77091             else {
77092                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
77093             }
77094         }
77095         function transformAndEmitSwitchStatement(node) {
77096             if (containsYield(node.caseBlock)) {
77097                 var caseBlock = node.caseBlock;
77098                 var numClauses = caseBlock.clauses.length;
77099                 var endLabel = beginSwitchBlock();
77100                 var expression = cacheExpression(ts.visitNode(node.expression, visitor, ts.isExpression));
77101                 var clauseLabels = [];
77102                 var defaultClauseIndex = -1;
77103                 for (var i = 0; i < numClauses; i++) {
77104                     var clause = caseBlock.clauses[i];
77105                     clauseLabels.push(defineLabel());
77106                     if (clause.kind === 285 && defaultClauseIndex === -1) {
77107                         defaultClauseIndex = i;
77108                     }
77109                 }
77110                 var clausesWritten = 0;
77111                 var pendingClauses = [];
77112                 while (clausesWritten < numClauses) {
77113                     var defaultClausesSkipped = 0;
77114                     for (var i = clausesWritten; i < numClauses; i++) {
77115                         var clause = caseBlock.clauses[i];
77116                         if (clause.kind === 284) {
77117                             if (containsYield(clause.expression) && pendingClauses.length > 0) {
77118                                 break;
77119                             }
77120                             pendingClauses.push(factory.createCaseClause(ts.visitNode(clause.expression, visitor, ts.isExpression), [
77121                                 createInlineBreak(clauseLabels[i], clause.expression)
77122                             ]));
77123                         }
77124                         else {
77125                             defaultClausesSkipped++;
77126                         }
77127                     }
77128                     if (pendingClauses.length) {
77129                         emitStatement(factory.createSwitchStatement(expression, factory.createCaseBlock(pendingClauses)));
77130                         clausesWritten += pendingClauses.length;
77131                         pendingClauses = [];
77132                     }
77133                     if (defaultClausesSkipped > 0) {
77134                         clausesWritten += defaultClausesSkipped;
77135                         defaultClausesSkipped = 0;
77136                     }
77137                 }
77138                 if (defaultClauseIndex >= 0) {
77139                     emitBreak(clauseLabels[defaultClauseIndex]);
77140                 }
77141                 else {
77142                     emitBreak(endLabel);
77143                 }
77144                 for (var i = 0; i < numClauses; i++) {
77145                     markLabel(clauseLabels[i]);
77146                     transformAndEmitStatements(caseBlock.clauses[i].statements);
77147                 }
77148                 endSwitchBlock();
77149             }
77150             else {
77151                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
77152             }
77153         }
77154         function visitSwitchStatement(node) {
77155             if (inStatementContainingYield) {
77156                 beginScriptSwitchBlock();
77157             }
77158             node = ts.visitEachChild(node, visitor, context);
77159             if (inStatementContainingYield) {
77160                 endSwitchBlock();
77161             }
77162             return node;
77163         }
77164         function transformAndEmitLabeledStatement(node) {
77165             if (containsYield(node)) {
77166                 beginLabeledBlock(ts.idText(node.label));
77167                 transformAndEmitEmbeddedStatement(node.statement);
77168                 endLabeledBlock();
77169             }
77170             else {
77171                 emitStatement(ts.visitNode(node, visitor, ts.isStatement));
77172             }
77173         }
77174         function visitLabeledStatement(node) {
77175             if (inStatementContainingYield) {
77176                 beginScriptLabeledBlock(ts.idText(node.label));
77177             }
77178             node = ts.visitEachChild(node, visitor, context);
77179             if (inStatementContainingYield) {
77180                 endLabeledBlock();
77181             }
77182             return node;
77183         }
77184         function transformAndEmitThrowStatement(node) {
77185             var _a;
77186             emitThrow(ts.visitNode((_a = node.expression) !== null && _a !== void 0 ? _a : factory.createVoidZero(), visitor, ts.isExpression), node);
77187         }
77188         function transformAndEmitTryStatement(node) {
77189             if (containsYield(node)) {
77190                 beginExceptionBlock();
77191                 transformAndEmitEmbeddedStatement(node.tryBlock);
77192                 if (node.catchClause) {
77193                     beginCatchBlock(node.catchClause.variableDeclaration);
77194                     transformAndEmitEmbeddedStatement(node.catchClause.block);
77195                 }
77196                 if (node.finallyBlock) {
77197                     beginFinallyBlock();
77198                     transformAndEmitEmbeddedStatement(node.finallyBlock);
77199                 }
77200                 endExceptionBlock();
77201             }
77202             else {
77203                 emitStatement(ts.visitEachChild(node, visitor, context));
77204             }
77205         }
77206         function containsYield(node) {
77207             return !!node && (node.transformFlags & 262144) !== 0;
77208         }
77209         function countInitialNodesWithoutYield(nodes) {
77210             var numNodes = nodes.length;
77211             for (var i = 0; i < numNodes; i++) {
77212                 if (containsYield(nodes[i])) {
77213                     return i;
77214                 }
77215             }
77216             return -1;
77217         }
77218         function onSubstituteNode(hint, node) {
77219             node = previousOnSubstituteNode(hint, node);
77220             if (hint === 1) {
77221                 return substituteExpression(node);
77222             }
77223             return node;
77224         }
77225         function substituteExpression(node) {
77226             if (ts.isIdentifier(node)) {
77227                 return substituteExpressionIdentifier(node);
77228             }
77229             return node;
77230         }
77231         function substituteExpressionIdentifier(node) {
77232             if (!ts.isGeneratedIdentifier(node) && renamedCatchVariables && renamedCatchVariables.has(ts.idText(node))) {
77233                 var original = ts.getOriginalNode(node);
77234                 if (ts.isIdentifier(original) && original.parent) {
77235                     var declaration = resolver.getReferencedValueDeclaration(original);
77236                     if (declaration) {
77237                         var name = renamedCatchVariableDeclarations[ts.getOriginalNodeId(declaration)];
77238                         if (name) {
77239                             var clone_5 = ts.setParent(ts.setTextRange(factory.cloneNode(name), name), name.parent);
77240                             ts.setSourceMapRange(clone_5, node);
77241                             ts.setCommentRange(clone_5, node);
77242                             return clone_5;
77243                         }
77244                     }
77245                 }
77246             }
77247             return node;
77248         }
77249         function cacheExpression(node) {
77250             if (ts.isGeneratedIdentifier(node) || ts.getEmitFlags(node) & 4096) {
77251                 return node;
77252             }
77253             var temp = factory.createTempVariable(hoistVariableDeclaration);
77254             emitAssignment(temp, node, node);
77255             return temp;
77256         }
77257         function declareLocal(name) {
77258             var temp = name
77259                 ? factory.createUniqueName(name)
77260                 : factory.createTempVariable(undefined);
77261             hoistVariableDeclaration(temp);
77262             return temp;
77263         }
77264         function defineLabel() {
77265             if (!labelOffsets) {
77266                 labelOffsets = [];
77267             }
77268             var label = nextLabelId;
77269             nextLabelId++;
77270             labelOffsets[label] = -1;
77271             return label;
77272         }
77273         function markLabel(label) {
77274             ts.Debug.assert(labelOffsets !== undefined, "No labels were defined.");
77275             labelOffsets[label] = operations ? operations.length : 0;
77276         }
77277         function beginBlock(block) {
77278             if (!blocks) {
77279                 blocks = [];
77280                 blockActions = [];
77281                 blockOffsets = [];
77282                 blockStack = [];
77283             }
77284             var index = blockActions.length;
77285             blockActions[index] = 0;
77286             blockOffsets[index] = operations ? operations.length : 0;
77287             blocks[index] = block;
77288             blockStack.push(block);
77289             return index;
77290         }
77291         function endBlock() {
77292             var block = peekBlock();
77293             if (block === undefined)
77294                 return ts.Debug.fail("beginBlock was never called.");
77295             var index = blockActions.length;
77296             blockActions[index] = 1;
77297             blockOffsets[index] = operations ? operations.length : 0;
77298             blocks[index] = block;
77299             blockStack.pop();
77300             return block;
77301         }
77302         function peekBlock() {
77303             return ts.lastOrUndefined(blockStack);
77304         }
77305         function peekBlockKind() {
77306             var block = peekBlock();
77307             return block && block.kind;
77308         }
77309         function beginWithBlock(expression) {
77310             var startLabel = defineLabel();
77311             var endLabel = defineLabel();
77312             markLabel(startLabel);
77313             beginBlock({
77314                 kind: 1,
77315                 expression: expression,
77316                 startLabel: startLabel,
77317                 endLabel: endLabel
77318             });
77319         }
77320         function endWithBlock() {
77321             ts.Debug.assert(peekBlockKind() === 1);
77322             var block = endBlock();
77323             markLabel(block.endLabel);
77324         }
77325         function beginExceptionBlock() {
77326             var startLabel = defineLabel();
77327             var endLabel = defineLabel();
77328             markLabel(startLabel);
77329             beginBlock({
77330                 kind: 0,
77331                 state: 0,
77332                 startLabel: startLabel,
77333                 endLabel: endLabel
77334             });
77335             emitNop();
77336             return endLabel;
77337         }
77338         function beginCatchBlock(variable) {
77339             ts.Debug.assert(peekBlockKind() === 0);
77340             var name;
77341             if (ts.isGeneratedIdentifier(variable.name)) {
77342                 name = variable.name;
77343                 hoistVariableDeclaration(variable.name);
77344             }
77345             else {
77346                 var text = ts.idText(variable.name);
77347                 name = declareLocal(text);
77348                 if (!renamedCatchVariables) {
77349                     renamedCatchVariables = new ts.Map();
77350                     renamedCatchVariableDeclarations = [];
77351                     context.enableSubstitution(78);
77352                 }
77353                 renamedCatchVariables.set(text, true);
77354                 renamedCatchVariableDeclarations[ts.getOriginalNodeId(variable)] = name;
77355             }
77356             var exception = peekBlock();
77357             ts.Debug.assert(exception.state < 1);
77358             var endLabel = exception.endLabel;
77359             emitBreak(endLabel);
77360             var catchLabel = defineLabel();
77361             markLabel(catchLabel);
77362             exception.state = 1;
77363             exception.catchVariable = name;
77364             exception.catchLabel = catchLabel;
77365             emitAssignment(name, factory.createCallExpression(factory.createPropertyAccessExpression(state, "sent"), undefined, []));
77366             emitNop();
77367         }
77368         function beginFinallyBlock() {
77369             ts.Debug.assert(peekBlockKind() === 0);
77370             var exception = peekBlock();
77371             ts.Debug.assert(exception.state < 2);
77372             var endLabel = exception.endLabel;
77373             emitBreak(endLabel);
77374             var finallyLabel = defineLabel();
77375             markLabel(finallyLabel);
77376             exception.state = 2;
77377             exception.finallyLabel = finallyLabel;
77378         }
77379         function endExceptionBlock() {
77380             ts.Debug.assert(peekBlockKind() === 0);
77381             var exception = endBlock();
77382             var state = exception.state;
77383             if (state < 2) {
77384                 emitBreak(exception.endLabel);
77385             }
77386             else {
77387                 emitEndfinally();
77388             }
77389             markLabel(exception.endLabel);
77390             emitNop();
77391             exception.state = 3;
77392         }
77393         function beginScriptLoopBlock() {
77394             beginBlock({
77395                 kind: 3,
77396                 isScript: true,
77397                 breakLabel: -1,
77398                 continueLabel: -1
77399             });
77400         }
77401         function beginLoopBlock(continueLabel) {
77402             var breakLabel = defineLabel();
77403             beginBlock({
77404                 kind: 3,
77405                 isScript: false,
77406                 breakLabel: breakLabel,
77407                 continueLabel: continueLabel,
77408             });
77409             return breakLabel;
77410         }
77411         function endLoopBlock() {
77412             ts.Debug.assert(peekBlockKind() === 3);
77413             var block = endBlock();
77414             var breakLabel = block.breakLabel;
77415             if (!block.isScript) {
77416                 markLabel(breakLabel);
77417             }
77418         }
77419         function beginScriptSwitchBlock() {
77420             beginBlock({
77421                 kind: 2,
77422                 isScript: true,
77423                 breakLabel: -1
77424             });
77425         }
77426         function beginSwitchBlock() {
77427             var breakLabel = defineLabel();
77428             beginBlock({
77429                 kind: 2,
77430                 isScript: false,
77431                 breakLabel: breakLabel,
77432             });
77433             return breakLabel;
77434         }
77435         function endSwitchBlock() {
77436             ts.Debug.assert(peekBlockKind() === 2);
77437             var block = endBlock();
77438             var breakLabel = block.breakLabel;
77439             if (!block.isScript) {
77440                 markLabel(breakLabel);
77441             }
77442         }
77443         function beginScriptLabeledBlock(labelText) {
77444             beginBlock({
77445                 kind: 4,
77446                 isScript: true,
77447                 labelText: labelText,
77448                 breakLabel: -1
77449             });
77450         }
77451         function beginLabeledBlock(labelText) {
77452             var breakLabel = defineLabel();
77453             beginBlock({
77454                 kind: 4,
77455                 isScript: false,
77456                 labelText: labelText,
77457                 breakLabel: breakLabel
77458             });
77459         }
77460         function endLabeledBlock() {
77461             ts.Debug.assert(peekBlockKind() === 4);
77462             var block = endBlock();
77463             if (!block.isScript) {
77464                 markLabel(block.breakLabel);
77465             }
77466         }
77467         function supportsUnlabeledBreak(block) {
77468             return block.kind === 2
77469                 || block.kind === 3;
77470         }
77471         function supportsLabeledBreakOrContinue(block) {
77472             return block.kind === 4;
77473         }
77474         function supportsUnlabeledContinue(block) {
77475             return block.kind === 3;
77476         }
77477         function hasImmediateContainingLabeledBlock(labelText, start) {
77478             for (var j = start; j >= 0; j--) {
77479                 var containingBlock = blockStack[j];
77480                 if (supportsLabeledBreakOrContinue(containingBlock)) {
77481                     if (containingBlock.labelText === labelText) {
77482                         return true;
77483                     }
77484                 }
77485                 else {
77486                     break;
77487                 }
77488             }
77489             return false;
77490         }
77491         function findBreakTarget(labelText) {
77492             if (blockStack) {
77493                 if (labelText) {
77494                     for (var i = blockStack.length - 1; i >= 0; i--) {
77495                         var block = blockStack[i];
77496                         if (supportsLabeledBreakOrContinue(block) && block.labelText === labelText) {
77497                             return block.breakLabel;
77498                         }
77499                         else if (supportsUnlabeledBreak(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) {
77500                             return block.breakLabel;
77501                         }
77502                     }
77503                 }
77504                 else {
77505                     for (var i = blockStack.length - 1; i >= 0; i--) {
77506                         var block = blockStack[i];
77507                         if (supportsUnlabeledBreak(block)) {
77508                             return block.breakLabel;
77509                         }
77510                     }
77511                 }
77512             }
77513             return 0;
77514         }
77515         function findContinueTarget(labelText) {
77516             if (blockStack) {
77517                 if (labelText) {
77518                     for (var i = blockStack.length - 1; i >= 0; i--) {
77519                         var block = blockStack[i];
77520                         if (supportsUnlabeledContinue(block) && hasImmediateContainingLabeledBlock(labelText, i - 1)) {
77521                             return block.continueLabel;
77522                         }
77523                     }
77524                 }
77525                 else {
77526                     for (var i = blockStack.length - 1; i >= 0; i--) {
77527                         var block = blockStack[i];
77528                         if (supportsUnlabeledContinue(block)) {
77529                             return block.continueLabel;
77530                         }
77531                     }
77532                 }
77533             }
77534             return 0;
77535         }
77536         function createLabel(label) {
77537             if (label !== undefined && label > 0) {
77538                 if (labelExpressions === undefined) {
77539                     labelExpressions = [];
77540                 }
77541                 var expression = factory.createNumericLiteral(-1);
77542                 if (labelExpressions[label] === undefined) {
77543                     labelExpressions[label] = [expression];
77544                 }
77545                 else {
77546                     labelExpressions[label].push(expression);
77547                 }
77548                 return expression;
77549             }
77550             return factory.createOmittedExpression();
77551         }
77552         function createInstruction(instruction) {
77553             var literal = factory.createNumericLiteral(instruction);
77554             ts.addSyntheticTrailingComment(literal, 3, getInstructionName(instruction));
77555             return literal;
77556         }
77557         function createInlineBreak(label, location) {
77558             ts.Debug.assertLessThan(0, label, "Invalid label");
77559             return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([
77560                 createInstruction(3),
77561                 createLabel(label)
77562             ])), location);
77563         }
77564         function createInlineReturn(expression, location) {
77565             return ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression
77566                 ? [createInstruction(2), expression]
77567                 : [createInstruction(2)])), location);
77568         }
77569         function createGeneratorResume(location) {
77570             return ts.setTextRange(factory.createCallExpression(factory.createPropertyAccessExpression(state, "sent"), undefined, []), location);
77571         }
77572         function emitNop() {
77573             emitWorker(0);
77574         }
77575         function emitStatement(node) {
77576             if (node) {
77577                 emitWorker(1, [node]);
77578             }
77579             else {
77580                 emitNop();
77581             }
77582         }
77583         function emitAssignment(left, right, location) {
77584             emitWorker(2, [left, right], location);
77585         }
77586         function emitBreak(label, location) {
77587             emitWorker(3, [label], location);
77588         }
77589         function emitBreakWhenTrue(label, condition, location) {
77590             emitWorker(4, [label, condition], location);
77591         }
77592         function emitBreakWhenFalse(label, condition, location) {
77593             emitWorker(5, [label, condition], location);
77594         }
77595         function emitYieldStar(expression, location) {
77596             emitWorker(7, [expression], location);
77597         }
77598         function emitYield(expression, location) {
77599             emitWorker(6, [expression], location);
77600         }
77601         function emitReturn(expression, location) {
77602             emitWorker(8, [expression], location);
77603         }
77604         function emitThrow(expression, location) {
77605             emitWorker(9, [expression], location);
77606         }
77607         function emitEndfinally() {
77608             emitWorker(10);
77609         }
77610         function emitWorker(code, args, location) {
77611             if (operations === undefined) {
77612                 operations = [];
77613                 operationArguments = [];
77614                 operationLocations = [];
77615             }
77616             if (labelOffsets === undefined) {
77617                 markLabel(defineLabel());
77618             }
77619             var operationIndex = operations.length;
77620             operations[operationIndex] = code;
77621             operationArguments[operationIndex] = args;
77622             operationLocations[operationIndex] = location;
77623         }
77624         function build() {
77625             blockIndex = 0;
77626             labelNumber = 0;
77627             labelNumbers = undefined;
77628             lastOperationWasAbrupt = false;
77629             lastOperationWasCompletion = false;
77630             clauses = undefined;
77631             statements = undefined;
77632             exceptionBlockStack = undefined;
77633             currentExceptionBlock = undefined;
77634             withBlockStack = undefined;
77635             var buildResult = buildStatements();
77636             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));
77637         }
77638         function buildStatements() {
77639             if (operations) {
77640                 for (var operationIndex = 0; operationIndex < operations.length; operationIndex++) {
77641                     writeOperation(operationIndex);
77642                 }
77643                 flushFinalLabel(operations.length);
77644             }
77645             else {
77646                 flushFinalLabel(0);
77647             }
77648             if (clauses) {
77649                 var labelExpression = factory.createPropertyAccessExpression(state, "label");
77650                 var switchStatement = factory.createSwitchStatement(labelExpression, factory.createCaseBlock(clauses));
77651                 return [ts.startOnNewLine(switchStatement)];
77652             }
77653             if (statements) {
77654                 return statements;
77655             }
77656             return [];
77657         }
77658         function flushLabel() {
77659             if (!statements) {
77660                 return;
77661             }
77662             appendLabel(!lastOperationWasAbrupt);
77663             lastOperationWasAbrupt = false;
77664             lastOperationWasCompletion = false;
77665             labelNumber++;
77666         }
77667         function flushFinalLabel(operationIndex) {
77668             if (isFinalLabelReachable(operationIndex)) {
77669                 tryEnterLabel(operationIndex);
77670                 withBlockStack = undefined;
77671                 writeReturn(undefined, undefined);
77672             }
77673             if (statements && clauses) {
77674                 appendLabel(false);
77675             }
77676             updateLabelExpressions();
77677         }
77678         function isFinalLabelReachable(operationIndex) {
77679             if (!lastOperationWasCompletion) {
77680                 return true;
77681             }
77682             if (!labelOffsets || !labelExpressions) {
77683                 return false;
77684             }
77685             for (var label = 0; label < labelOffsets.length; label++) {
77686                 if (labelOffsets[label] === operationIndex && labelExpressions[label]) {
77687                     return true;
77688                 }
77689             }
77690             return false;
77691         }
77692         function appendLabel(markLabelEnd) {
77693             if (!clauses) {
77694                 clauses = [];
77695             }
77696             if (statements) {
77697                 if (withBlockStack) {
77698                     for (var i = withBlockStack.length - 1; i >= 0; i--) {
77699                         var withBlock = withBlockStack[i];
77700                         statements = [factory.createWithStatement(withBlock.expression, factory.createBlock(statements))];
77701                     }
77702                 }
77703                 if (currentExceptionBlock) {
77704                     var startLabel = currentExceptionBlock.startLabel, catchLabel = currentExceptionBlock.catchLabel, finallyLabel = currentExceptionBlock.finallyLabel, endLabel = currentExceptionBlock.endLabel;
77705                     statements.unshift(factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createPropertyAccessExpression(state, "trys"), "push"), undefined, [
77706                         factory.createArrayLiteralExpression([
77707                             createLabel(startLabel),
77708                             createLabel(catchLabel),
77709                             createLabel(finallyLabel),
77710                             createLabel(endLabel)
77711                         ])
77712                     ])));
77713                     currentExceptionBlock = undefined;
77714                 }
77715                 if (markLabelEnd) {
77716                     statements.push(factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(state, "label"), factory.createNumericLiteral(labelNumber + 1))));
77717                 }
77718             }
77719             clauses.push(factory.createCaseClause(factory.createNumericLiteral(labelNumber), statements || []));
77720             statements = undefined;
77721         }
77722         function tryEnterLabel(operationIndex) {
77723             if (!labelOffsets) {
77724                 return;
77725             }
77726             for (var label = 0; label < labelOffsets.length; label++) {
77727                 if (labelOffsets[label] === operationIndex) {
77728                     flushLabel();
77729                     if (labelNumbers === undefined) {
77730                         labelNumbers = [];
77731                     }
77732                     if (labelNumbers[labelNumber] === undefined) {
77733                         labelNumbers[labelNumber] = [label];
77734                     }
77735                     else {
77736                         labelNumbers[labelNumber].push(label);
77737                     }
77738                 }
77739             }
77740         }
77741         function updateLabelExpressions() {
77742             if (labelExpressions !== undefined && labelNumbers !== undefined) {
77743                 for (var labelNumber_1 = 0; labelNumber_1 < labelNumbers.length; labelNumber_1++) {
77744                     var labels = labelNumbers[labelNumber_1];
77745                     if (labels !== undefined) {
77746                         for (var _i = 0, labels_1 = labels; _i < labels_1.length; _i++) {
77747                             var label = labels_1[_i];
77748                             var expressions = labelExpressions[label];
77749                             if (expressions !== undefined) {
77750                                 for (var _a = 0, expressions_1 = expressions; _a < expressions_1.length; _a++) {
77751                                     var expression = expressions_1[_a];
77752                                     expression.text = String(labelNumber_1);
77753                                 }
77754                             }
77755                         }
77756                     }
77757                 }
77758             }
77759         }
77760         function tryEnterOrLeaveBlock(operationIndex) {
77761             if (blocks) {
77762                 for (; blockIndex < blockActions.length && blockOffsets[blockIndex] <= operationIndex; blockIndex++) {
77763                     var block = blocks[blockIndex];
77764                     var blockAction = blockActions[blockIndex];
77765                     switch (block.kind) {
77766                         case 0:
77767                             if (blockAction === 0) {
77768                                 if (!exceptionBlockStack) {
77769                                     exceptionBlockStack = [];
77770                                 }
77771                                 if (!statements) {
77772                                     statements = [];
77773                                 }
77774                                 exceptionBlockStack.push(currentExceptionBlock);
77775                                 currentExceptionBlock = block;
77776                             }
77777                             else if (blockAction === 1) {
77778                                 currentExceptionBlock = exceptionBlockStack.pop();
77779                             }
77780                             break;
77781                         case 1:
77782                             if (blockAction === 0) {
77783                                 if (!withBlockStack) {
77784                                     withBlockStack = [];
77785                                 }
77786                                 withBlockStack.push(block);
77787                             }
77788                             else if (blockAction === 1) {
77789                                 withBlockStack.pop();
77790                             }
77791                             break;
77792                     }
77793                 }
77794             }
77795         }
77796         function writeOperation(operationIndex) {
77797             tryEnterLabel(operationIndex);
77798             tryEnterOrLeaveBlock(operationIndex);
77799             if (lastOperationWasAbrupt) {
77800                 return;
77801             }
77802             lastOperationWasAbrupt = false;
77803             lastOperationWasCompletion = false;
77804             var opcode = operations[operationIndex];
77805             if (opcode === 0) {
77806                 return;
77807             }
77808             else if (opcode === 10) {
77809                 return writeEndfinally();
77810             }
77811             var args = operationArguments[operationIndex];
77812             if (opcode === 1) {
77813                 return writeStatement(args[0]);
77814             }
77815             var location = operationLocations[operationIndex];
77816             switch (opcode) {
77817                 case 2:
77818                     return writeAssign(args[0], args[1], location);
77819                 case 3:
77820                     return writeBreak(args[0], location);
77821                 case 4:
77822                     return writeBreakWhenTrue(args[0], args[1], location);
77823                 case 5:
77824                     return writeBreakWhenFalse(args[0], args[1], location);
77825                 case 6:
77826                     return writeYield(args[0], location);
77827                 case 7:
77828                     return writeYieldStar(args[0], location);
77829                 case 8:
77830                     return writeReturn(args[0], location);
77831                 case 9:
77832                     return writeThrow(args[0], location);
77833             }
77834         }
77835         function writeStatement(statement) {
77836             if (statement) {
77837                 if (!statements) {
77838                     statements = [statement];
77839                 }
77840                 else {
77841                     statements.push(statement);
77842                 }
77843             }
77844         }
77845         function writeAssign(left, right, operationLocation) {
77846             writeStatement(ts.setTextRange(factory.createExpressionStatement(factory.createAssignment(left, right)), operationLocation));
77847         }
77848         function writeThrow(expression, operationLocation) {
77849             lastOperationWasAbrupt = true;
77850             lastOperationWasCompletion = true;
77851             writeStatement(ts.setTextRange(factory.createThrowStatement(expression), operationLocation));
77852         }
77853         function writeReturn(expression, operationLocation) {
77854             lastOperationWasAbrupt = true;
77855             lastOperationWasCompletion = true;
77856             writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression
77857                 ? [createInstruction(2), expression]
77858                 : [createInstruction(2)])), operationLocation), 384));
77859         }
77860         function writeBreak(label, operationLocation) {
77861             lastOperationWasAbrupt = true;
77862             writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([
77863                 createInstruction(3),
77864                 createLabel(label)
77865             ])), operationLocation), 384));
77866         }
77867         function writeBreakWhenTrue(label, condition, operationLocation) {
77868             writeStatement(ts.setEmitFlags(factory.createIfStatement(condition, ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([
77869                 createInstruction(3),
77870                 createLabel(label)
77871             ])), operationLocation), 384)), 1));
77872         }
77873         function writeBreakWhenFalse(label, condition, operationLocation) {
77874             writeStatement(ts.setEmitFlags(factory.createIfStatement(factory.createLogicalNot(condition), ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([
77875                 createInstruction(3),
77876                 createLabel(label)
77877             ])), operationLocation), 384)), 1));
77878         }
77879         function writeYield(expression, operationLocation) {
77880             lastOperationWasAbrupt = true;
77881             writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression(expression
77882                 ? [createInstruction(4), expression]
77883                 : [createInstruction(4)])), operationLocation), 384));
77884         }
77885         function writeYieldStar(expression, operationLocation) {
77886             lastOperationWasAbrupt = true;
77887             writeStatement(ts.setEmitFlags(ts.setTextRange(factory.createReturnStatement(factory.createArrayLiteralExpression([
77888                 createInstruction(5),
77889                 expression
77890             ])), operationLocation), 384));
77891         }
77892         function writeEndfinally() {
77893             lastOperationWasAbrupt = true;
77894             writeStatement(factory.createReturnStatement(factory.createArrayLiteralExpression([
77895                 createInstruction(7)
77896             ])));
77897         }
77898     }
77899     ts.transformGenerators = transformGenerators;
77900 })(ts || (ts = {}));
77901 var ts;
77902 (function (ts) {
77903     function transformModule(context) {
77904         function getTransformModuleDelegate(moduleKind) {
77905             switch (moduleKind) {
77906                 case ts.ModuleKind.AMD: return transformAMDModule;
77907                 case ts.ModuleKind.UMD: return transformUMDModule;
77908                 default: return transformCommonJSModule;
77909             }
77910         }
77911         var factory = context.factory, emitHelpers = context.getEmitHelperFactory, startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
77912         var compilerOptions = context.getCompilerOptions();
77913         var resolver = context.getEmitResolver();
77914         var host = context.getEmitHost();
77915         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
77916         var moduleKind = ts.getEmitModuleKind(compilerOptions);
77917         var previousOnSubstituteNode = context.onSubstituteNode;
77918         var previousOnEmitNode = context.onEmitNode;
77919         context.onSubstituteNode = onSubstituteNode;
77920         context.onEmitNode = onEmitNode;
77921         context.enableSubstitution(78);
77922         context.enableSubstitution(216);
77923         context.enableSubstitution(214);
77924         context.enableSubstitution(215);
77925         context.enableSubstitution(289);
77926         context.enableEmitNotification(297);
77927         var moduleInfoMap = [];
77928         var deferredExports = [];
77929         var currentSourceFile;
77930         var currentModuleInfo;
77931         var noSubstitution;
77932         var needUMDDynamicImportHelper;
77933         return ts.chainBundle(context, transformSourceFile);
77934         function transformSourceFile(node) {
77935             if (node.isDeclarationFile ||
77936                 !(ts.isEffectiveExternalModule(node, compilerOptions) ||
77937                     node.transformFlags & 2097152 ||
77938                     (ts.isJsonSourceFile(node) && ts.hasJsonModuleEmitEnabled(compilerOptions) && ts.outFile(compilerOptions)))) {
77939                 return node;
77940             }
77941             currentSourceFile = node;
77942             currentModuleInfo = ts.collectExternalModuleInfo(context, node, resolver, compilerOptions);
77943             moduleInfoMap[ts.getOriginalNodeId(node)] = currentModuleInfo;
77944             var transformModule = getTransformModuleDelegate(moduleKind);
77945             var updated = transformModule(node);
77946             currentSourceFile = undefined;
77947             currentModuleInfo = undefined;
77948             needUMDDynamicImportHelper = false;
77949             return updated;
77950         }
77951         function shouldEmitUnderscoreUnderscoreESModule() {
77952             if (!currentModuleInfo.exportEquals && ts.isExternalModule(currentSourceFile)) {
77953                 return true;
77954             }
77955             return false;
77956         }
77957         function transformCommonJSModule(node) {
77958             startLexicalEnvironment();
77959             var statements = [];
77960             var ensureUseStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile));
77961             var statementOffset = factory.copyPrologue(node.statements, statements, ensureUseStrict && !ts.isJsonSourceFile(node), sourceElementVisitor);
77962             if (shouldEmitUnderscoreUnderscoreESModule()) {
77963                 ts.append(statements, createUnderscoreUnderscoreESModule());
77964             }
77965             if (ts.length(currentModuleInfo.exportedNames)) {
77966                 var chunkSize = 50;
77967                 for (var i = 0; i < currentModuleInfo.exportedNames.length; i += chunkSize) {
77968                     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())));
77969                 }
77970             }
77971             ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement));
77972             ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset));
77973             addExportEqualsIfNeeded(statements, false);
77974             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
77975             var updated = factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(statements), node.statements));
77976             ts.addEmitHelpers(updated, context.readEmitHelpers());
77977             return updated;
77978         }
77979         function transformAMDModule(node) {
77980             var define = factory.createIdentifier("define");
77981             var moduleName = ts.tryGetModuleNameFromFile(factory, node, host, compilerOptions);
77982             var jsonSourceFile = ts.isJsonSourceFile(node) && node;
77983             var _a = collectAsynchronousDependencies(node, true), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames;
77984             var updated = factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray([
77985                 factory.createExpressionStatement(factory.createCallExpression(define, undefined, __spreadArray(__spreadArray([], (moduleName ? [moduleName] : [])), [
77986                     factory.createArrayLiteralExpression(jsonSourceFile ? ts.emptyArray : __spreadArray(__spreadArray([
77987                         factory.createStringLiteral("require"),
77988                         factory.createStringLiteral("exports")
77989                     ], aliasedModuleNames), unaliasedModuleNames)),
77990                     jsonSourceFile ?
77991                         jsonSourceFile.statements.length ? jsonSourceFile.statements[0].expression : factory.createObjectLiteralExpression() :
77992                         factory.createFunctionExpression(undefined, undefined, undefined, undefined, __spreadArray([
77993                             factory.createParameterDeclaration(undefined, undefined, undefined, "require"),
77994                             factory.createParameterDeclaration(undefined, undefined, undefined, "exports")
77995                         ], importAliasNames), undefined, transformAsynchronousModuleBody(node))
77996                 ])))
77997             ]), node.statements));
77998             ts.addEmitHelpers(updated, context.readEmitHelpers());
77999             return updated;
78000         }
78001         function transformUMDModule(node) {
78002             var _a = collectAsynchronousDependencies(node, false), aliasedModuleNames = _a.aliasedModuleNames, unaliasedModuleNames = _a.unaliasedModuleNames, importAliasNames = _a.importAliasNames;
78003             var moduleName = ts.tryGetModuleNameFromFile(factory, node, host, compilerOptions);
78004             var umdHeader = factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, "factory")], undefined, ts.setTextRange(factory.createBlock([
78005                 factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("module"), "object"), factory.createTypeCheck(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), "object")), factory.createBlock([
78006                     factory.createVariableStatement(undefined, [
78007                         factory.createVariableDeclaration("v", undefined, undefined, factory.createCallExpression(factory.createIdentifier("factory"), undefined, [
78008                             factory.createIdentifier("require"),
78009                             factory.createIdentifier("exports")
78010                         ]))
78011                     ]),
78012                     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)
78013                 ]), factory.createIfStatement(factory.createLogicalAnd(factory.createTypeCheck(factory.createIdentifier("define"), "function"), factory.createPropertyAccessExpression(factory.createIdentifier("define"), "amd")), factory.createBlock([
78014                     factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("define"), undefined, __spreadArray(__spreadArray([], (moduleName ? [moduleName] : [])), [
78015                         factory.createArrayLiteralExpression(__spreadArray(__spreadArray([
78016                             factory.createStringLiteral("require"),
78017                             factory.createStringLiteral("exports")
78018                         ], aliasedModuleNames), unaliasedModuleNames)),
78019                         factory.createIdentifier("factory")
78020                     ])))
78021                 ])))
78022             ], true), undefined));
78023             var updated = factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray([
78024                 factory.createExpressionStatement(factory.createCallExpression(umdHeader, undefined, [
78025                     factory.createFunctionExpression(undefined, undefined, undefined, undefined, __spreadArray([
78026                         factory.createParameterDeclaration(undefined, undefined, undefined, "require"),
78027                         factory.createParameterDeclaration(undefined, undefined, undefined, "exports")
78028                     ], importAliasNames), undefined, transformAsynchronousModuleBody(node))
78029                 ]))
78030             ]), node.statements));
78031             ts.addEmitHelpers(updated, context.readEmitHelpers());
78032             return updated;
78033         }
78034         function collectAsynchronousDependencies(node, includeNonAmdDependencies) {
78035             var aliasedModuleNames = [];
78036             var unaliasedModuleNames = [];
78037             var importAliasNames = [];
78038             for (var _i = 0, _a = node.amdDependencies; _i < _a.length; _i++) {
78039                 var amdDependency = _a[_i];
78040                 if (amdDependency.name) {
78041                     aliasedModuleNames.push(factory.createStringLiteral(amdDependency.path));
78042                     importAliasNames.push(factory.createParameterDeclaration(undefined, undefined, undefined, amdDependency.name));
78043                 }
78044                 else {
78045                     unaliasedModuleNames.push(factory.createStringLiteral(amdDependency.path));
78046                 }
78047             }
78048             for (var _b = 0, _c = currentModuleInfo.externalImports; _b < _c.length; _b++) {
78049                 var importNode = _c[_b];
78050                 var externalModuleName = ts.getExternalModuleNameLiteral(factory, importNode, currentSourceFile, host, resolver, compilerOptions);
78051                 var importAliasName = ts.getLocalNameForExternalImport(factory, importNode, currentSourceFile);
78052                 if (externalModuleName) {
78053                     if (includeNonAmdDependencies && importAliasName) {
78054                         ts.setEmitFlags(importAliasName, 4);
78055                         aliasedModuleNames.push(externalModuleName);
78056                         importAliasNames.push(factory.createParameterDeclaration(undefined, undefined, undefined, importAliasName));
78057                     }
78058                     else {
78059                         unaliasedModuleNames.push(externalModuleName);
78060                     }
78061                 }
78062             }
78063             return { aliasedModuleNames: aliasedModuleNames, unaliasedModuleNames: unaliasedModuleNames, importAliasNames: importAliasNames };
78064         }
78065         function getAMDImportExpressionForImport(node) {
78066             if (ts.isImportEqualsDeclaration(node) || ts.isExportDeclaration(node) || !ts.getExternalModuleNameLiteral(factory, node, currentSourceFile, host, resolver, compilerOptions)) {
78067                 return undefined;
78068             }
78069             var name = ts.getLocalNameForExternalImport(factory, node, currentSourceFile);
78070             var expr = getHelperExpressionForImport(node, name);
78071             if (expr === name) {
78072                 return undefined;
78073             }
78074             return factory.createExpressionStatement(factory.createAssignment(name, expr));
78075         }
78076         function transformAsynchronousModuleBody(node) {
78077             startLexicalEnvironment();
78078             var statements = [];
78079             var statementOffset = factory.copyPrologue(node.statements, statements, !compilerOptions.noImplicitUseStrict, sourceElementVisitor);
78080             if (shouldEmitUnderscoreUnderscoreESModule()) {
78081                 ts.append(statements, createUnderscoreUnderscoreESModule());
78082             }
78083             if (ts.length(currentModuleInfo.exportedNames)) {
78084                 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())));
78085             }
78086             ts.append(statements, ts.visitNode(currentModuleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement));
78087             if (moduleKind === ts.ModuleKind.AMD) {
78088                 ts.addRange(statements, ts.mapDefined(currentModuleInfo.externalImports, getAMDImportExpressionForImport));
78089             }
78090             ts.addRange(statements, ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset));
78091             addExportEqualsIfNeeded(statements, true);
78092             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
78093             var body = factory.createBlock(statements, true);
78094             if (needUMDDynamicImportHelper) {
78095                 ts.addEmitHelper(body, dynamicImportUMDHelper);
78096             }
78097             return body;
78098         }
78099         function addExportEqualsIfNeeded(statements, emitAsReturn) {
78100             if (currentModuleInfo.exportEquals) {
78101                 var expressionResult = ts.visitNode(currentModuleInfo.exportEquals.expression, moduleExpressionElementVisitor);
78102                 if (expressionResult) {
78103                     if (emitAsReturn) {
78104                         var statement = factory.createReturnStatement(expressionResult);
78105                         ts.setTextRange(statement, currentModuleInfo.exportEquals);
78106                         ts.setEmitFlags(statement, 384 | 1536);
78107                         statements.push(statement);
78108                     }
78109                     else {
78110                         var statement = factory.createExpressionStatement(factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("module"), "exports"), expressionResult));
78111                         ts.setTextRange(statement, currentModuleInfo.exportEquals);
78112                         ts.setEmitFlags(statement, 1536);
78113                         statements.push(statement);
78114                     }
78115                 }
78116             }
78117         }
78118         function sourceElementVisitor(node) {
78119             switch (node.kind) {
78120                 case 261:
78121                     return visitImportDeclaration(node);
78122                 case 260:
78123                     return visitImportEqualsDeclaration(node);
78124                 case 267:
78125                     return visitExportDeclaration(node);
78126                 case 266:
78127                     return visitExportAssignment(node);
78128                 case 232:
78129                     return visitVariableStatement(node);
78130                 case 251:
78131                     return visitFunctionDeclaration(node);
78132                 case 252:
78133                     return visitClassDeclaration(node);
78134                 case 338:
78135                     return visitMergeDeclarationMarker(node);
78136                 case 339:
78137                     return visitEndOfDeclarationMarker(node);
78138                 default:
78139                     return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
78140             }
78141         }
78142         function moduleExpressionElementVisitor(node) {
78143             if (!(node.transformFlags & 2097152) && !(node.transformFlags & 1024)) {
78144                 return node;
78145             }
78146             if (ts.isImportCall(node)) {
78147                 return visitImportCallExpression(node);
78148             }
78149             else if (ts.isDestructuringAssignment(node)) {
78150                 return visitDestructuringAssignment(node);
78151             }
78152             else {
78153                 return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
78154             }
78155         }
78156         function destructuringNeedsFlattening(node) {
78157             if (ts.isObjectLiteralExpression(node)) {
78158                 for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
78159                     var elem = _a[_i];
78160                     switch (elem.kind) {
78161                         case 288:
78162                             if (destructuringNeedsFlattening(elem.initializer)) {
78163                                 return true;
78164                             }
78165                             break;
78166                         case 289:
78167                             if (destructuringNeedsFlattening(elem.name)) {
78168                                 return true;
78169                             }
78170                             break;
78171                         case 290:
78172                             if (destructuringNeedsFlattening(elem.expression)) {
78173                                 return true;
78174                             }
78175                             break;
78176                         case 165:
78177                         case 167:
78178                         case 168:
78179                             return false;
78180                         default: ts.Debug.assertNever(elem, "Unhandled object member kind");
78181                     }
78182                 }
78183             }
78184             else if (ts.isArrayLiteralExpression(node)) {
78185                 for (var _b = 0, _c = node.elements; _b < _c.length; _b++) {
78186                     var elem = _c[_b];
78187                     if (ts.isSpreadElement(elem)) {
78188                         if (destructuringNeedsFlattening(elem.expression)) {
78189                             return true;
78190                         }
78191                     }
78192                     else if (destructuringNeedsFlattening(elem)) {
78193                         return true;
78194                     }
78195                 }
78196             }
78197             else if (ts.isIdentifier(node)) {
78198                 return ts.length(getExports(node)) > (ts.isExportName(node) ? 1 : 0);
78199             }
78200             return false;
78201         }
78202         function visitDestructuringAssignment(node) {
78203             if (destructuringNeedsFlattening(node.left)) {
78204                 return ts.flattenDestructuringAssignment(node, moduleExpressionElementVisitor, context, 0, false, createAllExportExpressions);
78205             }
78206             return ts.visitEachChild(node, moduleExpressionElementVisitor, context);
78207         }
78208         function visitImportCallExpression(node) {
78209             var externalModuleName = ts.getExternalModuleNameLiteral(factory, node, currentSourceFile, host, resolver, compilerOptions);
78210             var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), moduleExpressionElementVisitor);
78211             var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument;
78212             var containsLexicalThis = !!(node.transformFlags & 4096);
78213             switch (compilerOptions.module) {
78214                 case ts.ModuleKind.AMD:
78215                     return createImportCallExpressionAMD(argument, containsLexicalThis);
78216                 case ts.ModuleKind.UMD:
78217                     return createImportCallExpressionUMD(argument !== null && argument !== void 0 ? argument : factory.createVoidZero(), containsLexicalThis);
78218                 case ts.ModuleKind.CommonJS:
78219                 default:
78220                     return createImportCallExpressionCommonJS(argument, containsLexicalThis);
78221             }
78222         }
78223         function createImportCallExpressionUMD(arg, containsLexicalThis) {
78224             needUMDDynamicImportHelper = true;
78225             if (ts.isSimpleCopiableExpression(arg)) {
78226                 var argClone = ts.isGeneratedIdentifier(arg) ? arg : ts.isStringLiteral(arg) ? factory.createStringLiteralFromNode(arg) : ts.setEmitFlags(ts.setTextRange(factory.cloneNode(arg), arg), 1536);
78227                 return factory.createConditionalExpression(factory.createIdentifier("__syncRequire"), undefined, createImportCallExpressionCommonJS(arg, containsLexicalThis), undefined, createImportCallExpressionAMD(argClone, containsLexicalThis));
78228             }
78229             else {
78230                 var temp = factory.createTempVariable(hoistVariableDeclaration);
78231                 return factory.createComma(factory.createAssignment(temp, arg), factory.createConditionalExpression(factory.createIdentifier("__syncRequire"), undefined, createImportCallExpressionCommonJS(temp, containsLexicalThis), undefined, createImportCallExpressionAMD(temp, containsLexicalThis)));
78232             }
78233         }
78234         function createImportCallExpressionAMD(arg, containsLexicalThis) {
78235             var resolve = factory.createUniqueName("resolve");
78236             var reject = factory.createUniqueName("reject");
78237             var parameters = [
78238                 factory.createParameterDeclaration(undefined, undefined, undefined, resolve),
78239                 factory.createParameterDeclaration(undefined, undefined, undefined, reject)
78240             ];
78241             var body = factory.createBlock([
78242                 factory.createExpressionStatement(factory.createCallExpression(factory.createIdentifier("require"), undefined, [factory.createArrayLiteralExpression([arg || factory.createOmittedExpression()]), resolve, reject]))
78243             ]);
78244             var func;
78245             if (languageVersion >= 2) {
78246                 func = factory.createArrowFunction(undefined, undefined, parameters, undefined, undefined, body);
78247             }
78248             else {
78249                 func = factory.createFunctionExpression(undefined, undefined, undefined, undefined, parameters, undefined, body);
78250                 if (containsLexicalThis) {
78251                     ts.setEmitFlags(func, 8);
78252                 }
78253             }
78254             var promise = factory.createNewExpression(factory.createIdentifier("Promise"), undefined, [func]);
78255             if (compilerOptions.esModuleInterop) {
78256                 return factory.createCallExpression(factory.createPropertyAccessExpression(promise, factory.createIdentifier("then")), undefined, [emitHelpers().createImportStarCallbackHelper()]);
78257             }
78258             return promise;
78259         }
78260         function createImportCallExpressionCommonJS(arg, containsLexicalThis) {
78261             var promiseResolveCall = factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Promise"), "resolve"), undefined, []);
78262             var requireCall = factory.createCallExpression(factory.createIdentifier("require"), undefined, arg ? [arg] : []);
78263             if (compilerOptions.esModuleInterop) {
78264                 requireCall = emitHelpers().createImportStarHelper(requireCall);
78265             }
78266             var func;
78267             if (languageVersion >= 2) {
78268                 func = factory.createArrowFunction(undefined, undefined, [], undefined, undefined, requireCall);
78269             }
78270             else {
78271                 func = factory.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, factory.createBlock([factory.createReturnStatement(requireCall)]));
78272                 if (containsLexicalThis) {
78273                     ts.setEmitFlags(func, 8);
78274                 }
78275             }
78276             return factory.createCallExpression(factory.createPropertyAccessExpression(promiseResolveCall, "then"), undefined, [func]);
78277         }
78278         function getHelperExpressionForExport(node, innerExpr) {
78279             if (!compilerOptions.esModuleInterop || ts.getEmitFlags(node) & 67108864) {
78280                 return innerExpr;
78281             }
78282             if (ts.getExportNeedsImportStarHelper(node)) {
78283                 return emitHelpers().createImportStarHelper(innerExpr);
78284             }
78285             return innerExpr;
78286         }
78287         function getHelperExpressionForImport(node, innerExpr) {
78288             if (!compilerOptions.esModuleInterop || ts.getEmitFlags(node) & 67108864) {
78289                 return innerExpr;
78290             }
78291             if (ts.getImportNeedsImportStarHelper(node)) {
78292                 return emitHelpers().createImportStarHelper(innerExpr);
78293             }
78294             if (ts.getImportNeedsImportDefaultHelper(node)) {
78295                 return emitHelpers().createImportDefaultHelper(innerExpr);
78296             }
78297             return innerExpr;
78298         }
78299         function visitImportDeclaration(node) {
78300             var statements;
78301             var namespaceDeclaration = ts.getNamespaceDeclarationNode(node);
78302             if (moduleKind !== ts.ModuleKind.AMD) {
78303                 if (!node.importClause) {
78304                     return ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createRequireCall(node)), node), node);
78305                 }
78306                 else {
78307                     var variables = [];
78308                     if (namespaceDeclaration && !ts.isDefaultImport(node)) {
78309                         variables.push(factory.createVariableDeclaration(factory.cloneNode(namespaceDeclaration.name), undefined, undefined, getHelperExpressionForImport(node, createRequireCall(node))));
78310                     }
78311                     else {
78312                         variables.push(factory.createVariableDeclaration(factory.getGeneratedNameForNode(node), undefined, undefined, getHelperExpressionForImport(node, createRequireCall(node))));
78313                         if (namespaceDeclaration && ts.isDefaultImport(node)) {
78314                             variables.push(factory.createVariableDeclaration(factory.cloneNode(namespaceDeclaration.name), undefined, undefined, factory.getGeneratedNameForNode(node)));
78315                         }
78316                     }
78317                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement(undefined, factory.createVariableDeclarationList(variables, languageVersion >= 2 ? 2 : 0)), node), node));
78318                 }
78319             }
78320             else if (namespaceDeclaration && ts.isDefaultImport(node)) {
78321                 statements = ts.append(statements, factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
78322                     ts.setOriginalNode(ts.setTextRange(factory.createVariableDeclaration(factory.cloneNode(namespaceDeclaration.name), undefined, undefined, factory.getGeneratedNameForNode(node)), node), node)
78323                 ], languageVersion >= 2 ? 2 : 0)));
78324             }
78325             if (hasAssociatedEndOfDeclarationMarker(node)) {
78326                 var id = ts.getOriginalNodeId(node);
78327                 deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node);
78328             }
78329             else {
78330                 statements = appendExportsOfImportDeclaration(statements, node);
78331             }
78332             return ts.singleOrMany(statements);
78333         }
78334         function createRequireCall(importNode) {
78335             var moduleName = ts.getExternalModuleNameLiteral(factory, importNode, currentSourceFile, host, resolver, compilerOptions);
78336             var args = [];
78337             if (moduleName) {
78338                 args.push(moduleName);
78339             }
78340             return factory.createCallExpression(factory.createIdentifier("require"), undefined, args);
78341         }
78342         function visitImportEqualsDeclaration(node) {
78343             ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer.");
78344             var statements;
78345             if (moduleKind !== ts.ModuleKind.AMD) {
78346                 if (ts.hasSyntacticModifier(node, 1)) {
78347                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(node.name, createRequireCall(node))), node), node));
78348                 }
78349                 else {
78350                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
78351                         factory.createVariableDeclaration(factory.cloneNode(node.name), undefined, undefined, createRequireCall(node))
78352                     ], languageVersion >= 2 ? 2 : 0)), node), node));
78353                 }
78354             }
78355             else {
78356                 if (ts.hasSyntacticModifier(node, 1)) {
78357                     statements = ts.append(statements, ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(node), factory.getLocalName(node))), node), node));
78358                 }
78359             }
78360             if (hasAssociatedEndOfDeclarationMarker(node)) {
78361                 var id = ts.getOriginalNodeId(node);
78362                 deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node);
78363             }
78364             else {
78365                 statements = appendExportsOfImportEqualsDeclaration(statements, node);
78366             }
78367             return ts.singleOrMany(statements);
78368         }
78369         function visitExportDeclaration(node) {
78370             if (!node.moduleSpecifier) {
78371                 return undefined;
78372             }
78373             var generatedName = factory.getGeneratedNameForNode(node);
78374             if (node.exportClause && ts.isNamedExports(node.exportClause)) {
78375                 var statements = [];
78376                 if (moduleKind !== ts.ModuleKind.AMD) {
78377                     statements.push(ts.setOriginalNode(ts.setTextRange(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
78378                         factory.createVariableDeclaration(generatedName, undefined, undefined, createRequireCall(node))
78379                     ])), node), node));
78380                 }
78381                 for (var _i = 0, _a = node.exportClause.elements; _i < _a.length; _i++) {
78382                     var specifier = _a[_i];
78383                     if (languageVersion === 0) {
78384                         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));
78385                     }
78386                     else {
78387                         var exportNeedsImportDefault = !!compilerOptions.esModuleInterop &&
78388                             !(ts.getEmitFlags(node) & 67108864) &&
78389                             ts.idText(specifier.propertyName || specifier.name) === "default";
78390                         var exportedValue = factory.createPropertyAccessExpression(exportNeedsImportDefault ? emitHelpers().createImportDefaultHelper(generatedName) : generatedName, specifier.propertyName || specifier.name);
78391                         statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.getExportName(specifier), exportedValue, undefined, true)), specifier), specifier));
78392                     }
78393                 }
78394                 return ts.singleOrMany(statements);
78395             }
78396             else if (node.exportClause) {
78397                 var statements = [];
78398                 statements.push(ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(createExportExpression(factory.cloneNode(node.exportClause.name), getHelperExpressionForExport(node, moduleKind !== ts.ModuleKind.AMD ?
78399                     createRequireCall(node) :
78400                     ts.isExportNamespaceAsDefaultDeclaration(node) ? generatedName :
78401                         factory.createIdentifier(ts.idText(node.exportClause.name))))), node), node));
78402                 return ts.singleOrMany(statements);
78403             }
78404             else {
78405                 return ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(emitHelpers().createExportStarHelper(moduleKind !== ts.ModuleKind.AMD ? createRequireCall(node) : generatedName)), node), node);
78406             }
78407         }
78408         function visitExportAssignment(node) {
78409             if (node.isExportEquals) {
78410                 return undefined;
78411             }
78412             var statements;
78413             var original = node.original;
78414             if (original && hasAssociatedEndOfDeclarationMarker(original)) {
78415                 var id = ts.getOriginalNodeId(node);
78416                 deferredExports[id] = appendExportStatement(deferredExports[id], factory.createIdentifier("default"), ts.visitNode(node.expression, moduleExpressionElementVisitor), node, true);
78417             }
78418             else {
78419                 statements = appendExportStatement(statements, factory.createIdentifier("default"), ts.visitNode(node.expression, moduleExpressionElementVisitor), node, true);
78420             }
78421             return ts.singleOrMany(statements);
78422         }
78423         function visitFunctionDeclaration(node) {
78424             var statements;
78425             if (ts.hasSyntacticModifier(node, 1)) {
78426                 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));
78427             }
78428             else {
78429                 statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context));
78430             }
78431             if (hasAssociatedEndOfDeclarationMarker(node)) {
78432                 var id = ts.getOriginalNodeId(node);
78433                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
78434             }
78435             else {
78436                 statements = appendExportsOfHoistedDeclaration(statements, node);
78437             }
78438             return ts.singleOrMany(statements);
78439         }
78440         function visitClassDeclaration(node) {
78441             var statements;
78442             if (ts.hasSyntacticModifier(node, 1)) {
78443                 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));
78444             }
78445             else {
78446                 statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context));
78447             }
78448             if (hasAssociatedEndOfDeclarationMarker(node)) {
78449                 var id = ts.getOriginalNodeId(node);
78450                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
78451             }
78452             else {
78453                 statements = appendExportsOfHoistedDeclaration(statements, node);
78454             }
78455             return ts.singleOrMany(statements);
78456         }
78457         function visitVariableStatement(node) {
78458             var statements;
78459             var variables;
78460             var expressions;
78461             if (ts.hasSyntacticModifier(node, 1)) {
78462                 var modifiers = void 0;
78463                 var removeCommentsOnExpressions = false;
78464                 for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
78465                     var variable = _a[_i];
78466                     if (ts.isIdentifier(variable.name) && ts.isLocalName(variable.name)) {
78467                         if (!modifiers) {
78468                             modifiers = ts.visitNodes(node.modifiers, modifierVisitor, ts.isModifier);
78469                         }
78470                         variables = ts.append(variables, variable);
78471                     }
78472                     else if (variable.initializer) {
78473                         if (!ts.isBindingPattern(variable.name) && (ts.isArrowFunction(variable.initializer) || ts.isFunctionExpression(variable.initializer) || ts.isClassExpression(variable.initializer))) {
78474                             var expression = factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), variable.name), variable.name), factory.createIdentifier(ts.getTextOfIdentifierOrLiteral(variable.name)));
78475                             var updatedVariable = factory.createVariableDeclaration(variable.name, variable.exclamationToken, variable.type, ts.visitNode(variable.initializer, moduleExpressionElementVisitor));
78476                             variables = ts.append(variables, updatedVariable);
78477                             expressions = ts.append(expressions, expression);
78478                             removeCommentsOnExpressions = true;
78479                         }
78480                         else {
78481                             expressions = ts.append(expressions, transformInitializedVariable(variable));
78482                         }
78483                     }
78484                 }
78485                 if (variables) {
78486                     statements = ts.append(statements, factory.updateVariableStatement(node, modifiers, factory.updateVariableDeclarationList(node.declarationList, variables)));
78487                 }
78488                 if (expressions) {
78489                     var statement = ts.setOriginalNode(ts.setTextRange(factory.createExpressionStatement(factory.inlineExpressions(expressions)), node), node);
78490                     if (removeCommentsOnExpressions) {
78491                         ts.removeAllComments(statement);
78492                     }
78493                     statements = ts.append(statements, statement);
78494                 }
78495             }
78496             else {
78497                 statements = ts.append(statements, ts.visitEachChild(node, moduleExpressionElementVisitor, context));
78498             }
78499             if (hasAssociatedEndOfDeclarationMarker(node)) {
78500                 var id = ts.getOriginalNodeId(node);
78501                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node);
78502             }
78503             else {
78504                 statements = appendExportsOfVariableStatement(statements, node);
78505             }
78506             return ts.singleOrMany(statements);
78507         }
78508         function createAllExportExpressions(name, value, location) {
78509             var exportedNames = getExports(name);
78510             if (exportedNames) {
78511                 var expression = ts.isExportName(name) ? value : factory.createAssignment(name, value);
78512                 for (var _i = 0, exportedNames_1 = exportedNames; _i < exportedNames_1.length; _i++) {
78513                     var exportName = exportedNames_1[_i];
78514                     ts.setEmitFlags(expression, 4);
78515                     expression = createExportExpression(exportName, expression, location);
78516                 }
78517                 return expression;
78518             }
78519             return factory.createAssignment(name, value);
78520         }
78521         function transformInitializedVariable(node) {
78522             if (ts.isBindingPattern(node.name)) {
78523                 return ts.flattenDestructuringAssignment(ts.visitNode(node, moduleExpressionElementVisitor), undefined, context, 0, false, createAllExportExpressions);
78524             }
78525             else {
78526                 return factory.createAssignment(ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), node.name), node.name), node.initializer ? ts.visitNode(node.initializer, moduleExpressionElementVisitor) : factory.createVoidZero());
78527             }
78528         }
78529         function visitMergeDeclarationMarker(node) {
78530             if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 232) {
78531                 var id = ts.getOriginalNodeId(node);
78532                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original);
78533             }
78534             return node;
78535         }
78536         function hasAssociatedEndOfDeclarationMarker(node) {
78537             return (ts.getEmitFlags(node) & 4194304) !== 0;
78538         }
78539         function visitEndOfDeclarationMarker(node) {
78540             var id = ts.getOriginalNodeId(node);
78541             var statements = deferredExports[id];
78542             if (statements) {
78543                 delete deferredExports[id];
78544                 return ts.append(statements, node);
78545             }
78546             return node;
78547         }
78548         function appendExportsOfImportDeclaration(statements, decl) {
78549             if (currentModuleInfo.exportEquals) {
78550                 return statements;
78551             }
78552             var importClause = decl.importClause;
78553             if (!importClause) {
78554                 return statements;
78555             }
78556             if (importClause.name) {
78557                 statements = appendExportsOfDeclaration(statements, importClause);
78558             }
78559             var namedBindings = importClause.namedBindings;
78560             if (namedBindings) {
78561                 switch (namedBindings.kind) {
78562                     case 263:
78563                         statements = appendExportsOfDeclaration(statements, namedBindings);
78564                         break;
78565                     case 264:
78566                         for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) {
78567                             var importBinding = _a[_i];
78568                             statements = appendExportsOfDeclaration(statements, importBinding, true);
78569                         }
78570                         break;
78571                 }
78572             }
78573             return statements;
78574         }
78575         function appendExportsOfImportEqualsDeclaration(statements, decl) {
78576             if (currentModuleInfo.exportEquals) {
78577                 return statements;
78578             }
78579             return appendExportsOfDeclaration(statements, decl);
78580         }
78581         function appendExportsOfVariableStatement(statements, node) {
78582             if (currentModuleInfo.exportEquals) {
78583                 return statements;
78584             }
78585             for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
78586                 var decl = _a[_i];
78587                 statements = appendExportsOfBindingElement(statements, decl);
78588             }
78589             return statements;
78590         }
78591         function appendExportsOfBindingElement(statements, decl) {
78592             if (currentModuleInfo.exportEquals) {
78593                 return statements;
78594             }
78595             if (ts.isBindingPattern(decl.name)) {
78596                 for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) {
78597                     var element = _a[_i];
78598                     if (!ts.isOmittedExpression(element)) {
78599                         statements = appendExportsOfBindingElement(statements, element);
78600                     }
78601                 }
78602             }
78603             else if (!ts.isGeneratedIdentifier(decl.name)) {
78604                 statements = appendExportsOfDeclaration(statements, decl);
78605             }
78606             return statements;
78607         }
78608         function appendExportsOfHoistedDeclaration(statements, decl) {
78609             if (currentModuleInfo.exportEquals) {
78610                 return statements;
78611             }
78612             if (ts.hasSyntacticModifier(decl, 1)) {
78613                 var exportName = ts.hasSyntacticModifier(decl, 512) ? factory.createIdentifier("default") : factory.getDeclarationName(decl);
78614                 statements = appendExportStatement(statements, exportName, factory.getLocalName(decl), decl);
78615             }
78616             if (decl.name) {
78617                 statements = appendExportsOfDeclaration(statements, decl);
78618             }
78619             return statements;
78620         }
78621         function appendExportsOfDeclaration(statements, decl, liveBinding) {
78622             var name = factory.getDeclarationName(decl);
78623             var exportSpecifiers = currentModuleInfo.exportSpecifiers.get(ts.idText(name));
78624             if (exportSpecifiers) {
78625                 for (var _i = 0, exportSpecifiers_1 = exportSpecifiers; _i < exportSpecifiers_1.length; _i++) {
78626                     var exportSpecifier = exportSpecifiers_1[_i];
78627                     statements = appendExportStatement(statements, exportSpecifier.name, name, exportSpecifier.name, undefined, liveBinding);
78628                 }
78629             }
78630             return statements;
78631         }
78632         function appendExportStatement(statements, exportName, expression, location, allowComments, liveBinding) {
78633             statements = ts.append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding));
78634             return statements;
78635         }
78636         function createUnderscoreUnderscoreESModule() {
78637             var statement;
78638             if (languageVersion === 0) {
78639                 statement = factory.createExpressionStatement(createExportExpression(factory.createIdentifier("__esModule"), factory.createTrue()));
78640             }
78641             else {
78642                 statement = factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), undefined, [
78643                     factory.createIdentifier("exports"),
78644                     factory.createStringLiteral("__esModule"),
78645                     factory.createObjectLiteralExpression([
78646                         factory.createPropertyAssignment("value", factory.createTrue())
78647                     ])
78648                 ]));
78649             }
78650             ts.setEmitFlags(statement, 1048576);
78651             return statement;
78652         }
78653         function createExportStatement(name, value, location, allowComments, liveBinding) {
78654             var statement = ts.setTextRange(factory.createExpressionStatement(createExportExpression(name, value, undefined, liveBinding)), location);
78655             ts.startOnNewLine(statement);
78656             if (!allowComments) {
78657                 ts.setEmitFlags(statement, 1536);
78658             }
78659             return statement;
78660         }
78661         function createExportExpression(name, value, location, liveBinding) {
78662             return ts.setTextRange(liveBinding && languageVersion !== 0 ? factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("Object"), "defineProperty"), undefined, [
78663                 factory.createIdentifier("exports"),
78664                 factory.createStringLiteralFromNode(name),
78665                 factory.createObjectLiteralExpression([
78666                     factory.createPropertyAssignment("enumerable", factory.createTrue()),
78667                     factory.createPropertyAssignment("get", factory.createFunctionExpression(undefined, undefined, undefined, undefined, [], undefined, factory.createBlock([factory.createReturnStatement(value)])))
78668                 ])
78669             ]) : factory.createAssignment(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(name)), value), location);
78670         }
78671         function modifierVisitor(node) {
78672             switch (node.kind) {
78673                 case 92:
78674                 case 87:
78675                     return undefined;
78676             }
78677             return node;
78678         }
78679         function onEmitNode(hint, node, emitCallback) {
78680             if (node.kind === 297) {
78681                 currentSourceFile = node;
78682                 currentModuleInfo = moduleInfoMap[ts.getOriginalNodeId(currentSourceFile)];
78683                 noSubstitution = [];
78684                 previousOnEmitNode(hint, node, emitCallback);
78685                 currentSourceFile = undefined;
78686                 currentModuleInfo = undefined;
78687                 noSubstitution = undefined;
78688             }
78689             else {
78690                 previousOnEmitNode(hint, node, emitCallback);
78691             }
78692         }
78693         function onSubstituteNode(hint, node) {
78694             node = previousOnSubstituteNode(hint, node);
78695             if (node.id && noSubstitution[node.id]) {
78696                 return node;
78697             }
78698             if (hint === 1) {
78699                 return substituteExpression(node);
78700             }
78701             else if (ts.isShorthandPropertyAssignment(node)) {
78702                 return substituteShorthandPropertyAssignment(node);
78703             }
78704             return node;
78705         }
78706         function substituteShorthandPropertyAssignment(node) {
78707             var name = node.name;
78708             var exportedOrImportedName = substituteExpressionIdentifier(name);
78709             if (exportedOrImportedName !== name) {
78710                 if (node.objectAssignmentInitializer) {
78711                     var initializer = factory.createAssignment(exportedOrImportedName, node.objectAssignmentInitializer);
78712                     return ts.setTextRange(factory.createPropertyAssignment(name, initializer), node);
78713                 }
78714                 return ts.setTextRange(factory.createPropertyAssignment(name, exportedOrImportedName), node);
78715             }
78716             return node;
78717         }
78718         function substituteExpression(node) {
78719             switch (node.kind) {
78720                 case 78:
78721                     return substituteExpressionIdentifier(node);
78722                 case 216:
78723                     return substituteBinaryExpression(node);
78724                 case 215:
78725                 case 214:
78726                     return substituteUnaryExpression(node);
78727             }
78728             return node;
78729         }
78730         function substituteExpressionIdentifier(node) {
78731             var _a, _b;
78732             if (ts.getEmitFlags(node) & 4096) {
78733                 var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile);
78734                 if (externalHelpersModuleName) {
78735                     return factory.createPropertyAccessExpression(externalHelpersModuleName, node);
78736                 }
78737                 return node;
78738             }
78739             if (!(ts.isGeneratedIdentifier(node) && !(node.autoGenerateFlags & 64)) && !ts.isLocalName(node)) {
78740                 var exportContainer = resolver.getReferencedExportContainer(node, ts.isExportName(node));
78741                 if (exportContainer && exportContainer.kind === 297) {
78742                     return ts.setTextRange(factory.createPropertyAccessExpression(factory.createIdentifier("exports"), factory.cloneNode(node)), node);
78743                 }
78744                 var importDeclaration = resolver.getReferencedImportDeclaration(node);
78745                 if (importDeclaration) {
78746                     if (ts.isImportClause(importDeclaration)) {
78747                         return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(importDeclaration.parent), factory.createIdentifier("default")), node);
78748                     }
78749                     else if (ts.isImportSpecifier(importDeclaration)) {
78750                         var name = importDeclaration.propertyName || importDeclaration.name;
78751                         return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.parent) || importDeclaration), factory.cloneNode(name)), node);
78752                     }
78753                 }
78754             }
78755             return node;
78756         }
78757         function substituteBinaryExpression(node) {
78758             if (ts.isAssignmentOperator(node.operatorToken.kind)
78759                 && ts.isIdentifier(node.left)
78760                 && !ts.isGeneratedIdentifier(node.left)
78761                 && !ts.isLocalName(node.left)
78762                 && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) {
78763                 var exportedNames = getExports(node.left);
78764                 if (exportedNames) {
78765                     var expression = node;
78766                     for (var _i = 0, exportedNames_2 = exportedNames; _i < exportedNames_2.length; _i++) {
78767                         var exportName = exportedNames_2[_i];
78768                         noSubstitution[ts.getNodeId(expression)] = true;
78769                         expression = createExportExpression(exportName, expression, node);
78770                     }
78771                     return expression;
78772                 }
78773             }
78774             return node;
78775         }
78776         function substituteUnaryExpression(node) {
78777             if ((node.operator === 45 || node.operator === 46)
78778                 && ts.isIdentifier(node.operand)
78779                 && !ts.isGeneratedIdentifier(node.operand)
78780                 && !ts.isLocalName(node.operand)
78781                 && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) {
78782                 var exportedNames = getExports(node.operand);
78783                 if (exportedNames) {
78784                     var expression = node.kind === 215
78785                         ? ts.setTextRange(factory.createBinaryExpression(node.operand, factory.createToken(node.operator === 45 ? 63 : 64), factory.createNumericLiteral(1)), node)
78786                         : node;
78787                     for (var _i = 0, exportedNames_3 = exportedNames; _i < exportedNames_3.length; _i++) {
78788                         var exportName = exportedNames_3[_i];
78789                         noSubstitution[ts.getNodeId(expression)] = true;
78790                         expression = factory.createParenthesizedExpression(createExportExpression(exportName, expression));
78791                     }
78792                     return expression;
78793                 }
78794             }
78795             return node;
78796         }
78797         function getExports(name) {
78798             if (!ts.isGeneratedIdentifier(name)) {
78799                 var valueDeclaration = resolver.getReferencedImportDeclaration(name)
78800                     || resolver.getReferencedValueDeclaration(name);
78801                 if (valueDeclaration) {
78802                     return currentModuleInfo
78803                         && currentModuleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)];
78804                 }
78805             }
78806         }
78807     }
78808     ts.transformModule = transformModule;
78809     var dynamicImportUMDHelper = {
78810         name: "typescript:dynamicimport-sync-require",
78811         scoped: true,
78812         text: "\n            var __syncRequire = typeof module === \"object\" && typeof module.exports === \"object\";"
78813     };
78814 })(ts || (ts = {}));
78815 var ts;
78816 (function (ts) {
78817     function transformSystemModule(context) {
78818         var factory = context.factory, startLexicalEnvironment = context.startLexicalEnvironment, endLexicalEnvironment = context.endLexicalEnvironment, hoistVariableDeclaration = context.hoistVariableDeclaration;
78819         var compilerOptions = context.getCompilerOptions();
78820         var resolver = context.getEmitResolver();
78821         var host = context.getEmitHost();
78822         var previousOnSubstituteNode = context.onSubstituteNode;
78823         var previousOnEmitNode = context.onEmitNode;
78824         context.onSubstituteNode = onSubstituteNode;
78825         context.onEmitNode = onEmitNode;
78826         context.enableSubstitution(78);
78827         context.enableSubstitution(289);
78828         context.enableSubstitution(216);
78829         context.enableSubstitution(214);
78830         context.enableSubstitution(215);
78831         context.enableSubstitution(226);
78832         context.enableEmitNotification(297);
78833         var moduleInfoMap = [];
78834         var deferredExports = [];
78835         var exportFunctionsMap = [];
78836         var noSubstitutionMap = [];
78837         var contextObjectMap = [];
78838         var currentSourceFile;
78839         var moduleInfo;
78840         var exportFunction;
78841         var contextObject;
78842         var hoistedStatements;
78843         var enclosingBlockScopedContainer;
78844         var noSubstitution;
78845         return ts.chainBundle(context, transformSourceFile);
78846         function transformSourceFile(node) {
78847             if (node.isDeclarationFile || !(ts.isEffectiveExternalModule(node, compilerOptions) || node.transformFlags & 2097152)) {
78848                 return node;
78849             }
78850             var id = ts.getOriginalNodeId(node);
78851             currentSourceFile = node;
78852             enclosingBlockScopedContainer = node;
78853             moduleInfo = moduleInfoMap[id] = ts.collectExternalModuleInfo(context, node, resolver, compilerOptions);
78854             exportFunction = factory.createUniqueName("exports");
78855             exportFunctionsMap[id] = exportFunction;
78856             contextObject = contextObjectMap[id] = factory.createUniqueName("context");
78857             var dependencyGroups = collectDependencyGroups(moduleInfo.externalImports);
78858             var moduleBodyBlock = createSystemModuleBody(node, dependencyGroups);
78859             var moduleBodyFunction = factory.createFunctionExpression(undefined, undefined, undefined, undefined, [
78860                 factory.createParameterDeclaration(undefined, undefined, undefined, exportFunction),
78861                 factory.createParameterDeclaration(undefined, undefined, undefined, contextObject)
78862             ], undefined, moduleBodyBlock);
78863             var moduleName = ts.tryGetModuleNameFromFile(factory, node, host, compilerOptions);
78864             var dependencies = factory.createArrayLiteralExpression(ts.map(dependencyGroups, function (dependencyGroup) { return dependencyGroup.name; }));
78865             var updated = ts.setEmitFlags(factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray([
78866                 factory.createExpressionStatement(factory.createCallExpression(factory.createPropertyAccessExpression(factory.createIdentifier("System"), "register"), undefined, moduleName
78867                     ? [moduleName, dependencies, moduleBodyFunction]
78868                     : [dependencies, moduleBodyFunction]))
78869             ]), node.statements)), 1024);
78870             if (!ts.outFile(compilerOptions)) {
78871                 ts.moveEmitHelpers(updated, moduleBodyBlock, function (helper) { return !helper.scoped; });
78872             }
78873             if (noSubstitution) {
78874                 noSubstitutionMap[id] = noSubstitution;
78875                 noSubstitution = undefined;
78876             }
78877             currentSourceFile = undefined;
78878             moduleInfo = undefined;
78879             exportFunction = undefined;
78880             contextObject = undefined;
78881             hoistedStatements = undefined;
78882             enclosingBlockScopedContainer = undefined;
78883             return updated;
78884         }
78885         function collectDependencyGroups(externalImports) {
78886             var groupIndices = new ts.Map();
78887             var dependencyGroups = [];
78888             for (var _i = 0, externalImports_1 = externalImports; _i < externalImports_1.length; _i++) {
78889                 var externalImport = externalImports_1[_i];
78890                 var externalModuleName = ts.getExternalModuleNameLiteral(factory, externalImport, currentSourceFile, host, resolver, compilerOptions);
78891                 if (externalModuleName) {
78892                     var text = externalModuleName.text;
78893                     var groupIndex = groupIndices.get(text);
78894                     if (groupIndex !== undefined) {
78895                         dependencyGroups[groupIndex].externalImports.push(externalImport);
78896                     }
78897                     else {
78898                         groupIndices.set(text, dependencyGroups.length);
78899                         dependencyGroups.push({
78900                             name: externalModuleName,
78901                             externalImports: [externalImport]
78902                         });
78903                     }
78904                 }
78905             }
78906             return dependencyGroups;
78907         }
78908         function createSystemModuleBody(node, dependencyGroups) {
78909             var statements = [];
78910             startLexicalEnvironment();
78911             var ensureUseStrict = ts.getStrictOptionValue(compilerOptions, "alwaysStrict") || (!compilerOptions.noImplicitUseStrict && ts.isExternalModule(currentSourceFile));
78912             var statementOffset = factory.copyPrologue(node.statements, statements, ensureUseStrict, sourceElementVisitor);
78913             statements.push(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
78914                 factory.createVariableDeclaration("__moduleName", undefined, undefined, factory.createLogicalAnd(contextObject, factory.createPropertyAccessExpression(contextObject, "id")))
78915             ])));
78916             ts.visitNode(moduleInfo.externalHelpersImportDeclaration, sourceElementVisitor, ts.isStatement);
78917             var executeStatements = ts.visitNodes(node.statements, sourceElementVisitor, ts.isStatement, statementOffset);
78918             ts.addRange(statements, hoistedStatements);
78919             ts.insertStatementsAfterStandardPrologue(statements, endLexicalEnvironment());
78920             var exportStarFunction = addExportStarIfNeeded(statements);
78921             var modifiers = node.transformFlags & 524288 ?
78922                 factory.createModifiersFromModifierFlags(256) :
78923                 undefined;
78924             var moduleObject = factory.createObjectLiteralExpression([
78925                 factory.createPropertyAssignment("setters", createSettersArray(exportStarFunction, dependencyGroups)),
78926                 factory.createPropertyAssignment("execute", factory.createFunctionExpression(modifiers, undefined, undefined, undefined, [], undefined, factory.createBlock(executeStatements, true)))
78927             ], true);
78928             statements.push(factory.createReturnStatement(moduleObject));
78929             return factory.createBlock(statements, true);
78930         }
78931         function addExportStarIfNeeded(statements) {
78932             if (!moduleInfo.hasExportStarsToExportValues) {
78933                 return;
78934             }
78935             if (!moduleInfo.exportedNames && moduleInfo.exportSpecifiers.size === 0) {
78936                 var hasExportDeclarationWithExportClause = false;
78937                 for (var _i = 0, _a = moduleInfo.externalImports; _i < _a.length; _i++) {
78938                     var externalImport = _a[_i];
78939                     if (externalImport.kind === 267 && externalImport.exportClause) {
78940                         hasExportDeclarationWithExportClause = true;
78941                         break;
78942                     }
78943                 }
78944                 if (!hasExportDeclarationWithExportClause) {
78945                     var exportStarFunction_1 = createExportStarFunction(undefined);
78946                     statements.push(exportStarFunction_1);
78947                     return exportStarFunction_1.name;
78948                 }
78949             }
78950             var exportedNames = [];
78951             if (moduleInfo.exportedNames) {
78952                 for (var _b = 0, _c = moduleInfo.exportedNames; _b < _c.length; _b++) {
78953                     var exportedLocalName = _c[_b];
78954                     if (exportedLocalName.escapedText === "default") {
78955                         continue;
78956                     }
78957                     exportedNames.push(factory.createPropertyAssignment(factory.createStringLiteralFromNode(exportedLocalName), factory.createTrue()));
78958                 }
78959             }
78960             var exportedNamesStorageRef = factory.createUniqueName("exportedNames");
78961             statements.push(factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
78962                 factory.createVariableDeclaration(exportedNamesStorageRef, undefined, undefined, factory.createObjectLiteralExpression(exportedNames, true))
78963             ])));
78964             var exportStarFunction = createExportStarFunction(exportedNamesStorageRef);
78965             statements.push(exportStarFunction);
78966             return exportStarFunction.name;
78967         }
78968         function createExportStarFunction(localNames) {
78969             var exportStarFunction = factory.createUniqueName("exportStar");
78970             var m = factory.createIdentifier("m");
78971             var n = factory.createIdentifier("n");
78972             var exports = factory.createIdentifier("exports");
78973             var condition = factory.createStrictInequality(n, factory.createStringLiteral("default"));
78974             if (localNames) {
78975                 condition = factory.createLogicalAnd(condition, factory.createLogicalNot(factory.createCallExpression(factory.createPropertyAccessExpression(localNames, "hasOwnProperty"), undefined, [n])));
78976             }
78977             return factory.createFunctionDeclaration(undefined, undefined, undefined, exportStarFunction, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, m)], undefined, factory.createBlock([
78978                 factory.createVariableStatement(undefined, factory.createVariableDeclarationList([
78979                     factory.createVariableDeclaration(exports, undefined, undefined, factory.createObjectLiteralExpression([]))
78980                 ])),
78981                 factory.createForInStatement(factory.createVariableDeclarationList([
78982                     factory.createVariableDeclaration(n)
78983                 ]), m, factory.createBlock([
78984                     ts.setEmitFlags(factory.createIfStatement(condition, factory.createExpressionStatement(factory.createAssignment(factory.createElementAccessExpression(exports, n), factory.createElementAccessExpression(m, n)))), 1)
78985                 ])),
78986                 factory.createExpressionStatement(factory.createCallExpression(exportFunction, undefined, [exports]))
78987             ], true));
78988         }
78989         function createSettersArray(exportStarFunction, dependencyGroups) {
78990             var setters = [];
78991             for (var _i = 0, dependencyGroups_1 = dependencyGroups; _i < dependencyGroups_1.length; _i++) {
78992                 var group_2 = dependencyGroups_1[_i];
78993                 var localName = ts.forEach(group_2.externalImports, function (i) { return ts.getLocalNameForExternalImport(factory, i, currentSourceFile); });
78994                 var parameterName = localName ? factory.getGeneratedNameForNode(localName) : factory.createUniqueName("");
78995                 var statements = [];
78996                 for (var _a = 0, _b = group_2.externalImports; _a < _b.length; _a++) {
78997                     var entry = _b[_a];
78998                     var importVariableName = ts.getLocalNameForExternalImport(factory, entry, currentSourceFile);
78999                     switch (entry.kind) {
79000                         case 261:
79001                             if (!entry.importClause) {
79002                                 break;
79003                             }
79004                         case 260:
79005                             ts.Debug.assert(importVariableName !== undefined);
79006                             statements.push(factory.createExpressionStatement(factory.createAssignment(importVariableName, parameterName)));
79007                             break;
79008                         case 267:
79009                             ts.Debug.assert(importVariableName !== undefined);
79010                             if (entry.exportClause) {
79011                                 if (ts.isNamedExports(entry.exportClause)) {
79012                                     var properties = [];
79013                                     for (var _c = 0, _d = entry.exportClause.elements; _c < _d.length; _c++) {
79014                                         var e = _d[_c];
79015                                         properties.push(factory.createPropertyAssignment(factory.createStringLiteral(ts.idText(e.name)), factory.createElementAccessExpression(parameterName, factory.createStringLiteral(ts.idText(e.propertyName || e.name)))));
79016                                     }
79017                                     statements.push(factory.createExpressionStatement(factory.createCallExpression(exportFunction, undefined, [factory.createObjectLiteralExpression(properties, true)])));
79018                                 }
79019                                 else {
79020                                     statements.push(factory.createExpressionStatement(factory.createCallExpression(exportFunction, undefined, [
79021                                         factory.createStringLiteral(ts.idText(entry.exportClause.name)),
79022                                         parameterName
79023                                     ])));
79024                                 }
79025                             }
79026                             else {
79027                                 statements.push(factory.createExpressionStatement(factory.createCallExpression(exportStarFunction, undefined, [parameterName])));
79028                             }
79029                             break;
79030                     }
79031                 }
79032                 setters.push(factory.createFunctionExpression(undefined, undefined, undefined, undefined, [factory.createParameterDeclaration(undefined, undefined, undefined, parameterName)], undefined, factory.createBlock(statements, true)));
79033             }
79034             return factory.createArrayLiteralExpression(setters, true);
79035         }
79036         function sourceElementVisitor(node) {
79037             switch (node.kind) {
79038                 case 261:
79039                     return visitImportDeclaration(node);
79040                 case 260:
79041                     return visitImportEqualsDeclaration(node);
79042                 case 267:
79043                     return visitExportDeclaration(node);
79044                 case 266:
79045                     return visitExportAssignment(node);
79046                 default:
79047                     return nestedElementVisitor(node);
79048             }
79049         }
79050         function visitImportDeclaration(node) {
79051             var statements;
79052             if (node.importClause) {
79053                 hoistVariableDeclaration(ts.getLocalNameForExternalImport(factory, node, currentSourceFile));
79054             }
79055             if (hasAssociatedEndOfDeclarationMarker(node)) {
79056                 var id = ts.getOriginalNodeId(node);
79057                 deferredExports[id] = appendExportsOfImportDeclaration(deferredExports[id], node);
79058             }
79059             else {
79060                 statements = appendExportsOfImportDeclaration(statements, node);
79061             }
79062             return ts.singleOrMany(statements);
79063         }
79064         function visitExportDeclaration(node) {
79065             ts.Debug.assertIsDefined(node);
79066             return undefined;
79067         }
79068         function visitImportEqualsDeclaration(node) {
79069             ts.Debug.assert(ts.isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer.");
79070             var statements;
79071             hoistVariableDeclaration(ts.getLocalNameForExternalImport(factory, node, currentSourceFile));
79072             if (hasAssociatedEndOfDeclarationMarker(node)) {
79073                 var id = ts.getOriginalNodeId(node);
79074                 deferredExports[id] = appendExportsOfImportEqualsDeclaration(deferredExports[id], node);
79075             }
79076             else {
79077                 statements = appendExportsOfImportEqualsDeclaration(statements, node);
79078             }
79079             return ts.singleOrMany(statements);
79080         }
79081         function visitExportAssignment(node) {
79082             if (node.isExportEquals) {
79083                 return undefined;
79084             }
79085             var expression = ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression);
79086             var original = node.original;
79087             if (original && hasAssociatedEndOfDeclarationMarker(original)) {
79088                 var id = ts.getOriginalNodeId(node);
79089                 deferredExports[id] = appendExportStatement(deferredExports[id], factory.createIdentifier("default"), expression, true);
79090             }
79091             else {
79092                 return createExportStatement(factory.createIdentifier("default"), expression, true);
79093             }
79094         }
79095         function visitFunctionDeclaration(node) {
79096             if (ts.hasSyntacticModifier(node, 1)) {
79097                 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)));
79098             }
79099             else {
79100                 hoistedStatements = ts.append(hoistedStatements, ts.visitEachChild(node, destructuringAndImportCallVisitor, context));
79101             }
79102             if (hasAssociatedEndOfDeclarationMarker(node)) {
79103                 var id = ts.getOriginalNodeId(node);
79104                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
79105             }
79106             else {
79107                 hoistedStatements = appendExportsOfHoistedDeclaration(hoistedStatements, node);
79108             }
79109             return undefined;
79110         }
79111         function visitClassDeclaration(node) {
79112             var statements;
79113             var name = factory.getLocalName(node);
79114             hoistVariableDeclaration(name);
79115             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));
79116             if (hasAssociatedEndOfDeclarationMarker(node)) {
79117                 var id = ts.getOriginalNodeId(node);
79118                 deferredExports[id] = appendExportsOfHoistedDeclaration(deferredExports[id], node);
79119             }
79120             else {
79121                 statements = appendExportsOfHoistedDeclaration(statements, node);
79122             }
79123             return ts.singleOrMany(statements);
79124         }
79125         function visitVariableStatement(node) {
79126             if (!shouldHoistVariableDeclarationList(node.declarationList)) {
79127                 return ts.visitNode(node, destructuringAndImportCallVisitor, ts.isStatement);
79128             }
79129             var expressions;
79130             var isExportedDeclaration = ts.hasSyntacticModifier(node, 1);
79131             var isMarkedDeclaration = hasAssociatedEndOfDeclarationMarker(node);
79132             for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
79133                 var variable = _a[_i];
79134                 if (variable.initializer) {
79135                     expressions = ts.append(expressions, transformInitializedVariable(variable, isExportedDeclaration && !isMarkedDeclaration));
79136                 }
79137                 else {
79138                     hoistBindingElement(variable);
79139                 }
79140             }
79141             var statements;
79142             if (expressions) {
79143                 statements = ts.append(statements, ts.setTextRange(factory.createExpressionStatement(factory.inlineExpressions(expressions)), node));
79144             }
79145             if (isMarkedDeclaration) {
79146                 var id = ts.getOriginalNodeId(node);
79147                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node, isExportedDeclaration);
79148             }
79149             else {
79150                 statements = appendExportsOfVariableStatement(statements, node, false);
79151             }
79152             return ts.singleOrMany(statements);
79153         }
79154         function hoistBindingElement(node) {
79155             if (ts.isBindingPattern(node.name)) {
79156                 for (var _i = 0, _a = node.name.elements; _i < _a.length; _i++) {
79157                     var element = _a[_i];
79158                     if (!ts.isOmittedExpression(element)) {
79159                         hoistBindingElement(element);
79160                     }
79161                 }
79162             }
79163             else {
79164                 hoistVariableDeclaration(factory.cloneNode(node.name));
79165             }
79166         }
79167         function shouldHoistVariableDeclarationList(node) {
79168             return (ts.getEmitFlags(node) & 2097152) === 0
79169                 && (enclosingBlockScopedContainer.kind === 297
79170                     || (ts.getOriginalNode(node).flags & 3) === 0);
79171         }
79172         function transformInitializedVariable(node, isExportedDeclaration) {
79173             var createAssignment = isExportedDeclaration ? createExportedVariableAssignment : createNonExportedVariableAssignment;
79174             return ts.isBindingPattern(node.name)
79175                 ? ts.flattenDestructuringAssignment(node, destructuringAndImportCallVisitor, context, 0, false, createAssignment)
79176                 : node.initializer ? createAssignment(node.name, ts.visitNode(node.initializer, destructuringAndImportCallVisitor, ts.isExpression)) : node.name;
79177         }
79178         function createExportedVariableAssignment(name, value, location) {
79179             return createVariableAssignment(name, value, location, true);
79180         }
79181         function createNonExportedVariableAssignment(name, value, location) {
79182             return createVariableAssignment(name, value, location, false);
79183         }
79184         function createVariableAssignment(name, value, location, isExportedDeclaration) {
79185             hoistVariableDeclaration(factory.cloneNode(name));
79186             return isExportedDeclaration
79187                 ? createExportExpression(name, preventSubstitution(ts.setTextRange(factory.createAssignment(name, value), location)))
79188                 : preventSubstitution(ts.setTextRange(factory.createAssignment(name, value), location));
79189         }
79190         function visitMergeDeclarationMarker(node) {
79191             if (hasAssociatedEndOfDeclarationMarker(node) && node.original.kind === 232) {
79192                 var id = ts.getOriginalNodeId(node);
79193                 var isExportedDeclaration = ts.hasSyntacticModifier(node.original, 1);
79194                 deferredExports[id] = appendExportsOfVariableStatement(deferredExports[id], node.original, isExportedDeclaration);
79195             }
79196             return node;
79197         }
79198         function hasAssociatedEndOfDeclarationMarker(node) {
79199             return (ts.getEmitFlags(node) & 4194304) !== 0;
79200         }
79201         function visitEndOfDeclarationMarker(node) {
79202             var id = ts.getOriginalNodeId(node);
79203             var statements = deferredExports[id];
79204             if (statements) {
79205                 delete deferredExports[id];
79206                 return ts.append(statements, node);
79207             }
79208             else {
79209                 var original = ts.getOriginalNode(node);
79210                 if (ts.isModuleOrEnumDeclaration(original)) {
79211                     return ts.append(appendExportsOfDeclaration(statements, original), node);
79212                 }
79213             }
79214             return node;
79215         }
79216         function appendExportsOfImportDeclaration(statements, decl) {
79217             if (moduleInfo.exportEquals) {
79218                 return statements;
79219             }
79220             var importClause = decl.importClause;
79221             if (!importClause) {
79222                 return statements;
79223             }
79224             if (importClause.name) {
79225                 statements = appendExportsOfDeclaration(statements, importClause);
79226             }
79227             var namedBindings = importClause.namedBindings;
79228             if (namedBindings) {
79229                 switch (namedBindings.kind) {
79230                     case 263:
79231                         statements = appendExportsOfDeclaration(statements, namedBindings);
79232                         break;
79233                     case 264:
79234                         for (var _i = 0, _a = namedBindings.elements; _i < _a.length; _i++) {
79235                             var importBinding = _a[_i];
79236                             statements = appendExportsOfDeclaration(statements, importBinding);
79237                         }
79238                         break;
79239                 }
79240             }
79241             return statements;
79242         }
79243         function appendExportsOfImportEqualsDeclaration(statements, decl) {
79244             if (moduleInfo.exportEquals) {
79245                 return statements;
79246             }
79247             return appendExportsOfDeclaration(statements, decl);
79248         }
79249         function appendExportsOfVariableStatement(statements, node, exportSelf) {
79250             if (moduleInfo.exportEquals) {
79251                 return statements;
79252             }
79253             for (var _i = 0, _a = node.declarationList.declarations; _i < _a.length; _i++) {
79254                 var decl = _a[_i];
79255                 if (decl.initializer || exportSelf) {
79256                     statements = appendExportsOfBindingElement(statements, decl, exportSelf);
79257                 }
79258             }
79259             return statements;
79260         }
79261         function appendExportsOfBindingElement(statements, decl, exportSelf) {
79262             if (moduleInfo.exportEquals) {
79263                 return statements;
79264             }
79265             if (ts.isBindingPattern(decl.name)) {
79266                 for (var _i = 0, _a = decl.name.elements; _i < _a.length; _i++) {
79267                     var element = _a[_i];
79268                     if (!ts.isOmittedExpression(element)) {
79269                         statements = appendExportsOfBindingElement(statements, element, exportSelf);
79270                     }
79271                 }
79272             }
79273             else if (!ts.isGeneratedIdentifier(decl.name)) {
79274                 var excludeName = void 0;
79275                 if (exportSelf) {
79276                     statements = appendExportStatement(statements, decl.name, factory.getLocalName(decl));
79277                     excludeName = ts.idText(decl.name);
79278                 }
79279                 statements = appendExportsOfDeclaration(statements, decl, excludeName);
79280             }
79281             return statements;
79282         }
79283         function appendExportsOfHoistedDeclaration(statements, decl) {
79284             if (moduleInfo.exportEquals) {
79285                 return statements;
79286             }
79287             var excludeName;
79288             if (ts.hasSyntacticModifier(decl, 1)) {
79289                 var exportName = ts.hasSyntacticModifier(decl, 512) ? factory.createStringLiteral("default") : decl.name;
79290                 statements = appendExportStatement(statements, exportName, factory.getLocalName(decl));
79291                 excludeName = ts.getTextOfIdentifierOrLiteral(exportName);
79292             }
79293             if (decl.name) {
79294                 statements = appendExportsOfDeclaration(statements, decl, excludeName);
79295             }
79296             return statements;
79297         }
79298         function appendExportsOfDeclaration(statements, decl, excludeName) {
79299             if (moduleInfo.exportEquals) {
79300                 return statements;
79301             }
79302             var name = factory.getDeclarationName(decl);
79303             var exportSpecifiers = moduleInfo.exportSpecifiers.get(ts.idText(name));
79304             if (exportSpecifiers) {
79305                 for (var _i = 0, exportSpecifiers_2 = exportSpecifiers; _i < exportSpecifiers_2.length; _i++) {
79306                     var exportSpecifier = exportSpecifiers_2[_i];
79307                     if (exportSpecifier.name.escapedText !== excludeName) {
79308                         statements = appendExportStatement(statements, exportSpecifier.name, name);
79309                     }
79310                 }
79311             }
79312             return statements;
79313         }
79314         function appendExportStatement(statements, exportName, expression, allowComments) {
79315             statements = ts.append(statements, createExportStatement(exportName, expression, allowComments));
79316             return statements;
79317         }
79318         function createExportStatement(name, value, allowComments) {
79319             var statement = factory.createExpressionStatement(createExportExpression(name, value));
79320             ts.startOnNewLine(statement);
79321             if (!allowComments) {
79322                 ts.setEmitFlags(statement, 1536);
79323             }
79324             return statement;
79325         }
79326         function createExportExpression(name, value) {
79327             var exportName = ts.isIdentifier(name) ? factory.createStringLiteralFromNode(name) : name;
79328             ts.setEmitFlags(value, ts.getEmitFlags(value) | 1536);
79329             return ts.setCommentRange(factory.createCallExpression(exportFunction, undefined, [exportName, value]), value);
79330         }
79331         function nestedElementVisitor(node) {
79332             switch (node.kind) {
79333                 case 232:
79334                     return visitVariableStatement(node);
79335                 case 251:
79336                     return visitFunctionDeclaration(node);
79337                 case 252:
79338                     return visitClassDeclaration(node);
79339                 case 237:
79340                     return visitForStatement(node);
79341                 case 238:
79342                     return visitForInStatement(node);
79343                 case 239:
79344                     return visitForOfStatement(node);
79345                 case 235:
79346                     return visitDoStatement(node);
79347                 case 236:
79348                     return visitWhileStatement(node);
79349                 case 245:
79350                     return visitLabeledStatement(node);
79351                 case 243:
79352                     return visitWithStatement(node);
79353                 case 244:
79354                     return visitSwitchStatement(node);
79355                 case 258:
79356                     return visitCaseBlock(node);
79357                 case 284:
79358                     return visitCaseClause(node);
79359                 case 285:
79360                     return visitDefaultClause(node);
79361                 case 247:
79362                     return visitTryStatement(node);
79363                 case 287:
79364                     return visitCatchClause(node);
79365                 case 230:
79366                     return visitBlock(node);
79367                 case 338:
79368                     return visitMergeDeclarationMarker(node);
79369                 case 339:
79370                     return visitEndOfDeclarationMarker(node);
79371                 default:
79372                     return destructuringAndImportCallVisitor(node);
79373             }
79374         }
79375         function visitForStatement(node) {
79376             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
79377             enclosingBlockScopedContainer = node;
79378             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));
79379             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
79380             return node;
79381         }
79382         function visitForInStatement(node) {
79383             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
79384             enclosingBlockScopedContainer = node;
79385             node = factory.updateForInStatement(node, visitForInitializer(node.initializer), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock));
79386             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
79387             return node;
79388         }
79389         function visitForOfStatement(node) {
79390             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
79391             enclosingBlockScopedContainer = node;
79392             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));
79393             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
79394             return node;
79395         }
79396         function shouldHoistForInitializer(node) {
79397             return ts.isVariableDeclarationList(node)
79398                 && shouldHoistVariableDeclarationList(node);
79399         }
79400         function visitForInitializer(node) {
79401             if (shouldHoistForInitializer(node)) {
79402                 var expressions = void 0;
79403                 for (var _i = 0, _a = node.declarations; _i < _a.length; _i++) {
79404                     var variable = _a[_i];
79405                     expressions = ts.append(expressions, transformInitializedVariable(variable, false));
79406                     if (!variable.initializer) {
79407                         hoistBindingElement(variable);
79408                     }
79409                 }
79410                 return expressions ? factory.inlineExpressions(expressions) : factory.createOmittedExpression();
79411             }
79412             else {
79413                 return ts.visitEachChild(node, nestedElementVisitor, context);
79414             }
79415         }
79416         function visitDoStatement(node) {
79417             return factory.updateDoStatement(node, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock), ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression));
79418         }
79419         function visitWhileStatement(node) {
79420             return factory.updateWhileStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock));
79421         }
79422         function visitLabeledStatement(node) {
79423             return factory.updateLabeledStatement(node, node.label, ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock));
79424         }
79425         function visitWithStatement(node) {
79426             return factory.updateWithStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.statement, nestedElementVisitor, ts.isStatement, factory.liftToBlock));
79427         }
79428         function visitSwitchStatement(node) {
79429             return factory.updateSwitchStatement(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNode(node.caseBlock, nestedElementVisitor, ts.isCaseBlock));
79430         }
79431         function visitCaseBlock(node) {
79432             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
79433             enclosingBlockScopedContainer = node;
79434             node = factory.updateCaseBlock(node, ts.visitNodes(node.clauses, nestedElementVisitor, ts.isCaseOrDefaultClause));
79435             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
79436             return node;
79437         }
79438         function visitCaseClause(node) {
79439             return factory.updateCaseClause(node, ts.visitNode(node.expression, destructuringAndImportCallVisitor, ts.isExpression), ts.visitNodes(node.statements, nestedElementVisitor, ts.isStatement));
79440         }
79441         function visitDefaultClause(node) {
79442             return ts.visitEachChild(node, nestedElementVisitor, context);
79443         }
79444         function visitTryStatement(node) {
79445             return ts.visitEachChild(node, nestedElementVisitor, context);
79446         }
79447         function visitCatchClause(node) {
79448             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
79449             enclosingBlockScopedContainer = node;
79450             node = factory.updateCatchClause(node, node.variableDeclaration, ts.visitNode(node.block, nestedElementVisitor, ts.isBlock));
79451             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
79452             return node;
79453         }
79454         function visitBlock(node) {
79455             var savedEnclosingBlockScopedContainer = enclosingBlockScopedContainer;
79456             enclosingBlockScopedContainer = node;
79457             node = ts.visitEachChild(node, nestedElementVisitor, context);
79458             enclosingBlockScopedContainer = savedEnclosingBlockScopedContainer;
79459             return node;
79460         }
79461         function destructuringAndImportCallVisitor(node) {
79462             if (ts.isDestructuringAssignment(node)) {
79463                 return visitDestructuringAssignment(node);
79464             }
79465             else if (ts.isImportCall(node)) {
79466                 return visitImportCallExpression(node);
79467             }
79468             else if ((node.transformFlags & 1024) || (node.transformFlags & 2097152)) {
79469                 return ts.visitEachChild(node, destructuringAndImportCallVisitor, context);
79470             }
79471             else {
79472                 return node;
79473             }
79474         }
79475         function visitImportCallExpression(node) {
79476             var externalModuleName = ts.getExternalModuleNameLiteral(factory, node, currentSourceFile, host, resolver, compilerOptions);
79477             var firstArgument = ts.visitNode(ts.firstOrUndefined(node.arguments), destructuringAndImportCallVisitor);
79478             var argument = externalModuleName && (!firstArgument || !ts.isStringLiteral(firstArgument) || firstArgument.text !== externalModuleName.text) ? externalModuleName : firstArgument;
79479             return factory.createCallExpression(factory.createPropertyAccessExpression(contextObject, factory.createIdentifier("import")), undefined, argument ? [argument] : []);
79480         }
79481         function visitDestructuringAssignment(node) {
79482             if (hasExportedReferenceInDestructuringTarget(node.left)) {
79483                 return ts.flattenDestructuringAssignment(node, destructuringAndImportCallVisitor, context, 0, true);
79484             }
79485             return ts.visitEachChild(node, destructuringAndImportCallVisitor, context);
79486         }
79487         function hasExportedReferenceInDestructuringTarget(node) {
79488             if (ts.isAssignmentExpression(node, true)) {
79489                 return hasExportedReferenceInDestructuringTarget(node.left);
79490             }
79491             else if (ts.isSpreadElement(node)) {
79492                 return hasExportedReferenceInDestructuringTarget(node.expression);
79493             }
79494             else if (ts.isObjectLiteralExpression(node)) {
79495                 return ts.some(node.properties, hasExportedReferenceInDestructuringTarget);
79496             }
79497             else if (ts.isArrayLiteralExpression(node)) {
79498                 return ts.some(node.elements, hasExportedReferenceInDestructuringTarget);
79499             }
79500             else if (ts.isShorthandPropertyAssignment(node)) {
79501                 return hasExportedReferenceInDestructuringTarget(node.name);
79502             }
79503             else if (ts.isPropertyAssignment(node)) {
79504                 return hasExportedReferenceInDestructuringTarget(node.initializer);
79505             }
79506             else if (ts.isIdentifier(node)) {
79507                 var container = resolver.getReferencedExportContainer(node);
79508                 return container !== undefined && container.kind === 297;
79509             }
79510             else {
79511                 return false;
79512             }
79513         }
79514         function modifierVisitor(node) {
79515             switch (node.kind) {
79516                 case 92:
79517                 case 87:
79518                     return undefined;
79519             }
79520             return node;
79521         }
79522         function onEmitNode(hint, node, emitCallback) {
79523             if (node.kind === 297) {
79524                 var id = ts.getOriginalNodeId(node);
79525                 currentSourceFile = node;
79526                 moduleInfo = moduleInfoMap[id];
79527                 exportFunction = exportFunctionsMap[id];
79528                 noSubstitution = noSubstitutionMap[id];
79529                 contextObject = contextObjectMap[id];
79530                 if (noSubstitution) {
79531                     delete noSubstitutionMap[id];
79532                 }
79533                 previousOnEmitNode(hint, node, emitCallback);
79534                 currentSourceFile = undefined;
79535                 moduleInfo = undefined;
79536                 exportFunction = undefined;
79537                 contextObject = undefined;
79538                 noSubstitution = undefined;
79539             }
79540             else {
79541                 previousOnEmitNode(hint, node, emitCallback);
79542             }
79543         }
79544         function onSubstituteNode(hint, node) {
79545             node = previousOnSubstituteNode(hint, node);
79546             if (isSubstitutionPrevented(node)) {
79547                 return node;
79548             }
79549             if (hint === 1) {
79550                 return substituteExpression(node);
79551             }
79552             else if (hint === 4) {
79553                 return substituteUnspecified(node);
79554             }
79555             return node;
79556         }
79557         function substituteUnspecified(node) {
79558             switch (node.kind) {
79559                 case 289:
79560                     return substituteShorthandPropertyAssignment(node);
79561             }
79562             return node;
79563         }
79564         function substituteShorthandPropertyAssignment(node) {
79565             var _a, _b;
79566             var name = node.name;
79567             if (!ts.isGeneratedIdentifier(name) && !ts.isLocalName(name)) {
79568                 var importDeclaration = resolver.getReferencedImportDeclaration(name);
79569                 if (importDeclaration) {
79570                     if (ts.isImportClause(importDeclaration)) {
79571                         return ts.setTextRange(factory.createPropertyAssignment(factory.cloneNode(name), factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(importDeclaration.parent), factory.createIdentifier("default"))), node);
79572                     }
79573                     else if (ts.isImportSpecifier(importDeclaration)) {
79574                         return ts.setTextRange(factory.createPropertyAssignment(factory.cloneNode(name), factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.parent) || importDeclaration), factory.cloneNode(importDeclaration.propertyName || importDeclaration.name))), node);
79575                     }
79576                 }
79577             }
79578             return node;
79579         }
79580         function substituteExpression(node) {
79581             switch (node.kind) {
79582                 case 78:
79583                     return substituteExpressionIdentifier(node);
79584                 case 216:
79585                     return substituteBinaryExpression(node);
79586                 case 214:
79587                 case 215:
79588                     return substituteUnaryExpression(node);
79589                 case 226:
79590                     return substituteMetaProperty(node);
79591             }
79592             return node;
79593         }
79594         function substituteExpressionIdentifier(node) {
79595             var _a, _b;
79596             if (ts.getEmitFlags(node) & 4096) {
79597                 var externalHelpersModuleName = ts.getExternalHelpersModuleName(currentSourceFile);
79598                 if (externalHelpersModuleName) {
79599                     return factory.createPropertyAccessExpression(externalHelpersModuleName, node);
79600                 }
79601                 return node;
79602             }
79603             if (!ts.isGeneratedIdentifier(node) && !ts.isLocalName(node)) {
79604                 var importDeclaration = resolver.getReferencedImportDeclaration(node);
79605                 if (importDeclaration) {
79606                     if (ts.isImportClause(importDeclaration)) {
79607                         return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(importDeclaration.parent), factory.createIdentifier("default")), node);
79608                     }
79609                     else if (ts.isImportSpecifier(importDeclaration)) {
79610                         return ts.setTextRange(factory.createPropertyAccessExpression(factory.getGeneratedNameForNode(((_b = (_a = importDeclaration.parent) === null || _a === void 0 ? void 0 : _a.parent) === null || _b === void 0 ? void 0 : _b.parent) || importDeclaration), factory.cloneNode(importDeclaration.propertyName || importDeclaration.name)), node);
79611                     }
79612                 }
79613             }
79614             return node;
79615         }
79616         function substituteBinaryExpression(node) {
79617             if (ts.isAssignmentOperator(node.operatorToken.kind)
79618                 && ts.isIdentifier(node.left)
79619                 && !ts.isGeneratedIdentifier(node.left)
79620                 && !ts.isLocalName(node.left)
79621                 && !ts.isDeclarationNameOfEnumOrNamespace(node.left)) {
79622                 var exportedNames = getExports(node.left);
79623                 if (exportedNames) {
79624                     var expression = node;
79625                     for (var _i = 0, exportedNames_4 = exportedNames; _i < exportedNames_4.length; _i++) {
79626                         var exportName = exportedNames_4[_i];
79627                         expression = createExportExpression(exportName, preventSubstitution(expression));
79628                     }
79629                     return expression;
79630                 }
79631             }
79632             return node;
79633         }
79634         function substituteUnaryExpression(node) {
79635             if ((node.operator === 45 || node.operator === 46)
79636                 && ts.isIdentifier(node.operand)
79637                 && !ts.isGeneratedIdentifier(node.operand)
79638                 && !ts.isLocalName(node.operand)
79639                 && !ts.isDeclarationNameOfEnumOrNamespace(node.operand)) {
79640                 var exportedNames = getExports(node.operand);
79641                 if (exportedNames) {
79642                     var expression = node.kind === 215
79643                         ? ts.setTextRange(factory.createPrefixUnaryExpression(node.operator, node.operand), node)
79644                         : node;
79645                     for (var _i = 0, exportedNames_5 = exportedNames; _i < exportedNames_5.length; _i++) {
79646                         var exportName = exportedNames_5[_i];
79647                         expression = createExportExpression(exportName, preventSubstitution(expression));
79648                     }
79649                     if (node.kind === 215) {
79650                         expression = node.operator === 45
79651                             ? factory.createSubtract(preventSubstitution(expression), factory.createNumericLiteral(1))
79652                             : factory.createAdd(preventSubstitution(expression), factory.createNumericLiteral(1));
79653                     }
79654                     return expression;
79655                 }
79656             }
79657             return node;
79658         }
79659         function substituteMetaProperty(node) {
79660             if (ts.isImportMeta(node)) {
79661                 return factory.createPropertyAccessExpression(contextObject, factory.createIdentifier("meta"));
79662             }
79663             return node;
79664         }
79665         function getExports(name) {
79666             var exportedNames;
79667             if (!ts.isGeneratedIdentifier(name)) {
79668                 var valueDeclaration = resolver.getReferencedImportDeclaration(name)
79669                     || resolver.getReferencedValueDeclaration(name);
79670                 if (valueDeclaration) {
79671                     var exportContainer = resolver.getReferencedExportContainer(name, false);
79672                     if (exportContainer && exportContainer.kind === 297) {
79673                         exportedNames = ts.append(exportedNames, factory.getDeclarationName(valueDeclaration));
79674                     }
79675                     exportedNames = ts.addRange(exportedNames, moduleInfo && moduleInfo.exportedBindings[ts.getOriginalNodeId(valueDeclaration)]);
79676                 }
79677             }
79678             return exportedNames;
79679         }
79680         function preventSubstitution(node) {
79681             if (noSubstitution === undefined)
79682                 noSubstitution = [];
79683             noSubstitution[ts.getNodeId(node)] = true;
79684             return node;
79685         }
79686         function isSubstitutionPrevented(node) {
79687             return noSubstitution && node.id && noSubstitution[node.id];
79688         }
79689     }
79690     ts.transformSystemModule = transformSystemModule;
79691 })(ts || (ts = {}));
79692 var ts;
79693 (function (ts) {
79694     function transformECMAScriptModule(context) {
79695         var factory = context.factory, emitHelpers = context.getEmitHelperFactory;
79696         var compilerOptions = context.getCompilerOptions();
79697         var previousOnEmitNode = context.onEmitNode;
79698         var previousOnSubstituteNode = context.onSubstituteNode;
79699         context.onEmitNode = onEmitNode;
79700         context.onSubstituteNode = onSubstituteNode;
79701         context.enableEmitNotification(297);
79702         context.enableSubstitution(78);
79703         var helperNameSubstitutions;
79704         return ts.chainBundle(context, transformSourceFile);
79705         function transformSourceFile(node) {
79706             if (node.isDeclarationFile) {
79707                 return node;
79708             }
79709             if (ts.isExternalModule(node) || compilerOptions.isolatedModules) {
79710                 var result = updateExternalModule(node);
79711                 if (!ts.isExternalModule(node) || ts.some(result.statements, ts.isExternalModuleIndicator)) {
79712                     return result;
79713                 }
79714                 return factory.updateSourceFile(result, ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray([], result.statements), [ts.createEmptyExports(factory)])), result.statements));
79715             }
79716             return node;
79717         }
79718         function updateExternalModule(node) {
79719             var externalHelpersImportDeclaration = ts.createExternalHelpersImportDeclarationIfNeeded(factory, emitHelpers(), node, compilerOptions);
79720             if (externalHelpersImportDeclaration) {
79721                 var statements = [];
79722                 var statementOffset = factory.copyPrologue(node.statements, statements);
79723                 ts.append(statements, externalHelpersImportDeclaration);
79724                 ts.addRange(statements, ts.visitNodes(node.statements, visitor, ts.isStatement, statementOffset));
79725                 return factory.updateSourceFile(node, ts.setTextRange(factory.createNodeArray(statements), node.statements));
79726             }
79727             else {
79728                 return ts.visitEachChild(node, visitor, context);
79729             }
79730         }
79731         function visitor(node) {
79732             switch (node.kind) {
79733                 case 260:
79734                     return undefined;
79735                 case 266:
79736                     return visitExportAssignment(node);
79737                 case 267:
79738                     var exportDecl = node;
79739                     return visitExportDeclaration(exportDecl);
79740             }
79741             return node;
79742         }
79743         function visitExportAssignment(node) {
79744             return node.isExportEquals ? undefined : node;
79745         }
79746         function visitExportDeclaration(node) {
79747             if (compilerOptions.module !== undefined && compilerOptions.module > ts.ModuleKind.ES2015) {
79748                 return node;
79749             }
79750             if (!node.exportClause || !ts.isNamespaceExport(node.exportClause) || !node.moduleSpecifier) {
79751                 return node;
79752             }
79753             var oldIdentifier = node.exportClause.name;
79754             var synthName = factory.getGeneratedNameForNode(oldIdentifier);
79755             var importDecl = factory.createImportDeclaration(undefined, undefined, factory.createImportClause(false, undefined, factory.createNamespaceImport(synthName)), node.moduleSpecifier);
79756             ts.setOriginalNode(importDecl, node.exportClause);
79757             var exportDecl = ts.isExportNamespaceAsDefaultDeclaration(node) ? factory.createExportDefault(synthName) : factory.createExportDeclaration(undefined, undefined, false, factory.createNamedExports([factory.createExportSpecifier(synthName, oldIdentifier)]));
79758             ts.setOriginalNode(exportDecl, node);
79759             return [importDecl, exportDecl];
79760         }
79761         function onEmitNode(hint, node, emitCallback) {
79762             if (ts.isSourceFile(node)) {
79763                 if ((ts.isExternalModule(node) || compilerOptions.isolatedModules) && compilerOptions.importHelpers) {
79764                     helperNameSubstitutions = new ts.Map();
79765                 }
79766                 previousOnEmitNode(hint, node, emitCallback);
79767                 helperNameSubstitutions = undefined;
79768             }
79769             else {
79770                 previousOnEmitNode(hint, node, emitCallback);
79771             }
79772         }
79773         function onSubstituteNode(hint, node) {
79774             node = previousOnSubstituteNode(hint, node);
79775             if (helperNameSubstitutions && ts.isIdentifier(node) && ts.getEmitFlags(node) & 4096) {
79776                 return substituteHelperName(node);
79777             }
79778             return node;
79779         }
79780         function substituteHelperName(node) {
79781             var name = ts.idText(node);
79782             var substitution = helperNameSubstitutions.get(name);
79783             if (!substitution) {
79784                 helperNameSubstitutions.set(name, substitution = factory.createUniqueName(name, 16 | 32));
79785             }
79786             return substitution;
79787         }
79788     }
79789     ts.transformECMAScriptModule = transformECMAScriptModule;
79790 })(ts || (ts = {}));
79791 var ts;
79792 (function (ts) {
79793     function canProduceDiagnostics(node) {
79794         return ts.isVariableDeclaration(node) ||
79795             ts.isPropertyDeclaration(node) ||
79796             ts.isPropertySignature(node) ||
79797             ts.isBindingElement(node) ||
79798             ts.isSetAccessor(node) ||
79799             ts.isGetAccessor(node) ||
79800             ts.isConstructSignatureDeclaration(node) ||
79801             ts.isCallSignatureDeclaration(node) ||
79802             ts.isMethodDeclaration(node) ||
79803             ts.isMethodSignature(node) ||
79804             ts.isFunctionDeclaration(node) ||
79805             ts.isParameter(node) ||
79806             ts.isTypeParameterDeclaration(node) ||
79807             ts.isExpressionWithTypeArguments(node) ||
79808             ts.isImportEqualsDeclaration(node) ||
79809             ts.isTypeAliasDeclaration(node) ||
79810             ts.isConstructorDeclaration(node) ||
79811             ts.isIndexSignatureDeclaration(node) ||
79812             ts.isPropertyAccessExpression(node) ||
79813             ts.isJSDocTypeAlias(node);
79814     }
79815     ts.canProduceDiagnostics = canProduceDiagnostics;
79816     function createGetSymbolAccessibilityDiagnosticForNodeName(node) {
79817         if (ts.isSetAccessor(node) || ts.isGetAccessor(node)) {
79818             return getAccessorNameVisibilityError;
79819         }
79820         else if (ts.isMethodSignature(node) || ts.isMethodDeclaration(node)) {
79821             return getMethodNameVisibilityError;
79822         }
79823         else {
79824             return createGetSymbolAccessibilityDiagnosticForNode(node);
79825         }
79826         function getAccessorNameVisibilityError(symbolAccessibilityResult) {
79827             var diagnosticMessage = getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult);
79828             return diagnosticMessage !== undefined ? {
79829                 diagnosticMessage: diagnosticMessage,
79830                 errorNode: node,
79831                 typeName: node.name
79832             } : undefined;
79833         }
79834         function getAccessorNameVisibilityDiagnosticMessage(symbolAccessibilityResult) {
79835             if (ts.hasSyntacticModifier(node, 32)) {
79836                 return symbolAccessibilityResult.errorModuleName ?
79837                     symbolAccessibilityResult.accessibility === 2 ?
79838                         ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
79839                         ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
79840                     ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
79841             }
79842             else if (node.parent.kind === 252) {
79843                 return symbolAccessibilityResult.errorModuleName ?
79844                     symbolAccessibilityResult.accessibility === 2 ?
79845                         ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
79846                         ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
79847                     ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
79848             }
79849             else {
79850                 return symbolAccessibilityResult.errorModuleName ?
79851                     ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
79852                     ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
79853             }
79854         }
79855         function getMethodNameVisibilityError(symbolAccessibilityResult) {
79856             var diagnosticMessage = getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult);
79857             return diagnosticMessage !== undefined ? {
79858                 diagnosticMessage: diagnosticMessage,
79859                 errorNode: node,
79860                 typeName: node.name
79861             } : undefined;
79862         }
79863         function getMethodNameVisibilityDiagnosticMessage(symbolAccessibilityResult) {
79864             if (ts.hasSyntacticModifier(node, 32)) {
79865                 return symbolAccessibilityResult.errorModuleName ?
79866                     symbolAccessibilityResult.accessibility === 2 ?
79867                         ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
79868                         ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
79869                     ts.Diagnostics.Public_static_method_0_of_exported_class_has_or_is_using_private_name_1;
79870             }
79871             else if (node.parent.kind === 252) {
79872                 return symbolAccessibilityResult.errorModuleName ?
79873                     symbolAccessibilityResult.accessibility === 2 ?
79874                         ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
79875                         ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
79876                     ts.Diagnostics.Public_method_0_of_exported_class_has_or_is_using_private_name_1;
79877             }
79878             else {
79879                 return symbolAccessibilityResult.errorModuleName ?
79880                     ts.Diagnostics.Method_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
79881                     ts.Diagnostics.Method_0_of_exported_interface_has_or_is_using_private_name_1;
79882             }
79883         }
79884     }
79885     ts.createGetSymbolAccessibilityDiagnosticForNodeName = createGetSymbolAccessibilityDiagnosticForNodeName;
79886     function createGetSymbolAccessibilityDiagnosticForNode(node) {
79887         if (ts.isVariableDeclaration(node) || ts.isPropertyDeclaration(node) || ts.isPropertySignature(node) || ts.isPropertyAccessExpression(node) || ts.isBindingElement(node) || ts.isConstructorDeclaration(node)) {
79888             return getVariableDeclarationTypeVisibilityError;
79889         }
79890         else if (ts.isSetAccessor(node) || ts.isGetAccessor(node)) {
79891             return getAccessorDeclarationTypeVisibilityError;
79892         }
79893         else if (ts.isConstructSignatureDeclaration(node) || ts.isCallSignatureDeclaration(node) || ts.isMethodDeclaration(node) || ts.isMethodSignature(node) || ts.isFunctionDeclaration(node) || ts.isIndexSignatureDeclaration(node)) {
79894             return getReturnTypeVisibilityError;
79895         }
79896         else if (ts.isParameter(node)) {
79897             if (ts.isParameterPropertyDeclaration(node, node.parent) && ts.hasSyntacticModifier(node.parent, 8)) {
79898                 return getVariableDeclarationTypeVisibilityError;
79899             }
79900             return getParameterDeclarationTypeVisibilityError;
79901         }
79902         else if (ts.isTypeParameterDeclaration(node)) {
79903             return getTypeParameterConstraintVisibilityError;
79904         }
79905         else if (ts.isExpressionWithTypeArguments(node)) {
79906             return getHeritageClauseVisibilityError;
79907         }
79908         else if (ts.isImportEqualsDeclaration(node)) {
79909             return getImportEntityNameVisibilityError;
79910         }
79911         else if (ts.isTypeAliasDeclaration(node) || ts.isJSDocTypeAlias(node)) {
79912             return getTypeAliasDeclarationVisibilityError;
79913         }
79914         else {
79915             return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.SyntaxKind[node.kind]);
79916         }
79917         function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
79918             if (node.kind === 249 || node.kind === 198) {
79919                 return symbolAccessibilityResult.errorModuleName ?
79920                     symbolAccessibilityResult.accessibility === 2 ?
79921                         ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
79922                         ts.Diagnostics.Exported_variable_0_has_or_is_using_name_1_from_private_module_2 :
79923                     ts.Diagnostics.Exported_variable_0_has_or_is_using_private_name_1;
79924             }
79925             else if (node.kind === 163 || node.kind === 201 || node.kind === 162 ||
79926                 (node.kind === 160 && ts.hasSyntacticModifier(node.parent, 8))) {
79927                 if (ts.hasSyntacticModifier(node, 32)) {
79928                     return symbolAccessibilityResult.errorModuleName ?
79929                         symbolAccessibilityResult.accessibility === 2 ?
79930                             ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
79931                             ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
79932                         ts.Diagnostics.Public_static_property_0_of_exported_class_has_or_is_using_private_name_1;
79933                 }
79934                 else if (node.parent.kind === 252 || node.kind === 160) {
79935                     return symbolAccessibilityResult.errorModuleName ?
79936                         symbolAccessibilityResult.accessibility === 2 ?
79937                             ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
79938                             ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_name_1_from_private_module_2 :
79939                         ts.Diagnostics.Public_property_0_of_exported_class_has_or_is_using_private_name_1;
79940                 }
79941                 else {
79942                     return symbolAccessibilityResult.errorModuleName ?
79943                         ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_name_1_from_private_module_2 :
79944                         ts.Diagnostics.Property_0_of_exported_interface_has_or_is_using_private_name_1;
79945                 }
79946             }
79947         }
79948         function getVariableDeclarationTypeVisibilityError(symbolAccessibilityResult) {
79949             var diagnosticMessage = getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult);
79950             return diagnosticMessage !== undefined ? {
79951                 diagnosticMessage: diagnosticMessage,
79952                 errorNode: node,
79953                 typeName: node.name
79954             } : undefined;
79955         }
79956         function getAccessorDeclarationTypeVisibilityError(symbolAccessibilityResult) {
79957             var diagnosticMessage;
79958             if (node.kind === 168) {
79959                 if (ts.hasSyntacticModifier(node, 32)) {
79960                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79961                         ts.Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
79962                         ts.Diagnostics.Parameter_type_of_public_static_setter_0_from_exported_class_has_or_is_using_private_name_1;
79963                 }
79964                 else {
79965                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79966                         ts.Diagnostics.Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
79967                         ts.Diagnostics.Parameter_type_of_public_setter_0_from_exported_class_has_or_is_using_private_name_1;
79968                 }
79969             }
79970             else {
79971                 if (ts.hasSyntacticModifier(node, 32)) {
79972                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79973                         symbolAccessibilityResult.accessibility === 2 ?
79974                             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 :
79975                             ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
79976                         ts.Diagnostics.Return_type_of_public_static_getter_0_from_exported_class_has_or_is_using_private_name_1;
79977                 }
79978                 else {
79979                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79980                         symbolAccessibilityResult.accessibility === 2 ?
79981                             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 :
79982                             ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
79983                         ts.Diagnostics.Return_type_of_public_getter_0_from_exported_class_has_or_is_using_private_name_1;
79984                 }
79985             }
79986             return {
79987                 diagnosticMessage: diagnosticMessage,
79988                 errorNode: node.name,
79989                 typeName: node.name
79990             };
79991         }
79992         function getReturnTypeVisibilityError(symbolAccessibilityResult) {
79993             var diagnosticMessage;
79994             switch (node.kind) {
79995                 case 170:
79996                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
79997                         ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
79998                         ts.Diagnostics.Return_type_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_0;
79999                     break;
80000                 case 169:
80001                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
80002                         ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
80003                         ts.Diagnostics.Return_type_of_call_signature_from_exported_interface_has_or_is_using_private_name_0;
80004                     break;
80005                 case 171:
80006                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
80007                         ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
80008                         ts.Diagnostics.Return_type_of_index_signature_from_exported_interface_has_or_is_using_private_name_0;
80009                     break;
80010                 case 165:
80011                 case 164:
80012                     if (ts.hasSyntacticModifier(node, 32)) {
80013                         diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
80014                             symbolAccessibilityResult.accessibility === 2 ?
80015                                 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 :
80016                                 ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
80017                             ts.Diagnostics.Return_type_of_public_static_method_from_exported_class_has_or_is_using_private_name_0;
80018                     }
80019                     else if (node.parent.kind === 252) {
80020                         diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
80021                             symbolAccessibilityResult.accessibility === 2 ?
80022                                 ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
80023                                 ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_name_0_from_private_module_1 :
80024                             ts.Diagnostics.Return_type_of_public_method_from_exported_class_has_or_is_using_private_name_0;
80025                     }
80026                     else {
80027                         diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
80028                             ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_name_0_from_private_module_1 :
80029                             ts.Diagnostics.Return_type_of_method_from_exported_interface_has_or_is_using_private_name_0;
80030                     }
80031                     break;
80032                 case 251:
80033                     diagnosticMessage = symbolAccessibilityResult.errorModuleName ?
80034                         symbolAccessibilityResult.accessibility === 2 ?
80035                             ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_external_module_1_but_cannot_be_named :
80036                             ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_name_0_from_private_module_1 :
80037                         ts.Diagnostics.Return_type_of_exported_function_has_or_is_using_private_name_0;
80038                     break;
80039                 default:
80040                     return ts.Debug.fail("This is unknown kind for signature: " + node.kind);
80041             }
80042             return {
80043                 diagnosticMessage: diagnosticMessage,
80044                 errorNode: node.name || node
80045             };
80046         }
80047         function getParameterDeclarationTypeVisibilityError(symbolAccessibilityResult) {
80048             var diagnosticMessage = getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult);
80049             return diagnosticMessage !== undefined ? {
80050                 diagnosticMessage: diagnosticMessage,
80051                 errorNode: node,
80052                 typeName: node.name
80053             } : undefined;
80054         }
80055         function getParameterDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
80056             switch (node.parent.kind) {
80057                 case 166:
80058                     return symbolAccessibilityResult.errorModuleName ?
80059                         symbolAccessibilityResult.accessibility === 2 ?
80060                             ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
80061                             ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
80062                         ts.Diagnostics.Parameter_0_of_constructor_from_exported_class_has_or_is_using_private_name_1;
80063                 case 170:
80064                 case 175:
80065                     return symbolAccessibilityResult.errorModuleName ?
80066                         ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
80067                         ts.Diagnostics.Parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
80068                 case 169:
80069                     return symbolAccessibilityResult.errorModuleName ?
80070                         ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
80071                         ts.Diagnostics.Parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
80072                 case 171:
80073                     return symbolAccessibilityResult.errorModuleName ?
80074                         ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
80075                         ts.Diagnostics.Parameter_0_of_index_signature_from_exported_interface_has_or_is_using_private_name_1;
80076                 case 165:
80077                 case 164:
80078                     if (ts.hasSyntacticModifier(node.parent, 32)) {
80079                         return symbolAccessibilityResult.errorModuleName ?
80080                             symbolAccessibilityResult.accessibility === 2 ?
80081                                 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 :
80082                                 ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
80083                             ts.Diagnostics.Parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
80084                     }
80085                     else if (node.parent.parent.kind === 252) {
80086                         return symbolAccessibilityResult.errorModuleName ?
80087                             symbolAccessibilityResult.accessibility === 2 ?
80088                                 ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
80089                                 ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_name_1_from_private_module_2 :
80090                             ts.Diagnostics.Parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
80091                     }
80092                     else {
80093                         return symbolAccessibilityResult.errorModuleName ?
80094                             ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_name_1_from_private_module_2 :
80095                             ts.Diagnostics.Parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
80096                     }
80097                 case 251:
80098                 case 174:
80099                     return symbolAccessibilityResult.errorModuleName ?
80100                         symbolAccessibilityResult.accessibility === 2 ?
80101                             ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
80102                             ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_name_1_from_private_module_2 :
80103                         ts.Diagnostics.Parameter_0_of_exported_function_has_or_is_using_private_name_1;
80104                 case 168:
80105                 case 167:
80106                     return symbolAccessibilityResult.errorModuleName ?
80107                         symbolAccessibilityResult.accessibility === 2 ?
80108                             ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_external_module_2_but_cannot_be_named :
80109                             ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 :
80110                         ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1;
80111                 default:
80112                     return ts.Debug.fail("Unknown parent for parameter: " + ts.SyntaxKind[node.parent.kind]);
80113             }
80114         }
80115         function getTypeParameterConstraintVisibilityError() {
80116             var diagnosticMessage;
80117             switch (node.parent.kind) {
80118                 case 252:
80119                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_class_has_or_is_using_private_name_1;
80120                     break;
80121                 case 253:
80122                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1;
80123                     break;
80124                 case 190:
80125                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_mapped_object_type_is_using_private_name_1;
80126                     break;
80127                 case 175:
80128                 case 170:
80129                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_constructor_signature_from_exported_interface_has_or_is_using_private_name_1;
80130                     break;
80131                 case 169:
80132                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_call_signature_from_exported_interface_has_or_is_using_private_name_1;
80133                     break;
80134                 case 165:
80135                 case 164:
80136                     if (ts.hasSyntacticModifier(node.parent, 32)) {
80137                         diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_static_method_from_exported_class_has_or_is_using_private_name_1;
80138                     }
80139                     else if (node.parent.parent.kind === 252) {
80140                         diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_public_method_from_exported_class_has_or_is_using_private_name_1;
80141                     }
80142                     else {
80143                         diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_method_from_exported_interface_has_or_is_using_private_name_1;
80144                     }
80145                     break;
80146                 case 174:
80147                 case 251:
80148                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_function_has_or_is_using_private_name_1;
80149                     break;
80150                 case 254:
80151                     diagnosticMessage = ts.Diagnostics.Type_parameter_0_of_exported_type_alias_has_or_is_using_private_name_1;
80152                     break;
80153                 default:
80154                     return ts.Debug.fail("This is unknown parent for type parameter: " + node.parent.kind);
80155             }
80156             return {
80157                 diagnosticMessage: diagnosticMessage,
80158                 errorNode: node,
80159                 typeName: node.name
80160             };
80161         }
80162         function getHeritageClauseVisibilityError() {
80163             var diagnosticMessage;
80164             if (ts.isClassDeclaration(node.parent.parent)) {
80165                 diagnosticMessage = ts.isHeritageClause(node.parent) && node.parent.token === 116 ?
80166                     ts.Diagnostics.Implements_clause_of_exported_class_0_has_or_is_using_private_name_1 :
80167                     node.parent.parent.name ? ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1 :
80168                         ts.Diagnostics.extends_clause_of_exported_class_has_or_is_using_private_name_0;
80169             }
80170             else {
80171                 diagnosticMessage = ts.Diagnostics.extends_clause_of_exported_interface_0_has_or_is_using_private_name_1;
80172             }
80173             return {
80174                 diagnosticMessage: diagnosticMessage,
80175                 errorNode: node,
80176                 typeName: ts.getNameOfDeclaration(node.parent.parent)
80177             };
80178         }
80179         function getImportEntityNameVisibilityError() {
80180             return {
80181                 diagnosticMessage: ts.Diagnostics.Import_declaration_0_is_using_private_name_1,
80182                 errorNode: node,
80183                 typeName: node.name
80184             };
80185         }
80186         function getTypeAliasDeclarationVisibilityError(symbolAccessibilityResult) {
80187             return {
80188                 diagnosticMessage: symbolAccessibilityResult.errorModuleName
80189                     ? ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1_from_module_2
80190                     : ts.Diagnostics.Exported_type_alias_0_has_or_is_using_private_name_1,
80191                 errorNode: ts.isJSDocTypeAlias(node) ? ts.Debug.checkDefined(node.typeExpression) : node.type,
80192                 typeName: ts.isJSDocTypeAlias(node) ? ts.getNameOfDeclaration(node) : node.name,
80193             };
80194         }
80195     }
80196     ts.createGetSymbolAccessibilityDiagnosticForNode = createGetSymbolAccessibilityDiagnosticForNode;
80197 })(ts || (ts = {}));
80198 var ts;
80199 (function (ts) {
80200     function getDeclarationDiagnostics(host, resolver, file) {
80201         var compilerOptions = host.getCompilerOptions();
80202         var result = ts.transformNodes(resolver, host, ts.factory, compilerOptions, file ? [file] : ts.filter(host.getSourceFiles(), ts.isSourceFileNotJson), [transformDeclarations], false);
80203         return result.diagnostics;
80204     }
80205     ts.getDeclarationDiagnostics = getDeclarationDiagnostics;
80206     function hasInternalAnnotation(range, currentSourceFile) {
80207         var comment = currentSourceFile.text.substring(range.pos, range.end);
80208         return ts.stringContains(comment, "@internal");
80209     }
80210     function isInternalDeclaration(node, currentSourceFile) {
80211         var parseTreeNode = ts.getParseTreeNode(node);
80212         if (parseTreeNode && parseTreeNode.kind === 160) {
80213             var paramIdx = parseTreeNode.parent.parameters.indexOf(parseTreeNode);
80214             var previousSibling = paramIdx > 0 ? parseTreeNode.parent.parameters[paramIdx - 1] : undefined;
80215             var text = currentSourceFile.text;
80216             var commentRanges = previousSibling
80217                 ? ts.concatenate(ts.getTrailingCommentRanges(text, ts.skipTrivia(text, previousSibling.end + 1, false, true)), ts.getLeadingCommentRanges(text, node.pos))
80218                 : ts.getTrailingCommentRanges(text, ts.skipTrivia(text, node.pos, false, true));
80219             return commentRanges && commentRanges.length && hasInternalAnnotation(ts.last(commentRanges), currentSourceFile);
80220         }
80221         var leadingCommentRanges = parseTreeNode && ts.getLeadingCommentRangesOfNode(parseTreeNode, currentSourceFile);
80222         return !!ts.forEach(leadingCommentRanges, function (range) {
80223             return hasInternalAnnotation(range, currentSourceFile);
80224         });
80225     }
80226     ts.isInternalDeclaration = isInternalDeclaration;
80227     var declarationEmitNodeBuilderFlags = 1024 |
80228         2048 |
80229         4096 |
80230         8 |
80231         524288 |
80232         4 |
80233         1;
80234     function transformDeclarations(context) {
80235         var throwDiagnostic = function () { return ts.Debug.fail("Diagnostic emitted without context"); };
80236         var getSymbolAccessibilityDiagnostic = throwDiagnostic;
80237         var needsDeclare = true;
80238         var isBundledEmit = false;
80239         var resultHasExternalModuleIndicator = false;
80240         var needsScopeFixMarker = false;
80241         var resultHasScopeMarker = false;
80242         var enclosingDeclaration;
80243         var necessaryTypeReferences;
80244         var lateMarkedStatements;
80245         var lateStatementReplacementMap;
80246         var suppressNewDiagnosticContexts;
80247         var exportedModulesFromDeclarationEmit;
80248         var factory = context.factory;
80249         var host = context.getEmitHost();
80250         var symbolTracker = {
80251             trackSymbol: trackSymbol,
80252             reportInaccessibleThisError: reportInaccessibleThisError,
80253             reportInaccessibleUniqueSymbolError: reportInaccessibleUniqueSymbolError,
80254             reportCyclicStructureError: reportCyclicStructureError,
80255             reportPrivateInBaseOfClassExpression: reportPrivateInBaseOfClassExpression,
80256             reportLikelyUnsafeImportRequiredError: reportLikelyUnsafeImportRequiredError,
80257             reportTruncationError: reportTruncationError,
80258             moduleResolverHost: host,
80259             trackReferencedAmbientModule: trackReferencedAmbientModule,
80260             trackExternalModuleSymbolOfImportTypeNode: trackExternalModuleSymbolOfImportTypeNode,
80261             reportNonlocalAugmentation: reportNonlocalAugmentation
80262         };
80263         var errorNameNode;
80264         var errorFallbackNode;
80265         var currentSourceFile;
80266         var refs;
80267         var libs;
80268         var emittedImports;
80269         var resolver = context.getEmitResolver();
80270         var options = context.getCompilerOptions();
80271         var noResolve = options.noResolve, stripInternal = options.stripInternal;
80272         return transformRoot;
80273         function recordTypeReferenceDirectivesIfNecessary(typeReferenceDirectives) {
80274             if (!typeReferenceDirectives) {
80275                 return;
80276             }
80277             necessaryTypeReferences = necessaryTypeReferences || new ts.Set();
80278             for (var _i = 0, typeReferenceDirectives_2 = typeReferenceDirectives; _i < typeReferenceDirectives_2.length; _i++) {
80279                 var ref = typeReferenceDirectives_2[_i];
80280                 necessaryTypeReferences.add(ref);
80281             }
80282         }
80283         function trackReferencedAmbientModule(node, symbol) {
80284             var directives = resolver.getTypeReferenceDirectivesForSymbol(symbol, 67108863);
80285             if (ts.length(directives)) {
80286                 return recordTypeReferenceDirectivesIfNecessary(directives);
80287             }
80288             var container = ts.getSourceFileOfNode(node);
80289             refs.set(ts.getOriginalNodeId(container), container);
80290         }
80291         function handleSymbolAccessibilityError(symbolAccessibilityResult) {
80292             if (symbolAccessibilityResult.accessibility === 0) {
80293                 if (symbolAccessibilityResult && symbolAccessibilityResult.aliasesToMakeVisible) {
80294                     if (!lateMarkedStatements) {
80295                         lateMarkedStatements = symbolAccessibilityResult.aliasesToMakeVisible;
80296                     }
80297                     else {
80298                         for (var _i = 0, _a = symbolAccessibilityResult.aliasesToMakeVisible; _i < _a.length; _i++) {
80299                             var ref = _a[_i];
80300                             ts.pushIfUnique(lateMarkedStatements, ref);
80301                         }
80302                     }
80303                 }
80304             }
80305             else {
80306                 var errorInfo = getSymbolAccessibilityDiagnostic(symbolAccessibilityResult);
80307                 if (errorInfo) {
80308                     if (errorInfo.typeName) {
80309                         context.addDiagnostic(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, ts.getTextOfNode(errorInfo.typeName), symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName));
80310                     }
80311                     else {
80312                         context.addDiagnostic(ts.createDiagnosticForNode(symbolAccessibilityResult.errorNode || errorInfo.errorNode, errorInfo.diagnosticMessage, symbolAccessibilityResult.errorSymbolName, symbolAccessibilityResult.errorModuleName));
80313                     }
80314                 }
80315             }
80316         }
80317         function trackExternalModuleSymbolOfImportTypeNode(symbol) {
80318             if (!isBundledEmit) {
80319                 (exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol);
80320             }
80321         }
80322         function trackSymbol(symbol, enclosingDeclaration, meaning) {
80323             if (symbol.flags & 262144)
80324                 return;
80325             handleSymbolAccessibilityError(resolver.isSymbolAccessible(symbol, enclosingDeclaration, meaning, true));
80326             recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForSymbol(symbol, meaning));
80327         }
80328         function reportPrivateInBaseOfClassExpression(propertyName) {
80329             if (errorNameNode || errorFallbackNode) {
80330                 context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.Property_0_of_exported_class_expression_may_not_be_private_or_protected, propertyName));
80331             }
80332         }
80333         function reportInaccessibleUniqueSymbolError() {
80334             if (errorNameNode) {
80335                 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"));
80336             }
80337         }
80338         function reportCyclicStructureError() {
80339             if (errorNameNode) {
80340                 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)));
80341             }
80342         }
80343         function reportInaccessibleThisError() {
80344             if (errorNameNode) {
80345                 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"));
80346             }
80347         }
80348         function reportLikelyUnsafeImportRequiredError(specifier) {
80349             if (errorNameNode) {
80350                 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));
80351             }
80352         }
80353         function reportTruncationError() {
80354             if (errorNameNode || errorFallbackNode) {
80355                 context.addDiagnostic(ts.createDiagnosticForNode((errorNameNode || errorFallbackNode), ts.Diagnostics.The_inferred_type_of_this_node_exceeds_the_maximum_length_the_compiler_will_serialize_An_explicit_type_annotation_is_needed));
80356             }
80357         }
80358         function reportNonlocalAugmentation(containingFile, parentSymbol, symbol) {
80359             var primaryDeclaration = ts.find(parentSymbol.declarations, function (d) { return ts.getSourceFileOfNode(d) === containingFile; });
80360             var augmentingDeclarations = ts.filter(symbol.declarations, function (d) { return ts.getSourceFileOfNode(d) !== containingFile; });
80361             for (var _i = 0, augmentingDeclarations_1 = augmentingDeclarations; _i < augmentingDeclarations_1.length; _i++) {
80362                 var augmentations = augmentingDeclarations_1[_i];
80363                 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)));
80364             }
80365         }
80366         function transformDeclarationsForJS(sourceFile, bundled) {
80367             var oldDiag = getSymbolAccessibilityDiagnostic;
80368             getSymbolAccessibilityDiagnostic = function (s) { return (s.errorNode && ts.canProduceDiagnostics(s.errorNode) ? ts.createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : ({
80369                 diagnosticMessage: s.errorModuleName
80370                     ? ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit
80371                     : ts.Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit,
80372                 errorNode: s.errorNode || sourceFile
80373             })); };
80374             var result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker, bundled);
80375             getSymbolAccessibilityDiagnostic = oldDiag;
80376             return result;
80377         }
80378         function transformRoot(node) {
80379             if (node.kind === 297 && node.isDeclarationFile) {
80380                 return node;
80381             }
80382             if (node.kind === 298) {
80383                 isBundledEmit = true;
80384                 refs = new ts.Map();
80385                 libs = new ts.Map();
80386                 var hasNoDefaultLib_1 = false;
80387                 var bundle = factory.createBundle(ts.map(node.sourceFiles, function (sourceFile) {
80388                     if (sourceFile.isDeclarationFile)
80389                         return undefined;
80390                     hasNoDefaultLib_1 = hasNoDefaultLib_1 || sourceFile.hasNoDefaultLib;
80391                     currentSourceFile = sourceFile;
80392                     enclosingDeclaration = sourceFile;
80393                     lateMarkedStatements = undefined;
80394                     suppressNewDiagnosticContexts = false;
80395                     lateStatementReplacementMap = new ts.Map();
80396                     getSymbolAccessibilityDiagnostic = throwDiagnostic;
80397                     needsScopeFixMarker = false;
80398                     resultHasScopeMarker = false;
80399                     collectReferences(sourceFile, refs);
80400                     collectLibs(sourceFile, libs);
80401                     if (ts.isExternalOrCommonJsModule(sourceFile) || ts.isJsonSourceFile(sourceFile)) {
80402                         resultHasExternalModuleIndicator = false;
80403                         needsDeclare = false;
80404                         var statements = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile, true)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements);
80405                         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, []);
80406                         return newFile;
80407                     }
80408                     needsDeclare = true;
80409                     var updated = ts.isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile)) : ts.visitNodes(sourceFile.statements, visitDeclarationStatements);
80410                     return factory.updateSourceFile(sourceFile, transformAndReplaceLatePaintedStatements(updated), true, [], [], false, []);
80411                 }), ts.mapDefined(node.prepends, function (prepend) {
80412                     if (prepend.kind === 300) {
80413                         var sourceFile = ts.createUnparsedSourceFile(prepend, "dts", stripInternal);
80414                         hasNoDefaultLib_1 = hasNoDefaultLib_1 || !!sourceFile.hasNoDefaultLib;
80415                         collectReferences(sourceFile, refs);
80416                         recordTypeReferenceDirectivesIfNecessary(sourceFile.typeReferenceDirectives);
80417                         collectLibs(sourceFile, libs);
80418                         return sourceFile;
80419                     }
80420                     return prepend;
80421                 }));
80422                 bundle.syntheticFileReferences = [];
80423                 bundle.syntheticTypeReferences = getFileReferencesForUsedTypeReferences();
80424                 bundle.syntheticLibReferences = getLibReferences();
80425                 bundle.hasNoDefaultLib = hasNoDefaultLib_1;
80426                 var outputFilePath_1 = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, true).declarationFilePath));
80427                 var referenceVisitor_1 = mapReferencesIntoArray(bundle.syntheticFileReferences, outputFilePath_1);
80428                 refs.forEach(referenceVisitor_1);
80429                 return bundle;
80430             }
80431             needsDeclare = true;
80432             needsScopeFixMarker = false;
80433             resultHasScopeMarker = false;
80434             enclosingDeclaration = node;
80435             currentSourceFile = node;
80436             getSymbolAccessibilityDiagnostic = throwDiagnostic;
80437             isBundledEmit = false;
80438             resultHasExternalModuleIndicator = false;
80439             suppressNewDiagnosticContexts = false;
80440             lateMarkedStatements = undefined;
80441             lateStatementReplacementMap = new ts.Map();
80442             necessaryTypeReferences = undefined;
80443             refs = collectReferences(currentSourceFile, new ts.Map());
80444             libs = collectLibs(currentSourceFile, new ts.Map());
80445             var references = [];
80446             var outputFilePath = ts.getDirectoryPath(ts.normalizeSlashes(ts.getOutputPathsFor(node, host, true).declarationFilePath));
80447             var referenceVisitor = mapReferencesIntoArray(references, outputFilePath);
80448             var combinedStatements;
80449             if (ts.isSourceFileJS(currentSourceFile)) {
80450                 combinedStatements = factory.createNodeArray(transformDeclarationsForJS(node));
80451                 refs.forEach(referenceVisitor);
80452                 emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax);
80453             }
80454             else {
80455                 var statements = ts.visitNodes(node.statements, visitDeclarationStatements);
80456                 combinedStatements = ts.setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), node.statements);
80457                 refs.forEach(referenceVisitor);
80458                 emittedImports = ts.filter(combinedStatements, ts.isAnyImportSyntax);
80459                 if (ts.isExternalModule(node) && (!resultHasExternalModuleIndicator || (needsScopeFixMarker && !resultHasScopeMarker))) {
80460                     combinedStatements = ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray([], combinedStatements), [ts.createEmptyExports(factory)])), combinedStatements);
80461                 }
80462             }
80463             var updated = factory.updateSourceFile(node, combinedStatements, true, references, getFileReferencesForUsedTypeReferences(), node.hasNoDefaultLib, getLibReferences());
80464             updated.exportedModulesFromDeclarationEmit = exportedModulesFromDeclarationEmit;
80465             return updated;
80466             function getLibReferences() {
80467                 return ts.map(ts.arrayFrom(libs.keys()), function (lib) { return ({ fileName: lib, pos: -1, end: -1 }); });
80468             }
80469             function getFileReferencesForUsedTypeReferences() {
80470                 return necessaryTypeReferences ? ts.mapDefined(ts.arrayFrom(necessaryTypeReferences.keys()), getFileReferenceForTypeName) : [];
80471             }
80472             function getFileReferenceForTypeName(typeName) {
80473                 if (emittedImports) {
80474                     for (var _i = 0, emittedImports_1 = emittedImports; _i < emittedImports_1.length; _i++) {
80475                         var importStatement = emittedImports_1[_i];
80476                         if (ts.isImportEqualsDeclaration(importStatement) && ts.isExternalModuleReference(importStatement.moduleReference)) {
80477                             var expr = importStatement.moduleReference.expression;
80478                             if (ts.isStringLiteralLike(expr) && expr.text === typeName) {
80479                                 return undefined;
80480                             }
80481                         }
80482                         else if (ts.isImportDeclaration(importStatement) && ts.isStringLiteral(importStatement.moduleSpecifier) && importStatement.moduleSpecifier.text === typeName) {
80483                             return undefined;
80484                         }
80485                     }
80486                 }
80487                 return { fileName: typeName, pos: -1, end: -1 };
80488             }
80489             function mapReferencesIntoArray(references, outputFilePath) {
80490                 return function (file) {
80491                     var declFileName;
80492                     if (file.isDeclarationFile) {
80493                         declFileName = file.fileName;
80494                     }
80495                     else {
80496                         if (isBundledEmit && ts.contains(node.sourceFiles, file))
80497                             return;
80498                         var paths = ts.getOutputPathsFor(file, host, true);
80499                         declFileName = paths.declarationFilePath || paths.jsFilePath || file.fileName;
80500                     }
80501                     if (declFileName) {
80502                         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);
80503                         if (!ts.pathIsRelative(specifier)) {
80504                             recordTypeReferenceDirectivesIfNecessary([specifier]);
80505                             return;
80506                         }
80507                         var fileName = ts.getRelativePathToDirectoryOrUrl(outputFilePath, declFileName, host.getCurrentDirectory(), host.getCanonicalFileName, false);
80508                         if (ts.startsWith(fileName, "./") && ts.hasExtension(fileName)) {
80509                             fileName = fileName.substring(2);
80510                         }
80511                         if (ts.startsWith(fileName, "node_modules/") || ts.pathContainsNodeModules(fileName)) {
80512                             return;
80513                         }
80514                         references.push({ pos: -1, end: -1, fileName: fileName });
80515                     }
80516                 };
80517             }
80518         }
80519         function collectReferences(sourceFile, ret) {
80520             if (noResolve || (!ts.isUnparsedSource(sourceFile) && ts.isSourceFileJS(sourceFile)))
80521                 return ret;
80522             ts.forEach(sourceFile.referencedFiles, function (f) {
80523                 var elem = host.getSourceFileFromReference(sourceFile, f);
80524                 if (elem) {
80525                     ret.set(ts.getOriginalNodeId(elem), elem);
80526                 }
80527             });
80528             return ret;
80529         }
80530         function collectLibs(sourceFile, ret) {
80531             ts.forEach(sourceFile.libReferenceDirectives, function (ref) {
80532                 var lib = host.getLibFileFromReference(ref);
80533                 if (lib) {
80534                     ret.set(ts.toFileNameLowerCase(ref.fileName), true);
80535                 }
80536             });
80537             return ret;
80538         }
80539         function filterBindingPatternInitializers(name) {
80540             if (name.kind === 78) {
80541                 return name;
80542             }
80543             else {
80544                 if (name.kind === 197) {
80545                     return factory.updateArrayBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement));
80546                 }
80547                 else {
80548                     return factory.updateObjectBindingPattern(name, ts.visitNodes(name.elements, visitBindingElement));
80549                 }
80550             }
80551             function visitBindingElement(elem) {
80552                 if (elem.kind === 222) {
80553                     return elem;
80554                 }
80555                 return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
80556             }
80557         }
80558         function ensureParameter(p, modifierMask, type) {
80559             var oldDiag;
80560             if (!suppressNewDiagnosticContexts) {
80561                 oldDiag = getSymbolAccessibilityDiagnostic;
80562                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p);
80563             }
80564             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));
80565             if (!suppressNewDiagnosticContexts) {
80566                 getSymbolAccessibilityDiagnostic = oldDiag;
80567             }
80568             return newParam;
80569         }
80570         function shouldPrintWithInitializer(node) {
80571             return canHaveLiteralInitializer(node) && resolver.isLiteralConstDeclaration(ts.getParseTreeNode(node));
80572         }
80573         function ensureNoInitializer(node) {
80574             if (shouldPrintWithInitializer(node)) {
80575                 return resolver.createLiteralConstValue(ts.getParseTreeNode(node), symbolTracker);
80576             }
80577             return undefined;
80578         }
80579         function ensureType(node, type, ignorePrivate) {
80580             if (!ignorePrivate && ts.hasEffectiveModifier(node, 8)) {
80581                 return;
80582             }
80583             if (shouldPrintWithInitializer(node)) {
80584                 return;
80585             }
80586             var shouldUseResolverType = node.kind === 160 &&
80587                 (resolver.isRequiredInitializedParameter(node) ||
80588                     resolver.isOptionalUninitializedParameterProperty(node));
80589             if (type && !shouldUseResolverType) {
80590                 return ts.visitNode(type, visitDeclarationSubtree);
80591             }
80592             if (!ts.getParseTreeNode(node)) {
80593                 return type ? ts.visitNode(type, visitDeclarationSubtree) : factory.createKeywordTypeNode(128);
80594             }
80595             if (node.kind === 168) {
80596                 return factory.createKeywordTypeNode(128);
80597             }
80598             errorNameNode = node.name;
80599             var oldDiag;
80600             if (!suppressNewDiagnosticContexts) {
80601                 oldDiag = getSymbolAccessibilityDiagnostic;
80602                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(node);
80603             }
80604             if (node.kind === 249 || node.kind === 198) {
80605                 return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
80606             }
80607             if (node.kind === 160
80608                 || node.kind === 163
80609                 || node.kind === 162) {
80610                 if (!node.initializer)
80611                     return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType));
80612                 return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
80613             }
80614             return cleanup(resolver.createReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker));
80615             function cleanup(returnValue) {
80616                 errorNameNode = undefined;
80617                 if (!suppressNewDiagnosticContexts) {
80618                     getSymbolAccessibilityDiagnostic = oldDiag;
80619                 }
80620                 return returnValue || factory.createKeywordTypeNode(128);
80621             }
80622         }
80623         function isDeclarationAndNotVisible(node) {
80624             node = ts.getParseTreeNode(node);
80625             switch (node.kind) {
80626                 case 251:
80627                 case 256:
80628                 case 253:
80629                 case 252:
80630                 case 254:
80631                 case 255:
80632                     return !resolver.isDeclarationVisible(node);
80633                 case 249:
80634                     return !getBindingNameVisible(node);
80635                 case 260:
80636                 case 261:
80637                 case 267:
80638                 case 266:
80639                     return false;
80640             }
80641             return false;
80642         }
80643         function getBindingNameVisible(elem) {
80644             if (ts.isOmittedExpression(elem)) {
80645                 return false;
80646             }
80647             if (ts.isBindingPattern(elem.name)) {
80648                 return ts.some(elem.name.elements, getBindingNameVisible);
80649             }
80650             else {
80651                 return resolver.isDeclarationVisible(elem);
80652             }
80653         }
80654         function updateParamsList(node, params, modifierMask) {
80655             if (ts.hasEffectiveModifier(node, 8)) {
80656                 return undefined;
80657             }
80658             var newParams = ts.map(params, function (p) { return ensureParameter(p, modifierMask); });
80659             if (!newParams) {
80660                 return undefined;
80661             }
80662             return factory.createNodeArray(newParams, params.hasTrailingComma);
80663         }
80664         function updateAccessorParamsList(input, isPrivate) {
80665             var newParams;
80666             if (!isPrivate) {
80667                 var thisParameter = ts.getThisParameter(input);
80668                 if (thisParameter) {
80669                     newParams = [ensureParameter(thisParameter)];
80670                 }
80671             }
80672             if (ts.isSetAccessorDeclaration(input)) {
80673                 var newValueParameter = void 0;
80674                 if (!isPrivate) {
80675                     var valueParameter = ts.getSetAccessorValueParameter(input);
80676                     if (valueParameter) {
80677                         var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input));
80678                         newValueParameter = ensureParameter(valueParameter, undefined, accessorType);
80679                     }
80680                 }
80681                 if (!newValueParameter) {
80682                     newValueParameter = factory.createParameterDeclaration(undefined, undefined, undefined, "value");
80683                 }
80684                 newParams = ts.append(newParams, newValueParameter);
80685             }
80686             return factory.createNodeArray(newParams || ts.emptyArray);
80687         }
80688         function ensureTypeParams(node, params) {
80689             return ts.hasEffectiveModifier(node, 8) ? undefined : ts.visitNodes(params, visitDeclarationSubtree);
80690         }
80691         function isEnclosingDeclaration(node) {
80692             return ts.isSourceFile(node)
80693                 || ts.isTypeAliasDeclaration(node)
80694                 || ts.isModuleDeclaration(node)
80695                 || ts.isClassDeclaration(node)
80696                 || ts.isInterfaceDeclaration(node)
80697                 || ts.isFunctionLike(node)
80698                 || ts.isIndexSignatureDeclaration(node)
80699                 || ts.isMappedTypeNode(node);
80700         }
80701         function checkEntityNameVisibility(entityName, enclosingDeclaration) {
80702             var visibilityResult = resolver.isEntityNameVisible(entityName, enclosingDeclaration);
80703             handleSymbolAccessibilityError(visibilityResult);
80704             recordTypeReferenceDirectivesIfNecessary(resolver.getTypeReferenceDirectivesForEntityName(entityName));
80705         }
80706         function preserveJsDoc(updated, original) {
80707             if (ts.hasJSDocNodes(updated) && ts.hasJSDocNodes(original)) {
80708                 updated.jsDoc = original.jsDoc;
80709             }
80710             return ts.setCommentRange(updated, ts.getCommentRange(original));
80711         }
80712         function rewriteModuleSpecifier(parent, input) {
80713             if (!input)
80714                 return undefined;
80715             resultHasExternalModuleIndicator = resultHasExternalModuleIndicator || (parent.kind !== 256 && parent.kind !== 195);
80716             if (ts.isStringLiteralLike(input)) {
80717                 if (isBundledEmit) {
80718                     var newName = ts.getExternalModuleNameFromDeclaration(context.getEmitHost(), resolver, parent);
80719                     if (newName) {
80720                         return factory.createStringLiteral(newName);
80721                     }
80722                 }
80723                 else {
80724                     var symbol = resolver.getSymbolOfExternalModuleSpecifier(input);
80725                     if (symbol) {
80726                         (exportedModulesFromDeclarationEmit || (exportedModulesFromDeclarationEmit = [])).push(symbol);
80727                     }
80728                 }
80729             }
80730             return input;
80731         }
80732         function transformImportEqualsDeclaration(decl) {
80733             if (!resolver.isDeclarationVisible(decl))
80734                 return;
80735             if (decl.moduleReference.kind === 272) {
80736                 var specifier = ts.getExternalModuleImportEqualsDeclarationExpression(decl);
80737                 return factory.updateImportEqualsDeclaration(decl, undefined, decl.modifiers, decl.isTypeOnly, decl.name, factory.updateExternalModuleReference(decl.moduleReference, rewriteModuleSpecifier(decl, specifier)));
80738             }
80739             else {
80740                 var oldDiag = getSymbolAccessibilityDiagnostic;
80741                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(decl);
80742                 checkEntityNameVisibility(decl.moduleReference, enclosingDeclaration);
80743                 getSymbolAccessibilityDiagnostic = oldDiag;
80744                 return decl;
80745             }
80746         }
80747         function transformImportDeclaration(decl) {
80748             if (!decl.importClause) {
80749                 return factory.updateImportDeclaration(decl, undefined, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier));
80750             }
80751             var visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined;
80752             if (!decl.importClause.namedBindings) {
80753                 return visibleDefaultBinding && factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, undefined), rewriteModuleSpecifier(decl, decl.moduleSpecifier));
80754             }
80755             if (decl.importClause.namedBindings.kind === 263) {
80756                 var namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : undefined;
80757                 return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, undefined, decl.modifiers, factory.updateImportClause(decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, namedBindings), rewriteModuleSpecifier(decl, decl.moduleSpecifier)) : undefined;
80758             }
80759             var bindingList = ts.mapDefined(decl.importClause.namedBindings.elements, function (b) { return resolver.isDeclarationVisible(b) ? b : undefined; });
80760             if ((bindingList && bindingList.length) || visibleDefaultBinding) {
80761                 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));
80762             }
80763             if (resolver.isImportRequiredByAugmentation(decl)) {
80764                 return factory.updateImportDeclaration(decl, undefined, decl.modifiers, undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier));
80765             }
80766         }
80767         function transformAndReplaceLatePaintedStatements(statements) {
80768             while (ts.length(lateMarkedStatements)) {
80769                 var i = lateMarkedStatements.shift();
80770                 if (!ts.isLateVisibilityPaintedStatement(i)) {
80771                     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));
80772                 }
80773                 var priorNeedsDeclare = needsDeclare;
80774                 needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit);
80775                 var result = transformTopLevelDeclaration(i);
80776                 needsDeclare = priorNeedsDeclare;
80777                 lateStatementReplacementMap.set(ts.getOriginalNodeId(i), result);
80778             }
80779             return ts.visitNodes(statements, visitLateVisibilityMarkedStatements);
80780             function visitLateVisibilityMarkedStatements(statement) {
80781                 if (ts.isLateVisibilityPaintedStatement(statement)) {
80782                     var key = ts.getOriginalNodeId(statement);
80783                     if (lateStatementReplacementMap.has(key)) {
80784                         var result = lateStatementReplacementMap.get(key);
80785                         lateStatementReplacementMap.delete(key);
80786                         if (result) {
80787                             if (ts.isArray(result) ? ts.some(result, ts.needsScopeMarker) : ts.needsScopeMarker(result)) {
80788                                 needsScopeFixMarker = true;
80789                             }
80790                             if (ts.isSourceFile(statement.parent) && (ts.isArray(result) ? ts.some(result, ts.isExternalModuleIndicator) : ts.isExternalModuleIndicator(result))) {
80791                                 resultHasExternalModuleIndicator = true;
80792                             }
80793                         }
80794                         return result;
80795                     }
80796                 }
80797                 return statement;
80798             }
80799         }
80800         function visitDeclarationSubtree(input) {
80801             if (shouldStripInternal(input))
80802                 return;
80803             if (ts.isDeclaration(input)) {
80804                 if (isDeclarationAndNotVisible(input))
80805                     return;
80806                 if (ts.hasDynamicName(input) && !resolver.isLateBound(ts.getParseTreeNode(input))) {
80807                     return;
80808                 }
80809             }
80810             if (ts.isFunctionLike(input) && resolver.isImplementationOfOverload(input))
80811                 return;
80812             if (ts.isSemicolonClassElement(input))
80813                 return;
80814             var previousEnclosingDeclaration;
80815             if (isEnclosingDeclaration(input)) {
80816                 previousEnclosingDeclaration = enclosingDeclaration;
80817                 enclosingDeclaration = input;
80818             }
80819             var oldDiag = getSymbolAccessibilityDiagnostic;
80820             var canProduceDiagnostic = ts.canProduceDiagnostics(input);
80821             var oldWithinObjectLiteralType = suppressNewDiagnosticContexts;
80822             var shouldEnterSuppressNewDiagnosticsContextContext = ((input.kind === 177 || input.kind === 190) && input.parent.kind !== 254);
80823             if (ts.isMethodDeclaration(input) || ts.isMethodSignature(input)) {
80824                 if (ts.hasEffectiveModifier(input, 8)) {
80825                     if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input)
80826                         return;
80827                     return cleanup(factory.createPropertyDeclaration(undefined, ensureModifiers(input), input.name, undefined, undefined, undefined));
80828                 }
80829             }
80830             if (canProduceDiagnostic && !suppressNewDiagnosticContexts) {
80831                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input);
80832             }
80833             if (ts.isTypeQueryNode(input)) {
80834                 checkEntityNameVisibility(input.exprName, enclosingDeclaration);
80835             }
80836             if (shouldEnterSuppressNewDiagnosticsContextContext) {
80837                 suppressNewDiagnosticContexts = true;
80838             }
80839             if (isProcessedComponent(input)) {
80840                 switch (input.kind) {
80841                     case 223: {
80842                         if ((ts.isEntityName(input.expression) || ts.isEntityNameExpression(input.expression))) {
80843                             checkEntityNameVisibility(input.expression, enclosingDeclaration);
80844                         }
80845                         var node = ts.visitEachChild(input, visitDeclarationSubtree, context);
80846                         return cleanup(factory.updateExpressionWithTypeArguments(node, node.expression, node.typeArguments));
80847                     }
80848                     case 173: {
80849                         checkEntityNameVisibility(input.typeName, enclosingDeclaration);
80850                         var node = ts.visitEachChild(input, visitDeclarationSubtree, context);
80851                         return cleanup(factory.updateTypeReferenceNode(node, node.typeName, node.typeArguments));
80852                     }
80853                     case 170:
80854                         return cleanup(factory.updateConstructSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)));
80855                     case 166: {
80856                         var ctor = factory.createConstructorDeclaration(undefined, ensureModifiers(input), updateParamsList(input, input.parameters, 0), undefined);
80857                         return cleanup(ctor);
80858                     }
80859                     case 165: {
80860                         if (ts.isPrivateIdentifier(input.name)) {
80861                             return cleanup(undefined);
80862                         }
80863                         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);
80864                         return cleanup(sig);
80865                     }
80866                     case 167: {
80867                         if (ts.isPrivateIdentifier(input.name)) {
80868                             return cleanup(undefined);
80869                         }
80870                         var accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input));
80871                         return cleanup(factory.updateGetAccessorDeclaration(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8)), ensureType(input, accessorType), undefined));
80872                     }
80873                     case 168: {
80874                         if (ts.isPrivateIdentifier(input.name)) {
80875                             return cleanup(undefined);
80876                         }
80877                         return cleanup(factory.updateSetAccessorDeclaration(input, undefined, ensureModifiers(input), input.name, updateAccessorParamsList(input, ts.hasEffectiveModifier(input, 8)), undefined));
80878                     }
80879                     case 163:
80880                         if (ts.isPrivateIdentifier(input.name)) {
80881                             return cleanup(undefined);
80882                         }
80883                         return cleanup(factory.updatePropertyDeclaration(input, undefined, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type), ensureNoInitializer(input)));
80884                     case 162:
80885                         if (ts.isPrivateIdentifier(input.name)) {
80886                             return cleanup(undefined);
80887                         }
80888                         return cleanup(factory.updatePropertySignature(input, ensureModifiers(input), input.name, input.questionToken, ensureType(input, input.type)));
80889                     case 164: {
80890                         if (ts.isPrivateIdentifier(input.name)) {
80891                             return cleanup(undefined);
80892                         }
80893                         return cleanup(factory.updateMethodSignature(input, ensureModifiers(input), input.name, input.questionToken, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)));
80894                     }
80895                     case 169: {
80896                         return cleanup(factory.updateCallSignature(input, ensureTypeParams(input, input.typeParameters), updateParamsList(input, input.parameters), ensureType(input, input.type)));
80897                     }
80898                     case 171: {
80899                         return cleanup(factory.updateIndexSignature(input, undefined, ensureModifiers(input), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(128)));
80900                     }
80901                     case 249: {
80902                         if (ts.isBindingPattern(input.name)) {
80903                             return recreateBindingPattern(input.name);
80904                         }
80905                         shouldEnterSuppressNewDiagnosticsContextContext = true;
80906                         suppressNewDiagnosticContexts = true;
80907                         return cleanup(factory.updateVariableDeclaration(input, input.name, undefined, ensureType(input, input.type), ensureNoInitializer(input)));
80908                     }
80909                     case 159: {
80910                         if (isPrivateMethodTypeParameter(input) && (input.default || input.constraint)) {
80911                             return cleanup(factory.updateTypeParameterDeclaration(input, input.name, undefined, undefined));
80912                         }
80913                         return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context));
80914                     }
80915                     case 184: {
80916                         var checkType = ts.visitNode(input.checkType, visitDeclarationSubtree);
80917                         var extendsType = ts.visitNode(input.extendsType, visitDeclarationSubtree);
80918                         var oldEnclosingDecl = enclosingDeclaration;
80919                         enclosingDeclaration = input.trueType;
80920                         var trueType = ts.visitNode(input.trueType, visitDeclarationSubtree);
80921                         enclosingDeclaration = oldEnclosingDecl;
80922                         var falseType = ts.visitNode(input.falseType, visitDeclarationSubtree);
80923                         return cleanup(factory.updateConditionalTypeNode(input, checkType, extendsType, trueType, falseType));
80924                     }
80925                     case 174: {
80926                         return cleanup(factory.updateFunctionTypeNode(input, ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree)));
80927                     }
80928                     case 175: {
80929                         return cleanup(factory.updateConstructorTypeNode(input, ensureModifiers(input), ts.visitNodes(input.typeParameters, visitDeclarationSubtree), updateParamsList(input, input.parameters), ts.visitNode(input.type, visitDeclarationSubtree)));
80930                     }
80931                     case 195: {
80932                         if (!ts.isLiteralImportTypeNode(input))
80933                             return cleanup(input);
80934                         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));
80935                     }
80936                     default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.SyntaxKind[input.kind]);
80937                 }
80938             }
80939             if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) {
80940                 ts.setEmitFlags(input, 1);
80941             }
80942             return cleanup(ts.visitEachChild(input, visitDeclarationSubtree, context));
80943             function cleanup(returnValue) {
80944                 if (returnValue && canProduceDiagnostic && ts.hasDynamicName(input)) {
80945                     checkName(input);
80946                 }
80947                 if (isEnclosingDeclaration(input)) {
80948                     enclosingDeclaration = previousEnclosingDeclaration;
80949                 }
80950                 if (canProduceDiagnostic && !suppressNewDiagnosticContexts) {
80951                     getSymbolAccessibilityDiagnostic = oldDiag;
80952                 }
80953                 if (shouldEnterSuppressNewDiagnosticsContextContext) {
80954                     suppressNewDiagnosticContexts = oldWithinObjectLiteralType;
80955                 }
80956                 if (returnValue === input) {
80957                     return returnValue;
80958                 }
80959                 return returnValue && ts.setOriginalNode(preserveJsDoc(returnValue, input), input);
80960             }
80961         }
80962         function isPrivateMethodTypeParameter(node) {
80963             return node.parent.kind === 165 && ts.hasEffectiveModifier(node.parent, 8);
80964         }
80965         function visitDeclarationStatements(input) {
80966             if (!isPreservedDeclarationStatement(input)) {
80967                 return;
80968             }
80969             if (shouldStripInternal(input))
80970                 return;
80971             switch (input.kind) {
80972                 case 267: {
80973                     if (ts.isSourceFile(input.parent)) {
80974                         resultHasExternalModuleIndicator = true;
80975                     }
80976                     resultHasScopeMarker = true;
80977                     return factory.updateExportDeclaration(input, undefined, input.modifiers, input.isTypeOnly, input.exportClause, rewriteModuleSpecifier(input, input.moduleSpecifier));
80978                 }
80979                 case 266: {
80980                     if (ts.isSourceFile(input.parent)) {
80981                         resultHasExternalModuleIndicator = true;
80982                     }
80983                     resultHasScopeMarker = true;
80984                     if (input.expression.kind === 78) {
80985                         return input;
80986                     }
80987                     else {
80988                         var newId = factory.createUniqueName("_default", 16);
80989                         getSymbolAccessibilityDiagnostic = function () { return ({
80990                             diagnosticMessage: ts.Diagnostics.Default_export_of_the_module_has_or_is_using_private_name_0,
80991                             errorNode: input
80992                         }); };
80993                         errorFallbackNode = input;
80994                         var varDecl = factory.createVariableDeclaration(newId, undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined);
80995                         errorFallbackNode = undefined;
80996                         var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(133)] : [], factory.createVariableDeclarationList([varDecl], 2));
80997                         return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)];
80998                     }
80999                 }
81000             }
81001             var result = transformTopLevelDeclaration(input);
81002             lateStatementReplacementMap.set(ts.getOriginalNodeId(input), result);
81003             return input;
81004         }
81005         function stripExportModifiers(statement) {
81006             if (ts.isImportEqualsDeclaration(statement) || ts.hasEffectiveModifier(statement, 512) || !ts.canHaveModifiers(statement)) {
81007                 return statement;
81008             }
81009             var modifiers = factory.createModifiersFromModifierFlags(ts.getEffectiveModifierFlags(statement) & (11263 ^ 1));
81010             return factory.updateModifiers(statement, modifiers);
81011         }
81012         function transformTopLevelDeclaration(input) {
81013             if (shouldStripInternal(input))
81014                 return;
81015             switch (input.kind) {
81016                 case 260: {
81017                     return transformImportEqualsDeclaration(input);
81018                 }
81019                 case 261: {
81020                     return transformImportDeclaration(input);
81021                 }
81022             }
81023             if (ts.isDeclaration(input) && isDeclarationAndNotVisible(input))
81024                 return;
81025             if (ts.isFunctionLike(input) && resolver.isImplementationOfOverload(input))
81026                 return;
81027             var previousEnclosingDeclaration;
81028             if (isEnclosingDeclaration(input)) {
81029                 previousEnclosingDeclaration = enclosingDeclaration;
81030                 enclosingDeclaration = input;
81031             }
81032             var canProdiceDiagnostic = ts.canProduceDiagnostics(input);
81033             var oldDiag = getSymbolAccessibilityDiagnostic;
81034             if (canProdiceDiagnostic) {
81035                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(input);
81036             }
81037             var previousNeedsDeclare = needsDeclare;
81038             switch (input.kind) {
81039                 case 254:
81040                     return cleanup(factory.updateTypeAliasDeclaration(input, undefined, ensureModifiers(input), input.name, ts.visitNodes(input.typeParameters, visitDeclarationSubtree, ts.isTypeParameterDeclaration), ts.visitNode(input.type, visitDeclarationSubtree, ts.isTypeNode)));
81041                 case 253: {
81042                     return cleanup(factory.updateInterfaceDeclaration(input, undefined, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), transformHeritageClauses(input.heritageClauses), ts.visitNodes(input.members, visitDeclarationSubtree)));
81043                 }
81044                 case 251: {
81045                     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));
81046                     if (clean && resolver.isExpandoFunctionDeclaration(input)) {
81047                         var props = resolver.getPropertiesOfContainerFunction(input);
81048                         var fakespace_1 = ts.parseNodeFactory.createModuleDeclaration(undefined, undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), 16);
81049                         ts.setParent(fakespace_1, enclosingDeclaration);
81050                         fakespace_1.locals = ts.createSymbolTable(props);
81051                         fakespace_1.symbol = props[0].parent;
81052                         var exportMappings_1 = [];
81053                         var declarations = ts.mapDefined(props, function (p) {
81054                             if (!ts.isPropertyAccessExpression(p.valueDeclaration)) {
81055                                 return undefined;
81056                             }
81057                             getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p.valueDeclaration);
81058                             var type = resolver.createTypeOfDeclaration(p.valueDeclaration, fakespace_1, declarationEmitNodeBuilderFlags, symbolTracker);
81059                             getSymbolAccessibilityDiagnostic = oldDiag;
81060                             var nameStr = ts.unescapeLeadingUnderscores(p.escapedName);
81061                             var isNonContextualKeywordName = ts.isStringANonContextualKeyword(nameStr);
81062                             var name = isNonContextualKeywordName ? factory.getGeneratedNameForNode(p.valueDeclaration) : factory.createIdentifier(nameStr);
81063                             if (isNonContextualKeywordName) {
81064                                 exportMappings_1.push([name, nameStr]);
81065                             }
81066                             var varDecl = factory.createVariableDeclaration(name, undefined, type, undefined);
81067                             return factory.createVariableStatement(isNonContextualKeywordName ? undefined : [factory.createToken(92)], factory.createVariableDeclarationList([varDecl]));
81068                         });
81069                         if (!exportMappings_1.length) {
81070                             declarations = ts.mapDefined(declarations, function (declaration) { return factory.updateModifiers(declaration, 0); });
81071                         }
81072                         else {
81073                             declarations.push(factory.createExportDeclaration(undefined, undefined, false, factory.createNamedExports(ts.map(exportMappings_1, function (_a) {
81074                                 var gen = _a[0], exp = _a[1];
81075                                 return factory.createExportSpecifier(gen, exp);
81076                             }))));
81077                         }
81078                         var namespaceDecl = factory.createModuleDeclaration(undefined, ensureModifiers(input), input.name, factory.createModuleBlock(declarations), 16);
81079                         if (!ts.hasEffectiveModifier(clean, 512)) {
81080                             return [clean, namespaceDecl];
81081                         }
81082                         var modifiers = factory.createModifiersFromModifierFlags((ts.getEffectiveModifierFlags(clean) & ~513) | 2);
81083                         var cleanDeclaration = factory.updateFunctionDeclaration(clean, undefined, modifiers, undefined, clean.name, clean.typeParameters, clean.parameters, clean.type, undefined);
81084                         var namespaceDeclaration = factory.updateModuleDeclaration(namespaceDecl, undefined, modifiers, namespaceDecl.name, namespaceDecl.body);
81085                         var exportDefaultDeclaration = factory.createExportAssignment(undefined, undefined, false, namespaceDecl.name);
81086                         if (ts.isSourceFile(input.parent)) {
81087                             resultHasExternalModuleIndicator = true;
81088                         }
81089                         resultHasScopeMarker = true;
81090                         return [cleanDeclaration, namespaceDeclaration, exportDefaultDeclaration];
81091                     }
81092                     else {
81093                         return clean;
81094                     }
81095                 }
81096                 case 256: {
81097                     needsDeclare = false;
81098                     var inner = input.body;
81099                     if (inner && inner.kind === 257) {
81100                         var oldNeedsScopeFix = needsScopeFixMarker;
81101                         var oldHasScopeFix = resultHasScopeMarker;
81102                         resultHasScopeMarker = false;
81103                         needsScopeFixMarker = false;
81104                         var statements = ts.visitNodes(inner.statements, visitDeclarationStatements);
81105                         var lateStatements = transformAndReplaceLatePaintedStatements(statements);
81106                         if (input.flags & 8388608) {
81107                             needsScopeFixMarker = false;
81108                         }
81109                         if (!ts.isGlobalScopeAugmentation(input) && !hasScopeMarker(lateStatements) && !resultHasScopeMarker) {
81110                             if (needsScopeFixMarker) {
81111                                 lateStatements = factory.createNodeArray(__spreadArray(__spreadArray([], lateStatements), [ts.createEmptyExports(factory)]));
81112                             }
81113                             else {
81114                                 lateStatements = ts.visitNodes(lateStatements, stripExportModifiers);
81115                             }
81116                         }
81117                         var body = factory.updateModuleBlock(inner, lateStatements);
81118                         needsDeclare = previousNeedsDeclare;
81119                         needsScopeFixMarker = oldNeedsScopeFix;
81120                         resultHasScopeMarker = oldHasScopeFix;
81121                         var mods = ensureModifiers(input);
81122                         return cleanup(factory.updateModuleDeclaration(input, undefined, mods, ts.isExternalModuleAugmentation(input) ? rewriteModuleSpecifier(input, input.name) : input.name, body));
81123                     }
81124                     else {
81125                         needsDeclare = previousNeedsDeclare;
81126                         var mods = ensureModifiers(input);
81127                         needsDeclare = false;
81128                         ts.visitNode(inner, visitDeclarationStatements);
81129                         var id = ts.getOriginalNodeId(inner);
81130                         var body = lateStatementReplacementMap.get(id);
81131                         lateStatementReplacementMap.delete(id);
81132                         return cleanup(factory.updateModuleDeclaration(input, undefined, mods, input.name, body));
81133                     }
81134                 }
81135                 case 252: {
81136                     errorNameNode = input.name;
81137                     errorFallbackNode = input;
81138                     var modifiers = factory.createNodeArray(ensureModifiers(input));
81139                     var typeParameters = ensureTypeParams(input, input.typeParameters);
81140                     var ctor = ts.getFirstConstructorWithBody(input);
81141                     var parameterProperties = void 0;
81142                     if (ctor) {
81143                         var oldDiag_1 = getSymbolAccessibilityDiagnostic;
81144                         parameterProperties = ts.compact(ts.flatMap(ctor.parameters, function (param) {
81145                             if (!ts.hasSyntacticModifier(param, 92) || shouldStripInternal(param))
81146                                 return;
81147                             getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(param);
81148                             if (param.name.kind === 78) {
81149                                 return preserveJsDoc(factory.createPropertyDeclaration(undefined, ensureModifiers(param), param.name, param.questionToken, ensureType(param, param.type), ensureNoInitializer(param)), param);
81150                             }
81151                             else {
81152                                 return walkBindingPattern(param.name);
81153                             }
81154                             function walkBindingPattern(pattern) {
81155                                 var elems;
81156                                 for (var _i = 0, _a = pattern.elements; _i < _a.length; _i++) {
81157                                     var elem = _a[_i];
81158                                     if (ts.isOmittedExpression(elem))
81159                                         continue;
81160                                     if (ts.isBindingPattern(elem.name)) {
81161                                         elems = ts.concatenate(elems, walkBindingPattern(elem.name));
81162                                     }
81163                                     elems = elems || [];
81164                                     elems.push(factory.createPropertyDeclaration(undefined, ensureModifiers(param), elem.name, undefined, ensureType(elem, undefined), undefined));
81165                                 }
81166                                 return elems;
81167                             }
81168                         }));
81169                         getSymbolAccessibilityDiagnostic = oldDiag_1;
81170                     }
81171                     var hasPrivateIdentifier = ts.some(input.members, function (member) { return !!member.name && ts.isPrivateIdentifier(member.name); });
81172                     var privateIdentifier = hasPrivateIdentifier ? [
81173                         factory.createPropertyDeclaration(undefined, undefined, factory.createPrivateIdentifier("#private"), undefined, undefined, undefined)
81174                     ] : undefined;
81175                     var memberNodes = ts.concatenate(ts.concatenate(privateIdentifier, parameterProperties), ts.visitNodes(input.members, visitDeclarationSubtree));
81176                     var members = factory.createNodeArray(memberNodes);
81177                     var extendsClause_1 = ts.getEffectiveBaseTypeNode(input);
81178                     if (extendsClause_1 && !ts.isEntityNameExpression(extendsClause_1.expression) && extendsClause_1.expression.kind !== 103) {
81179                         var oldId = input.name ? ts.unescapeLeadingUnderscores(input.name.escapedText) : "default";
81180                         var newId_1 = factory.createUniqueName(oldId + "_base", 16);
81181                         getSymbolAccessibilityDiagnostic = function () { return ({
81182                             diagnosticMessage: ts.Diagnostics.extends_clause_of_exported_class_0_has_or_is_using_private_name_1,
81183                             errorNode: extendsClause_1,
81184                             typeName: input.name
81185                         }); };
81186                         var varDecl = factory.createVariableDeclaration(newId_1, undefined, resolver.createTypeOfExpression(extendsClause_1.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), undefined);
81187                         var statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(133)] : [], factory.createVariableDeclarationList([varDecl], 2));
81188                         var heritageClauses = factory.createNodeArray(ts.map(input.heritageClauses, function (clause) {
81189                             if (clause.token === 93) {
81190                                 var oldDiag_2 = getSymbolAccessibilityDiagnostic;
81191                                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(clause.types[0]);
81192                                 var newClause = factory.updateHeritageClause(clause, ts.map(clause.types, function (t) { return factory.updateExpressionWithTypeArguments(t, newId_1, ts.visitNodes(t.typeArguments, visitDeclarationSubtree)); }));
81193                                 getSymbolAccessibilityDiagnostic = oldDiag_2;
81194                                 return newClause;
81195                             }
81196                             return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) { return ts.isEntityNameExpression(t.expression) || t.expression.kind === 103; })), visitDeclarationSubtree));
81197                         }));
81198                         return [statement, cleanup(factory.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members))];
81199                     }
81200                     else {
81201                         var heritageClauses = transformHeritageClauses(input.heritageClauses);
81202                         return cleanup(factory.updateClassDeclaration(input, undefined, modifiers, input.name, typeParameters, heritageClauses, members));
81203                     }
81204                 }
81205                 case 232: {
81206                     return cleanup(transformVariableStatement(input));
81207                 }
81208                 case 255: {
81209                     return cleanup(factory.updateEnumDeclaration(input, undefined, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(ts.mapDefined(input.members, function (m) {
81210                         if (shouldStripInternal(m))
81211                             return;
81212                         var constValue = resolver.getConstantValue(m);
81213                         return preserveJsDoc(factory.updateEnumMember(m, m.name, constValue !== undefined ? typeof constValue === "string" ? factory.createStringLiteral(constValue) : factory.createNumericLiteral(constValue) : undefined), m);
81214                     }))));
81215                 }
81216             }
81217             return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.SyntaxKind[input.kind]);
81218             function cleanup(node) {
81219                 if (isEnclosingDeclaration(input)) {
81220                     enclosingDeclaration = previousEnclosingDeclaration;
81221                 }
81222                 if (canProdiceDiagnostic) {
81223                     getSymbolAccessibilityDiagnostic = oldDiag;
81224                 }
81225                 if (input.kind === 256) {
81226                     needsDeclare = previousNeedsDeclare;
81227                 }
81228                 if (node === input) {
81229                     return node;
81230                 }
81231                 errorFallbackNode = undefined;
81232                 errorNameNode = undefined;
81233                 return node && ts.setOriginalNode(preserveJsDoc(node, input), input);
81234             }
81235         }
81236         function transformVariableStatement(input) {
81237             if (!ts.forEach(input.declarationList.declarations, getBindingNameVisible))
81238                 return;
81239             var nodes = ts.visitNodes(input.declarationList.declarations, visitDeclarationSubtree);
81240             if (!ts.length(nodes))
81241                 return;
81242             return factory.updateVariableStatement(input, factory.createNodeArray(ensureModifiers(input)), factory.updateVariableDeclarationList(input.declarationList, nodes));
81243         }
81244         function recreateBindingPattern(d) {
81245             return ts.flatten(ts.mapDefined(d.elements, function (e) { return recreateBindingElement(e); }));
81246         }
81247         function recreateBindingElement(e) {
81248             if (e.kind === 222) {
81249                 return;
81250             }
81251             if (e.name) {
81252                 if (!getBindingNameVisible(e))
81253                     return;
81254                 if (ts.isBindingPattern(e.name)) {
81255                     return recreateBindingPattern(e.name);
81256                 }
81257                 else {
81258                     return factory.createVariableDeclaration(e.name, undefined, ensureType(e, undefined), undefined);
81259                 }
81260             }
81261         }
81262         function checkName(node) {
81263             var oldDiag;
81264             if (!suppressNewDiagnosticContexts) {
81265                 oldDiag = getSymbolAccessibilityDiagnostic;
81266                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNodeName(node);
81267             }
81268             errorNameNode = node.name;
81269             ts.Debug.assert(resolver.isLateBound(ts.getParseTreeNode(node)));
81270             var decl = node;
81271             var entityName = decl.name.expression;
81272             checkEntityNameVisibility(entityName, enclosingDeclaration);
81273             if (!suppressNewDiagnosticContexts) {
81274                 getSymbolAccessibilityDiagnostic = oldDiag;
81275             }
81276             errorNameNode = undefined;
81277         }
81278         function shouldStripInternal(node) {
81279             return !!stripInternal && !!node && isInternalDeclaration(node, currentSourceFile);
81280         }
81281         function isScopeMarker(node) {
81282             return ts.isExportAssignment(node) || ts.isExportDeclaration(node);
81283         }
81284         function hasScopeMarker(statements) {
81285             return ts.some(statements, isScopeMarker);
81286         }
81287         function ensureModifiers(node) {
81288             var currentFlags = ts.getEffectiveModifierFlags(node);
81289             var newFlags = ensureModifierFlags(node);
81290             if (currentFlags === newFlags) {
81291                 return node.modifiers;
81292             }
81293             return factory.createModifiersFromModifierFlags(newFlags);
81294         }
81295         function ensureModifierFlags(node) {
81296             var mask = 11263 ^ (4 | 256);
81297             var additions = (needsDeclare && !isAlwaysType(node)) ? 2 : 0;
81298             var parentIsFile = node.parent.kind === 297;
81299             if (!parentIsFile || (isBundledEmit && parentIsFile && ts.isExternalModule(node.parent))) {
81300                 mask ^= 2;
81301                 additions = 0;
81302             }
81303             return maskModifierFlags(node, mask, additions);
81304         }
81305         function getTypeAnnotationFromAllAccessorDeclarations(node, accessors) {
81306             var accessorType = getTypeAnnotationFromAccessor(node);
81307             if (!accessorType && node !== accessors.firstAccessor) {
81308                 accessorType = getTypeAnnotationFromAccessor(accessors.firstAccessor);
81309                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.firstAccessor);
81310             }
81311             if (!accessorType && accessors.secondAccessor && node !== accessors.secondAccessor) {
81312                 accessorType = getTypeAnnotationFromAccessor(accessors.secondAccessor);
81313                 getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(accessors.secondAccessor);
81314             }
81315             return accessorType;
81316         }
81317         function transformHeritageClauses(nodes) {
81318             return factory.createNodeArray(ts.filter(ts.map(nodes, function (clause) { return factory.updateHeritageClause(clause, ts.visitNodes(factory.createNodeArray(ts.filter(clause.types, function (t) {
81319                 return ts.isEntityNameExpression(t.expression) || (clause.token === 93 && t.expression.kind === 103);
81320             })), visitDeclarationSubtree)); }), function (clause) { return clause.types && !!clause.types.length; }));
81321         }
81322     }
81323     ts.transformDeclarations = transformDeclarations;
81324     function isAlwaysType(node) {
81325         if (node.kind === 253) {
81326             return true;
81327         }
81328         return false;
81329     }
81330     function maskModifiers(node, modifierMask, modifierAdditions) {
81331         return ts.factory.createModifiersFromModifierFlags(maskModifierFlags(node, modifierMask, modifierAdditions));
81332     }
81333     function maskModifierFlags(node, modifierMask, modifierAdditions) {
81334         if (modifierMask === void 0) { modifierMask = 11263 ^ 4; }
81335         if (modifierAdditions === void 0) { modifierAdditions = 0; }
81336         var flags = (ts.getEffectiveModifierFlags(node) & modifierMask) | modifierAdditions;
81337         if (flags & 512 && !(flags & 1)) {
81338             flags ^= 1;
81339         }
81340         if (flags & 512 && flags & 2) {
81341             flags ^= 2;
81342         }
81343         return flags;
81344     }
81345     function getTypeAnnotationFromAccessor(accessor) {
81346         if (accessor) {
81347             return accessor.kind === 167
81348                 ? accessor.type
81349                 : accessor.parameters.length > 0
81350                     ? accessor.parameters[0].type
81351                     : undefined;
81352         }
81353     }
81354     function canHaveLiteralInitializer(node) {
81355         switch (node.kind) {
81356             case 163:
81357             case 162:
81358                 return !ts.hasEffectiveModifier(node, 8);
81359             case 160:
81360             case 249:
81361                 return true;
81362         }
81363         return false;
81364     }
81365     function isPreservedDeclarationStatement(node) {
81366         switch (node.kind) {
81367             case 251:
81368             case 256:
81369             case 260:
81370             case 253:
81371             case 252:
81372             case 254:
81373             case 255:
81374             case 232:
81375             case 261:
81376             case 267:
81377             case 266:
81378                 return true;
81379         }
81380         return false;
81381     }
81382     function isProcessedComponent(node) {
81383         switch (node.kind) {
81384             case 170:
81385             case 166:
81386             case 165:
81387             case 167:
81388             case 168:
81389             case 163:
81390             case 162:
81391             case 164:
81392             case 169:
81393             case 171:
81394             case 249:
81395             case 159:
81396             case 223:
81397             case 173:
81398             case 184:
81399             case 174:
81400             case 175:
81401             case 195:
81402                 return true;
81403         }
81404         return false;
81405     }
81406 })(ts || (ts = {}));
81407 var ts;
81408 (function (ts) {
81409     function getModuleTransformer(moduleKind) {
81410         switch (moduleKind) {
81411             case ts.ModuleKind.ESNext:
81412             case ts.ModuleKind.ES2020:
81413             case ts.ModuleKind.ES2015:
81414                 return ts.transformECMAScriptModule;
81415             case ts.ModuleKind.System:
81416                 return ts.transformSystemModule;
81417             default:
81418                 return ts.transformModule;
81419         }
81420     }
81421     ts.noTransformers = { scriptTransformers: ts.emptyArray, declarationTransformers: ts.emptyArray };
81422     function getTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles) {
81423         return {
81424             scriptTransformers: getScriptTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles),
81425             declarationTransformers: getDeclarationTransformers(customTransformers),
81426         };
81427     }
81428     ts.getTransformers = getTransformers;
81429     function getScriptTransformers(compilerOptions, customTransformers, emitOnlyDtsFiles) {
81430         if (emitOnlyDtsFiles)
81431             return ts.emptyArray;
81432         var languageVersion = ts.getEmitScriptTarget(compilerOptions);
81433         var moduleKind = ts.getEmitModuleKind(compilerOptions);
81434         var transformers = [];
81435         ts.addRange(transformers, customTransformers && ts.map(customTransformers.before, wrapScriptTransformerFactory));
81436         transformers.push(ts.transformTypeScript);
81437         transformers.push(ts.transformClassFields);
81438         if (ts.getJSXTransformEnabled(compilerOptions)) {
81439             transformers.push(ts.transformJsx);
81440         }
81441         if (languageVersion < 99) {
81442             transformers.push(ts.transformESNext);
81443         }
81444         if (languageVersion < 7) {
81445             transformers.push(ts.transformES2020);
81446         }
81447         if (languageVersion < 6) {
81448             transformers.push(ts.transformES2019);
81449         }
81450         if (languageVersion < 5) {
81451             transformers.push(ts.transformES2018);
81452         }
81453         if (languageVersion < 4) {
81454             transformers.push(ts.transformES2017);
81455         }
81456         if (languageVersion < 3) {
81457             transformers.push(ts.transformES2016);
81458         }
81459         if (languageVersion < 2) {
81460             transformers.push(ts.transformES2015);
81461             transformers.push(ts.transformGenerators);
81462         }
81463         transformers.push(getModuleTransformer(moduleKind));
81464         if (languageVersion < 1) {
81465             transformers.push(ts.transformES5);
81466         }
81467         ts.addRange(transformers, customTransformers && ts.map(customTransformers.after, wrapScriptTransformerFactory));
81468         return transformers;
81469     }
81470     function getDeclarationTransformers(customTransformers) {
81471         var transformers = [];
81472         transformers.push(ts.transformDeclarations);
81473         ts.addRange(transformers, customTransformers && ts.map(customTransformers.afterDeclarations, wrapDeclarationTransformerFactory));
81474         return transformers;
81475     }
81476     function wrapCustomTransformer(transformer) {
81477         return function (node) { return ts.isBundle(node) ? transformer.transformBundle(node) : transformer.transformSourceFile(node); };
81478     }
81479     function wrapCustomTransformerFactory(transformer, handleDefault) {
81480         return function (context) {
81481             var customTransformer = transformer(context);
81482             return typeof customTransformer === "function"
81483                 ? handleDefault(context, customTransformer)
81484                 : wrapCustomTransformer(customTransformer);
81485         };
81486     }
81487     function wrapScriptTransformerFactory(transformer) {
81488         return wrapCustomTransformerFactory(transformer, ts.chainBundle);
81489     }
81490     function wrapDeclarationTransformerFactory(transformer) {
81491         return wrapCustomTransformerFactory(transformer, function (_, node) { return node; });
81492     }
81493     function noEmitSubstitution(_hint, node) {
81494         return node;
81495     }
81496     ts.noEmitSubstitution = noEmitSubstitution;
81497     function noEmitNotification(hint, node, callback) {
81498         callback(hint, node);
81499     }
81500     ts.noEmitNotification = noEmitNotification;
81501     function transformNodes(resolver, host, factory, options, nodes, transformers, allowDtsFiles) {
81502         var enabledSyntaxKindFeatures = new Array(341);
81503         var lexicalEnvironmentVariableDeclarations;
81504         var lexicalEnvironmentFunctionDeclarations;
81505         var lexicalEnvironmentStatements;
81506         var lexicalEnvironmentFlags = 0;
81507         var lexicalEnvironmentVariableDeclarationsStack = [];
81508         var lexicalEnvironmentFunctionDeclarationsStack = [];
81509         var lexicalEnvironmentStatementsStack = [];
81510         var lexicalEnvironmentFlagsStack = [];
81511         var lexicalEnvironmentStackOffset = 0;
81512         var lexicalEnvironmentSuspended = false;
81513         var emitHelpers;
81514         var onSubstituteNode = noEmitSubstitution;
81515         var onEmitNode = noEmitNotification;
81516         var state = 0;
81517         var diagnostics = [];
81518         var context = {
81519             factory: factory,
81520             getCompilerOptions: function () { return options; },
81521             getEmitResolver: function () { return resolver; },
81522             getEmitHost: function () { return host; },
81523             getEmitHelperFactory: ts.memoize(function () { return ts.createEmitHelperFactory(context); }),
81524             startLexicalEnvironment: startLexicalEnvironment,
81525             suspendLexicalEnvironment: suspendLexicalEnvironment,
81526             resumeLexicalEnvironment: resumeLexicalEnvironment,
81527             endLexicalEnvironment: endLexicalEnvironment,
81528             setLexicalEnvironmentFlags: setLexicalEnvironmentFlags,
81529             getLexicalEnvironmentFlags: getLexicalEnvironmentFlags,
81530             hoistVariableDeclaration: hoistVariableDeclaration,
81531             hoistFunctionDeclaration: hoistFunctionDeclaration,
81532             addInitializationStatement: addInitializationStatement,
81533             requestEmitHelper: requestEmitHelper,
81534             readEmitHelpers: readEmitHelpers,
81535             enableSubstitution: enableSubstitution,
81536             enableEmitNotification: enableEmitNotification,
81537             isSubstitutionEnabled: isSubstitutionEnabled,
81538             isEmitNotificationEnabled: isEmitNotificationEnabled,
81539             get onSubstituteNode() { return onSubstituteNode; },
81540             set onSubstituteNode(value) {
81541                 ts.Debug.assert(state < 1, "Cannot modify transformation hooks after initialization has completed.");
81542                 ts.Debug.assert(value !== undefined, "Value must not be 'undefined'");
81543                 onSubstituteNode = value;
81544             },
81545             get onEmitNode() { return onEmitNode; },
81546             set onEmitNode(value) {
81547                 ts.Debug.assert(state < 1, "Cannot modify transformation hooks after initialization has completed.");
81548                 ts.Debug.assert(value !== undefined, "Value must not be 'undefined'");
81549                 onEmitNode = value;
81550             },
81551             addDiagnostic: function (diag) {
81552                 diagnostics.push(diag);
81553             }
81554         };
81555         for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
81556             var node = nodes_2[_i];
81557             ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node)));
81558         }
81559         ts.performance.mark("beforeTransform");
81560         var transformersWithContext = transformers.map(function (t) { return t(context); });
81561         var transformation = function (node) {
81562             for (var _i = 0, transformersWithContext_1 = transformersWithContext; _i < transformersWithContext_1.length; _i++) {
81563                 var transform = transformersWithContext_1[_i];
81564                 node = transform(node);
81565             }
81566             return node;
81567         };
81568         state = 1;
81569         var transformed = [];
81570         for (var _a = 0, nodes_3 = nodes; _a < nodes_3.length; _a++) {
81571             var node = nodes_3[_a];
81572             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit", "transformNodes", node.kind === 297 ? { path: node.path } : { kind: node.kind, pos: node.pos, end: node.end });
81573             transformed.push((allowDtsFiles ? transformation : transformRoot)(node));
81574             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
81575         }
81576         state = 2;
81577         ts.performance.mark("afterTransform");
81578         ts.performance.measure("transformTime", "beforeTransform", "afterTransform");
81579         return {
81580             transformed: transformed,
81581             substituteNode: substituteNode,
81582             emitNodeWithNotification: emitNodeWithNotification,
81583             isEmitNotificationEnabled: isEmitNotificationEnabled,
81584             dispose: dispose,
81585             diagnostics: diagnostics
81586         };
81587         function transformRoot(node) {
81588             return node && (!ts.isSourceFile(node) || !node.isDeclarationFile) ? transformation(node) : node;
81589         }
81590         function enableSubstitution(kind) {
81591             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
81592             enabledSyntaxKindFeatures[kind] |= 1;
81593         }
81594         function isSubstitutionEnabled(node) {
81595             return (enabledSyntaxKindFeatures[node.kind] & 1) !== 0
81596                 && (ts.getEmitFlags(node) & 4) === 0;
81597         }
81598         function substituteNode(hint, node) {
81599             ts.Debug.assert(state < 3, "Cannot substitute a node after the result is disposed.");
81600             return node && isSubstitutionEnabled(node) && onSubstituteNode(hint, node) || node;
81601         }
81602         function enableEmitNotification(kind) {
81603             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
81604             enabledSyntaxKindFeatures[kind] |= 2;
81605         }
81606         function isEmitNotificationEnabled(node) {
81607             return (enabledSyntaxKindFeatures[node.kind] & 2) !== 0
81608                 || (ts.getEmitFlags(node) & 2) !== 0;
81609         }
81610         function emitNodeWithNotification(hint, node, emitCallback) {
81611             ts.Debug.assert(state < 3, "Cannot invoke TransformationResult callbacks after the result is disposed.");
81612             if (node) {
81613                 if (isEmitNotificationEnabled(node)) {
81614                     onEmitNode(hint, node, emitCallback);
81615                 }
81616                 else {
81617                     emitCallback(hint, node);
81618                 }
81619             }
81620         }
81621         function hoistVariableDeclaration(name) {
81622             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
81623             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
81624             var decl = ts.setEmitFlags(factory.createVariableDeclaration(name), 64);
81625             if (!lexicalEnvironmentVariableDeclarations) {
81626                 lexicalEnvironmentVariableDeclarations = [decl];
81627             }
81628             else {
81629                 lexicalEnvironmentVariableDeclarations.push(decl);
81630             }
81631             if (lexicalEnvironmentFlags & 1) {
81632                 lexicalEnvironmentFlags |= 2;
81633             }
81634         }
81635         function hoistFunctionDeclaration(func) {
81636             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
81637             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
81638             ts.setEmitFlags(func, 1048576);
81639             if (!lexicalEnvironmentFunctionDeclarations) {
81640                 lexicalEnvironmentFunctionDeclarations = [func];
81641             }
81642             else {
81643                 lexicalEnvironmentFunctionDeclarations.push(func);
81644             }
81645         }
81646         function addInitializationStatement(node) {
81647             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
81648             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
81649             ts.setEmitFlags(node, 1048576);
81650             if (!lexicalEnvironmentStatements) {
81651                 lexicalEnvironmentStatements = [node];
81652             }
81653             else {
81654                 lexicalEnvironmentStatements.push(node);
81655             }
81656         }
81657         function startLexicalEnvironment() {
81658             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
81659             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
81660             ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended.");
81661             lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentVariableDeclarations;
81662             lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFunctionDeclarations;
81663             lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentStatements;
81664             lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset] = lexicalEnvironmentFlags;
81665             lexicalEnvironmentStackOffset++;
81666             lexicalEnvironmentVariableDeclarations = undefined;
81667             lexicalEnvironmentFunctionDeclarations = undefined;
81668             lexicalEnvironmentStatements = undefined;
81669             lexicalEnvironmentFlags = 0;
81670         }
81671         function suspendLexicalEnvironment() {
81672             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
81673             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
81674             ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is already suspended.");
81675             lexicalEnvironmentSuspended = true;
81676         }
81677         function resumeLexicalEnvironment() {
81678             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
81679             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
81680             ts.Debug.assert(lexicalEnvironmentSuspended, "Lexical environment is not suspended.");
81681             lexicalEnvironmentSuspended = false;
81682         }
81683         function endLexicalEnvironment() {
81684             ts.Debug.assert(state > 0, "Cannot modify the lexical environment during initialization.");
81685             ts.Debug.assert(state < 2, "Cannot modify the lexical environment after transformation has completed.");
81686             ts.Debug.assert(!lexicalEnvironmentSuspended, "Lexical environment is suspended.");
81687             var statements;
81688             if (lexicalEnvironmentVariableDeclarations ||
81689                 lexicalEnvironmentFunctionDeclarations ||
81690                 lexicalEnvironmentStatements) {
81691                 if (lexicalEnvironmentFunctionDeclarations) {
81692                     statements = __spreadArray([], lexicalEnvironmentFunctionDeclarations);
81693                 }
81694                 if (lexicalEnvironmentVariableDeclarations) {
81695                     var statement = factory.createVariableStatement(undefined, factory.createVariableDeclarationList(lexicalEnvironmentVariableDeclarations));
81696                     ts.setEmitFlags(statement, 1048576);
81697                     if (!statements) {
81698                         statements = [statement];
81699                     }
81700                     else {
81701                         statements.push(statement);
81702                     }
81703                 }
81704                 if (lexicalEnvironmentStatements) {
81705                     if (!statements) {
81706                         statements = __spreadArray([], lexicalEnvironmentStatements);
81707                     }
81708                     else {
81709                         statements = __spreadArray(__spreadArray([], statements), lexicalEnvironmentStatements);
81710                     }
81711                 }
81712             }
81713             lexicalEnvironmentStackOffset--;
81714             lexicalEnvironmentVariableDeclarations = lexicalEnvironmentVariableDeclarationsStack[lexicalEnvironmentStackOffset];
81715             lexicalEnvironmentFunctionDeclarations = lexicalEnvironmentFunctionDeclarationsStack[lexicalEnvironmentStackOffset];
81716             lexicalEnvironmentStatements = lexicalEnvironmentStatementsStack[lexicalEnvironmentStackOffset];
81717             lexicalEnvironmentFlags = lexicalEnvironmentFlagsStack[lexicalEnvironmentStackOffset];
81718             if (lexicalEnvironmentStackOffset === 0) {
81719                 lexicalEnvironmentVariableDeclarationsStack = [];
81720                 lexicalEnvironmentFunctionDeclarationsStack = [];
81721                 lexicalEnvironmentStatementsStack = [];
81722                 lexicalEnvironmentFlagsStack = [];
81723             }
81724             return statements;
81725         }
81726         function setLexicalEnvironmentFlags(flags, value) {
81727             lexicalEnvironmentFlags = value ?
81728                 lexicalEnvironmentFlags | flags :
81729                 lexicalEnvironmentFlags & ~flags;
81730         }
81731         function getLexicalEnvironmentFlags() {
81732             return lexicalEnvironmentFlags;
81733         }
81734         function requestEmitHelper(helper) {
81735             ts.Debug.assert(state > 0, "Cannot modify the transformation context during initialization.");
81736             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
81737             ts.Debug.assert(!helper.scoped, "Cannot request a scoped emit helper.");
81738             if (helper.dependencies) {
81739                 for (var _i = 0, _a = helper.dependencies; _i < _a.length; _i++) {
81740                     var h = _a[_i];
81741                     requestEmitHelper(h);
81742                 }
81743             }
81744             emitHelpers = ts.append(emitHelpers, helper);
81745         }
81746         function readEmitHelpers() {
81747             ts.Debug.assert(state > 0, "Cannot modify the transformation context during initialization.");
81748             ts.Debug.assert(state < 2, "Cannot modify the transformation context after transformation has completed.");
81749             var helpers = emitHelpers;
81750             emitHelpers = undefined;
81751             return helpers;
81752         }
81753         function dispose() {
81754             if (state < 3) {
81755                 for (var _i = 0, nodes_4 = nodes; _i < nodes_4.length; _i++) {
81756                     var node = nodes_4[_i];
81757                     ts.disposeEmitNodes(ts.getSourceFileOfNode(ts.getParseTreeNode(node)));
81758                 }
81759                 lexicalEnvironmentVariableDeclarations = undefined;
81760                 lexicalEnvironmentVariableDeclarationsStack = undefined;
81761                 lexicalEnvironmentFunctionDeclarations = undefined;
81762                 lexicalEnvironmentFunctionDeclarationsStack = undefined;
81763                 onSubstituteNode = undefined;
81764                 onEmitNode = undefined;
81765                 emitHelpers = undefined;
81766                 state = 3;
81767             }
81768         }
81769     }
81770     ts.transformNodes = transformNodes;
81771     ts.nullTransformationContext = {
81772         get factory() { return ts.factory; },
81773         enableEmitNotification: ts.noop,
81774         enableSubstitution: ts.noop,
81775         endLexicalEnvironment: ts.returnUndefined,
81776         getCompilerOptions: function () { return ({}); },
81777         getEmitHost: ts.notImplemented,
81778         getEmitResolver: ts.notImplemented,
81779         getEmitHelperFactory: ts.notImplemented,
81780         setLexicalEnvironmentFlags: ts.noop,
81781         getLexicalEnvironmentFlags: function () { return 0; },
81782         hoistFunctionDeclaration: ts.noop,
81783         hoistVariableDeclaration: ts.noop,
81784         addInitializationStatement: ts.noop,
81785         isEmitNotificationEnabled: ts.notImplemented,
81786         isSubstitutionEnabled: ts.notImplemented,
81787         onEmitNode: ts.noop,
81788         onSubstituteNode: ts.notImplemented,
81789         readEmitHelpers: ts.notImplemented,
81790         requestEmitHelper: ts.noop,
81791         resumeLexicalEnvironment: ts.noop,
81792         startLexicalEnvironment: ts.noop,
81793         suspendLexicalEnvironment: ts.noop,
81794         addDiagnostic: ts.noop,
81795     };
81796 })(ts || (ts = {}));
81797 var ts;
81798 (function (ts) {
81799     var brackets = createBracketsMap();
81800     var syntheticParent = { pos: -1, end: -1 };
81801     function isBuildInfoFile(file) {
81802         return ts.fileExtensionIs(file, ".tsbuildinfo");
81803     }
81804     ts.isBuildInfoFile = isBuildInfoFile;
81805     function forEachEmittedFile(host, action, sourceFilesOrTargetSourceFile, forceDtsEmit, onlyBuildInfo, includeBuildInfo) {
81806         if (forceDtsEmit === void 0) { forceDtsEmit = false; }
81807         var sourceFiles = ts.isArray(sourceFilesOrTargetSourceFile) ? sourceFilesOrTargetSourceFile : ts.getSourceFilesToEmit(host, sourceFilesOrTargetSourceFile, forceDtsEmit);
81808         var options = host.getCompilerOptions();
81809         if (ts.outFile(options)) {
81810             var prepends = host.getPrependNodes();
81811             if (sourceFiles.length || prepends.length) {
81812                 var bundle = ts.factory.createBundle(sourceFiles, prepends);
81813                 var result = action(getOutputPathsFor(bundle, host, forceDtsEmit), bundle);
81814                 if (result) {
81815                     return result;
81816                 }
81817             }
81818         }
81819         else {
81820             if (!onlyBuildInfo) {
81821                 for (var _a = 0, sourceFiles_1 = sourceFiles; _a < sourceFiles_1.length; _a++) {
81822                     var sourceFile = sourceFiles_1[_a];
81823                     var result = action(getOutputPathsFor(sourceFile, host, forceDtsEmit), sourceFile);
81824                     if (result) {
81825                         return result;
81826                     }
81827                 }
81828             }
81829             if (includeBuildInfo) {
81830                 var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
81831                 if (buildInfoPath)
81832                     return action({ buildInfoPath: buildInfoPath }, undefined);
81833             }
81834         }
81835     }
81836     ts.forEachEmittedFile = forEachEmittedFile;
81837     function getTsBuildInfoEmitOutputFilePath(options) {
81838         var configFile = options.configFilePath;
81839         if (!ts.isIncrementalCompilation(options))
81840             return undefined;
81841         if (options.tsBuildInfoFile)
81842             return options.tsBuildInfoFile;
81843         var outPath = ts.outFile(options);
81844         var buildInfoExtensionLess;
81845         if (outPath) {
81846             buildInfoExtensionLess = ts.removeFileExtension(outPath);
81847         }
81848         else {
81849             if (!configFile)
81850                 return undefined;
81851             var configFileExtensionLess = ts.removeFileExtension(configFile);
81852             buildInfoExtensionLess = options.outDir ?
81853                 options.rootDir ?
81854                     ts.resolvePath(options.outDir, ts.getRelativePathFromDirectory(options.rootDir, configFileExtensionLess, true)) :
81855                     ts.combinePaths(options.outDir, ts.getBaseFileName(configFileExtensionLess)) :
81856                 configFileExtensionLess;
81857         }
81858         return buildInfoExtensionLess + ".tsbuildinfo";
81859     }
81860     ts.getTsBuildInfoEmitOutputFilePath = getTsBuildInfoEmitOutputFilePath;
81861     function getOutputPathsForBundle(options, forceDtsPaths) {
81862         var outPath = ts.outFile(options);
81863         var jsFilePath = options.emitDeclarationOnly ? undefined : outPath;
81864         var sourceMapFilePath = jsFilePath && getSourceMapFilePath(jsFilePath, options);
81865         var declarationFilePath = (forceDtsPaths || ts.getEmitDeclarations(options)) ? ts.removeFileExtension(outPath) + ".d.ts" : undefined;
81866         var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined;
81867         var buildInfoPath = getTsBuildInfoEmitOutputFilePath(options);
81868         return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: buildInfoPath };
81869     }
81870     ts.getOutputPathsForBundle = getOutputPathsForBundle;
81871     function getOutputPathsFor(sourceFile, host, forceDtsPaths) {
81872         var options = host.getCompilerOptions();
81873         if (sourceFile.kind === 298) {
81874             return getOutputPathsForBundle(options, forceDtsPaths);
81875         }
81876         else {
81877             var ownOutputFilePath = ts.getOwnEmitOutputFilePath(sourceFile.fileName, host, getOutputExtension(sourceFile, options));
81878             var isJsonFile = ts.isJsonSourceFile(sourceFile);
81879             var isJsonEmittedToSameLocation = isJsonFile &&
81880                 ts.comparePaths(sourceFile.fileName, ownOutputFilePath, host.getCurrentDirectory(), !host.useCaseSensitiveFileNames()) === 0;
81881             var jsFilePath = options.emitDeclarationOnly || isJsonEmittedToSameLocation ? undefined : ownOutputFilePath;
81882             var sourceMapFilePath = !jsFilePath || ts.isJsonSourceFile(sourceFile) ? undefined : getSourceMapFilePath(jsFilePath, options);
81883             var declarationFilePath = (forceDtsPaths || (ts.getEmitDeclarations(options) && !isJsonFile)) ? ts.getDeclarationEmitOutputFilePath(sourceFile.fileName, host) : undefined;
81884             var declarationMapPath = declarationFilePath && ts.getAreDeclarationMapsEnabled(options) ? declarationFilePath + ".map" : undefined;
81885             return { jsFilePath: jsFilePath, sourceMapFilePath: sourceMapFilePath, declarationFilePath: declarationFilePath, declarationMapPath: declarationMapPath, buildInfoPath: undefined };
81886         }
81887     }
81888     ts.getOutputPathsFor = getOutputPathsFor;
81889     function getSourceMapFilePath(jsFilePath, options) {
81890         return (options.sourceMap && !options.inlineSourceMap) ? jsFilePath + ".map" : undefined;
81891     }
81892     function getOutputExtension(sourceFile, options) {
81893         if (ts.isJsonSourceFile(sourceFile)) {
81894             return ".json";
81895         }
81896         if (options.jsx === 1) {
81897             if (ts.isSourceFileJS(sourceFile)) {
81898                 if (ts.fileExtensionIs(sourceFile.fileName, ".jsx")) {
81899                     return ".jsx";
81900                 }
81901             }
81902             else if (sourceFile.languageVariant === 1) {
81903                 return ".jsx";
81904             }
81905         }
81906         return ".js";
81907     }
81908     ts.getOutputExtension = getOutputExtension;
81909     function getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, outputDir, getCommonSourceDirectory) {
81910         return outputDir ?
81911             ts.resolvePath(outputDir, ts.getRelativePathFromDirectory(getCommonSourceDirectory ? getCommonSourceDirectory() : getCommonSourceDirectoryOfConfig(configFile, ignoreCase), inputFileName, ignoreCase)) :
81912             inputFileName;
81913     }
81914     function getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) {
81915         ts.Debug.assert(!ts.fileExtensionIs(inputFileName, ".d.ts") && !ts.fileExtensionIs(inputFileName, ".json"));
81916         return ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.declarationDir || configFile.options.outDir, getCommonSourceDirectory), ".d.ts");
81917     }
81918     ts.getOutputDeclarationFileName = getOutputDeclarationFileName;
81919     function getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory) {
81920         if (configFile.options.emitDeclarationOnly)
81921             return undefined;
81922         var isJsonFile = ts.fileExtensionIs(inputFileName, ".json");
81923         var outputFileName = ts.changeExtension(getOutputPathWithoutChangingExt(inputFileName, configFile, ignoreCase, configFile.options.outDir, getCommonSourceDirectory), isJsonFile ?
81924             ".json" :
81925             configFile.options.jsx === 1 && (ts.fileExtensionIs(inputFileName, ".tsx") || ts.fileExtensionIs(inputFileName, ".jsx")) ?
81926                 ".jsx" :
81927                 ".js");
81928         return !isJsonFile || ts.comparePaths(inputFileName, outputFileName, ts.Debug.checkDefined(configFile.options.configFilePath), ignoreCase) !== 0 ?
81929             outputFileName :
81930             undefined;
81931     }
81932     function createAddOutput() {
81933         var outputs;
81934         return { addOutput: addOutput, getOutputs: getOutputs };
81935         function addOutput(path) {
81936             if (path) {
81937                 (outputs || (outputs = [])).push(path);
81938             }
81939         }
81940         function getOutputs() {
81941             return outputs || ts.emptyArray;
81942         }
81943     }
81944     function getSingleOutputFileNames(configFile, addOutput) {
81945         var _a = getOutputPathsForBundle(configFile.options, false), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
81946         addOutput(jsFilePath);
81947         addOutput(sourceMapFilePath);
81948         addOutput(declarationFilePath);
81949         addOutput(declarationMapPath);
81950         addOutput(buildInfoPath);
81951     }
81952     function getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory) {
81953         if (ts.fileExtensionIs(inputFileName, ".d.ts"))
81954             return;
81955         var js = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
81956         addOutput(js);
81957         if (ts.fileExtensionIs(inputFileName, ".json"))
81958             return;
81959         if (js && configFile.options.sourceMap) {
81960             addOutput(js + ".map");
81961         }
81962         if (ts.getEmitDeclarations(configFile.options)) {
81963             var dts = getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
81964             addOutput(dts);
81965             if (configFile.options.declarationMap) {
81966                 addOutput(dts + ".map");
81967             }
81968         }
81969     }
81970     function getCommonSourceDirectory(options, emittedFiles, currentDirectory, getCanonicalFileName, checkSourceFilesBelongToPath) {
81971         var commonSourceDirectory;
81972         if (options.rootDir) {
81973             commonSourceDirectory = ts.getNormalizedAbsolutePath(options.rootDir, currentDirectory);
81974             checkSourceFilesBelongToPath === null || checkSourceFilesBelongToPath === void 0 ? void 0 : checkSourceFilesBelongToPath(options.rootDir);
81975         }
81976         else if (options.composite && options.configFilePath) {
81977             commonSourceDirectory = ts.getDirectoryPath(ts.normalizeSlashes(options.configFilePath));
81978             checkSourceFilesBelongToPath === null || checkSourceFilesBelongToPath === void 0 ? void 0 : checkSourceFilesBelongToPath(commonSourceDirectory);
81979         }
81980         else {
81981             commonSourceDirectory = ts.computeCommonSourceDirectoryOfFilenames(emittedFiles(), currentDirectory, getCanonicalFileName);
81982         }
81983         if (commonSourceDirectory && commonSourceDirectory[commonSourceDirectory.length - 1] !== ts.directorySeparator) {
81984             commonSourceDirectory += ts.directorySeparator;
81985         }
81986         return commonSourceDirectory;
81987     }
81988     ts.getCommonSourceDirectory = getCommonSourceDirectory;
81989     function getCommonSourceDirectoryOfConfig(_a, ignoreCase) {
81990         var options = _a.options, fileNames = _a.fileNames;
81991         return getCommonSourceDirectory(options, function () { return ts.filter(fileNames, function (file) { return !(options.noEmitForJsFiles && ts.fileExtensionIsOneOf(file, ts.supportedJSExtensions)) && !ts.fileExtensionIs(file, ".d.ts"); }); }, ts.getDirectoryPath(ts.normalizeSlashes(ts.Debug.checkDefined(options.configFilePath))), ts.createGetCanonicalFileName(!ignoreCase));
81992     }
81993     ts.getCommonSourceDirectoryOfConfig = getCommonSourceDirectoryOfConfig;
81994     function getAllProjectOutputs(configFile, ignoreCase) {
81995         var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs;
81996         if (ts.outFile(configFile.options)) {
81997             getSingleOutputFileNames(configFile, addOutput);
81998         }
81999         else {
82000             var getCommonSourceDirectory_1 = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); });
82001             for (var _b = 0, _c = configFile.fileNames; _b < _c.length; _b++) {
82002                 var inputFileName = _c[_b];
82003                 getOwnOutputFileNames(configFile, inputFileName, ignoreCase, addOutput, getCommonSourceDirectory_1);
82004             }
82005             addOutput(getTsBuildInfoEmitOutputFilePath(configFile.options));
82006         }
82007         return getOutputs();
82008     }
82009     ts.getAllProjectOutputs = getAllProjectOutputs;
82010     function getOutputFileNames(commandLine, inputFileName, ignoreCase) {
82011         inputFileName = ts.normalizePath(inputFileName);
82012         ts.Debug.assert(ts.contains(commandLine.fileNames, inputFileName), "Expected fileName to be present in command line");
82013         var _a = createAddOutput(), addOutput = _a.addOutput, getOutputs = _a.getOutputs;
82014         if (ts.outFile(commandLine.options)) {
82015             getSingleOutputFileNames(commandLine, addOutput);
82016         }
82017         else {
82018             getOwnOutputFileNames(commandLine, inputFileName, ignoreCase, addOutput);
82019         }
82020         return getOutputs();
82021     }
82022     ts.getOutputFileNames = getOutputFileNames;
82023     function getFirstProjectOutput(configFile, ignoreCase) {
82024         if (ts.outFile(configFile.options)) {
82025             var jsFilePath = getOutputPathsForBundle(configFile.options, false).jsFilePath;
82026             return ts.Debug.checkDefined(jsFilePath, "project " + configFile.options.configFilePath + " expected to have at least one output");
82027         }
82028         var getCommonSourceDirectory = ts.memoize(function () { return getCommonSourceDirectoryOfConfig(configFile, ignoreCase); });
82029         for (var _a = 0, _b = configFile.fileNames; _a < _b.length; _a++) {
82030             var inputFileName = _b[_a];
82031             if (ts.fileExtensionIs(inputFileName, ".d.ts"))
82032                 continue;
82033             var jsFilePath = getOutputJSFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
82034             if (jsFilePath)
82035                 return jsFilePath;
82036             if (ts.fileExtensionIs(inputFileName, ".json"))
82037                 continue;
82038             if (ts.getEmitDeclarations(configFile.options)) {
82039                 return getOutputDeclarationFileName(inputFileName, configFile, ignoreCase, getCommonSourceDirectory);
82040             }
82041         }
82042         var buildInfoPath = getTsBuildInfoEmitOutputFilePath(configFile.options);
82043         if (buildInfoPath)
82044             return buildInfoPath;
82045         return ts.Debug.fail("project " + configFile.options.configFilePath + " expected to have at least one output");
82046     }
82047     ts.getFirstProjectOutput = getFirstProjectOutput;
82048     function emitFiles(resolver, host, targetSourceFile, _a, emitOnlyDtsFiles, onlyBuildInfo, forceDtsEmit) {
82049         var scriptTransformers = _a.scriptTransformers, declarationTransformers = _a.declarationTransformers;
82050         var compilerOptions = host.getCompilerOptions();
82051         var sourceMapDataList = (compilerOptions.sourceMap || compilerOptions.inlineSourceMap || ts.getAreDeclarationMapsEnabled(compilerOptions)) ? [] : undefined;
82052         var emittedFilesList = compilerOptions.listEmittedFiles ? [] : undefined;
82053         var emitterDiagnostics = ts.createDiagnosticCollection();
82054         var newLine = ts.getNewLineCharacter(compilerOptions, function () { return host.getNewLine(); });
82055         var writer = ts.createTextWriter(newLine);
82056         var _b = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _b.enter, exit = _b.exit;
82057         var bundleBuildInfo;
82058         var emitSkipped = false;
82059         var exportedModulesFromDeclarationEmit;
82060         enter();
82061         forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile);
82062         exit();
82063         return {
82064             emitSkipped: emitSkipped,
82065             diagnostics: emitterDiagnostics.getDiagnostics(),
82066             emittedFiles: emittedFilesList,
82067             sourceMaps: sourceMapDataList,
82068             exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit
82069         };
82070         function emitSourceFileOrBundle(_a, sourceFileOrBundle) {
82071             var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
82072             var buildInfoDirectory;
82073             if (buildInfoPath && sourceFileOrBundle && ts.isBundle(sourceFileOrBundle)) {
82074                 buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
82075                 bundleBuildInfo = {
82076                     commonSourceDirectory: relativeToBuildInfo(host.getCommonSourceDirectory()),
82077                     sourceFiles: sourceFileOrBundle.sourceFiles.map(function (file) { return relativeToBuildInfo(ts.getNormalizedAbsolutePath(file.fileName, host.getCurrentDirectory())); })
82078                 };
82079             }
82080             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit", "emitJsFileOrBundle", { jsFilePath: jsFilePath });
82081             emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo);
82082             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
82083             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit", "emitDeclarationFileOrBundle", { declarationFilePath: declarationFilePath });
82084             emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo);
82085             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
82086             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit", "emitBuildInfo", { buildInfoPath: buildInfoPath });
82087             emitBuildInfo(bundleBuildInfo, buildInfoPath);
82088             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
82089             if (!emitSkipped && emittedFilesList) {
82090                 if (!emitOnlyDtsFiles) {
82091                     if (jsFilePath) {
82092                         emittedFilesList.push(jsFilePath);
82093                     }
82094                     if (sourceMapFilePath) {
82095                         emittedFilesList.push(sourceMapFilePath);
82096                     }
82097                     if (buildInfoPath) {
82098                         emittedFilesList.push(buildInfoPath);
82099                     }
82100                 }
82101                 if (declarationFilePath) {
82102                     emittedFilesList.push(declarationFilePath);
82103                 }
82104                 if (declarationMapPath) {
82105                     emittedFilesList.push(declarationMapPath);
82106                 }
82107             }
82108             function relativeToBuildInfo(path) {
82109                 return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, host.getCanonicalFileName));
82110             }
82111         }
82112         function emitBuildInfo(bundle, buildInfoPath) {
82113             if (!buildInfoPath || targetSourceFile || emitSkipped)
82114                 return;
82115             var program = host.getProgramBuildInfo();
82116             if (host.isEmitBlocked(buildInfoPath)) {
82117                 emitSkipped = true;
82118                 return;
82119             }
82120             var version = ts.version;
82121             ts.writeFile(host, emitterDiagnostics, buildInfoPath, getBuildInfoText({ bundle: bundle, program: program, version: version }), false);
82122         }
82123         function emitJsFileOrBundle(sourceFileOrBundle, jsFilePath, sourceMapFilePath, relativeToBuildInfo) {
82124             if (!sourceFileOrBundle || emitOnlyDtsFiles || !jsFilePath) {
82125                 return;
82126             }
82127             if ((jsFilePath && host.isEmitBlocked(jsFilePath)) || compilerOptions.noEmit) {
82128                 emitSkipped = true;
82129                 return;
82130             }
82131             var transform = ts.transformNodes(resolver, host, ts.factory, compilerOptions, [sourceFileOrBundle], scriptTransformers, false);
82132             var printerOptions = {
82133                 removeComments: compilerOptions.removeComments,
82134                 newLine: compilerOptions.newLine,
82135                 noEmitHelpers: compilerOptions.noEmitHelpers,
82136                 module: compilerOptions.module,
82137                 target: compilerOptions.target,
82138                 sourceMap: compilerOptions.sourceMap,
82139                 inlineSourceMap: compilerOptions.inlineSourceMap,
82140                 inlineSources: compilerOptions.inlineSources,
82141                 extendedDiagnostics: compilerOptions.extendedDiagnostics,
82142                 writeBundleFileInfo: !!bundleBuildInfo,
82143                 relativeToBuildInfo: relativeToBuildInfo
82144             };
82145             var printer = createPrinter(printerOptions, {
82146                 hasGlobalName: resolver.hasGlobalName,
82147                 onEmitNode: transform.emitNodeWithNotification,
82148                 isEmitNotificationEnabled: transform.isEmitNotificationEnabled,
82149                 substituteNode: transform.substituteNode,
82150             });
82151             ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform");
82152             printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions);
82153             transform.dispose();
82154             if (bundleBuildInfo)
82155                 bundleBuildInfo.js = printer.bundleFileInfo;
82156         }
82157         function emitDeclarationFileOrBundle(sourceFileOrBundle, declarationFilePath, declarationMapPath, relativeToBuildInfo) {
82158             if (!sourceFileOrBundle)
82159                 return;
82160             if (!declarationFilePath) {
82161                 if (emitOnlyDtsFiles || compilerOptions.emitDeclarationOnly)
82162                     emitSkipped = true;
82163                 return;
82164             }
82165             var sourceFiles = ts.isSourceFile(sourceFileOrBundle) ? [sourceFileOrBundle] : sourceFileOrBundle.sourceFiles;
82166             var filesForEmit = forceDtsEmit ? sourceFiles : ts.filter(sourceFiles, ts.isSourceFileNotJson);
82167             var inputListOrBundle = ts.outFile(compilerOptions) ? [ts.factory.createBundle(filesForEmit, !ts.isSourceFile(sourceFileOrBundle) ? sourceFileOrBundle.prepends : undefined)] : filesForEmit;
82168             if (emitOnlyDtsFiles && !ts.getEmitDeclarations(compilerOptions)) {
82169                 filesForEmit.forEach(collectLinkedAliases);
82170             }
82171             var declarationTransform = ts.transformNodes(resolver, host, ts.factory, compilerOptions, inputListOrBundle, declarationTransformers, false);
82172             if (ts.length(declarationTransform.diagnostics)) {
82173                 for (var _a = 0, _b = declarationTransform.diagnostics; _a < _b.length; _a++) {
82174                     var diagnostic = _b[_a];
82175                     emitterDiagnostics.add(diagnostic);
82176                 }
82177             }
82178             var printerOptions = {
82179                 removeComments: compilerOptions.removeComments,
82180                 newLine: compilerOptions.newLine,
82181                 noEmitHelpers: true,
82182                 module: compilerOptions.module,
82183                 target: compilerOptions.target,
82184                 sourceMap: compilerOptions.sourceMap,
82185                 inlineSourceMap: compilerOptions.inlineSourceMap,
82186                 extendedDiagnostics: compilerOptions.extendedDiagnostics,
82187                 onlyPrintJsDocStyle: true,
82188                 writeBundleFileInfo: !!bundleBuildInfo,
82189                 recordInternalSection: !!bundleBuildInfo,
82190                 relativeToBuildInfo: relativeToBuildInfo
82191             };
82192             var declarationPrinter = createPrinter(printerOptions, {
82193                 hasGlobalName: resolver.hasGlobalName,
82194                 onEmitNode: declarationTransform.emitNodeWithNotification,
82195                 isEmitNotificationEnabled: declarationTransform.isEmitNotificationEnabled,
82196                 substituteNode: declarationTransform.substituteNode,
82197             });
82198             var declBlocked = (!!declarationTransform.diagnostics && !!declarationTransform.diagnostics.length) || !!host.isEmitBlocked(declarationFilePath) || !!compilerOptions.noEmit;
82199             emitSkipped = emitSkipped || declBlocked;
82200             if (!declBlocked || forceDtsEmit) {
82201                 ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform");
82202                 printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, {
82203                     sourceMap: compilerOptions.declarationMap,
82204                     sourceRoot: compilerOptions.sourceRoot,
82205                     mapRoot: compilerOptions.mapRoot,
82206                     extendedDiagnostics: compilerOptions.extendedDiagnostics,
82207                 });
82208                 if (forceDtsEmit && declarationTransform.transformed[0].kind === 297) {
82209                     var sourceFile = declarationTransform.transformed[0];
82210                     exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit;
82211                 }
82212             }
82213             declarationTransform.dispose();
82214             if (bundleBuildInfo)
82215                 bundleBuildInfo.dts = declarationPrinter.bundleFileInfo;
82216         }
82217         function collectLinkedAliases(node) {
82218             if (ts.isExportAssignment(node)) {
82219                 if (node.expression.kind === 78) {
82220                     resolver.collectLinkedAliases(node.expression, true);
82221                 }
82222                 return;
82223             }
82224             else if (ts.isExportSpecifier(node)) {
82225                 resolver.collectLinkedAliases(node.propertyName || node.name, true);
82226                 return;
82227             }
82228             ts.forEachChild(node, collectLinkedAliases);
82229         }
82230         function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) {
82231             var bundle = sourceFileOrBundle.kind === 298 ? sourceFileOrBundle : undefined;
82232             var sourceFile = sourceFileOrBundle.kind === 297 ? sourceFileOrBundle : undefined;
82233             var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile];
82234             var sourceMapGenerator;
82235             if (shouldEmitSourceMaps(mapOptions, sourceFileOrBundle)) {
82236                 sourceMapGenerator = ts.createSourceMapGenerator(host, ts.getBaseFileName(ts.normalizeSlashes(jsFilePath)), getSourceRoot(mapOptions), getSourceMapDirectory(mapOptions, jsFilePath, sourceFile), mapOptions);
82237             }
82238             if (bundle) {
82239                 printer.writeBundle(bundle, writer, sourceMapGenerator);
82240             }
82241             else {
82242                 printer.writeFile(sourceFile, writer, sourceMapGenerator);
82243             }
82244             if (sourceMapGenerator) {
82245                 if (sourceMapDataList) {
82246                     sourceMapDataList.push({
82247                         inputSourceFileNames: sourceMapGenerator.getSources(),
82248                         sourceMap: sourceMapGenerator.toJSON()
82249                     });
82250                 }
82251                 var sourceMappingURL = getSourceMappingURL(mapOptions, sourceMapGenerator, jsFilePath, sourceMapFilePath, sourceFile);
82252                 if (sourceMappingURL) {
82253                     if (!writer.isAtStartOfLine())
82254                         writer.rawWrite(newLine);
82255                     writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL);
82256                 }
82257                 if (sourceMapFilePath) {
82258                     var sourceMap = sourceMapGenerator.toString();
82259                     ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, false, sourceFiles);
82260                 }
82261             }
82262             else {
82263                 writer.writeLine();
82264             }
82265             ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles);
82266             writer.clear();
82267         }
82268         function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) {
82269             return (mapOptions.sourceMap || mapOptions.inlineSourceMap)
82270                 && (sourceFileOrBundle.kind !== 297 || !ts.fileExtensionIs(sourceFileOrBundle.fileName, ".json"));
82271         }
82272         function getSourceRoot(mapOptions) {
82273             var sourceRoot = ts.normalizeSlashes(mapOptions.sourceRoot || "");
82274             return sourceRoot ? ts.ensureTrailingDirectorySeparator(sourceRoot) : sourceRoot;
82275         }
82276         function getSourceMapDirectory(mapOptions, filePath, sourceFile) {
82277             if (mapOptions.sourceRoot)
82278                 return host.getCommonSourceDirectory();
82279             if (mapOptions.mapRoot) {
82280                 var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot);
82281                 if (sourceFile) {
82282                     sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir));
82283                 }
82284                 if (ts.getRootLength(sourceMapDir) === 0) {
82285                     sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir);
82286                 }
82287                 return sourceMapDir;
82288             }
82289             return ts.getDirectoryPath(ts.normalizePath(filePath));
82290         }
82291         function getSourceMappingURL(mapOptions, sourceMapGenerator, filePath, sourceMapFilePath, sourceFile) {
82292             if (mapOptions.inlineSourceMap) {
82293                 var sourceMapText = sourceMapGenerator.toString();
82294                 var base64SourceMapText = ts.base64encode(ts.sys, sourceMapText);
82295                 return "data:application/json;base64," + base64SourceMapText;
82296             }
82297             var sourceMapFile = ts.getBaseFileName(ts.normalizeSlashes(ts.Debug.checkDefined(sourceMapFilePath)));
82298             if (mapOptions.mapRoot) {
82299                 var sourceMapDir = ts.normalizeSlashes(mapOptions.mapRoot);
82300                 if (sourceFile) {
82301                     sourceMapDir = ts.getDirectoryPath(ts.getSourceFilePathInNewDir(sourceFile.fileName, host, sourceMapDir));
82302                 }
82303                 if (ts.getRootLength(sourceMapDir) === 0) {
82304                     sourceMapDir = ts.combinePaths(host.getCommonSourceDirectory(), sourceMapDir);
82305                     return encodeURI(ts.getRelativePathToDirectoryOrUrl(ts.getDirectoryPath(ts.normalizePath(filePath)), ts.combinePaths(sourceMapDir, sourceMapFile), host.getCurrentDirectory(), host.getCanonicalFileName, true));
82306                 }
82307                 else {
82308                     return encodeURI(ts.combinePaths(sourceMapDir, sourceMapFile));
82309                 }
82310             }
82311             return encodeURI(sourceMapFile);
82312         }
82313     }
82314     ts.emitFiles = emitFiles;
82315     function getBuildInfoText(buildInfo) {
82316         return JSON.stringify(buildInfo, undefined, 2);
82317     }
82318     ts.getBuildInfoText = getBuildInfoText;
82319     function getBuildInfo(buildInfoText) {
82320         return JSON.parse(buildInfoText);
82321     }
82322     ts.getBuildInfo = getBuildInfo;
82323     ts.notImplementedResolver = {
82324         hasGlobalName: ts.notImplemented,
82325         getReferencedExportContainer: ts.notImplemented,
82326         getReferencedImportDeclaration: ts.notImplemented,
82327         getReferencedDeclarationWithCollidingName: ts.notImplemented,
82328         isDeclarationWithCollidingName: ts.notImplemented,
82329         isValueAliasDeclaration: ts.notImplemented,
82330         isReferencedAliasDeclaration: ts.notImplemented,
82331         isTopLevelValueImportEqualsWithEntityName: ts.notImplemented,
82332         getNodeCheckFlags: ts.notImplemented,
82333         isDeclarationVisible: ts.notImplemented,
82334         isLateBound: function (_node) { return false; },
82335         collectLinkedAliases: ts.notImplemented,
82336         isImplementationOfOverload: ts.notImplemented,
82337         isRequiredInitializedParameter: ts.notImplemented,
82338         isOptionalUninitializedParameterProperty: ts.notImplemented,
82339         isExpandoFunctionDeclaration: ts.notImplemented,
82340         getPropertiesOfContainerFunction: ts.notImplemented,
82341         createTypeOfDeclaration: ts.notImplemented,
82342         createReturnTypeOfSignatureDeclaration: ts.notImplemented,
82343         createTypeOfExpression: ts.notImplemented,
82344         createLiteralConstValue: ts.notImplemented,
82345         isSymbolAccessible: ts.notImplemented,
82346         isEntityNameVisible: ts.notImplemented,
82347         getConstantValue: ts.notImplemented,
82348         getReferencedValueDeclaration: ts.notImplemented,
82349         getTypeReferenceSerializationKind: ts.notImplemented,
82350         isOptionalParameter: ts.notImplemented,
82351         moduleExportsSomeValue: ts.notImplemented,
82352         isArgumentsLocalBinding: ts.notImplemented,
82353         getExternalModuleFileFromDeclaration: ts.notImplemented,
82354         getTypeReferenceDirectivesForEntityName: ts.notImplemented,
82355         getTypeReferenceDirectivesForSymbol: ts.notImplemented,
82356         isLiteralConstDeclaration: ts.notImplemented,
82357         getJsxFactoryEntity: ts.notImplemented,
82358         getJsxFragmentFactoryEntity: ts.notImplemented,
82359         getAllAccessorDeclarations: ts.notImplemented,
82360         getSymbolOfExternalModuleSpecifier: ts.notImplemented,
82361         isBindingCapturedByNode: ts.notImplemented,
82362         getDeclarationStatementsForSourceFile: ts.notImplemented,
82363         isImportRequiredByAugmentation: ts.notImplemented,
82364     };
82365     function createSourceFilesFromBundleBuildInfo(bundle, buildInfoDirectory, host) {
82366         var _a;
82367         var jsBundle = ts.Debug.checkDefined(bundle.js);
82368         var prologueMap = ((_a = jsBundle.sources) === null || _a === void 0 ? void 0 : _a.prologues) && ts.arrayToMap(jsBundle.sources.prologues, function (prologueInfo) { return prologueInfo.file; });
82369         return bundle.sourceFiles.map(function (fileName, index) {
82370             var _a, _b;
82371             var prologueInfo = prologueMap === null || prologueMap === void 0 ? void 0 : prologueMap.get(index);
82372             var statements = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.directives.map(function (directive) {
82373                 var literal = ts.setTextRange(ts.factory.createStringLiteral(directive.expression.text), directive.expression);
82374                 var statement = ts.setTextRange(ts.factory.createExpressionStatement(literal), directive);
82375                 ts.setParent(literal, statement);
82376                 return statement;
82377             });
82378             var eofToken = ts.factory.createToken(1);
82379             var sourceFile = ts.factory.createSourceFile(statements !== null && statements !== void 0 ? statements : [], eofToken, 0);
82380             sourceFile.fileName = ts.getRelativePathFromDirectory(host.getCurrentDirectory(), ts.getNormalizedAbsolutePath(fileName, buildInfoDirectory), !host.useCaseSensitiveFileNames());
82381             sourceFile.text = (_a = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text) !== null && _a !== void 0 ? _a : "";
82382             ts.setTextRangePosWidth(sourceFile, 0, (_b = prologueInfo === null || prologueInfo === void 0 ? void 0 : prologueInfo.text.length) !== null && _b !== void 0 ? _b : 0);
82383             ts.setEachParent(sourceFile.statements, sourceFile);
82384             ts.setTextRangePosWidth(eofToken, sourceFile.end, 0);
82385             ts.setParent(eofToken, sourceFile);
82386             return sourceFile;
82387         });
82388     }
82389     function emitUsingBuildInfo(config, host, getCommandLine, customTransformers) {
82390         var _a = getOutputPathsForBundle(config.options, false), buildInfoPath = _a.buildInfoPath, jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath;
82391         var buildInfoText = host.readFile(ts.Debug.checkDefined(buildInfoPath));
82392         if (!buildInfoText)
82393             return buildInfoPath;
82394         var jsFileText = host.readFile(ts.Debug.checkDefined(jsFilePath));
82395         if (!jsFileText)
82396             return jsFilePath;
82397         var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
82398         if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
82399             return sourceMapFilePath || "inline sourcemap decoding";
82400         var declarationText = declarationFilePath && host.readFile(declarationFilePath);
82401         if (declarationFilePath && !declarationText)
82402             return declarationFilePath;
82403         var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
82404         if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
82405             return declarationMapPath || "inline sourcemap decoding";
82406         var buildInfo = getBuildInfo(buildInfoText);
82407         if (!buildInfo.bundle || !buildInfo.bundle.js || (declarationText && !buildInfo.bundle.dts))
82408             return buildInfoPath;
82409         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
82410         var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo, true);
82411         var outputFiles = [];
82412         var prependNodes = ts.createPrependNodes(config.projectReferences, getCommandLine, function (f) { return host.readFile(f); });
82413         var sourceFilesForJsEmit = createSourceFilesFromBundleBuildInfo(buildInfo.bundle, buildInfoDirectory, host);
82414         var emitHost = {
82415             getPrependNodes: ts.memoize(function () { return __spreadArray(__spreadArray([], prependNodes), [ownPrependInput]); }),
82416             getCanonicalFileName: host.getCanonicalFileName,
82417             getCommonSourceDirectory: function () { return ts.getNormalizedAbsolutePath(buildInfo.bundle.commonSourceDirectory, buildInfoDirectory); },
82418             getCompilerOptions: function () { return config.options; },
82419             getCurrentDirectory: function () { return host.getCurrentDirectory(); },
82420             getNewLine: function () { return host.getNewLine(); },
82421             getSourceFile: ts.returnUndefined,
82422             getSourceFileByPath: ts.returnUndefined,
82423             getSourceFiles: function () { return sourceFilesForJsEmit; },
82424             getLibFileFromReference: ts.notImplemented,
82425             isSourceFileFromExternalLibrary: ts.returnFalse,
82426             getResolvedProjectReferenceToRedirect: ts.returnUndefined,
82427             getProjectReferenceRedirect: ts.returnUndefined,
82428             isSourceOfProjectReferenceRedirect: ts.returnFalse,
82429             writeFile: function (name, text, writeByteOrderMark) {
82430                 switch (name) {
82431                     case jsFilePath:
82432                         if (jsFileText === text)
82433                             return;
82434                         break;
82435                     case sourceMapFilePath:
82436                         if (sourceMapText === text)
82437                             return;
82438                         break;
82439                     case buildInfoPath:
82440                         var newBuildInfo = getBuildInfo(text);
82441                         newBuildInfo.program = buildInfo.program;
82442                         var _a = buildInfo.bundle, js = _a.js, dts = _a.dts, sourceFiles = _a.sourceFiles;
82443                         newBuildInfo.bundle.js.sources = js.sources;
82444                         if (dts) {
82445                             newBuildInfo.bundle.dts.sources = dts.sources;
82446                         }
82447                         newBuildInfo.bundle.sourceFiles = sourceFiles;
82448                         outputFiles.push({ name: name, text: getBuildInfoText(newBuildInfo), writeByteOrderMark: writeByteOrderMark });
82449                         return;
82450                     case declarationFilePath:
82451                         if (declarationText === text)
82452                             return;
82453                         break;
82454                     case declarationMapPath:
82455                         if (declarationMapText === text)
82456                             return;
82457                         break;
82458                     default:
82459                         ts.Debug.fail("Unexpected path: " + name);
82460                 }
82461                 outputFiles.push({ name: name, text: text, writeByteOrderMark: writeByteOrderMark });
82462             },
82463             isEmitBlocked: ts.returnFalse,
82464             readFile: function (f) { return host.readFile(f); },
82465             fileExists: function (f) { return host.fileExists(f); },
82466             useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
82467             getProgramBuildInfo: ts.returnUndefined,
82468             getSourceFileFromReference: ts.returnUndefined,
82469             redirectTargetsMap: ts.createMultiMap(),
82470             getFileIncludeReasons: ts.notImplemented,
82471         };
82472         emitFiles(ts.notImplementedResolver, emitHost, undefined, ts.getTransformers(config.options, customTransformers));
82473         return outputFiles;
82474     }
82475     ts.emitUsingBuildInfo = emitUsingBuildInfo;
82476     function createPrinter(printerOptions, handlers) {
82477         if (printerOptions === void 0) { printerOptions = {}; }
82478         if (handlers === void 0) { handlers = {}; }
82479         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;
82480         var extendedDiagnostics = !!printerOptions.extendedDiagnostics;
82481         var newLine = ts.getNewLineCharacter(printerOptions);
82482         var moduleKind = ts.getEmitModuleKind(printerOptions);
82483         var bundledHelpers = new ts.Map();
82484         var currentSourceFile;
82485         var nodeIdToGeneratedName;
82486         var autoGeneratedIdToGeneratedName;
82487         var generatedNames;
82488         var tempFlagsStack;
82489         var tempFlags;
82490         var reservedNamesStack;
82491         var reservedNames;
82492         var preserveSourceNewlines = printerOptions.preserveSourceNewlines;
82493         var nextListElementPos;
82494         var writer;
82495         var ownWriter;
82496         var write = writeBase;
82497         var isOwnFileEmit;
82498         var bundleFileInfo = printerOptions.writeBundleFileInfo ? { sections: [] } : undefined;
82499         var relativeToBuildInfo = bundleFileInfo ? ts.Debug.checkDefined(printerOptions.relativeToBuildInfo) : undefined;
82500         var recordInternalSection = printerOptions.recordInternalSection;
82501         var sourceFileTextPos = 0;
82502         var sourceFileTextKind = "text";
82503         var sourceMapsDisabled = true;
82504         var sourceMapGenerator;
82505         var sourceMapSource;
82506         var sourceMapSourceIndex = -1;
82507         var mostRecentlyAddedSourceMapSource;
82508         var mostRecentlyAddedSourceMapSourceIndex = -1;
82509         var containerPos = -1;
82510         var containerEnd = -1;
82511         var declarationListContainerEnd = -1;
82512         var currentLineMap;
82513         var detachedCommentsInfo;
82514         var hasWrittenComment = false;
82515         var commentsDisabled = !!printerOptions.removeComments;
82516         var lastNode;
82517         var lastSubstitution;
82518         var _c = ts.performance.createTimerIf(extendedDiagnostics, "commentTime", "beforeComment", "afterComment"), enterComment = _c.enter, exitComment = _c.exit;
82519         reset();
82520         return {
82521             printNode: printNode,
82522             printList: printList,
82523             printFile: printFile,
82524             printBundle: printBundle,
82525             writeNode: writeNode,
82526             writeList: writeList,
82527             writeFile: writeFile,
82528             writeBundle: writeBundle,
82529             bundleFileInfo: bundleFileInfo
82530         };
82531         function printNode(hint, node, sourceFile) {
82532             switch (hint) {
82533                 case 0:
82534                     ts.Debug.assert(ts.isSourceFile(node), "Expected a SourceFile node.");
82535                     break;
82536                 case 2:
82537                     ts.Debug.assert(ts.isIdentifier(node), "Expected an Identifier node.");
82538                     break;
82539                 case 1:
82540                     ts.Debug.assert(ts.isExpression(node), "Expected an Expression node.");
82541                     break;
82542             }
82543             switch (node.kind) {
82544                 case 297: return printFile(node);
82545                 case 298: return printBundle(node);
82546                 case 299: return printUnparsedSource(node);
82547             }
82548             writeNode(hint, node, sourceFile, beginPrint());
82549             return endPrint();
82550         }
82551         function printList(format, nodes, sourceFile) {
82552             writeList(format, nodes, sourceFile, beginPrint());
82553             return endPrint();
82554         }
82555         function printBundle(bundle) {
82556             writeBundle(bundle, beginPrint(), undefined);
82557             return endPrint();
82558         }
82559         function printFile(sourceFile) {
82560             writeFile(sourceFile, beginPrint(), undefined);
82561             return endPrint();
82562         }
82563         function printUnparsedSource(unparsed) {
82564             writeUnparsedSource(unparsed, beginPrint());
82565             return endPrint();
82566         }
82567         function writeNode(hint, node, sourceFile, output) {
82568             var previousWriter = writer;
82569             setWriter(output, undefined);
82570             print(hint, node, sourceFile);
82571             reset();
82572             writer = previousWriter;
82573         }
82574         function writeList(format, nodes, sourceFile, output) {
82575             var previousWriter = writer;
82576             setWriter(output, undefined);
82577             if (sourceFile) {
82578                 setSourceFile(sourceFile);
82579             }
82580             emitList(syntheticParent, nodes, format);
82581             reset();
82582             writer = previousWriter;
82583         }
82584         function getTextPosWithWriteLine() {
82585             return writer.getTextPosWithWriteLine ? writer.getTextPosWithWriteLine() : writer.getTextPos();
82586         }
82587         function updateOrPushBundleFileTextLike(pos, end, kind) {
82588             var last = ts.lastOrUndefined(bundleFileInfo.sections);
82589             if (last && last.kind === kind) {
82590                 last.end = end;
82591             }
82592             else {
82593                 bundleFileInfo.sections.push({ pos: pos, end: end, kind: kind });
82594             }
82595         }
82596         function recordBundleFileInternalSectionStart(node) {
82597             if (recordInternalSection &&
82598                 bundleFileInfo &&
82599                 currentSourceFile &&
82600                 (ts.isDeclaration(node) || ts.isVariableStatement(node)) &&
82601                 ts.isInternalDeclaration(node, currentSourceFile) &&
82602                 sourceFileTextKind !== "internal") {
82603                 var prevSourceFileTextKind = sourceFileTextKind;
82604                 recordBundleFileTextLikeSection(writer.getTextPos());
82605                 sourceFileTextPos = getTextPosWithWriteLine();
82606                 sourceFileTextKind = "internal";
82607                 return prevSourceFileTextKind;
82608             }
82609             return undefined;
82610         }
82611         function recordBundleFileInternalSectionEnd(prevSourceFileTextKind) {
82612             if (prevSourceFileTextKind) {
82613                 recordBundleFileTextLikeSection(writer.getTextPos());
82614                 sourceFileTextPos = getTextPosWithWriteLine();
82615                 sourceFileTextKind = prevSourceFileTextKind;
82616             }
82617         }
82618         function recordBundleFileTextLikeSection(end) {
82619             if (sourceFileTextPos < end) {
82620                 updateOrPushBundleFileTextLike(sourceFileTextPos, end, sourceFileTextKind);
82621                 return true;
82622             }
82623             return false;
82624         }
82625         function writeBundle(bundle, output, sourceMapGenerator) {
82626             var _a;
82627             isOwnFileEmit = false;
82628             var previousWriter = writer;
82629             setWriter(output, sourceMapGenerator);
82630             emitShebangIfNeeded(bundle);
82631             emitPrologueDirectivesIfNeeded(bundle);
82632             emitHelpers(bundle);
82633             emitSyntheticTripleSlashReferencesIfNeeded(bundle);
82634             for (var _b = 0, _c = bundle.prepends; _b < _c.length; _b++) {
82635                 var prepend = _c[_b];
82636                 writeLine();
82637                 var pos = writer.getTextPos();
82638                 var savedSections = bundleFileInfo && bundleFileInfo.sections;
82639                 if (savedSections)
82640                     bundleFileInfo.sections = [];
82641                 print(4, prepend, undefined);
82642                 if (bundleFileInfo) {
82643                     var newSections = bundleFileInfo.sections;
82644                     bundleFileInfo.sections = savedSections;
82645                     if (prepend.oldFileOfCurrentEmit)
82646                         (_a = bundleFileInfo.sections).push.apply(_a, newSections);
82647                     else {
82648                         newSections.forEach(function (section) { return ts.Debug.assert(ts.isBundleFileTextLike(section)); });
82649                         bundleFileInfo.sections.push({
82650                             pos: pos,
82651                             end: writer.getTextPos(),
82652                             kind: "prepend",
82653                             data: relativeToBuildInfo(prepend.fileName),
82654                             texts: newSections
82655                         });
82656                     }
82657                 }
82658             }
82659             sourceFileTextPos = getTextPosWithWriteLine();
82660             for (var _d = 0, _e = bundle.sourceFiles; _d < _e.length; _d++) {
82661                 var sourceFile = _e[_d];
82662                 print(0, sourceFile, sourceFile);
82663             }
82664             if (bundleFileInfo && bundle.sourceFiles.length) {
82665                 var end = writer.getTextPos();
82666                 if (recordBundleFileTextLikeSection(end)) {
82667                     var prologues = getPrologueDirectivesFromBundledSourceFiles(bundle);
82668                     if (prologues) {
82669                         if (!bundleFileInfo.sources)
82670                             bundleFileInfo.sources = {};
82671                         bundleFileInfo.sources.prologues = prologues;
82672                     }
82673                     var helpers = getHelpersFromBundledSourceFiles(bundle);
82674                     if (helpers) {
82675                         if (!bundleFileInfo.sources)
82676                             bundleFileInfo.sources = {};
82677                         bundleFileInfo.sources.helpers = helpers;
82678                     }
82679                 }
82680             }
82681             reset();
82682             writer = previousWriter;
82683         }
82684         function writeUnparsedSource(unparsed, output) {
82685             var previousWriter = writer;
82686             setWriter(output, undefined);
82687             print(4, unparsed, undefined);
82688             reset();
82689             writer = previousWriter;
82690         }
82691         function writeFile(sourceFile, output, sourceMapGenerator) {
82692             isOwnFileEmit = true;
82693             var previousWriter = writer;
82694             setWriter(output, sourceMapGenerator);
82695             emitShebangIfNeeded(sourceFile);
82696             emitPrologueDirectivesIfNeeded(sourceFile);
82697             print(0, sourceFile, sourceFile);
82698             reset();
82699             writer = previousWriter;
82700         }
82701         function beginPrint() {
82702             return ownWriter || (ownWriter = ts.createTextWriter(newLine));
82703         }
82704         function endPrint() {
82705             var text = ownWriter.getText();
82706             ownWriter.clear();
82707             return text;
82708         }
82709         function print(hint, node, sourceFile) {
82710             if (sourceFile) {
82711                 setSourceFile(sourceFile);
82712             }
82713             pipelineEmit(hint, node);
82714         }
82715         function setSourceFile(sourceFile) {
82716             currentSourceFile = sourceFile;
82717             currentLineMap = undefined;
82718             detachedCommentsInfo = undefined;
82719             if (sourceFile) {
82720                 setSourceMapSource(sourceFile);
82721             }
82722         }
82723         function setWriter(_writer, _sourceMapGenerator) {
82724             if (_writer && printerOptions.omitTrailingSemicolon) {
82725                 _writer = ts.getTrailingSemicolonDeferringWriter(_writer);
82726             }
82727             writer = _writer;
82728             sourceMapGenerator = _sourceMapGenerator;
82729             sourceMapsDisabled = !writer || !sourceMapGenerator;
82730         }
82731         function reset() {
82732             nodeIdToGeneratedName = [];
82733             autoGeneratedIdToGeneratedName = [];
82734             generatedNames = new ts.Set();
82735             tempFlagsStack = [];
82736             tempFlags = 0;
82737             reservedNamesStack = [];
82738             currentSourceFile = undefined;
82739             currentLineMap = undefined;
82740             detachedCommentsInfo = undefined;
82741             lastNode = undefined;
82742             lastSubstitution = undefined;
82743             setWriter(undefined, undefined);
82744         }
82745         function getCurrentLineMap() {
82746             return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile));
82747         }
82748         function emit(node) {
82749             if (node === undefined)
82750                 return;
82751             var prevSourceFileTextKind = recordBundleFileInternalSectionStart(node);
82752             var substitute = pipelineEmit(4, node);
82753             recordBundleFileInternalSectionEnd(prevSourceFileTextKind);
82754             return substitute;
82755         }
82756         function emitIdentifierName(node) {
82757             if (node === undefined)
82758                 return;
82759             return pipelineEmit(2, node);
82760         }
82761         function emitExpression(node) {
82762             if (node === undefined)
82763                 return;
82764             return pipelineEmit(1, node);
82765         }
82766         function emitJsxAttributeValue(node) {
82767             return pipelineEmit(ts.isStringLiteral(node) ? 6 : 4, node);
82768         }
82769         function pipelineEmit(emitHint, node) {
82770             var savedLastNode = lastNode;
82771             var savedLastSubstitution = lastSubstitution;
82772             var savedPreserveSourceNewlines = preserveSourceNewlines;
82773             lastNode = node;
82774             lastSubstitution = undefined;
82775             if (preserveSourceNewlines && !!(ts.getEmitFlags(node) & 134217728)) {
82776                 preserveSourceNewlines = false;
82777             }
82778             var pipelinePhase = getPipelinePhase(0, emitHint, node);
82779             pipelinePhase(emitHint, node);
82780             ts.Debug.assert(lastNode === node);
82781             var substitute = lastSubstitution;
82782             lastNode = savedLastNode;
82783             lastSubstitution = savedLastSubstitution;
82784             preserveSourceNewlines = savedPreserveSourceNewlines;
82785             return substitute || node;
82786         }
82787         function getPipelinePhase(phase, emitHint, node) {
82788             switch (phase) {
82789                 case 0:
82790                     if (onEmitNode !== ts.noEmitNotification && (!isEmitNotificationEnabled || isEmitNotificationEnabled(node))) {
82791                         return pipelineEmitWithNotification;
82792                     }
82793                 case 1:
82794                     if (substituteNode !== ts.noEmitSubstitution && (lastSubstitution = substituteNode(emitHint, node)) !== node) {
82795                         return pipelineEmitWithSubstitution;
82796                     }
82797                 case 2:
82798                     if (!commentsDisabled && node.kind !== 297) {
82799                         return pipelineEmitWithComments;
82800                     }
82801                 case 3:
82802                     if (!sourceMapsDisabled && node.kind !== 297 && !ts.isInJsonFile(node)) {
82803                         return pipelineEmitWithSourceMap;
82804                     }
82805                 case 4:
82806                     return pipelineEmitWithHint;
82807                 default:
82808                     return ts.Debug.assertNever(phase);
82809             }
82810         }
82811         function getNextPipelinePhase(currentPhase, emitHint, node) {
82812             return getPipelinePhase(currentPhase + 1, emitHint, node);
82813         }
82814         function pipelineEmitWithNotification(hint, node) {
82815             ts.Debug.assert(lastNode === node);
82816             var pipelinePhase = getNextPipelinePhase(0, hint, node);
82817             onEmitNode(hint, node, pipelinePhase);
82818             ts.Debug.assert(lastNode === node);
82819         }
82820         function pipelineEmitWithHint(hint, node) {
82821             ts.Debug.assert(lastNode === node || lastSubstitution === node);
82822             if (hint === 0)
82823                 return emitSourceFile(ts.cast(node, ts.isSourceFile));
82824             if (hint === 2)
82825                 return emitIdentifier(ts.cast(node, ts.isIdentifier));
82826             if (hint === 6)
82827                 return emitLiteral(ts.cast(node, ts.isStringLiteral), true);
82828             if (hint === 3)
82829                 return emitMappedTypeParameter(ts.cast(node, ts.isTypeParameterDeclaration));
82830             if (hint === 5) {
82831                 ts.Debug.assertNode(node, ts.isEmptyStatement);
82832                 return emitEmptyStatement(true);
82833             }
82834             if (hint === 4) {
82835                 if (ts.isKeyword(node.kind))
82836                     return writeTokenNode(node, writeKeyword);
82837                 switch (node.kind) {
82838                     case 15:
82839                     case 16:
82840                     case 17:
82841                         return emitLiteral(node, false);
82842                     case 299:
82843                     case 293:
82844                         return emitUnparsedSourceOrPrepend(node);
82845                     case 292:
82846                         return writeUnparsedNode(node);
82847                     case 294:
82848                     case 295:
82849                         return emitUnparsedTextLike(node);
82850                     case 296:
82851                         return emitUnparsedSyntheticReference(node);
82852                     case 78:
82853                         return emitIdentifier(node);
82854                     case 79:
82855                         return emitPrivateIdentifier(node);
82856                     case 157:
82857                         return emitQualifiedName(node);
82858                     case 158:
82859                         return emitComputedPropertyName(node);
82860                     case 159:
82861                         return emitTypeParameter(node);
82862                     case 160:
82863                         return emitParameter(node);
82864                     case 161:
82865                         return emitDecorator(node);
82866                     case 162:
82867                         return emitPropertySignature(node);
82868                     case 163:
82869                         return emitPropertyDeclaration(node);
82870                     case 164:
82871                         return emitMethodSignature(node);
82872                     case 165:
82873                         return emitMethodDeclaration(node);
82874                     case 166:
82875                         return emitConstructor(node);
82876                     case 167:
82877                     case 168:
82878                         return emitAccessorDeclaration(node);
82879                     case 169:
82880                         return emitCallSignature(node);
82881                     case 170:
82882                         return emitConstructSignature(node);
82883                     case 171:
82884                         return emitIndexSignature(node);
82885                     case 194:
82886                         return emitTemplateTypeSpan(node);
82887                     case 172:
82888                         return emitTypePredicate(node);
82889                     case 173:
82890                         return emitTypeReference(node);
82891                     case 174:
82892                         return emitFunctionType(node);
82893                     case 308:
82894                         return emitJSDocFunctionType(node);
82895                     case 175:
82896                         return emitConstructorType(node);
82897                     case 176:
82898                         return emitTypeQuery(node);
82899                     case 177:
82900                         return emitTypeLiteral(node);
82901                     case 178:
82902                         return emitArrayType(node);
82903                     case 179:
82904                         return emitTupleType(node);
82905                     case 180:
82906                         return emitOptionalType(node);
82907                     case 182:
82908                         return emitUnionType(node);
82909                     case 183:
82910                         return emitIntersectionType(node);
82911                     case 184:
82912                         return emitConditionalType(node);
82913                     case 185:
82914                         return emitInferType(node);
82915                     case 186:
82916                         return emitParenthesizedType(node);
82917                     case 223:
82918                         return emitExpressionWithTypeArguments(node);
82919                     case 187:
82920                         return emitThisType();
82921                     case 188:
82922                         return emitTypeOperator(node);
82923                     case 189:
82924                         return emitIndexedAccessType(node);
82925                     case 190:
82926                         return emitMappedType(node);
82927                     case 191:
82928                         return emitLiteralType(node);
82929                     case 193:
82930                         return emitTemplateType(node);
82931                     case 195:
82932                         return emitImportTypeNode(node);
82933                     case 303:
82934                         writePunctuation("*");
82935                         return;
82936                     case 304:
82937                         writePunctuation("?");
82938                         return;
82939                     case 305:
82940                         return emitJSDocNullableType(node);
82941                     case 306:
82942                         return emitJSDocNonNullableType(node);
82943                     case 307:
82944                         return emitJSDocOptionalType(node);
82945                     case 181:
82946                     case 309:
82947                         return emitRestOrJSDocVariadicType(node);
82948                     case 192:
82949                         return emitNamedTupleMember(node);
82950                     case 196:
82951                         return emitObjectBindingPattern(node);
82952                     case 197:
82953                         return emitArrayBindingPattern(node);
82954                     case 198:
82955                         return emitBindingElement(node);
82956                     case 228:
82957                         return emitTemplateSpan(node);
82958                     case 229:
82959                         return emitSemicolonClassElement();
82960                     case 230:
82961                         return emitBlock(node);
82962                     case 232:
82963                         return emitVariableStatement(node);
82964                     case 231:
82965                         return emitEmptyStatement(false);
82966                     case 233:
82967                         return emitExpressionStatement(node);
82968                     case 234:
82969                         return emitIfStatement(node);
82970                     case 235:
82971                         return emitDoStatement(node);
82972                     case 236:
82973                         return emitWhileStatement(node);
82974                     case 237:
82975                         return emitForStatement(node);
82976                     case 238:
82977                         return emitForInStatement(node);
82978                     case 239:
82979                         return emitForOfStatement(node);
82980                     case 240:
82981                         return emitContinueStatement(node);
82982                     case 241:
82983                         return emitBreakStatement(node);
82984                     case 242:
82985                         return emitReturnStatement(node);
82986                     case 243:
82987                         return emitWithStatement(node);
82988                     case 244:
82989                         return emitSwitchStatement(node);
82990                     case 245:
82991                         return emitLabeledStatement(node);
82992                     case 246:
82993                         return emitThrowStatement(node);
82994                     case 247:
82995                         return emitTryStatement(node);
82996                     case 248:
82997                         return emitDebuggerStatement(node);
82998                     case 249:
82999                         return emitVariableDeclaration(node);
83000                     case 250:
83001                         return emitVariableDeclarationList(node);
83002                     case 251:
83003                         return emitFunctionDeclaration(node);
83004                     case 252:
83005                         return emitClassDeclaration(node);
83006                     case 253:
83007                         return emitInterfaceDeclaration(node);
83008                     case 254:
83009                         return emitTypeAliasDeclaration(node);
83010                     case 255:
83011                         return emitEnumDeclaration(node);
83012                     case 256:
83013                         return emitModuleDeclaration(node);
83014                     case 257:
83015                         return emitModuleBlock(node);
83016                     case 258:
83017                         return emitCaseBlock(node);
83018                     case 259:
83019                         return emitNamespaceExportDeclaration(node);
83020                     case 260:
83021                         return emitImportEqualsDeclaration(node);
83022                     case 261:
83023                         return emitImportDeclaration(node);
83024                     case 262:
83025                         return emitImportClause(node);
83026                     case 263:
83027                         return emitNamespaceImport(node);
83028                     case 269:
83029                         return emitNamespaceExport(node);
83030                     case 264:
83031                         return emitNamedImports(node);
83032                     case 265:
83033                         return emitImportSpecifier(node);
83034                     case 266:
83035                         return emitExportAssignment(node);
83036                     case 267:
83037                         return emitExportDeclaration(node);
83038                     case 268:
83039                         return emitNamedExports(node);
83040                     case 270:
83041                         return emitExportSpecifier(node);
83042                     case 271:
83043                         return;
83044                     case 272:
83045                         return emitExternalModuleReference(node);
83046                     case 11:
83047                         return emitJsxText(node);
83048                     case 275:
83049                     case 278:
83050                         return emitJsxOpeningElementOrFragment(node);
83051                     case 276:
83052                     case 279:
83053                         return emitJsxClosingElementOrFragment(node);
83054                     case 280:
83055                         return emitJsxAttribute(node);
83056                     case 281:
83057                         return emitJsxAttributes(node);
83058                     case 282:
83059                         return emitJsxSpreadAttribute(node);
83060                     case 283:
83061                         return emitJsxExpression(node);
83062                     case 284:
83063                         return emitCaseClause(node);
83064                     case 285:
83065                         return emitDefaultClause(node);
83066                     case 286:
83067                         return emitHeritageClause(node);
83068                     case 287:
83069                         return emitCatchClause(node);
83070                     case 288:
83071                         return emitPropertyAssignment(node);
83072                     case 289:
83073                         return emitShorthandPropertyAssignment(node);
83074                     case 290:
83075                         return emitSpreadAssignment(node);
83076                     case 291:
83077                         return emitEnumMember(node);
83078                     case 326:
83079                     case 333:
83080                         return emitJSDocPropertyLikeTag(node);
83081                     case 327:
83082                     case 329:
83083                     case 328:
83084                     case 325:
83085                         return emitJSDocSimpleTypedTag(node);
83086                     case 316:
83087                     case 315:
83088                         return emitJSDocHeritageTag(node);
83089                     case 330:
83090                         return emitJSDocTemplateTag(node);
83091                     case 331:
83092                         return emitJSDocTypedefTag(node);
83093                     case 324:
83094                         return emitJSDocCallbackTag(node);
83095                     case 313:
83096                         return emitJSDocSignature(node);
83097                     case 312:
83098                         return emitJSDocTypeLiteral(node);
83099                     case 319:
83100                     case 314:
83101                         return emitJSDocSimpleTag(node);
83102                     case 332:
83103                         return emitJSDocSeeTag(node);
83104                     case 302:
83105                         return emitJSDocNameReference(node);
83106                     case 311:
83107                         return emitJSDoc(node);
83108                 }
83109                 if (ts.isExpression(node)) {
83110                     hint = 1;
83111                     if (substituteNode !== ts.noEmitSubstitution) {
83112                         lastSubstitution = node = substituteNode(hint, node);
83113                     }
83114                 }
83115                 else if (ts.isToken(node)) {
83116                     return writeTokenNode(node, writePunctuation);
83117                 }
83118             }
83119             if (hint === 1) {
83120                 switch (node.kind) {
83121                     case 8:
83122                     case 9:
83123                         return emitNumericOrBigIntLiteral(node);
83124                     case 10:
83125                     case 13:
83126                     case 14:
83127                         return emitLiteral(node, false);
83128                     case 78:
83129                         return emitIdentifier(node);
83130                     case 94:
83131                     case 103:
83132                     case 105:
83133                     case 109:
83134                     case 107:
83135                     case 99:
83136                         writeTokenNode(node, writeKeyword);
83137                         return;
83138                     case 199:
83139                         return emitArrayLiteralExpression(node);
83140                     case 200:
83141                         return emitObjectLiteralExpression(node);
83142                     case 201:
83143                         return emitPropertyAccessExpression(node);
83144                     case 202:
83145                         return emitElementAccessExpression(node);
83146                     case 203:
83147                         return emitCallExpression(node);
83148                     case 204:
83149                         return emitNewExpression(node);
83150                     case 205:
83151                         return emitTaggedTemplateExpression(node);
83152                     case 206:
83153                         return emitTypeAssertionExpression(node);
83154                     case 207:
83155                         return emitParenthesizedExpression(node);
83156                     case 208:
83157                         return emitFunctionExpression(node);
83158                     case 209:
83159                         return emitArrowFunction(node);
83160                     case 210:
83161                         return emitDeleteExpression(node);
83162                     case 211:
83163                         return emitTypeOfExpression(node);
83164                     case 212:
83165                         return emitVoidExpression(node);
83166                     case 213:
83167                         return emitAwaitExpression(node);
83168                     case 214:
83169                         return emitPrefixUnaryExpression(node);
83170                     case 215:
83171                         return emitPostfixUnaryExpression(node);
83172                     case 216:
83173                         return emitBinaryExpression(node);
83174                     case 217:
83175                         return emitConditionalExpression(node);
83176                     case 218:
83177                         return emitTemplateExpression(node);
83178                     case 219:
83179                         return emitYieldExpression(node);
83180                     case 220:
83181                         return emitSpreadExpression(node);
83182                     case 221:
83183                         return emitClassExpression(node);
83184                     case 222:
83185                         return;
83186                     case 224:
83187                         return emitAsExpression(node);
83188                     case 225:
83189                         return emitNonNullExpression(node);
83190                     case 226:
83191                         return emitMetaProperty(node);
83192                     case 273:
83193                         return emitJsxElement(node);
83194                     case 274:
83195                         return emitJsxSelfClosingElement(node);
83196                     case 277:
83197                         return emitJsxFragment(node);
83198                     case 336:
83199                         return emitPartiallyEmittedExpression(node);
83200                     case 337:
83201                         return emitCommaList(node);
83202                 }
83203             }
83204         }
83205         function emitMappedTypeParameter(node) {
83206             emit(node.name);
83207             writeSpace();
83208             writeKeyword("in");
83209             writeSpace();
83210             emit(node.constraint);
83211         }
83212         function pipelineEmitWithSubstitution(hint, node) {
83213             ts.Debug.assert(lastNode === node || lastSubstitution === node);
83214             var pipelinePhase = getNextPipelinePhase(1, hint, node);
83215             pipelinePhase(hint, lastSubstitution);
83216             ts.Debug.assert(lastNode === node || lastSubstitution === node);
83217         }
83218         function getHelpersFromBundledSourceFiles(bundle) {
83219             var result;
83220             if (moduleKind === ts.ModuleKind.None || printerOptions.noEmitHelpers) {
83221                 return undefined;
83222             }
83223             var bundledHelpers = new ts.Map();
83224             for (var _a = 0, _b = bundle.sourceFiles; _a < _b.length; _a++) {
83225                 var sourceFile = _b[_a];
83226                 var shouldSkip = ts.getExternalHelpersModuleName(sourceFile) !== undefined;
83227                 var helpers = getSortedEmitHelpers(sourceFile);
83228                 if (!helpers)
83229                     continue;
83230                 for (var _c = 0, helpers_5 = helpers; _c < helpers_5.length; _c++) {
83231                     var helper = helpers_5[_c];
83232                     if (!helper.scoped && !shouldSkip && !bundledHelpers.get(helper.name)) {
83233                         bundledHelpers.set(helper.name, true);
83234                         (result || (result = [])).push(helper.name);
83235                     }
83236                 }
83237             }
83238             return result;
83239         }
83240         function emitHelpers(node) {
83241             var helpersEmitted = false;
83242             var bundle = node.kind === 298 ? node : undefined;
83243             if (bundle && moduleKind === ts.ModuleKind.None) {
83244                 return;
83245             }
83246             var numPrepends = bundle ? bundle.prepends.length : 0;
83247             var numNodes = bundle ? bundle.sourceFiles.length + numPrepends : 1;
83248             for (var i = 0; i < numNodes; i++) {
83249                 var currentNode = bundle ? i < numPrepends ? bundle.prepends[i] : bundle.sourceFiles[i - numPrepends] : node;
83250                 var sourceFile = ts.isSourceFile(currentNode) ? currentNode : ts.isUnparsedSource(currentNode) ? undefined : currentSourceFile;
83251                 var shouldSkip = printerOptions.noEmitHelpers || (!!sourceFile && ts.hasRecordedExternalHelpers(sourceFile));
83252                 var shouldBundle = (ts.isSourceFile(currentNode) || ts.isUnparsedSource(currentNode)) && !isOwnFileEmit;
83253                 var helpers = ts.isUnparsedSource(currentNode) ? currentNode.helpers : getSortedEmitHelpers(currentNode);
83254                 if (helpers) {
83255                     for (var _a = 0, helpers_6 = helpers; _a < helpers_6.length; _a++) {
83256                         var helper = helpers_6[_a];
83257                         if (!helper.scoped) {
83258                             if (shouldSkip)
83259                                 continue;
83260                             if (shouldBundle) {
83261                                 if (bundledHelpers.get(helper.name)) {
83262                                     continue;
83263                                 }
83264                                 bundledHelpers.set(helper.name, true);
83265                             }
83266                         }
83267                         else if (bundle) {
83268                             continue;
83269                         }
83270                         var pos = getTextPosWithWriteLine();
83271                         if (typeof helper.text === "string") {
83272                             writeLines(helper.text);
83273                         }
83274                         else {
83275                             writeLines(helper.text(makeFileLevelOptimisticUniqueName));
83276                         }
83277                         if (bundleFileInfo)
83278                             bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "emitHelpers", data: helper.name });
83279                         helpersEmitted = true;
83280                     }
83281                 }
83282             }
83283             return helpersEmitted;
83284         }
83285         function getSortedEmitHelpers(node) {
83286             var helpers = ts.getEmitHelpers(node);
83287             return helpers && ts.stableSort(helpers, ts.compareEmitHelpers);
83288         }
83289         function emitNumericOrBigIntLiteral(node) {
83290             emitLiteral(node, false);
83291         }
83292         function emitLiteral(node, jsxAttributeEscape) {
83293             var text = getLiteralTextOfNode(node, printerOptions.neverAsciiEscape, jsxAttributeEscape);
83294             if ((printerOptions.sourceMap || printerOptions.inlineSourceMap)
83295                 && (node.kind === 10 || ts.isTemplateLiteralKind(node.kind))) {
83296                 writeLiteral(text);
83297             }
83298             else {
83299                 writeStringLiteral(text);
83300             }
83301         }
83302         function emitUnparsedSourceOrPrepend(unparsed) {
83303             for (var _a = 0, _b = unparsed.texts; _a < _b.length; _a++) {
83304                 var text = _b[_a];
83305                 writeLine();
83306                 emit(text);
83307             }
83308         }
83309         function writeUnparsedNode(unparsed) {
83310             writer.rawWrite(unparsed.parent.text.substring(unparsed.pos, unparsed.end));
83311         }
83312         function emitUnparsedTextLike(unparsed) {
83313             var pos = getTextPosWithWriteLine();
83314             writeUnparsedNode(unparsed);
83315             if (bundleFileInfo) {
83316                 updateOrPushBundleFileTextLike(pos, writer.getTextPos(), unparsed.kind === 294 ?
83317                     "text" :
83318                     "internal");
83319             }
83320         }
83321         function emitUnparsedSyntheticReference(unparsed) {
83322             var pos = getTextPosWithWriteLine();
83323             writeUnparsedNode(unparsed);
83324             if (bundleFileInfo) {
83325                 var section = ts.clone(unparsed.section);
83326                 section.pos = pos;
83327                 section.end = writer.getTextPos();
83328                 bundleFileInfo.sections.push(section);
83329             }
83330         }
83331         function emitIdentifier(node) {
83332             var writeText = node.symbol ? writeSymbol : write;
83333             writeText(getTextOfNode(node, false), node.symbol);
83334             emitList(node, node.typeArguments, 53776);
83335         }
83336         function emitPrivateIdentifier(node) {
83337             var writeText = node.symbol ? writeSymbol : write;
83338             writeText(getTextOfNode(node, false), node.symbol);
83339         }
83340         function emitQualifiedName(node) {
83341             emitEntityName(node.left);
83342             writePunctuation(".");
83343             emit(node.right);
83344         }
83345         function emitEntityName(node) {
83346             if (node.kind === 78) {
83347                 emitExpression(node);
83348             }
83349             else {
83350                 emit(node);
83351             }
83352         }
83353         function emitComputedPropertyName(node) {
83354             writePunctuation("[");
83355             emitExpression(node.expression);
83356             writePunctuation("]");
83357         }
83358         function emitTypeParameter(node) {
83359             emit(node.name);
83360             if (node.constraint) {
83361                 writeSpace();
83362                 writeKeyword("extends");
83363                 writeSpace();
83364                 emit(node.constraint);
83365             }
83366             if (node.default) {
83367                 writeSpace();
83368                 writeOperator("=");
83369                 writeSpace();
83370                 emit(node.default);
83371             }
83372         }
83373         function emitParameter(node) {
83374             emitDecorators(node, node.decorators);
83375             emitModifiers(node, node.modifiers);
83376             emit(node.dotDotDotToken);
83377             emitNodeWithWriter(node.name, writeParameter);
83378             emit(node.questionToken);
83379             if (node.parent && node.parent.kind === 308 && !node.name) {
83380                 emit(node.type);
83381             }
83382             else {
83383                 emitTypeAnnotation(node.type);
83384             }
83385             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);
83386         }
83387         function emitDecorator(decorator) {
83388             writePunctuation("@");
83389             emitExpression(decorator.expression);
83390         }
83391         function emitPropertySignature(node) {
83392             emitDecorators(node, node.decorators);
83393             emitModifiers(node, node.modifiers);
83394             emitNodeWithWriter(node.name, writeProperty);
83395             emit(node.questionToken);
83396             emitTypeAnnotation(node.type);
83397             writeTrailingSemicolon();
83398         }
83399         function emitPropertyDeclaration(node) {
83400             emitDecorators(node, node.decorators);
83401             emitModifiers(node, node.modifiers);
83402             emit(node.name);
83403             emit(node.questionToken);
83404             emit(node.exclamationToken);
83405             emitTypeAnnotation(node.type);
83406             emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name.end, node);
83407             writeTrailingSemicolon();
83408         }
83409         function emitMethodSignature(node) {
83410             pushNameGenerationScope(node);
83411             emitDecorators(node, node.decorators);
83412             emitModifiers(node, node.modifiers);
83413             emit(node.name);
83414             emit(node.questionToken);
83415             emitTypeParameters(node, node.typeParameters);
83416             emitParameters(node, node.parameters);
83417             emitTypeAnnotation(node.type);
83418             writeTrailingSemicolon();
83419             popNameGenerationScope(node);
83420         }
83421         function emitMethodDeclaration(node) {
83422             emitDecorators(node, node.decorators);
83423             emitModifiers(node, node.modifiers);
83424             emit(node.asteriskToken);
83425             emit(node.name);
83426             emit(node.questionToken);
83427             emitSignatureAndBody(node, emitSignatureHead);
83428         }
83429         function emitConstructor(node) {
83430             emitModifiers(node, node.modifiers);
83431             writeKeyword("constructor");
83432             emitSignatureAndBody(node, emitSignatureHead);
83433         }
83434         function emitAccessorDeclaration(node) {
83435             emitDecorators(node, node.decorators);
83436             emitModifiers(node, node.modifiers);
83437             writeKeyword(node.kind === 167 ? "get" : "set");
83438             writeSpace();
83439             emit(node.name);
83440             emitSignatureAndBody(node, emitSignatureHead);
83441         }
83442         function emitCallSignature(node) {
83443             pushNameGenerationScope(node);
83444             emitDecorators(node, node.decorators);
83445             emitModifiers(node, node.modifiers);
83446             emitTypeParameters(node, node.typeParameters);
83447             emitParameters(node, node.parameters);
83448             emitTypeAnnotation(node.type);
83449             writeTrailingSemicolon();
83450             popNameGenerationScope(node);
83451         }
83452         function emitConstructSignature(node) {
83453             pushNameGenerationScope(node);
83454             emitDecorators(node, node.decorators);
83455             emitModifiers(node, node.modifiers);
83456             writeKeyword("new");
83457             writeSpace();
83458             emitTypeParameters(node, node.typeParameters);
83459             emitParameters(node, node.parameters);
83460             emitTypeAnnotation(node.type);
83461             writeTrailingSemicolon();
83462             popNameGenerationScope(node);
83463         }
83464         function emitIndexSignature(node) {
83465             emitDecorators(node, node.decorators);
83466             emitModifiers(node, node.modifiers);
83467             emitParametersForIndexSignature(node, node.parameters);
83468             emitTypeAnnotation(node.type);
83469             writeTrailingSemicolon();
83470         }
83471         function emitTemplateTypeSpan(node) {
83472             emit(node.type);
83473             emit(node.literal);
83474         }
83475         function emitSemicolonClassElement() {
83476             writeTrailingSemicolon();
83477         }
83478         function emitTypePredicate(node) {
83479             if (node.assertsModifier) {
83480                 emit(node.assertsModifier);
83481                 writeSpace();
83482             }
83483             emit(node.parameterName);
83484             if (node.type) {
83485                 writeSpace();
83486                 writeKeyword("is");
83487                 writeSpace();
83488                 emit(node.type);
83489             }
83490         }
83491         function emitTypeReference(node) {
83492             emit(node.typeName);
83493             emitTypeArguments(node, node.typeArguments);
83494         }
83495         function emitFunctionType(node) {
83496             pushNameGenerationScope(node);
83497             emitTypeParameters(node, node.typeParameters);
83498             emitParametersForArrow(node, node.parameters);
83499             writeSpace();
83500             writePunctuation("=>");
83501             writeSpace();
83502             emit(node.type);
83503             popNameGenerationScope(node);
83504         }
83505         function emitJSDocFunctionType(node) {
83506             writeKeyword("function");
83507             emitParameters(node, node.parameters);
83508             writePunctuation(":");
83509             emit(node.type);
83510         }
83511         function emitJSDocNullableType(node) {
83512             writePunctuation("?");
83513             emit(node.type);
83514         }
83515         function emitJSDocNonNullableType(node) {
83516             writePunctuation("!");
83517             emit(node.type);
83518         }
83519         function emitJSDocOptionalType(node) {
83520             emit(node.type);
83521             writePunctuation("=");
83522         }
83523         function emitConstructorType(node) {
83524             pushNameGenerationScope(node);
83525             emitModifiers(node, node.modifiers);
83526             writeKeyword("new");
83527             writeSpace();
83528             emitTypeParameters(node, node.typeParameters);
83529             emitParameters(node, node.parameters);
83530             writeSpace();
83531             writePunctuation("=>");
83532             writeSpace();
83533             emit(node.type);
83534             popNameGenerationScope(node);
83535         }
83536         function emitTypeQuery(node) {
83537             writeKeyword("typeof");
83538             writeSpace();
83539             emit(node.exprName);
83540         }
83541         function emitTypeLiteral(node) {
83542             writePunctuation("{");
83543             var flags = ts.getEmitFlags(node) & 1 ? 768 : 32897;
83544             emitList(node, node.members, flags | 524288);
83545             writePunctuation("}");
83546         }
83547         function emitArrayType(node) {
83548             emit(node.elementType);
83549             writePunctuation("[");
83550             writePunctuation("]");
83551         }
83552         function emitRestOrJSDocVariadicType(node) {
83553             writePunctuation("...");
83554             emit(node.type);
83555         }
83556         function emitTupleType(node) {
83557             emitTokenWithComment(22, node.pos, writePunctuation, node);
83558             var flags = ts.getEmitFlags(node) & 1 ? 528 : 657;
83559             emitList(node, node.elements, flags | 524288);
83560             emitTokenWithComment(23, node.elements.end, writePunctuation, node);
83561         }
83562         function emitNamedTupleMember(node) {
83563             emit(node.dotDotDotToken);
83564             emit(node.name);
83565             emit(node.questionToken);
83566             emitTokenWithComment(58, node.name.end, writePunctuation, node);
83567             writeSpace();
83568             emit(node.type);
83569         }
83570         function emitOptionalType(node) {
83571             emit(node.type);
83572             writePunctuation("?");
83573         }
83574         function emitUnionType(node) {
83575             emitList(node, node.types, 516);
83576         }
83577         function emitIntersectionType(node) {
83578             emitList(node, node.types, 520);
83579         }
83580         function emitConditionalType(node) {
83581             emit(node.checkType);
83582             writeSpace();
83583             writeKeyword("extends");
83584             writeSpace();
83585             emit(node.extendsType);
83586             writeSpace();
83587             writePunctuation("?");
83588             writeSpace();
83589             emit(node.trueType);
83590             writeSpace();
83591             writePunctuation(":");
83592             writeSpace();
83593             emit(node.falseType);
83594         }
83595         function emitInferType(node) {
83596             writeKeyword("infer");
83597             writeSpace();
83598             emit(node.typeParameter);
83599         }
83600         function emitParenthesizedType(node) {
83601             writePunctuation("(");
83602             emit(node.type);
83603             writePunctuation(")");
83604         }
83605         function emitThisType() {
83606             writeKeyword("this");
83607         }
83608         function emitTypeOperator(node) {
83609             writeTokenText(node.operator, writeKeyword);
83610             writeSpace();
83611             emit(node.type);
83612         }
83613         function emitIndexedAccessType(node) {
83614             emit(node.objectType);
83615             writePunctuation("[");
83616             emit(node.indexType);
83617             writePunctuation("]");
83618         }
83619         function emitMappedType(node) {
83620             var emitFlags = ts.getEmitFlags(node);
83621             writePunctuation("{");
83622             if (emitFlags & 1) {
83623                 writeSpace();
83624             }
83625             else {
83626                 writeLine();
83627                 increaseIndent();
83628             }
83629             if (node.readonlyToken) {
83630                 emit(node.readonlyToken);
83631                 if (node.readonlyToken.kind !== 142) {
83632                     writeKeyword("readonly");
83633                 }
83634                 writeSpace();
83635             }
83636             writePunctuation("[");
83637             pipelineEmit(3, node.typeParameter);
83638             if (node.nameType) {
83639                 writeSpace();
83640                 writeKeyword("as");
83641                 writeSpace();
83642                 emit(node.nameType);
83643             }
83644             writePunctuation("]");
83645             if (node.questionToken) {
83646                 emit(node.questionToken);
83647                 if (node.questionToken.kind !== 57) {
83648                     writePunctuation("?");
83649                 }
83650             }
83651             writePunctuation(":");
83652             writeSpace();
83653             emit(node.type);
83654             writeTrailingSemicolon();
83655             if (emitFlags & 1) {
83656                 writeSpace();
83657             }
83658             else {
83659                 writeLine();
83660                 decreaseIndent();
83661             }
83662             writePunctuation("}");
83663         }
83664         function emitLiteralType(node) {
83665             emitExpression(node.literal);
83666         }
83667         function emitTemplateType(node) {
83668             emit(node.head);
83669             emitList(node, node.templateSpans, 262144);
83670         }
83671         function emitImportTypeNode(node) {
83672             if (node.isTypeOf) {
83673                 writeKeyword("typeof");
83674                 writeSpace();
83675             }
83676             writeKeyword("import");
83677             writePunctuation("(");
83678             emit(node.argument);
83679             writePunctuation(")");
83680             if (node.qualifier) {
83681                 writePunctuation(".");
83682                 emit(node.qualifier);
83683             }
83684             emitTypeArguments(node, node.typeArguments);
83685         }
83686         function emitObjectBindingPattern(node) {
83687             writePunctuation("{");
83688             emitList(node, node.elements, 525136);
83689             writePunctuation("}");
83690         }
83691         function emitArrayBindingPattern(node) {
83692             writePunctuation("[");
83693             emitList(node, node.elements, 524880);
83694             writePunctuation("]");
83695         }
83696         function emitBindingElement(node) {
83697             emit(node.dotDotDotToken);
83698             if (node.propertyName) {
83699                 emit(node.propertyName);
83700                 writePunctuation(":");
83701                 writeSpace();
83702             }
83703             emit(node.name);
83704             emitInitializer(node.initializer, node.name.end, node);
83705         }
83706         function emitArrayLiteralExpression(node) {
83707             var elements = node.elements;
83708             var preferNewLine = node.multiLine ? 65536 : 0;
83709             emitExpressionList(node, elements, 8914 | preferNewLine);
83710         }
83711         function emitObjectLiteralExpression(node) {
83712             ts.forEach(node.properties, generateMemberNames);
83713             var indentedFlag = ts.getEmitFlags(node) & 65536;
83714             if (indentedFlag) {
83715                 increaseIndent();
83716             }
83717             var preferNewLine = node.multiLine ? 65536 : 0;
83718             var allowTrailingComma = currentSourceFile.languageVersion >= 1 && !ts.isJsonSourceFile(currentSourceFile) ? 64 : 0;
83719             emitList(node, node.properties, 526226 | allowTrailingComma | preferNewLine);
83720             if (indentedFlag) {
83721                 decreaseIndent();
83722             }
83723         }
83724         function emitPropertyAccessExpression(node) {
83725             var expression = ts.cast(emitExpression(node.expression), ts.isExpression);
83726             var token = node.questionDotToken || ts.setTextRangePosEnd(ts.factory.createToken(24), node.expression.end, node.name.pos);
83727             var linesBeforeDot = getLinesBetweenNodes(node, node.expression, token);
83728             var linesAfterDot = getLinesBetweenNodes(node, token, node.name);
83729             writeLinesAndIndent(linesBeforeDot, false);
83730             var shouldEmitDotDot = token.kind !== 28 &&
83731                 mayNeedDotDotForPropertyAccess(expression) &&
83732                 !writer.hasTrailingComment() &&
83733                 !writer.hasTrailingWhitespace();
83734             if (shouldEmitDotDot) {
83735                 writePunctuation(".");
83736             }
83737             if (node.questionDotToken) {
83738                 emit(token);
83739             }
83740             else {
83741                 emitTokenWithComment(token.kind, node.expression.end, writePunctuation, node);
83742             }
83743             writeLinesAndIndent(linesAfterDot, false);
83744             emit(node.name);
83745             decreaseIndentIf(linesBeforeDot, linesAfterDot);
83746         }
83747         function mayNeedDotDotForPropertyAccess(expression) {
83748             expression = ts.skipPartiallyEmittedExpressions(expression);
83749             if (ts.isNumericLiteral(expression)) {
83750                 var text = getLiteralTextOfNode(expression, true, false);
83751                 return !expression.numericLiteralFlags && !ts.stringContains(text, ts.tokenToString(24));
83752             }
83753             else if (ts.isAccessExpression(expression)) {
83754                 var constantValue = ts.getConstantValue(expression);
83755                 return typeof constantValue === "number" && isFinite(constantValue)
83756                     && Math.floor(constantValue) === constantValue;
83757             }
83758         }
83759         function emitElementAccessExpression(node) {
83760             emitExpression(node.expression);
83761             emit(node.questionDotToken);
83762             emitTokenWithComment(22, node.expression.end, writePunctuation, node);
83763             emitExpression(node.argumentExpression);
83764             emitTokenWithComment(23, node.argumentExpression.end, writePunctuation, node);
83765         }
83766         function emitCallExpression(node) {
83767             emitExpression(node.expression);
83768             emit(node.questionDotToken);
83769             emitTypeArguments(node, node.typeArguments);
83770             emitExpressionList(node, node.arguments, 2576);
83771         }
83772         function emitNewExpression(node) {
83773             emitTokenWithComment(102, node.pos, writeKeyword, node);
83774             writeSpace();
83775             emitExpression(node.expression);
83776             emitTypeArguments(node, node.typeArguments);
83777             emitExpressionList(node, node.arguments, 18960);
83778         }
83779         function emitTaggedTemplateExpression(node) {
83780             emitExpression(node.tag);
83781             emitTypeArguments(node, node.typeArguments);
83782             writeSpace();
83783             emitExpression(node.template);
83784         }
83785         function emitTypeAssertionExpression(node) {
83786             writePunctuation("<");
83787             emit(node.type);
83788             writePunctuation(">");
83789             emitExpression(node.expression);
83790         }
83791         function emitParenthesizedExpression(node) {
83792             var openParenPos = emitTokenWithComment(20, node.pos, writePunctuation, node);
83793             var indented = writeLineSeparatorsAndIndentBefore(node.expression, node);
83794             emitExpression(node.expression);
83795             writeLineSeparatorsAfter(node.expression, node);
83796             decreaseIndentIf(indented);
83797             emitTokenWithComment(21, node.expression ? node.expression.end : openParenPos, writePunctuation, node);
83798         }
83799         function emitFunctionExpression(node) {
83800             generateNameIfNeeded(node.name);
83801             emitFunctionDeclarationOrExpression(node);
83802         }
83803         function emitArrowFunction(node) {
83804             emitDecorators(node, node.decorators);
83805             emitModifiers(node, node.modifiers);
83806             emitSignatureAndBody(node, emitArrowFunctionHead);
83807         }
83808         function emitArrowFunctionHead(node) {
83809             emitTypeParameters(node, node.typeParameters);
83810             emitParametersForArrow(node, node.parameters);
83811             emitTypeAnnotation(node.type);
83812             writeSpace();
83813             emit(node.equalsGreaterThanToken);
83814         }
83815         function emitDeleteExpression(node) {
83816             emitTokenWithComment(88, node.pos, writeKeyword, node);
83817             writeSpace();
83818             emitExpression(node.expression);
83819         }
83820         function emitTypeOfExpression(node) {
83821             emitTokenWithComment(111, node.pos, writeKeyword, node);
83822             writeSpace();
83823             emitExpression(node.expression);
83824         }
83825         function emitVoidExpression(node) {
83826             emitTokenWithComment(113, node.pos, writeKeyword, node);
83827             writeSpace();
83828             emitExpression(node.expression);
83829         }
83830         function emitAwaitExpression(node) {
83831             emitTokenWithComment(130, node.pos, writeKeyword, node);
83832             writeSpace();
83833             emitExpression(node.expression);
83834         }
83835         function emitPrefixUnaryExpression(node) {
83836             writeTokenText(node.operator, writeOperator);
83837             if (shouldEmitWhitespaceBeforeOperand(node)) {
83838                 writeSpace();
83839             }
83840             emitExpression(node.operand);
83841         }
83842         function shouldEmitWhitespaceBeforeOperand(node) {
83843             var operand = node.operand;
83844             return operand.kind === 214
83845                 && ((node.operator === 39 && (operand.operator === 39 || operand.operator === 45))
83846                     || (node.operator === 40 && (operand.operator === 40 || operand.operator === 46)));
83847         }
83848         function emitPostfixUnaryExpression(node) {
83849             emitExpression(node.operand);
83850             writeTokenText(node.operator, writeOperator);
83851         }
83852         function emitBinaryExpression(node) {
83853             var nodeStack = [node];
83854             var stateStack = [0];
83855             var stackIndex = 0;
83856             while (stackIndex >= 0) {
83857                 node = nodeStack[stackIndex];
83858                 switch (stateStack[stackIndex]) {
83859                     case 0: {
83860                         maybePipelineEmitExpression(node.left);
83861                         break;
83862                     }
83863                     case 1: {
83864                         var isCommaOperator = node.operatorToken.kind !== 27;
83865                         var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken);
83866                         var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right);
83867                         writeLinesAndIndent(linesBeforeOperator, isCommaOperator);
83868                         emitLeadingCommentsOfPosition(node.operatorToken.pos);
83869                         writeTokenNode(node.operatorToken, node.operatorToken.kind === 100 ? writeKeyword : writeOperator);
83870                         emitTrailingCommentsOfPosition(node.operatorToken.end, true);
83871                         writeLinesAndIndent(linesAfterOperator, true);
83872                         maybePipelineEmitExpression(node.right);
83873                         break;
83874                     }
83875                     case 2: {
83876                         var linesBeforeOperator = getLinesBetweenNodes(node, node.left, node.operatorToken);
83877                         var linesAfterOperator = getLinesBetweenNodes(node, node.operatorToken, node.right);
83878                         decreaseIndentIf(linesBeforeOperator, linesAfterOperator);
83879                         stackIndex--;
83880                         break;
83881                     }
83882                     default: return ts.Debug.fail("Invalid state " + stateStack[stackIndex] + " for emitBinaryExpressionWorker");
83883                 }
83884             }
83885             function maybePipelineEmitExpression(next) {
83886                 stateStack[stackIndex]++;
83887                 var savedLastNode = lastNode;
83888                 var savedLastSubstitution = lastSubstitution;
83889                 lastNode = next;
83890                 lastSubstitution = undefined;
83891                 var pipelinePhase = getPipelinePhase(0, 1, next);
83892                 if (pipelinePhase === pipelineEmitWithHint && ts.isBinaryExpression(next)) {
83893                     stackIndex++;
83894                     stateStack[stackIndex] = 0;
83895                     nodeStack[stackIndex] = next;
83896                 }
83897                 else {
83898                     pipelinePhase(1, next);
83899                 }
83900                 ts.Debug.assert(lastNode === next);
83901                 lastNode = savedLastNode;
83902                 lastSubstitution = savedLastSubstitution;
83903             }
83904         }
83905         function emitConditionalExpression(node) {
83906             var linesBeforeQuestion = getLinesBetweenNodes(node, node.condition, node.questionToken);
83907             var linesAfterQuestion = getLinesBetweenNodes(node, node.questionToken, node.whenTrue);
83908             var linesBeforeColon = getLinesBetweenNodes(node, node.whenTrue, node.colonToken);
83909             var linesAfterColon = getLinesBetweenNodes(node, node.colonToken, node.whenFalse);
83910             emitExpression(node.condition);
83911             writeLinesAndIndent(linesBeforeQuestion, true);
83912             emit(node.questionToken);
83913             writeLinesAndIndent(linesAfterQuestion, true);
83914             emitExpression(node.whenTrue);
83915             decreaseIndentIf(linesBeforeQuestion, linesAfterQuestion);
83916             writeLinesAndIndent(linesBeforeColon, true);
83917             emit(node.colonToken);
83918             writeLinesAndIndent(linesAfterColon, true);
83919             emitExpression(node.whenFalse);
83920             decreaseIndentIf(linesBeforeColon, linesAfterColon);
83921         }
83922         function emitTemplateExpression(node) {
83923             emit(node.head);
83924             emitList(node, node.templateSpans, 262144);
83925         }
83926         function emitYieldExpression(node) {
83927             emitTokenWithComment(124, node.pos, writeKeyword, node);
83928             emit(node.asteriskToken);
83929             emitExpressionWithLeadingSpace(node.expression);
83930         }
83931         function emitSpreadExpression(node) {
83932             emitTokenWithComment(25, node.pos, writePunctuation, node);
83933             emitExpression(node.expression);
83934         }
83935         function emitClassExpression(node) {
83936             generateNameIfNeeded(node.name);
83937             emitClassDeclarationOrExpression(node);
83938         }
83939         function emitExpressionWithTypeArguments(node) {
83940             emitExpression(node.expression);
83941             emitTypeArguments(node, node.typeArguments);
83942         }
83943         function emitAsExpression(node) {
83944             emitExpression(node.expression);
83945             if (node.type) {
83946                 writeSpace();
83947                 writeKeyword("as");
83948                 writeSpace();
83949                 emit(node.type);
83950             }
83951         }
83952         function emitNonNullExpression(node) {
83953             emitExpression(node.expression);
83954             writeOperator("!");
83955         }
83956         function emitMetaProperty(node) {
83957             writeToken(node.keywordToken, node.pos, writePunctuation);
83958             writePunctuation(".");
83959             emit(node.name);
83960         }
83961         function emitTemplateSpan(node) {
83962             emitExpression(node.expression);
83963             emit(node.literal);
83964         }
83965         function emitBlock(node) {
83966             emitBlockStatements(node, !node.multiLine && isEmptyBlock(node));
83967         }
83968         function emitBlockStatements(node, forceSingleLine) {
83969             emitTokenWithComment(18, node.pos, writePunctuation, node);
83970             var format = forceSingleLine || ts.getEmitFlags(node) & 1 ? 768 : 129;
83971             emitList(node, node.statements, format);
83972             emitTokenWithComment(19, node.statements.end, writePunctuation, node, !!(format & 1));
83973         }
83974         function emitVariableStatement(node) {
83975             emitModifiers(node, node.modifiers);
83976             emit(node.declarationList);
83977             writeTrailingSemicolon();
83978         }
83979         function emitEmptyStatement(isEmbeddedStatement) {
83980             if (isEmbeddedStatement) {
83981                 writePunctuation(";");
83982             }
83983             else {
83984                 writeTrailingSemicolon();
83985             }
83986         }
83987         function emitExpressionStatement(node) {
83988             emitExpression(node.expression);
83989             if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
83990                 writeTrailingSemicolon();
83991             }
83992         }
83993         function emitIfStatement(node) {
83994             var openParenPos = emitTokenWithComment(98, node.pos, writeKeyword, node);
83995             writeSpace();
83996             emitTokenWithComment(20, openParenPos, writePunctuation, node);
83997             emitExpression(node.expression);
83998             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
83999             emitEmbeddedStatement(node, node.thenStatement);
84000             if (node.elseStatement) {
84001                 writeLineOrSpace(node, node.thenStatement, node.elseStatement);
84002                 emitTokenWithComment(90, node.thenStatement.end, writeKeyword, node);
84003                 if (node.elseStatement.kind === 234) {
84004                     writeSpace();
84005                     emit(node.elseStatement);
84006                 }
84007                 else {
84008                     emitEmbeddedStatement(node, node.elseStatement);
84009                 }
84010             }
84011         }
84012         function emitWhileClause(node, startPos) {
84013             var openParenPos = emitTokenWithComment(114, startPos, writeKeyword, node);
84014             writeSpace();
84015             emitTokenWithComment(20, openParenPos, writePunctuation, node);
84016             emitExpression(node.expression);
84017             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
84018         }
84019         function emitDoStatement(node) {
84020             emitTokenWithComment(89, node.pos, writeKeyword, node);
84021             emitEmbeddedStatement(node, node.statement);
84022             if (ts.isBlock(node.statement) && !preserveSourceNewlines) {
84023                 writeSpace();
84024             }
84025             else {
84026                 writeLineOrSpace(node, node.statement, node.expression);
84027             }
84028             emitWhileClause(node, node.statement.end);
84029             writeTrailingSemicolon();
84030         }
84031         function emitWhileStatement(node) {
84032             emitWhileClause(node, node.pos);
84033             emitEmbeddedStatement(node, node.statement);
84034         }
84035         function emitForStatement(node) {
84036             var openParenPos = emitTokenWithComment(96, node.pos, writeKeyword, node);
84037             writeSpace();
84038             var pos = emitTokenWithComment(20, openParenPos, writePunctuation, node);
84039             emitForBinding(node.initializer);
84040             pos = emitTokenWithComment(26, node.initializer ? node.initializer.end : pos, writePunctuation, node);
84041             emitExpressionWithLeadingSpace(node.condition);
84042             pos = emitTokenWithComment(26, node.condition ? node.condition.end : pos, writePunctuation, node);
84043             emitExpressionWithLeadingSpace(node.incrementor);
84044             emitTokenWithComment(21, node.incrementor ? node.incrementor.end : pos, writePunctuation, node);
84045             emitEmbeddedStatement(node, node.statement);
84046         }
84047         function emitForInStatement(node) {
84048             var openParenPos = emitTokenWithComment(96, node.pos, writeKeyword, node);
84049             writeSpace();
84050             emitTokenWithComment(20, openParenPos, writePunctuation, node);
84051             emitForBinding(node.initializer);
84052             writeSpace();
84053             emitTokenWithComment(100, node.initializer.end, writeKeyword, node);
84054             writeSpace();
84055             emitExpression(node.expression);
84056             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
84057             emitEmbeddedStatement(node, node.statement);
84058         }
84059         function emitForOfStatement(node) {
84060             var openParenPos = emitTokenWithComment(96, node.pos, writeKeyword, node);
84061             writeSpace();
84062             emitWithTrailingSpace(node.awaitModifier);
84063             emitTokenWithComment(20, openParenPos, writePunctuation, node);
84064             emitForBinding(node.initializer);
84065             writeSpace();
84066             emitTokenWithComment(156, node.initializer.end, writeKeyword, node);
84067             writeSpace();
84068             emitExpression(node.expression);
84069             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
84070             emitEmbeddedStatement(node, node.statement);
84071         }
84072         function emitForBinding(node) {
84073             if (node !== undefined) {
84074                 if (node.kind === 250) {
84075                     emit(node);
84076                 }
84077                 else {
84078                     emitExpression(node);
84079                 }
84080             }
84081         }
84082         function emitContinueStatement(node) {
84083             emitTokenWithComment(85, node.pos, writeKeyword, node);
84084             emitWithLeadingSpace(node.label);
84085             writeTrailingSemicolon();
84086         }
84087         function emitBreakStatement(node) {
84088             emitTokenWithComment(80, node.pos, writeKeyword, node);
84089             emitWithLeadingSpace(node.label);
84090             writeTrailingSemicolon();
84091         }
84092         function emitTokenWithComment(token, pos, writer, contextNode, indentLeading) {
84093             var node = ts.getParseTreeNode(contextNode);
84094             var isSimilarNode = node && node.kind === contextNode.kind;
84095             var startPos = pos;
84096             if (isSimilarNode && currentSourceFile) {
84097                 pos = ts.skipTrivia(currentSourceFile.text, pos);
84098             }
84099             if (isSimilarNode && contextNode.pos !== startPos) {
84100                 var needsIndent = indentLeading && currentSourceFile && !ts.positionsAreOnSameLine(startPos, pos, currentSourceFile);
84101                 if (needsIndent) {
84102                     increaseIndent();
84103                 }
84104                 emitLeadingCommentsOfPosition(startPos);
84105                 if (needsIndent) {
84106                     decreaseIndent();
84107                 }
84108             }
84109             pos = writeTokenText(token, writer, pos);
84110             if (isSimilarNode && contextNode.end !== pos) {
84111                 var isJsxExprContext = contextNode.kind === 283;
84112                 emitTrailingCommentsOfPosition(pos, !isJsxExprContext, isJsxExprContext);
84113             }
84114             return pos;
84115         }
84116         function emitReturnStatement(node) {
84117             emitTokenWithComment(104, node.pos, writeKeyword, node);
84118             emitExpressionWithLeadingSpace(node.expression);
84119             writeTrailingSemicolon();
84120         }
84121         function emitWithStatement(node) {
84122             var openParenPos = emitTokenWithComment(115, node.pos, writeKeyword, node);
84123             writeSpace();
84124             emitTokenWithComment(20, openParenPos, writePunctuation, node);
84125             emitExpression(node.expression);
84126             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
84127             emitEmbeddedStatement(node, node.statement);
84128         }
84129         function emitSwitchStatement(node) {
84130             var openParenPos = emitTokenWithComment(106, node.pos, writeKeyword, node);
84131             writeSpace();
84132             emitTokenWithComment(20, openParenPos, writePunctuation, node);
84133             emitExpression(node.expression);
84134             emitTokenWithComment(21, node.expression.end, writePunctuation, node);
84135             writeSpace();
84136             emit(node.caseBlock);
84137         }
84138         function emitLabeledStatement(node) {
84139             emit(node.label);
84140             emitTokenWithComment(58, node.label.end, writePunctuation, node);
84141             writeSpace();
84142             emit(node.statement);
84143         }
84144         function emitThrowStatement(node) {
84145             emitTokenWithComment(108, node.pos, writeKeyword, node);
84146             emitExpressionWithLeadingSpace(node.expression);
84147             writeTrailingSemicolon();
84148         }
84149         function emitTryStatement(node) {
84150             emitTokenWithComment(110, node.pos, writeKeyword, node);
84151             writeSpace();
84152             emit(node.tryBlock);
84153             if (node.catchClause) {
84154                 writeLineOrSpace(node, node.tryBlock, node.catchClause);
84155                 emit(node.catchClause);
84156             }
84157             if (node.finallyBlock) {
84158                 writeLineOrSpace(node, node.catchClause || node.tryBlock, node.finallyBlock);
84159                 emitTokenWithComment(95, (node.catchClause || node.tryBlock).end, writeKeyword, node);
84160                 writeSpace();
84161                 emit(node.finallyBlock);
84162             }
84163         }
84164         function emitDebuggerStatement(node) {
84165             writeToken(86, node.pos, writeKeyword);
84166             writeTrailingSemicolon();
84167         }
84168         function emitVariableDeclaration(node) {
84169             emit(node.name);
84170             emit(node.exclamationToken);
84171             emitTypeAnnotation(node.type);
84172             emitInitializer(node.initializer, node.type ? node.type.end : node.name.end, node);
84173         }
84174         function emitVariableDeclarationList(node) {
84175             writeKeyword(ts.isLet(node) ? "let" : ts.isVarConst(node) ? "const" : "var");
84176             writeSpace();
84177             emitList(node, node.declarations, 528);
84178         }
84179         function emitFunctionDeclaration(node) {
84180             emitFunctionDeclarationOrExpression(node);
84181         }
84182         function emitFunctionDeclarationOrExpression(node) {
84183             emitDecorators(node, node.decorators);
84184             emitModifiers(node, node.modifiers);
84185             writeKeyword("function");
84186             emit(node.asteriskToken);
84187             writeSpace();
84188             emitIdentifierName(node.name);
84189             emitSignatureAndBody(node, emitSignatureHead);
84190         }
84191         function emitBlockCallback(_hint, body) {
84192             emitBlockFunctionBody(body);
84193         }
84194         function emitSignatureAndBody(node, emitSignatureHead) {
84195             var body = node.body;
84196             if (body) {
84197                 if (ts.isBlock(body)) {
84198                     var indentedFlag = ts.getEmitFlags(node) & 65536;
84199                     if (indentedFlag) {
84200                         increaseIndent();
84201                     }
84202                     pushNameGenerationScope(node);
84203                     ts.forEach(node.parameters, generateNames);
84204                     generateNames(node.body);
84205                     emitSignatureHead(node);
84206                     if (onEmitNode) {
84207                         onEmitNode(4, body, emitBlockCallback);
84208                     }
84209                     else {
84210                         emitBlockFunctionBody(body);
84211                     }
84212                     popNameGenerationScope(node);
84213                     if (indentedFlag) {
84214                         decreaseIndent();
84215                     }
84216                 }
84217                 else {
84218                     emitSignatureHead(node);
84219                     writeSpace();
84220                     emitExpression(body);
84221                 }
84222             }
84223             else {
84224                 emitSignatureHead(node);
84225                 writeTrailingSemicolon();
84226             }
84227         }
84228         function emitSignatureHead(node) {
84229             emitTypeParameters(node, node.typeParameters);
84230             emitParameters(node, node.parameters);
84231             emitTypeAnnotation(node.type);
84232         }
84233         function shouldEmitBlockFunctionBodyOnSingleLine(body) {
84234             if (ts.getEmitFlags(body) & 1) {
84235                 return true;
84236             }
84237             if (body.multiLine) {
84238                 return false;
84239             }
84240             if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
84241                 return false;
84242             }
84243             if (getLeadingLineTerminatorCount(body, body.statements, 2)
84244                 || getClosingLineTerminatorCount(body, body.statements, 2)) {
84245                 return false;
84246             }
84247             var previousStatement;
84248             for (var _a = 0, _b = body.statements; _a < _b.length; _a++) {
84249                 var statement = _b[_a];
84250                 if (getSeparatingLineTerminatorCount(previousStatement, statement, 2) > 0) {
84251                     return false;
84252                 }
84253                 previousStatement = statement;
84254             }
84255             return true;
84256         }
84257         function emitBlockFunctionBody(body) {
84258             writeSpace();
84259             writePunctuation("{");
84260             increaseIndent();
84261             var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body)
84262                 ? emitBlockFunctionBodyOnSingleLine
84263                 : emitBlockFunctionBodyWorker;
84264             if (emitBodyWithDetachedComments) {
84265                 emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
84266             }
84267             else {
84268                 emitBlockFunctionBody(body);
84269             }
84270             decreaseIndent();
84271             writeToken(19, body.statements.end, writePunctuation, body);
84272         }
84273         function emitBlockFunctionBodyOnSingleLine(body) {
84274             emitBlockFunctionBodyWorker(body, true);
84275         }
84276         function emitBlockFunctionBodyWorker(body, emitBlockFunctionBodyOnSingleLine) {
84277             var statementOffset = emitPrologueDirectives(body.statements);
84278             var pos = writer.getTextPos();
84279             emitHelpers(body);
84280             if (statementOffset === 0 && pos === writer.getTextPos() && emitBlockFunctionBodyOnSingleLine) {
84281                 decreaseIndent();
84282                 emitList(body, body.statements, 768);
84283                 increaseIndent();
84284             }
84285             else {
84286                 emitList(body, body.statements, 1, statementOffset);
84287             }
84288         }
84289         function emitClassDeclaration(node) {
84290             emitClassDeclarationOrExpression(node);
84291         }
84292         function emitClassDeclarationOrExpression(node) {
84293             ts.forEach(node.members, generateMemberNames);
84294             emitDecorators(node, node.decorators);
84295             emitModifiers(node, node.modifiers);
84296             writeKeyword("class");
84297             if (node.name) {
84298                 writeSpace();
84299                 emitIdentifierName(node.name);
84300             }
84301             var indentedFlag = ts.getEmitFlags(node) & 65536;
84302             if (indentedFlag) {
84303                 increaseIndent();
84304             }
84305             emitTypeParameters(node, node.typeParameters);
84306             emitList(node, node.heritageClauses, 0);
84307             writeSpace();
84308             writePunctuation("{");
84309             emitList(node, node.members, 129);
84310             writePunctuation("}");
84311             if (indentedFlag) {
84312                 decreaseIndent();
84313             }
84314         }
84315         function emitInterfaceDeclaration(node) {
84316             emitDecorators(node, node.decorators);
84317             emitModifiers(node, node.modifiers);
84318             writeKeyword("interface");
84319             writeSpace();
84320             emit(node.name);
84321             emitTypeParameters(node, node.typeParameters);
84322             emitList(node, node.heritageClauses, 512);
84323             writeSpace();
84324             writePunctuation("{");
84325             emitList(node, node.members, 129);
84326             writePunctuation("}");
84327         }
84328         function emitTypeAliasDeclaration(node) {
84329             emitDecorators(node, node.decorators);
84330             emitModifiers(node, node.modifiers);
84331             writeKeyword("type");
84332             writeSpace();
84333             emit(node.name);
84334             emitTypeParameters(node, node.typeParameters);
84335             writeSpace();
84336             writePunctuation("=");
84337             writeSpace();
84338             emit(node.type);
84339             writeTrailingSemicolon();
84340         }
84341         function emitEnumDeclaration(node) {
84342             emitModifiers(node, node.modifiers);
84343             writeKeyword("enum");
84344             writeSpace();
84345             emit(node.name);
84346             writeSpace();
84347             writePunctuation("{");
84348             emitList(node, node.members, 145);
84349             writePunctuation("}");
84350         }
84351         function emitModuleDeclaration(node) {
84352             emitModifiers(node, node.modifiers);
84353             if (~node.flags & 1024) {
84354                 writeKeyword(node.flags & 16 ? "namespace" : "module");
84355                 writeSpace();
84356             }
84357             emit(node.name);
84358             var body = node.body;
84359             if (!body)
84360                 return writeTrailingSemicolon();
84361             while (body.kind === 256) {
84362                 writePunctuation(".");
84363                 emit(body.name);
84364                 body = body.body;
84365             }
84366             writeSpace();
84367             emit(body);
84368         }
84369         function emitModuleBlock(node) {
84370             pushNameGenerationScope(node);
84371             ts.forEach(node.statements, generateNames);
84372             emitBlockStatements(node, isEmptyBlock(node));
84373             popNameGenerationScope(node);
84374         }
84375         function emitCaseBlock(node) {
84376             emitTokenWithComment(18, node.pos, writePunctuation, node);
84377             emitList(node, node.clauses, 129);
84378             emitTokenWithComment(19, node.clauses.end, writePunctuation, node, true);
84379         }
84380         function emitImportEqualsDeclaration(node) {
84381             emitModifiers(node, node.modifiers);
84382             emitTokenWithComment(99, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node);
84383             writeSpace();
84384             if (node.isTypeOnly) {
84385                 emitTokenWithComment(149, node.pos, writeKeyword, node);
84386                 writeSpace();
84387             }
84388             emit(node.name);
84389             writeSpace();
84390             emitTokenWithComment(62, node.name.end, writePunctuation, node);
84391             writeSpace();
84392             emitModuleReference(node.moduleReference);
84393             writeTrailingSemicolon();
84394         }
84395         function emitModuleReference(node) {
84396             if (node.kind === 78) {
84397                 emitExpression(node);
84398             }
84399             else {
84400                 emit(node);
84401             }
84402         }
84403         function emitImportDeclaration(node) {
84404             emitModifiers(node, node.modifiers);
84405             emitTokenWithComment(99, node.modifiers ? node.modifiers.end : node.pos, writeKeyword, node);
84406             writeSpace();
84407             if (node.importClause) {
84408                 emit(node.importClause);
84409                 writeSpace();
84410                 emitTokenWithComment(153, node.importClause.end, writeKeyword, node);
84411                 writeSpace();
84412             }
84413             emitExpression(node.moduleSpecifier);
84414             writeTrailingSemicolon();
84415         }
84416         function emitImportClause(node) {
84417             if (node.isTypeOnly) {
84418                 emitTokenWithComment(149, node.pos, writeKeyword, node);
84419                 writeSpace();
84420             }
84421             emit(node.name);
84422             if (node.name && node.namedBindings) {
84423                 emitTokenWithComment(27, node.name.end, writePunctuation, node);
84424                 writeSpace();
84425             }
84426             emit(node.namedBindings);
84427         }
84428         function emitNamespaceImport(node) {
84429             var asPos = emitTokenWithComment(41, node.pos, writePunctuation, node);
84430             writeSpace();
84431             emitTokenWithComment(126, asPos, writeKeyword, node);
84432             writeSpace();
84433             emit(node.name);
84434         }
84435         function emitNamedImports(node) {
84436             emitNamedImportsOrExports(node);
84437         }
84438         function emitImportSpecifier(node) {
84439             emitImportOrExportSpecifier(node);
84440         }
84441         function emitExportAssignment(node) {
84442             var nextPos = emitTokenWithComment(92, node.pos, writeKeyword, node);
84443             writeSpace();
84444             if (node.isExportEquals) {
84445                 emitTokenWithComment(62, nextPos, writeOperator, node);
84446             }
84447             else {
84448                 emitTokenWithComment(87, nextPos, writeKeyword, node);
84449             }
84450             writeSpace();
84451             emitExpression(node.expression);
84452             writeTrailingSemicolon();
84453         }
84454         function emitExportDeclaration(node) {
84455             var nextPos = emitTokenWithComment(92, node.pos, writeKeyword, node);
84456             writeSpace();
84457             if (node.isTypeOnly) {
84458                 nextPos = emitTokenWithComment(149, nextPos, writeKeyword, node);
84459                 writeSpace();
84460             }
84461             if (node.exportClause) {
84462                 emit(node.exportClause);
84463             }
84464             else {
84465                 nextPos = emitTokenWithComment(41, nextPos, writePunctuation, node);
84466             }
84467             if (node.moduleSpecifier) {
84468                 writeSpace();
84469                 var fromPos = node.exportClause ? node.exportClause.end : nextPos;
84470                 emitTokenWithComment(153, fromPos, writeKeyword, node);
84471                 writeSpace();
84472                 emitExpression(node.moduleSpecifier);
84473             }
84474             writeTrailingSemicolon();
84475         }
84476         function emitNamespaceExportDeclaration(node) {
84477             var nextPos = emitTokenWithComment(92, node.pos, writeKeyword, node);
84478             writeSpace();
84479             nextPos = emitTokenWithComment(126, nextPos, writeKeyword, node);
84480             writeSpace();
84481             nextPos = emitTokenWithComment(140, nextPos, writeKeyword, node);
84482             writeSpace();
84483             emit(node.name);
84484             writeTrailingSemicolon();
84485         }
84486         function emitNamespaceExport(node) {
84487             var asPos = emitTokenWithComment(41, node.pos, writePunctuation, node);
84488             writeSpace();
84489             emitTokenWithComment(126, asPos, writeKeyword, node);
84490             writeSpace();
84491             emit(node.name);
84492         }
84493         function emitNamedExports(node) {
84494             emitNamedImportsOrExports(node);
84495         }
84496         function emitExportSpecifier(node) {
84497             emitImportOrExportSpecifier(node);
84498         }
84499         function emitNamedImportsOrExports(node) {
84500             writePunctuation("{");
84501             emitList(node, node.elements, 525136);
84502             writePunctuation("}");
84503         }
84504         function emitImportOrExportSpecifier(node) {
84505             if (node.propertyName) {
84506                 emit(node.propertyName);
84507                 writeSpace();
84508                 emitTokenWithComment(126, node.propertyName.end, writeKeyword, node);
84509                 writeSpace();
84510             }
84511             emit(node.name);
84512         }
84513         function emitExternalModuleReference(node) {
84514             writeKeyword("require");
84515             writePunctuation("(");
84516             emitExpression(node.expression);
84517             writePunctuation(")");
84518         }
84519         function emitJsxElement(node) {
84520             emit(node.openingElement);
84521             emitList(node, node.children, 262144);
84522             emit(node.closingElement);
84523         }
84524         function emitJsxSelfClosingElement(node) {
84525             writePunctuation("<");
84526             emitJsxTagName(node.tagName);
84527             emitTypeArguments(node, node.typeArguments);
84528             writeSpace();
84529             emit(node.attributes);
84530             writePunctuation("/>");
84531         }
84532         function emitJsxFragment(node) {
84533             emit(node.openingFragment);
84534             emitList(node, node.children, 262144);
84535             emit(node.closingFragment);
84536         }
84537         function emitJsxOpeningElementOrFragment(node) {
84538             writePunctuation("<");
84539             if (ts.isJsxOpeningElement(node)) {
84540                 var indented = writeLineSeparatorsAndIndentBefore(node.tagName, node);
84541                 emitJsxTagName(node.tagName);
84542                 emitTypeArguments(node, node.typeArguments);
84543                 if (node.attributes.properties && node.attributes.properties.length > 0) {
84544                     writeSpace();
84545                 }
84546                 emit(node.attributes);
84547                 writeLineSeparatorsAfter(node.attributes, node);
84548                 decreaseIndentIf(indented);
84549             }
84550             writePunctuation(">");
84551         }
84552         function emitJsxText(node) {
84553             writer.writeLiteral(node.text);
84554         }
84555         function emitJsxClosingElementOrFragment(node) {
84556             writePunctuation("</");
84557             if (ts.isJsxClosingElement(node)) {
84558                 emitJsxTagName(node.tagName);
84559             }
84560             writePunctuation(">");
84561         }
84562         function emitJsxAttributes(node) {
84563             emitList(node, node.properties, 262656);
84564         }
84565         function emitJsxAttribute(node) {
84566             emit(node.name);
84567             emitNodeWithPrefix("=", writePunctuation, node.initializer, emitJsxAttributeValue);
84568         }
84569         function emitJsxSpreadAttribute(node) {
84570             writePunctuation("{...");
84571             emitExpression(node.expression);
84572             writePunctuation("}");
84573         }
84574         function hasTrailingCommentsAtPosition(pos) {
84575             var result = false;
84576             ts.forEachTrailingCommentRange((currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.text) || "", pos + 1, function () { return result = true; });
84577             return result;
84578         }
84579         function hasLeadingCommentsAtPosition(pos) {
84580             var result = false;
84581             ts.forEachLeadingCommentRange((currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.text) || "", pos + 1, function () { return result = true; });
84582             return result;
84583         }
84584         function hasCommentsAtPosition(pos) {
84585             return hasTrailingCommentsAtPosition(pos) || hasLeadingCommentsAtPosition(pos);
84586         }
84587         function emitJsxExpression(node) {
84588             var _a;
84589             if (node.expression || (!commentsDisabled && !ts.nodeIsSynthesized(node) && hasCommentsAtPosition(node.pos))) {
84590                 var isMultiline = currentSourceFile && !ts.nodeIsSynthesized(node) && ts.getLineAndCharacterOfPosition(currentSourceFile, node.pos).line !== ts.getLineAndCharacterOfPosition(currentSourceFile, node.end).line;
84591                 if (isMultiline) {
84592                     writer.increaseIndent();
84593                 }
84594                 var end = emitTokenWithComment(18, node.pos, writePunctuation, node);
84595                 emit(node.dotDotDotToken);
84596                 emitExpression(node.expression);
84597                 emitTokenWithComment(19, ((_a = node.expression) === null || _a === void 0 ? void 0 : _a.end) || end, writePunctuation, node);
84598                 if (isMultiline) {
84599                     writer.decreaseIndent();
84600                 }
84601             }
84602         }
84603         function emitJsxTagName(node) {
84604             if (node.kind === 78) {
84605                 emitExpression(node);
84606             }
84607             else {
84608                 emit(node);
84609             }
84610         }
84611         function emitCaseClause(node) {
84612             emitTokenWithComment(81, node.pos, writeKeyword, node);
84613             writeSpace();
84614             emitExpression(node.expression);
84615             emitCaseOrDefaultClauseRest(node, node.statements, node.expression.end);
84616         }
84617         function emitDefaultClause(node) {
84618             var pos = emitTokenWithComment(87, node.pos, writeKeyword, node);
84619             emitCaseOrDefaultClauseRest(node, node.statements, pos);
84620         }
84621         function emitCaseOrDefaultClauseRest(parentNode, statements, colonPos) {
84622             var emitAsSingleStatement = statements.length === 1 &&
84623                 (ts.nodeIsSynthesized(parentNode) ||
84624                     ts.nodeIsSynthesized(statements[0]) ||
84625                     ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile));
84626             var format = 163969;
84627             if (emitAsSingleStatement) {
84628                 writeToken(58, colonPos, writePunctuation, parentNode);
84629                 writeSpace();
84630                 format &= ~(1 | 128);
84631             }
84632             else {
84633                 emitTokenWithComment(58, colonPos, writePunctuation, parentNode);
84634             }
84635             emitList(parentNode, statements, format);
84636         }
84637         function emitHeritageClause(node) {
84638             writeSpace();
84639             writeTokenText(node.token, writeKeyword);
84640             writeSpace();
84641             emitList(node, node.types, 528);
84642         }
84643         function emitCatchClause(node) {
84644             var openParenPos = emitTokenWithComment(82, node.pos, writeKeyword, node);
84645             writeSpace();
84646             if (node.variableDeclaration) {
84647                 emitTokenWithComment(20, openParenPos, writePunctuation, node);
84648                 emit(node.variableDeclaration);
84649                 emitTokenWithComment(21, node.variableDeclaration.end, writePunctuation, node);
84650                 writeSpace();
84651             }
84652             emit(node.block);
84653         }
84654         function emitPropertyAssignment(node) {
84655             emit(node.name);
84656             writePunctuation(":");
84657             writeSpace();
84658             var initializer = node.initializer;
84659             if ((ts.getEmitFlags(initializer) & 512) === 0) {
84660                 var commentRange = ts.getCommentRange(initializer);
84661                 emitTrailingCommentsOfPosition(commentRange.pos);
84662             }
84663             emitExpression(initializer);
84664         }
84665         function emitShorthandPropertyAssignment(node) {
84666             emit(node.name);
84667             if (node.objectAssignmentInitializer) {
84668                 writeSpace();
84669                 writePunctuation("=");
84670                 writeSpace();
84671                 emitExpression(node.objectAssignmentInitializer);
84672             }
84673         }
84674         function emitSpreadAssignment(node) {
84675             if (node.expression) {
84676                 emitTokenWithComment(25, node.pos, writePunctuation, node);
84677                 emitExpression(node.expression);
84678             }
84679         }
84680         function emitEnumMember(node) {
84681             emit(node.name);
84682             emitInitializer(node.initializer, node.name.end, node);
84683         }
84684         function emitJSDoc(node) {
84685             write("/**");
84686             if (node.comment) {
84687                 var lines = node.comment.split(/\r\n?|\n/g);
84688                 for (var _a = 0, lines_2 = lines; _a < lines_2.length; _a++) {
84689                     var line = lines_2[_a];
84690                     writeLine();
84691                     writeSpace();
84692                     writePunctuation("*");
84693                     writeSpace();
84694                     write(line);
84695                 }
84696             }
84697             if (node.tags) {
84698                 if (node.tags.length === 1 && node.tags[0].kind === 329 && !node.comment) {
84699                     writeSpace();
84700                     emit(node.tags[0]);
84701                 }
84702                 else {
84703                     emitList(node, node.tags, 33);
84704                 }
84705             }
84706             writeSpace();
84707             write("*/");
84708         }
84709         function emitJSDocSimpleTypedTag(tag) {
84710             emitJSDocTagName(tag.tagName);
84711             emitJSDocTypeExpression(tag.typeExpression);
84712             emitJSDocComment(tag.comment);
84713         }
84714         function emitJSDocSeeTag(tag) {
84715             emitJSDocTagName(tag.tagName);
84716             emit(tag.name);
84717             emitJSDocComment(tag.comment);
84718         }
84719         function emitJSDocNameReference(node) {
84720             writeSpace();
84721             writePunctuation("{");
84722             emit(node.name);
84723             writePunctuation("}");
84724         }
84725         function emitJSDocHeritageTag(tag) {
84726             emitJSDocTagName(tag.tagName);
84727             writeSpace();
84728             writePunctuation("{");
84729             emit(tag.class);
84730             writePunctuation("}");
84731             emitJSDocComment(tag.comment);
84732         }
84733         function emitJSDocTemplateTag(tag) {
84734             emitJSDocTagName(tag.tagName);
84735             emitJSDocTypeExpression(tag.constraint);
84736             writeSpace();
84737             emitList(tag, tag.typeParameters, 528);
84738             emitJSDocComment(tag.comment);
84739         }
84740         function emitJSDocTypedefTag(tag) {
84741             emitJSDocTagName(tag.tagName);
84742             if (tag.typeExpression) {
84743                 if (tag.typeExpression.kind === 301) {
84744                     emitJSDocTypeExpression(tag.typeExpression);
84745                 }
84746                 else {
84747                     writeSpace();
84748                     writePunctuation("{");
84749                     write("Object");
84750                     if (tag.typeExpression.isArrayType) {
84751                         writePunctuation("[");
84752                         writePunctuation("]");
84753                     }
84754                     writePunctuation("}");
84755                 }
84756             }
84757             if (tag.fullName) {
84758                 writeSpace();
84759                 emit(tag.fullName);
84760             }
84761             emitJSDocComment(tag.comment);
84762             if (tag.typeExpression && tag.typeExpression.kind === 312) {
84763                 emitJSDocTypeLiteral(tag.typeExpression);
84764             }
84765         }
84766         function emitJSDocCallbackTag(tag) {
84767             emitJSDocTagName(tag.tagName);
84768             if (tag.name) {
84769                 writeSpace();
84770                 emit(tag.name);
84771             }
84772             emitJSDocComment(tag.comment);
84773             emitJSDocSignature(tag.typeExpression);
84774         }
84775         function emitJSDocSimpleTag(tag) {
84776             emitJSDocTagName(tag.tagName);
84777             emitJSDocComment(tag.comment);
84778         }
84779         function emitJSDocTypeLiteral(lit) {
84780             emitList(lit, ts.factory.createNodeArray(lit.jsDocPropertyTags), 33);
84781         }
84782         function emitJSDocSignature(sig) {
84783             if (sig.typeParameters) {
84784                 emitList(sig, ts.factory.createNodeArray(sig.typeParameters), 33);
84785             }
84786             if (sig.parameters) {
84787                 emitList(sig, ts.factory.createNodeArray(sig.parameters), 33);
84788             }
84789             if (sig.type) {
84790                 writeLine();
84791                 writeSpace();
84792                 writePunctuation("*");
84793                 writeSpace();
84794                 emit(sig.type);
84795             }
84796         }
84797         function emitJSDocPropertyLikeTag(param) {
84798             emitJSDocTagName(param.tagName);
84799             emitJSDocTypeExpression(param.typeExpression);
84800             writeSpace();
84801             if (param.isBracketed) {
84802                 writePunctuation("[");
84803             }
84804             emit(param.name);
84805             if (param.isBracketed) {
84806                 writePunctuation("]");
84807             }
84808             emitJSDocComment(param.comment);
84809         }
84810         function emitJSDocTagName(tagName) {
84811             writePunctuation("@");
84812             emit(tagName);
84813         }
84814         function emitJSDocComment(comment) {
84815             if (comment) {
84816                 writeSpace();
84817                 write(comment);
84818             }
84819         }
84820         function emitJSDocTypeExpression(typeExpression) {
84821             if (typeExpression) {
84822                 writeSpace();
84823                 writePunctuation("{");
84824                 emit(typeExpression.type);
84825                 writePunctuation("}");
84826             }
84827         }
84828         function emitSourceFile(node) {
84829             writeLine();
84830             var statements = node.statements;
84831             if (emitBodyWithDetachedComments) {
84832                 var shouldEmitDetachedComment = statements.length === 0 ||
84833                     !ts.isPrologueDirective(statements[0]) ||
84834                     ts.nodeIsSynthesized(statements[0]);
84835                 if (shouldEmitDetachedComment) {
84836                     emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
84837                     return;
84838                 }
84839             }
84840             emitSourceFileWorker(node);
84841         }
84842         function emitSyntheticTripleSlashReferencesIfNeeded(node) {
84843             emitTripleSlashDirectives(!!node.hasNoDefaultLib, node.syntheticFileReferences || [], node.syntheticTypeReferences || [], node.syntheticLibReferences || []);
84844             for (var _a = 0, _b = node.prepends; _a < _b.length; _a++) {
84845                 var prepend = _b[_a];
84846                 if (ts.isUnparsedSource(prepend) && prepend.syntheticReferences) {
84847                     for (var _c = 0, _d = prepend.syntheticReferences; _c < _d.length; _c++) {
84848                         var ref = _d[_c];
84849                         emit(ref);
84850                         writeLine();
84851                     }
84852                 }
84853             }
84854         }
84855         function emitTripleSlashDirectivesIfNeeded(node) {
84856             if (node.isDeclarationFile)
84857                 emitTripleSlashDirectives(node.hasNoDefaultLib, node.referencedFiles, node.typeReferenceDirectives, node.libReferenceDirectives);
84858         }
84859         function emitTripleSlashDirectives(hasNoDefaultLib, files, types, libs) {
84860             if (hasNoDefaultLib) {
84861                 var pos = writer.getTextPos();
84862                 writeComment("/// <reference no-default-lib=\"true\"/>");
84863                 if (bundleFileInfo)
84864                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "no-default-lib" });
84865                 writeLine();
84866             }
84867             if (currentSourceFile && currentSourceFile.moduleName) {
84868                 writeComment("/// <amd-module name=\"" + currentSourceFile.moduleName + "\" />");
84869                 writeLine();
84870             }
84871             if (currentSourceFile && currentSourceFile.amdDependencies) {
84872                 for (var _a = 0, _b = currentSourceFile.amdDependencies; _a < _b.length; _a++) {
84873                     var dep = _b[_a];
84874                     if (dep.name) {
84875                         writeComment("/// <amd-dependency name=\"" + dep.name + "\" path=\"" + dep.path + "\" />");
84876                     }
84877                     else {
84878                         writeComment("/// <amd-dependency path=\"" + dep.path + "\" />");
84879                     }
84880                     writeLine();
84881                 }
84882             }
84883             for (var _c = 0, files_1 = files; _c < files_1.length; _c++) {
84884                 var directive = files_1[_c];
84885                 var pos = writer.getTextPos();
84886                 writeComment("/// <reference path=\"" + directive.fileName + "\" />");
84887                 if (bundleFileInfo)
84888                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "reference", data: directive.fileName });
84889                 writeLine();
84890             }
84891             for (var _d = 0, types_25 = types; _d < types_25.length; _d++) {
84892                 var directive = types_25[_d];
84893                 var pos = writer.getTextPos();
84894                 writeComment("/// <reference types=\"" + directive.fileName + "\" />");
84895                 if (bundleFileInfo)
84896                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "type", data: directive.fileName });
84897                 writeLine();
84898             }
84899             for (var _e = 0, libs_1 = libs; _e < libs_1.length; _e++) {
84900                 var directive = libs_1[_e];
84901                 var pos = writer.getTextPos();
84902                 writeComment("/// <reference lib=\"" + directive.fileName + "\" />");
84903                 if (bundleFileInfo)
84904                     bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "lib", data: directive.fileName });
84905                 writeLine();
84906             }
84907         }
84908         function emitSourceFileWorker(node) {
84909             var statements = node.statements;
84910             pushNameGenerationScope(node);
84911             ts.forEach(node.statements, generateNames);
84912             emitHelpers(node);
84913             var index = ts.findIndex(statements, function (statement) { return !ts.isPrologueDirective(statement); });
84914             emitTripleSlashDirectivesIfNeeded(node);
84915             emitList(node, statements, 1, index === -1 ? statements.length : index);
84916             popNameGenerationScope(node);
84917         }
84918         function emitPartiallyEmittedExpression(node) {
84919             emitExpression(node.expression);
84920         }
84921         function emitCommaList(node) {
84922             emitExpressionList(node, node.elements, 528);
84923         }
84924         function emitPrologueDirectives(statements, sourceFile, seenPrologueDirectives, recordBundleFileSection) {
84925             var needsToSetSourceFile = !!sourceFile;
84926             for (var i = 0; i < statements.length; i++) {
84927                 var statement = statements[i];
84928                 if (ts.isPrologueDirective(statement)) {
84929                     var shouldEmitPrologueDirective = seenPrologueDirectives ? !seenPrologueDirectives.has(statement.expression.text) : true;
84930                     if (shouldEmitPrologueDirective) {
84931                         if (needsToSetSourceFile) {
84932                             needsToSetSourceFile = false;
84933                             setSourceFile(sourceFile);
84934                         }
84935                         writeLine();
84936                         var pos = writer.getTextPos();
84937                         emit(statement);
84938                         if (recordBundleFileSection && bundleFileInfo)
84939                             bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue", data: statement.expression.text });
84940                         if (seenPrologueDirectives) {
84941                             seenPrologueDirectives.add(statement.expression.text);
84942                         }
84943                     }
84944                 }
84945                 else {
84946                     return i;
84947                 }
84948             }
84949             return statements.length;
84950         }
84951         function emitUnparsedPrologues(prologues, seenPrologueDirectives) {
84952             for (var _a = 0, prologues_1 = prologues; _a < prologues_1.length; _a++) {
84953                 var prologue = prologues_1[_a];
84954                 if (!seenPrologueDirectives.has(prologue.data)) {
84955                     writeLine();
84956                     var pos = writer.getTextPos();
84957                     emit(prologue);
84958                     if (bundleFileInfo)
84959                         bundleFileInfo.sections.push({ pos: pos, end: writer.getTextPos(), kind: "prologue", data: prologue.data });
84960                     if (seenPrologueDirectives) {
84961                         seenPrologueDirectives.add(prologue.data);
84962                     }
84963                 }
84964             }
84965         }
84966         function emitPrologueDirectivesIfNeeded(sourceFileOrBundle) {
84967             if (ts.isSourceFile(sourceFileOrBundle)) {
84968                 emitPrologueDirectives(sourceFileOrBundle.statements, sourceFileOrBundle);
84969             }
84970             else {
84971                 var seenPrologueDirectives = new ts.Set();
84972                 for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) {
84973                     var prepend = _b[_a];
84974                     emitUnparsedPrologues(prepend.prologues, seenPrologueDirectives);
84975                 }
84976                 for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) {
84977                     var sourceFile = _d[_c];
84978                     emitPrologueDirectives(sourceFile.statements, sourceFile, seenPrologueDirectives, true);
84979                 }
84980                 setSourceFile(undefined);
84981             }
84982         }
84983         function getPrologueDirectivesFromBundledSourceFiles(bundle) {
84984             var seenPrologueDirectives = new ts.Set();
84985             var prologues;
84986             for (var index = 0; index < bundle.sourceFiles.length; index++) {
84987                 var sourceFile = bundle.sourceFiles[index];
84988                 var directives = void 0;
84989                 var end = 0;
84990                 for (var _a = 0, _b = sourceFile.statements; _a < _b.length; _a++) {
84991                     var statement = _b[_a];
84992                     if (!ts.isPrologueDirective(statement))
84993                         break;
84994                     if (seenPrologueDirectives.has(statement.expression.text))
84995                         continue;
84996                     seenPrologueDirectives.add(statement.expression.text);
84997                     (directives || (directives = [])).push({
84998                         pos: statement.pos,
84999                         end: statement.end,
85000                         expression: {
85001                             pos: statement.expression.pos,
85002                             end: statement.expression.end,
85003                             text: statement.expression.text
85004                         }
85005                     });
85006                     end = end < statement.end ? statement.end : end;
85007                 }
85008                 if (directives)
85009                     (prologues || (prologues = [])).push({ file: index, text: sourceFile.text.substring(0, end), directives: directives });
85010             }
85011             return prologues;
85012         }
85013         function emitShebangIfNeeded(sourceFileOrBundle) {
85014             if (ts.isSourceFile(sourceFileOrBundle) || ts.isUnparsedSource(sourceFileOrBundle)) {
85015                 var shebang = ts.getShebang(sourceFileOrBundle.text);
85016                 if (shebang) {
85017                     writeComment(shebang);
85018                     writeLine();
85019                     return true;
85020                 }
85021             }
85022             else {
85023                 for (var _a = 0, _b = sourceFileOrBundle.prepends; _a < _b.length; _a++) {
85024                     var prepend = _b[_a];
85025                     ts.Debug.assertNode(prepend, ts.isUnparsedSource);
85026                     if (emitShebangIfNeeded(prepend)) {
85027                         return true;
85028                     }
85029                 }
85030                 for (var _c = 0, _d = sourceFileOrBundle.sourceFiles; _c < _d.length; _c++) {
85031                     var sourceFile = _d[_c];
85032                     if (emitShebangIfNeeded(sourceFile)) {
85033                         return true;
85034                     }
85035                 }
85036             }
85037         }
85038         function emitNodeWithWriter(node, writer) {
85039             if (!node)
85040                 return;
85041             var savedWrite = write;
85042             write = writer;
85043             emit(node);
85044             write = savedWrite;
85045         }
85046         function emitModifiers(node, modifiers) {
85047             if (modifiers && modifiers.length) {
85048                 emitList(node, modifiers, 262656);
85049                 writeSpace();
85050             }
85051         }
85052         function emitTypeAnnotation(node) {
85053             if (node) {
85054                 writePunctuation(":");
85055                 writeSpace();
85056                 emit(node);
85057             }
85058         }
85059         function emitInitializer(node, equalCommentStartPos, container) {
85060             if (node) {
85061                 writeSpace();
85062                 emitTokenWithComment(62, equalCommentStartPos, writeOperator, container);
85063                 writeSpace();
85064                 emitExpression(node);
85065             }
85066         }
85067         function emitNodeWithPrefix(prefix, prefixWriter, node, emit) {
85068             if (node) {
85069                 prefixWriter(prefix);
85070                 emit(node);
85071             }
85072         }
85073         function emitWithLeadingSpace(node) {
85074             if (node) {
85075                 writeSpace();
85076                 emit(node);
85077             }
85078         }
85079         function emitExpressionWithLeadingSpace(node) {
85080             if (node) {
85081                 writeSpace();
85082                 emitExpression(node);
85083             }
85084         }
85085         function emitWithTrailingSpace(node) {
85086             if (node) {
85087                 emit(node);
85088                 writeSpace();
85089             }
85090         }
85091         function emitEmbeddedStatement(parent, node) {
85092             if (ts.isBlock(node) || ts.getEmitFlags(parent) & 1) {
85093                 writeSpace();
85094                 emit(node);
85095             }
85096             else {
85097                 writeLine();
85098                 increaseIndent();
85099                 if (ts.isEmptyStatement(node)) {
85100                     pipelineEmit(5, node);
85101                 }
85102                 else {
85103                     emit(node);
85104                 }
85105                 decreaseIndent();
85106             }
85107         }
85108         function emitDecorators(parentNode, decorators) {
85109             emitList(parentNode, decorators, 2146305);
85110         }
85111         function emitTypeArguments(parentNode, typeArguments) {
85112             emitList(parentNode, typeArguments, 53776);
85113         }
85114         function emitTypeParameters(parentNode, typeParameters) {
85115             if (ts.isFunctionLike(parentNode) && parentNode.typeArguments) {
85116                 return emitTypeArguments(parentNode, parentNode.typeArguments);
85117             }
85118             emitList(parentNode, typeParameters, 53776);
85119         }
85120         function emitParameters(parentNode, parameters) {
85121             emitList(parentNode, parameters, 2576);
85122         }
85123         function canEmitSimpleArrowHead(parentNode, parameters) {
85124             var parameter = ts.singleOrUndefined(parameters);
85125             return parameter
85126                 && parameter.pos === parentNode.pos
85127                 && ts.isArrowFunction(parentNode)
85128                 && !parentNode.type
85129                 && !ts.some(parentNode.decorators)
85130                 && !ts.some(parentNode.modifiers)
85131                 && !ts.some(parentNode.typeParameters)
85132                 && !ts.some(parameter.decorators)
85133                 && !ts.some(parameter.modifiers)
85134                 && !parameter.dotDotDotToken
85135                 && !parameter.questionToken
85136                 && !parameter.type
85137                 && !parameter.initializer
85138                 && ts.isIdentifier(parameter.name);
85139         }
85140         function emitParametersForArrow(parentNode, parameters) {
85141             if (canEmitSimpleArrowHead(parentNode, parameters)) {
85142                 emitList(parentNode, parameters, 2576 & ~2048);
85143             }
85144             else {
85145                 emitParameters(parentNode, parameters);
85146             }
85147         }
85148         function emitParametersForIndexSignature(parentNode, parameters) {
85149             emitList(parentNode, parameters, 8848);
85150         }
85151         function emitList(parentNode, children, format, start, count) {
85152             emitNodeList(emit, parentNode, children, format, start, count);
85153         }
85154         function emitExpressionList(parentNode, children, format, start, count) {
85155             emitNodeList(emitExpression, parentNode, children, format, start, count);
85156         }
85157         function writeDelimiter(format) {
85158             switch (format & 60) {
85159                 case 0:
85160                     break;
85161                 case 16:
85162                     writePunctuation(",");
85163                     break;
85164                 case 4:
85165                     writeSpace();
85166                     writePunctuation("|");
85167                     break;
85168                 case 32:
85169                     writeSpace();
85170                     writePunctuation("*");
85171                     writeSpace();
85172                     break;
85173                 case 8:
85174                     writeSpace();
85175                     writePunctuation("&");
85176                     break;
85177             }
85178         }
85179         function emitNodeList(emit, parentNode, children, format, start, count) {
85180             if (start === void 0) { start = 0; }
85181             if (count === void 0) { count = children ? children.length - start : 0; }
85182             var isUndefined = children === undefined;
85183             if (isUndefined && format & 16384) {
85184                 return;
85185             }
85186             var isEmpty = children === undefined || start >= children.length || count === 0;
85187             if (isEmpty && format & 32768) {
85188                 if (onBeforeEmitNodeArray) {
85189                     onBeforeEmitNodeArray(children);
85190                 }
85191                 if (onAfterEmitNodeArray) {
85192                     onAfterEmitNodeArray(children);
85193                 }
85194                 return;
85195             }
85196             if (format & 15360) {
85197                 writePunctuation(getOpeningBracket(format));
85198                 if (isEmpty && !isUndefined) {
85199                     emitTrailingCommentsOfPosition(children.pos, true);
85200                 }
85201             }
85202             if (onBeforeEmitNodeArray) {
85203                 onBeforeEmitNodeArray(children);
85204             }
85205             if (isEmpty) {
85206                 if (format & 1 && !(preserveSourceNewlines && ts.rangeIsOnSingleLine(parentNode, currentSourceFile))) {
85207                     writeLine();
85208                 }
85209                 else if (format & 256 && !(format & 524288)) {
85210                     writeSpace();
85211                 }
85212             }
85213             else {
85214                 var mayEmitInterveningComments = (format & 262144) === 0;
85215                 var shouldEmitInterveningComments = mayEmitInterveningComments;
85216                 var leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children, format);
85217                 if (leadingLineTerminatorCount) {
85218                     writeLine(leadingLineTerminatorCount);
85219                     shouldEmitInterveningComments = false;
85220                 }
85221                 else if (format & 256) {
85222                     writeSpace();
85223                 }
85224                 if (format & 128) {
85225                     increaseIndent();
85226                 }
85227                 var previousSibling = void 0;
85228                 var previousSourceFileTextKind = void 0;
85229                 var shouldDecreaseIndentAfterEmit = false;
85230                 for (var i = 0; i < count; i++) {
85231                     var child = children[start + i];
85232                     if (format & 32) {
85233                         writeLine();
85234                         writeDelimiter(format);
85235                     }
85236                     else if (previousSibling) {
85237                         if (format & 60 && previousSibling.end !== parentNode.end) {
85238                             emitLeadingCommentsOfPosition(previousSibling.end);
85239                         }
85240                         writeDelimiter(format);
85241                         recordBundleFileInternalSectionEnd(previousSourceFileTextKind);
85242                         var separatingLineTerminatorCount = getSeparatingLineTerminatorCount(previousSibling, child, format);
85243                         if (separatingLineTerminatorCount > 0) {
85244                             if ((format & (3 | 128)) === 0) {
85245                                 increaseIndent();
85246                                 shouldDecreaseIndentAfterEmit = true;
85247                             }
85248                             writeLine(separatingLineTerminatorCount);
85249                             shouldEmitInterveningComments = false;
85250                         }
85251                         else if (previousSibling && format & 512) {
85252                             writeSpace();
85253                         }
85254                     }
85255                     previousSourceFileTextKind = recordBundleFileInternalSectionStart(child);
85256                     if (shouldEmitInterveningComments) {
85257                         if (emitTrailingCommentsOfPosition) {
85258                             var commentRange = ts.getCommentRange(child);
85259                             emitTrailingCommentsOfPosition(commentRange.pos);
85260                         }
85261                     }
85262                     else {
85263                         shouldEmitInterveningComments = mayEmitInterveningComments;
85264                     }
85265                     nextListElementPos = child.pos;
85266                     emit(child);
85267                     if (shouldDecreaseIndentAfterEmit) {
85268                         decreaseIndent();
85269                         shouldDecreaseIndentAfterEmit = false;
85270                     }
85271                     previousSibling = child;
85272                 }
85273                 var emitFlags = previousSibling ? ts.getEmitFlags(previousSibling) : 0;
85274                 var skipTrailingComments = commentsDisabled || !!(emitFlags & 1024);
85275                 var hasTrailingComma = (children === null || children === void 0 ? void 0 : children.hasTrailingComma) && (format & 64) && (format & 16);
85276                 if (hasTrailingComma) {
85277                     if (previousSibling && !skipTrailingComments) {
85278                         emitTokenWithComment(27, previousSibling.end, writePunctuation, previousSibling);
85279                     }
85280                     else {
85281                         writePunctuation(",");
85282                     }
85283                 }
85284                 if (previousSibling && parentNode.end !== previousSibling.end && (format & 60) && !skipTrailingComments) {
85285                     emitLeadingCommentsOfPosition(hasTrailingComma && (children === null || children === void 0 ? void 0 : children.end) ? children.end : previousSibling.end);
85286                 }
85287                 if (format & 128) {
85288                     decreaseIndent();
85289                 }
85290                 recordBundleFileInternalSectionEnd(previousSourceFileTextKind);
85291                 var closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children, format);
85292                 if (closingLineTerminatorCount) {
85293                     writeLine(closingLineTerminatorCount);
85294                 }
85295                 else if (format & (2097152 | 256)) {
85296                     writeSpace();
85297                 }
85298             }
85299             if (onAfterEmitNodeArray) {
85300                 onAfterEmitNodeArray(children);
85301             }
85302             if (format & 15360) {
85303                 if (isEmpty && !isUndefined) {
85304                     emitLeadingCommentsOfPosition(children.end);
85305                 }
85306                 writePunctuation(getClosingBracket(format));
85307             }
85308         }
85309         function writeLiteral(s) {
85310             writer.writeLiteral(s);
85311         }
85312         function writeStringLiteral(s) {
85313             writer.writeStringLiteral(s);
85314         }
85315         function writeBase(s) {
85316             writer.write(s);
85317         }
85318         function writeSymbol(s, sym) {
85319             writer.writeSymbol(s, sym);
85320         }
85321         function writePunctuation(s) {
85322             writer.writePunctuation(s);
85323         }
85324         function writeTrailingSemicolon() {
85325             writer.writeTrailingSemicolon(";");
85326         }
85327         function writeKeyword(s) {
85328             writer.writeKeyword(s);
85329         }
85330         function writeOperator(s) {
85331             writer.writeOperator(s);
85332         }
85333         function writeParameter(s) {
85334             writer.writeParameter(s);
85335         }
85336         function writeComment(s) {
85337             writer.writeComment(s);
85338         }
85339         function writeSpace() {
85340             writer.writeSpace(" ");
85341         }
85342         function writeProperty(s) {
85343             writer.writeProperty(s);
85344         }
85345         function writeLine(count) {
85346             if (count === void 0) { count = 1; }
85347             for (var i = 0; i < count; i++) {
85348                 writer.writeLine(i > 0);
85349             }
85350         }
85351         function increaseIndent() {
85352             writer.increaseIndent();
85353         }
85354         function decreaseIndent() {
85355             writer.decreaseIndent();
85356         }
85357         function writeToken(token, pos, writer, contextNode) {
85358             return !sourceMapsDisabled
85359                 ? emitTokenWithSourceMap(contextNode, token, writer, pos, writeTokenText)
85360                 : writeTokenText(token, writer, pos);
85361         }
85362         function writeTokenNode(node, writer) {
85363             if (onBeforeEmitToken) {
85364                 onBeforeEmitToken(node);
85365             }
85366             writer(ts.tokenToString(node.kind));
85367             if (onAfterEmitToken) {
85368                 onAfterEmitToken(node);
85369             }
85370         }
85371         function writeTokenText(token, writer, pos) {
85372             var tokenString = ts.tokenToString(token);
85373             writer(tokenString);
85374             return pos < 0 ? pos : pos + tokenString.length;
85375         }
85376         function writeLineOrSpace(parentNode, prevChildNode, nextChildNode) {
85377             if (ts.getEmitFlags(parentNode) & 1) {
85378                 writeSpace();
85379             }
85380             else if (preserveSourceNewlines) {
85381                 var lines = getLinesBetweenNodes(parentNode, prevChildNode, nextChildNode);
85382                 if (lines) {
85383                     writeLine(lines);
85384                 }
85385                 else {
85386                     writeSpace();
85387                 }
85388             }
85389             else {
85390                 writeLine();
85391             }
85392         }
85393         function writeLines(text) {
85394             var lines = text.split(/\r\n?|\n/g);
85395             var indentation = ts.guessIndentation(lines);
85396             for (var _a = 0, lines_3 = lines; _a < lines_3.length; _a++) {
85397                 var lineText = lines_3[_a];
85398                 var line = indentation ? lineText.slice(indentation) : lineText;
85399                 if (line.length) {
85400                     writeLine();
85401                     write(line);
85402                 }
85403             }
85404         }
85405         function writeLinesAndIndent(lineCount, writeSpaceIfNotIndenting) {
85406             if (lineCount) {
85407                 increaseIndent();
85408                 writeLine(lineCount);
85409             }
85410             else if (writeSpaceIfNotIndenting) {
85411                 writeSpace();
85412             }
85413         }
85414         function decreaseIndentIf(value1, value2) {
85415             if (value1) {
85416                 decreaseIndent();
85417             }
85418             if (value2) {
85419                 decreaseIndent();
85420             }
85421         }
85422         function getLeadingLineTerminatorCount(parentNode, children, format) {
85423             if (format & 2 || preserveSourceNewlines) {
85424                 if (format & 65536) {
85425                     return 1;
85426                 }
85427                 var firstChild_1 = children[0];
85428                 if (firstChild_1 === undefined) {
85429                     return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
85430                 }
85431                 if (firstChild_1.pos === nextListElementPos) {
85432                     return 0;
85433                 }
85434                 if (firstChild_1.kind === 11) {
85435                     return 0;
85436                 }
85437                 if (!ts.positionIsSynthesized(parentNode.pos) &&
85438                     !ts.nodeIsSynthesized(firstChild_1) &&
85439                     (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) {
85440                     if (preserveSourceNewlines) {
85441                         return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndPrecedingNonWhitespaceCharacter(firstChild_1.pos, parentNode.pos, currentSourceFile, includeComments); });
85442                     }
85443                     return ts.rangeStartPositionsAreOnSameLine(parentNode, firstChild_1, currentSourceFile) ? 0 : 1;
85444                 }
85445                 if (synthesizedNodeStartsOnNewLine(firstChild_1, format)) {
85446                     return 1;
85447                 }
85448             }
85449             return format & 1 ? 1 : 0;
85450         }
85451         function getSeparatingLineTerminatorCount(previousNode, nextNode, format) {
85452             if (format & 2 || preserveSourceNewlines) {
85453                 if (previousNode === undefined || nextNode === undefined) {
85454                     return 0;
85455                 }
85456                 if (nextNode.kind === 11) {
85457                     return 0;
85458                 }
85459                 else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode) && previousNode.parent === nextNode.parent) {
85460                     if (preserveSourceNewlines) {
85461                         return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); });
85462                     }
85463                     return ts.rangeEndIsOnSameLineAsRangeStart(previousNode, nextNode, currentSourceFile) ? 0 : 1;
85464                 }
85465                 else if (synthesizedNodeStartsOnNewLine(previousNode, format) || synthesizedNodeStartsOnNewLine(nextNode, format)) {
85466                     return 1;
85467                 }
85468             }
85469             else if (ts.getStartsOnNewLine(nextNode)) {
85470                 return 1;
85471             }
85472             return format & 1 ? 1 : 0;
85473         }
85474         function getClosingLineTerminatorCount(parentNode, children, format) {
85475             if (format & 2 || preserveSourceNewlines) {
85476                 if (format & 65536) {
85477                     return 1;
85478                 }
85479                 var lastChild = ts.lastOrUndefined(children);
85480                 if (lastChild === undefined) {
85481                     return ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
85482                 }
85483                 if (!ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) {
85484                     if (preserveSourceNewlines) {
85485                         var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end;
85486                         return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); });
85487                     }
85488                     return ts.rangeEndPositionsAreOnSameLine(parentNode, lastChild, currentSourceFile) ? 0 : 1;
85489                 }
85490                 if (synthesizedNodeStartsOnNewLine(lastChild, format)) {
85491                     return 1;
85492                 }
85493             }
85494             if (format & 1 && !(format & 131072)) {
85495                 return 1;
85496             }
85497             return 0;
85498         }
85499         function getEffectiveLines(getLineDifference) {
85500             ts.Debug.assert(!!preserveSourceNewlines);
85501             var lines = getLineDifference(true);
85502             if (lines === 0) {
85503                 return getLineDifference(false);
85504             }
85505             return lines;
85506         }
85507         function writeLineSeparatorsAndIndentBefore(node, parent) {
85508             var leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], 0);
85509             if (leadingNewlines) {
85510                 writeLinesAndIndent(leadingNewlines, false);
85511             }
85512             return !!leadingNewlines;
85513         }
85514         function writeLineSeparatorsAfter(node, parent) {
85515             var trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], 0);
85516             if (trailingNewlines) {
85517                 writeLine(trailingNewlines);
85518             }
85519         }
85520         function synthesizedNodeStartsOnNewLine(node, format) {
85521             if (ts.nodeIsSynthesized(node)) {
85522                 var startsOnNewLine = ts.getStartsOnNewLine(node);
85523                 if (startsOnNewLine === undefined) {
85524                     return (format & 65536) !== 0;
85525                 }
85526                 return startsOnNewLine;
85527             }
85528             return (format & 65536) !== 0;
85529         }
85530         function getLinesBetweenNodes(parent, node1, node2) {
85531             if (ts.getEmitFlags(parent) & 131072) {
85532                 return 0;
85533             }
85534             parent = skipSynthesizedParentheses(parent);
85535             node1 = skipSynthesizedParentheses(node1);
85536             node2 = skipSynthesizedParentheses(node2);
85537             if (ts.getStartsOnNewLine(node2)) {
85538                 return 1;
85539             }
85540             if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
85541                 if (preserveSourceNewlines) {
85542                     return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); });
85543                 }
85544                 return ts.rangeEndIsOnSameLineAsRangeStart(node1, node2, currentSourceFile) ? 0 : 1;
85545             }
85546             return 0;
85547         }
85548         function isEmptyBlock(block) {
85549             return block.statements.length === 0
85550                 && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile);
85551         }
85552         function skipSynthesizedParentheses(node) {
85553             while (node.kind === 207 && ts.nodeIsSynthesized(node)) {
85554                 node = node.expression;
85555             }
85556             return node;
85557         }
85558         function getTextOfNode(node, includeTrivia) {
85559             if (ts.isGeneratedIdentifier(node)) {
85560                 return generateName(node);
85561             }
85562             else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) {
85563                 return ts.idText(node);
85564             }
85565             else if (node.kind === 10 && node.textSourceNode) {
85566                 return getTextOfNode(node.textSourceNode, includeTrivia);
85567             }
85568             else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) {
85569                 return node.text;
85570             }
85571             return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia);
85572         }
85573         function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) {
85574             if (node.kind === 10 && node.textSourceNode) {
85575                 var textSourceNode = node.textSourceNode;
85576                 if (ts.isIdentifier(textSourceNode) || ts.isNumericLiteral(textSourceNode)) {
85577                     var text = ts.isNumericLiteral(textSourceNode) ? textSourceNode.text : getTextOfNode(textSourceNode);
85578                     return jsxAttributeEscape ? "\"" + ts.escapeJsxAttributeString(text) + "\"" :
85579                         neverAsciiEscape || (ts.getEmitFlags(node) & 16777216) ? "\"" + ts.escapeString(text) + "\"" :
85580                             "\"" + ts.escapeNonAsciiString(text) + "\"";
85581                 }
85582                 else {
85583                     return getLiteralTextOfNode(textSourceNode, neverAsciiEscape, jsxAttributeEscape);
85584                 }
85585             }
85586             var flags = (neverAsciiEscape ? 1 : 0)
85587                 | (jsxAttributeEscape ? 2 : 0)
85588                 | (printerOptions.terminateUnterminatedLiterals ? 4 : 0)
85589                 | (printerOptions.target && printerOptions.target === 99 ? 8 : 0);
85590             return ts.getLiteralText(node, currentSourceFile, flags);
85591         }
85592         function pushNameGenerationScope(node) {
85593             if (node && ts.getEmitFlags(node) & 524288) {
85594                 return;
85595             }
85596             tempFlagsStack.push(tempFlags);
85597             tempFlags = 0;
85598             reservedNamesStack.push(reservedNames);
85599         }
85600         function popNameGenerationScope(node) {
85601             if (node && ts.getEmitFlags(node) & 524288) {
85602                 return;
85603             }
85604             tempFlags = tempFlagsStack.pop();
85605             reservedNames = reservedNamesStack.pop();
85606         }
85607         function reserveNameInNestedScopes(name) {
85608             if (!reservedNames || reservedNames === ts.lastOrUndefined(reservedNamesStack)) {
85609                 reservedNames = new ts.Set();
85610             }
85611             reservedNames.add(name);
85612         }
85613         function generateNames(node) {
85614             if (!node)
85615                 return;
85616             switch (node.kind) {
85617                 case 230:
85618                     ts.forEach(node.statements, generateNames);
85619                     break;
85620                 case 245:
85621                 case 243:
85622                 case 235:
85623                 case 236:
85624                     generateNames(node.statement);
85625                     break;
85626                 case 234:
85627                     generateNames(node.thenStatement);
85628                     generateNames(node.elseStatement);
85629                     break;
85630                 case 237:
85631                 case 239:
85632                 case 238:
85633                     generateNames(node.initializer);
85634                     generateNames(node.statement);
85635                     break;
85636                 case 244:
85637                     generateNames(node.caseBlock);
85638                     break;
85639                 case 258:
85640                     ts.forEach(node.clauses, generateNames);
85641                     break;
85642                 case 284:
85643                 case 285:
85644                     ts.forEach(node.statements, generateNames);
85645                     break;
85646                 case 247:
85647                     generateNames(node.tryBlock);
85648                     generateNames(node.catchClause);
85649                     generateNames(node.finallyBlock);
85650                     break;
85651                 case 287:
85652                     generateNames(node.variableDeclaration);
85653                     generateNames(node.block);
85654                     break;
85655                 case 232:
85656                     generateNames(node.declarationList);
85657                     break;
85658                 case 250:
85659                     ts.forEach(node.declarations, generateNames);
85660                     break;
85661                 case 249:
85662                 case 160:
85663                 case 198:
85664                 case 252:
85665                     generateNameIfNeeded(node.name);
85666                     break;
85667                 case 251:
85668                     generateNameIfNeeded(node.name);
85669                     if (ts.getEmitFlags(node) & 524288) {
85670                         ts.forEach(node.parameters, generateNames);
85671                         generateNames(node.body);
85672                     }
85673                     break;
85674                 case 196:
85675                 case 197:
85676                     ts.forEach(node.elements, generateNames);
85677                     break;
85678                 case 261:
85679                     generateNames(node.importClause);
85680                     break;
85681                 case 262:
85682                     generateNameIfNeeded(node.name);
85683                     generateNames(node.namedBindings);
85684                     break;
85685                 case 263:
85686                     generateNameIfNeeded(node.name);
85687                     break;
85688                 case 269:
85689                     generateNameIfNeeded(node.name);
85690                     break;
85691                 case 264:
85692                     ts.forEach(node.elements, generateNames);
85693                     break;
85694                 case 265:
85695                     generateNameIfNeeded(node.propertyName || node.name);
85696                     break;
85697             }
85698         }
85699         function generateMemberNames(node) {
85700             if (!node)
85701                 return;
85702             switch (node.kind) {
85703                 case 288:
85704                 case 289:
85705                 case 163:
85706                 case 165:
85707                 case 167:
85708                 case 168:
85709                     generateNameIfNeeded(node.name);
85710                     break;
85711             }
85712         }
85713         function generateNameIfNeeded(name) {
85714             if (name) {
85715                 if (ts.isGeneratedIdentifier(name)) {
85716                     generateName(name);
85717                 }
85718                 else if (ts.isBindingPattern(name)) {
85719                     generateNames(name);
85720                 }
85721             }
85722         }
85723         function generateName(name) {
85724             if ((name.autoGenerateFlags & 7) === 4) {
85725                 return generateNameCached(getNodeForGeneratedName(name), name.autoGenerateFlags);
85726             }
85727             else {
85728                 var autoGenerateId = name.autoGenerateId;
85729                 return autoGeneratedIdToGeneratedName[autoGenerateId] || (autoGeneratedIdToGeneratedName[autoGenerateId] = makeName(name));
85730             }
85731         }
85732         function generateNameCached(node, flags) {
85733             var nodeId = ts.getNodeId(node);
85734             return nodeIdToGeneratedName[nodeId] || (nodeIdToGeneratedName[nodeId] = generateNameForNode(node, flags));
85735         }
85736         function isUniqueName(name) {
85737             return isFileLevelUniqueName(name)
85738                 && !generatedNames.has(name)
85739                 && !(reservedNames && reservedNames.has(name));
85740         }
85741         function isFileLevelUniqueName(name) {
85742             return currentSourceFile ? ts.isFileLevelUniqueName(currentSourceFile, name, hasGlobalName) : true;
85743         }
85744         function isUniqueLocalName(name, container) {
85745             for (var node = container; ts.isNodeDescendantOf(node, container); node = node.nextContainer) {
85746                 if (node.locals) {
85747                     var local = node.locals.get(ts.escapeLeadingUnderscores(name));
85748                     if (local && local.flags & (111551 | 1048576 | 2097152)) {
85749                         return false;
85750                     }
85751                 }
85752             }
85753             return true;
85754         }
85755         function makeTempVariableName(flags, reservedInNestedScopes) {
85756             if (flags && !(tempFlags & flags)) {
85757                 var name = flags === 268435456 ? "_i" : "_n";
85758                 if (isUniqueName(name)) {
85759                     tempFlags |= flags;
85760                     if (reservedInNestedScopes) {
85761                         reserveNameInNestedScopes(name);
85762                     }
85763                     return name;
85764                 }
85765             }
85766             while (true) {
85767                 var count = tempFlags & 268435455;
85768                 tempFlags++;
85769                 if (count !== 8 && count !== 13) {
85770                     var name = count < 26
85771                         ? "_" + String.fromCharCode(97 + count)
85772                         : "_" + (count - 26);
85773                     if (isUniqueName(name)) {
85774                         if (reservedInNestedScopes) {
85775                             reserveNameInNestedScopes(name);
85776                         }
85777                         return name;
85778                     }
85779                 }
85780             }
85781         }
85782         function makeUniqueName(baseName, checkFn, optimistic, scoped) {
85783             if (checkFn === void 0) { checkFn = isUniqueName; }
85784             if (optimistic) {
85785                 if (checkFn(baseName)) {
85786                     if (scoped) {
85787                         reserveNameInNestedScopes(baseName);
85788                     }
85789                     else {
85790                         generatedNames.add(baseName);
85791                     }
85792                     return baseName;
85793                 }
85794             }
85795             if (baseName.charCodeAt(baseName.length - 1) !== 95) {
85796                 baseName += "_";
85797             }
85798             var i = 1;
85799             while (true) {
85800                 var generatedName = baseName + i;
85801                 if (checkFn(generatedName)) {
85802                     if (scoped) {
85803                         reserveNameInNestedScopes(generatedName);
85804                     }
85805                     else {
85806                         generatedNames.add(generatedName);
85807                     }
85808                     return generatedName;
85809                 }
85810                 i++;
85811             }
85812         }
85813         function makeFileLevelOptimisticUniqueName(name) {
85814             return makeUniqueName(name, isFileLevelUniqueName, true);
85815         }
85816         function generateNameForModuleOrEnum(node) {
85817             var name = getTextOfNode(node.name);
85818             return isUniqueLocalName(name, node) ? name : makeUniqueName(name);
85819         }
85820         function generateNameForImportOrExportDeclaration(node) {
85821             var expr = ts.getExternalModuleName(node);
85822             var baseName = ts.isStringLiteral(expr) ?
85823                 ts.makeIdentifierFromModuleName(expr.text) : "module";
85824             return makeUniqueName(baseName);
85825         }
85826         function generateNameForExportDefault() {
85827             return makeUniqueName("default");
85828         }
85829         function generateNameForClassExpression() {
85830             return makeUniqueName("class");
85831         }
85832         function generateNameForMethodOrAccessor(node) {
85833             if (ts.isIdentifier(node.name)) {
85834                 return generateNameCached(node.name);
85835             }
85836             return makeTempVariableName(0);
85837         }
85838         function generateNameForNode(node, flags) {
85839             switch (node.kind) {
85840                 case 78:
85841                     return makeUniqueName(getTextOfNode(node), isUniqueName, !!(flags & 16), !!(flags & 8));
85842                 case 256:
85843                 case 255:
85844                     return generateNameForModuleOrEnum(node);
85845                 case 261:
85846                 case 267:
85847                     return generateNameForImportOrExportDeclaration(node);
85848                 case 251:
85849                 case 252:
85850                 case 266:
85851                     return generateNameForExportDefault();
85852                 case 221:
85853                     return generateNameForClassExpression();
85854                 case 165:
85855                 case 167:
85856                 case 168:
85857                     return generateNameForMethodOrAccessor(node);
85858                 case 158:
85859                     return makeTempVariableName(0, true);
85860                 default:
85861                     return makeTempVariableName(0);
85862             }
85863         }
85864         function makeName(name) {
85865             switch (name.autoGenerateFlags & 7) {
85866                 case 1:
85867                     return makeTempVariableName(0, !!(name.autoGenerateFlags & 8));
85868                 case 2:
85869                     return makeTempVariableName(268435456, !!(name.autoGenerateFlags & 8));
85870                 case 3:
85871                     return makeUniqueName(ts.idText(name), (name.autoGenerateFlags & 32) ? isFileLevelUniqueName : isUniqueName, !!(name.autoGenerateFlags & 16), !!(name.autoGenerateFlags & 8));
85872             }
85873             return ts.Debug.fail("Unsupported GeneratedIdentifierKind.");
85874         }
85875         function getNodeForGeneratedName(name) {
85876             var autoGenerateId = name.autoGenerateId;
85877             var node = name;
85878             var original = node.original;
85879             while (original) {
85880                 node = original;
85881                 if (ts.isIdentifier(node)
85882                     && !!(node.autoGenerateFlags & 4)
85883                     && node.autoGenerateId !== autoGenerateId) {
85884                     break;
85885                 }
85886                 original = node.original;
85887             }
85888             return node;
85889         }
85890         function pipelineEmitWithComments(hint, node) {
85891             ts.Debug.assert(lastNode === node || lastSubstitution === node);
85892             enterComment();
85893             hasWrittenComment = false;
85894             var emitFlags = ts.getEmitFlags(node);
85895             var _a = ts.getCommentRange(node), pos = _a.pos, end = _a.end;
85896             var isEmittedNode = node.kind !== 335;
85897             var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0 || node.kind === 11;
85898             var skipTrailingComments = end < 0 || (emitFlags & 1024) !== 0 || node.kind === 11;
85899             var savedContainerPos = containerPos;
85900             var savedContainerEnd = containerEnd;
85901             var savedDeclarationListContainerEnd = declarationListContainerEnd;
85902             if ((pos > 0 || end > 0) && pos !== end) {
85903                 if (!skipLeadingComments) {
85904                     emitLeadingComments(pos, isEmittedNode);
85905                 }
85906                 if (!skipLeadingComments || (pos >= 0 && (emitFlags & 512) !== 0)) {
85907                     containerPos = pos;
85908                 }
85909                 if (!skipTrailingComments || (end >= 0 && (emitFlags & 1024) !== 0)) {
85910                     containerEnd = end;
85911                     if (node.kind === 250) {
85912                         declarationListContainerEnd = end;
85913                     }
85914                 }
85915             }
85916             ts.forEach(ts.getSyntheticLeadingComments(node), emitLeadingSynthesizedComment);
85917             exitComment();
85918             var pipelinePhase = getNextPipelinePhase(2, hint, node);
85919             if (emitFlags & 2048) {
85920                 commentsDisabled = true;
85921                 pipelinePhase(hint, node);
85922                 commentsDisabled = false;
85923             }
85924             else {
85925                 pipelinePhase(hint, node);
85926             }
85927             enterComment();
85928             ts.forEach(ts.getSyntheticTrailingComments(node), emitTrailingSynthesizedComment);
85929             if ((pos > 0 || end > 0) && pos !== end) {
85930                 containerPos = savedContainerPos;
85931                 containerEnd = savedContainerEnd;
85932                 declarationListContainerEnd = savedDeclarationListContainerEnd;
85933                 if (!skipTrailingComments && isEmittedNode) {
85934                     emitTrailingComments(end);
85935                 }
85936             }
85937             exitComment();
85938             ts.Debug.assert(lastNode === node || lastSubstitution === node);
85939         }
85940         function emitLeadingSynthesizedComment(comment) {
85941             if (comment.hasLeadingNewline || comment.kind === 2) {
85942                 writer.writeLine();
85943             }
85944             writeSynthesizedComment(comment);
85945             if (comment.hasTrailingNewLine || comment.kind === 2) {
85946                 writer.writeLine();
85947             }
85948             else {
85949                 writer.writeSpace(" ");
85950             }
85951         }
85952         function emitTrailingSynthesizedComment(comment) {
85953             if (!writer.isAtStartOfLine()) {
85954                 writer.writeSpace(" ");
85955             }
85956             writeSynthesizedComment(comment);
85957             if (comment.hasTrailingNewLine) {
85958                 writer.writeLine();
85959             }
85960         }
85961         function writeSynthesizedComment(comment) {
85962             var text = formatSynthesizedComment(comment);
85963             var lineMap = comment.kind === 3 ? ts.computeLineStarts(text) : undefined;
85964             ts.writeCommentRange(text, lineMap, writer, 0, text.length, newLine);
85965         }
85966         function formatSynthesizedComment(comment) {
85967             return comment.kind === 3
85968                 ? "/*" + comment.text + "*/"
85969                 : "//" + comment.text;
85970         }
85971         function emitBodyWithDetachedComments(node, detachedRange, emitCallback) {
85972             enterComment();
85973             var pos = detachedRange.pos, end = detachedRange.end;
85974             var emitFlags = ts.getEmitFlags(node);
85975             var skipLeadingComments = pos < 0 || (emitFlags & 512) !== 0;
85976             var skipTrailingComments = commentsDisabled || end < 0 || (emitFlags & 1024) !== 0;
85977             if (!skipLeadingComments) {
85978                 emitDetachedCommentsAndUpdateCommentsInfo(detachedRange);
85979             }
85980             exitComment();
85981             if (emitFlags & 2048 && !commentsDisabled) {
85982                 commentsDisabled = true;
85983                 emitCallback(node);
85984                 commentsDisabled = false;
85985             }
85986             else {
85987                 emitCallback(node);
85988             }
85989             enterComment();
85990             if (!skipTrailingComments) {
85991                 emitLeadingComments(detachedRange.end, true);
85992                 if (hasWrittenComment && !writer.isAtStartOfLine()) {
85993                     writer.writeLine();
85994                 }
85995             }
85996             exitComment();
85997         }
85998         function emitLeadingComments(pos, isEmittedNode) {
85999             hasWrittenComment = false;
86000             if (isEmittedNode) {
86001                 if (pos === 0 && (currentSourceFile === null || currentSourceFile === void 0 ? void 0 : currentSourceFile.isDeclarationFile)) {
86002                     forEachLeadingCommentToEmit(pos, emitNonTripleSlashLeadingComment);
86003                 }
86004                 else {
86005                     forEachLeadingCommentToEmit(pos, emitLeadingComment);
86006                 }
86007             }
86008             else if (pos === 0) {
86009                 forEachLeadingCommentToEmit(pos, emitTripleSlashLeadingComment);
86010             }
86011         }
86012         function emitTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
86013             if (isTripleSlashComment(commentPos, commentEnd)) {
86014                 emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos);
86015             }
86016         }
86017         function emitNonTripleSlashLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
86018             if (!isTripleSlashComment(commentPos, commentEnd)) {
86019                 emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos);
86020             }
86021         }
86022         function shouldWriteComment(text, pos) {
86023             if (printerOptions.onlyPrintJsDocStyle) {
86024                 return (ts.isJSDocLikeText(text, pos) || ts.isPinnedComment(text, pos));
86025             }
86026             return true;
86027         }
86028         function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
86029             if (!shouldWriteComment(currentSourceFile.text, commentPos))
86030                 return;
86031             if (!hasWrittenComment) {
86032                 ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos);
86033                 hasWrittenComment = true;
86034             }
86035             emitPos(commentPos);
86036             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
86037             emitPos(commentEnd);
86038             if (hasTrailingNewLine) {
86039                 writer.writeLine();
86040             }
86041             else if (kind === 3) {
86042                 writer.writeSpace(" ");
86043             }
86044         }
86045         function emitLeadingCommentsOfPosition(pos) {
86046             if (commentsDisabled || pos === -1) {
86047                 return;
86048             }
86049             emitLeadingComments(pos, true);
86050         }
86051         function emitTrailingComments(pos) {
86052             forEachTrailingCommentToEmit(pos, emitTrailingComment);
86053         }
86054         function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) {
86055             if (!shouldWriteComment(currentSourceFile.text, commentPos))
86056                 return;
86057             if (!writer.isAtStartOfLine()) {
86058                 writer.writeSpace(" ");
86059             }
86060             emitPos(commentPos);
86061             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
86062             emitPos(commentEnd);
86063             if (hasTrailingNewLine) {
86064                 writer.writeLine();
86065             }
86066         }
86067         function emitTrailingCommentsOfPosition(pos, prefixSpace, forceNoNewline) {
86068             if (commentsDisabled) {
86069                 return;
86070             }
86071             enterComment();
86072             forEachTrailingCommentToEmit(pos, prefixSpace ? emitTrailingComment : forceNoNewline ? emitTrailingCommentOfPositionNoNewline : emitTrailingCommentOfPosition);
86073             exitComment();
86074         }
86075         function emitTrailingCommentOfPositionNoNewline(commentPos, commentEnd, kind) {
86076             emitPos(commentPos);
86077             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
86078             emitPos(commentEnd);
86079             if (kind === 2) {
86080                 writer.writeLine();
86081             }
86082         }
86083         function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) {
86084             emitPos(commentPos);
86085             ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
86086             emitPos(commentEnd);
86087             if (hasTrailingNewLine) {
86088                 writer.writeLine();
86089             }
86090             else {
86091                 writer.writeSpace(" ");
86092             }
86093         }
86094         function forEachLeadingCommentToEmit(pos, cb) {
86095             if (currentSourceFile && (containerPos === -1 || pos !== containerPos)) {
86096                 if (hasDetachedComments(pos)) {
86097                     forEachLeadingCommentWithoutDetachedComments(cb);
86098                 }
86099                 else {
86100                     ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, pos);
86101                 }
86102             }
86103         }
86104         function forEachTrailingCommentToEmit(end, cb) {
86105             if (currentSourceFile && (containerEnd === -1 || (end !== containerEnd && end !== declarationListContainerEnd))) {
86106                 ts.forEachTrailingCommentRange(currentSourceFile.text, end, cb);
86107             }
86108         }
86109         function hasDetachedComments(pos) {
86110             return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos;
86111         }
86112         function forEachLeadingCommentWithoutDetachedComments(cb) {
86113             var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos;
86114             if (detachedCommentsInfo.length - 1) {
86115                 detachedCommentsInfo.pop();
86116             }
86117             else {
86118                 detachedCommentsInfo = undefined;
86119             }
86120             ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, pos);
86121         }
86122         function emitDetachedCommentsAndUpdateCommentsInfo(range) {
86123             var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
86124             if (currentDetachedCommentInfo) {
86125                 if (detachedCommentsInfo) {
86126                     detachedCommentsInfo.push(currentDetachedCommentInfo);
86127                 }
86128                 else {
86129                     detachedCommentsInfo = [currentDetachedCommentInfo];
86130                 }
86131             }
86132         }
86133         function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) {
86134             if (!shouldWriteComment(currentSourceFile.text, commentPos))
86135                 return;
86136             emitPos(commentPos);
86137             ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine);
86138             emitPos(commentEnd);
86139         }
86140         function isTripleSlashComment(commentPos, commentEnd) {
86141             return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
86142         }
86143         function getParsedSourceMap(node) {
86144             if (node.parsedSourceMap === undefined && node.sourceMapText !== undefined) {
86145                 node.parsedSourceMap = ts.tryParseRawSourceMap(node.sourceMapText) || false;
86146             }
86147             return node.parsedSourceMap || undefined;
86148         }
86149         function pipelineEmitWithSourceMap(hint, node) {
86150             ts.Debug.assert(lastNode === node || lastSubstitution === node);
86151             var pipelinePhase = getNextPipelinePhase(3, hint, node);
86152             if (ts.isUnparsedSource(node) || ts.isUnparsedPrepend(node)) {
86153                 pipelinePhase(hint, node);
86154             }
86155             else if (ts.isUnparsedNode(node)) {
86156                 var parsed = getParsedSourceMap(node.parent);
86157                 if (parsed && sourceMapGenerator) {
86158                     sourceMapGenerator.appendSourceMap(writer.getLine(), writer.getColumn(), parsed, node.parent.sourceMapPath, node.parent.getLineAndCharacterOfPosition(node.pos), node.parent.getLineAndCharacterOfPosition(node.end));
86159                 }
86160                 pipelinePhase(hint, node);
86161             }
86162             else {
86163                 var _a = ts.getSourceMapRange(node), pos = _a.pos, end = _a.end, _b = _a.source, source = _b === void 0 ? sourceMapSource : _b;
86164                 var emitFlags = ts.getEmitFlags(node);
86165                 if (node.kind !== 335
86166                     && (emitFlags & 16) === 0
86167                     && pos >= 0) {
86168                     emitSourcePos(source, skipSourceTrivia(source, pos));
86169                 }
86170                 if (emitFlags & 64) {
86171                     sourceMapsDisabled = true;
86172                     pipelinePhase(hint, node);
86173                     sourceMapsDisabled = false;
86174                 }
86175                 else {
86176                     pipelinePhase(hint, node);
86177                 }
86178                 if (node.kind !== 335
86179                     && (emitFlags & 32) === 0
86180                     && end >= 0) {
86181                     emitSourcePos(source, end);
86182                 }
86183             }
86184             ts.Debug.assert(lastNode === node || lastSubstitution === node);
86185         }
86186         function skipSourceTrivia(source, pos) {
86187             return source.skipTrivia ? source.skipTrivia(pos) : ts.skipTrivia(source.text, pos);
86188         }
86189         function emitPos(pos) {
86190             if (sourceMapsDisabled || ts.positionIsSynthesized(pos) || isJsonSourceMapSource(sourceMapSource)) {
86191                 return;
86192             }
86193             var _a = ts.getLineAndCharacterOfPosition(sourceMapSource, pos), sourceLine = _a.line, sourceCharacter = _a.character;
86194             sourceMapGenerator.addMapping(writer.getLine(), writer.getColumn(), sourceMapSourceIndex, sourceLine, sourceCharacter, undefined);
86195         }
86196         function emitSourcePos(source, pos) {
86197             if (source !== sourceMapSource) {
86198                 var savedSourceMapSource = sourceMapSource;
86199                 var savedSourceMapSourceIndex = sourceMapSourceIndex;
86200                 setSourceMapSource(source);
86201                 emitPos(pos);
86202                 resetSourceMapSource(savedSourceMapSource, savedSourceMapSourceIndex);
86203             }
86204             else {
86205                 emitPos(pos);
86206             }
86207         }
86208         function emitTokenWithSourceMap(node, token, writer, tokenPos, emitCallback) {
86209             if (sourceMapsDisabled || node && ts.isInJsonFile(node)) {
86210                 return emitCallback(token, writer, tokenPos);
86211             }
86212             var emitNode = node && node.emitNode;
86213             var emitFlags = emitNode && emitNode.flags || 0;
86214             var range = emitNode && emitNode.tokenSourceMapRanges && emitNode.tokenSourceMapRanges[token];
86215             var source = range && range.source || sourceMapSource;
86216             tokenPos = skipSourceTrivia(source, range ? range.pos : tokenPos);
86217             if ((emitFlags & 128) === 0 && tokenPos >= 0) {
86218                 emitSourcePos(source, tokenPos);
86219             }
86220             tokenPos = emitCallback(token, writer, tokenPos);
86221             if (range)
86222                 tokenPos = range.end;
86223             if ((emitFlags & 256) === 0 && tokenPos >= 0) {
86224                 emitSourcePos(source, tokenPos);
86225             }
86226             return tokenPos;
86227         }
86228         function setSourceMapSource(source) {
86229             if (sourceMapsDisabled) {
86230                 return;
86231             }
86232             sourceMapSource = source;
86233             if (source === mostRecentlyAddedSourceMapSource) {
86234                 sourceMapSourceIndex = mostRecentlyAddedSourceMapSourceIndex;
86235                 return;
86236             }
86237             if (isJsonSourceMapSource(source)) {
86238                 return;
86239             }
86240             sourceMapSourceIndex = sourceMapGenerator.addSource(source.fileName);
86241             if (printerOptions.inlineSources) {
86242                 sourceMapGenerator.setSourceContent(sourceMapSourceIndex, source.text);
86243             }
86244             mostRecentlyAddedSourceMapSource = source;
86245             mostRecentlyAddedSourceMapSourceIndex = sourceMapSourceIndex;
86246         }
86247         function resetSourceMapSource(source, sourceIndex) {
86248             sourceMapSource = source;
86249             sourceMapSourceIndex = sourceIndex;
86250         }
86251         function isJsonSourceMapSource(sourceFile) {
86252             return ts.fileExtensionIs(sourceFile.fileName, ".json");
86253         }
86254     }
86255     ts.createPrinter = createPrinter;
86256     function createBracketsMap() {
86257         var brackets = [];
86258         brackets[1024] = ["{", "}"];
86259         brackets[2048] = ["(", ")"];
86260         brackets[4096] = ["<", ">"];
86261         brackets[8192] = ["[", "]"];
86262         return brackets;
86263     }
86264     function getOpeningBracket(format) {
86265         return brackets[format & 15360][0];
86266     }
86267     function getClosingBracket(format) {
86268         return brackets[format & 15360][1];
86269     }
86270 })(ts || (ts = {}));
86271 var ts;
86272 (function (ts) {
86273     function createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames) {
86274         if (!host.getDirectories || !host.readDirectory) {
86275             return undefined;
86276         }
86277         var cachedReadDirectoryResult = new ts.Map();
86278         var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
86279         return {
86280             useCaseSensitiveFileNames: useCaseSensitiveFileNames,
86281             fileExists: fileExists,
86282             readFile: function (path, encoding) { return host.readFile(path, encoding); },
86283             directoryExists: host.directoryExists && directoryExists,
86284             getDirectories: getDirectories,
86285             readDirectory: readDirectory,
86286             createDirectory: host.createDirectory && createDirectory,
86287             writeFile: host.writeFile && writeFile,
86288             addOrDeleteFileOrDirectory: addOrDeleteFileOrDirectory,
86289             addOrDeleteFile: addOrDeleteFile,
86290             clearCache: clearCache,
86291             realpath: host.realpath && realpath
86292         };
86293         function toPath(fileName) {
86294             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
86295         }
86296         function getCachedFileSystemEntries(rootDirPath) {
86297             return cachedReadDirectoryResult.get(ts.ensureTrailingDirectorySeparator(rootDirPath));
86298         }
86299         function getCachedFileSystemEntriesForBaseDir(path) {
86300             return getCachedFileSystemEntries(ts.getDirectoryPath(path));
86301         }
86302         function getBaseNameOfFileName(fileName) {
86303             return ts.getBaseFileName(ts.normalizePath(fileName));
86304         }
86305         function createCachedFileSystemEntries(rootDir, rootDirPath) {
86306             var resultFromHost = {
86307                 files: ts.map(host.readDirectory(rootDir, undefined, undefined, ["*.*"]), getBaseNameOfFileName) || [],
86308                 directories: host.getDirectories(rootDir) || []
86309             };
86310             cachedReadDirectoryResult.set(ts.ensureTrailingDirectorySeparator(rootDirPath), resultFromHost);
86311             return resultFromHost;
86312         }
86313         function tryReadDirectory(rootDir, rootDirPath) {
86314             rootDirPath = ts.ensureTrailingDirectorySeparator(rootDirPath);
86315             var cachedResult = getCachedFileSystemEntries(rootDirPath);
86316             if (cachedResult) {
86317                 return cachedResult;
86318             }
86319             try {
86320                 return createCachedFileSystemEntries(rootDir, rootDirPath);
86321             }
86322             catch (_e) {
86323                 ts.Debug.assert(!cachedReadDirectoryResult.has(ts.ensureTrailingDirectorySeparator(rootDirPath)));
86324                 return undefined;
86325             }
86326         }
86327         function fileNameEqual(name1, name2) {
86328             return getCanonicalFileName(name1) === getCanonicalFileName(name2);
86329         }
86330         function hasEntry(entries, name) {
86331             return ts.some(entries, function (file) { return fileNameEqual(file, name); });
86332         }
86333         function updateFileSystemEntry(entries, baseName, isValid) {
86334             if (hasEntry(entries, baseName)) {
86335                 if (!isValid) {
86336                     return ts.filterMutate(entries, function (entry) { return !fileNameEqual(entry, baseName); });
86337                 }
86338             }
86339             else if (isValid) {
86340                 return entries.push(baseName);
86341             }
86342         }
86343         function writeFile(fileName, data, writeByteOrderMark) {
86344             var path = toPath(fileName);
86345             var result = getCachedFileSystemEntriesForBaseDir(path);
86346             if (result) {
86347                 updateFilesOfFileSystemEntry(result, getBaseNameOfFileName(fileName), true);
86348             }
86349             return host.writeFile(fileName, data, writeByteOrderMark);
86350         }
86351         function fileExists(fileName) {
86352             var path = toPath(fileName);
86353             var result = getCachedFileSystemEntriesForBaseDir(path);
86354             return result && hasEntry(result.files, getBaseNameOfFileName(fileName)) ||
86355                 host.fileExists(fileName);
86356         }
86357         function directoryExists(dirPath) {
86358             var path = toPath(dirPath);
86359             return cachedReadDirectoryResult.has(ts.ensureTrailingDirectorySeparator(path)) || host.directoryExists(dirPath);
86360         }
86361         function createDirectory(dirPath) {
86362             var path = toPath(dirPath);
86363             var result = getCachedFileSystemEntriesForBaseDir(path);
86364             var baseFileName = getBaseNameOfFileName(dirPath);
86365             if (result) {
86366                 updateFileSystemEntry(result.directories, baseFileName, true);
86367             }
86368             host.createDirectory(dirPath);
86369         }
86370         function getDirectories(rootDir) {
86371             var rootDirPath = toPath(rootDir);
86372             var result = tryReadDirectory(rootDir, rootDirPath);
86373             if (result) {
86374                 return result.directories.slice();
86375             }
86376             return host.getDirectories(rootDir);
86377         }
86378         function readDirectory(rootDir, extensions, excludes, includes, depth) {
86379             var rootDirPath = toPath(rootDir);
86380             var result = tryReadDirectory(rootDir, rootDirPath);
86381             if (result) {
86382                 return ts.matchFiles(rootDir, extensions, excludes, includes, useCaseSensitiveFileNames, currentDirectory, depth, getFileSystemEntries, realpath);
86383             }
86384             return host.readDirectory(rootDir, extensions, excludes, includes, depth);
86385             function getFileSystemEntries(dir) {
86386                 var path = toPath(dir);
86387                 if (path === rootDirPath) {
86388                     return result;
86389                 }
86390                 return tryReadDirectory(dir, path) || ts.emptyFileSystemEntries;
86391             }
86392         }
86393         function realpath(s) {
86394             return host.realpath ? host.realpath(s) : s;
86395         }
86396         function addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath) {
86397             var existingResult = getCachedFileSystemEntries(fileOrDirectoryPath);
86398             if (existingResult) {
86399                 clearCache();
86400                 return undefined;
86401             }
86402             var parentResult = getCachedFileSystemEntriesForBaseDir(fileOrDirectoryPath);
86403             if (!parentResult) {
86404                 return undefined;
86405             }
86406             if (!host.directoryExists) {
86407                 clearCache();
86408                 return undefined;
86409             }
86410             var baseName = getBaseNameOfFileName(fileOrDirectory);
86411             var fsQueryResult = {
86412                 fileExists: host.fileExists(fileOrDirectoryPath),
86413                 directoryExists: host.directoryExists(fileOrDirectoryPath)
86414             };
86415             if (fsQueryResult.directoryExists || hasEntry(parentResult.directories, baseName)) {
86416                 clearCache();
86417             }
86418             else {
86419                 updateFilesOfFileSystemEntry(parentResult, baseName, fsQueryResult.fileExists);
86420             }
86421             return fsQueryResult;
86422         }
86423         function addOrDeleteFile(fileName, filePath, eventKind) {
86424             if (eventKind === ts.FileWatcherEventKind.Changed) {
86425                 return;
86426             }
86427             var parentResult = getCachedFileSystemEntriesForBaseDir(filePath);
86428             if (parentResult) {
86429                 updateFilesOfFileSystemEntry(parentResult, getBaseNameOfFileName(fileName), eventKind === ts.FileWatcherEventKind.Created);
86430             }
86431         }
86432         function updateFilesOfFileSystemEntry(parentResult, baseName, fileExists) {
86433             updateFileSystemEntry(parentResult.files, baseName, fileExists);
86434         }
86435         function clearCache() {
86436             cachedReadDirectoryResult.clear();
86437         }
86438     }
86439     ts.createCachedDirectoryStructureHost = createCachedDirectoryStructureHost;
86440     var ConfigFileProgramReloadLevel;
86441     (function (ConfigFileProgramReloadLevel) {
86442         ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["None"] = 0] = "None";
86443         ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["Partial"] = 1] = "Partial";
86444         ConfigFileProgramReloadLevel[ConfigFileProgramReloadLevel["Full"] = 2] = "Full";
86445     })(ConfigFileProgramReloadLevel = ts.ConfigFileProgramReloadLevel || (ts.ConfigFileProgramReloadLevel = {}));
86446     function updateSharedExtendedConfigFileWatcher(projectPath, parsed, extendedConfigFilesMap, createExtendedConfigFileWatch, toPath) {
86447         var _a;
86448         var extendedConfigs = ts.arrayToMap(((_a = parsed === null || parsed === void 0 ? void 0 : parsed.options.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath);
86449         extendedConfigFilesMap.forEach(function (watcher, extendedConfigFilePath) {
86450             if (!extendedConfigs.has(extendedConfigFilePath)) {
86451                 watcher.projects.delete(projectPath);
86452                 watcher.close();
86453             }
86454         });
86455         extendedConfigs.forEach(function (extendedConfigFileName, extendedConfigFilePath) {
86456             var existing = extendedConfigFilesMap.get(extendedConfigFilePath);
86457             if (existing) {
86458                 existing.projects.add(projectPath);
86459             }
86460             else {
86461                 extendedConfigFilesMap.set(extendedConfigFilePath, {
86462                     projects: new ts.Set([projectPath]),
86463                     fileWatcher: createExtendedConfigFileWatch(extendedConfigFileName, extendedConfigFilePath),
86464                     close: function () {
86465                         var existing = extendedConfigFilesMap.get(extendedConfigFilePath);
86466                         if (!existing || existing.projects.size !== 0)
86467                             return;
86468                         existing.fileWatcher.close();
86469                         extendedConfigFilesMap.delete(extendedConfigFilePath);
86470                     },
86471                 });
86472             }
86473         });
86474     }
86475     ts.updateSharedExtendedConfigFileWatcher = updateSharedExtendedConfigFileWatcher;
86476     function updateMissingFilePathsWatch(program, missingFileWatches, createMissingFileWatch) {
86477         var missingFilePaths = program.getMissingFilePaths();
86478         var newMissingFilePathMap = ts.arrayToMap(missingFilePaths, ts.identity, ts.returnTrue);
86479         ts.mutateMap(missingFileWatches, newMissingFilePathMap, {
86480             createNewValue: createMissingFileWatch,
86481             onDeleteValue: ts.closeFileWatcher
86482         });
86483     }
86484     ts.updateMissingFilePathsWatch = updateMissingFilePathsWatch;
86485     function updateWatchingWildcardDirectories(existingWatchedForWildcards, wildcardDirectories, watchDirectory) {
86486         ts.mutateMap(existingWatchedForWildcards, wildcardDirectories, {
86487             createNewValue: createWildcardDirectoryWatcher,
86488             onDeleteValue: closeFileWatcherOf,
86489             onExistingValue: updateWildcardDirectoryWatcher
86490         });
86491         function createWildcardDirectoryWatcher(directory, flags) {
86492             return {
86493                 watcher: watchDirectory(directory, flags),
86494                 flags: flags
86495             };
86496         }
86497         function updateWildcardDirectoryWatcher(existingWatcher, flags, directory) {
86498             if (existingWatcher.flags === flags) {
86499                 return;
86500             }
86501             existingWatcher.watcher.close();
86502             existingWatchedForWildcards.set(directory, createWildcardDirectoryWatcher(directory, flags));
86503         }
86504     }
86505     ts.updateWatchingWildcardDirectories = updateWatchingWildcardDirectories;
86506     function isIgnoredFileFromWildCardWatching(_a) {
86507         var watchedDirPath = _a.watchedDirPath, fileOrDirectory = _a.fileOrDirectory, fileOrDirectoryPath = _a.fileOrDirectoryPath, configFileName = _a.configFileName, options = _a.options, program = _a.program, extraFileExtensions = _a.extraFileExtensions, currentDirectory = _a.currentDirectory, useCaseSensitiveFileNames = _a.useCaseSensitiveFileNames, writeLog = _a.writeLog;
86508         var newPath = ts.removeIgnoredPath(fileOrDirectoryPath);
86509         if (!newPath) {
86510             writeLog("Project: " + configFileName + " Detected ignored path: " + fileOrDirectory);
86511             return true;
86512         }
86513         fileOrDirectoryPath = newPath;
86514         if (fileOrDirectoryPath === watchedDirPath)
86515             return false;
86516         if (ts.hasExtension(fileOrDirectoryPath) && !ts.isSupportedSourceFileName(fileOrDirectory, options, extraFileExtensions)) {
86517             writeLog("Project: " + configFileName + " Detected file add/remove of non supported extension: " + fileOrDirectory);
86518             return true;
86519         }
86520         if (ts.isExcludedFile(fileOrDirectory, options.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), useCaseSensitiveFileNames, currentDirectory)) {
86521             writeLog("Project: " + configFileName + " Detected excluded file: " + fileOrDirectory);
86522             return true;
86523         }
86524         if (!program)
86525             return false;
86526         if (options.outFile || options.outDir)
86527             return false;
86528         if (ts.fileExtensionIs(fileOrDirectoryPath, ".d.ts")) {
86529             if (options.declarationDir)
86530                 return false;
86531         }
86532         else if (!ts.fileExtensionIsOneOf(fileOrDirectoryPath, ts.supportedJSExtensions)) {
86533             return false;
86534         }
86535         var filePathWithoutExtension = ts.removeFileExtension(fileOrDirectoryPath);
86536         var realProgram = isBuilderProgram(program) ? program.getProgramOrUndefined() : program;
86537         if (hasSourceFile((filePathWithoutExtension + ".ts")) ||
86538             hasSourceFile((filePathWithoutExtension + ".tsx"))) {
86539             writeLog("Project: " + configFileName + " Detected output file: " + fileOrDirectory);
86540             return true;
86541         }
86542         return false;
86543         function hasSourceFile(file) {
86544             return realProgram ?
86545                 !!realProgram.getSourceFileByPath(file) :
86546                 program.getState().fileInfos.has(file);
86547         }
86548     }
86549     ts.isIgnoredFileFromWildCardWatching = isIgnoredFileFromWildCardWatching;
86550     function isBuilderProgram(program) {
86551         return !!program.getState;
86552     }
86553     function isEmittedFileOfProgram(program, file) {
86554         if (!program) {
86555             return false;
86556         }
86557         return program.isEmittedFile(file);
86558     }
86559     ts.isEmittedFileOfProgram = isEmittedFileOfProgram;
86560     var WatchLogLevel;
86561     (function (WatchLogLevel) {
86562         WatchLogLevel[WatchLogLevel["None"] = 0] = "None";
86563         WatchLogLevel[WatchLogLevel["TriggerOnly"] = 1] = "TriggerOnly";
86564         WatchLogLevel[WatchLogLevel["Verbose"] = 2] = "Verbose";
86565     })(WatchLogLevel = ts.WatchLogLevel || (ts.WatchLogLevel = {}));
86566     function getWatchFactory(host, watchLogLevel, log, getDetailWatchInfo) {
86567         ts.setSysLog(watchLogLevel === WatchLogLevel.Verbose ? log : ts.noop);
86568         var plainInvokeFactory = {
86569             watchFile: function (file, callback, pollingInterval, options) { return host.watchFile(file, callback, pollingInterval, options); },
86570             watchDirectory: function (directory, callback, flags, options) { return host.watchDirectory(directory, callback, (flags & 1) !== 0, options); },
86571         };
86572         var triggerInvokingFactory = watchLogLevel !== WatchLogLevel.None ?
86573             {
86574                 watchFile: createTriggerLoggingAddWatch("watchFile"),
86575                 watchDirectory: createTriggerLoggingAddWatch("watchDirectory")
86576             } :
86577             undefined;
86578         var factory = watchLogLevel === WatchLogLevel.Verbose ?
86579             {
86580                 watchFile: createFileWatcherWithLogging,
86581                 watchDirectory: createDirectoryWatcherWithLogging
86582             } :
86583             triggerInvokingFactory || plainInvokeFactory;
86584         var excludeWatcherFactory = watchLogLevel === WatchLogLevel.Verbose ?
86585             createExcludeWatcherWithLogging :
86586             ts.returnNoopFileWatcher;
86587         return {
86588             watchFile: createExcludeHandlingAddWatch("watchFile"),
86589             watchDirectory: createExcludeHandlingAddWatch("watchDirectory")
86590         };
86591         function createExcludeHandlingAddWatch(key) {
86592             return function (file, cb, flags, options, detailInfo1, detailInfo2) {
86593                 var _a;
86594                 return !ts.matchesExclude(file, key === "watchFile" ? options === null || options === void 0 ? void 0 : options.excludeFiles : options === null || options === void 0 ? void 0 : options.excludeDirectories, useCaseSensitiveFileNames(), ((_a = host.getCurrentDirectory) === null || _a === void 0 ? void 0 : _a.call(host)) || "") ?
86595                     factory[key].call(undefined, file, cb, flags, options, detailInfo1, detailInfo2) :
86596                     excludeWatcherFactory(file, flags, options, detailInfo1, detailInfo2);
86597             };
86598         }
86599         function useCaseSensitiveFileNames() {
86600             return typeof host.useCaseSensitiveFileNames === "boolean" ?
86601                 host.useCaseSensitiveFileNames :
86602                 host.useCaseSensitiveFileNames();
86603         }
86604         function createExcludeWatcherWithLogging(file, flags, options, detailInfo1, detailInfo2) {
86605             log("ExcludeWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo));
86606             return {
86607                 close: function () { return log("ExcludeWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo)); }
86608             };
86609         }
86610         function createFileWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) {
86611             log("FileWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo));
86612             var watcher = triggerInvokingFactory.watchFile(file, cb, flags, options, detailInfo1, detailInfo2);
86613             return {
86614                 close: function () {
86615                     log("FileWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo));
86616                     watcher.close();
86617                 }
86618             };
86619         }
86620         function createDirectoryWatcherWithLogging(file, cb, flags, options, detailInfo1, detailInfo2) {
86621             var watchInfo = "DirectoryWatcher:: Added:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo);
86622             log(watchInfo);
86623             var start = ts.timestamp();
86624             var watcher = triggerInvokingFactory.watchDirectory(file, cb, flags, options, detailInfo1, detailInfo2);
86625             var elapsed = ts.timestamp() - start;
86626             log("Elapsed:: " + elapsed + "ms " + watchInfo);
86627             return {
86628                 close: function () {
86629                     var watchInfo = "DirectoryWatcher:: Close:: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo);
86630                     log(watchInfo);
86631                     var start = ts.timestamp();
86632                     watcher.close();
86633                     var elapsed = ts.timestamp() - start;
86634                     log("Elapsed:: " + elapsed + "ms " + watchInfo);
86635                 }
86636             };
86637         }
86638         function createTriggerLoggingAddWatch(key) {
86639             return function (file, cb, flags, options, detailInfo1, detailInfo2) { return plainInvokeFactory[key].call(undefined, file, function () {
86640                 var args = [];
86641                 for (var _i = 0; _i < arguments.length; _i++) {
86642                     args[_i] = arguments[_i];
86643                 }
86644                 var triggerredInfo = (key === "watchFile" ? "FileWatcher" : "DirectoryWatcher") + ":: Triggered with " + args[0] + " " + (args[1] !== undefined ? args[1] : "") + ":: " + getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo);
86645                 log(triggerredInfo);
86646                 var start = ts.timestamp();
86647                 cb.call.apply(cb, __spreadArray([undefined], args));
86648                 var elapsed = ts.timestamp() - start;
86649                 log("Elapsed:: " + elapsed + "ms " + triggerredInfo);
86650             }, flags, options, detailInfo1, detailInfo2); };
86651         }
86652         function getWatchInfo(file, flags, options, detailInfo1, detailInfo2, getDetailWatchInfo) {
86653             return "WatchInfo: " + file + " " + flags + " " + JSON.stringify(options) + " " + (getDetailWatchInfo ? getDetailWatchInfo(detailInfo1, detailInfo2) : detailInfo2 === undefined ? detailInfo1 : detailInfo1 + " " + detailInfo2);
86654         }
86655     }
86656     ts.getWatchFactory = getWatchFactory;
86657     function getFallbackOptions(options) {
86658         var fallbackPolling = options === null || options === void 0 ? void 0 : options.fallbackPolling;
86659         return {
86660             watchFile: fallbackPolling !== undefined ?
86661                 fallbackPolling :
86662                 ts.WatchFileKind.PriorityPollingInterval
86663         };
86664     }
86665     ts.getFallbackOptions = getFallbackOptions;
86666     function closeFileWatcherOf(objWithWatcher) {
86667         objWithWatcher.watcher.close();
86668     }
86669     ts.closeFileWatcherOf = closeFileWatcherOf;
86670 })(ts || (ts = {}));
86671 var ts;
86672 (function (ts) {
86673     function findConfigFile(searchPath, fileExists, configName) {
86674         if (configName === void 0) { configName = "tsconfig.json"; }
86675         return ts.forEachAncestorDirectory(searchPath, function (ancestor) {
86676             var fileName = ts.combinePaths(ancestor, configName);
86677             return fileExists(fileName) ? fileName : undefined;
86678         });
86679     }
86680     ts.findConfigFile = findConfigFile;
86681     function resolveTripleslashReference(moduleName, containingFile) {
86682         var basePath = ts.getDirectoryPath(containingFile);
86683         var referencedFileName = ts.isRootedDiskPath(moduleName) ? moduleName : ts.combinePaths(basePath, moduleName);
86684         return ts.normalizePath(referencedFileName);
86685     }
86686     ts.resolveTripleslashReference = resolveTripleslashReference;
86687     function computeCommonSourceDirectoryOfFilenames(fileNames, currentDirectory, getCanonicalFileName) {
86688         var commonPathComponents;
86689         var failed = ts.forEach(fileNames, function (sourceFile) {
86690             var sourcePathComponents = ts.getNormalizedPathComponents(sourceFile, currentDirectory);
86691             sourcePathComponents.pop();
86692             if (!commonPathComponents) {
86693                 commonPathComponents = sourcePathComponents;
86694                 return;
86695             }
86696             var n = Math.min(commonPathComponents.length, sourcePathComponents.length);
86697             for (var i = 0; i < n; i++) {
86698                 if (getCanonicalFileName(commonPathComponents[i]) !== getCanonicalFileName(sourcePathComponents[i])) {
86699                     if (i === 0) {
86700                         return true;
86701                     }
86702                     commonPathComponents.length = i;
86703                     break;
86704                 }
86705             }
86706             if (sourcePathComponents.length < commonPathComponents.length) {
86707                 commonPathComponents.length = sourcePathComponents.length;
86708             }
86709         });
86710         if (failed) {
86711             return "";
86712         }
86713         if (!commonPathComponents) {
86714             return currentDirectory;
86715         }
86716         return ts.getPathFromPathComponents(commonPathComponents);
86717     }
86718     ts.computeCommonSourceDirectoryOfFilenames = computeCommonSourceDirectoryOfFilenames;
86719     function createCompilerHost(options, setParentNodes) {
86720         return createCompilerHostWorker(options, setParentNodes);
86721     }
86722     ts.createCompilerHost = createCompilerHost;
86723     function createCompilerHostWorker(options, setParentNodes, system) {
86724         if (system === void 0) { system = ts.sys; }
86725         var existingDirectories = new ts.Map();
86726         var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
86727         var computeHash = ts.maybeBind(system, system.createHash) || ts.generateDjb2Hash;
86728         function getSourceFile(fileName, languageVersion, onError) {
86729             var text;
86730             try {
86731                 ts.performance.mark("beforeIORead");
86732                 text = compilerHost.readFile(fileName);
86733                 ts.performance.mark("afterIORead");
86734                 ts.performance.measure("I/O Read", "beforeIORead", "afterIORead");
86735             }
86736             catch (e) {
86737                 if (onError) {
86738                     onError(e.message);
86739                 }
86740                 text = "";
86741             }
86742             return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined;
86743         }
86744         function directoryExists(directoryPath) {
86745             if (existingDirectories.has(directoryPath)) {
86746                 return true;
86747             }
86748             if ((compilerHost.directoryExists || system.directoryExists)(directoryPath)) {
86749                 existingDirectories.set(directoryPath, true);
86750                 return true;
86751             }
86752             return false;
86753         }
86754         function writeFile(fileName, data, writeByteOrderMark, onError) {
86755             try {
86756                 ts.performance.mark("beforeIOWrite");
86757                 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); });
86758                 ts.performance.mark("afterIOWrite");
86759                 ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
86760             }
86761             catch (e) {
86762                 if (onError) {
86763                     onError(e.message);
86764                 }
86765             }
86766         }
86767         var outputFingerprints;
86768         function writeFileWorker(fileName, data, writeByteOrderMark) {
86769             if (!ts.isWatchSet(options) || !system.getModifiedTime) {
86770                 system.writeFile(fileName, data, writeByteOrderMark);
86771                 return;
86772             }
86773             if (!outputFingerprints) {
86774                 outputFingerprints = new ts.Map();
86775             }
86776             var hash = computeHash(data);
86777             var mtimeBefore = system.getModifiedTime(fileName);
86778             if (mtimeBefore) {
86779                 var fingerprint = outputFingerprints.get(fileName);
86780                 if (fingerprint &&
86781                     fingerprint.byteOrderMark === writeByteOrderMark &&
86782                     fingerprint.hash === hash &&
86783                     fingerprint.mtime.getTime() === mtimeBefore.getTime()) {
86784                     return;
86785                 }
86786             }
86787             system.writeFile(fileName, data, writeByteOrderMark);
86788             var mtimeAfter = system.getModifiedTime(fileName) || ts.missingFileModifiedTime;
86789             outputFingerprints.set(fileName, {
86790                 hash: hash,
86791                 byteOrderMark: writeByteOrderMark,
86792                 mtime: mtimeAfter
86793             });
86794         }
86795         function getDefaultLibLocation() {
86796             return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath()));
86797         }
86798         var newLine = ts.getNewLineCharacter(options, function () { return system.newLine; });
86799         var realpath = system.realpath && (function (path) { return system.realpath(path); });
86800         var compilerHost = {
86801             getSourceFile: getSourceFile,
86802             getDefaultLibLocation: getDefaultLibLocation,
86803             getDefaultLibFileName: function (options) { return ts.combinePaths(getDefaultLibLocation(), ts.getDefaultLibFileName(options)); },
86804             writeFile: writeFile,
86805             getCurrentDirectory: ts.memoize(function () { return system.getCurrentDirectory(); }),
86806             useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; },
86807             getCanonicalFileName: getCanonicalFileName,
86808             getNewLine: function () { return newLine; },
86809             fileExists: function (fileName) { return system.fileExists(fileName); },
86810             readFile: function (fileName) { return system.readFile(fileName); },
86811             trace: function (s) { return system.write(s + newLine); },
86812             directoryExists: function (directoryName) { return system.directoryExists(directoryName); },
86813             getEnvironmentVariable: function (name) { return system.getEnvironmentVariable ? system.getEnvironmentVariable(name) : ""; },
86814             getDirectories: function (path) { return system.getDirectories(path); },
86815             realpath: realpath,
86816             readDirectory: function (path, extensions, include, exclude, depth) { return system.readDirectory(path, extensions, include, exclude, depth); },
86817             createDirectory: function (d) { return system.createDirectory(d); },
86818             createHash: ts.maybeBind(system, system.createHash)
86819         };
86820         return compilerHost;
86821     }
86822     ts.createCompilerHostWorker = createCompilerHostWorker;
86823     function changeCompilerHostLikeToUseCache(host, toPath, getSourceFile) {
86824         var originalReadFile = host.readFile;
86825         var originalFileExists = host.fileExists;
86826         var originalDirectoryExists = host.directoryExists;
86827         var originalCreateDirectory = host.createDirectory;
86828         var originalWriteFile = host.writeFile;
86829         var readFileCache = new ts.Map();
86830         var fileExistsCache = new ts.Map();
86831         var directoryExistsCache = new ts.Map();
86832         var sourceFileCache = new ts.Map();
86833         var readFileWithCache = function (fileName) {
86834             var key = toPath(fileName);
86835             var value = readFileCache.get(key);
86836             if (value !== undefined)
86837                 return value !== false ? value : undefined;
86838             return setReadFileCache(key, fileName);
86839         };
86840         var setReadFileCache = function (key, fileName) {
86841             var newValue = originalReadFile.call(host, fileName);
86842             readFileCache.set(key, newValue !== undefined ? newValue : false);
86843             return newValue;
86844         };
86845         host.readFile = function (fileName) {
86846             var key = toPath(fileName);
86847             var value = readFileCache.get(key);
86848             if (value !== undefined)
86849                 return value !== false ? value : undefined;
86850             if (!ts.fileExtensionIs(fileName, ".json") && !ts.isBuildInfoFile(fileName)) {
86851                 return originalReadFile.call(host, fileName);
86852             }
86853             return setReadFileCache(key, fileName);
86854         };
86855         var getSourceFileWithCache = getSourceFile ? function (fileName, languageVersion, onError, shouldCreateNewSourceFile) {
86856             var key = toPath(fileName);
86857             var value = sourceFileCache.get(key);
86858             if (value)
86859                 return value;
86860             var sourceFile = getSourceFile(fileName, languageVersion, onError, shouldCreateNewSourceFile);
86861             if (sourceFile && (ts.isDeclarationFileName(fileName) || ts.fileExtensionIs(fileName, ".json"))) {
86862                 sourceFileCache.set(key, sourceFile);
86863             }
86864             return sourceFile;
86865         } : undefined;
86866         host.fileExists = function (fileName) {
86867             var key = toPath(fileName);
86868             var value = fileExistsCache.get(key);
86869             if (value !== undefined)
86870                 return value;
86871             var newValue = originalFileExists.call(host, fileName);
86872             fileExistsCache.set(key, !!newValue);
86873             return newValue;
86874         };
86875         if (originalWriteFile) {
86876             host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) {
86877                 var key = toPath(fileName);
86878                 fileExistsCache.delete(key);
86879                 var value = readFileCache.get(key);
86880                 if (value !== undefined && value !== data) {
86881                     readFileCache.delete(key);
86882                     sourceFileCache.delete(key);
86883                 }
86884                 else if (getSourceFileWithCache) {
86885                     var sourceFile = sourceFileCache.get(key);
86886                     if (sourceFile && sourceFile.text !== data) {
86887                         sourceFileCache.delete(key);
86888                     }
86889                 }
86890                 originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles);
86891             };
86892         }
86893         if (originalDirectoryExists && originalCreateDirectory) {
86894             host.directoryExists = function (directory) {
86895                 var key = toPath(directory);
86896                 var value = directoryExistsCache.get(key);
86897                 if (value !== undefined)
86898                     return value;
86899                 var newValue = originalDirectoryExists.call(host, directory);
86900                 directoryExistsCache.set(key, !!newValue);
86901                 return newValue;
86902             };
86903             host.createDirectory = function (directory) {
86904                 var key = toPath(directory);
86905                 directoryExistsCache.delete(key);
86906                 originalCreateDirectory.call(host, directory);
86907             };
86908         }
86909         return {
86910             originalReadFile: originalReadFile,
86911             originalFileExists: originalFileExists,
86912             originalDirectoryExists: originalDirectoryExists,
86913             originalCreateDirectory: originalCreateDirectory,
86914             originalWriteFile: originalWriteFile,
86915             getSourceFileWithCache: getSourceFileWithCache,
86916             readFileWithCache: readFileWithCache
86917         };
86918     }
86919     ts.changeCompilerHostLikeToUseCache = changeCompilerHostLikeToUseCache;
86920     function getPreEmitDiagnostics(program, sourceFile, cancellationToken) {
86921         var diagnostics;
86922         diagnostics = ts.addRange(diagnostics, program.getConfigFileParsingDiagnostics());
86923         diagnostics = ts.addRange(diagnostics, program.getOptionsDiagnostics(cancellationToken));
86924         diagnostics = ts.addRange(diagnostics, program.getSyntacticDiagnostics(sourceFile, cancellationToken));
86925         diagnostics = ts.addRange(diagnostics, program.getGlobalDiagnostics(cancellationToken));
86926         diagnostics = ts.addRange(diagnostics, program.getSemanticDiagnostics(sourceFile, cancellationToken));
86927         if (ts.getEmitDeclarations(program.getCompilerOptions())) {
86928             diagnostics = ts.addRange(diagnostics, program.getDeclarationDiagnostics(sourceFile, cancellationToken));
86929         }
86930         return ts.sortAndDeduplicateDiagnostics(diagnostics || ts.emptyArray);
86931     }
86932     ts.getPreEmitDiagnostics = getPreEmitDiagnostics;
86933     function formatDiagnostics(diagnostics, host) {
86934         var output = "";
86935         for (var _i = 0, diagnostics_3 = diagnostics; _i < diagnostics_3.length; _i++) {
86936             var diagnostic = diagnostics_3[_i];
86937             output += formatDiagnostic(diagnostic, host);
86938         }
86939         return output;
86940     }
86941     ts.formatDiagnostics = formatDiagnostics;
86942     function formatDiagnostic(diagnostic, host) {
86943         var errorMessage = ts.diagnosticCategoryName(diagnostic) + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine()) + host.getNewLine();
86944         if (diagnostic.file) {
86945             var _a = ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start), line = _a.line, character = _a.character;
86946             var fileName = diagnostic.file.fileName;
86947             var relativeFileName = ts.convertToRelativePath(fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); });
86948             return relativeFileName + "(" + (line + 1) + "," + (character + 1) + "): " + errorMessage;
86949         }
86950         return errorMessage;
86951     }
86952     ts.formatDiagnostic = formatDiagnostic;
86953     var ForegroundColorEscapeSequences;
86954     (function (ForegroundColorEscapeSequences) {
86955         ForegroundColorEscapeSequences["Grey"] = "\u001B[90m";
86956         ForegroundColorEscapeSequences["Red"] = "\u001B[91m";
86957         ForegroundColorEscapeSequences["Yellow"] = "\u001B[93m";
86958         ForegroundColorEscapeSequences["Blue"] = "\u001B[94m";
86959         ForegroundColorEscapeSequences["Cyan"] = "\u001B[96m";
86960     })(ForegroundColorEscapeSequences = ts.ForegroundColorEscapeSequences || (ts.ForegroundColorEscapeSequences = {}));
86961     var gutterStyleSequence = "\u001b[7m";
86962     var gutterSeparator = " ";
86963     var resetEscapeSequence = "\u001b[0m";
86964     var ellipsis = "...";
86965     var halfIndent = "  ";
86966     var indent = "    ";
86967     function getCategoryFormat(category) {
86968         switch (category) {
86969             case ts.DiagnosticCategory.Error: return ForegroundColorEscapeSequences.Red;
86970             case ts.DiagnosticCategory.Warning: return ForegroundColorEscapeSequences.Yellow;
86971             case ts.DiagnosticCategory.Suggestion: return ts.Debug.fail("Should never get an Info diagnostic on the command line.");
86972             case ts.DiagnosticCategory.Message: return ForegroundColorEscapeSequences.Blue;
86973         }
86974     }
86975     function formatColorAndReset(text, formatStyle) {
86976         return formatStyle + text + resetEscapeSequence;
86977     }
86978     ts.formatColorAndReset = formatColorAndReset;
86979     function formatCodeSpan(file, start, length, indent, squiggleColor, host) {
86980         var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character;
86981         var _b = ts.getLineAndCharacterOfPosition(file, start + length), lastLine = _b.line, lastLineChar = _b.character;
86982         var lastLineInFile = ts.getLineAndCharacterOfPosition(file, file.text.length).line;
86983         var hasMoreThanFiveLines = (lastLine - firstLine) >= 4;
86984         var gutterWidth = (lastLine + 1 + "").length;
86985         if (hasMoreThanFiveLines) {
86986             gutterWidth = Math.max(ellipsis.length, gutterWidth);
86987         }
86988         var context = "";
86989         for (var i = firstLine; i <= lastLine; i++) {
86990             context += host.getNewLine();
86991             if (hasMoreThanFiveLines && firstLine + 1 < i && i < lastLine - 1) {
86992                 context += indent + formatColorAndReset(ts.padLeft(ellipsis, gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine();
86993                 i = lastLine - 1;
86994             }
86995             var lineStart = ts.getPositionOfLineAndCharacter(file, i, 0);
86996             var lineEnd = i < lastLineInFile ? ts.getPositionOfLineAndCharacter(file, i + 1, 0) : file.text.length;
86997             var lineContent = file.text.slice(lineStart, lineEnd);
86998             lineContent = lineContent.replace(/\s+$/g, "");
86999             lineContent = lineContent.replace(/\t/g, " ");
87000             context += indent + formatColorAndReset(ts.padLeft(i + 1 + "", gutterWidth), gutterStyleSequence) + gutterSeparator;
87001             context += lineContent + host.getNewLine();
87002             context += indent + formatColorAndReset(ts.padLeft("", gutterWidth), gutterStyleSequence) + gutterSeparator;
87003             context += squiggleColor;
87004             if (i === firstLine) {
87005                 var lastCharForLine = i === lastLine ? lastLineChar : undefined;
87006                 context += lineContent.slice(0, firstLineChar).replace(/\S/g, " ");
87007                 context += lineContent.slice(firstLineChar, lastCharForLine).replace(/./g, "~");
87008             }
87009             else if (i === lastLine) {
87010                 context += lineContent.slice(0, lastLineChar).replace(/./g, "~");
87011             }
87012             else {
87013                 context += lineContent.replace(/./g, "~");
87014             }
87015             context += resetEscapeSequence;
87016         }
87017         return context;
87018     }
87019     function formatLocation(file, start, host, color) {
87020         if (color === void 0) { color = formatColorAndReset; }
87021         var _a = ts.getLineAndCharacterOfPosition(file, start), firstLine = _a.line, firstLineChar = _a.character;
87022         var relativeFileName = host ? ts.convertToRelativePath(file.fileName, host.getCurrentDirectory(), function (fileName) { return host.getCanonicalFileName(fileName); }) : file.fileName;
87023         var output = "";
87024         output += color(relativeFileName, ForegroundColorEscapeSequences.Cyan);
87025         output += ":";
87026         output += color("" + (firstLine + 1), ForegroundColorEscapeSequences.Yellow);
87027         output += ":";
87028         output += color("" + (firstLineChar + 1), ForegroundColorEscapeSequences.Yellow);
87029         return output;
87030     }
87031     ts.formatLocation = formatLocation;
87032     function formatDiagnosticsWithColorAndContext(diagnostics, host) {
87033         var output = "";
87034         for (var _i = 0, diagnostics_4 = diagnostics; _i < diagnostics_4.length; _i++) {
87035             var diagnostic = diagnostics_4[_i];
87036             if (diagnostic.file) {
87037                 var file = diagnostic.file, start = diagnostic.start;
87038                 output += formatLocation(file, start, host);
87039                 output += " - ";
87040             }
87041             output += formatColorAndReset(ts.diagnosticCategoryName(diagnostic), getCategoryFormat(diagnostic.category));
87042             output += formatColorAndReset(" TS" + diagnostic.code + ": ", ForegroundColorEscapeSequences.Grey);
87043             output += flattenDiagnosticMessageText(diagnostic.messageText, host.getNewLine());
87044             if (diagnostic.file) {
87045                 output += host.getNewLine();
87046                 output += formatCodeSpan(diagnostic.file, diagnostic.start, diagnostic.length, "", getCategoryFormat(diagnostic.category), host);
87047             }
87048             if (diagnostic.relatedInformation) {
87049                 output += host.getNewLine();
87050                 for (var _a = 0, _b = diagnostic.relatedInformation; _a < _b.length; _a++) {
87051                     var _c = _b[_a], file = _c.file, start = _c.start, length_9 = _c.length, messageText = _c.messageText;
87052                     if (file) {
87053                         output += host.getNewLine();
87054                         output += halfIndent + formatLocation(file, start, host);
87055                         output += formatCodeSpan(file, start, length_9, indent, ForegroundColorEscapeSequences.Cyan, host);
87056                     }
87057                     output += host.getNewLine();
87058                     output += indent + flattenDiagnosticMessageText(messageText, host.getNewLine());
87059                 }
87060             }
87061             output += host.getNewLine();
87062         }
87063         return output;
87064     }
87065     ts.formatDiagnosticsWithColorAndContext = formatDiagnosticsWithColorAndContext;
87066     function flattenDiagnosticMessageText(diag, newLine, indent) {
87067         if (indent === void 0) { indent = 0; }
87068         if (ts.isString(diag)) {
87069             return diag;
87070         }
87071         else if (diag === undefined) {
87072             return "";
87073         }
87074         var result = "";
87075         if (indent) {
87076             result += newLine;
87077             for (var i = 0; i < indent; i++) {
87078                 result += "  ";
87079             }
87080         }
87081         result += diag.messageText;
87082         indent++;
87083         if (diag.next) {
87084             for (var _i = 0, _a = diag.next; _i < _a.length; _i++) {
87085                 var kid = _a[_i];
87086                 result += flattenDiagnosticMessageText(kid, newLine, indent);
87087             }
87088         }
87089         return result;
87090     }
87091     ts.flattenDiagnosticMessageText = flattenDiagnosticMessageText;
87092     function loadWithLocalCache(names, containingFile, redirectedReference, loader) {
87093         if (names.length === 0) {
87094             return [];
87095         }
87096         var resolutions = [];
87097         var cache = new ts.Map();
87098         for (var _i = 0, names_2 = names; _i < names_2.length; _i++) {
87099             var name = names_2[_i];
87100             var result = void 0;
87101             if (cache.has(name)) {
87102                 result = cache.get(name);
87103             }
87104             else {
87105                 cache.set(name, result = loader(name, containingFile, redirectedReference));
87106             }
87107             resolutions.push(result);
87108         }
87109         return resolutions;
87110     }
87111     ts.loadWithLocalCache = loadWithLocalCache;
87112     function forEachResolvedProjectReference(resolvedProjectReferences, cb) {
87113         return forEachProjectReference(undefined, resolvedProjectReferences, function (resolvedRef, parent) { return resolvedRef && cb(resolvedRef, parent); });
87114     }
87115     ts.forEachResolvedProjectReference = forEachResolvedProjectReference;
87116     function forEachProjectReference(projectReferences, resolvedProjectReferences, cbResolvedRef, cbRef) {
87117         var seenResolvedRefs;
87118         return worker(projectReferences, resolvedProjectReferences, undefined);
87119         function worker(projectReferences, resolvedProjectReferences, parent) {
87120             if (cbRef) {
87121                 var result = cbRef(projectReferences, parent);
87122                 if (result) {
87123                     return result;
87124                 }
87125             }
87126             return ts.forEach(resolvedProjectReferences, function (resolvedRef, index) {
87127                 if (resolvedRef && (seenResolvedRefs === null || seenResolvedRefs === void 0 ? void 0 : seenResolvedRefs.has(resolvedRef.sourceFile.path))) {
87128                     return undefined;
87129                 }
87130                 var result = cbResolvedRef(resolvedRef, parent, index);
87131                 if (result || !resolvedRef)
87132                     return result;
87133                 (seenResolvedRefs || (seenResolvedRefs = new ts.Set())).add(resolvedRef.sourceFile.path);
87134                 return worker(resolvedRef.commandLine.projectReferences, resolvedRef.references, resolvedRef);
87135             });
87136         }
87137     }
87138     ts.inferredTypesContainingFile = "__inferred type names__.ts";
87139     function isReferencedFile(reason) {
87140         switch (reason === null || reason === void 0 ? void 0 : reason.kind) {
87141             case ts.FileIncludeKind.Import:
87142             case ts.FileIncludeKind.ReferenceFile:
87143             case ts.FileIncludeKind.TypeReferenceDirective:
87144             case ts.FileIncludeKind.LibReferenceDirective:
87145                 return true;
87146             default:
87147                 return false;
87148         }
87149     }
87150     ts.isReferencedFile = isReferencedFile;
87151     function isReferenceFileLocation(location) {
87152         return location.pos !== undefined;
87153     }
87154     ts.isReferenceFileLocation = isReferenceFileLocation;
87155     function getReferencedFileLocation(getSourceFileByPath, ref) {
87156         var _a, _b, _c;
87157         var _d, _e, _f, _g;
87158         var file = ts.Debug.checkDefined(getSourceFileByPath(ref.file));
87159         var kind = ref.kind, index = ref.index;
87160         var pos, end, packageId;
87161         switch (kind) {
87162             case ts.FileIncludeKind.Import:
87163                 var importLiteral = getModuleNameStringLiteralAt(file, index);
87164                 packageId = (_e = (_d = file.resolvedModules) === null || _d === void 0 ? void 0 : _d.get(importLiteral.text)) === null || _e === void 0 ? void 0 : _e.packageId;
87165                 if (importLiteral.pos === -1)
87166                     return { file: file, packageId: packageId, text: importLiteral.text };
87167                 pos = ts.skipTrivia(file.text, importLiteral.pos);
87168                 end = importLiteral.end;
87169                 break;
87170             case ts.FileIncludeKind.ReferenceFile:
87171                 (_a = file.referencedFiles[index], pos = _a.pos, end = _a.end);
87172                 break;
87173             case ts.FileIncludeKind.TypeReferenceDirective:
87174                 (_b = file.typeReferenceDirectives[index], pos = _b.pos, end = _b.end);
87175                 packageId = (_g = (_f = file.resolvedTypeReferenceDirectiveNames) === null || _f === void 0 ? void 0 : _f.get(ts.toFileNameLowerCase(file.typeReferenceDirectives[index].fileName))) === null || _g === void 0 ? void 0 : _g.packageId;
87176                 break;
87177             case ts.FileIncludeKind.LibReferenceDirective:
87178                 (_c = file.libReferenceDirectives[index], pos = _c.pos, end = _c.end);
87179                 break;
87180             default:
87181                 return ts.Debug.assertNever(kind);
87182         }
87183         return { file: file, pos: pos, end: end, packageId: packageId };
87184     }
87185     ts.getReferencedFileLocation = getReferencedFileLocation;
87186     function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences) {
87187         if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames())) {
87188             return false;
87189         }
87190         if (!ts.arrayIsEqualTo(program.getRootFileNames(), rootFileNames)) {
87191             return false;
87192         }
87193         var seenResolvedRefs;
87194         if (!ts.arrayIsEqualTo(program.getProjectReferences(), projectReferences, projectReferenceUptoDate)) {
87195             return false;
87196         }
87197         if (program.getSourceFiles().some(sourceFileNotUptoDate)) {
87198             return false;
87199         }
87200         if (program.getMissingFilePaths().some(fileExists)) {
87201             return false;
87202         }
87203         var currentOptions = program.getCompilerOptions();
87204         if (!ts.compareDataObjects(currentOptions, newOptions)) {
87205             return false;
87206         }
87207         if (currentOptions.configFile && newOptions.configFile) {
87208             return currentOptions.configFile.text === newOptions.configFile.text;
87209         }
87210         return true;
87211         function sourceFileNotUptoDate(sourceFile) {
87212             return !sourceFileVersionUptoDate(sourceFile) ||
87213                 hasInvalidatedResolution(sourceFile.path);
87214         }
87215         function sourceFileVersionUptoDate(sourceFile) {
87216             return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName);
87217         }
87218         function projectReferenceUptoDate(oldRef, newRef, index) {
87219             if (!ts.projectReferenceIsEqualTo(oldRef, newRef)) {
87220                 return false;
87221             }
87222             return resolvedProjectReferenceUptoDate(program.getResolvedProjectReferences()[index], oldRef);
87223         }
87224         function resolvedProjectReferenceUptoDate(oldResolvedRef, oldRef) {
87225             if (oldResolvedRef) {
87226                 if (ts.contains(seenResolvedRefs, oldResolvedRef)) {
87227                     return true;
87228                 }
87229                 if (!sourceFileVersionUptoDate(oldResolvedRef.sourceFile)) {
87230                     return false;
87231                 }
87232                 (seenResolvedRefs || (seenResolvedRefs = [])).push(oldResolvedRef);
87233                 return !ts.forEach(oldResolvedRef.references, function (childResolvedRef, index) {
87234                     return !resolvedProjectReferenceUptoDate(childResolvedRef, oldResolvedRef.commandLine.projectReferences[index]);
87235                 });
87236             }
87237             return !fileExists(resolveProjectReferencePath(oldRef));
87238         }
87239     }
87240     ts.isProgramUptoDate = isProgramUptoDate;
87241     function getConfigFileParsingDiagnostics(configFileParseResult) {
87242         return configFileParseResult.options.configFile ? __spreadArray(__spreadArray([], configFileParseResult.options.configFile.parseDiagnostics), configFileParseResult.errors) :
87243             configFileParseResult.errors;
87244     }
87245     ts.getConfigFileParsingDiagnostics = getConfigFileParsingDiagnostics;
87246     function shouldProgramCreateNewSourceFiles(program, newOptions) {
87247         if (!program)
87248             return false;
87249         var oldOptions = program.getCompilerOptions();
87250         return !!ts.sourceFileAffectingCompilerOptions.some(function (option) {
87251             return !ts.isJsonEqual(ts.getCompilerOptionValue(oldOptions, option), ts.getCompilerOptionValue(newOptions, option));
87252         });
87253     }
87254     function createCreateProgramOptions(rootNames, options, host, oldProgram, configFileParsingDiagnostics) {
87255         return {
87256             rootNames: rootNames,
87257             options: options,
87258             host: host,
87259             oldProgram: oldProgram,
87260             configFileParsingDiagnostics: configFileParsingDiagnostics
87261         };
87262     }
87263     function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) {
87264         var _a, _b, _c;
87265         var createProgramOptions = ts.isArray(rootNamesOrOptions) ? createCreateProgramOptions(rootNamesOrOptions, _options, _host, _oldProgram, _configFileParsingDiagnostics) : rootNamesOrOptions;
87266         var rootNames = createProgramOptions.rootNames, options = createProgramOptions.options, configFileParsingDiagnostics = createProgramOptions.configFileParsingDiagnostics, projectReferences = createProgramOptions.projectReferences;
87267         var oldProgram = createProgramOptions.oldProgram;
87268         var processingDefaultLibFiles;
87269         var processingOtherFiles;
87270         var files;
87271         var symlinks;
87272         var commonSourceDirectory;
87273         var diagnosticsProducingTypeChecker;
87274         var noDiagnosticsTypeChecker;
87275         var classifiableNames;
87276         var ambientModuleNameToUnmodifiedFileName = new ts.Map();
87277         var fileReasons = ts.createMultiMap();
87278         var cachedBindAndCheckDiagnosticsForFile = {};
87279         var cachedDeclarationDiagnosticsForFile = {};
87280         var resolvedTypeReferenceDirectives = new ts.Map();
87281         var fileProcessingDiagnostics;
87282         var maxNodeModuleJsDepth = typeof options.maxNodeModuleJsDepth === "number" ? options.maxNodeModuleJsDepth : 0;
87283         var currentNodeModulesDepth = 0;
87284         var modulesWithElidedImports = new ts.Map();
87285         var sourceFilesFoundSearchingNodeModules = new ts.Map();
87286         ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "createProgram", { configFilePath: options.configFilePath, rootDir: options.rootDir }, true);
87287         ts.performance.mark("beforeProgram");
87288         var host = createProgramOptions.host || createCompilerHost(options);
87289         var configParsingHost = parseConfigHostFromCompilerHostLike(host);
87290         var skipDefaultLib = options.noLib;
87291         var getDefaultLibraryFileName = ts.memoize(function () { return host.getDefaultLibFileName(options); });
87292         var defaultLibraryPath = host.getDefaultLibLocation ? host.getDefaultLibLocation() : ts.getDirectoryPath(getDefaultLibraryFileName());
87293         var programDiagnostics = ts.createDiagnosticCollection();
87294         var currentDirectory = host.getCurrentDirectory();
87295         var supportedExtensions = ts.getSupportedExtensions(options);
87296         var supportedExtensionsWithJsonIfResolveJsonModule = ts.getSuppoertedExtensionsWithJsonIfResolveJsonModule(options, supportedExtensions);
87297         var hasEmitBlockingDiagnostics = new ts.Map();
87298         var _compilerOptionsObjectLiteralSyntax;
87299         var moduleResolutionCache;
87300         var actualResolveModuleNamesWorker;
87301         var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
87302         if (host.resolveModuleNames) {
87303             actualResolveModuleNamesWorker = function (moduleNames, containingFile, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFile, reusedNames, redirectedReference, options).map(function (resolved) {
87304                 if (!resolved || resolved.extension !== undefined) {
87305                     return resolved;
87306                 }
87307                 var withExtension = ts.clone(resolved);
87308                 withExtension.extension = ts.extensionFromPath(resolved.resolvedFileName);
87309                 return withExtension;
87310             }); };
87311         }
87312         else {
87313             moduleResolutionCache = ts.createModuleResolutionCache(currentDirectory, function (x) { return host.getCanonicalFileName(x); }, options);
87314             var loader_1 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, options, host, moduleResolutionCache, redirectedReference).resolvedModule; };
87315             actualResolveModuleNamesWorker = function (moduleNames, containingFile, _reusedNames, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_1); };
87316         }
87317         var actualResolveTypeReferenceDirectiveNamesWorker;
87318         if (host.resolveTypeReferenceDirectives) {
87319             actualResolveTypeReferenceDirectiveNamesWorker = function (typeDirectiveNames, containingFile, redirectedReference) { return host.resolveTypeReferenceDirectives(ts.Debug.checkEachDefined(typeDirectiveNames), containingFile, redirectedReference, options); };
87320         }
87321         else {
87322             var loader_2 = function (typesRef, containingFile, redirectedReference) { return ts.resolveTypeReferenceDirective(typesRef, containingFile, options, host, redirectedReference).resolvedTypeReferenceDirective; };
87323             actualResolveTypeReferenceDirectiveNamesWorker = function (typeReferenceDirectiveNames, containingFile, redirectedReference) { return loadWithLocalCache(ts.Debug.checkEachDefined(typeReferenceDirectiveNames), containingFile, redirectedReference, loader_2); };
87324         }
87325         var packageIdToSourceFile = new ts.Map();
87326         var sourceFileToPackageName = new ts.Map();
87327         var redirectTargetsMap = ts.createMultiMap();
87328         var filesByName = new ts.Map();
87329         var missingFilePaths;
87330         var filesByNameIgnoreCase = host.useCaseSensitiveFileNames() ? new ts.Map() : undefined;
87331         var resolvedProjectReferences;
87332         var projectReferenceRedirects;
87333         var mapFromFileToProjectReferenceRedirects;
87334         var mapFromToProjectReferenceRedirectSource;
87335         var useSourceOfProjectReferenceRedirect = !!((_a = host.useSourceOfProjectReferenceRedirect) === null || _a === void 0 ? void 0 : _a.call(host)) &&
87336             !options.disableSourceOfProjectReferenceRedirect;
87337         var _d = updateHostForUseSourceOfProjectReferenceRedirect({
87338             compilerHost: host,
87339             getSymlinkCache: getSymlinkCache,
87340             useSourceOfProjectReferenceRedirect: useSourceOfProjectReferenceRedirect,
87341             toPath: toPath,
87342             getResolvedProjectReferences: getResolvedProjectReferences,
87343             getSourceOfProjectReferenceRedirect: getSourceOfProjectReferenceRedirect,
87344             forEachResolvedProjectReference: forEachResolvedProjectReference
87345         }), onProgramCreateComplete = _d.onProgramCreateComplete, fileExists = _d.fileExists, directoryExists = _d.directoryExists;
87346         ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "shouldProgramCreateNewSourceFiles", { hasOldProgram: !!oldProgram });
87347         var shouldCreateNewSourceFile = shouldProgramCreateNewSourceFiles(oldProgram, options);
87348         ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
87349         var structureIsReused;
87350         ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "tryReuseStructureFromOldProgram", {});
87351         structureIsReused = tryReuseStructureFromOldProgram();
87352         ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
87353         if (structureIsReused !== 2) {
87354             processingDefaultLibFiles = [];
87355             processingOtherFiles = [];
87356             if (projectReferences) {
87357                 if (!resolvedProjectReferences) {
87358                     resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile);
87359                 }
87360                 if (rootNames.length) {
87361                     resolvedProjectReferences === null || resolvedProjectReferences === void 0 ? void 0 : resolvedProjectReferences.forEach(function (parsedRef, index) {
87362                         if (!parsedRef)
87363                             return;
87364                         var out = ts.outFile(parsedRef.commandLine.options);
87365                         if (useSourceOfProjectReferenceRedirect) {
87366                             if (out || ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) {
87367                                 for (var _i = 0, _a = parsedRef.commandLine.fileNames; _i < _a.length; _i++) {
87368                                     var fileName = _a[_i];
87369                                     processProjectReferenceFile(fileName, { kind: ts.FileIncludeKind.SourceFromProjectReference, index: index });
87370                                 }
87371                             }
87372                         }
87373                         else {
87374                             if (out) {
87375                                 processProjectReferenceFile(ts.changeExtension(out, ".d.ts"), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index });
87376                             }
87377                             else if (ts.getEmitModuleKind(parsedRef.commandLine.options) === ts.ModuleKind.None) {
87378                                 var getCommonSourceDirectory_2 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(parsedRef.commandLine, !host.useCaseSensitiveFileNames()); });
87379                                 for (var _b = 0, _c = parsedRef.commandLine.fileNames; _b < _c.length; _b++) {
87380                                     var fileName = _c[_b];
87381                                     if (!ts.fileExtensionIs(fileName, ".d.ts") && !ts.fileExtensionIs(fileName, ".json")) {
87382                                         processProjectReferenceFile(ts.getOutputDeclarationFileName(fileName, parsedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_2), { kind: ts.FileIncludeKind.OutputFromProjectReference, index: index });
87383                                     }
87384                                 }
87385                             }
87386                         }
87387                     });
87388                 }
87389             }
87390             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processRootFiles", { count: rootNames.length });
87391             ts.forEach(rootNames, function (name, index) { return processRootFile(name, false, false, { kind: ts.FileIncludeKind.RootFile, index: index }); });
87392             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
87393             var typeReferences = rootNames.length ? ts.getAutomaticTypeDirectiveNames(options, host) : ts.emptyArray;
87394             if (typeReferences.length) {
87395                 ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferences", { count: typeReferences.length });
87396                 var containingDirectory = options.configFilePath ? ts.getDirectoryPath(options.configFilePath) : host.getCurrentDirectory();
87397                 var containingFilename = ts.combinePaths(containingDirectory, ts.inferredTypesContainingFile);
87398                 var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeReferences, containingFilename);
87399                 for (var i = 0; i < typeReferences.length; i++) {
87400                     processTypeReferenceDirective(typeReferences[i], resolutions[i], { kind: ts.FileIncludeKind.AutomaticTypeDirectiveFile, typeReference: typeReferences[i], packageId: (_b = resolutions[i]) === null || _b === void 0 ? void 0 : _b.packageId });
87401                 }
87402                 ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
87403             }
87404             if (rootNames.length && !skipDefaultLib) {
87405                 var defaultLibraryFileName = getDefaultLibraryFileName();
87406                 if (!options.lib && defaultLibraryFileName) {
87407                     processRootFile(defaultLibraryFileName, true, false, { kind: ts.FileIncludeKind.LibFile });
87408                 }
87409                 else {
87410                     ts.forEach(options.lib, function (libFileName, index) {
87411                         processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), true, false, { kind: ts.FileIncludeKind.LibFile, index: index });
87412                     });
87413                 }
87414             }
87415             missingFilePaths = ts.arrayFrom(ts.mapDefinedIterator(filesByName.entries(), function (_a) {
87416                 var path = _a[0], file = _a[1];
87417                 return file === undefined ? path : undefined;
87418             }));
87419             files = ts.stableSort(processingDefaultLibFiles, compareDefaultLibFiles).concat(processingOtherFiles);
87420             processingDefaultLibFiles = undefined;
87421             processingOtherFiles = undefined;
87422         }
87423         ts.Debug.assert(!!missingFilePaths);
87424         if (oldProgram && host.onReleaseOldSourceFile) {
87425             var oldSourceFiles = oldProgram.getSourceFiles();
87426             for (var _i = 0, oldSourceFiles_1 = oldSourceFiles; _i < oldSourceFiles_1.length; _i++) {
87427                 var oldSourceFile = oldSourceFiles_1[_i];
87428                 var newFile = getSourceFileByPath(oldSourceFile.resolvedPath);
87429                 if (shouldCreateNewSourceFile || !newFile ||
87430                     (oldSourceFile.resolvedPath === oldSourceFile.path && newFile.resolvedPath !== oldSourceFile.path)) {
87431                     host.onReleaseOldSourceFile(oldSourceFile, oldProgram.getCompilerOptions(), !!getSourceFileByPath(oldSourceFile.path));
87432                 }
87433             }
87434             oldProgram.forEachResolvedProjectReference(function (resolvedProjectReference) {
87435                 if (!getResolvedProjectReferenceByPath(resolvedProjectReference.sourceFile.path)) {
87436                     host.onReleaseOldSourceFile(resolvedProjectReference.sourceFile, oldProgram.getCompilerOptions(), false);
87437                 }
87438             });
87439         }
87440         oldProgram = undefined;
87441         var program = {
87442             getRootFileNames: function () { return rootNames; },
87443             getSourceFile: getSourceFile,
87444             getSourceFileByPath: getSourceFileByPath,
87445             getSourceFiles: function () { return files; },
87446             getMissingFilePaths: function () { return missingFilePaths; },
87447             getFilesByNameMap: function () { return filesByName; },
87448             getCompilerOptions: function () { return options; },
87449             getSyntacticDiagnostics: getSyntacticDiagnostics,
87450             getOptionsDiagnostics: getOptionsDiagnostics,
87451             getGlobalDiagnostics: getGlobalDiagnostics,
87452             getSemanticDiagnostics: getSemanticDiagnostics,
87453             getCachedSemanticDiagnostics: getCachedSemanticDiagnostics,
87454             getSuggestionDiagnostics: getSuggestionDiagnostics,
87455             getDeclarationDiagnostics: getDeclarationDiagnostics,
87456             getBindAndCheckDiagnostics: getBindAndCheckDiagnostics,
87457             getProgramDiagnostics: getProgramDiagnostics,
87458             getTypeChecker: getTypeChecker,
87459             getClassifiableNames: getClassifiableNames,
87460             getDiagnosticsProducingTypeChecker: getDiagnosticsProducingTypeChecker,
87461             getCommonSourceDirectory: getCommonSourceDirectory,
87462             emit: emit,
87463             getCurrentDirectory: function () { return currentDirectory; },
87464             getNodeCount: function () { return getDiagnosticsProducingTypeChecker().getNodeCount(); },
87465             getIdentifierCount: function () { return getDiagnosticsProducingTypeChecker().getIdentifierCount(); },
87466             getSymbolCount: function () { return getDiagnosticsProducingTypeChecker().getSymbolCount(); },
87467             getTypeCatalog: function () { return getDiagnosticsProducingTypeChecker().getTypeCatalog(); },
87468             getTypeCount: function () { return getDiagnosticsProducingTypeChecker().getTypeCount(); },
87469             getInstantiationCount: function () { return getDiagnosticsProducingTypeChecker().getInstantiationCount(); },
87470             getRelationCacheSizes: function () { return getDiagnosticsProducingTypeChecker().getRelationCacheSizes(); },
87471             getFileProcessingDiagnostics: function () { return fileProcessingDiagnostics; },
87472             getResolvedTypeReferenceDirectives: function () { return resolvedTypeReferenceDirectives; },
87473             isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
87474             isSourceFileDefaultLibrary: isSourceFileDefaultLibrary,
87475             dropDiagnosticsProducingTypeChecker: dropDiagnosticsProducingTypeChecker,
87476             getSourceFileFromReference: getSourceFileFromReference,
87477             getLibFileFromReference: getLibFileFromReference,
87478             sourceFileToPackageName: sourceFileToPackageName,
87479             redirectTargetsMap: redirectTargetsMap,
87480             isEmittedFile: isEmittedFile,
87481             getConfigFileParsingDiagnostics: getConfigFileParsingDiagnostics,
87482             getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
87483             getProjectReferences: getProjectReferences,
87484             getResolvedProjectReferences: getResolvedProjectReferences,
87485             getProjectReferenceRedirect: getProjectReferenceRedirect,
87486             getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
87487             getResolvedProjectReferenceByPath: getResolvedProjectReferenceByPath,
87488             forEachResolvedProjectReference: forEachResolvedProjectReference,
87489             isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
87490             emitBuildInfo: emitBuildInfo,
87491             fileExists: fileExists,
87492             directoryExists: directoryExists,
87493             getSymlinkCache: getSymlinkCache,
87494             realpath: (_c = host.realpath) === null || _c === void 0 ? void 0 : _c.bind(host),
87495             useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
87496             getFileIncludeReasons: function () { return fileReasons; },
87497             structureIsReused: structureIsReused,
87498         };
87499         onProgramCreateComplete();
87500         fileProcessingDiagnostics === null || fileProcessingDiagnostics === void 0 ? void 0 : fileProcessingDiagnostics.forEach(function (diagnostic) {
87501             switch (diagnostic.kind) {
87502                 case 1:
87503                     return programDiagnostics.add(createDiagnosticExplainingFile(diagnostic.file && getSourceFileByPath(diagnostic.file), diagnostic.fileProcessingReason, diagnostic.diagnostic, diagnostic.args || ts.emptyArray));
87504                 case 0:
87505                     var _a = getReferencedFileLocation(getSourceFileByPath, diagnostic.reason), file = _a.file, pos = _a.pos, end = _a.end;
87506                     return programDiagnostics.add(ts.createFileDiagnostic.apply(void 0, __spreadArray([file, ts.Debug.checkDefined(pos), ts.Debug.checkDefined(end) - pos, diagnostic.diagnostic], diagnostic.args || ts.emptyArray)));
87507                 default:
87508                     ts.Debug.assertNever(diagnostic);
87509             }
87510         });
87511         verifyCompilerOptions();
87512         ts.performance.mark("afterProgram");
87513         ts.performance.measure("Program", "beforeProgram", "afterProgram");
87514         ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
87515         return program;
87516         function resolveModuleNamesWorker(moduleNames, containingFile, reusedNames) {
87517             if (!moduleNames.length)
87518                 return ts.emptyArray;
87519             var containingFileName = ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory);
87520             var redirectedReference = getRedirectReferenceForResolution(containingFile);
87521             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "resolveModuleNamesWorker", { containingFileName: containingFileName });
87522             ts.performance.mark("beforeResolveModule");
87523             var result = actualResolveModuleNamesWorker(moduleNames, containingFileName, reusedNames, redirectedReference);
87524             ts.performance.mark("afterResolveModule");
87525             ts.performance.measure("ResolveModule", "beforeResolveModule", "afterResolveModule");
87526             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
87527             return result;
87528         }
87529         function resolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFile) {
87530             if (!typeDirectiveNames.length)
87531                 return [];
87532             var containingFileName = !ts.isString(containingFile) ? ts.getNormalizedAbsolutePath(containingFile.originalFileName, currentDirectory) : containingFile;
87533             var redirectedReference = !ts.isString(containingFile) ? getRedirectReferenceForResolution(containingFile) : undefined;
87534             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "resolveTypeReferenceDirectiveNamesWorker", { containingFileName: containingFileName });
87535             ts.performance.mark("beforeResolveTypeReference");
87536             var result = actualResolveTypeReferenceDirectiveNamesWorker(typeDirectiveNames, containingFileName, redirectedReference);
87537             ts.performance.mark("afterResolveTypeReference");
87538             ts.performance.measure("ResolveTypeReference", "beforeResolveTypeReference", "afterResolveTypeReference");
87539             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
87540             return result;
87541         }
87542         function getRedirectReferenceForResolution(file) {
87543             var redirect = getResolvedProjectReferenceToRedirect(file.originalFileName);
87544             if (redirect || !ts.fileExtensionIs(file.originalFileName, ".d.ts"))
87545                 return redirect;
87546             var resultFromDts = getRedirectReferenceForResolutionFromSourceOfProject(file.originalFileName, file.path);
87547             if (resultFromDts)
87548                 return resultFromDts;
87549             if (!host.realpath || !options.preserveSymlinks || !ts.stringContains(file.originalFileName, ts.nodeModulesPathPart))
87550                 return undefined;
87551             var realDeclarationFileName = host.realpath(file.originalFileName);
87552             var realDeclarationPath = toPath(realDeclarationFileName);
87553             return realDeclarationPath === file.path ? undefined : getRedirectReferenceForResolutionFromSourceOfProject(realDeclarationFileName, realDeclarationPath);
87554         }
87555         function getRedirectReferenceForResolutionFromSourceOfProject(fileName, filePath) {
87556             var source = getSourceOfProjectReferenceRedirect(fileName);
87557             if (ts.isString(source))
87558                 return getResolvedProjectReferenceToRedirect(source);
87559             if (!source)
87560                 return undefined;
87561             return forEachResolvedProjectReference(function (resolvedRef) {
87562                 var out = ts.outFile(resolvedRef.commandLine.options);
87563                 if (!out)
87564                     return undefined;
87565                 return toPath(out) === filePath ? resolvedRef : undefined;
87566             });
87567         }
87568         function compareDefaultLibFiles(a, b) {
87569             return ts.compareValues(getDefaultLibFilePriority(a), getDefaultLibFilePriority(b));
87570         }
87571         function getDefaultLibFilePriority(a) {
87572             if (ts.containsPath(defaultLibraryPath, a.fileName, false)) {
87573                 var basename = ts.getBaseFileName(a.fileName);
87574                 if (basename === "lib.d.ts" || basename === "lib.es6.d.ts")
87575                     return 0;
87576                 var name = ts.removeSuffix(ts.removePrefix(basename, "lib."), ".d.ts");
87577                 var index = ts.libs.indexOf(name);
87578                 if (index !== -1)
87579                     return index + 1;
87580             }
87581             return ts.libs.length + 2;
87582         }
87583         function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
87584             return moduleResolutionCache && ts.resolveModuleNameFromCache(moduleName, containingFile, moduleResolutionCache);
87585         }
87586         function toPath(fileName) {
87587             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
87588         }
87589         function getCommonSourceDirectory() {
87590             if (commonSourceDirectory === undefined) {
87591                 var emittedFiles_1 = ts.filter(files, function (file) { return ts.sourceFileMayBeEmitted(file, program); });
87592                 commonSourceDirectory = ts.getCommonSourceDirectory(options, function () { return ts.mapDefined(emittedFiles_1, function (file) { return file.isDeclarationFile ? undefined : file.fileName; }); }, currentDirectory, getCanonicalFileName, function (commonSourceDirectory) { return checkSourceFilesBelongToPath(emittedFiles_1, commonSourceDirectory); });
87593             }
87594             return commonSourceDirectory;
87595         }
87596         function getClassifiableNames() {
87597             var _a;
87598             if (!classifiableNames) {
87599                 getTypeChecker();
87600                 classifiableNames = new ts.Set();
87601                 for (var _i = 0, files_2 = files; _i < files_2.length; _i++) {
87602                     var sourceFile = files_2[_i];
87603                     (_a = sourceFile.classifiableNames) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return classifiableNames.add(value); });
87604                 }
87605             }
87606             return classifiableNames;
87607         }
87608         function resolveModuleNamesReusingOldState(moduleNames, file) {
87609             if (structureIsReused === 0 && !file.ambientModuleNames.length) {
87610                 return resolveModuleNamesWorker(moduleNames, file, undefined);
87611             }
87612             var oldSourceFile = oldProgram && oldProgram.getSourceFile(file.fileName);
87613             if (oldSourceFile !== file && file.resolvedModules) {
87614                 var result_14 = [];
87615                 for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
87616                     var moduleName = moduleNames_1[_i];
87617                     var resolvedModule = file.resolvedModules.get(moduleName);
87618                     result_14.push(resolvedModule);
87619                 }
87620                 return result_14;
87621             }
87622             var unknownModuleNames;
87623             var result;
87624             var reusedNames;
87625             var predictedToResolveToAmbientModuleMarker = {};
87626             for (var i = 0; i < moduleNames.length; i++) {
87627                 var moduleName = moduleNames[i];
87628                 if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
87629                     var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName);
87630                     if (oldResolvedModule) {
87631                         if (ts.isTraceEnabled(options, host)) {
87632                             ts.trace(host, ts.Diagnostics.Reusing_resolution_of_module_0_to_file_1_from_old_program, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory));
87633                         }
87634                         (result || (result = new Array(moduleNames.length)))[i] = oldResolvedModule;
87635                         (reusedNames || (reusedNames = [])).push(moduleName);
87636                         continue;
87637                     }
87638                 }
87639                 var resolvesToAmbientModuleInNonModifiedFile = false;
87640                 if (ts.contains(file.ambientModuleNames, moduleName)) {
87641                     resolvesToAmbientModuleInNonModifiedFile = true;
87642                     if (ts.isTraceEnabled(options, host)) {
87643                         ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_locally_declared_ambient_module_in_file_1, moduleName, ts.getNormalizedAbsolutePath(file.originalFileName, currentDirectory));
87644                     }
87645                 }
87646                 else {
87647                     resolvesToAmbientModuleInNonModifiedFile = moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName);
87648                 }
87649                 if (resolvesToAmbientModuleInNonModifiedFile) {
87650                     (result || (result = new Array(moduleNames.length)))[i] = predictedToResolveToAmbientModuleMarker;
87651                 }
87652                 else {
87653                     (unknownModuleNames || (unknownModuleNames = [])).push(moduleName);
87654                 }
87655             }
87656             var resolutions = unknownModuleNames && unknownModuleNames.length
87657                 ? resolveModuleNamesWorker(unknownModuleNames, file, reusedNames)
87658                 : ts.emptyArray;
87659             if (!result) {
87660                 ts.Debug.assert(resolutions.length === moduleNames.length);
87661                 return resolutions;
87662             }
87663             var j = 0;
87664             for (var i = 0; i < result.length; i++) {
87665                 if (result[i]) {
87666                     if (result[i] === predictedToResolveToAmbientModuleMarker) {
87667                         result[i] = undefined;
87668                     }
87669                 }
87670                 else {
87671                     result[i] = resolutions[j];
87672                     j++;
87673                 }
87674             }
87675             ts.Debug.assert(j === resolutions.length);
87676             return result;
87677             function moduleNameResolvesToAmbientModuleInNonModifiedFile(moduleName) {
87678                 var resolutionToFile = ts.getResolvedModule(oldSourceFile, moduleName);
87679                 var resolvedFile = resolutionToFile && oldProgram.getSourceFile(resolutionToFile.resolvedFileName);
87680                 if (resolutionToFile && resolvedFile) {
87681                     return false;
87682                 }
87683                 var unmodifiedFile = ambientModuleNameToUnmodifiedFileName.get(moduleName);
87684                 if (!unmodifiedFile) {
87685                     return false;
87686                 }
87687                 if (ts.isTraceEnabled(options, host)) {
87688                     ts.trace(host, ts.Diagnostics.Module_0_was_resolved_as_ambient_module_declared_in_1_since_this_file_was_not_modified, moduleName, unmodifiedFile);
87689                 }
87690                 return true;
87691             }
87692         }
87693         function canReuseProjectReferences() {
87694             return !forEachProjectReference(oldProgram.getProjectReferences(), oldProgram.getResolvedProjectReferences(), function (oldResolvedRef, parent, index) {
87695                 var newRef = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
87696                 var newResolvedRef = parseProjectReferenceConfigFile(newRef);
87697                 if (oldResolvedRef) {
87698                     return !newResolvedRef || newResolvedRef.sourceFile !== oldResolvedRef.sourceFile;
87699                 }
87700                 else {
87701                     return newResolvedRef !== undefined;
87702                 }
87703             }, function (oldProjectReferences, parent) {
87704                 var newReferences = parent ? getResolvedProjectReferenceByPath(parent.sourceFile.path).commandLine.projectReferences : projectReferences;
87705                 return !ts.arrayIsEqualTo(oldProjectReferences, newReferences, ts.projectReferenceIsEqualTo);
87706             });
87707         }
87708         function tryReuseStructureFromOldProgram() {
87709             var _a;
87710             if (!oldProgram) {
87711                 return 0;
87712             }
87713             var oldOptions = oldProgram.getCompilerOptions();
87714             if (ts.changesAffectModuleResolution(oldOptions, options)) {
87715                 return 0;
87716             }
87717             var oldRootNames = oldProgram.getRootFileNames();
87718             if (!ts.arrayIsEqualTo(oldRootNames, rootNames)) {
87719                 return 0;
87720             }
87721             if (!ts.arrayIsEqualTo(options.types, oldOptions.types)) {
87722                 return 0;
87723             }
87724             if (!canReuseProjectReferences()) {
87725                 return 0;
87726             }
87727             if (projectReferences) {
87728                 resolvedProjectReferences = projectReferences.map(parseProjectReferenceConfigFile);
87729             }
87730             var newSourceFiles = [];
87731             var modifiedSourceFiles = [];
87732             structureIsReused = 2;
87733             if (oldProgram.getMissingFilePaths().some(function (missingFilePath) { return host.fileExists(missingFilePath); })) {
87734                 return 0;
87735             }
87736             var oldSourceFiles = oldProgram.getSourceFiles();
87737             var seenPackageNames = new ts.Map();
87738             for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
87739                 var oldSourceFile = oldSourceFiles_2[_i];
87740                 var newSourceFile = host.getSourceFileByPath
87741                     ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, options.target, undefined, shouldCreateNewSourceFile)
87742                     : host.getSourceFile(oldSourceFile.fileName, options.target, undefined, shouldCreateNewSourceFile);
87743                 if (!newSourceFile) {
87744                     return 0;
87745                 }
87746                 ts.Debug.assert(!newSourceFile.redirectInfo, "Host should not return a redirect source file from `getSourceFile`");
87747                 var fileChanged = void 0;
87748                 if (oldSourceFile.redirectInfo) {
87749                     if (newSourceFile !== oldSourceFile.redirectInfo.unredirected) {
87750                         return 0;
87751                     }
87752                     fileChanged = false;
87753                     newSourceFile = oldSourceFile;
87754                 }
87755                 else if (oldProgram.redirectTargetsMap.has(oldSourceFile.path)) {
87756                     if (newSourceFile !== oldSourceFile) {
87757                         return 0;
87758                     }
87759                     fileChanged = false;
87760                 }
87761                 else {
87762                     fileChanged = newSourceFile !== oldSourceFile;
87763                 }
87764                 newSourceFile.path = oldSourceFile.path;
87765                 newSourceFile.originalFileName = oldSourceFile.originalFileName;
87766                 newSourceFile.resolvedPath = oldSourceFile.resolvedPath;
87767                 newSourceFile.fileName = oldSourceFile.fileName;
87768                 var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path);
87769                 if (packageName !== undefined) {
87770                     var prevKind = seenPackageNames.get(packageName);
87771                     var newKind = fileChanged ? 1 : 0;
87772                     if ((prevKind !== undefined && newKind === 1) || prevKind === 1) {
87773                         return 0;
87774                     }
87775                     seenPackageNames.set(packageName, newKind);
87776                 }
87777                 if (fileChanged) {
87778                     if (!ts.arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
87779                         return 0;
87780                     }
87781                     if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
87782                         structureIsReused = 1;
87783                     }
87784                     if (!ts.arrayIsEqualTo(oldSourceFile.referencedFiles, newSourceFile.referencedFiles, fileReferenceIsEqualTo)) {
87785                         structureIsReused = 1;
87786                     }
87787                     collectExternalModuleReferences(newSourceFile);
87788                     if (!ts.arrayIsEqualTo(oldSourceFile.imports, newSourceFile.imports, moduleNameIsEqualTo)) {
87789                         structureIsReused = 1;
87790                     }
87791                     if (!ts.arrayIsEqualTo(oldSourceFile.moduleAugmentations, newSourceFile.moduleAugmentations, moduleNameIsEqualTo)) {
87792                         structureIsReused = 1;
87793                     }
87794                     if ((oldSourceFile.flags & 3145728) !== (newSourceFile.flags & 3145728)) {
87795                         structureIsReused = 1;
87796                     }
87797                     if (!ts.arrayIsEqualTo(oldSourceFile.typeReferenceDirectives, newSourceFile.typeReferenceDirectives, fileReferenceIsEqualTo)) {
87798                         structureIsReused = 1;
87799                     }
87800                     modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
87801                 }
87802                 else if (hasInvalidatedResolution(oldSourceFile.path)) {
87803                     structureIsReused = 1;
87804                     modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
87805                 }
87806                 newSourceFiles.push(newSourceFile);
87807             }
87808             if (structureIsReused !== 2) {
87809                 return structureIsReused;
87810             }
87811             var modifiedFiles = modifiedSourceFiles.map(function (f) { return f.oldFile; });
87812             for (var _b = 0, oldSourceFiles_3 = oldSourceFiles; _b < oldSourceFiles_3.length; _b++) {
87813                 var oldFile = oldSourceFiles_3[_b];
87814                 if (!ts.contains(modifiedFiles, oldFile)) {
87815                     for (var _c = 0, _d = oldFile.ambientModuleNames; _c < _d.length; _c++) {
87816                         var moduleName = _d[_c];
87817                         ambientModuleNameToUnmodifiedFileName.set(moduleName, oldFile.fileName);
87818                     }
87819                 }
87820             }
87821             for (var _e = 0, modifiedSourceFiles_1 = modifiedSourceFiles; _e < modifiedSourceFiles_1.length; _e++) {
87822                 var _f = modifiedSourceFiles_1[_e], oldSourceFile = _f.oldFile, newSourceFile = _f.newFile;
87823                 var moduleNames = getModuleNames(newSourceFile);
87824                 var resolutions = resolveModuleNamesReusingOldState(moduleNames, newSourceFile);
87825                 var resolutionsChanged = ts.hasChangesInResolutions(moduleNames, resolutions, oldSourceFile.resolvedModules, ts.moduleResolutionIsEqualTo);
87826                 if (resolutionsChanged) {
87827                     structureIsReused = 1;
87828                     newSourceFile.resolvedModules = ts.zipToMap(moduleNames, resolutions);
87829                 }
87830                 else {
87831                     newSourceFile.resolvedModules = oldSourceFile.resolvedModules;
87832                 }
87833                 var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
87834                 var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
87835                 var typeReferenceEesolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, ts.typeDirectiveIsEqualTo);
87836                 if (typeReferenceEesolutionsChanged) {
87837                     structureIsReused = 1;
87838                     newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToMap(typesReferenceDirectives, typeReferenceResolutions);
87839                 }
87840                 else {
87841                     newSourceFile.resolvedTypeReferenceDirectiveNames = oldSourceFile.resolvedTypeReferenceDirectiveNames;
87842                 }
87843             }
87844             if (structureIsReused !== 2) {
87845                 return structureIsReused;
87846             }
87847             if ((_a = host.hasChangedAutomaticTypeDirectiveNames) === null || _a === void 0 ? void 0 : _a.call(host)) {
87848                 return 1;
87849             }
87850             missingFilePaths = oldProgram.getMissingFilePaths();
87851             ts.Debug.assert(newSourceFiles.length === oldProgram.getSourceFiles().length);
87852             for (var _g = 0, newSourceFiles_1 = newSourceFiles; _g < newSourceFiles_1.length; _g++) {
87853                 var newSourceFile = newSourceFiles_1[_g];
87854                 filesByName.set(newSourceFile.path, newSourceFile);
87855             }
87856             var oldFilesByNameMap = oldProgram.getFilesByNameMap();
87857             oldFilesByNameMap.forEach(function (oldFile, path) {
87858                 if (!oldFile) {
87859                     filesByName.set(path, oldFile);
87860                     return;
87861                 }
87862                 if (oldFile.path === path) {
87863                     if (oldProgram.isSourceFileFromExternalLibrary(oldFile)) {
87864                         sourceFilesFoundSearchingNodeModules.set(oldFile.path, true);
87865                     }
87866                     return;
87867                 }
87868                 filesByName.set(path, filesByName.get(oldFile.path));
87869             });
87870             files = newSourceFiles;
87871             fileReasons = oldProgram.getFileIncludeReasons();
87872             fileProcessingDiagnostics = oldProgram.getFileProcessingDiagnostics();
87873             resolvedTypeReferenceDirectives = oldProgram.getResolvedTypeReferenceDirectives();
87874             sourceFileToPackageName = oldProgram.sourceFileToPackageName;
87875             redirectTargetsMap = oldProgram.redirectTargetsMap;
87876             return 2;
87877         }
87878         function getEmitHost(writeFileCallback) {
87879             return {
87880                 getPrependNodes: getPrependNodes,
87881                 getCanonicalFileName: getCanonicalFileName,
87882                 getCommonSourceDirectory: program.getCommonSourceDirectory,
87883                 getCompilerOptions: program.getCompilerOptions,
87884                 getCurrentDirectory: function () { return currentDirectory; },
87885                 getNewLine: function () { return host.getNewLine(); },
87886                 getSourceFile: program.getSourceFile,
87887                 getSourceFileByPath: program.getSourceFileByPath,
87888                 getSourceFiles: program.getSourceFiles,
87889                 getLibFileFromReference: program.getLibFileFromReference,
87890                 isSourceFileFromExternalLibrary: isSourceFileFromExternalLibrary,
87891                 getResolvedProjectReferenceToRedirect: getResolvedProjectReferenceToRedirect,
87892                 getProjectReferenceRedirect: getProjectReferenceRedirect,
87893                 isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
87894                 getSymlinkCache: getSymlinkCache,
87895                 writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }),
87896                 isEmitBlocked: isEmitBlocked,
87897                 readFile: function (f) { return host.readFile(f); },
87898                 fileExists: function (f) {
87899                     var path = toPath(f);
87900                     if (getSourceFileByPath(path))
87901                         return true;
87902                     if (ts.contains(missingFilePaths, path))
87903                         return false;
87904                     return host.fileExists(f);
87905                 },
87906                 useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
87907                 getProgramBuildInfo: function () { return program.getProgramBuildInfo && program.getProgramBuildInfo(); },
87908                 getSourceFileFromReference: function (file, ref) { return program.getSourceFileFromReference(file, ref); },
87909                 redirectTargetsMap: redirectTargetsMap,
87910                 getFileIncludeReasons: program.getFileIncludeReasons,
87911             };
87912         }
87913         function emitBuildInfo(writeFileCallback) {
87914             ts.Debug.assert(!ts.outFile(options));
87915             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit", "emitBuildInfo", {}, true);
87916             ts.performance.mark("beforeEmit");
87917             var emitResult = ts.emitFiles(ts.notImplementedResolver, getEmitHost(writeFileCallback), undefined, ts.noTransformers, false, true);
87918             ts.performance.mark("afterEmit");
87919             ts.performance.measure("Emit", "beforeEmit", "afterEmit");
87920             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
87921             return emitResult;
87922         }
87923         function getResolvedProjectReferences() {
87924             return resolvedProjectReferences;
87925         }
87926         function getProjectReferences() {
87927             return projectReferences;
87928         }
87929         function getPrependNodes() {
87930             return createPrependNodes(projectReferences, function (_ref, index) { var _a; return (_a = resolvedProjectReferences[index]) === null || _a === void 0 ? void 0 : _a.commandLine; }, function (fileName) {
87931                 var path = toPath(fileName);
87932                 var sourceFile = getSourceFileByPath(path);
87933                 return sourceFile ? sourceFile.text : filesByName.has(path) ? undefined : host.readFile(path);
87934             });
87935         }
87936         function isSourceFileFromExternalLibrary(file) {
87937             return !!sourceFilesFoundSearchingNodeModules.get(file.path);
87938         }
87939         function isSourceFileDefaultLibrary(file) {
87940             if (file.hasNoDefaultLib) {
87941                 return true;
87942             }
87943             if (!options.noLib) {
87944                 return false;
87945             }
87946             var equalityComparer = host.useCaseSensitiveFileNames() ? ts.equateStringsCaseSensitive : ts.equateStringsCaseInsensitive;
87947             if (!options.lib) {
87948                 return equalityComparer(file.fileName, getDefaultLibraryFileName());
87949             }
87950             else {
87951                 return ts.some(options.lib, function (libFileName) { return equalityComparer(file.fileName, ts.combinePaths(defaultLibraryPath, libFileName)); });
87952             }
87953         }
87954         function getDiagnosticsProducingTypeChecker() {
87955             return diagnosticsProducingTypeChecker || (diagnosticsProducingTypeChecker = ts.createTypeChecker(program, true));
87956         }
87957         function dropDiagnosticsProducingTypeChecker() {
87958             diagnosticsProducingTypeChecker = undefined;
87959         }
87960         function getTypeChecker() {
87961             return noDiagnosticsTypeChecker || (noDiagnosticsTypeChecker = ts.createTypeChecker(program, false));
87962         }
87963         function emit(sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit) {
87964             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit", "emit", { path: sourceFile === null || sourceFile === void 0 ? void 0 : sourceFile.path }, true);
87965             var result = runWithCancellationToken(function () { return emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, transformers, forceDtsEmit); });
87966             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
87967             return result;
87968         }
87969         function isEmitBlocked(emitFileName) {
87970             return hasEmitBlockingDiagnostics.has(toPath(emitFileName));
87971         }
87972         function emitWorker(program, sourceFile, writeFileCallback, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit) {
87973             if (!forceDtsEmit) {
87974                 var result = handleNoEmitOptions(program, sourceFile, writeFileCallback, cancellationToken);
87975                 if (result)
87976                     return result;
87977             }
87978             var emitResolver = getDiagnosticsProducingTypeChecker().getEmitResolver(ts.outFile(options) ? undefined : sourceFile, cancellationToken);
87979             ts.performance.mark("beforeEmit");
87980             var emitResult = ts.emitFiles(emitResolver, getEmitHost(writeFileCallback), sourceFile, ts.getTransformers(options, customTransformers, emitOnlyDtsFiles), emitOnlyDtsFiles, false, forceDtsEmit);
87981             ts.performance.mark("afterEmit");
87982             ts.performance.measure("Emit", "beforeEmit", "afterEmit");
87983             return emitResult;
87984         }
87985         function getSourceFile(fileName) {
87986             return getSourceFileByPath(toPath(fileName));
87987         }
87988         function getSourceFileByPath(path) {
87989             return filesByName.get(path) || undefined;
87990         }
87991         function getDiagnosticsHelper(sourceFile, getDiagnostics, cancellationToken) {
87992             if (sourceFile) {
87993                 return getDiagnostics(sourceFile, cancellationToken);
87994             }
87995             return ts.sortAndDeduplicateDiagnostics(ts.flatMap(program.getSourceFiles(), function (sourceFile) {
87996                 if (cancellationToken) {
87997                     cancellationToken.throwIfCancellationRequested();
87998                 }
87999                 return getDiagnostics(sourceFile, cancellationToken);
88000             }));
88001         }
88002         function getSyntacticDiagnostics(sourceFile, cancellationToken) {
88003             return getDiagnosticsHelper(sourceFile, getSyntacticDiagnosticsForFile, cancellationToken);
88004         }
88005         function getSemanticDiagnostics(sourceFile, cancellationToken) {
88006             return getDiagnosticsHelper(sourceFile, getSemanticDiagnosticsForFile, cancellationToken);
88007         }
88008         function getCachedSemanticDiagnostics(sourceFile) {
88009             var _a;
88010             return sourceFile
88011                 ? (_a = cachedBindAndCheckDiagnosticsForFile.perFile) === null || _a === void 0 ? void 0 : _a.get(sourceFile.path)
88012                 : cachedBindAndCheckDiagnosticsForFile.allDiagnostics;
88013         }
88014         function getBindAndCheckDiagnostics(sourceFile, cancellationToken) {
88015             return getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken);
88016         }
88017         function getProgramDiagnostics(sourceFile) {
88018             var _a;
88019             if (ts.skipTypeChecking(sourceFile, options, program)) {
88020                 return ts.emptyArray;
88021             }
88022             var programDiagnosticsInFile = programDiagnostics.getDiagnostics(sourceFile.fileName);
88023             if (!((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) {
88024                 return programDiagnosticsInFile;
88025             }
88026             return getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, programDiagnosticsInFile).diagnostics;
88027         }
88028         function getDeclarationDiagnostics(sourceFile, cancellationToken) {
88029             var options = program.getCompilerOptions();
88030             if (!sourceFile || ts.outFile(options)) {
88031                 return getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
88032             }
88033             else {
88034                 return getDiagnosticsHelper(sourceFile, getDeclarationDiagnosticsForFile, cancellationToken);
88035             }
88036         }
88037         function getSyntacticDiagnosticsForFile(sourceFile) {
88038             if (ts.isSourceFileJS(sourceFile)) {
88039                 if (!sourceFile.additionalSyntacticDiagnostics) {
88040                     sourceFile.additionalSyntacticDiagnostics = getJSSyntacticDiagnosticsForFile(sourceFile);
88041                 }
88042                 return ts.concatenate(sourceFile.additionalSyntacticDiagnostics, sourceFile.parseDiagnostics);
88043             }
88044             return sourceFile.parseDiagnostics;
88045         }
88046         function runWithCancellationToken(func) {
88047             try {
88048                 return func();
88049             }
88050             catch (e) {
88051                 if (e instanceof ts.OperationCanceledException) {
88052                     noDiagnosticsTypeChecker = undefined;
88053                     diagnosticsProducingTypeChecker = undefined;
88054                 }
88055                 throw e;
88056             }
88057         }
88058         function getSemanticDiagnosticsForFile(sourceFile, cancellationToken) {
88059             return ts.concatenate(filterSemanticDiagnotics(getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken), options), getProgramDiagnostics(sourceFile));
88060         }
88061         function getBindAndCheckDiagnosticsForFile(sourceFile, cancellationToken) {
88062             return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedBindAndCheckDiagnosticsForFile, getBindAndCheckDiagnosticsForFileNoCache);
88063         }
88064         function getBindAndCheckDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
88065             return runWithCancellationToken(function () {
88066                 if (ts.skipTypeChecking(sourceFile, options, program)) {
88067                     return ts.emptyArray;
88068                 }
88069                 var typeChecker = getDiagnosticsProducingTypeChecker();
88070                 ts.Debug.assert(!!sourceFile.bindDiagnostics);
88071                 var isCheckJs = ts.isCheckJsEnabledForFile(sourceFile, options);
88072                 var isTsNoCheck = !!sourceFile.checkJsDirective && sourceFile.checkJsDirective.enabled === false;
88073                 var includeBindAndCheckDiagnostics = !isTsNoCheck && (sourceFile.scriptKind === 3 || sourceFile.scriptKind === 4 ||
88074                     sourceFile.scriptKind === 5 || isCheckJs || sourceFile.scriptKind === 7);
88075                 var bindDiagnostics = includeBindAndCheckDiagnostics ? sourceFile.bindDiagnostics : ts.emptyArray;
88076                 var checkDiagnostics = includeBindAndCheckDiagnostics ? typeChecker.getDiagnostics(sourceFile, cancellationToken) : ts.emptyArray;
88077                 return getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics, bindDiagnostics, checkDiagnostics, isCheckJs ? sourceFile.jsDocDiagnostics : undefined);
88078             });
88079         }
88080         function getMergedBindAndCheckDiagnostics(sourceFile, includeBindAndCheckDiagnostics) {
88081             var _a;
88082             var allDiagnostics = [];
88083             for (var _i = 2; _i < arguments.length; _i++) {
88084                 allDiagnostics[_i - 2] = arguments[_i];
88085             }
88086             var flatDiagnostics = ts.flatten(allDiagnostics);
88087             if (!includeBindAndCheckDiagnostics || !((_a = sourceFile.commentDirectives) === null || _a === void 0 ? void 0 : _a.length)) {
88088                 return flatDiagnostics;
88089             }
88090             var _b = getDiagnosticsWithPrecedingDirectives(sourceFile, sourceFile.commentDirectives, flatDiagnostics), diagnostics = _b.diagnostics, directives = _b.directives;
88091             for (var _c = 0, _d = directives.getUnusedExpectations(); _c < _d.length; _c++) {
88092                 var errorExpectation = _d[_c];
88093                 diagnostics.push(ts.createDiagnosticForRange(sourceFile, errorExpectation.range, ts.Diagnostics.Unused_ts_expect_error_directive));
88094             }
88095             return diagnostics;
88096         }
88097         function getDiagnosticsWithPrecedingDirectives(sourceFile, commentDirectives, flatDiagnostics) {
88098             var directives = ts.createCommentDirectivesMap(sourceFile, commentDirectives);
88099             var diagnostics = flatDiagnostics.filter(function (diagnostic) { return markPrecedingCommentDirectiveLine(diagnostic, directives) === -1; });
88100             return { diagnostics: diagnostics, directives: directives };
88101         }
88102         function getSuggestionDiagnostics(sourceFile, cancellationToken) {
88103             return runWithCancellationToken(function () {
88104                 return getDiagnosticsProducingTypeChecker().getSuggestionDiagnostics(sourceFile, cancellationToken);
88105             });
88106         }
88107         function markPrecedingCommentDirectiveLine(diagnostic, directives) {
88108             var file = diagnostic.file, start = diagnostic.start;
88109             if (!file) {
88110                 return -1;
88111             }
88112             var lineStarts = ts.getLineStarts(file);
88113             var line = ts.computeLineAndCharacterOfPosition(lineStarts, start).line - 1;
88114             while (line >= 0) {
88115                 if (directives.markUsed(line)) {
88116                     return line;
88117                 }
88118                 var lineText = file.text.slice(lineStarts[line], lineStarts[line + 1]).trim();
88119                 if (lineText !== "" && !/^(\s*)\/\/(.*)$/.test(lineText)) {
88120                     return -1;
88121                 }
88122                 line--;
88123             }
88124             return -1;
88125         }
88126         function getJSSyntacticDiagnosticsForFile(sourceFile) {
88127             return runWithCancellationToken(function () {
88128                 var diagnostics = [];
88129                 walk(sourceFile, sourceFile);
88130                 ts.forEachChildRecursively(sourceFile, walk, walkArray);
88131                 return diagnostics;
88132                 function walk(node, parent) {
88133                     switch (parent.kind) {
88134                         case 160:
88135                         case 163:
88136                         case 165:
88137                             if (parent.questionToken === node) {
88138                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?"));
88139                                 return "skip";
88140                             }
88141                         case 164:
88142                         case 166:
88143                         case 167:
88144                         case 168:
88145                         case 208:
88146                         case 251:
88147                         case 209:
88148                         case 249:
88149                             if (parent.type === node) {
88150                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_annotations_can_only_be_used_in_TypeScript_files));
88151                                 return "skip";
88152                             }
88153                     }
88154                     switch (node.kind) {
88155                         case 262:
88156                             if (node.isTypeOnly) {
88157                                 diagnostics.push(createDiagnosticForNode(parent, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "import type"));
88158                                 return "skip";
88159                             }
88160                             break;
88161                         case 267:
88162                             if (node.isTypeOnly) {
88163                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, "export type"));
88164                                 return "skip";
88165                             }
88166                             break;
88167                         case 260:
88168                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.import_can_only_be_used_in_TypeScript_files));
88169                             return "skip";
88170                         case 266:
88171                             if (node.isExportEquals) {
88172                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.export_can_only_be_used_in_TypeScript_files));
88173                                 return "skip";
88174                             }
88175                             break;
88176                         case 286:
88177                             var heritageClause = node;
88178                             if (heritageClause.token === 116) {
88179                                 diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.implements_clauses_can_only_be_used_in_TypeScript_files));
88180                                 return "skip";
88181                             }
88182                             break;
88183                         case 253:
88184                             var interfaceKeyword = ts.tokenToString(117);
88185                             ts.Debug.assertIsDefined(interfaceKeyword);
88186                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, interfaceKeyword));
88187                             return "skip";
88188                         case 256:
88189                             var moduleKeyword = node.flags & 16 ? ts.tokenToString(140) : ts.tokenToString(139);
88190                             ts.Debug.assertIsDefined(moduleKeyword);
88191                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, moduleKeyword));
88192                             return "skip";
88193                         case 254:
88194                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Type_aliases_can_only_be_used_in_TypeScript_files));
88195                             return "skip";
88196                         case 255:
88197                             var enumKeyword = ts.Debug.checkDefined(ts.tokenToString(91));
88198                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics._0_declarations_can_only_be_used_in_TypeScript_files, enumKeyword));
88199                             return "skip";
88200                         case 225:
88201                             diagnostics.push(createDiagnosticForNode(node, ts.Diagnostics.Non_null_assertions_can_only_be_used_in_TypeScript_files));
88202                             return "skip";
88203                         case 224:
88204                             diagnostics.push(createDiagnosticForNode(node.type, ts.Diagnostics.Type_assertion_expressions_can_only_be_used_in_TypeScript_files));
88205                             return "skip";
88206                         case 206:
88207                             ts.Debug.fail();
88208                     }
88209                 }
88210                 function walkArray(nodes, parent) {
88211                     if (parent.decorators === nodes && !options.experimentalDecorators) {
88212                         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));
88213                     }
88214                     switch (parent.kind) {
88215                         case 252:
88216                         case 221:
88217                         case 165:
88218                         case 166:
88219                         case 167:
88220                         case 168:
88221                         case 208:
88222                         case 251:
88223                         case 209:
88224                             if (nodes === parent.typeParameters) {
88225                                 diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_parameter_declarations_can_only_be_used_in_TypeScript_files));
88226                                 return "skip";
88227                             }
88228                         case 232:
88229                             if (nodes === parent.modifiers) {
88230                                 checkModifiers(parent.modifiers, parent.kind === 232);
88231                                 return "skip";
88232                             }
88233                             break;
88234                         case 163:
88235                             if (nodes === parent.modifiers) {
88236                                 for (var _i = 0, _a = nodes; _i < _a.length; _i++) {
88237                                     var modifier = _a[_i];
88238                                     if (modifier.kind !== 123) {
88239                                         diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind)));
88240                                     }
88241                                 }
88242                                 return "skip";
88243                             }
88244                             break;
88245                         case 160:
88246                             if (nodes === parent.modifiers) {
88247                                 diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files));
88248                                 return "skip";
88249                             }
88250                             break;
88251                         case 203:
88252                         case 204:
88253                         case 223:
88254                         case 274:
88255                         case 275:
88256                         case 205:
88257                             if (nodes === parent.typeArguments) {
88258                                 diagnostics.push(createDiagnosticForNodeArray(nodes, ts.Diagnostics.Type_arguments_can_only_be_used_in_TypeScript_files));
88259                                 return "skip";
88260                             }
88261                             break;
88262                     }
88263                 }
88264                 function checkModifiers(modifiers, isConstValid) {
88265                     for (var _i = 0, modifiers_2 = modifiers; _i < modifiers_2.length; _i++) {
88266                         var modifier = modifiers_2[_i];
88267                         switch (modifier.kind) {
88268                             case 84:
88269                                 if (isConstValid) {
88270                                     continue;
88271                                 }
88272                             case 122:
88273                             case 120:
88274                             case 121:
88275                             case 142:
88276                             case 133:
88277                             case 125:
88278                                 diagnostics.push(createDiagnosticForNode(modifier, ts.Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, ts.tokenToString(modifier.kind)));
88279                                 break;
88280                             case 123:
88281                             case 92:
88282                             case 87:
88283                         }
88284                     }
88285                 }
88286                 function createDiagnosticForNodeArray(nodes, message, arg0, arg1, arg2) {
88287                     var start = nodes.pos;
88288                     return ts.createFileDiagnostic(sourceFile, start, nodes.end - start, message, arg0, arg1, arg2);
88289                 }
88290                 function createDiagnosticForNode(node, message, arg0, arg1, arg2) {
88291                     return ts.createDiagnosticForNodeInSourceFile(sourceFile, node, message, arg0, arg1, arg2);
88292                 }
88293             });
88294         }
88295         function getDeclarationDiagnosticsWorker(sourceFile, cancellationToken) {
88296             return getAndCacheDiagnostics(sourceFile, cancellationToken, cachedDeclarationDiagnosticsForFile, getDeclarationDiagnosticsForFileNoCache);
88297         }
88298         function getDeclarationDiagnosticsForFileNoCache(sourceFile, cancellationToken) {
88299             return runWithCancellationToken(function () {
88300                 var resolver = getDiagnosticsProducingTypeChecker().getEmitResolver(sourceFile, cancellationToken);
88301                 return ts.getDeclarationDiagnostics(getEmitHost(ts.noop), resolver, sourceFile) || ts.emptyArray;
88302             });
88303         }
88304         function getAndCacheDiagnostics(sourceFile, cancellationToken, cache, getDiagnostics) {
88305             var _a;
88306             var cachedResult = sourceFile
88307                 ? (_a = cache.perFile) === null || _a === void 0 ? void 0 : _a.get(sourceFile.path)
88308                 : cache.allDiagnostics;
88309             if (cachedResult) {
88310                 return cachedResult;
88311             }
88312             var result = getDiagnostics(sourceFile, cancellationToken);
88313             if (sourceFile) {
88314                 (cache.perFile || (cache.perFile = new ts.Map())).set(sourceFile.path, result);
88315             }
88316             else {
88317                 cache.allDiagnostics = result;
88318             }
88319             return result;
88320         }
88321         function getDeclarationDiagnosticsForFile(sourceFile, cancellationToken) {
88322             return sourceFile.isDeclarationFile ? [] : getDeclarationDiagnosticsWorker(sourceFile, cancellationToken);
88323         }
88324         function getOptionsDiagnostics() {
88325             return ts.sortAndDeduplicateDiagnostics(ts.concatenate(programDiagnostics.getGlobalDiagnostics(), getOptionsDiagnosticsOfConfigFile()));
88326         }
88327         function getOptionsDiagnosticsOfConfigFile() {
88328             if (!options.configFile) {
88329                 return ts.emptyArray;
88330             }
88331             var diagnostics = programDiagnostics.getDiagnostics(options.configFile.fileName);
88332             forEachResolvedProjectReference(function (resolvedRef) {
88333                 diagnostics = ts.concatenate(diagnostics, programDiagnostics.getDiagnostics(resolvedRef.sourceFile.fileName));
88334             });
88335             return diagnostics;
88336         }
88337         function getGlobalDiagnostics() {
88338             return rootNames.length ? ts.sortAndDeduplicateDiagnostics(getDiagnosticsProducingTypeChecker().getGlobalDiagnostics().slice()) : ts.emptyArray;
88339         }
88340         function getConfigFileParsingDiagnostics() {
88341             return configFileParsingDiagnostics || ts.emptyArray;
88342         }
88343         function processRootFile(fileName, isDefaultLib, ignoreNoDefaultLib, reason) {
88344             processSourceFile(ts.normalizePath(fileName), isDefaultLib, ignoreNoDefaultLib, undefined, reason);
88345         }
88346         function fileReferenceIsEqualTo(a, b) {
88347             return a.fileName === b.fileName;
88348         }
88349         function moduleNameIsEqualTo(a, b) {
88350             return a.kind === 78
88351                 ? b.kind === 78 && a.escapedText === b.escapedText
88352                 : b.kind === 10 && a.text === b.text;
88353         }
88354         function createSyntheticImport(text, file) {
88355             var externalHelpersModuleReference = ts.factory.createStringLiteral(text);
88356             var importDecl = ts.factory.createImportDeclaration(undefined, undefined, undefined, externalHelpersModuleReference);
88357             ts.addEmitFlags(importDecl, 67108864);
88358             ts.setParent(externalHelpersModuleReference, importDecl);
88359             ts.setParent(importDecl, file);
88360             externalHelpersModuleReference.flags &= ~8;
88361             importDecl.flags &= ~8;
88362             return externalHelpersModuleReference;
88363         }
88364         function collectExternalModuleReferences(file) {
88365             if (file.imports) {
88366                 return;
88367             }
88368             var isJavaScriptFile = ts.isSourceFileJS(file);
88369             var isExternalModuleFile = ts.isExternalModule(file);
88370             var imports;
88371             var moduleAugmentations;
88372             var ambientModules;
88373             if ((options.isolatedModules || isExternalModuleFile)
88374                 && !file.isDeclarationFile) {
88375                 if (options.importHelpers) {
88376                     imports = [createSyntheticImport(ts.externalHelpersModuleNameText, file)];
88377                 }
88378                 var jsxImport = ts.getJSXRuntimeImport(ts.getJSXImplicitImportBase(options, file), options);
88379                 if (jsxImport) {
88380                     (imports || (imports = [])).push(createSyntheticImport(jsxImport, file));
88381                 }
88382             }
88383             for (var _i = 0, _a = file.statements; _i < _a.length; _i++) {
88384                 var node = _a[_i];
88385                 collectModuleReferences(node, false);
88386             }
88387             if ((file.flags & 1048576) || isJavaScriptFile) {
88388                 collectDynamicImportOrRequireCalls(file);
88389             }
88390             file.imports = imports || ts.emptyArray;
88391             file.moduleAugmentations = moduleAugmentations || ts.emptyArray;
88392             file.ambientModuleNames = ambientModules || ts.emptyArray;
88393             return;
88394             function collectModuleReferences(node, inAmbientModule) {
88395                 if (ts.isAnyImportOrReExport(node)) {
88396                     var moduleNameExpr = ts.getExternalModuleName(node);
88397                     if (moduleNameExpr && ts.isStringLiteral(moduleNameExpr) && moduleNameExpr.text && (!inAmbientModule || !ts.isExternalModuleNameRelative(moduleNameExpr.text))) {
88398                         imports = ts.append(imports, moduleNameExpr);
88399                     }
88400                 }
88401                 else if (ts.isModuleDeclaration(node)) {
88402                     if (ts.isAmbientModule(node) && (inAmbientModule || ts.hasSyntacticModifier(node, 2) || file.isDeclarationFile)) {
88403                         var nameText = ts.getTextOfIdentifierOrLiteral(node.name);
88404                         if (isExternalModuleFile || (inAmbientModule && !ts.isExternalModuleNameRelative(nameText))) {
88405                             (moduleAugmentations || (moduleAugmentations = [])).push(node.name);
88406                         }
88407                         else if (!inAmbientModule) {
88408                             if (file.isDeclarationFile) {
88409                                 (ambientModules || (ambientModules = [])).push(nameText);
88410                             }
88411                             var body = node.body;
88412                             if (body) {
88413                                 for (var _i = 0, _a = body.statements; _i < _a.length; _i++) {
88414                                     var statement = _a[_i];
88415                                     collectModuleReferences(statement, true);
88416                                 }
88417                             }
88418                         }
88419                     }
88420                 }
88421             }
88422             function collectDynamicImportOrRequireCalls(file) {
88423                 var r = /import|require/g;
88424                 while (r.exec(file.text) !== null) {
88425                     var node = getNodeAtPosition(file, r.lastIndex);
88426                     if (isJavaScriptFile && ts.isRequireCall(node, true)) {
88427                         imports = ts.append(imports, node.arguments[0]);
88428                     }
88429                     else if (ts.isImportCall(node) && node.arguments.length === 1 && ts.isStringLiteralLike(node.arguments[0])) {
88430                         imports = ts.append(imports, node.arguments[0]);
88431                     }
88432                     else if (ts.isLiteralImportTypeNode(node)) {
88433                         imports = ts.append(imports, node.argument.literal);
88434                     }
88435                 }
88436             }
88437             function getNodeAtPosition(sourceFile, position) {
88438                 var current = sourceFile;
88439                 var getContainingChild = function (child) {
88440                     if (child.pos <= position && (position < child.end || (position === child.end && (child.kind === 1)))) {
88441                         return child;
88442                     }
88443                 };
88444                 while (true) {
88445                     var child = isJavaScriptFile && ts.hasJSDocNodes(current) && ts.forEach(current.jsDoc, getContainingChild) || ts.forEachChild(current, getContainingChild);
88446                     if (!child) {
88447                         return current;
88448                     }
88449                     current = child;
88450                 }
88451             }
88452         }
88453         function getLibFileFromReference(ref) {
88454             var libName = ts.toFileNameLowerCase(ref.fileName);
88455             var libFileName = ts.libMap.get(libName);
88456             if (libFileName) {
88457                 return getSourceFile(ts.combinePaths(defaultLibraryPath, libFileName));
88458             }
88459         }
88460         function getSourceFileFromReference(referencingFile, ref) {
88461             return getSourceFileFromReferenceWorker(resolveTripleslashReference(ref.fileName, referencingFile.fileName), getSourceFile);
88462         }
88463         function getSourceFileFromReferenceWorker(fileName, getSourceFile, fail, reason) {
88464             if (ts.hasExtension(fileName)) {
88465                 var canonicalFileName_1 = host.getCanonicalFileName(fileName);
88466                 if (!options.allowNonTsExtensions && !ts.forEach(supportedExtensionsWithJsonIfResolveJsonModule, function (extension) { return ts.fileExtensionIs(canonicalFileName_1, extension); })) {
88467                     if (fail) {
88468                         if (ts.hasJSFileExtension(canonicalFileName_1)) {
88469                             fail(ts.Diagnostics.File_0_is_a_JavaScript_file_Did_you_mean_to_enable_the_allowJs_option, fileName);
88470                         }
88471                         else {
88472                             fail(ts.Diagnostics.File_0_has_an_unsupported_extension_The_only_supported_extensions_are_1, fileName, "'" + supportedExtensions.join("', '") + "'");
88473                         }
88474                     }
88475                     return undefined;
88476                 }
88477                 var sourceFile = getSourceFile(fileName);
88478                 if (fail) {
88479                     if (!sourceFile) {
88480                         var redirect = getProjectReferenceRedirect(fileName);
88481                         if (redirect) {
88482                             fail(ts.Diagnostics.Output_file_0_has_not_been_built_from_source_file_1, redirect, fileName);
88483                         }
88484                         else {
88485                             fail(ts.Diagnostics.File_0_not_found, fileName);
88486                         }
88487                     }
88488                     else if (isReferencedFile(reason) && canonicalFileName_1 === host.getCanonicalFileName(getSourceFileByPath(reason.file).fileName)) {
88489                         fail(ts.Diagnostics.A_file_cannot_have_a_reference_to_itself);
88490                     }
88491                 }
88492                 return sourceFile;
88493             }
88494             else {
88495                 var sourceFileNoExtension = options.allowNonTsExtensions && getSourceFile(fileName);
88496                 if (sourceFileNoExtension)
88497                     return sourceFileNoExtension;
88498                 if (fail && options.allowNonTsExtensions) {
88499                     fail(ts.Diagnostics.File_0_not_found, fileName);
88500                     return undefined;
88501                 }
88502                 var sourceFileWithAddedExtension = ts.forEach(supportedExtensions, function (extension) { return getSourceFile(fileName + extension); });
88503                 if (fail && !sourceFileWithAddedExtension)
88504                     fail(ts.Diagnostics.Could_not_resolve_the_path_0_with_the_extensions_Colon_1, fileName, "'" + supportedExtensions.join("', '") + "'");
88505                 return sourceFileWithAddedExtension;
88506             }
88507         }
88508         function processSourceFile(fileName, isDefaultLib, ignoreNoDefaultLib, packageId, reason) {
88509             getSourceFileFromReferenceWorker(fileName, function (fileName) { return findSourceFile(fileName, toPath(fileName), isDefaultLib, ignoreNoDefaultLib, reason, packageId); }, function (diagnostic) {
88510                 var args = [];
88511                 for (var _i = 1; _i < arguments.length; _i++) {
88512                     args[_i - 1] = arguments[_i];
88513                 }
88514                 return addFilePreprocessingFileExplainingDiagnostic(undefined, reason, diagnostic, args);
88515             }, reason);
88516         }
88517         function processProjectReferenceFile(fileName, reason) {
88518             return processSourceFile(fileName, false, false, undefined, reason);
88519         }
88520         function reportFileNamesDifferOnlyInCasingError(fileName, existingFile, reason) {
88521             var hasExistingReasonToReportErrorOn = !isReferencedFile(reason) && ts.some(fileReasons.get(existingFile.path), isReferencedFile);
88522             if (hasExistingReasonToReportErrorOn) {
88523                 addFilePreprocessingFileExplainingDiagnostic(existingFile, reason, ts.Diagnostics.Already_included_file_name_0_differs_from_file_name_1_only_in_casing, [existingFile.fileName, fileName]);
88524             }
88525             else {
88526                 addFilePreprocessingFileExplainingDiagnostic(existingFile, reason, ts.Diagnostics.File_name_0_differs_from_already_included_file_name_1_only_in_casing, [fileName, existingFile.fileName]);
88527             }
88528         }
88529         function createRedirectSourceFile(redirectTarget, unredirected, fileName, path, resolvedPath, originalFileName) {
88530             var redirect = Object.create(redirectTarget);
88531             redirect.fileName = fileName;
88532             redirect.path = path;
88533             redirect.resolvedPath = resolvedPath;
88534             redirect.originalFileName = originalFileName;
88535             redirect.redirectInfo = { redirectTarget: redirectTarget, unredirected: unredirected };
88536             sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
88537             Object.defineProperties(redirect, {
88538                 id: {
88539                     get: function () { return this.redirectInfo.redirectTarget.id; },
88540                     set: function (value) { this.redirectInfo.redirectTarget.id = value; },
88541                 },
88542                 symbol: {
88543                     get: function () { return this.redirectInfo.redirectTarget.symbol; },
88544                     set: function (value) { this.redirectInfo.redirectTarget.symbol = value; },
88545                 },
88546             });
88547             return redirect;
88548         }
88549         function findSourceFile(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
88550             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "findSourceFile", {
88551                 fileName: fileName,
88552                 isDefaultLib: isDefaultLib || undefined,
88553                 fileIncludeKind: ts.FileIncludeKind[reason.kind],
88554             });
88555             var result = findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId);
88556             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
88557             return result;
88558         }
88559         function findSourceFileWorker(fileName, path, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
88560             if (useSourceOfProjectReferenceRedirect) {
88561                 var source = getSourceOfProjectReferenceRedirect(fileName);
88562                 if (!source &&
88563                     host.realpath &&
88564                     options.preserveSymlinks &&
88565                     ts.isDeclarationFileName(fileName) &&
88566                     ts.stringContains(fileName, ts.nodeModulesPathPart)) {
88567                     var realPath = host.realpath(fileName);
88568                     if (realPath !== fileName)
88569                         source = getSourceOfProjectReferenceRedirect(realPath);
88570                 }
88571                 if (source) {
88572                     var file_1 = ts.isString(source) ?
88573                         findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, reason, packageId) :
88574                         undefined;
88575                     if (file_1)
88576                         addFileToFilesByName(file_1, path, undefined);
88577                     return file_1;
88578                 }
88579             }
88580             var originalFileName = fileName;
88581             if (filesByName.has(path)) {
88582                 var file_2 = filesByName.get(path);
88583                 addFileIncludeReason(file_2 || undefined, reason);
88584                 if (file_2 && options.forceConsistentCasingInFileNames) {
88585                     var checkedName = file_2.fileName;
88586                     var isRedirect = toPath(checkedName) !== toPath(fileName);
88587                     if (isRedirect) {
88588                         fileName = getProjectReferenceRedirect(fileName) || fileName;
88589                     }
88590                     var checkedAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(checkedName, currentDirectory);
88591                     var inputAbsolutePath = ts.getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory);
88592                     if (checkedAbsolutePath !== inputAbsolutePath) {
88593                         reportFileNamesDifferOnlyInCasingError(fileName, file_2, reason);
88594                     }
88595                 }
88596                 if (file_2 && sourceFilesFoundSearchingNodeModules.get(file_2.path) && currentNodeModulesDepth === 0) {
88597                     sourceFilesFoundSearchingNodeModules.set(file_2.path, false);
88598                     if (!options.noResolve) {
88599                         processReferencedFiles(file_2, isDefaultLib);
88600                         processTypeReferenceDirectives(file_2);
88601                     }
88602                     if (!options.noLib) {
88603                         processLibReferenceDirectives(file_2);
88604                     }
88605                     modulesWithElidedImports.set(file_2.path, false);
88606                     processImportedModules(file_2);
88607                 }
88608                 else if (file_2 && modulesWithElidedImports.get(file_2.path)) {
88609                     if (currentNodeModulesDepth < maxNodeModuleJsDepth) {
88610                         modulesWithElidedImports.set(file_2.path, false);
88611                         processImportedModules(file_2);
88612                     }
88613                 }
88614                 return file_2 || undefined;
88615             }
88616             var redirectedPath;
88617             if (isReferencedFile(reason) && !useSourceOfProjectReferenceRedirect) {
88618                 var redirectProject = getProjectReferenceRedirectProject(fileName);
88619                 if (redirectProject) {
88620                     if (ts.outFile(redirectProject.commandLine.options)) {
88621                         return undefined;
88622                     }
88623                     var redirect = getProjectReferenceOutputName(redirectProject, fileName);
88624                     fileName = redirect;
88625                     redirectedPath = toPath(redirect);
88626                 }
88627             }
88628             var file = host.getSourceFile(fileName, options.target, function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile);
88629             if (packageId) {
88630                 var packageIdKey = ts.packageIdToString(packageId);
88631                 var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
88632                 if (fileFromPackageId) {
88633                     var dupFile = createRedirectSourceFile(fileFromPackageId, file, fileName, path, toPath(fileName), originalFileName);
88634                     redirectTargetsMap.add(fileFromPackageId.path, fileName);
88635                     addFileToFilesByName(dupFile, path, redirectedPath);
88636                     addFileIncludeReason(dupFile, reason);
88637                     sourceFileToPackageName.set(path, packageId.name);
88638                     processingOtherFiles.push(dupFile);
88639                     return dupFile;
88640                 }
88641                 else if (file) {
88642                     packageIdToSourceFile.set(packageIdKey, file);
88643                     sourceFileToPackageName.set(path, packageId.name);
88644                 }
88645             }
88646             addFileToFilesByName(file, path, redirectedPath);
88647             if (file) {
88648                 sourceFilesFoundSearchingNodeModules.set(path, currentNodeModulesDepth > 0);
88649                 file.fileName = fileName;
88650                 file.path = path;
88651                 file.resolvedPath = toPath(fileName);
88652                 file.originalFileName = originalFileName;
88653                 addFileIncludeReason(file, reason);
88654                 if (host.useCaseSensitiveFileNames()) {
88655                     var pathLowerCase = ts.toFileNameLowerCase(path);
88656                     var existingFile = filesByNameIgnoreCase.get(pathLowerCase);
88657                     if (existingFile) {
88658                         reportFileNamesDifferOnlyInCasingError(fileName, existingFile, reason);
88659                     }
88660                     else {
88661                         filesByNameIgnoreCase.set(pathLowerCase, file);
88662                     }
88663                 }
88664                 skipDefaultLib = skipDefaultLib || (file.hasNoDefaultLib && !ignoreNoDefaultLib);
88665                 if (!options.noResolve) {
88666                     processReferencedFiles(file, isDefaultLib);
88667                     processTypeReferenceDirectives(file);
88668                 }
88669                 if (!options.noLib) {
88670                     processLibReferenceDirectives(file);
88671                 }
88672                 processImportedModules(file);
88673                 if (isDefaultLib) {
88674                     processingDefaultLibFiles.push(file);
88675                 }
88676                 else {
88677                     processingOtherFiles.push(file);
88678                 }
88679             }
88680             return file;
88681         }
88682         function addFileIncludeReason(file, reason) {
88683             if (file)
88684                 fileReasons.add(file.path, reason);
88685         }
88686         function addFileToFilesByName(file, path, redirectedPath) {
88687             if (redirectedPath) {
88688                 filesByName.set(redirectedPath, file);
88689                 filesByName.set(path, file || false);
88690             }
88691             else {
88692                 filesByName.set(path, file);
88693             }
88694         }
88695         function getProjectReferenceRedirect(fileName) {
88696             var referencedProject = getProjectReferenceRedirectProject(fileName);
88697             return referencedProject && getProjectReferenceOutputName(referencedProject, fileName);
88698         }
88699         function getProjectReferenceRedirectProject(fileName) {
88700             if (!resolvedProjectReferences || !resolvedProjectReferences.length || ts.fileExtensionIs(fileName, ".d.ts") || ts.fileExtensionIs(fileName, ".json")) {
88701                 return undefined;
88702             }
88703             return getResolvedProjectReferenceToRedirect(fileName);
88704         }
88705         function getProjectReferenceOutputName(referencedProject, fileName) {
88706             var out = ts.outFile(referencedProject.commandLine.options);
88707             return out ?
88708                 ts.changeExtension(out, ".d.ts") :
88709                 ts.getOutputDeclarationFileName(fileName, referencedProject.commandLine, !host.useCaseSensitiveFileNames());
88710         }
88711         function getResolvedProjectReferenceToRedirect(fileName) {
88712             if (mapFromFileToProjectReferenceRedirects === undefined) {
88713                 mapFromFileToProjectReferenceRedirects = new ts.Map();
88714                 forEachResolvedProjectReference(function (referencedProject) {
88715                     if (toPath(options.configFilePath) !== referencedProject.sourceFile.path) {
88716                         referencedProject.commandLine.fileNames.forEach(function (f) {
88717                             return mapFromFileToProjectReferenceRedirects.set(toPath(f), referencedProject.sourceFile.path);
88718                         });
88719                     }
88720                 });
88721             }
88722             var referencedProjectPath = mapFromFileToProjectReferenceRedirects.get(toPath(fileName));
88723             return referencedProjectPath && getResolvedProjectReferenceByPath(referencedProjectPath);
88724         }
88725         function forEachResolvedProjectReference(cb) {
88726             return ts.forEachResolvedProjectReference(resolvedProjectReferences, cb);
88727         }
88728         function getSourceOfProjectReferenceRedirect(file) {
88729             if (!ts.isDeclarationFileName(file))
88730                 return undefined;
88731             if (mapFromToProjectReferenceRedirectSource === undefined) {
88732                 mapFromToProjectReferenceRedirectSource = new ts.Map();
88733                 forEachResolvedProjectReference(function (resolvedRef) {
88734                     var out = ts.outFile(resolvedRef.commandLine.options);
88735                     if (out) {
88736                         var outputDts = ts.changeExtension(out, ".d.ts");
88737                         mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), true);
88738                     }
88739                     else {
88740                         var getCommonSourceDirectory_3 = ts.memoize(function () { return ts.getCommonSourceDirectoryOfConfig(resolvedRef.commandLine, !host.useCaseSensitiveFileNames()); });
88741                         ts.forEach(resolvedRef.commandLine.fileNames, function (fileName) {
88742                             if (!ts.fileExtensionIs(fileName, ".d.ts") && !ts.fileExtensionIs(fileName, ".json")) {
88743                                 var outputDts = ts.getOutputDeclarationFileName(fileName, resolvedRef.commandLine, !host.useCaseSensitiveFileNames(), getCommonSourceDirectory_3);
88744                                 mapFromToProjectReferenceRedirectSource.set(toPath(outputDts), fileName);
88745                             }
88746                         });
88747                     }
88748                 });
88749             }
88750             return mapFromToProjectReferenceRedirectSource.get(toPath(file));
88751         }
88752         function isSourceOfProjectReferenceRedirect(fileName) {
88753             return useSourceOfProjectReferenceRedirect && !!getResolvedProjectReferenceToRedirect(fileName);
88754         }
88755         function getResolvedProjectReferenceByPath(projectReferencePath) {
88756             if (!projectReferenceRedirects) {
88757                 return undefined;
88758             }
88759             return projectReferenceRedirects.get(projectReferencePath) || undefined;
88760         }
88761         function processReferencedFiles(file, isDefaultLib) {
88762             ts.forEach(file.referencedFiles, function (ref, index) {
88763                 processSourceFile(resolveTripleslashReference(ref.fileName, file.fileName), isDefaultLib, false, undefined, { kind: ts.FileIncludeKind.ReferenceFile, file: file.path, index: index, });
88764             });
88765         }
88766         function processTypeReferenceDirectives(file) {
88767             var typeDirectives = ts.map(file.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
88768             if (!typeDirectives) {
88769                 return;
88770             }
88771             var resolutions = resolveTypeReferenceDirectiveNamesWorker(typeDirectives, file);
88772             for (var index = 0; index < typeDirectives.length; index++) {
88773                 var ref = file.typeReferenceDirectives[index];
88774                 var resolvedTypeReferenceDirective = resolutions[index];
88775                 var fileName = ts.toFileNameLowerCase(ref.fileName);
88776                 ts.setResolvedTypeReferenceDirective(file, fileName, resolvedTypeReferenceDirective);
88777                 processTypeReferenceDirective(fileName, resolvedTypeReferenceDirective, { kind: ts.FileIncludeKind.TypeReferenceDirective, file: file.path, index: index, });
88778             }
88779         }
88780         function processTypeReferenceDirective(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
88781             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program", "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
88782             processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason);
88783             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
88784         }
88785         function processTypeReferenceDirectiveWorker(typeReferenceDirective, resolvedTypeReferenceDirective, reason) {
88786             var previousResolution = resolvedTypeReferenceDirectives.get(typeReferenceDirective);
88787             if (previousResolution && previousResolution.primary) {
88788                 return;
88789             }
88790             var saveResolution = true;
88791             if (resolvedTypeReferenceDirective) {
88792                 if (resolvedTypeReferenceDirective.isExternalLibraryImport)
88793                     currentNodeModulesDepth++;
88794                 if (resolvedTypeReferenceDirective.primary) {
88795                     processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, reason);
88796                 }
88797                 else {
88798                     if (previousResolution) {
88799                         if (resolvedTypeReferenceDirective.resolvedFileName !== previousResolution.resolvedFileName) {
88800                             var otherFileText = host.readFile(resolvedTypeReferenceDirective.resolvedFileName);
88801                             var existingFile = getSourceFile(previousResolution.resolvedFileName);
88802                             if (otherFileText !== existingFile.text) {
88803                                 addFilePreprocessingFileExplainingDiagnostic(existingFile, reason, 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]);
88804                             }
88805                         }
88806                         saveResolution = false;
88807                     }
88808                     else {
88809                         processSourceFile(resolvedTypeReferenceDirective.resolvedFileName, false, false, resolvedTypeReferenceDirective.packageId, reason);
88810                     }
88811                 }
88812                 if (resolvedTypeReferenceDirective.isExternalLibraryImport)
88813                     currentNodeModulesDepth--;
88814             }
88815             else {
88816                 addFilePreprocessingFileExplainingDiagnostic(undefined, reason, ts.Diagnostics.Cannot_find_type_definition_file_for_0, [typeReferenceDirective]);
88817             }
88818             if (saveResolution) {
88819                 resolvedTypeReferenceDirectives.set(typeReferenceDirective, resolvedTypeReferenceDirective);
88820             }
88821         }
88822         function processLibReferenceDirectives(file) {
88823             ts.forEach(file.libReferenceDirectives, function (libReference, index) {
88824                 var libName = ts.toFileNameLowerCase(libReference.fileName);
88825                 var libFileName = ts.libMap.get(libName);
88826                 if (libFileName) {
88827                     processRootFile(ts.combinePaths(defaultLibraryPath, libFileName), true, true, { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, });
88828                 }
88829                 else {
88830                     var unqualifiedLibName = ts.removeSuffix(ts.removePrefix(libName, "lib."), ".d.ts");
88831                     var suggestion = ts.getSpellingSuggestion(unqualifiedLibName, ts.libs, ts.identity);
88832                     var diagnostic = suggestion ? ts.Diagnostics.Cannot_find_lib_definition_for_0_Did_you_mean_1 : ts.Diagnostics.Cannot_find_lib_definition_for_0;
88833                     (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
88834                         kind: 0,
88835                         reason: { kind: ts.FileIncludeKind.LibReferenceDirective, file: file.path, index: index, },
88836                         diagnostic: diagnostic,
88837                         args: [libName, suggestion]
88838                     });
88839                 }
88840             });
88841         }
88842         function getCanonicalFileName(fileName) {
88843             return host.getCanonicalFileName(fileName);
88844         }
88845         function processImportedModules(file) {
88846             collectExternalModuleReferences(file);
88847             if (file.imports.length || file.moduleAugmentations.length) {
88848                 var moduleNames = getModuleNames(file);
88849                 var resolutions = resolveModuleNamesReusingOldState(moduleNames, file);
88850                 ts.Debug.assert(resolutions.length === moduleNames.length);
88851                 for (var index = 0; index < moduleNames.length; index++) {
88852                     var resolution = resolutions[index];
88853                     ts.setResolvedModule(file, moduleNames[index], resolution);
88854                     if (!resolution) {
88855                         continue;
88856                     }
88857                     var isFromNodeModulesSearch = resolution.isExternalLibraryImport;
88858                     var isJsFile = !ts.resolutionExtensionIsTSOrJson(resolution.extension);
88859                     var isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
88860                     var resolvedFileName = resolution.resolvedFileName;
88861                     if (isFromNodeModulesSearch) {
88862                         currentNodeModulesDepth++;
88863                     }
88864                     var elideImport = isJsFileFromNodeModules && currentNodeModulesDepth > maxNodeModuleJsDepth;
88865                     var shouldAddFile = resolvedFileName
88866                         && !getResolutionDiagnostic(options, resolution)
88867                         && !options.noResolve
88868                         && index < file.imports.length
88869                         && !elideImport
88870                         && !(isJsFile && !ts.getAllowJSCompilerOption(options))
88871                         && (ts.isInJSFile(file.imports[index]) || !(file.imports[index].flags & 4194304));
88872                     if (elideImport) {
88873                         modulesWithElidedImports.set(file.path, true);
88874                     }
88875                     else if (shouldAddFile) {
88876                         var path = toPath(resolvedFileName);
88877                         findSourceFile(resolvedFileName, path, false, false, { kind: ts.FileIncludeKind.Import, file: file.path, index: index, }, resolution.packageId);
88878                     }
88879                     if (isFromNodeModulesSearch) {
88880                         currentNodeModulesDepth--;
88881                     }
88882                 }
88883             }
88884             else {
88885                 file.resolvedModules = undefined;
88886             }
88887         }
88888         function checkSourceFilesBelongToPath(sourceFiles, rootDirectory) {
88889             var allFilesBelongToPath = true;
88890             var absoluteRootDirectoryPath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(rootDirectory, currentDirectory));
88891             for (var _i = 0, sourceFiles_2 = sourceFiles; _i < sourceFiles_2.length; _i++) {
88892                 var sourceFile = sourceFiles_2[_i];
88893                 if (!sourceFile.isDeclarationFile) {
88894                     var absoluteSourceFilePath = host.getCanonicalFileName(ts.getNormalizedAbsolutePath(sourceFile.fileName, currentDirectory));
88895                     if (absoluteSourceFilePath.indexOf(absoluteRootDirectoryPath) !== 0) {
88896                         addProgramDiagnosticExplainingFile(sourceFile, ts.Diagnostics.File_0_is_not_under_rootDir_1_rootDir_is_expected_to_contain_all_source_files, [sourceFile.fileName, rootDirectory]);
88897                         allFilesBelongToPath = false;
88898                     }
88899                 }
88900             }
88901             return allFilesBelongToPath;
88902         }
88903         function parseProjectReferenceConfigFile(ref) {
88904             if (!projectReferenceRedirects) {
88905                 projectReferenceRedirects = new ts.Map();
88906             }
88907             var refPath = resolveProjectReferencePath(ref);
88908             var sourceFilePath = toPath(refPath);
88909             var fromCache = projectReferenceRedirects.get(sourceFilePath);
88910             if (fromCache !== undefined) {
88911                 return fromCache || undefined;
88912             }
88913             var commandLine;
88914             var sourceFile;
88915             if (host.getParsedCommandLine) {
88916                 commandLine = host.getParsedCommandLine(refPath);
88917                 if (!commandLine) {
88918                     addFileToFilesByName(undefined, sourceFilePath, undefined);
88919                     projectReferenceRedirects.set(sourceFilePath, false);
88920                     return undefined;
88921                 }
88922                 sourceFile = ts.Debug.checkDefined(commandLine.options.configFile);
88923                 ts.Debug.assert(!sourceFile.path || sourceFile.path === sourceFilePath);
88924                 addFileToFilesByName(sourceFile, sourceFilePath, undefined);
88925             }
88926             else {
88927                 var basePath = ts.getNormalizedAbsolutePath(ts.getDirectoryPath(refPath), host.getCurrentDirectory());
88928                 sourceFile = host.getSourceFile(refPath, 100);
88929                 addFileToFilesByName(sourceFile, sourceFilePath, undefined);
88930                 if (sourceFile === undefined) {
88931                     projectReferenceRedirects.set(sourceFilePath, false);
88932                     return undefined;
88933                 }
88934                 commandLine = ts.parseJsonSourceFileConfigFileContent(sourceFile, configParsingHost, basePath, undefined, refPath);
88935             }
88936             sourceFile.fileName = refPath;
88937             sourceFile.path = sourceFilePath;
88938             sourceFile.resolvedPath = sourceFilePath;
88939             sourceFile.originalFileName = refPath;
88940             var resolvedRef = { commandLine: commandLine, sourceFile: sourceFile };
88941             projectReferenceRedirects.set(sourceFilePath, resolvedRef);
88942             if (commandLine.projectReferences) {
88943                 resolvedRef.references = commandLine.projectReferences.map(parseProjectReferenceConfigFile);
88944             }
88945             return resolvedRef;
88946         }
88947         function verifyCompilerOptions() {
88948             if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) {
88949                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks");
88950             }
88951             if (options.isolatedModules) {
88952                 if (options.out) {
88953                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "isolatedModules");
88954                 }
88955                 if (options.outFile) {
88956                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "outFile", "isolatedModules");
88957                 }
88958             }
88959             if (options.inlineSourceMap) {
88960                 if (options.sourceMap) {
88961                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "sourceMap", "inlineSourceMap");
88962                 }
88963                 if (options.mapRoot) {
88964                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "mapRoot", "inlineSourceMap");
88965                 }
88966             }
88967             if (options.composite) {
88968                 if (options.declaration === false) {
88969                     createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_declaration_emit, "declaration");
88970                 }
88971                 if (options.incremental === false) {
88972                     createDiagnosticForOptionName(ts.Diagnostics.Composite_projects_may_not_disable_incremental_compilation, "declaration");
88973                 }
88974             }
88975             var outputFile = ts.outFile(options);
88976             if (options.tsBuildInfoFile) {
88977                 if (!ts.isIncrementalCompilation(options)) {
88978                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "tsBuildInfoFile", "incremental", "composite");
88979                 }
88980             }
88981             else if (options.incremental && !outputFile && !options.configFilePath) {
88982                 programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_incremental_can_only_be_specified_using_tsconfig_emitting_to_single_file_or_when_option_tsBuildInfoFile_is_specified));
88983             }
88984             verifyProjectReferences();
88985             if (options.composite) {
88986                 var rootPaths = new ts.Set(rootNames.map(toPath));
88987                 for (var _i = 0, files_3 = files; _i < files_3.length; _i++) {
88988                     var file = files_3[_i];
88989                     if (ts.sourceFileMayBeEmitted(file, program) && !rootPaths.has(file.path)) {
88990                         addProgramDiagnosticExplainingFile(file, 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 || ""]);
88991                     }
88992                 }
88993             }
88994             if (options.paths) {
88995                 for (var key in options.paths) {
88996                     if (!ts.hasProperty(options.paths, key)) {
88997                         continue;
88998                     }
88999                     if (!ts.hasZeroOrOneAsteriskCharacter(key)) {
89000                         createDiagnosticForOptionPaths(true, key, ts.Diagnostics.Pattern_0_can_have_at_most_one_Asterisk_character, key);
89001                     }
89002                     if (ts.isArray(options.paths[key])) {
89003                         var len = options.paths[key].length;
89004                         if (len === 0) {
89005                             createDiagnosticForOptionPaths(false, key, ts.Diagnostics.Substitutions_for_pattern_0_shouldn_t_be_an_empty_array, key);
89006                         }
89007                         for (var i = 0; i < len; i++) {
89008                             var subst = options.paths[key][i];
89009                             var typeOfSubst = typeof subst;
89010                             if (typeOfSubst === "string") {
89011                                 if (!ts.hasZeroOrOneAsteriskCharacter(subst)) {
89012                                     createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character, subst, key);
89013                                 }
89014                                 if (!options.baseUrl && !ts.pathIsRelative(subst) && !ts.pathIsAbsolute(subst)) {
89015                                     createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Non_relative_paths_are_not_allowed_when_baseUrl_is_not_set_Did_you_forget_a_leading_Slash);
89016                                 }
89017                             }
89018                             else {
89019                                 createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2, subst, key, typeOfSubst);
89020                             }
89021                         }
89022                     }
89023                     else {
89024                         createDiagnosticForOptionPaths(false, key, ts.Diagnostics.Substitutions_for_pattern_0_should_be_an_array, key);
89025                     }
89026                 }
89027             }
89028             if (!options.sourceMap && !options.inlineSourceMap) {
89029                 if (options.inlineSources) {
89030                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "inlineSources");
89031                 }
89032                 if (options.sourceRoot) {
89033                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_can_only_be_used_when_either_option_inlineSourceMap_or_option_sourceMap_is_provided, "sourceRoot");
89034                 }
89035             }
89036             if (options.out && options.outFile) {
89037                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "out", "outFile");
89038             }
89039             if (options.mapRoot && !(options.sourceMap || options.declarationMap)) {
89040                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "mapRoot", "sourceMap", "declarationMap");
89041             }
89042             if (options.declarationDir) {
89043                 if (!ts.getEmitDeclarations(options)) {
89044                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "declarationDir", "declaration", "composite");
89045                 }
89046                 if (outputFile) {
89047                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "declarationDir", options.out ? "out" : "outFile");
89048                 }
89049             }
89050             if (options.declarationMap && !ts.getEmitDeclarations(options)) {
89051                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "declarationMap", "declaration", "composite");
89052             }
89053             if (options.lib && options.noLib) {
89054                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "lib", "noLib");
89055             }
89056             if (options.noImplicitUseStrict && ts.getStrictOptionValue(options, "alwaysStrict")) {
89057                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "noImplicitUseStrict", "alwaysStrict");
89058             }
89059             var languageVersion = options.target || 0;
89060             var firstNonAmbientExternalModuleSourceFile = ts.find(files, function (f) { return ts.isExternalModule(f) && !f.isDeclarationFile; });
89061             if (options.isolatedModules) {
89062                 if (options.module === ts.ModuleKind.None && languageVersion < 2) {
89063                     createDiagnosticForOptionName(ts.Diagnostics.Option_isolatedModules_can_only_be_used_when_either_option_module_is_provided_or_option_target_is_ES2015_or_higher, "isolatedModules", "target");
89064                 }
89065                 if (options.preserveConstEnums === false) {
89066                     createDiagnosticForOptionName(ts.Diagnostics.Option_preserveConstEnums_cannot_be_disabled_when_isolatedModules_is_enabled, "preserveConstEnums", "isolatedModules");
89067                 }
89068                 var firstNonExternalModuleSourceFile = ts.find(files, function (f) { return !ts.isExternalModule(f) && !ts.isSourceFileJS(f) && !f.isDeclarationFile && f.scriptKind !== 6; });
89069                 if (firstNonExternalModuleSourceFile) {
89070                     var span = ts.getErrorSpanForNode(firstNonExternalModuleSourceFile, firstNonExternalModuleSourceFile);
89071                     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)));
89072                 }
89073             }
89074             else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 && options.module === ts.ModuleKind.None) {
89075                 var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
89076                 programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
89077             }
89078             if (outputFile && !options.emitDeclarationOnly) {
89079                 if (options.module && !(options.module === ts.ModuleKind.AMD || options.module === ts.ModuleKind.System)) {
89080                     createDiagnosticForOptionName(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile", "module");
89081                 }
89082                 else if (options.module === undefined && firstNonAmbientExternalModuleSourceFile) {
89083                     var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
89084                     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"));
89085                 }
89086             }
89087             if (options.resolveJsonModule) {
89088                 if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs) {
89089                     createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule");
89090                 }
89091                 else if (!ts.hasJsonModuleEmitEnabled(options)) {
89092                     createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_can_only_be_specified_when_module_code_generation_is_commonjs_amd_es2015_or_esNext, "resolveJsonModule", "module");
89093                 }
89094             }
89095             if (options.outDir ||
89096                 options.sourceRoot ||
89097                 options.mapRoot) {
89098                 var dir = getCommonSourceDirectory();
89099                 if (options.outDir && dir === "" && files.some(function (file) { return ts.getRootLength(file.fileName) > 1; })) {
89100                     createDiagnosticForOptionName(ts.Diagnostics.Cannot_find_the_common_subdirectory_path_for_the_input_files, "outDir");
89101                 }
89102             }
89103             if (options.useDefineForClassFields && languageVersion === 0) {
89104                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_target_is_ES3, "useDefineForClassFields");
89105             }
89106             if (options.checkJs && !ts.getAllowJSCompilerOption(options)) {
89107                 programDiagnostics.add(ts.createCompilerDiagnostic(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "checkJs", "allowJs"));
89108             }
89109             if (options.emitDeclarationOnly) {
89110                 if (!ts.getEmitDeclarations(options)) {
89111                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1_or_option_2, "emitDeclarationOnly", "declaration", "composite");
89112                 }
89113                 if (options.noEmit) {
89114                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "emitDeclarationOnly", "noEmit");
89115                 }
89116             }
89117             if (options.emitDecoratorMetadata &&
89118                 !options.experimentalDecorators) {
89119                 createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "emitDecoratorMetadata", "experimentalDecorators");
89120             }
89121             if (options.jsxFactory) {
89122                 if (options.reactNamespace) {
89123                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_with_option_1, "reactNamespace", "jsxFactory");
89124                 }
89125                 if (options.jsx === 4 || options.jsx === 5) {
89126                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFactory", ts.inverseJsxOptionMap.get("" + options.jsx));
89127                 }
89128                 if (!ts.parseIsolatedEntityName(options.jsxFactory, languageVersion)) {
89129                     createOptionValueDiagnostic("jsxFactory", ts.Diagnostics.Invalid_value_for_jsxFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFactory);
89130                 }
89131             }
89132             else if (options.reactNamespace && !ts.isIdentifierText(options.reactNamespace, languageVersion)) {
89133                 createOptionValueDiagnostic("reactNamespace", ts.Diagnostics.Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier, options.reactNamespace);
89134             }
89135             if (options.jsxFragmentFactory) {
89136                 if (!options.jsxFactory) {
89137                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "jsxFragmentFactory", "jsxFactory");
89138                 }
89139                 if (options.jsx === 4 || options.jsx === 5) {
89140                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxFragmentFactory", ts.inverseJsxOptionMap.get("" + options.jsx));
89141                 }
89142                 if (!ts.parseIsolatedEntityName(options.jsxFragmentFactory, languageVersion)) {
89143                     createOptionValueDiagnostic("jsxFragmentFactory", ts.Diagnostics.Invalid_value_for_jsxFragmentFactory_0_is_not_a_valid_identifier_or_qualified_name, options.jsxFragmentFactory);
89144                 }
89145             }
89146             if (options.reactNamespace) {
89147                 if (options.jsx === 4 || options.jsx === 5) {
89148                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "reactNamespace", ts.inverseJsxOptionMap.get("" + options.jsx));
89149                 }
89150             }
89151             if (options.jsxImportSource) {
89152                 if (options.jsx === 2) {
89153                     createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_when_option_jsx_is_1, "jsxImportSource", ts.inverseJsxOptionMap.get("" + options.jsx));
89154                 }
89155             }
89156             if (!options.noEmit && !options.suppressOutputPathCheck) {
89157                 var emitHost = getEmitHost();
89158                 var emitFilesSeen_1 = new ts.Set();
89159                 ts.forEachEmittedFile(emitHost, function (emitFileNames) {
89160                     if (!options.emitDeclarationOnly) {
89161                         verifyEmitFilePath(emitFileNames.jsFilePath, emitFilesSeen_1);
89162                     }
89163                     verifyEmitFilePath(emitFileNames.declarationFilePath, emitFilesSeen_1);
89164                 });
89165             }
89166             function verifyEmitFilePath(emitFileName, emitFilesSeen) {
89167                 if (emitFileName) {
89168                     var emitFilePath = toPath(emitFileName);
89169                     if (filesByName.has(emitFilePath)) {
89170                         var chain = void 0;
89171                         if (!options.configFilePath) {
89172                             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);
89173                         }
89174                         chain = ts.chainDiagnosticMessages(chain, ts.Diagnostics.Cannot_write_file_0_because_it_would_overwrite_input_file, emitFileName);
89175                         blockEmittingOfFile(emitFileName, ts.createCompilerDiagnosticFromMessageChain(chain));
89176                     }
89177                     var emitFileKey = !host.useCaseSensitiveFileNames() ? ts.toFileNameLowerCase(emitFilePath) : emitFilePath;
89178                     if (emitFilesSeen.has(emitFileKey)) {
89179                         blockEmittingOfFile(emitFileName, ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_write_file_0_because_it_would_be_overwritten_by_multiple_input_files, emitFileName));
89180                     }
89181                     else {
89182                         emitFilesSeen.add(emitFileKey);
89183                     }
89184                 }
89185             }
89186         }
89187         function createDiagnosticExplainingFile(file, fileProcessingReason, diagnostic, args) {
89188             var _a;
89189             var fileIncludeReasons;
89190             var relatedInfo;
89191             var locationReason = isReferencedFile(fileProcessingReason) ? fileProcessingReason : undefined;
89192             if (file)
89193                 (_a = fileReasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(processReason);
89194             if (fileProcessingReason)
89195                 processReason(fileProcessingReason);
89196             if (locationReason && (fileIncludeReasons === null || fileIncludeReasons === void 0 ? void 0 : fileIncludeReasons.length) === 1)
89197                 fileIncludeReasons = undefined;
89198             var location = locationReason && getReferencedFileLocation(getSourceFileByPath, locationReason);
89199             var fileIncludeReasonDetails = fileIncludeReasons && ts.chainDiagnosticMessages(fileIncludeReasons, ts.Diagnostics.The_file_is_in_the_program_because_Colon);
89200             var redirectInfo = file && ts.explainIfFileIsRedirect(file);
89201             var chain = ts.chainDiagnosticMessages.apply(void 0, __spreadArray([redirectInfo ? fileIncludeReasonDetails ? __spreadArray([fileIncludeReasonDetails], redirectInfo) : redirectInfo : fileIncludeReasonDetails, diagnostic], args || ts.emptyArray));
89202             return location && isReferenceFileLocation(location) ?
89203                 ts.createFileDiagnosticFromMessageChain(location.file, location.pos, location.end - location.pos, chain, relatedInfo) :
89204                 ts.createCompilerDiagnosticFromMessageChain(chain, relatedInfo);
89205             function processReason(reason) {
89206                 (fileIncludeReasons || (fileIncludeReasons = [])).push(ts.fileIncludeReasonToDiagnostics(program, reason));
89207                 if (!locationReason && isReferencedFile(reason)) {
89208                     locationReason = reason;
89209                 }
89210                 else if (locationReason !== reason) {
89211                     relatedInfo = ts.append(relatedInfo, fileIncludeReasonToRelatedInformation(reason));
89212                 }
89213                 if (reason === fileProcessingReason)
89214                     fileProcessingReason = undefined;
89215             }
89216         }
89217         function addFilePreprocessingFileExplainingDiagnostic(file, fileProcessingReason, diagnostic, args) {
89218             (fileProcessingDiagnostics || (fileProcessingDiagnostics = [])).push({
89219                 kind: 1,
89220                 file: file && file.path,
89221                 fileProcessingReason: fileProcessingReason,
89222                 diagnostic: diagnostic,
89223                 args: args
89224             });
89225         }
89226         function addProgramDiagnosticExplainingFile(file, diagnostic, args) {
89227             programDiagnostics.add(createDiagnosticExplainingFile(file, undefined, diagnostic, args));
89228         }
89229         function fileIncludeReasonToRelatedInformation(reason) {
89230             if (isReferencedFile(reason)) {
89231                 var referenceLocation = getReferencedFileLocation(getSourceFileByPath, reason);
89232                 var message_2;
89233                 switch (reason.kind) {
89234                     case ts.FileIncludeKind.Import:
89235                         message_2 = ts.Diagnostics.File_is_included_via_import_here;
89236                         break;
89237                     case ts.FileIncludeKind.ReferenceFile:
89238                         message_2 = ts.Diagnostics.File_is_included_via_reference_here;
89239                         break;
89240                     case ts.FileIncludeKind.TypeReferenceDirective:
89241                         message_2 = ts.Diagnostics.File_is_included_via_type_library_reference_here;
89242                         break;
89243                     case ts.FileIncludeKind.LibReferenceDirective:
89244                         message_2 = ts.Diagnostics.File_is_included_via_library_reference_here;
89245                         break;
89246                     default:
89247                         ts.Debug.assertNever(reason);
89248                 }
89249                 return isReferenceFileLocation(referenceLocation) ? ts.createFileDiagnostic(referenceLocation.file, referenceLocation.pos, referenceLocation.end - referenceLocation.pos, message_2) : undefined;
89250             }
89251             if (!options.configFile)
89252                 return undefined;
89253             var configFileNode;
89254             var message;
89255             switch (reason.kind) {
89256                 case ts.FileIncludeKind.RootFile:
89257                     if (!options.configFile.configFileSpecs)
89258                         return undefined;
89259                     var fileName = ts.getNormalizedAbsolutePath(rootNames[reason.index], currentDirectory);
89260                     var matchedByFiles = ts.getMatchedFileSpec(program, fileName);
89261                     if (matchedByFiles) {
89262                         configFileNode = ts.getTsConfigPropArrayElementValue(options.configFile, "files", matchedByFiles);
89263                         message = ts.Diagnostics.File_is_matched_by_files_list_specified_here;
89264                         break;
89265                     }
89266                     var matchedByInclude = ts.getMatchedIncludeSpec(program, fileName);
89267                     if (!matchedByInclude)
89268                         return undefined;
89269                     configFileNode = ts.getTsConfigPropArrayElementValue(options.configFile, "include", matchedByInclude);
89270                     message = ts.Diagnostics.File_is_matched_by_include_pattern_specified_here;
89271                     break;
89272                 case ts.FileIncludeKind.SourceFromProjectReference:
89273                 case ts.FileIncludeKind.OutputFromProjectReference:
89274                     var referencedResolvedRef_1 = ts.Debug.checkDefined(resolvedProjectReferences === null || resolvedProjectReferences === void 0 ? void 0 : resolvedProjectReferences[reason.index]);
89275                     var referenceInfo = forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, parent, index) {
89276                         return resolvedRef === referencedResolvedRef_1 ? { sourceFile: (parent === null || parent === void 0 ? void 0 : parent.sourceFile) || options.configFile, index: index } : undefined;
89277                     });
89278                     if (!referenceInfo)
89279                         return undefined;
89280                     var sourceFile = referenceInfo.sourceFile, index = referenceInfo.index;
89281                     var referencesSyntax = ts.firstDefined(ts.getTsConfigPropArray(sourceFile, "references"), function (property) { return ts.isArrayLiteralExpression(property.initializer) ? property.initializer : undefined; });
89282                     return referencesSyntax && referencesSyntax.elements.length > index ?
89283                         ts.createDiagnosticForNodeInSourceFile(sourceFile, referencesSyntax.elements[index], reason.kind === ts.FileIncludeKind.OutputFromProjectReference ?
89284                             ts.Diagnostics.File_is_output_from_referenced_project_specified_here :
89285                             ts.Diagnostics.File_is_source_from_referenced_project_specified_here) :
89286                         undefined;
89287                 case ts.FileIncludeKind.AutomaticTypeDirectiveFile:
89288                     if (!options.types)
89289                         return undefined;
89290                     configFileNode = getOptionsSyntaxByArrayElementValue("types", reason.typeReference);
89291                     message = ts.Diagnostics.File_is_entry_point_of_type_library_specified_here;
89292                     break;
89293                 case ts.FileIncludeKind.LibFile:
89294                     if (reason.index !== undefined) {
89295                         configFileNode = getOptionsSyntaxByArrayElementValue("lib", options.lib[reason.index]);
89296                         message = ts.Diagnostics.File_is_library_specified_here;
89297                         break;
89298                     }
89299                     var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === options.target ? key : undefined; });
89300                     configFileNode = target ? getOptionsSyntaxByValue("target", target) : undefined;
89301                     message = ts.Diagnostics.File_is_default_library_for_target_specified_here;
89302                     break;
89303                 default:
89304                     ts.Debug.assertNever(reason);
89305             }
89306             return configFileNode && ts.createDiagnosticForNodeInSourceFile(options.configFile, configFileNode, message);
89307         }
89308         function verifyProjectReferences() {
89309             var buildInfoPath = !options.suppressOutputPathCheck ? ts.getTsBuildInfoEmitOutputFilePath(options) : undefined;
89310             forEachProjectReference(projectReferences, resolvedProjectReferences, function (resolvedRef, parent, index) {
89311                 var ref = (parent ? parent.commandLine.projectReferences : projectReferences)[index];
89312                 var parentFile = parent && parent.sourceFile;
89313                 if (!resolvedRef) {
89314                     createDiagnosticForReference(parentFile, index, ts.Diagnostics.File_0_not_found, ref.path);
89315                     return;
89316                 }
89317                 var options = resolvedRef.commandLine.options;
89318                 if (!options.composite || options.noEmit) {
89319                     var inputs = parent ? parent.commandLine.fileNames : rootNames;
89320                     if (inputs.length) {
89321                         if (!options.composite)
89322                             createDiagnosticForReference(parentFile, index, ts.Diagnostics.Referenced_project_0_must_have_setting_composite_Colon_true, ref.path);
89323                         if (options.noEmit)
89324                             createDiagnosticForReference(parentFile, index, ts.Diagnostics.Referenced_project_0_may_not_disable_emit, ref.path);
89325                     }
89326                 }
89327                 if (ref.prepend) {
89328                     var out = ts.outFile(options);
89329                     if (out) {
89330                         if (!host.fileExists(out)) {
89331                             createDiagnosticForReference(parentFile, index, ts.Diagnostics.Output_file_0_from_project_1_does_not_exist, out, ref.path);
89332                         }
89333                     }
89334                     else {
89335                         createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_prepend_project_0_because_it_does_not_have_outFile_set, ref.path);
89336                     }
89337                 }
89338                 if (!parent && buildInfoPath && buildInfoPath === ts.getTsBuildInfoEmitOutputFilePath(options)) {
89339                     createDiagnosticForReference(parentFile, index, ts.Diagnostics.Cannot_write_file_0_because_it_will_overwrite_tsbuildinfo_file_generated_by_referenced_project_1, buildInfoPath, ref.path);
89340                     hasEmitBlockingDiagnostics.set(toPath(buildInfoPath), true);
89341                 }
89342             });
89343         }
89344         function createDiagnosticForOptionPathKeyValue(key, valueIndex, message, arg0, arg1, arg2) {
89345             var needCompilerDiagnostic = true;
89346             var pathsSyntax = getOptionPathsSyntax();
89347             for (var _i = 0, pathsSyntax_1 = pathsSyntax; _i < pathsSyntax_1.length; _i++) {
89348                 var pathProp = pathsSyntax_1[_i];
89349                 if (ts.isObjectLiteralExpression(pathProp.initializer)) {
89350                     for (var _a = 0, _b = ts.getPropertyAssignment(pathProp.initializer, key); _a < _b.length; _a++) {
89351                         var keyProps = _b[_a];
89352                         var initializer = keyProps.initializer;
89353                         if (ts.isArrayLiteralExpression(initializer) && initializer.elements.length > valueIndex) {
89354                             programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, initializer.elements[valueIndex], message, arg0, arg1, arg2));
89355                             needCompilerDiagnostic = false;
89356                         }
89357                     }
89358                 }
89359             }
89360             if (needCompilerDiagnostic) {
89361                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1, arg2));
89362             }
89363         }
89364         function createDiagnosticForOptionPaths(onKey, key, message, arg0) {
89365             var needCompilerDiagnostic = true;
89366             var pathsSyntax = getOptionPathsSyntax();
89367             for (var _i = 0, pathsSyntax_2 = pathsSyntax; _i < pathsSyntax_2.length; _i++) {
89368                 var pathProp = pathsSyntax_2[_i];
89369                 if (ts.isObjectLiteralExpression(pathProp.initializer) &&
89370                     createOptionDiagnosticInObjectLiteralSyntax(pathProp.initializer, onKey, key, undefined, message, arg0)) {
89371                     needCompilerDiagnostic = false;
89372                 }
89373             }
89374             if (needCompilerDiagnostic) {
89375                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0));
89376             }
89377         }
89378         function getOptionsSyntaxByName(name) {
89379             var compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();
89380             return compilerOptionsObjectLiteralSyntax && ts.getPropertyAssignment(compilerOptionsObjectLiteralSyntax, name);
89381         }
89382         function getOptionPathsSyntax() {
89383             return getOptionsSyntaxByName("paths") || ts.emptyArray;
89384         }
89385         function getOptionsSyntaxByValue(name, value) {
89386             var syntaxByName = getOptionsSyntaxByName(name);
89387             return syntaxByName && ts.firstDefined(syntaxByName, function (property) { return ts.isStringLiteral(property.initializer) && property.initializer.text === value ? property.initializer : undefined; });
89388         }
89389         function getOptionsSyntaxByArrayElementValue(name, value) {
89390             var compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();
89391             return compilerOptionsObjectLiteralSyntax && ts.getPropertyArrayElementValue(compilerOptionsObjectLiteralSyntax, name, value);
89392         }
89393         function createDiagnosticForOptionName(message, option1, option2, option3) {
89394             createDiagnosticForOption(true, option1, option2, message, option1, option2, option3);
89395         }
89396         function createOptionValueDiagnostic(option1, message, arg0) {
89397             createDiagnosticForOption(false, option1, undefined, message, arg0);
89398         }
89399         function createDiagnosticForReference(sourceFile, index, message, arg0, arg1) {
89400             var referencesSyntax = ts.firstDefined(ts.getTsConfigPropArray(sourceFile || options.configFile, "references"), function (property) { return ts.isArrayLiteralExpression(property.initializer) ? property.initializer : undefined; });
89401             if (referencesSyntax && referencesSyntax.elements.length > index) {
89402                 programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(sourceFile || options.configFile, referencesSyntax.elements[index], message, arg0, arg1));
89403             }
89404             else {
89405                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1));
89406             }
89407         }
89408         function createDiagnosticForOption(onKey, option1, option2, message, arg0, arg1, arg2) {
89409             var compilerOptionsObjectLiteralSyntax = getCompilerOptionsObjectLiteralSyntax();
89410             var needCompilerDiagnostic = !compilerOptionsObjectLiteralSyntax ||
89411                 !createOptionDiagnosticInObjectLiteralSyntax(compilerOptionsObjectLiteralSyntax, onKey, option1, option2, message, arg0, arg1, arg2);
89412             if (needCompilerDiagnostic) {
89413                 programDiagnostics.add(ts.createCompilerDiagnostic(message, arg0, arg1, arg2));
89414             }
89415         }
89416         function getCompilerOptionsObjectLiteralSyntax() {
89417             if (_compilerOptionsObjectLiteralSyntax === undefined) {
89418                 _compilerOptionsObjectLiteralSyntax = false;
89419                 var jsonObjectLiteral = ts.getTsConfigObjectLiteralExpression(options.configFile);
89420                 if (jsonObjectLiteral) {
89421                     for (var _i = 0, _a = ts.getPropertyAssignment(jsonObjectLiteral, "compilerOptions"); _i < _a.length; _i++) {
89422                         var prop = _a[_i];
89423                         if (ts.isObjectLiteralExpression(prop.initializer)) {
89424                             _compilerOptionsObjectLiteralSyntax = prop.initializer;
89425                             break;
89426                         }
89427                     }
89428                 }
89429             }
89430             return _compilerOptionsObjectLiteralSyntax || undefined;
89431         }
89432         function createOptionDiagnosticInObjectLiteralSyntax(objectLiteral, onKey, key1, key2, message, arg0, arg1, arg2) {
89433             var props = ts.getPropertyAssignment(objectLiteral, key1, key2);
89434             for (var _i = 0, props_3 = props; _i < props_3.length; _i++) {
89435                 var prop = props_3[_i];
89436                 programDiagnostics.add(ts.createDiagnosticForNodeInSourceFile(options.configFile, onKey ? prop.name : prop.initializer, message, arg0, arg1, arg2));
89437             }
89438             return !!props.length;
89439         }
89440         function blockEmittingOfFile(emitFileName, diag) {
89441             hasEmitBlockingDiagnostics.set(toPath(emitFileName), true);
89442             programDiagnostics.add(diag);
89443         }
89444         function isEmittedFile(file) {
89445             if (options.noEmit) {
89446                 return false;
89447             }
89448             var filePath = toPath(file);
89449             if (getSourceFileByPath(filePath)) {
89450                 return false;
89451             }
89452             var out = ts.outFile(options);
89453             if (out) {
89454                 return isSameFile(filePath, out) || isSameFile(filePath, ts.removeFileExtension(out) + ".d.ts");
89455             }
89456             if (options.declarationDir && ts.containsPath(options.declarationDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames())) {
89457                 return true;
89458             }
89459             if (options.outDir) {
89460                 return ts.containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames());
89461             }
89462             if (ts.fileExtensionIsOneOf(filePath, ts.supportedJSExtensions) || ts.fileExtensionIs(filePath, ".d.ts")) {
89463                 var filePathWithoutExtension = ts.removeFileExtension(filePath);
89464                 return !!getSourceFileByPath((filePathWithoutExtension + ".ts")) ||
89465                     !!getSourceFileByPath((filePathWithoutExtension + ".tsx"));
89466             }
89467             return false;
89468         }
89469         function isSameFile(file1, file2) {
89470             return ts.comparePaths(file1, file2, currentDirectory, !host.useCaseSensitiveFileNames()) === 0;
89471         }
89472         function getSymlinkCache() {
89473             if (host.getSymlinkCache) {
89474                 return host.getSymlinkCache();
89475             }
89476             return symlinks || (symlinks = ts.discoverProbableSymlinks(files, getCanonicalFileName, host.getCurrentDirectory()));
89477         }
89478     }
89479     ts.createProgram = createProgram;
89480     function updateHostForUseSourceOfProjectReferenceRedirect(host) {
89481         var setOfDeclarationDirectories;
89482         var originalFileExists = host.compilerHost.fileExists;
89483         var originalDirectoryExists = host.compilerHost.directoryExists;
89484         var originalGetDirectories = host.compilerHost.getDirectories;
89485         var originalRealpath = host.compilerHost.realpath;
89486         if (!host.useSourceOfProjectReferenceRedirect)
89487             return { onProgramCreateComplete: ts.noop, fileExists: fileExists };
89488         host.compilerHost.fileExists = fileExists;
89489         var directoryExists;
89490         if (originalDirectoryExists) {
89491             directoryExists = host.compilerHost.directoryExists = function (path) {
89492                 if (originalDirectoryExists.call(host.compilerHost, path)) {
89493                     handleDirectoryCouldBeSymlink(path);
89494                     return true;
89495                 }
89496                 if (!host.getResolvedProjectReferences())
89497                     return false;
89498                 if (!setOfDeclarationDirectories) {
89499                     setOfDeclarationDirectories = new ts.Set();
89500                     host.forEachResolvedProjectReference(function (ref) {
89501                         var out = ts.outFile(ref.commandLine.options);
89502                         if (out) {
89503                             setOfDeclarationDirectories.add(ts.getDirectoryPath(host.toPath(out)));
89504                         }
89505                         else {
89506                             var declarationDir = ref.commandLine.options.declarationDir || ref.commandLine.options.outDir;
89507                             if (declarationDir) {
89508                                 setOfDeclarationDirectories.add(host.toPath(declarationDir));
89509                             }
89510                         }
89511                     });
89512                 }
89513                 return fileOrDirectoryExistsUsingSource(path, false);
89514             };
89515         }
89516         if (originalGetDirectories) {
89517             host.compilerHost.getDirectories = function (path) {
89518                 return !host.getResolvedProjectReferences() || (originalDirectoryExists && originalDirectoryExists.call(host.compilerHost, path)) ?
89519                     originalGetDirectories.call(host.compilerHost, path) :
89520                     [];
89521             };
89522         }
89523         if (originalRealpath) {
89524             host.compilerHost.realpath = function (s) {
89525                 var _a;
89526                 return ((_a = host.getSymlinkCache().getSymlinkedFiles()) === null || _a === void 0 ? void 0 : _a.get(host.toPath(s))) ||
89527                     originalRealpath.call(host.compilerHost, s);
89528             };
89529         }
89530         return { onProgramCreateComplete: onProgramCreateComplete, fileExists: fileExists, directoryExists: directoryExists };
89531         function onProgramCreateComplete() {
89532             host.compilerHost.fileExists = originalFileExists;
89533             host.compilerHost.directoryExists = originalDirectoryExists;
89534             host.compilerHost.getDirectories = originalGetDirectories;
89535         }
89536         function fileExists(file) {
89537             if (originalFileExists.call(host.compilerHost, file))
89538                 return true;
89539             if (!host.getResolvedProjectReferences())
89540                 return false;
89541             if (!ts.isDeclarationFileName(file))
89542                 return false;
89543             return fileOrDirectoryExistsUsingSource(file, true);
89544         }
89545         function fileExistsIfProjectReferenceDts(file) {
89546             var source = host.getSourceOfProjectReferenceRedirect(file);
89547             return source !== undefined ?
89548                 ts.isString(source) ? originalFileExists.call(host.compilerHost, source) : true :
89549                 undefined;
89550         }
89551         function directoryExistsIfProjectReferenceDeclDir(dir) {
89552             var dirPath = host.toPath(dir);
89553             var dirPathWithTrailingDirectorySeparator = "" + dirPath + ts.directorySeparator;
89554             return ts.forEachKey(setOfDeclarationDirectories, function (declDirPath) { return dirPath === declDirPath ||
89555                 ts.startsWith(declDirPath, dirPathWithTrailingDirectorySeparator) ||
89556                 ts.startsWith(dirPath, declDirPath + "/"); });
89557         }
89558         function handleDirectoryCouldBeSymlink(directory) {
89559             var _a;
89560             if (!host.getResolvedProjectReferences() || ts.containsIgnoredPath(directory))
89561                 return;
89562             if (!originalRealpath || !ts.stringContains(directory, ts.nodeModulesPathPart))
89563                 return;
89564             var symlinkCache = host.getSymlinkCache();
89565             var directoryPath = ts.ensureTrailingDirectorySeparator(host.toPath(directory));
89566             if ((_a = symlinkCache.getSymlinkedDirectories()) === null || _a === void 0 ? void 0 : _a.has(directoryPath))
89567                 return;
89568             var real = ts.normalizePath(originalRealpath.call(host.compilerHost, directory));
89569             var realPath;
89570             if (real === directory ||
89571                 (realPath = ts.ensureTrailingDirectorySeparator(host.toPath(real))) === directoryPath) {
89572                 symlinkCache.setSymlinkedDirectory(directoryPath, false);
89573                 return;
89574             }
89575             symlinkCache.setSymlinkedDirectory(directory, {
89576                 real: ts.ensureTrailingDirectorySeparator(real),
89577                 realPath: realPath
89578             });
89579         }
89580         function fileOrDirectoryExistsUsingSource(fileOrDirectory, isFile) {
89581             var _a;
89582             var fileOrDirectoryExistsUsingSource = isFile ?
89583                 function (file) { return fileExistsIfProjectReferenceDts(file); } :
89584                 function (dir) { return directoryExistsIfProjectReferenceDeclDir(dir); };
89585             var result = fileOrDirectoryExistsUsingSource(fileOrDirectory);
89586             if (result !== undefined)
89587                 return result;
89588             var symlinkCache = host.getSymlinkCache();
89589             var symlinkedDirectories = symlinkCache.getSymlinkedDirectories();
89590             if (!symlinkedDirectories)
89591                 return false;
89592             var fileOrDirectoryPath = host.toPath(fileOrDirectory);
89593             if (!ts.stringContains(fileOrDirectoryPath, ts.nodeModulesPathPart))
89594                 return false;
89595             if (isFile && ((_a = symlinkCache.getSymlinkedFiles()) === null || _a === void 0 ? void 0 : _a.has(fileOrDirectoryPath)))
89596                 return true;
89597             return ts.firstDefinedIterator(symlinkedDirectories.entries(), function (_a) {
89598                 var directoryPath = _a[0], symlinkedDirectory = _a[1];
89599                 if (!symlinkedDirectory || !ts.startsWith(fileOrDirectoryPath, directoryPath))
89600                     return undefined;
89601                 var result = fileOrDirectoryExistsUsingSource(fileOrDirectoryPath.replace(directoryPath, symlinkedDirectory.realPath));
89602                 if (isFile && result) {
89603                     var absolutePath = ts.getNormalizedAbsolutePath(fileOrDirectory, host.compilerHost.getCurrentDirectory());
89604                     symlinkCache.setSymlinkedFile(fileOrDirectoryPath, "" + symlinkedDirectory.real + absolutePath.replace(new RegExp(directoryPath, "i"), ""));
89605                 }
89606                 return result;
89607             }) || false;
89608         }
89609     }
89610     ts.emitSkippedWithNoDiagnostics = { diagnostics: ts.emptyArray, sourceMaps: undefined, emittedFiles: undefined, emitSkipped: true };
89611     function handleNoEmitOptions(program, sourceFile, writeFile, cancellationToken) {
89612         var options = program.getCompilerOptions();
89613         if (options.noEmit) {
89614             program.getSemanticDiagnostics(sourceFile, cancellationToken);
89615             return sourceFile || ts.outFile(options) ?
89616                 ts.emitSkippedWithNoDiagnostics :
89617                 program.emitBuildInfo(writeFile, cancellationToken);
89618         }
89619         if (!options.noEmitOnError)
89620             return undefined;
89621         var diagnostics = __spreadArray(__spreadArray(__spreadArray(__spreadArray([], program.getOptionsDiagnostics(cancellationToken)), program.getSyntacticDiagnostics(sourceFile, cancellationToken)), program.getGlobalDiagnostics(cancellationToken)), program.getSemanticDiagnostics(sourceFile, cancellationToken));
89622         if (diagnostics.length === 0 && ts.getEmitDeclarations(program.getCompilerOptions())) {
89623             diagnostics = program.getDeclarationDiagnostics(undefined, cancellationToken);
89624         }
89625         if (!diagnostics.length)
89626             return undefined;
89627         var emittedFiles;
89628         if (!sourceFile && !ts.outFile(options)) {
89629             var emitResult = program.emitBuildInfo(writeFile, cancellationToken);
89630             if (emitResult.diagnostics)
89631                 diagnostics = __spreadArray(__spreadArray([], diagnostics), emitResult.diagnostics);
89632             emittedFiles = emitResult.emittedFiles;
89633         }
89634         return { diagnostics: diagnostics, sourceMaps: undefined, emittedFiles: emittedFiles, emitSkipped: true };
89635     }
89636     ts.handleNoEmitOptions = handleNoEmitOptions;
89637     function filterSemanticDiagnotics(diagnostic, option) {
89638         return ts.filter(diagnostic, function (d) { return !d.skippedOn || !option[d.skippedOn]; });
89639     }
89640     ts.filterSemanticDiagnotics = filterSemanticDiagnotics;
89641     function parseConfigHostFromCompilerHostLike(host, directoryStructureHost) {
89642         if (directoryStructureHost === void 0) { directoryStructureHost = host; }
89643         return {
89644             fileExists: function (f) { return directoryStructureHost.fileExists(f); },
89645             readDirectory: function (root, extensions, excludes, includes, depth) {
89646                 ts.Debug.assertIsDefined(directoryStructureHost.readDirectory, "'CompilerHost.readDirectory' must be implemented to correctly process 'projectReferences'");
89647                 return directoryStructureHost.readDirectory(root, extensions, excludes, includes, depth);
89648             },
89649             readFile: function (f) { return directoryStructureHost.readFile(f); },
89650             useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(),
89651             getCurrentDirectory: function () { return host.getCurrentDirectory(); },
89652             onUnRecoverableConfigFileDiagnostic: host.onUnRecoverableConfigFileDiagnostic || ts.returnUndefined,
89653             trace: host.trace ? function (s) { return host.trace(s); } : undefined
89654         };
89655     }
89656     ts.parseConfigHostFromCompilerHostLike = parseConfigHostFromCompilerHostLike;
89657     function createPrependNodes(projectReferences, getCommandLine, readFile) {
89658         if (!projectReferences)
89659             return ts.emptyArray;
89660         var nodes;
89661         for (var i = 0; i < projectReferences.length; i++) {
89662             var ref = projectReferences[i];
89663             var resolvedRefOpts = getCommandLine(ref, i);
89664             if (ref.prepend && resolvedRefOpts && resolvedRefOpts.options) {
89665                 var out = ts.outFile(resolvedRefOpts.options);
89666                 if (!out)
89667                     continue;
89668                 var _a = ts.getOutputPathsForBundle(resolvedRefOpts.options, true), jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
89669                 var node = ts.createInputFiles(readFile, jsFilePath, sourceMapFilePath, declarationFilePath, declarationMapPath, buildInfoPath);
89670                 (nodes || (nodes = [])).push(node);
89671             }
89672         }
89673         return nodes || ts.emptyArray;
89674     }
89675     ts.createPrependNodes = createPrependNodes;
89676     function resolveProjectReferencePath(hostOrRef, ref) {
89677         var passedInRef = ref ? ref : hostOrRef;
89678         return ts.resolveConfigFileProjectName(passedInRef.path);
89679     }
89680     ts.resolveProjectReferencePath = resolveProjectReferencePath;
89681     function getResolutionDiagnostic(options, _a) {
89682         var extension = _a.extension;
89683         switch (extension) {
89684             case ".ts":
89685             case ".d.ts":
89686                 return undefined;
89687             case ".tsx":
89688                 return needJsx();
89689             case ".jsx":
89690                 return needJsx() || needAllowJs();
89691             case ".js":
89692                 return needAllowJs();
89693             case ".json":
89694                 return needResolveJsonModule();
89695         }
89696         function needJsx() {
89697             return options.jsx ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_jsx_is_not_set;
89698         }
89699         function needAllowJs() {
89700             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;
89701         }
89702         function needResolveJsonModule() {
89703             return options.resolveJsonModule ? undefined : ts.Diagnostics.Module_0_was_resolved_to_1_but_resolveJsonModule_is_not_used;
89704         }
89705     }
89706     ts.getResolutionDiagnostic = getResolutionDiagnostic;
89707     function getModuleNames(_a) {
89708         var imports = _a.imports, moduleAugmentations = _a.moduleAugmentations;
89709         var res = imports.map(function (i) { return i.text; });
89710         for (var _i = 0, moduleAugmentations_1 = moduleAugmentations; _i < moduleAugmentations_1.length; _i++) {
89711             var aug = moduleAugmentations_1[_i];
89712             if (aug.kind === 10) {
89713                 res.push(aug.text);
89714             }
89715         }
89716         return res;
89717     }
89718     function getModuleNameStringLiteralAt(_a, index) {
89719         var imports = _a.imports, moduleAugmentations = _a.moduleAugmentations;
89720         if (index < imports.length)
89721             return imports[index];
89722         var augIndex = imports.length;
89723         for (var _i = 0, moduleAugmentations_2 = moduleAugmentations; _i < moduleAugmentations_2.length; _i++) {
89724             var aug = moduleAugmentations_2[_i];
89725             if (aug.kind === 10) {
89726                 if (index === augIndex)
89727                     return aug;
89728                 augIndex++;
89729             }
89730         }
89731         ts.Debug.fail("should never ask for module name at index higher than possible module name");
89732     }
89733     ts.getModuleNameStringLiteralAt = getModuleNameStringLiteralAt;
89734 })(ts || (ts = {}));
89735 var ts;
89736 (function (ts) {
89737     function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) {
89738         var outputFiles = [];
89739         var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics, exportedModulesFromDeclarationEmit = _a.exportedModulesFromDeclarationEmit;
89740         return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics, exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit };
89741         function writeFile(fileName, text, writeByteOrderMark) {
89742             outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text });
89743         }
89744     }
89745     ts.getFileEmitOutput = getFileEmitOutput;
89746     var BuilderState;
89747     (function (BuilderState) {
89748         function getReferencedFileFromImportedModuleSymbol(symbol) {
89749             if (symbol.declarations && symbol.declarations[0]) {
89750                 var declarationSourceFile = ts.getSourceFileOfNode(symbol.declarations[0]);
89751                 return declarationSourceFile && declarationSourceFile.resolvedPath;
89752             }
89753         }
89754         function getReferencedFileFromImportLiteral(checker, importName) {
89755             var symbol = checker.getSymbolAtLocation(importName);
89756             return symbol && getReferencedFileFromImportedModuleSymbol(symbol);
89757         }
89758         function getReferencedFileFromFileName(program, fileName, sourceFileDirectory, getCanonicalFileName) {
89759             return ts.toPath(program.getProjectReferenceRedirect(fileName) || fileName, sourceFileDirectory, getCanonicalFileName);
89760         }
89761         function getReferencedFiles(program, sourceFile, getCanonicalFileName) {
89762             var referencedFiles;
89763             if (sourceFile.imports && sourceFile.imports.length > 0) {
89764                 var checker = program.getTypeChecker();
89765                 for (var _i = 0, _a = sourceFile.imports; _i < _a.length; _i++) {
89766                     var importName = _a[_i];
89767                     var declarationSourceFilePath = getReferencedFileFromImportLiteral(checker, importName);
89768                     if (declarationSourceFilePath) {
89769                         addReferencedFile(declarationSourceFilePath);
89770                     }
89771                 }
89772             }
89773             var sourceFileDirectory = ts.getDirectoryPath(sourceFile.resolvedPath);
89774             if (sourceFile.referencedFiles && sourceFile.referencedFiles.length > 0) {
89775                 for (var _b = 0, _c = sourceFile.referencedFiles; _b < _c.length; _b++) {
89776                     var referencedFile = _c[_b];
89777                     var referencedPath = getReferencedFileFromFileName(program, referencedFile.fileName, sourceFileDirectory, getCanonicalFileName);
89778                     addReferencedFile(referencedPath);
89779                 }
89780             }
89781             if (sourceFile.resolvedTypeReferenceDirectiveNames) {
89782                 sourceFile.resolvedTypeReferenceDirectiveNames.forEach(function (resolvedTypeReferenceDirective) {
89783                     if (!resolvedTypeReferenceDirective) {
89784                         return;
89785                     }
89786                     var fileName = resolvedTypeReferenceDirective.resolvedFileName;
89787                     var typeFilePath = getReferencedFileFromFileName(program, fileName, sourceFileDirectory, getCanonicalFileName);
89788                     addReferencedFile(typeFilePath);
89789                 });
89790             }
89791             if (sourceFile.moduleAugmentations.length) {
89792                 var checker = program.getTypeChecker();
89793                 for (var _d = 0, _e = sourceFile.moduleAugmentations; _d < _e.length; _d++) {
89794                     var moduleName = _e[_d];
89795                     if (!ts.isStringLiteral(moduleName)) {
89796                         continue;
89797                     }
89798                     var symbol = checker.getSymbolAtLocation(moduleName);
89799                     if (!symbol) {
89800                         continue;
89801                     }
89802                     addReferenceFromAmbientModule(symbol);
89803                 }
89804             }
89805             for (var _f = 0, _g = program.getTypeChecker().getAmbientModules(); _f < _g.length; _f++) {
89806                 var ambientModule = _g[_f];
89807                 if (ambientModule.declarations.length > 1) {
89808                     addReferenceFromAmbientModule(ambientModule);
89809                 }
89810             }
89811             return referencedFiles;
89812             function addReferenceFromAmbientModule(symbol) {
89813                 for (var _i = 0, _a = symbol.declarations; _i < _a.length; _i++) {
89814                     var declaration = _a[_i];
89815                     var declarationSourceFile = ts.getSourceFileOfNode(declaration);
89816                     if (declarationSourceFile &&
89817                         declarationSourceFile !== sourceFile) {
89818                         addReferencedFile(declarationSourceFile.resolvedPath);
89819                     }
89820                 }
89821             }
89822             function addReferencedFile(referencedPath) {
89823                 (referencedFiles || (referencedFiles = new ts.Set())).add(referencedPath);
89824             }
89825         }
89826         function canReuseOldState(newReferencedMap, oldState) {
89827             return oldState && !oldState.referencedMap === !newReferencedMap;
89828         }
89829         BuilderState.canReuseOldState = canReuseOldState;
89830         function create(newProgram, getCanonicalFileName, oldState) {
89831             var fileInfos = new ts.Map();
89832             var referencedMap = newProgram.getCompilerOptions().module !== ts.ModuleKind.None ? new ts.Map() : undefined;
89833             var exportedModulesMap = referencedMap ? new ts.Map() : undefined;
89834             var hasCalledUpdateShapeSignature = new ts.Set();
89835             var useOldState = canReuseOldState(referencedMap, oldState);
89836             newProgram.getTypeChecker();
89837             for (var _i = 0, _a = newProgram.getSourceFiles(); _i < _a.length; _i++) {
89838                 var sourceFile = _a[_i];
89839                 var version_2 = ts.Debug.checkDefined(sourceFile.version, "Program intended to be used with Builder should have source files with versions set");
89840                 var oldInfo = useOldState ? oldState.fileInfos.get(sourceFile.resolvedPath) : undefined;
89841                 if (referencedMap) {
89842                     var newReferences = getReferencedFiles(newProgram, sourceFile, getCanonicalFileName);
89843                     if (newReferences) {
89844                         referencedMap.set(sourceFile.resolvedPath, newReferences);
89845                     }
89846                     if (useOldState) {
89847                         var exportedModules = oldState.exportedModulesMap.get(sourceFile.resolvedPath);
89848                         if (exportedModules) {
89849                             exportedModulesMap.set(sourceFile.resolvedPath, exportedModules);
89850                         }
89851                     }
89852                 }
89853                 fileInfos.set(sourceFile.resolvedPath, { version: version_2, signature: oldInfo && oldInfo.signature, affectsGlobalScope: isFileAffectingGlobalScope(sourceFile) });
89854             }
89855             return {
89856                 fileInfos: fileInfos,
89857                 referencedMap: referencedMap,
89858                 exportedModulesMap: exportedModulesMap,
89859                 hasCalledUpdateShapeSignature: hasCalledUpdateShapeSignature
89860             };
89861         }
89862         BuilderState.create = create;
89863         function releaseCache(state) {
89864             state.allFilesExcludingDefaultLibraryFile = undefined;
89865             state.allFileNames = undefined;
89866         }
89867         BuilderState.releaseCache = releaseCache;
89868         function clone(state) {
89869             return {
89870                 fileInfos: new ts.Map(state.fileInfos),
89871                 referencedMap: state.referencedMap && new ts.Map(state.referencedMap),
89872                 exportedModulesMap: state.exportedModulesMap && new ts.Map(state.exportedModulesMap),
89873                 hasCalledUpdateShapeSignature: new ts.Set(state.hasCalledUpdateShapeSignature),
89874             };
89875         }
89876         BuilderState.clone = clone;
89877         function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, cacheToUpdateSignature, exportedModulesMapCache) {
89878             var signatureCache = cacheToUpdateSignature || new ts.Map();
89879             var sourceFile = programOfThisState.getSourceFileByPath(path);
89880             if (!sourceFile) {
89881                 return ts.emptyArray;
89882             }
89883             if (!updateShapeSignature(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache)) {
89884                 return [sourceFile];
89885             }
89886             var result = (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, signatureCache, cancellationToken, computeHash, exportedModulesMapCache);
89887             if (!cacheToUpdateSignature) {
89888                 updateSignaturesFromCache(state, signatureCache);
89889             }
89890             return result;
89891         }
89892         BuilderState.getFilesAffectedBy = getFilesAffectedBy;
89893         function updateSignaturesFromCache(state, signatureCache) {
89894             signatureCache.forEach(function (signature, path) { return updateSignatureOfFile(state, signature, path); });
89895         }
89896         BuilderState.updateSignaturesFromCache = updateSignaturesFromCache;
89897         function updateSignatureOfFile(state, signature, path) {
89898             state.fileInfos.get(path).signature = signature;
89899             state.hasCalledUpdateShapeSignature.add(path);
89900         }
89901         BuilderState.updateSignatureOfFile = updateSignatureOfFile;
89902         function updateShapeSignature(state, programOfThisState, sourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
89903             ts.Debug.assert(!!sourceFile);
89904             ts.Debug.assert(!exportedModulesMapCache || !!state.exportedModulesMap, "Compute visible to outside map only if visibleToOutsideReferencedMap present in the state");
89905             if (state.hasCalledUpdateShapeSignature.has(sourceFile.resolvedPath) || cacheToUpdateSignature.has(sourceFile.resolvedPath)) {
89906                 return false;
89907             }
89908             var info = state.fileInfos.get(sourceFile.resolvedPath);
89909             if (!info)
89910                 return ts.Debug.fail();
89911             var prevSignature = info.signature;
89912             var latestSignature;
89913             if (sourceFile.isDeclarationFile) {
89914                 latestSignature = sourceFile.version;
89915                 if (exportedModulesMapCache && latestSignature !== prevSignature) {
89916                     var references = state.referencedMap ? state.referencedMap.get(sourceFile.resolvedPath) : undefined;
89917                     exportedModulesMapCache.set(sourceFile.resolvedPath, references || false);
89918                 }
89919             }
89920             else {
89921                 var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile, true, cancellationToken, undefined, true);
89922                 var firstDts_1 = emitOutput_1.outputFiles &&
89923                     programOfThisState.getCompilerOptions().declarationMap ?
89924                     emitOutput_1.outputFiles.length > 1 ? emitOutput_1.outputFiles[1] : undefined :
89925                     emitOutput_1.outputFiles.length > 0 ? emitOutput_1.outputFiles[0] : undefined;
89926                 if (firstDts_1) {
89927                     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; })); });
89928                     latestSignature = (computeHash || ts.generateDjb2Hash)(firstDts_1.text);
89929                     if (exportedModulesMapCache && latestSignature !== prevSignature) {
89930                         updateExportedModules(sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit, exportedModulesMapCache);
89931                     }
89932                 }
89933                 else {
89934                     latestSignature = prevSignature;
89935                 }
89936             }
89937             cacheToUpdateSignature.set(sourceFile.resolvedPath, latestSignature);
89938             return !prevSignature || latestSignature !== prevSignature;
89939         }
89940         BuilderState.updateShapeSignature = updateShapeSignature;
89941         function updateExportedModules(sourceFile, exportedModulesFromDeclarationEmit, exportedModulesMapCache) {
89942             if (!exportedModulesFromDeclarationEmit) {
89943                 exportedModulesMapCache.set(sourceFile.resolvedPath, false);
89944                 return;
89945             }
89946             var exportedModules;
89947             exportedModulesFromDeclarationEmit.forEach(function (symbol) { return addExportedModule(getReferencedFileFromImportedModuleSymbol(symbol)); });
89948             exportedModulesMapCache.set(sourceFile.resolvedPath, exportedModules || false);
89949             function addExportedModule(exportedModulePath) {
89950                 if (exportedModulePath) {
89951                     if (!exportedModules) {
89952                         exportedModules = new ts.Set();
89953                     }
89954                     exportedModules.add(exportedModulePath);
89955                 }
89956             }
89957         }
89958         function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
89959             if (exportedModulesMapCache) {
89960                 ts.Debug.assert(!!state.exportedModulesMap);
89961                 exportedModulesMapCache.forEach(function (exportedModules, path) {
89962                     if (exportedModules) {
89963                         state.exportedModulesMap.set(path, exportedModules);
89964                     }
89965                     else {
89966                         state.exportedModulesMap.delete(path);
89967                     }
89968                 });
89969             }
89970         }
89971         BuilderState.updateExportedFilesMapFromCache = updateExportedFilesMapFromCache;
89972         function getAllDependencies(state, programOfThisState, sourceFile) {
89973             var compilerOptions = programOfThisState.getCompilerOptions();
89974             if (ts.outFile(compilerOptions)) {
89975                 return getAllFileNames(state, programOfThisState);
89976             }
89977             if (!state.referencedMap || isFileAffectingGlobalScope(sourceFile)) {
89978                 return getAllFileNames(state, programOfThisState);
89979             }
89980             var seenMap = new ts.Set();
89981             var queue = [sourceFile.resolvedPath];
89982             while (queue.length) {
89983                 var path = queue.pop();
89984                 if (!seenMap.has(path)) {
89985                     seenMap.add(path);
89986                     var references = state.referencedMap.get(path);
89987                     if (references) {
89988                         var iterator = references.keys();
89989                         for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) {
89990                             queue.push(iterResult.value);
89991                         }
89992                     }
89993                 }
89994             }
89995             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; }));
89996         }
89997         BuilderState.getAllDependencies = getAllDependencies;
89998         function getAllFileNames(state, programOfThisState) {
89999             if (!state.allFileNames) {
90000                 var sourceFiles = programOfThisState.getSourceFiles();
90001                 state.allFileNames = sourceFiles === ts.emptyArray ? ts.emptyArray : sourceFiles.map(function (file) { return file.fileName; });
90002             }
90003             return state.allFileNames;
90004         }
90005         function getReferencedByPaths(state, referencedFilePath) {
90006             return ts.arrayFrom(ts.mapDefinedIterator(state.referencedMap.entries(), function (_a) {
90007                 var filePath = _a[0], referencesInFile = _a[1];
90008                 return referencesInFile.has(referencedFilePath) ? filePath : undefined;
90009             }));
90010         }
90011         BuilderState.getReferencedByPaths = getReferencedByPaths;
90012         function containsOnlyAmbientModules(sourceFile) {
90013             for (var _i = 0, _a = sourceFile.statements; _i < _a.length; _i++) {
90014                 var statement = _a[_i];
90015                 if (!ts.isModuleWithStringLiteralName(statement)) {
90016                     return false;
90017                 }
90018             }
90019             return true;
90020         }
90021         function containsGlobalScopeAugmentation(sourceFile) {
90022             return ts.some(sourceFile.moduleAugmentations, function (augmentation) { return ts.isGlobalScopeAugmentation(augmentation.parent); });
90023         }
90024         function isFileAffectingGlobalScope(sourceFile) {
90025             return containsGlobalScopeAugmentation(sourceFile) ||
90026                 !ts.isExternalModule(sourceFile) && !containsOnlyAmbientModules(sourceFile);
90027         }
90028         function getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, firstSourceFile) {
90029             if (state.allFilesExcludingDefaultLibraryFile) {
90030                 return state.allFilesExcludingDefaultLibraryFile;
90031             }
90032             var result;
90033             if (firstSourceFile)
90034                 addSourceFile(firstSourceFile);
90035             for (var _i = 0, _a = programOfThisState.getSourceFiles(); _i < _a.length; _i++) {
90036                 var sourceFile = _a[_i];
90037                 if (sourceFile !== firstSourceFile) {
90038                     addSourceFile(sourceFile);
90039                 }
90040             }
90041             state.allFilesExcludingDefaultLibraryFile = result || ts.emptyArray;
90042             return state.allFilesExcludingDefaultLibraryFile;
90043             function addSourceFile(sourceFile) {
90044                 if (!programOfThisState.isSourceFileDefaultLibrary(sourceFile)) {
90045                     (result || (result = [])).push(sourceFile);
90046                 }
90047             }
90048         }
90049         BuilderState.getAllFilesExcludingDefaultLibraryFile = getAllFilesExcludingDefaultLibraryFile;
90050         function getFilesAffectedByUpdatedShapeWhenNonModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape) {
90051             var compilerOptions = programOfThisState.getCompilerOptions();
90052             if (compilerOptions && ts.outFile(compilerOptions)) {
90053                 return [sourceFileWithUpdatedShape];
90054             }
90055             return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
90056         }
90057         function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache) {
90058             if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
90059                 return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
90060             }
90061             var compilerOptions = programOfThisState.getCompilerOptions();
90062             if (compilerOptions && (compilerOptions.isolatedModules || ts.outFile(compilerOptions))) {
90063                 return [sourceFileWithUpdatedShape];
90064             }
90065             var seenFileNamesMap = new ts.Map();
90066             seenFileNamesMap.set(sourceFileWithUpdatedShape.resolvedPath, sourceFileWithUpdatedShape);
90067             var queue = getReferencedByPaths(state, sourceFileWithUpdatedShape.resolvedPath);
90068             while (queue.length > 0) {
90069                 var currentPath = queue.pop();
90070                 if (!seenFileNamesMap.has(currentPath)) {
90071                     var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
90072                     seenFileNamesMap.set(currentPath, currentSourceFile);
90073                     if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cacheToUpdateSignature, cancellationToken, computeHash, exportedModulesMapCache)) {
90074                         queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
90075                     }
90076                 }
90077             }
90078             return ts.arrayFrom(ts.mapDefinedIterator(seenFileNamesMap.values(), function (value) { return value; }));
90079         }
90080     })(BuilderState = ts.BuilderState || (ts.BuilderState = {}));
90081 })(ts || (ts = {}));
90082 var ts;
90083 (function (ts) {
90084     function hasSameKeys(map1, map2) {
90085         return map1 === map2 || map1 !== undefined && map2 !== undefined && map1.size === map2.size && !ts.forEachKey(map1, function (key) { return !map2.has(key); });
90086     }
90087     function createBuilderProgramState(newProgram, getCanonicalFileName, oldState) {
90088         var state = ts.BuilderState.create(newProgram, getCanonicalFileName, oldState);
90089         state.program = newProgram;
90090         var compilerOptions = newProgram.getCompilerOptions();
90091         state.compilerOptions = compilerOptions;
90092         if (!ts.outFile(compilerOptions)) {
90093             state.semanticDiagnosticsPerFile = new ts.Map();
90094         }
90095         state.changedFilesSet = new ts.Set();
90096         var useOldState = ts.BuilderState.canReuseOldState(state.referencedMap, oldState);
90097         var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
90098         var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
90099             !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
90100         if (useOldState) {
90101             if (!oldState.currentChangedFilePath) {
90102                 var affectedSignatures = oldState.currentAffectedFilesSignatures;
90103                 ts.Debug.assert(!oldState.affectedFiles && (!affectedSignatures || !affectedSignatures.size), "Cannot reuse if only few affected files of currentChangedFile were iterated");
90104             }
90105             var changedFilesSet = oldState.changedFilesSet;
90106             if (canCopySemanticDiagnostics) {
90107                 ts.Debug.assert(!changedFilesSet || !ts.forEachKey(changedFilesSet, function (path) { return oldState.semanticDiagnosticsPerFile.has(path); }), "Semantic diagnostics shouldnt be available for changed files");
90108             }
90109             changedFilesSet === null || changedFilesSet === void 0 ? void 0 : changedFilesSet.forEach(function (value) { return state.changedFilesSet.add(value); });
90110             if (!ts.outFile(compilerOptions) && oldState.affectedFilesPendingEmit) {
90111                 state.affectedFilesPendingEmit = oldState.affectedFilesPendingEmit.slice();
90112                 state.affectedFilesPendingEmitKind = oldState.affectedFilesPendingEmitKind && new ts.Map(oldState.affectedFilesPendingEmitKind);
90113                 state.affectedFilesPendingEmitIndex = oldState.affectedFilesPendingEmitIndex;
90114                 state.seenAffectedFiles = new ts.Set();
90115             }
90116         }
90117         var referencedMap = state.referencedMap;
90118         var oldReferencedMap = useOldState ? oldState.referencedMap : undefined;
90119         var copyDeclarationFileDiagnostics = canCopySemanticDiagnostics && !compilerOptions.skipLibCheck === !oldCompilerOptions.skipLibCheck;
90120         var copyLibFileDiagnostics = copyDeclarationFileDiagnostics && !compilerOptions.skipDefaultLibCheck === !oldCompilerOptions.skipDefaultLibCheck;
90121         state.fileInfos.forEach(function (info, sourceFilePath) {
90122             var oldInfo;
90123             var newReferences;
90124             if (!useOldState ||
90125                 !(oldInfo = oldState.fileInfos.get(sourceFilePath)) ||
90126                 oldInfo.version !== info.version ||
90127                 !hasSameKeys(newReferences = referencedMap && referencedMap.get(sourceFilePath), oldReferencedMap && oldReferencedMap.get(sourceFilePath)) ||
90128                 newReferences && ts.forEachKey(newReferences, function (path) { return !state.fileInfos.has(path) && oldState.fileInfos.has(path); })) {
90129                 state.changedFilesSet.add(sourceFilePath);
90130             }
90131             else if (canCopySemanticDiagnostics) {
90132                 var sourceFile = newProgram.getSourceFileByPath(sourceFilePath);
90133                 if (sourceFile.isDeclarationFile && !copyDeclarationFileDiagnostics) {
90134                     return;
90135                 }
90136                 if (sourceFile.hasNoDefaultLib && !copyLibFileDiagnostics) {
90137                     return;
90138                 }
90139                 var diagnostics = oldState.semanticDiagnosticsPerFile.get(sourceFilePath);
90140                 if (diagnostics) {
90141                     state.semanticDiagnosticsPerFile.set(sourceFilePath, oldState.hasReusableDiagnostic ? convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) : diagnostics);
90142                     if (!state.semanticDiagnosticsFromOldState) {
90143                         state.semanticDiagnosticsFromOldState = new ts.Set();
90144                     }
90145                     state.semanticDiagnosticsFromOldState.add(sourceFilePath);
90146                 }
90147             }
90148         });
90149         if (useOldState && ts.forEachEntry(oldState.fileInfos, function (info, sourceFilePath) { return info.affectsGlobalScope && !state.fileInfos.has(sourceFilePath); })) {
90150             ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, newProgram, undefined)
90151                 .forEach(function (file) { return state.changedFilesSet.add(file.resolvedPath); });
90152         }
90153         else if (oldCompilerOptions && !ts.outFile(compilerOptions) && ts.compilerOptionsAffectEmit(compilerOptions, oldCompilerOptions)) {
90154             newProgram.getSourceFiles().forEach(function (f) { return addToAffectedFilesPendingEmit(state, f.resolvedPath, 1); });
90155             ts.Debug.assert(!state.seenAffectedFiles || !state.seenAffectedFiles.size);
90156             state.seenAffectedFiles = state.seenAffectedFiles || new ts.Set();
90157         }
90158         state.buildInfoEmitPending = !!state.changedFilesSet.size;
90159         return state;
90160     }
90161     function convertToDiagnostics(diagnostics, newProgram, getCanonicalFileName) {
90162         if (!diagnostics.length)
90163             return ts.emptyArray;
90164         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(newProgram.getCompilerOptions()), newProgram.getCurrentDirectory()));
90165         return diagnostics.map(function (diagnostic) {
90166             var result = convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath);
90167             result.reportsUnnecessary = diagnostic.reportsUnnecessary;
90168             result.reportsDeprecated = diagnostic.reportDeprecated;
90169             result.source = diagnostic.source;
90170             result.skippedOn = diagnostic.skippedOn;
90171             var relatedInformation = diagnostic.relatedInformation;
90172             result.relatedInformation = relatedInformation ?
90173                 relatedInformation.length ?
90174                     relatedInformation.map(function (r) { return convertToDiagnosticRelatedInformation(r, newProgram, toPath); }) :
90175                     [] :
90176                 undefined;
90177             return result;
90178         });
90179         function toPath(path) {
90180             return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
90181         }
90182     }
90183     function convertToDiagnosticRelatedInformation(diagnostic, newProgram, toPath) {
90184         var file = diagnostic.file;
90185         return __assign(__assign({}, diagnostic), { file: file ? newProgram.getSourceFileByPath(toPath(file)) : undefined });
90186     }
90187     function releaseCache(state) {
90188         ts.BuilderState.releaseCache(state);
90189         state.program = undefined;
90190     }
90191     function cloneBuilderProgramState(state) {
90192         var newState = ts.BuilderState.clone(state);
90193         newState.semanticDiagnosticsPerFile = state.semanticDiagnosticsPerFile && new ts.Map(state.semanticDiagnosticsPerFile);
90194         newState.changedFilesSet = new ts.Set(state.changedFilesSet);
90195         newState.affectedFiles = state.affectedFiles;
90196         newState.affectedFilesIndex = state.affectedFilesIndex;
90197         newState.currentChangedFilePath = state.currentChangedFilePath;
90198         newState.currentAffectedFilesSignatures = state.currentAffectedFilesSignatures && new ts.Map(state.currentAffectedFilesSignatures);
90199         newState.currentAffectedFilesExportedModulesMap = state.currentAffectedFilesExportedModulesMap && new ts.Map(state.currentAffectedFilesExportedModulesMap);
90200         newState.seenAffectedFiles = state.seenAffectedFiles && new ts.Set(state.seenAffectedFiles);
90201         newState.cleanedDiagnosticsOfLibFiles = state.cleanedDiagnosticsOfLibFiles;
90202         newState.semanticDiagnosticsFromOldState = state.semanticDiagnosticsFromOldState && new ts.Set(state.semanticDiagnosticsFromOldState);
90203         newState.program = state.program;
90204         newState.compilerOptions = state.compilerOptions;
90205         newState.affectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
90206         newState.affectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
90207         newState.affectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
90208         newState.seenEmittedFiles = state.seenEmittedFiles && new ts.Map(state.seenEmittedFiles);
90209         newState.programEmitComplete = state.programEmitComplete;
90210         return newState;
90211     }
90212     function assertSourceFileOkWithoutNextAffectedCall(state, sourceFile) {
90213         ts.Debug.assert(!sourceFile || !state.affectedFiles || state.affectedFiles[state.affectedFilesIndex - 1] !== sourceFile || !state.semanticDiagnosticsPerFile.has(sourceFile.resolvedPath));
90214     }
90215     function getNextAffectedFile(state, cancellationToken, computeHash) {
90216         while (true) {
90217             var affectedFiles = state.affectedFiles;
90218             if (affectedFiles) {
90219                 var seenAffectedFiles = state.seenAffectedFiles;
90220                 var affectedFilesIndex = state.affectedFilesIndex;
90221                 while (affectedFilesIndex < affectedFiles.length) {
90222                     var affectedFile = affectedFiles[affectedFilesIndex];
90223                     if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
90224                         state.affectedFilesIndex = affectedFilesIndex;
90225                         handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash);
90226                         return affectedFile;
90227                     }
90228                     affectedFilesIndex++;
90229                 }
90230                 state.changedFilesSet.delete(state.currentChangedFilePath);
90231                 state.currentChangedFilePath = undefined;
90232                 ts.BuilderState.updateSignaturesFromCache(state, state.currentAffectedFilesSignatures);
90233                 state.currentAffectedFilesSignatures.clear();
90234                 ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
90235                 state.affectedFiles = undefined;
90236             }
90237             var nextKey = state.changedFilesSet.keys().next();
90238             if (nextKey.done) {
90239                 return undefined;
90240             }
90241             var program = ts.Debug.checkDefined(state.program);
90242             var compilerOptions = program.getCompilerOptions();
90243             if (ts.outFile(compilerOptions)) {
90244                 ts.Debug.assert(!state.semanticDiagnosticsPerFile);
90245                 return program;
90246             }
90247             if (!state.currentAffectedFilesSignatures)
90248                 state.currentAffectedFilesSignatures = new ts.Map();
90249             if (state.exportedModulesMap) {
90250                 if (!state.currentAffectedFilesExportedModulesMap)
90251                     state.currentAffectedFilesExportedModulesMap = new ts.Map();
90252             }
90253             state.affectedFiles = ts.BuilderState.getFilesAffectedBy(state, program, nextKey.value, cancellationToken, computeHash, state.currentAffectedFilesSignatures, state.currentAffectedFilesExportedModulesMap);
90254             state.currentChangedFilePath = nextKey.value;
90255             state.affectedFilesIndex = 0;
90256             if (!state.seenAffectedFiles)
90257                 state.seenAffectedFiles = new ts.Set();
90258         }
90259     }
90260     function getNextAffectedFilePendingEmit(state) {
90261         var affectedFilesPendingEmit = state.affectedFilesPendingEmit;
90262         if (affectedFilesPendingEmit) {
90263             var seenEmittedFiles = (state.seenEmittedFiles || (state.seenEmittedFiles = new ts.Map()));
90264             for (var i = state.affectedFilesPendingEmitIndex; i < affectedFilesPendingEmit.length; i++) {
90265                 var affectedFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(affectedFilesPendingEmit[i]);
90266                 if (affectedFile) {
90267                     var seenKind = seenEmittedFiles.get(affectedFile.resolvedPath);
90268                     var emitKind = ts.Debug.checkDefined(ts.Debug.checkDefined(state.affectedFilesPendingEmitKind).get(affectedFile.resolvedPath));
90269                     if (seenKind === undefined || seenKind < emitKind) {
90270                         state.affectedFilesPendingEmitIndex = i;
90271                         return { affectedFile: affectedFile, emitKind: emitKind };
90272                     }
90273                 }
90274             }
90275             state.affectedFilesPendingEmit = undefined;
90276             state.affectedFilesPendingEmitKind = undefined;
90277             state.affectedFilesPendingEmitIndex = undefined;
90278         }
90279         return undefined;
90280     }
90281     function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash) {
90282         removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
90283         if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
90284             if (!state.cleanedDiagnosticsOfLibFiles) {
90285                 state.cleanedDiagnosticsOfLibFiles = true;
90286                 var program_1 = ts.Debug.checkDefined(state.program);
90287                 var options_2 = program_1.getCompilerOptions();
90288                 ts.forEach(program_1.getSourceFiles(), function (f) {
90289                     return program_1.isSourceFileDefaultLibrary(f) &&
90290                         !ts.skipTypeChecking(f, options_2, program_1) &&
90291                         removeSemanticDiagnosticsOf(state, f.resolvedPath);
90292                 });
90293             }
90294             return;
90295         }
90296         if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
90297             forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash); });
90298         }
90299     }
90300     function handleDtsMayChangeOf(state, path, cancellationToken, computeHash) {
90301         removeSemanticDiagnosticsOf(state, path);
90302         if (!state.changedFilesSet.has(path)) {
90303             var program = ts.Debug.checkDefined(state.program);
90304             var sourceFile = program.getSourceFileByPath(path);
90305             if (sourceFile) {
90306                 ts.BuilderState.updateShapeSignature(state, program, sourceFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
90307                 if (ts.getEmitDeclarations(state.compilerOptions)) {
90308                     addToAffectedFilesPendingEmit(state, path, 0);
90309                 }
90310             }
90311         }
90312         return false;
90313     }
90314     function removeSemanticDiagnosticsOf(state, path) {
90315         if (!state.semanticDiagnosticsFromOldState) {
90316             return true;
90317         }
90318         state.semanticDiagnosticsFromOldState.delete(path);
90319         state.semanticDiagnosticsPerFile.delete(path);
90320         return !state.semanticDiagnosticsFromOldState.size;
90321     }
90322     function isChangedSignature(state, path) {
90323         var newSignature = ts.Debug.checkDefined(state.currentAffectedFilesSignatures).get(path);
90324         var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
90325         return newSignature !== oldSignature;
90326     }
90327     function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) {
90328         if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) {
90329             return;
90330         }
90331         if (!isChangedSignature(state, affectedFile.resolvedPath))
90332             return;
90333         if (state.compilerOptions.isolatedModules) {
90334             var seenFileNamesMap = new ts.Map();
90335             seenFileNamesMap.set(affectedFile.resolvedPath, true);
90336             var queue = ts.BuilderState.getReferencedByPaths(state, affectedFile.resolvedPath);
90337             while (queue.length > 0) {
90338                 var currentPath = queue.pop();
90339                 if (!seenFileNamesMap.has(currentPath)) {
90340                     seenFileNamesMap.set(currentPath, true);
90341                     var result = fn(state, currentPath);
90342                     if (result && isChangedSignature(state, currentPath)) {
90343                         var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
90344                         queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
90345                     }
90346                 }
90347             }
90348         }
90349         ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
90350         var seenFileAndExportsOfFile = new ts.Set();
90351         if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) {
90352             return exportedModules &&
90353                 exportedModules.has(affectedFile.resolvedPath) &&
90354                 forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
90355         })) {
90356             return;
90357         }
90358         ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) {
90359             return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) &&
90360                 exportedModules.has(affectedFile.resolvedPath) &&
90361                 forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
90362         });
90363     }
90364     function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) {
90365         return ts.forEachEntry(state.referencedMap, function (referencesInFile, filePath) {
90366             return referencesInFile.has(referencedPath) && forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn);
90367         });
90368     }
90369     function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) {
90370         if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) {
90371             return false;
90372         }
90373         if (fn(state, filePath)) {
90374             return true;
90375         }
90376         ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
90377         if (ts.forEachEntry(state.currentAffectedFilesExportedModulesMap, function (exportedModules, exportedFromPath) {
90378             return exportedModules &&
90379                 exportedModules.has(filePath) &&
90380                 forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
90381         })) {
90382             return true;
90383         }
90384         if (ts.forEachEntry(state.exportedModulesMap, function (exportedModules, exportedFromPath) {
90385             return !state.currentAffectedFilesExportedModulesMap.has(exportedFromPath) &&
90386                 exportedModules.has(filePath) &&
90387                 forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
90388         })) {
90389             return true;
90390         }
90391         return !!ts.forEachEntry(state.referencedMap, function (referencesInFile, referencingFilePath) {
90392             return referencesInFile.has(filePath) &&
90393                 !seenFileAndExportsOfFile.has(referencingFilePath) &&
90394                 fn(state, referencingFilePath);
90395         });
90396     }
90397     function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) {
90398         if (isBuildInfoEmit) {
90399             state.buildInfoEmitPending = false;
90400         }
90401         else if (affected === state.program) {
90402             state.changedFilesSet.clear();
90403             state.programEmitComplete = true;
90404         }
90405         else {
90406             state.seenAffectedFiles.add(affected.resolvedPath);
90407             if (emitKind !== undefined) {
90408                 (state.seenEmittedFiles || (state.seenEmittedFiles = new ts.Map())).set(affected.resolvedPath, emitKind);
90409             }
90410             if (isPendingEmit) {
90411                 state.affectedFilesPendingEmitIndex++;
90412                 state.buildInfoEmitPending = true;
90413             }
90414             else {
90415                 state.affectedFilesIndex++;
90416             }
90417         }
90418     }
90419     function toAffectedFileResult(state, result, affected) {
90420         doneWithAffectedFile(state, affected);
90421         return { result: result, affected: affected };
90422     }
90423     function toAffectedFileEmitResult(state, result, affected, emitKind, isPendingEmit, isBuildInfoEmit) {
90424         doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit);
90425         return { result: result, affected: affected };
90426     }
90427     function getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken) {
90428         return ts.concatenate(getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken), ts.Debug.checkDefined(state.program).getProgramDiagnostics(sourceFile));
90429     }
90430     function getBinderAndCheckerDiagnosticsOfFile(state, sourceFile, cancellationToken) {
90431         var path = sourceFile.resolvedPath;
90432         if (state.semanticDiagnosticsPerFile) {
90433             var cachedDiagnostics = state.semanticDiagnosticsPerFile.get(path);
90434             if (cachedDiagnostics) {
90435                 return ts.filterSemanticDiagnotics(cachedDiagnostics, state.compilerOptions);
90436             }
90437         }
90438         var diagnostics = ts.Debug.checkDefined(state.program).getBindAndCheckDiagnostics(sourceFile, cancellationToken);
90439         if (state.semanticDiagnosticsPerFile) {
90440             state.semanticDiagnosticsPerFile.set(path, diagnostics);
90441         }
90442         return ts.filterSemanticDiagnotics(diagnostics, state.compilerOptions);
90443     }
90444     function getProgramBuildInfo(state, getCanonicalFileName) {
90445         if (ts.outFile(state.compilerOptions))
90446             return undefined;
90447         var currentDirectory = ts.Debug.checkDefined(state.program).getCurrentDirectory();
90448         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(ts.getTsBuildInfoEmitOutputFilePath(state.compilerOptions), currentDirectory));
90449         var fileInfos = {};
90450         state.fileInfos.forEach(function (value, key) {
90451             var signature = state.currentAffectedFilesSignatures && state.currentAffectedFilesSignatures.get(key);
90452             fileInfos[relativeToBuildInfo(key)] = signature === undefined ? value : { version: value.version, signature: signature, affectsGlobalScope: value.affectsGlobalScope };
90453         });
90454         var result = {
90455             fileInfos: fileInfos,
90456             options: convertToReusableCompilerOptions(state.compilerOptions, relativeToBuildInfoEnsuringAbsolutePath)
90457         };
90458         if (state.referencedMap) {
90459             var referencedMap = {};
90460             for (var _i = 0, _a = ts.arrayFrom(state.referencedMap.keys()).sort(ts.compareStringsCaseSensitive); _i < _a.length; _i++) {
90461                 var key = _a[_i];
90462                 referencedMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.referencedMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
90463             }
90464             result.referencedMap = referencedMap;
90465         }
90466         if (state.exportedModulesMap) {
90467             var exportedModulesMap = {};
90468             for (var _b = 0, _c = ts.arrayFrom(state.exportedModulesMap.keys()).sort(ts.compareStringsCaseSensitive); _b < _c.length; _b++) {
90469                 var key = _c[_b];
90470                 var newValue = state.currentAffectedFilesExportedModulesMap && state.currentAffectedFilesExportedModulesMap.get(key);
90471                 if (newValue === undefined)
90472                     exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(state.exportedModulesMap.get(key).keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
90473                 else if (newValue)
90474                     exportedModulesMap[relativeToBuildInfo(key)] = ts.arrayFrom(newValue.keys(), relativeToBuildInfo).sort(ts.compareStringsCaseSensitive);
90475             }
90476             result.exportedModulesMap = exportedModulesMap;
90477         }
90478         if (state.semanticDiagnosticsPerFile) {
90479             var semanticDiagnosticsPerFile = [];
90480             for (var _d = 0, _e = ts.arrayFrom(state.semanticDiagnosticsPerFile.keys()).sort(ts.compareStringsCaseSensitive); _d < _e.length; _d++) {
90481                 var key = _e[_d];
90482                 var value = state.semanticDiagnosticsPerFile.get(key);
90483                 semanticDiagnosticsPerFile.push(value.length ?
90484                     [
90485                         relativeToBuildInfo(key),
90486                         state.hasReusableDiagnostic ?
90487                             value :
90488                             convertToReusableDiagnostics(value, relativeToBuildInfo)
90489                     ] :
90490                     relativeToBuildInfo(key));
90491             }
90492             result.semanticDiagnosticsPerFile = semanticDiagnosticsPerFile;
90493         }
90494         if (state.affectedFilesPendingEmit) {
90495             var affectedFilesPendingEmit = [];
90496             var seenFiles = new ts.Set();
90497             for (var _f = 0, _g = state.affectedFilesPendingEmit.slice(state.affectedFilesPendingEmitIndex).sort(ts.compareStringsCaseSensitive); _f < _g.length; _f++) {
90498                 var path = _g[_f];
90499                 if (ts.tryAddToSet(seenFiles, path)) {
90500                     affectedFilesPendingEmit.push([relativeToBuildInfo(path), state.affectedFilesPendingEmitKind.get(path)]);
90501                 }
90502             }
90503             result.affectedFilesPendingEmit = affectedFilesPendingEmit;
90504         }
90505         return result;
90506         function relativeToBuildInfoEnsuringAbsolutePath(path) {
90507             return relativeToBuildInfo(ts.getNormalizedAbsolutePath(path, currentDirectory));
90508         }
90509         function relativeToBuildInfo(path) {
90510             return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(buildInfoDirectory, path, getCanonicalFileName));
90511         }
90512     }
90513     function convertToReusableCompilerOptions(options, relativeToBuildInfo) {
90514         var result = {};
90515         var optionsNameMap = ts.getOptionsNameMap().optionsNameMap;
90516         for (var name in options) {
90517             if (ts.hasProperty(options, name)) {
90518                 result[name] = convertToReusableCompilerOptionValue(optionsNameMap.get(name.toLowerCase()), options[name], relativeToBuildInfo);
90519             }
90520         }
90521         if (result.configFilePath) {
90522             result.configFilePath = relativeToBuildInfo(result.configFilePath);
90523         }
90524         return result;
90525     }
90526     function convertToReusableCompilerOptionValue(option, value, relativeToBuildInfo) {
90527         if (option) {
90528             if (option.type === "list") {
90529                 var values = value;
90530                 if (option.element.isFilePath && values.length) {
90531                     return values.map(relativeToBuildInfo);
90532                 }
90533             }
90534             else if (option.isFilePath) {
90535                 return relativeToBuildInfo(value);
90536             }
90537         }
90538         return value;
90539     }
90540     function convertToReusableDiagnostics(diagnostics, relativeToBuildInfo) {
90541         ts.Debug.assert(!!diagnostics.length);
90542         return diagnostics.map(function (diagnostic) {
90543             var result = convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo);
90544             result.reportsUnnecessary = diagnostic.reportsUnnecessary;
90545             result.reportDeprecated = diagnostic.reportsDeprecated;
90546             result.source = diagnostic.source;
90547             result.skippedOn = diagnostic.skippedOn;
90548             var relatedInformation = diagnostic.relatedInformation;
90549             result.relatedInformation = relatedInformation ?
90550                 relatedInformation.length ?
90551                     relatedInformation.map(function (r) { return convertToReusableDiagnosticRelatedInformation(r, relativeToBuildInfo); }) :
90552                     [] :
90553                 undefined;
90554             return result;
90555         });
90556     }
90557     function convertToReusableDiagnosticRelatedInformation(diagnostic, relativeToBuildInfo) {
90558         var file = diagnostic.file;
90559         return __assign(__assign({}, diagnostic), { file: file ? relativeToBuildInfo(file.resolvedPath) : undefined });
90560     }
90561     var BuilderProgramKind;
90562     (function (BuilderProgramKind) {
90563         BuilderProgramKind[BuilderProgramKind["SemanticDiagnosticsBuilderProgram"] = 0] = "SemanticDiagnosticsBuilderProgram";
90564         BuilderProgramKind[BuilderProgramKind["EmitAndSemanticDiagnosticsBuilderProgram"] = 1] = "EmitAndSemanticDiagnosticsBuilderProgram";
90565     })(BuilderProgramKind = ts.BuilderProgramKind || (ts.BuilderProgramKind = {}));
90566     function getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
90567         var host;
90568         var newProgram;
90569         var oldProgram;
90570         if (newProgramOrRootNames === undefined) {
90571             ts.Debug.assert(hostOrOptions === undefined);
90572             host = oldProgramOrHost;
90573             oldProgram = configFileParsingDiagnosticsOrOldProgram;
90574             ts.Debug.assert(!!oldProgram);
90575             newProgram = oldProgram.getProgram();
90576         }
90577         else if (ts.isArray(newProgramOrRootNames)) {
90578             oldProgram = configFileParsingDiagnosticsOrOldProgram;
90579             newProgram = ts.createProgram({
90580                 rootNames: newProgramOrRootNames,
90581                 options: hostOrOptions,
90582                 host: oldProgramOrHost,
90583                 oldProgram: oldProgram && oldProgram.getProgramOrUndefined(),
90584                 configFileParsingDiagnostics: configFileParsingDiagnostics,
90585                 projectReferences: projectReferences
90586             });
90587             host = oldProgramOrHost;
90588         }
90589         else {
90590             newProgram = newProgramOrRootNames;
90591             host = hostOrOptions;
90592             oldProgram = oldProgramOrHost;
90593             configFileParsingDiagnostics = configFileParsingDiagnosticsOrOldProgram;
90594         }
90595         return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
90596     }
90597     ts.getBuilderCreationParameters = getBuilderCreationParameters;
90598     function createBuilderProgram(kind, _a) {
90599         var newProgram = _a.newProgram, host = _a.host, oldProgram = _a.oldProgram, configFileParsingDiagnostics = _a.configFileParsingDiagnostics;
90600         var oldState = oldProgram && oldProgram.getState();
90601         if (oldState && newProgram === oldState.program && configFileParsingDiagnostics === newProgram.getConfigFileParsingDiagnostics()) {
90602             newProgram = undefined;
90603             oldState = undefined;
90604             return oldProgram;
90605         }
90606         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
90607         var computeHash = ts.maybeBind(host, host.createHash);
90608         var state = createBuilderProgramState(newProgram, getCanonicalFileName, oldState);
90609         var backupState;
90610         newProgram.getProgramBuildInfo = function () { return getProgramBuildInfo(state, getCanonicalFileName); };
90611         newProgram = undefined;
90612         oldProgram = undefined;
90613         oldState = undefined;
90614         var builderProgram = createRedirectedBuilderProgram(state, configFileParsingDiagnostics);
90615         builderProgram.getState = function () { return state; };
90616         builderProgram.backupState = function () {
90617             ts.Debug.assert(backupState === undefined);
90618             backupState = cloneBuilderProgramState(state);
90619         };
90620         builderProgram.restoreState = function () {
90621             state = ts.Debug.checkDefined(backupState);
90622             backupState = undefined;
90623         };
90624         builderProgram.getAllDependencies = function (sourceFile) { return ts.BuilderState.getAllDependencies(state, ts.Debug.checkDefined(state.program), sourceFile); };
90625         builderProgram.getSemanticDiagnostics = getSemanticDiagnostics;
90626         builderProgram.emit = emit;
90627         builderProgram.releaseProgram = function () {
90628             releaseCache(state);
90629             backupState = undefined;
90630         };
90631         if (kind === BuilderProgramKind.SemanticDiagnosticsBuilderProgram) {
90632             builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
90633         }
90634         else if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
90635             builderProgram.getSemanticDiagnosticsOfNextAffectedFile = getSemanticDiagnosticsOfNextAffectedFile;
90636             builderProgram.emitNextAffectedFile = emitNextAffectedFile;
90637             builderProgram.emitBuildInfo = emitBuildInfo;
90638         }
90639         else {
90640             ts.notImplemented();
90641         }
90642         return builderProgram;
90643         function emitBuildInfo(writeFile, cancellationToken) {
90644             if (state.buildInfoEmitPending) {
90645                 var result = ts.Debug.checkDefined(state.program).emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken);
90646                 state.buildInfoEmitPending = false;
90647                 return result;
90648             }
90649             return ts.emitSkippedWithNoDiagnostics;
90650         }
90651         function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
90652             var affected = getNextAffectedFile(state, cancellationToken, computeHash);
90653             var emitKind = 1;
90654             var isPendingEmitFile = false;
90655             if (!affected) {
90656                 if (!ts.outFile(state.compilerOptions)) {
90657                     var pendingAffectedFile = getNextAffectedFilePendingEmit(state);
90658                     if (!pendingAffectedFile) {
90659                         if (!state.buildInfoEmitPending) {
90660                             return undefined;
90661                         }
90662                         var affected_1 = ts.Debug.checkDefined(state.program);
90663                         return toAffectedFileEmitResult(state, affected_1.emitBuildInfo(writeFile || ts.maybeBind(host, host.writeFile), cancellationToken), affected_1, 1, false, true);
90664                     }
90665                     (affected = pendingAffectedFile.affectedFile, emitKind = pendingAffectedFile.emitKind);
90666                     isPendingEmitFile = true;
90667                 }
90668                 else {
90669                     var program = ts.Debug.checkDefined(state.program);
90670                     if (state.programEmitComplete)
90671                         return undefined;
90672                     affected = program;
90673                 }
90674             }
90675             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);
90676         }
90677         function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
90678             var restorePendingEmitOnHandlingNoEmitSuccess = false;
90679             var savedAffectedFilesPendingEmit;
90680             var savedAffectedFilesPendingEmitKind;
90681             var savedAffectedFilesPendingEmitIndex;
90682             if (kind !== BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram &&
90683                 !targetSourceFile &&
90684                 !ts.outFile(state.compilerOptions) &&
90685                 !state.compilerOptions.noEmit &&
90686                 state.compilerOptions.noEmitOnError) {
90687                 restorePendingEmitOnHandlingNoEmitSuccess = true;
90688                 savedAffectedFilesPendingEmit = state.affectedFilesPendingEmit && state.affectedFilesPendingEmit.slice();
90689                 savedAffectedFilesPendingEmitKind = state.affectedFilesPendingEmitKind && new ts.Map(state.affectedFilesPendingEmitKind);
90690                 savedAffectedFilesPendingEmitIndex = state.affectedFilesPendingEmitIndex;
90691             }
90692             if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
90693                 assertSourceFileOkWithoutNextAffectedCall(state, targetSourceFile);
90694             }
90695             var result = ts.handleNoEmitOptions(builderProgram, targetSourceFile, writeFile, cancellationToken);
90696             if (result)
90697                 return result;
90698             if (restorePendingEmitOnHandlingNoEmitSuccess) {
90699                 state.affectedFilesPendingEmit = savedAffectedFilesPendingEmit;
90700                 state.affectedFilesPendingEmitKind = savedAffectedFilesPendingEmitKind;
90701                 state.affectedFilesPendingEmitIndex = savedAffectedFilesPendingEmitIndex;
90702             }
90703             if (!targetSourceFile && kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram) {
90704                 var sourceMaps = [];
90705                 var emitSkipped = false;
90706                 var diagnostics = void 0;
90707                 var emittedFiles = [];
90708                 var affectedEmitResult = void 0;
90709                 while (affectedEmitResult = emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers)) {
90710                     emitSkipped = emitSkipped || affectedEmitResult.result.emitSkipped;
90711                     diagnostics = ts.addRange(diagnostics, affectedEmitResult.result.diagnostics);
90712                     emittedFiles = ts.addRange(emittedFiles, affectedEmitResult.result.emittedFiles);
90713                     sourceMaps = ts.addRange(sourceMaps, affectedEmitResult.result.sourceMaps);
90714                 }
90715                 return {
90716                     emitSkipped: emitSkipped,
90717                     diagnostics: diagnostics || ts.emptyArray,
90718                     emittedFiles: emittedFiles,
90719                     sourceMaps: sourceMaps
90720                 };
90721             }
90722             return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
90723         }
90724         function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
90725             while (true) {
90726                 var affected = getNextAffectedFile(state, cancellationToken, computeHash);
90727                 if (!affected) {
90728                     return undefined;
90729                 }
90730                 else if (affected === state.program) {
90731                     return toAffectedFileResult(state, state.program.getSemanticDiagnostics(undefined, cancellationToken), affected);
90732                 }
90733                 if (kind === BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram || state.compilerOptions.noEmit || state.compilerOptions.noEmitOnError) {
90734                     addToAffectedFilesPendingEmit(state, affected.resolvedPath, 1);
90735                 }
90736                 if (ignoreSourceFile && ignoreSourceFile(affected)) {
90737                     doneWithAffectedFile(state, affected);
90738                     continue;
90739                 }
90740                 return toAffectedFileResult(state, getSemanticDiagnosticsOfFile(state, affected, cancellationToken), affected);
90741             }
90742         }
90743         function getSemanticDiagnostics(sourceFile, cancellationToken) {
90744             assertSourceFileOkWithoutNextAffectedCall(state, sourceFile);
90745             var compilerOptions = ts.Debug.checkDefined(state.program).getCompilerOptions();
90746             if (ts.outFile(compilerOptions)) {
90747                 ts.Debug.assert(!state.semanticDiagnosticsPerFile);
90748                 return ts.Debug.checkDefined(state.program).getSemanticDiagnostics(sourceFile, cancellationToken);
90749             }
90750             if (sourceFile) {
90751                 return getSemanticDiagnosticsOfFile(state, sourceFile, cancellationToken);
90752             }
90753             while (getSemanticDiagnosticsOfNextAffectedFile(cancellationToken)) {
90754             }
90755             var diagnostics;
90756             for (var _i = 0, _a = ts.Debug.checkDefined(state.program).getSourceFiles(); _i < _a.length; _i++) {
90757                 var sourceFile_1 = _a[_i];
90758                 diagnostics = ts.addRange(diagnostics, getSemanticDiagnosticsOfFile(state, sourceFile_1, cancellationToken));
90759             }
90760             return diagnostics || ts.emptyArray;
90761         }
90762     }
90763     ts.createBuilderProgram = createBuilderProgram;
90764     function addToAffectedFilesPendingEmit(state, affectedFilePendingEmit, kind) {
90765         if (!state.affectedFilesPendingEmit)
90766             state.affectedFilesPendingEmit = [];
90767         if (!state.affectedFilesPendingEmitKind)
90768             state.affectedFilesPendingEmitKind = new ts.Map();
90769         var existingKind = state.affectedFilesPendingEmitKind.get(affectedFilePendingEmit);
90770         state.affectedFilesPendingEmit.push(affectedFilePendingEmit);
90771         state.affectedFilesPendingEmitKind.set(affectedFilePendingEmit, existingKind || kind);
90772         if (state.affectedFilesPendingEmitIndex === undefined) {
90773             state.affectedFilesPendingEmitIndex = 0;
90774         }
90775     }
90776     function getMapOfReferencedSet(mapLike, toPath) {
90777         if (!mapLike)
90778             return undefined;
90779         var map = new ts.Map();
90780         for (var key in mapLike) {
90781             if (ts.hasProperty(mapLike, key)) {
90782                 map.set(toPath(key), new ts.Set(mapLike[key].map(toPath)));
90783             }
90784         }
90785         return map;
90786     }
90787     function createBuildProgramUsingProgramBuildInfo(program, buildInfoPath, host) {
90788         var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
90789         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
90790         var fileInfos = new ts.Map();
90791         for (var key in program.fileInfos) {
90792             if (ts.hasProperty(program.fileInfos, key)) {
90793                 fileInfos.set(toPath(key), program.fileInfos[key]);
90794             }
90795         }
90796         var state = {
90797             fileInfos: fileInfos,
90798             compilerOptions: ts.convertToOptionsWithAbsolutePaths(program.options, toAbsolutePath),
90799             referencedMap: getMapOfReferencedSet(program.referencedMap, toPath),
90800             exportedModulesMap: getMapOfReferencedSet(program.exportedModulesMap, toPath),
90801             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]; }),
90802             hasReusableDiagnostic: true,
90803             affectedFilesPendingEmit: ts.map(program.affectedFilesPendingEmit, function (value) { return toPath(value[0]); }),
90804             affectedFilesPendingEmitKind: program.affectedFilesPendingEmit && ts.arrayToMap(program.affectedFilesPendingEmit, function (value) { return toPath(value[0]); }, function (value) { return value[1]; }),
90805             affectedFilesPendingEmitIndex: program.affectedFilesPendingEmit && 0,
90806         };
90807         return {
90808             getState: function () { return state; },
90809             backupState: ts.noop,
90810             restoreState: ts.noop,
90811             getProgram: ts.notImplemented,
90812             getProgramOrUndefined: ts.returnUndefined,
90813             releaseProgram: ts.noop,
90814             getCompilerOptions: function () { return state.compilerOptions; },
90815             getSourceFile: ts.notImplemented,
90816             getSourceFiles: ts.notImplemented,
90817             getOptionsDiagnostics: ts.notImplemented,
90818             getGlobalDiagnostics: ts.notImplemented,
90819             getConfigFileParsingDiagnostics: ts.notImplemented,
90820             getSyntacticDiagnostics: ts.notImplemented,
90821             getDeclarationDiagnostics: ts.notImplemented,
90822             getSemanticDiagnostics: ts.notImplemented,
90823             emit: ts.notImplemented,
90824             getAllDependencies: ts.notImplemented,
90825             getCurrentDirectory: ts.notImplemented,
90826             emitNextAffectedFile: ts.notImplemented,
90827             getSemanticDiagnosticsOfNextAffectedFile: ts.notImplemented,
90828             emitBuildInfo: ts.notImplemented,
90829             close: ts.noop,
90830         };
90831         function toPath(path) {
90832             return ts.toPath(path, buildInfoDirectory, getCanonicalFileName);
90833         }
90834         function toAbsolutePath(path) {
90835             return ts.getNormalizedAbsolutePath(path, buildInfoDirectory);
90836         }
90837     }
90838     ts.createBuildProgramUsingProgramBuildInfo = createBuildProgramUsingProgramBuildInfo;
90839     function createRedirectedBuilderProgram(state, configFileParsingDiagnostics) {
90840         return {
90841             getState: ts.notImplemented,
90842             backupState: ts.noop,
90843             restoreState: ts.noop,
90844             getProgram: getProgram,
90845             getProgramOrUndefined: function () { return state.program; },
90846             releaseProgram: function () { return state.program = undefined; },
90847             getCompilerOptions: function () { return state.compilerOptions; },
90848             getSourceFile: function (fileName) { return getProgram().getSourceFile(fileName); },
90849             getSourceFiles: function () { return getProgram().getSourceFiles(); },
90850             getOptionsDiagnostics: function (cancellationToken) { return getProgram().getOptionsDiagnostics(cancellationToken); },
90851             getGlobalDiagnostics: function (cancellationToken) { return getProgram().getGlobalDiagnostics(cancellationToken); },
90852             getConfigFileParsingDiagnostics: function () { return configFileParsingDiagnostics; },
90853             getSyntacticDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getSyntacticDiagnostics(sourceFile, cancellationToken); },
90854             getDeclarationDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getDeclarationDiagnostics(sourceFile, cancellationToken); },
90855             getSemanticDiagnostics: function (sourceFile, cancellationToken) { return getProgram().getSemanticDiagnostics(sourceFile, cancellationToken); },
90856             emit: function (sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers) { return getProgram().emit(sourceFile, writeFile, cancellationToken, emitOnlyDts, customTransformers); },
90857             emitBuildInfo: function (writeFile, cancellationToken) { return getProgram().emitBuildInfo(writeFile, cancellationToken); },
90858             getAllDependencies: ts.notImplemented,
90859             getCurrentDirectory: function () { return getProgram().getCurrentDirectory(); },
90860             close: ts.noop,
90861         };
90862         function getProgram() {
90863             return ts.Debug.checkDefined(state.program);
90864         }
90865     }
90866     ts.createRedirectedBuilderProgram = createRedirectedBuilderProgram;
90867 })(ts || (ts = {}));
90868 var ts;
90869 (function (ts) {
90870     function createSemanticDiagnosticsBuilderProgram(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
90871         return ts.createBuilderProgram(ts.BuilderProgramKind.SemanticDiagnosticsBuilderProgram, ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
90872     }
90873     ts.createSemanticDiagnosticsBuilderProgram = createSemanticDiagnosticsBuilderProgram;
90874     function createEmitAndSemanticDiagnosticsBuilderProgram(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
90875         return ts.createBuilderProgram(ts.BuilderProgramKind.EmitAndSemanticDiagnosticsBuilderProgram, ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences));
90876     }
90877     ts.createEmitAndSemanticDiagnosticsBuilderProgram = createEmitAndSemanticDiagnosticsBuilderProgram;
90878     function createAbstractBuilder(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences) {
90879         var _a = ts.getBuilderCreationParameters(newProgramOrRootNames, hostOrOptions, oldProgramOrHost, configFileParsingDiagnosticsOrOldProgram, configFileParsingDiagnostics, projectReferences), newProgram = _a.newProgram, newConfigFileParsingDiagnostics = _a.configFileParsingDiagnostics;
90880         return ts.createRedirectedBuilderProgram({ program: newProgram, compilerOptions: newProgram.getCompilerOptions() }, newConfigFileParsingDiagnostics);
90881     }
90882     ts.createAbstractBuilder = createAbstractBuilder;
90883 })(ts || (ts = {}));
90884 var ts;
90885 (function (ts) {
90886     function removeIgnoredPath(path) {
90887         if (ts.endsWith(path, "/node_modules/.staging")) {
90888             return ts.removeSuffix(path, "/.staging");
90889         }
90890         return ts.some(ts.ignoredPaths, function (searchPath) { return ts.stringContains(path, searchPath); }) ?
90891             undefined :
90892             path;
90893     }
90894     ts.removeIgnoredPath = removeIgnoredPath;
90895     function canWatchDirectory(dirPath) {
90896         var rootLength = ts.getRootLength(dirPath);
90897         if (dirPath.length === rootLength) {
90898             return false;
90899         }
90900         var nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, rootLength);
90901         if (nextDirectorySeparator === -1) {
90902             return false;
90903         }
90904         var pathPartForUserCheck = dirPath.substring(rootLength, nextDirectorySeparator + 1);
90905         var isNonDirectorySeparatorRoot = rootLength > 1 || dirPath.charCodeAt(0) !== 47;
90906         if (isNonDirectorySeparatorRoot &&
90907             dirPath.search(/[a-zA-Z]:/) !== 0 &&
90908             pathPartForUserCheck.search(/[a-zA-z]\$\//) === 0) {
90909             nextDirectorySeparator = dirPath.indexOf(ts.directorySeparator, nextDirectorySeparator + 1);
90910             if (nextDirectorySeparator === -1) {
90911                 return false;
90912             }
90913             pathPartForUserCheck = dirPath.substring(rootLength + pathPartForUserCheck.length, nextDirectorySeparator + 1);
90914         }
90915         if (isNonDirectorySeparatorRoot &&
90916             pathPartForUserCheck.search(/users\//i) !== 0) {
90917             return true;
90918         }
90919         for (var searchIndex = nextDirectorySeparator + 1, searchLevels = 2; searchLevels > 0; searchLevels--) {
90920             searchIndex = dirPath.indexOf(ts.directorySeparator, searchIndex) + 1;
90921             if (searchIndex === 0) {
90922                 return false;
90923             }
90924         }
90925         return true;
90926     }
90927     ts.canWatchDirectory = canWatchDirectory;
90928     function createResolutionCache(resolutionHost, rootDirForResolution, logChangesWhenResolvingModule) {
90929         var filesWithChangedSetOfUnresolvedImports;
90930         var filesWithInvalidatedResolutions;
90931         var filesWithInvalidatedNonRelativeUnresolvedImports;
90932         var nonRelativeExternalModuleResolutions = ts.createMultiMap();
90933         var resolutionsWithFailedLookups = [];
90934         var resolvedFileToResolution = ts.createMultiMap();
90935         var hasChangedAutomaticTypeDirectiveNames = false;
90936         var failedLookupChecks = [];
90937         var startsWithPathChecks = [];
90938         var isInDirectoryChecks = [];
90939         var getCurrentDirectory = ts.memoize(function () { return resolutionHost.getCurrentDirectory(); });
90940         var cachedDirectoryStructureHost = resolutionHost.getCachedDirectoryStructureHost();
90941         var resolvedModuleNames = new ts.Map();
90942         var perDirectoryResolvedModuleNames = ts.createCacheWithRedirects();
90943         var nonRelativeModuleNameCache = ts.createCacheWithRedirects();
90944         var moduleResolutionCache = ts.createModuleResolutionCacheWithMaps(perDirectoryResolvedModuleNames, nonRelativeModuleNameCache, getCurrentDirectory(), resolutionHost.getCanonicalFileName);
90945         var resolvedTypeReferenceDirectives = new ts.Map();
90946         var perDirectoryResolvedTypeReferenceDirectives = ts.createCacheWithRedirects();
90947         var failedLookupDefaultExtensions = [".ts", ".tsx", ".js", ".jsx", ".json"];
90948         var customFailedLookupPaths = new ts.Map();
90949         var directoryWatchesOfFailedLookups = new ts.Map();
90950         var rootDir = rootDirForResolution && ts.removeTrailingDirectorySeparator(ts.getNormalizedAbsolutePath(rootDirForResolution, getCurrentDirectory()));
90951         var rootPath = (rootDir && resolutionHost.toPath(rootDir));
90952         var rootSplitLength = rootPath !== undefined ? rootPath.split(ts.directorySeparator).length : 0;
90953         var typeRootsWatches = new ts.Map();
90954         return {
90955             startRecordingFilesWithChangedResolutions: startRecordingFilesWithChangedResolutions,
90956             finishRecordingFilesWithChangedResolutions: finishRecordingFilesWithChangedResolutions,
90957             startCachingPerDirectoryResolution: clearPerDirectoryResolutions,
90958             finishCachingPerDirectoryResolution: finishCachingPerDirectoryResolution,
90959             resolveModuleNames: resolveModuleNames,
90960             getResolvedModuleWithFailedLookupLocationsFromCache: getResolvedModuleWithFailedLookupLocationsFromCache,
90961             resolveTypeReferenceDirectives: resolveTypeReferenceDirectives,
90962             removeResolutionsFromProjectReferenceRedirects: removeResolutionsFromProjectReferenceRedirects,
90963             removeResolutionsOfFile: removeResolutionsOfFile,
90964             hasChangedAutomaticTypeDirectiveNames: function () { return hasChangedAutomaticTypeDirectiveNames; },
90965             invalidateResolutionOfFile: invalidateResolutionOfFile,
90966             invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations,
90967             setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports,
90968             createHasInvalidatedResolution: createHasInvalidatedResolution,
90969             isFileWithInvalidatedNonRelativeUnresolvedImports: isFileWithInvalidatedNonRelativeUnresolvedImports,
90970             updateTypeRootsWatch: updateTypeRootsWatch,
90971             closeTypeRootsWatch: closeTypeRootsWatch,
90972             clear: clear
90973         };
90974         function getResolvedModule(resolution) {
90975             return resolution.resolvedModule;
90976         }
90977         function getResolvedTypeReferenceDirective(resolution) {
90978             return resolution.resolvedTypeReferenceDirective;
90979         }
90980         function isInDirectoryPath(dir, file) {
90981             if (dir === undefined || file.length <= dir.length) {
90982                 return false;
90983             }
90984             return ts.startsWith(file, dir) && file[dir.length] === ts.directorySeparator;
90985         }
90986         function clear() {
90987             ts.clearMap(directoryWatchesOfFailedLookups, ts.closeFileWatcherOf);
90988             customFailedLookupPaths.clear();
90989             nonRelativeExternalModuleResolutions.clear();
90990             closeTypeRootsWatch();
90991             resolvedModuleNames.clear();
90992             resolvedTypeReferenceDirectives.clear();
90993             resolvedFileToResolution.clear();
90994             resolutionsWithFailedLookups.length = 0;
90995             failedLookupChecks.length = 0;
90996             startsWithPathChecks.length = 0;
90997             isInDirectoryChecks.length = 0;
90998             clearPerDirectoryResolutions();
90999             hasChangedAutomaticTypeDirectiveNames = false;
91000         }
91001         function startRecordingFilesWithChangedResolutions() {
91002             filesWithChangedSetOfUnresolvedImports = [];
91003         }
91004         function finishRecordingFilesWithChangedResolutions() {
91005             var collected = filesWithChangedSetOfUnresolvedImports;
91006             filesWithChangedSetOfUnresolvedImports = undefined;
91007             return collected;
91008         }
91009         function isFileWithInvalidatedNonRelativeUnresolvedImports(path) {
91010             if (!filesWithInvalidatedNonRelativeUnresolvedImports) {
91011                 return false;
91012             }
91013             var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
91014             return !!value && !!value.length;
91015         }
91016         function createHasInvalidatedResolution(forceAllFilesAsInvalidated) {
91017             invalidateResolutionsOfFailedLookupLocations();
91018             if (forceAllFilesAsInvalidated) {
91019                 filesWithInvalidatedResolutions = undefined;
91020                 return ts.returnTrue;
91021             }
91022             var collected = filesWithInvalidatedResolutions;
91023             filesWithInvalidatedResolutions = undefined;
91024             return function (path) { return (!!collected && collected.has(path)) ||
91025                 isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
91026         }
91027         function clearPerDirectoryResolutions() {
91028             perDirectoryResolvedModuleNames.clear();
91029             nonRelativeModuleNameCache.clear();
91030             perDirectoryResolvedTypeReferenceDirectives.clear();
91031             nonRelativeExternalModuleResolutions.forEach(watchFailedLookupLocationOfNonRelativeModuleResolutions);
91032             nonRelativeExternalModuleResolutions.clear();
91033         }
91034         function finishCachingPerDirectoryResolution() {
91035             filesWithInvalidatedNonRelativeUnresolvedImports = undefined;
91036             clearPerDirectoryResolutions();
91037             directoryWatchesOfFailedLookups.forEach(function (watcher, path) {
91038                 if (watcher.refCount === 0) {
91039                     directoryWatchesOfFailedLookups.delete(path);
91040                     watcher.watcher.close();
91041                 }
91042             });
91043             hasChangedAutomaticTypeDirectiveNames = false;
91044         }
91045         function resolveModuleName(moduleName, containingFile, compilerOptions, host, redirectedReference) {
91046             var _a;
91047             var primaryResult = ts.resolveModuleName(moduleName, containingFile, compilerOptions, host, moduleResolutionCache, redirectedReference);
91048             if (!resolutionHost.getGlobalCache) {
91049                 return primaryResult;
91050             }
91051             var globalCache = resolutionHost.getGlobalCache();
91052             if (globalCache !== undefined && !ts.isExternalModuleNameRelative(moduleName) && !(primaryResult.resolvedModule && ts.extensionIsTS(primaryResult.resolvedModule.extension))) {
91053                 var _b = ts.loadModuleFromGlobalCache(ts.Debug.checkDefined(resolutionHost.globalCacheResolutionModuleName)(moduleName), resolutionHost.projectName, compilerOptions, host, globalCache), resolvedModule = _b.resolvedModule, failedLookupLocations = _b.failedLookupLocations;
91054                 if (resolvedModule) {
91055                     primaryResult.resolvedModule = resolvedModule;
91056                     (_a = primaryResult.failedLookupLocations).push.apply(_a, failedLookupLocations);
91057                     return primaryResult;
91058                 }
91059             }
91060             return primaryResult;
91061         }
91062         function resolveNamesWithLocalCache(_a) {
91063             var _b;
91064             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;
91065             var path = resolutionHost.toPath(containingFile);
91066             var resolutionsInFile = cache.get(path) || cache.set(path, new ts.Map()).get(path);
91067             var dirPath = ts.getDirectoryPath(path);
91068             var perDirectoryCache = perDirectoryCacheWithRedirects.getOrCreateMapOfCacheRedirects(redirectedReference);
91069             var perDirectoryResolution = perDirectoryCache.get(dirPath);
91070             if (!perDirectoryResolution) {
91071                 perDirectoryResolution = new ts.Map();
91072                 perDirectoryCache.set(dirPath, perDirectoryResolution);
91073             }
91074             var resolvedModules = [];
91075             var compilerOptions = resolutionHost.getCompilationSettings();
91076             var hasInvalidatedNonRelativeUnresolvedImport = logChanges && isFileWithInvalidatedNonRelativeUnresolvedImports(path);
91077             var program = resolutionHost.getCurrentProgram();
91078             var oldRedirect = program && program.getResolvedProjectReferenceToRedirect(containingFile);
91079             var unmatchedRedirects = oldRedirect ?
91080                 !redirectedReference || redirectedReference.sourceFile.path !== oldRedirect.sourceFile.path :
91081                 !!redirectedReference;
91082             var seenNamesInFile = new ts.Map();
91083             for (var _i = 0, names_3 = names; _i < names_3.length; _i++) {
91084                 var name = names_3[_i];
91085                 var resolution = resolutionsInFile.get(name);
91086                 if (!seenNamesInFile.has(name) &&
91087                     unmatchedRedirects || !resolution || resolution.isInvalidated ||
91088                     (hasInvalidatedNonRelativeUnresolvedImport && !ts.isExternalModuleNameRelative(name) && shouldRetryResolution(resolution))) {
91089                     var existingResolution = resolution;
91090                     var resolutionInDirectory = perDirectoryResolution.get(name);
91091                     if (resolutionInDirectory) {
91092                         resolution = resolutionInDirectory;
91093                     }
91094                     else {
91095                         resolution = loader(name, containingFile, compilerOptions, ((_b = resolutionHost.getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(resolutionHost)) || resolutionHost, redirectedReference);
91096                         perDirectoryResolution.set(name, resolution);
91097                     }
91098                     resolutionsInFile.set(name, resolution);
91099                     watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
91100                     if (existingResolution) {
91101                         stopWatchFailedLookupLocationOfResolution(existingResolution, path, getResolutionWithResolvedFileName);
91102                     }
91103                     if (logChanges && filesWithChangedSetOfUnresolvedImports && !resolutionIsEqualTo(existingResolution, resolution)) {
91104                         filesWithChangedSetOfUnresolvedImports.push(path);
91105                         logChanges = false;
91106                     }
91107                 }
91108                 ts.Debug.assert(resolution !== undefined && !resolution.isInvalidated);
91109                 seenNamesInFile.set(name, true);
91110                 resolvedModules.push(getResolutionWithResolvedFileName(resolution));
91111             }
91112             resolutionsInFile.forEach(function (resolution, name) {
91113                 if (!seenNamesInFile.has(name) && !ts.contains(reusedNames, name)) {
91114                     stopWatchFailedLookupLocationOfResolution(resolution, path, getResolutionWithResolvedFileName);
91115                     resolutionsInFile.delete(name);
91116                 }
91117             });
91118             return resolvedModules;
91119             function resolutionIsEqualTo(oldResolution, newResolution) {
91120                 if (oldResolution === newResolution) {
91121                     return true;
91122                 }
91123                 if (!oldResolution || !newResolution) {
91124                     return false;
91125                 }
91126                 var oldResult = getResolutionWithResolvedFileName(oldResolution);
91127                 var newResult = getResolutionWithResolvedFileName(newResolution);
91128                 if (oldResult === newResult) {
91129                     return true;
91130                 }
91131                 if (!oldResult || !newResult) {
91132                     return false;
91133                 }
91134                 return oldResult.resolvedFileName === newResult.resolvedFileName;
91135             }
91136         }
91137         function resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference) {
91138             return resolveNamesWithLocalCache({
91139                 names: typeDirectiveNames,
91140                 containingFile: containingFile,
91141                 redirectedReference: redirectedReference,
91142                 cache: resolvedTypeReferenceDirectives,
91143                 perDirectoryCacheWithRedirects: perDirectoryResolvedTypeReferenceDirectives,
91144                 loader: ts.resolveTypeReferenceDirective,
91145                 getResolutionWithResolvedFileName: getResolvedTypeReferenceDirective,
91146                 shouldRetryResolution: function (resolution) { return resolution.resolvedTypeReferenceDirective === undefined; },
91147             });
91148         }
91149         function resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference) {
91150             return resolveNamesWithLocalCache({
91151                 names: moduleNames,
91152                 containingFile: containingFile,
91153                 redirectedReference: redirectedReference,
91154                 cache: resolvedModuleNames,
91155                 perDirectoryCacheWithRedirects: perDirectoryResolvedModuleNames,
91156                 loader: resolveModuleName,
91157                 getResolutionWithResolvedFileName: getResolvedModule,
91158                 shouldRetryResolution: function (resolution) { return !resolution.resolvedModule || !ts.resolutionExtensionIsTSOrJson(resolution.resolvedModule.extension); },
91159                 reusedNames: reusedNames,
91160                 logChanges: logChangesWhenResolvingModule,
91161             });
91162         }
91163         function getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile) {
91164             var cache = resolvedModuleNames.get(resolutionHost.toPath(containingFile));
91165             return cache && cache.get(moduleName);
91166         }
91167         function isNodeModulesAtTypesDirectory(dirPath) {
91168             return ts.endsWith(dirPath, "/node_modules/@types");
91169         }
91170         function getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath) {
91171             if (isInDirectoryPath(rootPath, failedLookupLocationPath)) {
91172                 failedLookupLocation = ts.isRootedDiskPath(failedLookupLocation) ? ts.normalizePath(failedLookupLocation) : ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory());
91173                 var failedLookupPathSplit = failedLookupLocationPath.split(ts.directorySeparator);
91174                 var failedLookupSplit = failedLookupLocation.split(ts.directorySeparator);
91175                 ts.Debug.assert(failedLookupSplit.length === failedLookupPathSplit.length, "FailedLookup: " + failedLookupLocation + " failedLookupLocationPath: " + failedLookupLocationPath);
91176                 if (failedLookupPathSplit.length > rootSplitLength + 1) {
91177                     return {
91178                         dir: failedLookupSplit.slice(0, rootSplitLength + 1).join(ts.directorySeparator),
91179                         dirPath: failedLookupPathSplit.slice(0, rootSplitLength + 1).join(ts.directorySeparator)
91180                     };
91181                 }
91182                 else {
91183                     return {
91184                         dir: rootDir,
91185                         dirPath: rootPath,
91186                         nonRecursive: false
91187                     };
91188                 }
91189             }
91190             return getDirectoryToWatchFromFailedLookupLocationDirectory(ts.getDirectoryPath(ts.getNormalizedAbsolutePath(failedLookupLocation, getCurrentDirectory())), ts.getDirectoryPath(failedLookupLocationPath));
91191         }
91192         function getDirectoryToWatchFromFailedLookupLocationDirectory(dir, dirPath) {
91193             while (ts.pathContainsNodeModules(dirPath)) {
91194                 dir = ts.getDirectoryPath(dir);
91195                 dirPath = ts.getDirectoryPath(dirPath);
91196             }
91197             if (ts.isNodeModulesDirectory(dirPath)) {
91198                 return canWatchDirectory(ts.getDirectoryPath(dirPath)) ? { dir: dir, dirPath: dirPath } : undefined;
91199             }
91200             var nonRecursive = true;
91201             var subDirectoryPath, subDirectory;
91202             if (rootPath !== undefined) {
91203                 while (!isInDirectoryPath(dirPath, rootPath)) {
91204                     var parentPath = ts.getDirectoryPath(dirPath);
91205                     if (parentPath === dirPath) {
91206                         break;
91207                     }
91208                     nonRecursive = false;
91209                     subDirectoryPath = dirPath;
91210                     subDirectory = dir;
91211                     dirPath = parentPath;
91212                     dir = ts.getDirectoryPath(dir);
91213                 }
91214             }
91215             return canWatchDirectory(dirPath) ? { dir: subDirectory || dir, dirPath: subDirectoryPath || dirPath, nonRecursive: nonRecursive } : undefined;
91216         }
91217         function isPathWithDefaultFailedLookupExtension(path) {
91218             return ts.fileExtensionIsOneOf(path, failedLookupDefaultExtensions);
91219         }
91220         function watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, filePath, getResolutionWithResolvedFileName) {
91221             if (resolution.refCount) {
91222                 resolution.refCount++;
91223                 ts.Debug.assertDefined(resolution.files);
91224             }
91225             else {
91226                 resolution.refCount = 1;
91227                 ts.Debug.assert(ts.length(resolution.files) === 0);
91228                 if (ts.isExternalModuleNameRelative(name)) {
91229                     watchFailedLookupLocationOfResolution(resolution);
91230                 }
91231                 else {
91232                     nonRelativeExternalModuleResolutions.add(name, resolution);
91233                 }
91234                 var resolved = getResolutionWithResolvedFileName(resolution);
91235                 if (resolved && resolved.resolvedFileName) {
91236                     resolvedFileToResolution.add(resolutionHost.toPath(resolved.resolvedFileName), resolution);
91237                 }
91238             }
91239             (resolution.files || (resolution.files = [])).push(filePath);
91240         }
91241         function watchFailedLookupLocationOfResolution(resolution) {
91242             ts.Debug.assert(!!resolution.refCount);
91243             var failedLookupLocations = resolution.failedLookupLocations;
91244             if (!failedLookupLocations.length)
91245                 return;
91246             resolutionsWithFailedLookups.push(resolution);
91247             var setAtRoot = false;
91248             for (var _i = 0, failedLookupLocations_1 = failedLookupLocations; _i < failedLookupLocations_1.length; _i++) {
91249                 var failedLookupLocation = failedLookupLocations_1[_i];
91250                 var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
91251                 var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
91252                 if (toWatch) {
91253                     var dir = toWatch.dir, dirPath = toWatch.dirPath, nonRecursive = toWatch.nonRecursive;
91254                     if (!isPathWithDefaultFailedLookupExtension(failedLookupLocationPath)) {
91255                         var refCount = customFailedLookupPaths.get(failedLookupLocationPath) || 0;
91256                         customFailedLookupPaths.set(failedLookupLocationPath, refCount + 1);
91257                     }
91258                     if (dirPath === rootPath) {
91259                         ts.Debug.assert(!nonRecursive);
91260                         setAtRoot = true;
91261                     }
91262                     else {
91263                         setDirectoryWatcher(dir, dirPath, nonRecursive);
91264                     }
91265                 }
91266             }
91267             if (setAtRoot) {
91268                 setDirectoryWatcher(rootDir, rootPath, true);
91269             }
91270         }
91271         function watchFailedLookupLocationOfNonRelativeModuleResolutions(resolutions, name) {
91272             var program = resolutionHost.getCurrentProgram();
91273             if (!program || !program.getTypeChecker().tryFindAmbientModuleWithoutAugmentations(name)) {
91274                 resolutions.forEach(watchFailedLookupLocationOfResolution);
91275             }
91276         }
91277         function setDirectoryWatcher(dir, dirPath, nonRecursive) {
91278             var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
91279             if (dirWatcher) {
91280                 ts.Debug.assert(!!nonRecursive === !!dirWatcher.nonRecursive);
91281                 dirWatcher.refCount++;
91282             }
91283             else {
91284                 directoryWatchesOfFailedLookups.set(dirPath, { watcher: createDirectoryWatcher(dir, dirPath, nonRecursive), refCount: 1, nonRecursive: nonRecursive });
91285             }
91286         }
91287         function stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName) {
91288             ts.unorderedRemoveItem(ts.Debug.assertDefined(resolution.files), filePath);
91289             resolution.refCount--;
91290             if (resolution.refCount) {
91291                 return;
91292             }
91293             var resolved = getResolutionWithResolvedFileName(resolution);
91294             if (resolved && resolved.resolvedFileName) {
91295                 resolvedFileToResolution.remove(resolutionHost.toPath(resolved.resolvedFileName), resolution);
91296             }
91297             if (!ts.unorderedRemoveItem(resolutionsWithFailedLookups, resolution)) {
91298                 return;
91299             }
91300             var failedLookupLocations = resolution.failedLookupLocations;
91301             var removeAtRoot = false;
91302             for (var _i = 0, failedLookupLocations_2 = failedLookupLocations; _i < failedLookupLocations_2.length; _i++) {
91303                 var failedLookupLocation = failedLookupLocations_2[_i];
91304                 var failedLookupLocationPath = resolutionHost.toPath(failedLookupLocation);
91305                 var toWatch = getDirectoryToWatchFailedLookupLocation(failedLookupLocation, failedLookupLocationPath);
91306                 if (toWatch) {
91307                     var dirPath = toWatch.dirPath;
91308                     var refCount = customFailedLookupPaths.get(failedLookupLocationPath);
91309                     if (refCount) {
91310                         if (refCount === 1) {
91311                             customFailedLookupPaths.delete(failedLookupLocationPath);
91312                         }
91313                         else {
91314                             ts.Debug.assert(refCount > 1);
91315                             customFailedLookupPaths.set(failedLookupLocationPath, refCount - 1);
91316                         }
91317                     }
91318                     if (dirPath === rootPath) {
91319                         removeAtRoot = true;
91320                     }
91321                     else {
91322                         removeDirectoryWatcher(dirPath);
91323                     }
91324                 }
91325             }
91326             if (removeAtRoot) {
91327                 removeDirectoryWatcher(rootPath);
91328             }
91329         }
91330         function removeDirectoryWatcher(dirPath) {
91331             var dirWatcher = directoryWatchesOfFailedLookups.get(dirPath);
91332             dirWatcher.refCount--;
91333         }
91334         function createDirectoryWatcher(directory, dirPath, nonRecursive) {
91335             return resolutionHost.watchDirectoryOfFailedLookupLocation(directory, function (fileOrDirectory) {
91336                 var fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
91337                 if (cachedDirectoryStructureHost) {
91338                     cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
91339                 }
91340                 scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
91341             }, nonRecursive ? 0 : 1);
91342         }
91343         function removeResolutionsOfFileFromCache(cache, filePath, getResolutionWithResolvedFileName) {
91344             var resolutions = cache.get(filePath);
91345             if (resolutions) {
91346                 resolutions.forEach(function (resolution) { return stopWatchFailedLookupLocationOfResolution(resolution, filePath, getResolutionWithResolvedFileName); });
91347                 cache.delete(filePath);
91348             }
91349         }
91350         function removeResolutionsFromProjectReferenceRedirects(filePath) {
91351             if (!ts.fileExtensionIs(filePath, ".json")) {
91352                 return;
91353             }
91354             var program = resolutionHost.getCurrentProgram();
91355             if (!program) {
91356                 return;
91357             }
91358             var resolvedProjectReference = program.getResolvedProjectReferenceByPath(filePath);
91359             if (!resolvedProjectReference) {
91360                 return;
91361             }
91362             resolvedProjectReference.commandLine.fileNames.forEach(function (f) { return removeResolutionsOfFile(resolutionHost.toPath(f)); });
91363         }
91364         function removeResolutionsOfFile(filePath) {
91365             removeResolutionsOfFileFromCache(resolvedModuleNames, filePath, getResolvedModule);
91366             removeResolutionsOfFileFromCache(resolvedTypeReferenceDirectives, filePath, getResolvedTypeReferenceDirective);
91367         }
91368         function invalidateResolutions(resolutions, canInvalidate) {
91369             if (!resolutions)
91370                 return false;
91371             var invalidated = false;
91372             for (var _i = 0, resolutions_1 = resolutions; _i < resolutions_1.length; _i++) {
91373                 var resolution = resolutions_1[_i];
91374                 if (resolution.isInvalidated || !canInvalidate(resolution))
91375                     continue;
91376                 resolution.isInvalidated = invalidated = true;
91377                 for (var _a = 0, _b = ts.Debug.assertDefined(resolution.files); _a < _b.length; _a++) {
91378                     var containingFilePath = _b[_a];
91379                     (filesWithInvalidatedResolutions || (filesWithInvalidatedResolutions = new ts.Set())).add(containingFilePath);
91380                     hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames || ts.endsWith(containingFilePath, ts.inferredTypesContainingFile);
91381                 }
91382             }
91383             return invalidated;
91384         }
91385         function invalidateResolutionOfFile(filePath) {
91386             removeResolutionsOfFile(filePath);
91387             var prevHasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
91388             if (invalidateResolutions(resolvedFileToResolution.get(filePath), ts.returnTrue) &&
91389                 hasChangedAutomaticTypeDirectiveNames &&
91390                 !prevHasChangedAutomaticTypeDirectiveNames) {
91391                 resolutionHost.onChangedAutomaticTypeDirectiveNames();
91392             }
91393         }
91394         function setFilesWithInvalidatedNonRelativeUnresolvedImports(filesMap) {
91395             ts.Debug.assert(filesWithInvalidatedNonRelativeUnresolvedImports === filesMap || filesWithInvalidatedNonRelativeUnresolvedImports === undefined);
91396             filesWithInvalidatedNonRelativeUnresolvedImports = filesMap;
91397         }
91398         function scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, isCreatingWatchedDirectory) {
91399             if (isCreatingWatchedDirectory) {
91400                 isInDirectoryChecks.push(fileOrDirectoryPath);
91401             }
91402             else {
91403                 var updatedPath = removeIgnoredPath(fileOrDirectoryPath);
91404                 if (!updatedPath)
91405                     return false;
91406                 fileOrDirectoryPath = updatedPath;
91407                 if (resolutionHost.fileIsOpen(fileOrDirectoryPath)) {
91408                     return false;
91409                 }
91410                 var dirOfFileOrDirectory = ts.getDirectoryPath(fileOrDirectoryPath);
91411                 if (isNodeModulesAtTypesDirectory(fileOrDirectoryPath) || ts.isNodeModulesDirectory(fileOrDirectoryPath) ||
91412                     isNodeModulesAtTypesDirectory(dirOfFileOrDirectory) || ts.isNodeModulesDirectory(dirOfFileOrDirectory)) {
91413                     failedLookupChecks.push(fileOrDirectoryPath);
91414                     startsWithPathChecks.push(fileOrDirectoryPath);
91415                 }
91416                 else {
91417                     if (!isPathWithDefaultFailedLookupExtension(fileOrDirectoryPath) && !customFailedLookupPaths.has(fileOrDirectoryPath)) {
91418                         return false;
91419                     }
91420                     if (ts.isEmittedFileOfProgram(resolutionHost.getCurrentProgram(), fileOrDirectoryPath)) {
91421                         return false;
91422                     }
91423                     failedLookupChecks.push(fileOrDirectoryPath);
91424                 }
91425             }
91426             resolutionHost.scheduleInvalidateResolutionsOfFailedLookupLocations();
91427         }
91428         function invalidateResolutionsOfFailedLookupLocations() {
91429             if (!failedLookupChecks.length && !startsWithPathChecks.length && !isInDirectoryChecks.length) {
91430                 return false;
91431             }
91432             var invalidated = invalidateResolutions(resolutionsWithFailedLookups, canInvalidateFailedLookupResolution);
91433             failedLookupChecks.length = 0;
91434             startsWithPathChecks.length = 0;
91435             isInDirectoryChecks.length = 0;
91436             return invalidated;
91437         }
91438         function canInvalidateFailedLookupResolution(resolution) {
91439             return resolution.failedLookupLocations.some(function (location) {
91440                 var locationPath = resolutionHost.toPath(location);
91441                 return ts.contains(failedLookupChecks, locationPath) ||
91442                     startsWithPathChecks.some(function (fileOrDirectoryPath) { return ts.startsWith(locationPath, fileOrDirectoryPath); }) ||
91443                     isInDirectoryChecks.some(function (fileOrDirectoryPath) { return isInDirectoryPath(fileOrDirectoryPath, locationPath); });
91444             });
91445         }
91446         function closeTypeRootsWatch() {
91447             ts.clearMap(typeRootsWatches, ts.closeFileWatcher);
91448         }
91449         function getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath) {
91450             if (isInDirectoryPath(rootPath, typeRootPath)) {
91451                 return rootPath;
91452             }
91453             var toWatch = getDirectoryToWatchFromFailedLookupLocationDirectory(typeRoot, typeRootPath);
91454             return toWatch && directoryWatchesOfFailedLookups.has(toWatch.dirPath) ? toWatch.dirPath : undefined;
91455         }
91456         function createTypeRootsWatch(typeRootPath, typeRoot) {
91457             return resolutionHost.watchTypeRootsDirectory(typeRoot, function (fileOrDirectory) {
91458                 var fileOrDirectoryPath = resolutionHost.toPath(fileOrDirectory);
91459                 if (cachedDirectoryStructureHost) {
91460                     cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
91461                 }
91462                 hasChangedAutomaticTypeDirectiveNames = true;
91463                 resolutionHost.onChangedAutomaticTypeDirectiveNames();
91464                 var dirPath = getDirectoryToWatchFailedLookupLocationFromTypeRoot(typeRoot, typeRootPath);
91465                 if (dirPath) {
91466                     scheduleInvalidateResolutionOfFailedLookupLocation(fileOrDirectoryPath, dirPath === fileOrDirectoryPath);
91467                 }
91468             }, 1);
91469         }
91470         function updateTypeRootsWatch() {
91471             var options = resolutionHost.getCompilationSettings();
91472             if (options.types) {
91473                 closeTypeRootsWatch();
91474                 return;
91475             }
91476             var typeRoots = ts.getEffectiveTypeRoots(options, { directoryExists: directoryExistsForTypeRootWatch, getCurrentDirectory: getCurrentDirectory });
91477             if (typeRoots) {
91478                 ts.mutateMap(typeRootsWatches, ts.arrayToMap(typeRoots, function (tr) { return resolutionHost.toPath(tr); }), {
91479                     createNewValue: createTypeRootsWatch,
91480                     onDeleteValue: ts.closeFileWatcher
91481                 });
91482             }
91483             else {
91484                 closeTypeRootsWatch();
91485             }
91486         }
91487         function directoryExistsForTypeRootWatch(nodeTypesDirectory) {
91488             var dir = ts.getDirectoryPath(ts.getDirectoryPath(nodeTypesDirectory));
91489             var dirPath = resolutionHost.toPath(dir);
91490             return dirPath === rootPath || canWatchDirectory(dirPath);
91491         }
91492     }
91493     ts.createResolutionCache = createResolutionCache;
91494 })(ts || (ts = {}));
91495 var ts;
91496 (function (ts) {
91497     var moduleSpecifiers;
91498     (function (moduleSpecifiers) {
91499         function getPreferences(_a, compilerOptions, importingSourceFile) {
91500             var importModuleSpecifierPreference = _a.importModuleSpecifierPreference, importModuleSpecifierEnding = _a.importModuleSpecifierEnding;
91501             return {
91502                 relativePreference: importModuleSpecifierPreference === "relative" ? 0 :
91503                     importModuleSpecifierPreference === "non-relative" ? 1 :
91504                         importModuleSpecifierPreference === "project-relative" ? 3 :
91505                             2,
91506                 ending: getEnding(),
91507             };
91508             function getEnding() {
91509                 switch (importModuleSpecifierEnding) {
91510                     case "minimal": return 0;
91511                     case "index": return 1;
91512                     case "js": return 2;
91513                     default: return usesJsExtensionOnImports(importingSourceFile) ? 2
91514                         : ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs ? 1 : 0;
91515                 }
91516             }
91517         }
91518         function getPreferencesForUpdate(compilerOptions, oldImportSpecifier) {
91519             return {
91520                 relativePreference: ts.isExternalModuleNameRelative(oldImportSpecifier) ? 0 : 1,
91521                 ending: ts.hasJSFileExtension(oldImportSpecifier) ?
91522                     2 :
91523                     ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeJs || ts.endsWith(oldImportSpecifier, "index") ? 1 : 0,
91524             };
91525         }
91526         function updateModuleSpecifier(compilerOptions, importingSourceFileName, toFileName, host, oldImportSpecifier) {
91527             var res = getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferencesForUpdate(compilerOptions, oldImportSpecifier));
91528             if (res === oldImportSpecifier)
91529                 return undefined;
91530             return res;
91531         }
91532         moduleSpecifiers.updateModuleSpecifier = updateModuleSpecifier;
91533         function getModuleSpecifier(compilerOptions, importingSourceFile, importingSourceFileName, toFileName, host, preferences) {
91534             if (preferences === void 0) { preferences = {}; }
91535             return getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, getPreferences(preferences, compilerOptions, importingSourceFile));
91536         }
91537         moduleSpecifiers.getModuleSpecifier = getModuleSpecifier;
91538         function getNodeModulesPackageName(compilerOptions, importingSourceFileName, nodeModulesFileName, host) {
91539             var info = getInfo(importingSourceFileName, host);
91540             var modulePaths = getAllModulePaths(importingSourceFileName, nodeModulesFileName, host);
91541             return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions, true); });
91542         }
91543         moduleSpecifiers.getNodeModulesPackageName = getNodeModulesPackageName;
91544         function getModuleSpecifierWorker(compilerOptions, importingSourceFileName, toFileName, host, preferences) {
91545             var info = getInfo(importingSourceFileName, host);
91546             var modulePaths = getAllModulePaths(importingSourceFileName, toFileName, host);
91547             return ts.firstDefined(modulePaths, function (modulePath) { return tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions); }) ||
91548                 getLocalModuleSpecifier(toFileName, info, compilerOptions, host, preferences);
91549         }
91550         function getModuleSpecifiers(moduleSymbol, checker, compilerOptions, importingSourceFile, host, userPreferences) {
91551             var ambient = tryGetModuleNameFromAmbientModule(moduleSymbol, checker);
91552             if (ambient)
91553                 return [ambient];
91554             var info = getInfo(importingSourceFile.path, host);
91555             var moduleSourceFile = ts.getSourceFileOfNode(moduleSymbol.valueDeclaration || ts.getNonAugmentationDeclaration(moduleSymbol));
91556             var modulePaths = getAllModulePaths(importingSourceFile.path, moduleSourceFile.originalFileName, host);
91557             var preferences = getPreferences(userPreferences, compilerOptions, importingSourceFile);
91558             var existingSpecifier = ts.forEach(modulePaths, function (modulePath) { return ts.forEach(host.getFileIncludeReasons().get(ts.toPath(modulePath.path, host.getCurrentDirectory(), info.getCanonicalFileName)), function (reason) {
91559                 if (reason.kind !== ts.FileIncludeKind.Import || reason.file !== importingSourceFile.path)
91560                     return undefined;
91561                 var specifier = ts.getModuleNameStringLiteralAt(importingSourceFile, reason.index).text;
91562                 return preferences.relativePreference !== 1 || !ts.pathIsRelative(specifier) ?
91563                     specifier :
91564                     undefined;
91565             }); });
91566             if (existingSpecifier)
91567                 return [existingSpecifier];
91568             var importedFileIsInNodeModules = ts.some(modulePaths, function (p) { return p.isInNodeModules; });
91569             var nodeModulesSpecifiers;
91570             var pathsSpecifiers;
91571             var relativeSpecifiers;
91572             for (var _i = 0, modulePaths_1 = modulePaths; _i < modulePaths_1.length; _i++) {
91573                 var modulePath = modulePaths_1[_i];
91574                 var specifier = tryGetModuleNameAsNodeModule(modulePath, info, host, compilerOptions);
91575                 nodeModulesSpecifiers = ts.append(nodeModulesSpecifiers, specifier);
91576                 if (specifier && modulePath.isRedirect) {
91577                     return nodeModulesSpecifiers;
91578                 }
91579                 if (!specifier && !modulePath.isRedirect) {
91580                     var local = getLocalModuleSpecifier(modulePath.path, info, compilerOptions, host, preferences);
91581                     if (ts.pathIsBareSpecifier(local)) {
91582                         pathsSpecifiers = ts.append(pathsSpecifiers, local);
91583                     }
91584                     else if (!importedFileIsInNodeModules || modulePath.isInNodeModules) {
91585                         relativeSpecifiers = ts.append(relativeSpecifiers, local);
91586                     }
91587                 }
91588             }
91589             return (pathsSpecifiers === null || pathsSpecifiers === void 0 ? void 0 : pathsSpecifiers.length) ? pathsSpecifiers :
91590                 (nodeModulesSpecifiers === null || nodeModulesSpecifiers === void 0 ? void 0 : nodeModulesSpecifiers.length) ? nodeModulesSpecifiers :
91591                     ts.Debug.checkDefined(relativeSpecifiers);
91592         }
91593         moduleSpecifiers.getModuleSpecifiers = getModuleSpecifiers;
91594         function getInfo(importingSourceFileName, host) {
91595             var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames ? host.useCaseSensitiveFileNames() : true);
91596             var sourceDirectory = ts.getDirectoryPath(importingSourceFileName);
91597             return { getCanonicalFileName: getCanonicalFileName, importingSourceFileName: importingSourceFileName, sourceDirectory: sourceDirectory };
91598         }
91599         function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, _a) {
91600             var ending = _a.ending, relativePreference = _a.relativePreference;
91601             var baseUrl = compilerOptions.baseUrl, paths = compilerOptions.paths, rootDirs = compilerOptions.rootDirs;
91602             var sourceDirectory = info.sourceDirectory, getCanonicalFileName = info.getCanonicalFileName;
91603             var relativePath = rootDirs && tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) ||
91604                 removeExtensionAndIndexPostFix(ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceDirectory, moduleFileName, getCanonicalFileName)), ending, compilerOptions);
91605             if (!baseUrl && !paths || relativePreference === 0) {
91606                 return relativePath;
91607             }
91608             var baseDirectory = ts.getPathsBasePath(compilerOptions, host) || baseUrl;
91609             var relativeToBaseUrl = getRelativePathIfInDirectory(moduleFileName, baseDirectory, getCanonicalFileName);
91610             if (!relativeToBaseUrl) {
91611                 return relativePath;
91612             }
91613             var importRelativeToBaseUrl = removeExtensionAndIndexPostFix(relativeToBaseUrl, ending, compilerOptions);
91614             var fromPaths = paths && tryGetModuleNameFromPaths(ts.removeFileExtension(relativeToBaseUrl), importRelativeToBaseUrl, paths);
91615             var nonRelative = fromPaths === undefined && baseUrl !== undefined ? importRelativeToBaseUrl : fromPaths;
91616             if (!nonRelative) {
91617                 return relativePath;
91618             }
91619             if (relativePreference === 1) {
91620                 return nonRelative;
91621             }
91622             if (relativePreference === 3) {
91623                 var projectDirectory = host.getCurrentDirectory();
91624                 var modulePath = ts.toPath(moduleFileName, projectDirectory, getCanonicalFileName);
91625                 var sourceIsInternal = ts.startsWith(sourceDirectory, projectDirectory);
91626                 var targetIsInternal = ts.startsWith(modulePath, projectDirectory);
91627                 if (sourceIsInternal && !targetIsInternal || !sourceIsInternal && targetIsInternal) {
91628                     return nonRelative;
91629                 }
91630                 var nearestTargetPackageJson = getNearestAncestorDirectoryWithPackageJson(host, ts.getDirectoryPath(modulePath));
91631                 var nearestSourcePackageJson = getNearestAncestorDirectoryWithPackageJson(host, sourceDirectory);
91632                 if (nearestSourcePackageJson !== nearestTargetPackageJson) {
91633                     return nonRelative;
91634                 }
91635                 return relativePath;
91636             }
91637             if (relativePreference !== 2)
91638                 ts.Debug.assertNever(relativePreference);
91639             return isPathRelativeToParent(nonRelative) || countPathComponents(relativePath) < countPathComponents(nonRelative) ? relativePath : nonRelative;
91640         }
91641         function countPathComponents(path) {
91642             var count = 0;
91643             for (var i = ts.startsWith(path, "./") ? 2 : 0; i < path.length; i++) {
91644                 if (path.charCodeAt(i) === 47)
91645                     count++;
91646             }
91647             return count;
91648         }
91649         moduleSpecifiers.countPathComponents = countPathComponents;
91650         function usesJsExtensionOnImports(_a) {
91651             var imports = _a.imports;
91652             return ts.firstDefined(imports, function (_a) {
91653                 var text = _a.text;
91654                 return ts.pathIsRelative(text) ? ts.hasJSFileExtension(text) : undefined;
91655             }) || false;
91656         }
91657         function comparePathsByRedirectAndNumberOfDirectorySeparators(a, b) {
91658             return ts.compareBooleans(b.isRedirect, a.isRedirect) || ts.compareNumberOfDirectorySeparators(a.path, b.path);
91659         }
91660         function getNearestAncestorDirectoryWithPackageJson(host, fileName) {
91661             if (host.getNearestAncestorDirectoryWithPackageJson) {
91662                 return host.getNearestAncestorDirectoryWithPackageJson(fileName);
91663             }
91664             return !!ts.forEachAncestorDirectory(fileName, function (directory) {
91665                 return host.fileExists(ts.combinePaths(directory, "package.json")) ? true : undefined;
91666             });
91667         }
91668         function forEachFileNameOfModule(importingFileName, importedFileName, host, preferSymlinks, cb) {
91669             var getCanonicalFileName = ts.hostGetCanonicalFileName(host);
91670             var cwd = host.getCurrentDirectory();
91671             var referenceRedirect = host.isSourceOfProjectReferenceRedirect(importedFileName) ? host.getProjectReferenceRedirect(importedFileName) : undefined;
91672             var importedPath = ts.toPath(importedFileName, cwd, getCanonicalFileName);
91673             var redirects = host.redirectTargetsMap.get(importedPath) || ts.emptyArray;
91674             var importedFileNames = __spreadArray(__spreadArray(__spreadArray([], (referenceRedirect ? [referenceRedirect] : ts.emptyArray)), [importedFileName]), redirects);
91675             var targets = importedFileNames.map(function (f) { return ts.getNormalizedAbsolutePath(f, cwd); });
91676             var shouldFilterIgnoredPaths = !ts.every(targets, ts.containsIgnoredPath);
91677             if (!preferSymlinks) {
91678                 var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
91679                 if (result_15)
91680                     return result_15;
91681             }
91682             var links = host.getSymlinkCache
91683                 ? host.getSymlinkCache()
91684                 : ts.discoverProbableSymlinks(host.getSourceFiles(), getCanonicalFileName, cwd);
91685             var symlinkedDirectories = links.getSymlinkedDirectoriesByRealpath();
91686             var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
91687             var result = symlinkedDirectories && ts.forEachAncestorDirectory(ts.getDirectoryPath(fullImportedFileName), function (realPathDirectory) {
91688                 var symlinkDirectories = symlinkedDirectories.get(ts.ensureTrailingDirectorySeparator(ts.toPath(realPathDirectory, cwd, getCanonicalFileName)));
91689                 if (!symlinkDirectories)
91690                     return undefined;
91691                 if (ts.startsWithDirectory(importingFileName, realPathDirectory, getCanonicalFileName)) {
91692                     return false;
91693                 }
91694                 return ts.forEach(targets, function (target) {
91695                     if (!ts.startsWithDirectory(target, realPathDirectory, getCanonicalFileName)) {
91696                         return;
91697                     }
91698                     var relative = ts.getRelativePathFromDirectory(realPathDirectory, target, getCanonicalFileName);
91699                     for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
91700                         var symlinkDirectory = symlinkDirectories_1[_i];
91701                         var option = ts.resolvePath(symlinkDirectory, relative);
91702                         var result_16 = cb(option, target === referenceRedirect);
91703                         shouldFilterIgnoredPaths = true;
91704                         if (result_16)
91705                             return result_16;
91706                     }
91707                 });
91708             });
91709             return result || (preferSymlinks
91710                 ? ts.forEach(targets, function (p) { return shouldFilterIgnoredPaths && ts.containsIgnoredPath(p) ? undefined : cb(p, p === referenceRedirect); })
91711                 : undefined);
91712         }
91713         moduleSpecifiers.forEachFileNameOfModule = forEachFileNameOfModule;
91714         function getAllModulePaths(importingFileName, importedFileName, host) {
91715             var cwd = host.getCurrentDirectory();
91716             var getCanonicalFileName = ts.hostGetCanonicalFileName(host);
91717             var allFileNames = new ts.Map();
91718             var importedFileFromNodeModules = false;
91719             forEachFileNameOfModule(importingFileName, importedFileName, host, true, function (path, isRedirect) {
91720                 var isInNodeModules = ts.pathContainsNodeModules(path);
91721                 allFileNames.set(path, { path: getCanonicalFileName(path), isRedirect: isRedirect, isInNodeModules: isInNodeModules });
91722                 importedFileFromNodeModules = importedFileFromNodeModules || isInNodeModules;
91723             });
91724             var sortedPaths = [];
91725             var _loop_24 = function (directory) {
91726                 var directoryStart = ts.ensureTrailingDirectorySeparator(directory);
91727                 var pathsInDirectory;
91728                 allFileNames.forEach(function (_a, fileName) {
91729                     var path = _a.path, isRedirect = _a.isRedirect, isInNodeModules = _a.isInNodeModules;
91730                     if (ts.startsWith(path, directoryStart)) {
91731                         (pathsInDirectory || (pathsInDirectory = [])).push({ path: fileName, isRedirect: isRedirect, isInNodeModules: isInNodeModules });
91732                         allFileNames.delete(fileName);
91733                     }
91734                 });
91735                 if (pathsInDirectory) {
91736                     if (pathsInDirectory.length > 1) {
91737                         pathsInDirectory.sort(comparePathsByRedirectAndNumberOfDirectorySeparators);
91738                     }
91739                     sortedPaths.push.apply(sortedPaths, pathsInDirectory);
91740                 }
91741                 var newDirectory = ts.getDirectoryPath(directory);
91742                 if (newDirectory === directory)
91743                     return out_directory_1 = directory, "break";
91744                 directory = newDirectory;
91745                 out_directory_1 = directory;
91746             };
91747             var out_directory_1;
91748             for (var directory = ts.getDirectoryPath(ts.toPath(importingFileName, cwd, getCanonicalFileName)); allFileNames.size !== 0;) {
91749                 var state_8 = _loop_24(directory);
91750                 directory = out_directory_1;
91751                 if (state_8 === "break")
91752                     break;
91753             }
91754             if (allFileNames.size) {
91755                 var remainingPaths = ts.arrayFrom(allFileNames.values());
91756                 if (remainingPaths.length > 1)
91757                     remainingPaths.sort(comparePathsByRedirectAndNumberOfDirectorySeparators);
91758                 sortedPaths.push.apply(sortedPaths, remainingPaths);
91759             }
91760             return sortedPaths;
91761         }
91762         function tryGetModuleNameFromAmbientModule(moduleSymbol, checker) {
91763             var decl = ts.find(moduleSymbol.declarations, function (d) { return ts.isNonGlobalAmbientModule(d) && (!ts.isExternalModuleAugmentation(d) || !ts.isExternalModuleNameRelative(ts.getTextOfIdentifierOrLiteral(d.name))); });
91764             if (decl) {
91765                 return decl.name.text;
91766             }
91767             var ambientModuleDeclareCandidates = ts.mapDefined(moduleSymbol.declarations, function (d) {
91768                 var _a, _b, _c, _d;
91769                 if (!ts.isModuleDeclaration(d))
91770                     return;
91771                 var topNamespace = getTopNamespace(d);
91772                 if (!(((_a = topNamespace === null || topNamespace === void 0 ? void 0 : topNamespace.parent) === null || _a === void 0 ? void 0 : _a.parent)
91773                     && ts.isModuleBlock(topNamespace.parent) && ts.isAmbientModule(topNamespace.parent.parent) && ts.isSourceFile(topNamespace.parent.parent.parent)))
91774                     return;
91775                 var exportAssignment = (_d = (_c = (_b = topNamespace.parent.parent.symbol.exports) === null || _b === void 0 ? void 0 : _b.get("export=")) === null || _c === void 0 ? void 0 : _c.valueDeclaration) === null || _d === void 0 ? void 0 : _d.expression;
91776                 if (!exportAssignment)
91777                     return;
91778                 var exportSymbol = checker.getSymbolAtLocation(exportAssignment);
91779                 if (!exportSymbol)
91780                     return;
91781                 var originalExportSymbol = (exportSymbol === null || exportSymbol === void 0 ? void 0 : exportSymbol.flags) & 2097152 ? checker.getAliasedSymbol(exportSymbol) : exportSymbol;
91782                 if (originalExportSymbol === d.symbol)
91783                     return topNamespace.parent.parent;
91784                 function getTopNamespace(namespaceDeclaration) {
91785                     while (namespaceDeclaration.flags & 4) {
91786                         namespaceDeclaration = namespaceDeclaration.parent;
91787                     }
91788                     return namespaceDeclaration;
91789                 }
91790             });
91791             var ambientModuleDeclare = ambientModuleDeclareCandidates[0];
91792             if (ambientModuleDeclare) {
91793                 return ambientModuleDeclare.name.text;
91794             }
91795         }
91796         function tryGetModuleNameFromPaths(relativeToBaseUrlWithIndex, relativeToBaseUrl, paths) {
91797             for (var key in paths) {
91798                 for (var _i = 0, _a = paths[key]; _i < _a.length; _i++) {
91799                     var patternText_1 = _a[_i];
91800                     var pattern = ts.removeFileExtension(ts.normalizePath(patternText_1));
91801                     var indexOfStar = pattern.indexOf("*");
91802                     if (indexOfStar !== -1) {
91803                         var prefix = pattern.substr(0, indexOfStar);
91804                         var suffix = pattern.substr(indexOfStar + 1);
91805                         if (relativeToBaseUrl.length >= prefix.length + suffix.length &&
91806                             ts.startsWith(relativeToBaseUrl, prefix) &&
91807                             ts.endsWith(relativeToBaseUrl, suffix) ||
91808                             !suffix && relativeToBaseUrl === ts.removeTrailingDirectorySeparator(prefix)) {
91809                             var matchedStar = relativeToBaseUrl.substr(prefix.length, relativeToBaseUrl.length - suffix.length);
91810                             return key.replace("*", matchedStar);
91811                         }
91812                     }
91813                     else if (pattern === relativeToBaseUrl || pattern === relativeToBaseUrlWithIndex) {
91814                         return key;
91815                     }
91816                 }
91817             }
91818         }
91819         function tryGetModuleNameFromRootDirs(rootDirs, moduleFileName, sourceDirectory, getCanonicalFileName, ending, compilerOptions) {
91820             var normalizedTargetPath = getPathRelativeToRootDirs(moduleFileName, rootDirs, getCanonicalFileName);
91821             if (normalizedTargetPath === undefined) {
91822                 return undefined;
91823             }
91824             var normalizedSourcePath = getPathRelativeToRootDirs(sourceDirectory, rootDirs, getCanonicalFileName);
91825             var relativePath = normalizedSourcePath !== undefined ? ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(normalizedSourcePath, normalizedTargetPath, getCanonicalFileName)) : normalizedTargetPath;
91826             return ts.getEmitModuleResolutionKind(compilerOptions) === ts.ModuleResolutionKind.NodeJs
91827                 ? removeExtensionAndIndexPostFix(relativePath, ending, compilerOptions)
91828                 : ts.removeFileExtension(relativePath);
91829         }
91830         function tryGetModuleNameAsNodeModule(_a, _b, host, options, packageNameOnly) {
91831             var path = _a.path, isRedirect = _a.isRedirect;
91832             var getCanonicalFileName = _b.getCanonicalFileName, sourceDirectory = _b.sourceDirectory;
91833             if (!host.fileExists || !host.readFile) {
91834                 return undefined;
91835             }
91836             var parts = getNodeModulePathParts(path);
91837             if (!parts) {
91838                 return undefined;
91839             }
91840             var moduleSpecifier = path;
91841             var isPackageRootPath = false;
91842             if (!packageNameOnly) {
91843                 var packageRootIndex = parts.packageRootIndex;
91844                 var moduleFileNameForExtensionless = void 0;
91845                 while (true) {
91846                     var _c = tryDirectoryWithPackageJson(packageRootIndex), moduleFileToTry = _c.moduleFileToTry, packageRootPath = _c.packageRootPath;
91847                     if (packageRootPath) {
91848                         moduleSpecifier = packageRootPath;
91849                         isPackageRootPath = true;
91850                         break;
91851                     }
91852                     if (!moduleFileNameForExtensionless)
91853                         moduleFileNameForExtensionless = moduleFileToTry;
91854                     packageRootIndex = path.indexOf(ts.directorySeparator, packageRootIndex + 1);
91855                     if (packageRootIndex === -1) {
91856                         moduleSpecifier = getExtensionlessFileName(moduleFileNameForExtensionless);
91857                         break;
91858                     }
91859                 }
91860             }
91861             if (isRedirect && !isPackageRootPath) {
91862                 return undefined;
91863             }
91864             var globalTypingsCacheLocation = host.getGlobalTypingsCacheLocation && host.getGlobalTypingsCacheLocation();
91865             var pathToTopLevelNodeModules = getCanonicalFileName(moduleSpecifier.substring(0, parts.topLevelNodeModulesIndex));
91866             if (!(ts.startsWith(sourceDirectory, pathToTopLevelNodeModules) || globalTypingsCacheLocation && ts.startsWith(getCanonicalFileName(globalTypingsCacheLocation), pathToTopLevelNodeModules))) {
91867                 return undefined;
91868             }
91869             var nodeModulesDirectoryName = moduleSpecifier.substring(parts.topLevelPackageNameIndex + 1);
91870             var packageName = ts.getPackageNameFromTypesPackageName(nodeModulesDirectoryName);
91871             return ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs && packageName === nodeModulesDirectoryName ? undefined : packageName;
91872             function tryDirectoryWithPackageJson(packageRootIndex) {
91873                 var packageRootPath = path.substring(0, packageRootIndex);
91874                 var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
91875                 var moduleFileToTry = path;
91876                 if (host.fileExists(packageJsonPath)) {
91877                     var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
91878                     var versionPaths = packageJsonContent.typesVersions
91879                         ? ts.getPackageJsonTypesVersionsPaths(packageJsonContent.typesVersions)
91880                         : undefined;
91881                     if (versionPaths) {
91882                         var subModuleName = path.slice(packageRootPath.length + 1);
91883                         var fromPaths = tryGetModuleNameFromPaths(ts.removeFileExtension(subModuleName), removeExtensionAndIndexPostFix(subModuleName, 0, options), versionPaths.paths);
91884                         if (fromPaths !== undefined) {
91885                             moduleFileToTry = ts.combinePaths(packageRootPath, fromPaths);
91886                         }
91887                     }
91888                     var mainFileRelative = packageJsonContent.typings || packageJsonContent.types || packageJsonContent.main;
91889                     if (ts.isString(mainFileRelative)) {
91890                         var mainExportFile = ts.toPath(mainFileRelative, packageRootPath, getCanonicalFileName);
91891                         if (ts.removeFileExtension(mainExportFile) === ts.removeFileExtension(getCanonicalFileName(moduleFileToTry))) {
91892                             return { packageRootPath: packageRootPath, moduleFileToTry: moduleFileToTry };
91893                         }
91894                     }
91895                 }
91896                 return { moduleFileToTry: moduleFileToTry };
91897             }
91898             function getExtensionlessFileName(path) {
91899                 var fullModulePathWithoutExtension = ts.removeFileExtension(path);
91900                 if (getCanonicalFileName(fullModulePathWithoutExtension.substring(parts.fileNameIndex)) === "/index" && !tryGetAnyFileFromPath(host, fullModulePathWithoutExtension.substring(0, parts.fileNameIndex))) {
91901                     return fullModulePathWithoutExtension.substring(0, parts.fileNameIndex);
91902                 }
91903                 return fullModulePathWithoutExtension;
91904             }
91905         }
91906         function tryGetAnyFileFromPath(host, path) {
91907             if (!host.fileExists)
91908                 return;
91909             var extensions = ts.getSupportedExtensions({ allowJs: true }, [{ extension: "node", isMixedContent: false }, { extension: "json", isMixedContent: false, scriptKind: 6 }]);
91910             for (var _i = 0, extensions_3 = extensions; _i < extensions_3.length; _i++) {
91911                 var e = extensions_3[_i];
91912                 var fullPath = path + e;
91913                 if (host.fileExists(fullPath)) {
91914                     return fullPath;
91915                 }
91916             }
91917         }
91918         function getNodeModulePathParts(fullPath) {
91919             var topLevelNodeModulesIndex = 0;
91920             var topLevelPackageNameIndex = 0;
91921             var packageRootIndex = 0;
91922             var fileNameIndex = 0;
91923             var partStart = 0;
91924             var partEnd = 0;
91925             var state = 0;
91926             while (partEnd >= 0) {
91927                 partStart = partEnd;
91928                 partEnd = fullPath.indexOf("/", partStart + 1);
91929                 switch (state) {
91930                     case 0:
91931                         if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
91932                             topLevelNodeModulesIndex = partStart;
91933                             topLevelPackageNameIndex = partEnd;
91934                             state = 1;
91935                         }
91936                         break;
91937                     case 1:
91938                     case 2:
91939                         if (state === 1 && fullPath.charAt(partStart + 1) === "@") {
91940                             state = 2;
91941                         }
91942                         else {
91943                             packageRootIndex = partEnd;
91944                             state = 3;
91945                         }
91946                         break;
91947                     case 3:
91948                         if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
91949                             state = 1;
91950                         }
91951                         else {
91952                             state = 3;
91953                         }
91954                         break;
91955                 }
91956             }
91957             fileNameIndex = partStart;
91958             return state > 1 ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
91959         }
91960         function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
91961             return ts.firstDefined(rootDirs, function (rootDir) {
91962                 var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
91963                 return isPathRelativeToParent(relativePath) ? undefined : relativePath;
91964             });
91965         }
91966         function removeExtensionAndIndexPostFix(fileName, ending, options) {
91967             if (ts.fileExtensionIs(fileName, ".json"))
91968                 return fileName;
91969             var noExtension = ts.removeFileExtension(fileName);
91970             switch (ending) {
91971                 case 0:
91972                     return ts.removeSuffix(noExtension, "/index");
91973                 case 1:
91974                     return noExtension;
91975                 case 2:
91976                     return noExtension + getJSExtensionForFile(fileName, options);
91977                 default:
91978                     return ts.Debug.assertNever(ending);
91979             }
91980         }
91981         function getJSExtensionForFile(fileName, options) {
91982             var ext = ts.extensionFromPath(fileName);
91983             switch (ext) {
91984                 case ".ts":
91985                 case ".d.ts":
91986                     return ".js";
91987                 case ".tsx":
91988                     return options.jsx === 1 ? ".jsx" : ".js";
91989                 case ".js":
91990                 case ".jsx":
91991                 case ".json":
91992                     return ext;
91993                 case ".tsbuildinfo":
91994                     return ts.Debug.fail("Extension " + ".tsbuildinfo" + " is unsupported:: FileName:: " + fileName);
91995                 default:
91996                     return ts.Debug.assertNever(ext);
91997             }
91998         }
91999         function getRelativePathIfInDirectory(path, directoryPath, getCanonicalFileName) {
92000             var relativePath = ts.getRelativePathToDirectoryOrUrl(directoryPath, path, directoryPath, getCanonicalFileName, false);
92001             return ts.isRootedDiskPath(relativePath) ? undefined : relativePath;
92002         }
92003         function isPathRelativeToParent(path) {
92004             return ts.startsWith(path, "..");
92005         }
92006     })(moduleSpecifiers = ts.moduleSpecifiers || (ts.moduleSpecifiers = {}));
92007 })(ts || (ts = {}));
92008 var ts;
92009 (function (ts) {
92010     var sysFormatDiagnosticsHost = ts.sys ? {
92011         getCurrentDirectory: function () { return ts.sys.getCurrentDirectory(); },
92012         getNewLine: function () { return ts.sys.newLine; },
92013         getCanonicalFileName: ts.createGetCanonicalFileName(ts.sys.useCaseSensitiveFileNames)
92014     } : undefined;
92015     function createDiagnosticReporter(system, pretty) {
92016         var host = system === ts.sys ? sysFormatDiagnosticsHost : {
92017             getCurrentDirectory: function () { return system.getCurrentDirectory(); },
92018             getNewLine: function () { return system.newLine; },
92019             getCanonicalFileName: ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames),
92020         };
92021         if (!pretty) {
92022             return function (diagnostic) { return system.write(ts.formatDiagnostic(diagnostic, host)); };
92023         }
92024         var diagnostics = new Array(1);
92025         return function (diagnostic) {
92026             diagnostics[0] = diagnostic;
92027             system.write(ts.formatDiagnosticsWithColorAndContext(diagnostics, host) + host.getNewLine());
92028             diagnostics[0] = undefined;
92029         };
92030     }
92031     ts.createDiagnosticReporter = createDiagnosticReporter;
92032     function clearScreenIfNotWatchingForFileChanges(system, diagnostic, options) {
92033         if (system.clearScreen &&
92034             !options.preserveWatchOutput &&
92035             !options.extendedDiagnostics &&
92036             !options.diagnostics &&
92037             ts.contains(ts.screenStartingMessageCodes, diagnostic.code)) {
92038             system.clearScreen();
92039             return true;
92040         }
92041         return false;
92042     }
92043     ts.screenStartingMessageCodes = [
92044         ts.Diagnostics.Starting_compilation_in_watch_mode.code,
92045         ts.Diagnostics.File_change_detected_Starting_incremental_compilation.code,
92046     ];
92047     function getPlainDiagnosticFollowingNewLines(diagnostic, newLine) {
92048         return ts.contains(ts.screenStartingMessageCodes, diagnostic.code)
92049             ? newLine + newLine
92050             : newLine;
92051     }
92052     function getLocaleTimeString(system) {
92053         return !system.now ?
92054             new Date().toLocaleTimeString() :
92055             system.now().toLocaleTimeString("en-US", { timeZone: "UTC" });
92056     }
92057     ts.getLocaleTimeString = getLocaleTimeString;
92058     function createWatchStatusReporter(system, pretty) {
92059         return pretty ?
92060             function (diagnostic, newLine, options) {
92061                 clearScreenIfNotWatchingForFileChanges(system, diagnostic, options);
92062                 var output = "[" + ts.formatColorAndReset(getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] ";
92063                 output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (newLine + newLine);
92064                 system.write(output);
92065             } :
92066             function (diagnostic, newLine, options) {
92067                 var output = "";
92068                 if (!clearScreenIfNotWatchingForFileChanges(system, diagnostic, options)) {
92069                     output += newLine;
92070                 }
92071                 output += getLocaleTimeString(system) + " - ";
92072                 output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + getPlainDiagnosticFollowingNewLines(diagnostic, newLine);
92073                 system.write(output);
92074             };
92075     }
92076     ts.createWatchStatusReporter = createWatchStatusReporter;
92077     function parseConfigFileWithSystem(configFileName, optionsToExtend, watchOptionsToExtend, system, reportDiagnostic) {
92078         var host = system;
92079         host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic); };
92080         var result = ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtend, host, undefined, watchOptionsToExtend);
92081         host.onUnRecoverableConfigFileDiagnostic = undefined;
92082         return result;
92083     }
92084     ts.parseConfigFileWithSystem = parseConfigFileWithSystem;
92085     function getErrorCountForSummary(diagnostics) {
92086         return ts.countWhere(diagnostics, function (diagnostic) { return diagnostic.category === ts.DiagnosticCategory.Error; });
92087     }
92088     ts.getErrorCountForSummary = getErrorCountForSummary;
92089     function getWatchErrorSummaryDiagnosticMessage(errorCount) {
92090         return errorCount === 1 ?
92091             ts.Diagnostics.Found_1_error_Watching_for_file_changes :
92092             ts.Diagnostics.Found_0_errors_Watching_for_file_changes;
92093     }
92094     ts.getWatchErrorSummaryDiagnosticMessage = getWatchErrorSummaryDiagnosticMessage;
92095     function getErrorSummaryText(errorCount, newLine) {
92096         if (errorCount === 0)
92097             return "";
92098         var d = ts.createCompilerDiagnostic(errorCount === 1 ? ts.Diagnostics.Found_1_error : ts.Diagnostics.Found_0_errors, errorCount);
92099         return "" + newLine + ts.flattenDiagnosticMessageText(d.messageText, newLine) + newLine + newLine;
92100     }
92101     ts.getErrorSummaryText = getErrorSummaryText;
92102     function isBuilderProgram(program) {
92103         return !!program.getState;
92104     }
92105     ts.isBuilderProgram = isBuilderProgram;
92106     function listFiles(program, write) {
92107         var options = program.getCompilerOptions();
92108         if (options.explainFiles) {
92109             explainFiles(isBuilderProgram(program) ? program.getProgram() : program, write);
92110         }
92111         else if (options.listFiles || options.listFilesOnly) {
92112             ts.forEach(program.getSourceFiles(), function (file) {
92113                 write(file.fileName);
92114             });
92115         }
92116     }
92117     ts.listFiles = listFiles;
92118     function explainFiles(program, write) {
92119         var _a, _b;
92120         var reasons = program.getFileIncludeReasons();
92121         var getCanonicalFileName = ts.createGetCanonicalFileName(program.useCaseSensitiveFileNames());
92122         var relativeFileName = function (fileName) { return ts.convertToRelativePath(fileName, program.getCurrentDirectory(), getCanonicalFileName); };
92123         for (var _i = 0, _c = program.getSourceFiles(); _i < _c.length; _i++) {
92124             var file = _c[_i];
92125             write("" + toFileName(file, relativeFileName));
92126             (_a = reasons.get(file.path)) === null || _a === void 0 ? void 0 : _a.forEach(function (reason) { return write("  " + fileIncludeReasonToDiagnostics(program, reason, relativeFileName).messageText); });
92127             (_b = explainIfFileIsRedirect(file, relativeFileName)) === null || _b === void 0 ? void 0 : _b.forEach(function (d) { return write("  " + d.messageText); });
92128         }
92129     }
92130     ts.explainFiles = explainFiles;
92131     function explainIfFileIsRedirect(file, fileNameConvertor) {
92132         var result;
92133         if (file.path !== file.resolvedPath) {
92134             (result || (result = [])).push(ts.chainDiagnosticMessages(undefined, ts.Diagnostics.File_is_output_of_project_reference_source_0, toFileName(file.originalFileName, fileNameConvertor)));
92135         }
92136         if (file.redirectInfo) {
92137             (result || (result = [])).push(ts.chainDiagnosticMessages(undefined, ts.Diagnostics.File_redirects_to_file_0, toFileName(file.redirectInfo.redirectTarget, fileNameConvertor)));
92138         }
92139         return result;
92140     }
92141     ts.explainIfFileIsRedirect = explainIfFileIsRedirect;
92142     function getMatchedFileSpec(program, fileName) {
92143         var _a;
92144         var configFile = program.getCompilerOptions().configFile;
92145         if (!((_a = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _a === void 0 ? void 0 : _a.validatedFilesSpec))
92146             return undefined;
92147         var getCanonicalFileName = ts.createGetCanonicalFileName(program.useCaseSensitiveFileNames());
92148         var filePath = getCanonicalFileName(fileName);
92149         var basePath = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory()));
92150         return ts.find(configFile.configFileSpecs.validatedFilesSpec, function (fileSpec) { return getCanonicalFileName(ts.getNormalizedAbsolutePath(fileSpec, basePath)) === filePath; });
92151     }
92152     ts.getMatchedFileSpec = getMatchedFileSpec;
92153     function getMatchedIncludeSpec(program, fileName) {
92154         var _a, _b;
92155         var configFile = program.getCompilerOptions().configFile;
92156         if (!((_a = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _a === void 0 ? void 0 : _a.validatedIncludeSpecs))
92157             return undefined;
92158         var isJsonFile = ts.fileExtensionIs(fileName, ".json");
92159         var basePath = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFile.fileName, program.getCurrentDirectory()));
92160         var useCaseSensitiveFileNames = program.useCaseSensitiveFileNames();
92161         return ts.find((_b = configFile === null || configFile === void 0 ? void 0 : configFile.configFileSpecs) === null || _b === void 0 ? void 0 : _b.validatedIncludeSpecs, function (includeSpec) {
92162             if (isJsonFile && !ts.endsWith(includeSpec, ".json"))
92163                 return false;
92164             var pattern = ts.getPatternFromSpec(includeSpec, basePath, "files");
92165             return !!pattern && ts.getRegexFromPattern("(" + pattern + ")$", useCaseSensitiveFileNames).test(fileName);
92166         });
92167     }
92168     ts.getMatchedIncludeSpec = getMatchedIncludeSpec;
92169     function fileIncludeReasonToDiagnostics(program, reason, fileNameConvertor) {
92170         var _a, _b;
92171         var options = program.getCompilerOptions();
92172         if (ts.isReferencedFile(reason)) {
92173             var referenceLocation = ts.getReferencedFileLocation(function (path) { return program.getSourceFileByPath(path); }, reason);
92174             var referenceText = ts.isReferenceFileLocation(referenceLocation) ? referenceLocation.file.text.substring(referenceLocation.pos, referenceLocation.end) : "\"" + referenceLocation.text + "\"";
92175             var message = void 0;
92176             ts.Debug.assert(ts.isReferenceFileLocation(referenceLocation) || reason.kind === ts.FileIncludeKind.Import, "Only synthetic references are imports");
92177             switch (reason.kind) {
92178                 case ts.FileIncludeKind.Import:
92179                     if (ts.isReferenceFileLocation(referenceLocation)) {
92180                         message = referenceLocation.packageId ?
92181                             ts.Diagnostics.Imported_via_0_from_file_1_with_packageId_2 :
92182                             ts.Diagnostics.Imported_via_0_from_file_1;
92183                     }
92184                     else if (referenceLocation.text === ts.externalHelpersModuleNameText) {
92185                         message = referenceLocation.packageId ?
92186                             ts.Diagnostics.Imported_via_0_from_file_1_with_packageId_2_to_import_importHelpers_as_specified_in_compilerOptions :
92187                             ts.Diagnostics.Imported_via_0_from_file_1_to_import_importHelpers_as_specified_in_compilerOptions;
92188                     }
92189                     else {
92190                         message = referenceLocation.packageId ?
92191                             ts.Diagnostics.Imported_via_0_from_file_1_with_packageId_2_to_import_jsx_and_jsxs_factory_functions :
92192                             ts.Diagnostics.Imported_via_0_from_file_1_to_import_jsx_and_jsxs_factory_functions;
92193                     }
92194                     break;
92195                 case ts.FileIncludeKind.ReferenceFile:
92196                     ts.Debug.assert(!referenceLocation.packageId);
92197                     message = ts.Diagnostics.Referenced_via_0_from_file_1;
92198                     break;
92199                 case ts.FileIncludeKind.TypeReferenceDirective:
92200                     message = referenceLocation.packageId ?
92201                         ts.Diagnostics.Type_library_referenced_via_0_from_file_1_with_packageId_2 :
92202                         ts.Diagnostics.Type_library_referenced_via_0_from_file_1;
92203                     break;
92204                 case ts.FileIncludeKind.LibReferenceDirective:
92205                     ts.Debug.assert(!referenceLocation.packageId);
92206                     message = ts.Diagnostics.Library_referenced_via_0_from_file_1;
92207                     break;
92208                 default:
92209                     ts.Debug.assertNever(reason);
92210             }
92211             return ts.chainDiagnosticMessages(undefined, message, referenceText, toFileName(referenceLocation.file, fileNameConvertor), referenceLocation.packageId && ts.packageIdToString(referenceLocation.packageId));
92212         }
92213         switch (reason.kind) {
92214             case ts.FileIncludeKind.RootFile:
92215                 if (!((_a = options.configFile) === null || _a === void 0 ? void 0 : _a.configFileSpecs))
92216                     return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Root_file_specified_for_compilation);
92217                 var fileName = ts.getNormalizedAbsolutePath(program.getRootFileNames()[reason.index], program.getCurrentDirectory());
92218                 var matchedByFiles = getMatchedFileSpec(program, fileName);
92219                 if (matchedByFiles)
92220                     return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Part_of_files_list_in_tsconfig_json);
92221                 var matchedByInclude = getMatchedIncludeSpec(program, fileName);
92222                 return matchedByInclude ?
92223                     ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Matched_by_include_pattern_0_in_1, matchedByInclude, toFileName(options.configFile, fileNameConvertor)) :
92224                     ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Root_file_specified_for_compilation);
92225             case ts.FileIncludeKind.SourceFromProjectReference:
92226             case ts.FileIncludeKind.OutputFromProjectReference:
92227                 var isOutput = reason.kind === ts.FileIncludeKind.OutputFromProjectReference;
92228                 var referencedResolvedRef = ts.Debug.checkDefined((_b = program.getResolvedProjectReferences()) === null || _b === void 0 ? void 0 : _b[reason.index]);
92229                 return ts.chainDiagnosticMessages(undefined, ts.outFile(options) ?
92230                     isOutput ?
92231                         ts.Diagnostics.Output_from_referenced_project_0_included_because_1_specified :
92232                         ts.Diagnostics.Source_from_referenced_project_0_included_because_1_specified :
92233                     isOutput ?
92234                         ts.Diagnostics.Output_from_referenced_project_0_included_because_module_is_specified_as_none :
92235                         ts.Diagnostics.Source_from_referenced_project_0_included_because_module_is_specified_as_none, toFileName(referencedResolvedRef.sourceFile.fileName, fileNameConvertor), options.outFile ? "--outFile" : "--out");
92236             case ts.FileIncludeKind.AutomaticTypeDirectiveFile:
92237                 return ts.chainDiagnosticMessages(undefined, options.types ?
92238                     reason.packageId ?
92239                         ts.Diagnostics.Entry_point_of_type_library_0_specified_in_compilerOptions_with_packageId_1 :
92240                         ts.Diagnostics.Entry_point_of_type_library_0_specified_in_compilerOptions :
92241                     reason.packageId ?
92242                         ts.Diagnostics.Entry_point_for_implicit_type_library_0_with_packageId_1 :
92243                         ts.Diagnostics.Entry_point_for_implicit_type_library_0, reason.typeReference, reason.packageId && ts.packageIdToString(reason.packageId));
92244             case ts.FileIncludeKind.LibFile:
92245                 if (reason.index !== undefined)
92246                     return ts.chainDiagnosticMessages(undefined, ts.Diagnostics.Library_0_specified_in_compilerOptions, options.lib[reason.index]);
92247                 var target = ts.forEachEntry(ts.targetOptionDeclaration.type, function (value, key) { return value === options.target ? key : undefined; });
92248                 return ts.chainDiagnosticMessages(undefined, target ?
92249                     ts.Diagnostics.Default_library_for_target_0 :
92250                     ts.Diagnostics.Default_library, target);
92251             default:
92252                 ts.Debug.assertNever(reason);
92253         }
92254     }
92255     ts.fileIncludeReasonToDiagnostics = fileIncludeReasonToDiagnostics;
92256     function toFileName(file, fileNameConvertor) {
92257         var fileName = ts.isString(file) ? file : file.fileName;
92258         return fileNameConvertor ? fileNameConvertor(fileName) : fileName;
92259     }
92260     function emitFilesAndReportErrors(program, reportDiagnostic, write, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
92261         var isListFilesOnly = !!program.getCompilerOptions().listFilesOnly;
92262         var allDiagnostics = program.getConfigFileParsingDiagnostics().slice();
92263         var configFileParsingDiagnosticsLength = allDiagnostics.length;
92264         ts.addRange(allDiagnostics, program.getSyntacticDiagnostics(undefined, cancellationToken));
92265         if (allDiagnostics.length === configFileParsingDiagnosticsLength) {
92266             ts.addRange(allDiagnostics, program.getOptionsDiagnostics(cancellationToken));
92267             if (!isListFilesOnly) {
92268                 ts.addRange(allDiagnostics, program.getGlobalDiagnostics(cancellationToken));
92269                 if (allDiagnostics.length === configFileParsingDiagnosticsLength) {
92270                     ts.addRange(allDiagnostics, program.getSemanticDiagnostics(undefined, cancellationToken));
92271                 }
92272             }
92273         }
92274         var emitResult = isListFilesOnly
92275             ? { emitSkipped: true, diagnostics: ts.emptyArray }
92276             : program.emit(undefined, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers);
92277         var emittedFiles = emitResult.emittedFiles, emitDiagnostics = emitResult.diagnostics;
92278         ts.addRange(allDiagnostics, emitDiagnostics);
92279         var diagnostics = ts.sortAndDeduplicateDiagnostics(allDiagnostics);
92280         diagnostics.forEach(reportDiagnostic);
92281         if (write) {
92282             var currentDir_1 = program.getCurrentDirectory();
92283             ts.forEach(emittedFiles, function (file) {
92284                 var filepath = ts.getNormalizedAbsolutePath(file, currentDir_1);
92285                 write("TSFILE: " + filepath);
92286             });
92287             listFiles(program, write);
92288         }
92289         if (reportSummary) {
92290             reportSummary(getErrorCountForSummary(diagnostics));
92291         }
92292         return {
92293             emitResult: emitResult,
92294             diagnostics: diagnostics,
92295         };
92296     }
92297     ts.emitFilesAndReportErrors = emitFilesAndReportErrors;
92298     function emitFilesAndReportErrorsAndGetExitStatus(program, reportDiagnostic, write, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
92299         var _a = emitFilesAndReportErrors(program, reportDiagnostic, write, reportSummary, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers), emitResult = _a.emitResult, diagnostics = _a.diagnostics;
92300         if (emitResult.emitSkipped && diagnostics.length > 0) {
92301             return ts.ExitStatus.DiagnosticsPresent_OutputsSkipped;
92302         }
92303         else if (diagnostics.length > 0) {
92304             return ts.ExitStatus.DiagnosticsPresent_OutputsGenerated;
92305         }
92306         return ts.ExitStatus.Success;
92307     }
92308     ts.emitFilesAndReportErrorsAndGetExitStatus = emitFilesAndReportErrorsAndGetExitStatus;
92309     ts.noopFileWatcher = { close: ts.noop };
92310     ts.returnNoopFileWatcher = function () { return ts.noopFileWatcher; };
92311     function createWatchHost(system, reportWatchStatus) {
92312         if (system === void 0) { system = ts.sys; }
92313         var onWatchStatusChange = reportWatchStatus || createWatchStatusReporter(system);
92314         return {
92315             onWatchStatusChange: onWatchStatusChange,
92316             watchFile: ts.maybeBind(system, system.watchFile) || ts.returnNoopFileWatcher,
92317             watchDirectory: ts.maybeBind(system, system.watchDirectory) || ts.returnNoopFileWatcher,
92318             setTimeout: ts.maybeBind(system, system.setTimeout) || ts.noop,
92319             clearTimeout: ts.maybeBind(system, system.clearTimeout) || ts.noop
92320         };
92321     }
92322     ts.createWatchHost = createWatchHost;
92323     ts.WatchType = {
92324         ConfigFile: "Config file",
92325         ExtendedConfigFile: "Extended config file",
92326         SourceFile: "Source file",
92327         MissingFile: "Missing file",
92328         WildcardDirectory: "Wild card directory",
92329         FailedLookupLocations: "Failed Lookup Locations",
92330         TypeRoots: "Type roots"
92331     };
92332     function createWatchFactory(host, options) {
92333         var watchLogLevel = host.trace ? options.extendedDiagnostics ? ts.WatchLogLevel.Verbose : options.diagnostics ? ts.WatchLogLevel.TriggerOnly : ts.WatchLogLevel.None : ts.WatchLogLevel.None;
92334         var writeLog = watchLogLevel !== ts.WatchLogLevel.None ? (function (s) { return host.trace(s); }) : ts.noop;
92335         var result = ts.getWatchFactory(host, watchLogLevel, writeLog);
92336         result.writeLog = writeLog;
92337         return result;
92338     }
92339     ts.createWatchFactory = createWatchFactory;
92340     function createCompilerHostFromProgramHost(host, getCompilerOptions, directoryStructureHost) {
92341         if (directoryStructureHost === void 0) { directoryStructureHost = host; }
92342         var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
92343         var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); });
92344         return {
92345             getSourceFile: function (fileName, languageVersion, onError) {
92346                 var text;
92347                 try {
92348                     ts.performance.mark("beforeIORead");
92349                     text = host.readFile(fileName, getCompilerOptions().charset);
92350                     ts.performance.mark("afterIORead");
92351                     ts.performance.measure("I/O Read", "beforeIORead", "afterIORead");
92352                 }
92353                 catch (e) {
92354                     if (onError) {
92355                         onError(e.message);
92356                     }
92357                     text = "";
92358                 }
92359                 return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion) : undefined;
92360             },
92361             getDefaultLibLocation: ts.maybeBind(host, host.getDefaultLibLocation),
92362             getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); },
92363             writeFile: writeFile,
92364             getCurrentDirectory: ts.memoize(function () { return host.getCurrentDirectory(); }),
92365             useCaseSensitiveFileNames: function () { return useCaseSensitiveFileNames; },
92366             getCanonicalFileName: ts.createGetCanonicalFileName(useCaseSensitiveFileNames),
92367             getNewLine: function () { return ts.getNewLineCharacter(getCompilerOptions(), hostGetNewLine); },
92368             fileExists: function (f) { return host.fileExists(f); },
92369             readFile: function (f) { return host.readFile(f); },
92370             trace: ts.maybeBind(host, host.trace),
92371             directoryExists: ts.maybeBind(directoryStructureHost, directoryStructureHost.directoryExists),
92372             getDirectories: ts.maybeBind(directoryStructureHost, directoryStructureHost.getDirectories),
92373             realpath: ts.maybeBind(host, host.realpath),
92374             getEnvironmentVariable: ts.maybeBind(host, host.getEnvironmentVariable) || (function () { return ""; }),
92375             createHash: ts.maybeBind(host, host.createHash),
92376             readDirectory: ts.maybeBind(host, host.readDirectory),
92377         };
92378         function writeFile(fileName, text, writeByteOrderMark, onError) {
92379             try {
92380                 ts.performance.mark("beforeIOWrite");
92381                 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); });
92382                 ts.performance.mark("afterIOWrite");
92383                 ts.performance.measure("I/O Write", "beforeIOWrite", "afterIOWrite");
92384             }
92385             catch (e) {
92386                 if (onError) {
92387                     onError(e.message);
92388                 }
92389             }
92390         }
92391     }
92392     ts.createCompilerHostFromProgramHost = createCompilerHostFromProgramHost;
92393     function setGetSourceFileAsHashVersioned(compilerHost, host) {
92394         var originalGetSourceFile = compilerHost.getSourceFile;
92395         var computeHash = ts.maybeBind(host, host.createHash) || ts.generateDjb2Hash;
92396         compilerHost.getSourceFile = function () {
92397             var args = [];
92398             for (var _i = 0; _i < arguments.length; _i++) {
92399                 args[_i] = arguments[_i];
92400             }
92401             var result = originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArray([compilerHost], args));
92402             if (result) {
92403                 result.version = computeHash(result.text);
92404             }
92405             return result;
92406         };
92407     }
92408     ts.setGetSourceFileAsHashVersioned = setGetSourceFileAsHashVersioned;
92409     function createProgramHost(system, createProgram) {
92410         var getDefaultLibLocation = ts.memoize(function () { return ts.getDirectoryPath(ts.normalizePath(system.getExecutingFilePath())); });
92411         return {
92412             useCaseSensitiveFileNames: function () { return system.useCaseSensitiveFileNames; },
92413             getNewLine: function () { return system.newLine; },
92414             getCurrentDirectory: ts.memoize(function () { return system.getCurrentDirectory(); }),
92415             getDefaultLibLocation: getDefaultLibLocation,
92416             getDefaultLibFileName: function (options) { return ts.combinePaths(getDefaultLibLocation(), ts.getDefaultLibFileName(options)); },
92417             fileExists: function (path) { return system.fileExists(path); },
92418             readFile: function (path, encoding) { return system.readFile(path, encoding); },
92419             directoryExists: function (path) { return system.directoryExists(path); },
92420             getDirectories: function (path) { return system.getDirectories(path); },
92421             readDirectory: function (path, extensions, exclude, include, depth) { return system.readDirectory(path, extensions, exclude, include, depth); },
92422             realpath: ts.maybeBind(system, system.realpath),
92423             getEnvironmentVariable: ts.maybeBind(system, system.getEnvironmentVariable),
92424             trace: function (s) { return system.write(s + system.newLine); },
92425             createDirectory: function (path) { return system.createDirectory(path); },
92426             writeFile: function (path, data, writeByteOrderMark) { return system.writeFile(path, data, writeByteOrderMark); },
92427             createHash: ts.maybeBind(system, system.createHash),
92428             createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram
92429         };
92430     }
92431     ts.createProgramHost = createProgramHost;
92432     function createWatchCompilerHost(system, createProgram, reportDiagnostic, reportWatchStatus) {
92433         if (system === void 0) { system = ts.sys; }
92434         var write = function (s) { return system.write(s + system.newLine); };
92435         var result = createProgramHost(system, createProgram);
92436         ts.copyProperties(result, createWatchHost(system, reportWatchStatus));
92437         result.afterProgramCreate = function (builderProgram) {
92438             var compilerOptions = builderProgram.getCompilerOptions();
92439             var newLine = ts.getNewLineCharacter(compilerOptions, function () { return system.newLine; });
92440             emitFilesAndReportErrors(builderProgram, reportDiagnostic, write, function (errorCount) { return result.onWatchStatusChange(ts.createCompilerDiagnostic(getWatchErrorSummaryDiagnosticMessage(errorCount), errorCount), newLine, compilerOptions, errorCount); });
92441         };
92442         return result;
92443     }
92444     function reportUnrecoverableDiagnostic(system, reportDiagnostic, diagnostic) {
92445         reportDiagnostic(diagnostic);
92446         system.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
92447     }
92448     function createWatchCompilerHostOfConfigFile(_a) {
92449         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;
92450         var diagnosticReporter = reportDiagnostic || createDiagnosticReporter(system);
92451         var host = createWatchCompilerHost(system, createProgram, diagnosticReporter, reportWatchStatus);
92452         host.onUnRecoverableConfigFileDiagnostic = function (diagnostic) { return reportUnrecoverableDiagnostic(system, diagnosticReporter, diagnostic); };
92453         host.configFileName = configFileName;
92454         host.optionsToExtend = optionsToExtend;
92455         host.watchOptionsToExtend = watchOptionsToExtend;
92456         host.extraFileExtensions = extraFileExtensions;
92457         return host;
92458     }
92459     ts.createWatchCompilerHostOfConfigFile = createWatchCompilerHostOfConfigFile;
92460     function createWatchCompilerHostOfFilesAndCompilerOptions(_a) {
92461         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;
92462         var host = createWatchCompilerHost(system, createProgram, reportDiagnostic || createDiagnosticReporter(system), reportWatchStatus);
92463         host.rootFiles = rootFiles;
92464         host.options = options;
92465         host.watchOptions = watchOptions;
92466         host.projectReferences = projectReferences;
92467         return host;
92468     }
92469     ts.createWatchCompilerHostOfFilesAndCompilerOptions = createWatchCompilerHostOfFilesAndCompilerOptions;
92470     function performIncrementalCompilation(input) {
92471         var system = input.system || ts.sys;
92472         var host = input.host || (input.host = ts.createIncrementalCompilerHost(input.options, system));
92473         var builderProgram = ts.createIncrementalProgram(input);
92474         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);
92475         if (input.afterProgramEmitAndDiagnostics)
92476             input.afterProgramEmitAndDiagnostics(builderProgram);
92477         return exitStatus;
92478     }
92479     ts.performIncrementalCompilation = performIncrementalCompilation;
92480 })(ts || (ts = {}));
92481 var ts;
92482 (function (ts) {
92483     function readBuilderProgram(compilerOptions, host) {
92484         if (ts.outFile(compilerOptions))
92485             return undefined;
92486         var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(compilerOptions);
92487         if (!buildInfoPath)
92488             return undefined;
92489         var content = host.readFile(buildInfoPath);
92490         if (!content)
92491             return undefined;
92492         var buildInfo = ts.getBuildInfo(content);
92493         if (buildInfo.version !== ts.version)
92494             return undefined;
92495         if (!buildInfo.program)
92496             return undefined;
92497         return ts.createBuildProgramUsingProgramBuildInfo(buildInfo.program, buildInfoPath, host);
92498     }
92499     ts.readBuilderProgram = readBuilderProgram;
92500     function createIncrementalCompilerHost(options, system) {
92501         if (system === void 0) { system = ts.sys; }
92502         var host = ts.createCompilerHostWorker(options, undefined, system);
92503         host.createHash = ts.maybeBind(system, system.createHash);
92504         ts.setGetSourceFileAsHashVersioned(host, system);
92505         ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
92506         return host;
92507     }
92508     ts.createIncrementalCompilerHost = createIncrementalCompilerHost;
92509     function createIncrementalProgram(_a) {
92510         var rootNames = _a.rootNames, options = _a.options, configFileParsingDiagnostics = _a.configFileParsingDiagnostics, projectReferences = _a.projectReferences, host = _a.host, createProgram = _a.createProgram;
92511         host = host || createIncrementalCompilerHost(options);
92512         createProgram = createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram;
92513         var oldProgram = readBuilderProgram(options, host);
92514         return createProgram(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences);
92515     }
92516     ts.createIncrementalProgram = createIncrementalProgram;
92517     function createWatchCompilerHost(rootFilesOrConfigFileName, options, system, createProgram, reportDiagnostic, reportWatchStatus, projectReferencesOrWatchOptionsToExtend, watchOptionsOrExtraFileExtensions) {
92518         if (ts.isArray(rootFilesOrConfigFileName)) {
92519             return ts.createWatchCompilerHostOfFilesAndCompilerOptions({
92520                 rootFiles: rootFilesOrConfigFileName,
92521                 options: options,
92522                 watchOptions: watchOptionsOrExtraFileExtensions,
92523                 projectReferences: projectReferencesOrWatchOptionsToExtend,
92524                 system: system,
92525                 createProgram: createProgram,
92526                 reportDiagnostic: reportDiagnostic,
92527                 reportWatchStatus: reportWatchStatus,
92528             });
92529         }
92530         else {
92531             return ts.createWatchCompilerHostOfConfigFile({
92532                 configFileName: rootFilesOrConfigFileName,
92533                 optionsToExtend: options,
92534                 watchOptionsToExtend: projectReferencesOrWatchOptionsToExtend,
92535                 extraFileExtensions: watchOptionsOrExtraFileExtensions,
92536                 system: system,
92537                 createProgram: createProgram,
92538                 reportDiagnostic: reportDiagnostic,
92539                 reportWatchStatus: reportWatchStatus,
92540             });
92541         }
92542     }
92543     ts.createWatchCompilerHost = createWatchCompilerHost;
92544     function createWatchProgram(host) {
92545         var builderProgram;
92546         var reloadLevel;
92547         var extendedConfigFilesMap;
92548         var missingFilesMap;
92549         var watchedWildcardDirectories;
92550         var timerToUpdateProgram;
92551         var timerToInvalidateFailedLookupResolutions;
92552         var sourceFilesCache = new ts.Map();
92553         var missingFilePathsRequestedForRelease;
92554         var hasChangedCompilerOptions = false;
92555         var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
92556         var currentDirectory = host.getCurrentDirectory();
92557         var configFileName = host.configFileName, _a = host.optionsToExtend, optionsToExtendForConfigFile = _a === void 0 ? {} : _a, watchOptionsToExtend = host.watchOptionsToExtend, extraFileExtensions = host.extraFileExtensions, createProgram = host.createProgram;
92558         var rootFileNames = host.rootFiles, compilerOptions = host.options, watchOptions = host.watchOptions, projectReferences = host.projectReferences;
92559         var wildcardDirectories;
92560         var configFileParsingDiagnostics;
92561         var canConfigFileJsonReportNoInputFiles = false;
92562         var hasChangedConfigFileParsingErrors = false;
92563         var cachedDirectoryStructureHost = configFileName === undefined ? undefined : ts.createCachedDirectoryStructureHost(host, currentDirectory, useCaseSensitiveFileNames);
92564         var directoryStructureHost = cachedDirectoryStructureHost || host;
92565         var parseConfigFileHost = ts.parseConfigHostFromCompilerHostLike(host, directoryStructureHost);
92566         var newLine = updateNewLine();
92567         if (configFileName && host.configFileParsingResult) {
92568             setConfigFileParsingResult(host.configFileParsingResult);
92569             newLine = updateNewLine();
92570         }
92571         reportWatchDiagnostic(ts.Diagnostics.Starting_compilation_in_watch_mode);
92572         if (configFileName && !host.configFileParsingResult) {
92573             newLine = ts.getNewLineCharacter(optionsToExtendForConfigFile, function () { return host.getNewLine(); });
92574             ts.Debug.assert(!rootFileNames);
92575             parseConfigFile();
92576             newLine = updateNewLine();
92577         }
92578         var _b = ts.createWatchFactory(host, compilerOptions), watchFile = _b.watchFile, watchDirectory = _b.watchDirectory, writeLog = _b.writeLog;
92579         var getCanonicalFileName = ts.createGetCanonicalFileName(useCaseSensitiveFileNames);
92580         writeLog("Current directory: " + currentDirectory + " CaseSensitiveFileNames: " + useCaseSensitiveFileNames);
92581         var configFileWatcher;
92582         if (configFileName) {
92583             configFileWatcher = watchFile(configFileName, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ConfigFile);
92584         }
92585         var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return compilerOptions; }, directoryStructureHost);
92586         ts.setGetSourceFileAsHashVersioned(compilerHost, host);
92587         var getNewSourceFile = compilerHost.getSourceFile;
92588         compilerHost.getSourceFile = function (fileName) {
92589             var args = [];
92590             for (var _i = 1; _i < arguments.length; _i++) {
92591                 args[_i - 1] = arguments[_i];
92592             }
92593             return getVersionedSourceFileByPath.apply(void 0, __spreadArray([fileName, toPath(fileName)], args));
92594         };
92595         compilerHost.getSourceFileByPath = getVersionedSourceFileByPath;
92596         compilerHost.getNewLine = function () { return newLine; };
92597         compilerHost.fileExists = fileExists;
92598         compilerHost.onReleaseOldSourceFile = onReleaseOldSourceFile;
92599         compilerHost.toPath = toPath;
92600         compilerHost.getCompilationSettings = function () { return compilerOptions; };
92601         compilerHost.useSourceOfProjectReferenceRedirect = ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect);
92602         compilerHost.watchDirectoryOfFailedLookupLocation = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.FailedLookupLocations); };
92603         compilerHost.watchTypeRootsDirectory = function (dir, cb, flags) { return watchDirectory(dir, cb, flags, watchOptions, ts.WatchType.TypeRoots); };
92604         compilerHost.getCachedDirectoryStructureHost = function () { return cachedDirectoryStructureHost; };
92605         compilerHost.scheduleInvalidateResolutionsOfFailedLookupLocations = scheduleInvalidateResolutionsOfFailedLookupLocations;
92606         compilerHost.onInvalidatedResolution = scheduleProgramUpdate;
92607         compilerHost.onChangedAutomaticTypeDirectiveNames = scheduleProgramUpdate;
92608         compilerHost.fileIsOpen = ts.returnFalse;
92609         compilerHost.getCurrentProgram = getCurrentProgram;
92610         compilerHost.writeLog = writeLog;
92611         var resolutionCache = ts.createResolutionCache(compilerHost, configFileName ?
92612             ts.getDirectoryPath(ts.getNormalizedAbsolutePath(configFileName, currentDirectory)) :
92613             currentDirectory, false);
92614         compilerHost.resolveModuleNames = host.resolveModuleNames ?
92615             (function () {
92616                 var args = [];
92617                 for (var _i = 0; _i < arguments.length; _i++) {
92618                     args[_i] = arguments[_i];
92619                 }
92620                 return host.resolveModuleNames.apply(host, args);
92621             }) :
92622             (function (moduleNames, containingFile, reusedNames, redirectedReference) { return resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference); });
92623         compilerHost.resolveTypeReferenceDirectives = host.resolveTypeReferenceDirectives ?
92624             (function () {
92625                 var args = [];
92626                 for (var _i = 0; _i < arguments.length; _i++) {
92627                     args[_i] = arguments[_i];
92628                 }
92629                 return host.resolveTypeReferenceDirectives.apply(host, args);
92630             }) :
92631             (function (typeDirectiveNames, containingFile, redirectedReference) { return resolutionCache.resolveTypeReferenceDirectives(typeDirectiveNames, containingFile, redirectedReference); });
92632         var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
92633         builderProgram = readBuilderProgram(compilerOptions, compilerHost);
92634         synchronizeProgram();
92635         watchConfigFileWildCardDirectories();
92636         watchExtendedConfigFiles();
92637         return configFileName ?
92638             { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, close: close } :
92639             { getCurrentProgram: getCurrentBuilderProgram, getProgram: updateProgram, updateRootFileNames: updateRootFileNames, close: close };
92640         function close() {
92641             clearInvalidateResolutionsOfFailedLookupLocations();
92642             resolutionCache.clear();
92643             ts.clearMap(sourceFilesCache, function (value) {
92644                 if (value && value.fileWatcher) {
92645                     value.fileWatcher.close();
92646                     value.fileWatcher = undefined;
92647                 }
92648             });
92649             if (configFileWatcher) {
92650                 configFileWatcher.close();
92651                 configFileWatcher = undefined;
92652             }
92653             if (extendedConfigFilesMap) {
92654                 ts.clearMap(extendedConfigFilesMap, ts.closeFileWatcher);
92655                 extendedConfigFilesMap = undefined;
92656             }
92657             if (watchedWildcardDirectories) {
92658                 ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf);
92659                 watchedWildcardDirectories = undefined;
92660             }
92661             if (missingFilesMap) {
92662                 ts.clearMap(missingFilesMap, ts.closeFileWatcher);
92663                 missingFilesMap = undefined;
92664             }
92665         }
92666         function getCurrentBuilderProgram() {
92667             return builderProgram;
92668         }
92669         function getCurrentProgram() {
92670             return builderProgram && builderProgram.getProgramOrUndefined();
92671         }
92672         function synchronizeProgram() {
92673             writeLog("Synchronizing program");
92674             clearInvalidateResolutionsOfFailedLookupLocations();
92675             var program = getCurrentBuilderProgram();
92676             if (hasChangedCompilerOptions) {
92677                 newLine = updateNewLine();
92678                 if (program && ts.changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) {
92679                     resolutionCache.clear();
92680                 }
92681             }
92682             var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
92683             if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, projectReferences)) {
92684                 if (hasChangedConfigFileParsingErrors) {
92685                     builderProgram = createProgram(undefined, undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
92686                     hasChangedConfigFileParsingErrors = false;
92687                 }
92688             }
92689             else {
92690                 createNewProgram(hasInvalidatedResolution);
92691             }
92692             if (host.afterProgramCreate && program !== builderProgram) {
92693                 host.afterProgramCreate(builderProgram);
92694             }
92695             return builderProgram;
92696         }
92697         function createNewProgram(hasInvalidatedResolution) {
92698             writeLog("CreatingProgramWith::");
92699             writeLog("  roots: " + JSON.stringify(rootFileNames));
92700             writeLog("  options: " + JSON.stringify(compilerOptions));
92701             var needsUpdateInTypeRootWatch = hasChangedCompilerOptions || !getCurrentProgram();
92702             hasChangedCompilerOptions = false;
92703             hasChangedConfigFileParsingErrors = false;
92704             resolutionCache.startCachingPerDirectoryResolution();
92705             compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
92706             compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
92707             builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
92708             resolutionCache.finishCachingPerDirectoryResolution();
92709             ts.updateMissingFilePathsWatch(builderProgram.getProgram(), missingFilesMap || (missingFilesMap = new ts.Map()), watchMissingFilePath);
92710             if (needsUpdateInTypeRootWatch) {
92711                 resolutionCache.updateTypeRootsWatch();
92712             }
92713             if (missingFilePathsRequestedForRelease) {
92714                 for (var _i = 0, missingFilePathsRequestedForRelease_1 = missingFilePathsRequestedForRelease; _i < missingFilePathsRequestedForRelease_1.length; _i++) {
92715                     var missingFilePath = missingFilePathsRequestedForRelease_1[_i];
92716                     if (!missingFilesMap.has(missingFilePath)) {
92717                         sourceFilesCache.delete(missingFilePath);
92718                     }
92719                 }
92720                 missingFilePathsRequestedForRelease = undefined;
92721             }
92722         }
92723         function updateRootFileNames(files) {
92724             ts.Debug.assert(!configFileName, "Cannot update root file names with config file watch mode");
92725             rootFileNames = files;
92726             scheduleProgramUpdate();
92727         }
92728         function updateNewLine() {
92729             return ts.getNewLineCharacter(compilerOptions || optionsToExtendForConfigFile, function () { return host.getNewLine(); });
92730         }
92731         function toPath(fileName) {
92732             return ts.toPath(fileName, currentDirectory, getCanonicalFileName);
92733         }
92734         function isFileMissingOnHost(hostSourceFile) {
92735             return typeof hostSourceFile === "boolean";
92736         }
92737         function isFilePresenceUnknownOnHost(hostSourceFile) {
92738             return typeof hostSourceFile.version === "boolean";
92739         }
92740         function fileExists(fileName) {
92741             var path = toPath(fileName);
92742             if (isFileMissingOnHost(sourceFilesCache.get(path))) {
92743                 return false;
92744             }
92745             return directoryStructureHost.fileExists(fileName);
92746         }
92747         function getVersionedSourceFileByPath(fileName, path, languageVersion, onError, shouldCreateNewSourceFile) {
92748             var hostSourceFile = sourceFilesCache.get(path);
92749             if (isFileMissingOnHost(hostSourceFile)) {
92750                 return undefined;
92751             }
92752             if (hostSourceFile === undefined || shouldCreateNewSourceFile || isFilePresenceUnknownOnHost(hostSourceFile)) {
92753                 var sourceFile = getNewSourceFile(fileName, languageVersion, onError);
92754                 if (hostSourceFile) {
92755                     if (sourceFile) {
92756                         hostSourceFile.sourceFile = sourceFile;
92757                         hostSourceFile.version = sourceFile.version;
92758                         if (!hostSourceFile.fileWatcher) {
92759                             hostSourceFile.fileWatcher = watchFilePath(path, fileName, onSourceFileChange, ts.PollingInterval.Low, watchOptions, ts.WatchType.SourceFile);
92760                         }
92761                     }
92762                     else {
92763                         if (hostSourceFile.fileWatcher) {
92764                             hostSourceFile.fileWatcher.close();
92765                         }
92766                         sourceFilesCache.set(path, false);
92767                     }
92768                 }
92769                 else {
92770                     if (sourceFile) {
92771                         var fileWatcher = watchFilePath(path, fileName, onSourceFileChange, ts.PollingInterval.Low, watchOptions, ts.WatchType.SourceFile);
92772                         sourceFilesCache.set(path, { sourceFile: sourceFile, version: sourceFile.version, fileWatcher: fileWatcher });
92773                     }
92774                     else {
92775                         sourceFilesCache.set(path, false);
92776                     }
92777                 }
92778                 return sourceFile;
92779             }
92780             return hostSourceFile.sourceFile;
92781         }
92782         function nextSourceFileVersion(path) {
92783             var hostSourceFile = sourceFilesCache.get(path);
92784             if (hostSourceFile !== undefined) {
92785                 if (isFileMissingOnHost(hostSourceFile)) {
92786                     sourceFilesCache.set(path, { version: false });
92787                 }
92788                 else {
92789                     hostSourceFile.version = false;
92790                 }
92791             }
92792         }
92793         function getSourceVersion(path) {
92794             var hostSourceFile = sourceFilesCache.get(path);
92795             return !hostSourceFile || !hostSourceFile.version ? undefined : hostSourceFile.version;
92796         }
92797         function onReleaseOldSourceFile(oldSourceFile, _oldOptions, hasSourceFileByPath) {
92798             var hostSourceFileInfo = sourceFilesCache.get(oldSourceFile.resolvedPath);
92799             if (hostSourceFileInfo !== undefined) {
92800                 if (isFileMissingOnHost(hostSourceFileInfo)) {
92801                     (missingFilePathsRequestedForRelease || (missingFilePathsRequestedForRelease = [])).push(oldSourceFile.path);
92802                 }
92803                 else if (hostSourceFileInfo.sourceFile === oldSourceFile) {
92804                     if (hostSourceFileInfo.fileWatcher) {
92805                         hostSourceFileInfo.fileWatcher.close();
92806                     }
92807                     sourceFilesCache.delete(oldSourceFile.resolvedPath);
92808                     if (!hasSourceFileByPath) {
92809                         resolutionCache.removeResolutionsOfFile(oldSourceFile.path);
92810                     }
92811                 }
92812             }
92813         }
92814         function reportWatchDiagnostic(message) {
92815             if (host.onWatchStatusChange) {
92816                 host.onWatchStatusChange(ts.createCompilerDiagnostic(message), newLine, compilerOptions || optionsToExtendForConfigFile);
92817             }
92818         }
92819         function hasChangedAutomaticTypeDirectiveNames() {
92820             return resolutionCache.hasChangedAutomaticTypeDirectiveNames();
92821         }
92822         function clearInvalidateResolutionsOfFailedLookupLocations() {
92823             if (!timerToInvalidateFailedLookupResolutions)
92824                 return false;
92825             host.clearTimeout(timerToInvalidateFailedLookupResolutions);
92826             timerToInvalidateFailedLookupResolutions = undefined;
92827             return true;
92828         }
92829         function scheduleInvalidateResolutionsOfFailedLookupLocations() {
92830             if (!host.setTimeout || !host.clearTimeout) {
92831                 return resolutionCache.invalidateResolutionsOfFailedLookupLocations();
92832             }
92833             var pending = clearInvalidateResolutionsOfFailedLookupLocations();
92834             writeLog("Scheduling invalidateFailedLookup" + (pending ? ", Cancelled earlier one" : ""));
92835             timerToInvalidateFailedLookupResolutions = host.setTimeout(invalidateResolutionsOfFailedLookup, 250);
92836         }
92837         function invalidateResolutionsOfFailedLookup() {
92838             timerToInvalidateFailedLookupResolutions = undefined;
92839             if (resolutionCache.invalidateResolutionsOfFailedLookupLocations()) {
92840                 scheduleProgramUpdate();
92841             }
92842         }
92843         function scheduleProgramUpdate() {
92844             if (!host.setTimeout || !host.clearTimeout) {
92845                 return;
92846             }
92847             if (timerToUpdateProgram) {
92848                 host.clearTimeout(timerToUpdateProgram);
92849             }
92850             writeLog("Scheduling update");
92851             timerToUpdateProgram = host.setTimeout(updateProgramWithWatchStatus, 250);
92852         }
92853         function scheduleProgramReload() {
92854             ts.Debug.assert(!!configFileName);
92855             reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
92856             scheduleProgramUpdate();
92857         }
92858         function updateProgramWithWatchStatus() {
92859             timerToUpdateProgram = undefined;
92860             reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
92861             updateProgram();
92862         }
92863         function updateProgram() {
92864             switch (reloadLevel) {
92865                 case ts.ConfigFileProgramReloadLevel.Partial:
92866                     ts.perfLogger.logStartUpdateProgram("PartialConfigReload");
92867                     reloadFileNamesFromConfigFile();
92868                     break;
92869                 case ts.ConfigFileProgramReloadLevel.Full:
92870                     ts.perfLogger.logStartUpdateProgram("FullConfigReload");
92871                     reloadConfigFile();
92872                     break;
92873                 default:
92874                     ts.perfLogger.logStartUpdateProgram("SynchronizeProgram");
92875                     synchronizeProgram();
92876                     break;
92877             }
92878             ts.perfLogger.logStopUpdateProgram("Done");
92879             return getCurrentBuilderProgram();
92880         }
92881         function reloadFileNamesFromConfigFile() {
92882             writeLog("Reloading new file names and options");
92883             rootFileNames = ts.getFileNamesFromConfigSpecs(compilerOptions.configFile.configFileSpecs, ts.getNormalizedAbsolutePath(ts.getDirectoryPath(configFileName), currentDirectory), compilerOptions, parseConfigFileHost, extraFileExtensions);
92884             if (ts.updateErrorForNoInputFiles(rootFileNames, ts.getNormalizedAbsolutePath(configFileName, currentDirectory), compilerOptions.configFile.configFileSpecs, configFileParsingDiagnostics, canConfigFileJsonReportNoInputFiles)) {
92885                 hasChangedConfigFileParsingErrors = true;
92886             }
92887             synchronizeProgram();
92888         }
92889         function reloadConfigFile() {
92890             writeLog("Reloading config file: " + configFileName);
92891             reloadLevel = ts.ConfigFileProgramReloadLevel.None;
92892             if (cachedDirectoryStructureHost) {
92893                 cachedDirectoryStructureHost.clearCache();
92894             }
92895             parseConfigFile();
92896             hasChangedCompilerOptions = true;
92897             synchronizeProgram();
92898             watchConfigFileWildCardDirectories();
92899             watchExtendedConfigFiles();
92900         }
92901         function parseConfigFile() {
92902             setConfigFileParsingResult(ts.getParsedCommandLineOfConfigFile(configFileName, optionsToExtendForConfigFile, parseConfigFileHost, undefined, watchOptionsToExtend, extraFileExtensions));
92903         }
92904         function setConfigFileParsingResult(configFileParseResult) {
92905             rootFileNames = configFileParseResult.fileNames;
92906             compilerOptions = configFileParseResult.options;
92907             watchOptions = configFileParseResult.watchOptions;
92908             projectReferences = configFileParseResult.projectReferences;
92909             wildcardDirectories = configFileParseResult.wildcardDirectories;
92910             configFileParsingDiagnostics = ts.getConfigFileParsingDiagnostics(configFileParseResult).slice();
92911             canConfigFileJsonReportNoInputFiles = ts.canJsonReportNoInputFiles(configFileParseResult.raw);
92912             hasChangedConfigFileParsingErrors = true;
92913         }
92914         function watchFilePath(path, file, callback, pollingInterval, options, watchType) {
92915             return watchFile(file, function (fileName, eventKind) { return callback(fileName, eventKind, path); }, pollingInterval, options, watchType);
92916         }
92917         function onSourceFileChange(fileName, eventKind, path) {
92918             updateCachedSystemWithFile(fileName, path, eventKind);
92919             if (eventKind === ts.FileWatcherEventKind.Deleted && sourceFilesCache.has(path)) {
92920                 resolutionCache.invalidateResolutionOfFile(path);
92921             }
92922             resolutionCache.removeResolutionsFromProjectReferenceRedirects(path);
92923             nextSourceFileVersion(path);
92924             scheduleProgramUpdate();
92925         }
92926         function updateCachedSystemWithFile(fileName, path, eventKind) {
92927             if (cachedDirectoryStructureHost) {
92928                 cachedDirectoryStructureHost.addOrDeleteFile(fileName, path, eventKind);
92929             }
92930         }
92931         function watchMissingFilePath(missingFilePath) {
92932             return watchFilePath(missingFilePath, missingFilePath, onMissingFileChange, ts.PollingInterval.Medium, watchOptions, ts.WatchType.MissingFile);
92933         }
92934         function onMissingFileChange(fileName, eventKind, missingFilePath) {
92935             updateCachedSystemWithFile(fileName, missingFilePath, eventKind);
92936             if (eventKind === ts.FileWatcherEventKind.Created && missingFilesMap.has(missingFilePath)) {
92937                 missingFilesMap.get(missingFilePath).close();
92938                 missingFilesMap.delete(missingFilePath);
92939                 nextSourceFileVersion(missingFilePath);
92940                 scheduleProgramUpdate();
92941             }
92942         }
92943         function watchConfigFileWildCardDirectories() {
92944             if (wildcardDirectories) {
92945                 ts.updateWatchingWildcardDirectories(watchedWildcardDirectories || (watchedWildcardDirectories = new ts.Map()), new ts.Map(ts.getEntries(wildcardDirectories)), watchWildcardDirectory);
92946             }
92947             else if (watchedWildcardDirectories) {
92948                 ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf);
92949             }
92950         }
92951         function watchWildcardDirectory(directory, flags) {
92952             return watchDirectory(directory, function (fileOrDirectory) {
92953                 ts.Debug.assert(!!configFileName);
92954                 var fileOrDirectoryPath = toPath(fileOrDirectory);
92955                 if (cachedDirectoryStructureHost) {
92956                     cachedDirectoryStructureHost.addOrDeleteFileOrDirectory(fileOrDirectory, fileOrDirectoryPath);
92957                 }
92958                 nextSourceFileVersion(fileOrDirectoryPath);
92959                 if (ts.isIgnoredFileFromWildCardWatching({
92960                     watchedDirPath: toPath(directory),
92961                     fileOrDirectory: fileOrDirectory,
92962                     fileOrDirectoryPath: fileOrDirectoryPath,
92963                     configFileName: configFileName,
92964                     extraFileExtensions: extraFileExtensions,
92965                     options: compilerOptions,
92966                     program: getCurrentBuilderProgram(),
92967                     currentDirectory: currentDirectory,
92968                     useCaseSensitiveFileNames: useCaseSensitiveFileNames,
92969                     writeLog: writeLog
92970                 }))
92971                     return;
92972                 if (reloadLevel !== ts.ConfigFileProgramReloadLevel.Full) {
92973                     reloadLevel = ts.ConfigFileProgramReloadLevel.Partial;
92974                     scheduleProgramUpdate();
92975                 }
92976             }, flags, watchOptions, ts.WatchType.WildcardDirectory);
92977         }
92978         function watchExtendedConfigFiles() {
92979             var _a;
92980             ts.mutateMap(extendedConfigFilesMap || (extendedConfigFilesMap = new ts.Map()), ts.arrayToMap(((_a = compilerOptions.configFile) === null || _a === void 0 ? void 0 : _a.extendedSourceFiles) || ts.emptyArray, toPath), {
92981                 createNewValue: watchExtendedConfigFile,
92982                 onDeleteValue: ts.closeFileWatcher
92983             });
92984         }
92985         function watchExtendedConfigFile(extendedConfigFile) {
92986             return watchFile(extendedConfigFile, scheduleProgramReload, ts.PollingInterval.High, watchOptions, ts.WatchType.ExtendedConfigFile);
92987         }
92988     }
92989     ts.createWatchProgram = createWatchProgram;
92990 })(ts || (ts = {}));
92991 var ts;
92992 (function (ts) {
92993     var UpToDateStatusType;
92994     (function (UpToDateStatusType) {
92995         UpToDateStatusType[UpToDateStatusType["Unbuildable"] = 0] = "Unbuildable";
92996         UpToDateStatusType[UpToDateStatusType["UpToDate"] = 1] = "UpToDate";
92997         UpToDateStatusType[UpToDateStatusType["UpToDateWithUpstreamTypes"] = 2] = "UpToDateWithUpstreamTypes";
92998         UpToDateStatusType[UpToDateStatusType["OutOfDateWithPrepend"] = 3] = "OutOfDateWithPrepend";
92999         UpToDateStatusType[UpToDateStatusType["OutputMissing"] = 4] = "OutputMissing";
93000         UpToDateStatusType[UpToDateStatusType["OutOfDateWithSelf"] = 5] = "OutOfDateWithSelf";
93001         UpToDateStatusType[UpToDateStatusType["OutOfDateWithUpstream"] = 6] = "OutOfDateWithUpstream";
93002         UpToDateStatusType[UpToDateStatusType["UpstreamOutOfDate"] = 7] = "UpstreamOutOfDate";
93003         UpToDateStatusType[UpToDateStatusType["UpstreamBlocked"] = 8] = "UpstreamBlocked";
93004         UpToDateStatusType[UpToDateStatusType["ComputingUpstream"] = 9] = "ComputingUpstream";
93005         UpToDateStatusType[UpToDateStatusType["TsVersionOutputOfDate"] = 10] = "TsVersionOutputOfDate";
93006         UpToDateStatusType[UpToDateStatusType["ContainerOnly"] = 11] = "ContainerOnly";
93007     })(UpToDateStatusType = ts.UpToDateStatusType || (ts.UpToDateStatusType = {}));
93008     function resolveConfigFileProjectName(project) {
93009         if (ts.fileExtensionIs(project, ".json")) {
93010             return project;
93011         }
93012         return ts.combinePaths(project, "tsconfig.json");
93013     }
93014     ts.resolveConfigFileProjectName = resolveConfigFileProjectName;
93015 })(ts || (ts = {}));
93016 var ts;
93017 (function (ts) {
93018     var minimumDate = new Date(-8640000000000000);
93019     var maximumDate = new Date(8640000000000000);
93020     var BuildResultFlags;
93021     (function (BuildResultFlags) {
93022         BuildResultFlags[BuildResultFlags["None"] = 0] = "None";
93023         BuildResultFlags[BuildResultFlags["Success"] = 1] = "Success";
93024         BuildResultFlags[BuildResultFlags["DeclarationOutputUnchanged"] = 2] = "DeclarationOutputUnchanged";
93025         BuildResultFlags[BuildResultFlags["ConfigFileErrors"] = 4] = "ConfigFileErrors";
93026         BuildResultFlags[BuildResultFlags["SyntaxErrors"] = 8] = "SyntaxErrors";
93027         BuildResultFlags[BuildResultFlags["TypeErrors"] = 16] = "TypeErrors";
93028         BuildResultFlags[BuildResultFlags["DeclarationEmitErrors"] = 32] = "DeclarationEmitErrors";
93029         BuildResultFlags[BuildResultFlags["EmitErrors"] = 64] = "EmitErrors";
93030         BuildResultFlags[BuildResultFlags["AnyErrors"] = 124] = "AnyErrors";
93031     })(BuildResultFlags || (BuildResultFlags = {}));
93032     function getOrCreateValueFromConfigFileMap(configFileMap, resolved, createT) {
93033         var existingValue = configFileMap.get(resolved);
93034         var newValue;
93035         if (!existingValue) {
93036             newValue = createT();
93037             configFileMap.set(resolved, newValue);
93038         }
93039         return existingValue || newValue;
93040     }
93041     function getOrCreateValueMapFromConfigFileMap(configFileMap, resolved) {
93042         return getOrCreateValueFromConfigFileMap(configFileMap, resolved, function () { return new ts.Map(); });
93043     }
93044     function newer(date1, date2) {
93045         return date2 > date1 ? date2 : date1;
93046     }
93047     function isDeclarationFile(fileName) {
93048         return ts.fileExtensionIs(fileName, ".d.ts");
93049     }
93050     function isCircularBuildOrder(buildOrder) {
93051         return !!buildOrder && !!buildOrder.buildOrder;
93052     }
93053     ts.isCircularBuildOrder = isCircularBuildOrder;
93054     function getBuildOrderFromAnyBuildOrder(anyBuildOrder) {
93055         return isCircularBuildOrder(anyBuildOrder) ? anyBuildOrder.buildOrder : anyBuildOrder;
93056     }
93057     ts.getBuildOrderFromAnyBuildOrder = getBuildOrderFromAnyBuildOrder;
93058     function createBuilderStatusReporter(system, pretty) {
93059         return function (diagnostic) {
93060             var output = pretty ? "[" + ts.formatColorAndReset(ts.getLocaleTimeString(system), ts.ForegroundColorEscapeSequences.Grey) + "] " : ts.getLocaleTimeString(system) + " - ";
93061             output += "" + ts.flattenDiagnosticMessageText(diagnostic.messageText, system.newLine) + (system.newLine + system.newLine);
93062             system.write(output);
93063         };
93064     }
93065     ts.createBuilderStatusReporter = createBuilderStatusReporter;
93066     function createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus) {
93067         var host = ts.createProgramHost(system, createProgram);
93068         host.getModifiedTime = system.getModifiedTime ? function (path) { return system.getModifiedTime(path); } : ts.returnUndefined;
93069         host.setModifiedTime = system.setModifiedTime ? function (path, date) { return system.setModifiedTime(path, date); } : ts.noop;
93070         host.deleteFile = system.deleteFile ? function (path) { return system.deleteFile(path); } : ts.noop;
93071         host.reportDiagnostic = reportDiagnostic || ts.createDiagnosticReporter(system);
93072         host.reportSolutionBuilderStatus = reportSolutionBuilderStatus || createBuilderStatusReporter(system);
93073         host.now = ts.maybeBind(system, system.now);
93074         return host;
93075     }
93076     function createSolutionBuilderHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportErrorSummary) {
93077         if (system === void 0) { system = ts.sys; }
93078         var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus);
93079         host.reportErrorSummary = reportErrorSummary;
93080         return host;
93081     }
93082     ts.createSolutionBuilderHost = createSolutionBuilderHost;
93083     function createSolutionBuilderWithWatchHost(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus, reportWatchStatus) {
93084         if (system === void 0) { system = ts.sys; }
93085         var host = createSolutionBuilderHostBase(system, createProgram, reportDiagnostic, reportSolutionBuilderStatus);
93086         var watchHost = ts.createWatchHost(system, reportWatchStatus);
93087         ts.copyProperties(host, watchHost);
93088         return host;
93089     }
93090     ts.createSolutionBuilderWithWatchHost = createSolutionBuilderWithWatchHost;
93091     function getCompilerOptionsOfBuildOptions(buildOptions) {
93092         var result = {};
93093         ts.commonOptionsWithBuild.forEach(function (option) {
93094             if (ts.hasProperty(buildOptions, option.name))
93095                 result[option.name] = buildOptions[option.name];
93096         });
93097         return result;
93098     }
93099     function createSolutionBuilder(host, rootNames, defaultOptions) {
93100         return createSolutionBuilderWorker(false, host, rootNames, defaultOptions);
93101     }
93102     ts.createSolutionBuilder = createSolutionBuilder;
93103     function createSolutionBuilderWithWatch(host, rootNames, defaultOptions, baseWatchOptions) {
93104         return createSolutionBuilderWorker(true, host, rootNames, defaultOptions, baseWatchOptions);
93105     }
93106     ts.createSolutionBuilderWithWatch = createSolutionBuilderWithWatch;
93107     function createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) {
93108         var host = hostOrHostWithWatch;
93109         var hostWithWatch = hostOrHostWithWatch;
93110         var currentDirectory = host.getCurrentDirectory();
93111         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
93112         var baseCompilerOptions = getCompilerOptionsOfBuildOptions(options);
93113         var compilerHost = ts.createCompilerHostFromProgramHost(host, function () { return state.projectCompilerOptions; });
93114         ts.setGetSourceFileAsHashVersioned(compilerHost, host);
93115         compilerHost.getParsedCommandLine = function (fileName) { return parseConfigFile(state, fileName, toResolvedConfigFilePath(state, fileName)); };
93116         compilerHost.resolveModuleNames = ts.maybeBind(host, host.resolveModuleNames);
93117         compilerHost.resolveTypeReferenceDirectives = ts.maybeBind(host, host.resolveTypeReferenceDirectives);
93118         var moduleResolutionCache = !compilerHost.resolveModuleNames ? ts.createModuleResolutionCache(currentDirectory, getCanonicalFileName) : undefined;
93119         if (!compilerHost.resolveModuleNames) {
93120             var loader_3 = function (moduleName, containingFile, redirectedReference) { return ts.resolveModuleName(moduleName, containingFile, state.projectCompilerOptions, compilerHost, moduleResolutionCache, redirectedReference).resolvedModule; };
93121             compilerHost.resolveModuleNames = function (moduleNames, containingFile, _reusedNames, redirectedReference) {
93122                 return ts.loadWithLocalCache(ts.Debug.checkEachDefined(moduleNames), containingFile, redirectedReference, loader_3);
93123             };
93124         }
93125         var _a = ts.createWatchFactory(hostWithWatch, options), watchFile = _a.watchFile, watchDirectory = _a.watchDirectory, writeLog = _a.writeLog;
93126         var state = {
93127             host: host,
93128             hostWithWatch: hostWithWatch,
93129             currentDirectory: currentDirectory,
93130             getCanonicalFileName: getCanonicalFileName,
93131             parseConfigFileHost: ts.parseConfigHostFromCompilerHostLike(host),
93132             write: ts.maybeBind(host, host.trace),
93133             options: options,
93134             baseCompilerOptions: baseCompilerOptions,
93135             rootNames: rootNames,
93136             baseWatchOptions: baseWatchOptions,
93137             resolvedConfigFilePaths: new ts.Map(),
93138             configFileCache: new ts.Map(),
93139             projectStatus: new ts.Map(),
93140             buildInfoChecked: new ts.Map(),
93141             extendedConfigCache: new ts.Map(),
93142             builderPrograms: new ts.Map(),
93143             diagnostics: new ts.Map(),
93144             projectPendingBuild: new ts.Map(),
93145             projectErrorsReported: new ts.Map(),
93146             compilerHost: compilerHost,
93147             moduleResolutionCache: moduleResolutionCache,
93148             buildOrder: undefined,
93149             readFileWithCache: function (f) { return host.readFile(f); },
93150             projectCompilerOptions: baseCompilerOptions,
93151             cache: undefined,
93152             allProjectBuildPending: true,
93153             needsSummary: true,
93154             watchAllProjectsPending: watch,
93155             currentInvalidatedProject: undefined,
93156             watch: watch,
93157             allWatchedWildcardDirectories: new ts.Map(),
93158             allWatchedInputFiles: new ts.Map(),
93159             allWatchedConfigFiles: new ts.Map(),
93160             allWatchedExtendedConfigFiles: new ts.Map(),
93161             timerToBuildInvalidatedProject: undefined,
93162             reportFileChangeDetected: false,
93163             watchFile: watchFile,
93164             watchDirectory: watchDirectory,
93165             writeLog: writeLog,
93166         };
93167         return state;
93168     }
93169     function toPath(state, fileName) {
93170         return ts.toPath(fileName, state.currentDirectory, state.getCanonicalFileName);
93171     }
93172     function toResolvedConfigFilePath(state, fileName) {
93173         var resolvedConfigFilePaths = state.resolvedConfigFilePaths;
93174         var path = resolvedConfigFilePaths.get(fileName);
93175         if (path !== undefined)
93176             return path;
93177         var resolvedPath = toPath(state, fileName);
93178         resolvedConfigFilePaths.set(fileName, resolvedPath);
93179         return resolvedPath;
93180     }
93181     function isParsedCommandLine(entry) {
93182         return !!entry.options;
93183     }
93184     function parseConfigFile(state, configFileName, configFilePath) {
93185         var configFileCache = state.configFileCache;
93186         var value = configFileCache.get(configFilePath);
93187         if (value) {
93188             return isParsedCommandLine(value) ? value : undefined;
93189         }
93190         var diagnostic;
93191         var parseConfigFileHost = state.parseConfigFileHost, baseCompilerOptions = state.baseCompilerOptions, baseWatchOptions = state.baseWatchOptions, extendedConfigCache = state.extendedConfigCache, host = state.host;
93192         var parsed;
93193         if (host.getParsedCommandLine) {
93194             parsed = host.getParsedCommandLine(configFileName);
93195             if (!parsed)
93196                 diagnostic = ts.createCompilerDiagnostic(ts.Diagnostics.File_0_not_found, configFileName);
93197         }
93198         else {
93199             parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = function (d) { return diagnostic = d; };
93200             parsed = ts.getParsedCommandLineOfConfigFile(configFileName, baseCompilerOptions, parseConfigFileHost, extendedConfigCache, baseWatchOptions);
93201             parseConfigFileHost.onUnRecoverableConfigFileDiagnostic = ts.noop;
93202         }
93203         configFileCache.set(configFilePath, parsed || diagnostic);
93204         return parsed;
93205     }
93206     function resolveProjectName(state, name) {
93207         return ts.resolveConfigFileProjectName(ts.resolvePath(state.currentDirectory, name));
93208     }
93209     function createBuildOrder(state, roots) {
93210         var temporaryMarks = new ts.Map();
93211         var permanentMarks = new ts.Map();
93212         var circularityReportStack = [];
93213         var buildOrder;
93214         var circularDiagnostics;
93215         for (var _i = 0, roots_1 = roots; _i < roots_1.length; _i++) {
93216             var root = roots_1[_i];
93217             visit(root);
93218         }
93219         return circularDiagnostics ?
93220             { buildOrder: buildOrder || ts.emptyArray, circularDiagnostics: circularDiagnostics } :
93221             buildOrder || ts.emptyArray;
93222         function visit(configFileName, inCircularContext) {
93223             var projPath = toResolvedConfigFilePath(state, configFileName);
93224             if (permanentMarks.has(projPath))
93225                 return;
93226             if (temporaryMarks.has(projPath)) {
93227                 if (!inCircularContext) {
93228                     (circularDiagnostics || (circularDiagnostics = [])).push(ts.createCompilerDiagnostic(ts.Diagnostics.Project_references_may_not_form_a_circular_graph_Cycle_detected_Colon_0, circularityReportStack.join("\r\n")));
93229                 }
93230                 return;
93231             }
93232             temporaryMarks.set(projPath, true);
93233             circularityReportStack.push(configFileName);
93234             var parsed = parseConfigFile(state, configFileName, projPath);
93235             if (parsed && parsed.projectReferences) {
93236                 for (var _i = 0, _a = parsed.projectReferences; _i < _a.length; _i++) {
93237                     var ref = _a[_i];
93238                     var resolvedRefPath = resolveProjectName(state, ref.path);
93239                     visit(resolvedRefPath, inCircularContext || ref.circular);
93240                 }
93241             }
93242             circularityReportStack.pop();
93243             permanentMarks.set(projPath, true);
93244             (buildOrder || (buildOrder = [])).push(configFileName);
93245         }
93246     }
93247     function getBuildOrder(state) {
93248         return state.buildOrder || createStateBuildOrder(state);
93249     }
93250     function createStateBuildOrder(state) {
93251         var buildOrder = createBuildOrder(state, state.rootNames.map(function (f) { return resolveProjectName(state, f); }));
93252         state.resolvedConfigFilePaths.clear();
93253         var currentProjects = new ts.Map(getBuildOrderFromAnyBuildOrder(buildOrder).map(function (resolved) { return [toResolvedConfigFilePath(state, resolved), true]; }));
93254         var noopOnDelete = { onDeleteValue: ts.noop };
93255         ts.mutateMapSkippingNewValues(state.configFileCache, currentProjects, noopOnDelete);
93256         ts.mutateMapSkippingNewValues(state.projectStatus, currentProjects, noopOnDelete);
93257         ts.mutateMapSkippingNewValues(state.buildInfoChecked, currentProjects, noopOnDelete);
93258         ts.mutateMapSkippingNewValues(state.builderPrograms, currentProjects, noopOnDelete);
93259         ts.mutateMapSkippingNewValues(state.diagnostics, currentProjects, noopOnDelete);
93260         ts.mutateMapSkippingNewValues(state.projectPendingBuild, currentProjects, noopOnDelete);
93261         ts.mutateMapSkippingNewValues(state.projectErrorsReported, currentProjects, noopOnDelete);
93262         if (state.watch) {
93263             ts.mutateMapSkippingNewValues(state.allWatchedConfigFiles, currentProjects, { onDeleteValue: ts.closeFileWatcher });
93264             state.allWatchedExtendedConfigFiles.forEach(function (watcher) {
93265                 watcher.projects.forEach(function (project) {
93266                     if (!currentProjects.has(project)) {
93267                         watcher.projects.delete(project);
93268                     }
93269                 });
93270                 watcher.close();
93271             });
93272             ts.mutateMapSkippingNewValues(state.allWatchedWildcardDirectories, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcherOf); } });
93273             ts.mutateMapSkippingNewValues(state.allWatchedInputFiles, currentProjects, { onDeleteValue: function (existingMap) { return existingMap.forEach(ts.closeFileWatcher); } });
93274         }
93275         return state.buildOrder = buildOrder;
93276     }
93277     function getBuildOrderFor(state, project, onlyReferences) {
93278         var resolvedProject = project && resolveProjectName(state, project);
93279         var buildOrderFromState = getBuildOrder(state);
93280         if (isCircularBuildOrder(buildOrderFromState))
93281             return buildOrderFromState;
93282         if (resolvedProject) {
93283             var projectPath_1 = toResolvedConfigFilePath(state, resolvedProject);
93284             var projectIndex = ts.findIndex(buildOrderFromState, function (configFileName) { return toResolvedConfigFilePath(state, configFileName) === projectPath_1; });
93285             if (projectIndex === -1)
93286                 return undefined;
93287         }
93288         var buildOrder = resolvedProject ? createBuildOrder(state, [resolvedProject]) : buildOrderFromState;
93289         ts.Debug.assert(!isCircularBuildOrder(buildOrder));
93290         ts.Debug.assert(!onlyReferences || resolvedProject !== undefined);
93291         ts.Debug.assert(!onlyReferences || buildOrder[buildOrder.length - 1] === resolvedProject);
93292         return onlyReferences ? buildOrder.slice(0, buildOrder.length - 1) : buildOrder;
93293     }
93294     function enableCache(state) {
93295         if (state.cache) {
93296             disableCache(state);
93297         }
93298         var compilerHost = state.compilerHost, host = state.host;
93299         var originalReadFileWithCache = state.readFileWithCache;
93300         var originalGetSourceFile = compilerHost.getSourceFile;
93301         var _a = ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return toPath(state, fileName); }, function () {
93302             var args = [];
93303             for (var _i = 0; _i < arguments.length; _i++) {
93304                 args[_i] = arguments[_i];
93305             }
93306             return originalGetSourceFile.call.apply(originalGetSourceFile, __spreadArray([compilerHost], args));
93307         }), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile, getSourceFileWithCache = _a.getSourceFileWithCache, readFileWithCache = _a.readFileWithCache;
93308         state.readFileWithCache = readFileWithCache;
93309         compilerHost.getSourceFile = getSourceFileWithCache;
93310         state.cache = {
93311             originalReadFile: originalReadFile,
93312             originalFileExists: originalFileExists,
93313             originalDirectoryExists: originalDirectoryExists,
93314             originalCreateDirectory: originalCreateDirectory,
93315             originalWriteFile: originalWriteFile,
93316             originalReadFileWithCache: originalReadFileWithCache,
93317             originalGetSourceFile: originalGetSourceFile,
93318         };
93319     }
93320     function disableCache(state) {
93321         if (!state.cache)
93322             return;
93323         var cache = state.cache, host = state.host, compilerHost = state.compilerHost, extendedConfigCache = state.extendedConfigCache, moduleResolutionCache = state.moduleResolutionCache;
93324         host.readFile = cache.originalReadFile;
93325         host.fileExists = cache.originalFileExists;
93326         host.directoryExists = cache.originalDirectoryExists;
93327         host.createDirectory = cache.originalCreateDirectory;
93328         host.writeFile = cache.originalWriteFile;
93329         compilerHost.getSourceFile = cache.originalGetSourceFile;
93330         state.readFileWithCache = cache.originalReadFileWithCache;
93331         extendedConfigCache.clear();
93332         if (moduleResolutionCache) {
93333             moduleResolutionCache.directoryToModuleNameMap.clear();
93334             moduleResolutionCache.moduleNameToDirectoryMap.clear();
93335         }
93336         state.cache = undefined;
93337     }
93338     function clearProjectStatus(state, resolved) {
93339         state.projectStatus.delete(resolved);
93340         state.diagnostics.delete(resolved);
93341     }
93342     function addProjToQueue(_a, proj, reloadLevel) {
93343         var projectPendingBuild = _a.projectPendingBuild;
93344         var value = projectPendingBuild.get(proj);
93345         if (value === undefined) {
93346             projectPendingBuild.set(proj, reloadLevel);
93347         }
93348         else if (value < reloadLevel) {
93349             projectPendingBuild.set(proj, reloadLevel);
93350         }
93351     }
93352     function setupInitialBuild(state, cancellationToken) {
93353         if (!state.allProjectBuildPending)
93354             return;
93355         state.allProjectBuildPending = false;
93356         if (state.options.watch) {
93357             reportWatchStatus(state, ts.Diagnostics.Starting_compilation_in_watch_mode);
93358         }
93359         enableCache(state);
93360         var buildOrder = getBuildOrderFromAnyBuildOrder(getBuildOrder(state));
93361         buildOrder.forEach(function (configFileName) {
93362             return state.projectPendingBuild.set(toResolvedConfigFilePath(state, configFileName), ts.ConfigFileProgramReloadLevel.None);
93363         });
93364         if (cancellationToken) {
93365             cancellationToken.throwIfCancellationRequested();
93366         }
93367     }
93368     var InvalidatedProjectKind;
93369     (function (InvalidatedProjectKind) {
93370         InvalidatedProjectKind[InvalidatedProjectKind["Build"] = 0] = "Build";
93371         InvalidatedProjectKind[InvalidatedProjectKind["UpdateBundle"] = 1] = "UpdateBundle";
93372         InvalidatedProjectKind[InvalidatedProjectKind["UpdateOutputFileStamps"] = 2] = "UpdateOutputFileStamps";
93373     })(InvalidatedProjectKind = ts.InvalidatedProjectKind || (ts.InvalidatedProjectKind = {}));
93374     function doneInvalidatedProject(state, projectPath) {
93375         state.projectPendingBuild.delete(projectPath);
93376         state.currentInvalidatedProject = undefined;
93377         return state.diagnostics.has(projectPath) ?
93378             ts.ExitStatus.DiagnosticsPresent_OutputsSkipped :
93379             ts.ExitStatus.Success;
93380     }
93381     function createUpdateOutputFileStampsProject(state, project, projectPath, config, buildOrder) {
93382         var updateOutputFileStampsPending = true;
93383         return {
93384             kind: InvalidatedProjectKind.UpdateOutputFileStamps,
93385             project: project,
93386             projectPath: projectPath,
93387             buildOrder: buildOrder,
93388             getCompilerOptions: function () { return config.options; },
93389             getCurrentDirectory: function () { return state.currentDirectory; },
93390             updateOutputFileStatmps: function () {
93391                 updateOutputTimestamps(state, config, projectPath);
93392                 updateOutputFileStampsPending = false;
93393             },
93394             done: function () {
93395                 if (updateOutputFileStampsPending) {
93396                     updateOutputTimestamps(state, config, projectPath);
93397                 }
93398                 return doneInvalidatedProject(state, projectPath);
93399             }
93400         };
93401     }
93402     var BuildStep;
93403     (function (BuildStep) {
93404         BuildStep[BuildStep["CreateProgram"] = 0] = "CreateProgram";
93405         BuildStep[BuildStep["SyntaxDiagnostics"] = 1] = "SyntaxDiagnostics";
93406         BuildStep[BuildStep["SemanticDiagnostics"] = 2] = "SemanticDiagnostics";
93407         BuildStep[BuildStep["Emit"] = 3] = "Emit";
93408         BuildStep[BuildStep["EmitBundle"] = 4] = "EmitBundle";
93409         BuildStep[BuildStep["EmitBuildInfo"] = 5] = "EmitBuildInfo";
93410         BuildStep[BuildStep["BuildInvalidatedProjectOfBundle"] = 6] = "BuildInvalidatedProjectOfBundle";
93411         BuildStep[BuildStep["QueueReferencingProjects"] = 7] = "QueueReferencingProjects";
93412         BuildStep[BuildStep["Done"] = 8] = "Done";
93413     })(BuildStep || (BuildStep = {}));
93414     function createBuildOrUpdateInvalidedProject(kind, state, project, projectPath, projectIndex, config, buildOrder) {
93415         var step = kind === InvalidatedProjectKind.Build ? BuildStep.CreateProgram : BuildStep.EmitBundle;
93416         var program;
93417         var buildResult;
93418         var invalidatedProjectOfBundle;
93419         return kind === InvalidatedProjectKind.Build ?
93420             {
93421                 kind: kind,
93422                 project: project,
93423                 projectPath: projectPath,
93424                 buildOrder: buildOrder,
93425                 getCompilerOptions: function () { return config.options; },
93426                 getCurrentDirectory: function () { return state.currentDirectory; },
93427                 getBuilderProgram: function () { return withProgramOrUndefined(ts.identity); },
93428                 getProgram: function () {
93429                     return withProgramOrUndefined(function (program) { return program.getProgramOrUndefined(); });
93430                 },
93431                 getSourceFile: function (fileName) {
93432                     return withProgramOrUndefined(function (program) { return program.getSourceFile(fileName); });
93433                 },
93434                 getSourceFiles: function () {
93435                     return withProgramOrEmptyArray(function (program) { return program.getSourceFiles(); });
93436                 },
93437                 getOptionsDiagnostics: function (cancellationToken) {
93438                     return withProgramOrEmptyArray(function (program) { return program.getOptionsDiagnostics(cancellationToken); });
93439                 },
93440                 getGlobalDiagnostics: function (cancellationToken) {
93441                     return withProgramOrEmptyArray(function (program) { return program.getGlobalDiagnostics(cancellationToken); });
93442                 },
93443                 getConfigFileParsingDiagnostics: function () {
93444                     return withProgramOrEmptyArray(function (program) { return program.getConfigFileParsingDiagnostics(); });
93445                 },
93446                 getSyntacticDiagnostics: function (sourceFile, cancellationToken) {
93447                     return withProgramOrEmptyArray(function (program) { return program.getSyntacticDiagnostics(sourceFile, cancellationToken); });
93448                 },
93449                 getAllDependencies: function (sourceFile) {
93450                     return withProgramOrEmptyArray(function (program) { return program.getAllDependencies(sourceFile); });
93451                 },
93452                 getSemanticDiagnostics: function (sourceFile, cancellationToken) {
93453                     return withProgramOrEmptyArray(function (program) { return program.getSemanticDiagnostics(sourceFile, cancellationToken); });
93454                 },
93455                 getSemanticDiagnosticsOfNextAffectedFile: function (cancellationToken, ignoreSourceFile) {
93456                     return withProgramOrUndefined(function (program) {
93457                         return (program.getSemanticDiagnosticsOfNextAffectedFile) &&
93458                             program.getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile);
93459                     });
93460                 },
93461                 emit: function (targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
93462                     if (targetSourceFile || emitOnlyDtsFiles) {
93463                         return withProgramOrUndefined(function (program) { return program.emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers); });
93464                     }
93465                     executeSteps(BuildStep.SemanticDiagnostics, cancellationToken);
93466                     if (step === BuildStep.EmitBuildInfo) {
93467                         return emitBuildInfo(writeFile, cancellationToken);
93468                     }
93469                     if (step !== BuildStep.Emit)
93470                         return undefined;
93471                     return emit(writeFile, cancellationToken, customTransformers);
93472                 },
93473                 done: done
93474             } :
93475             {
93476                 kind: kind,
93477                 project: project,
93478                 projectPath: projectPath,
93479                 buildOrder: buildOrder,
93480                 getCompilerOptions: function () { return config.options; },
93481                 getCurrentDirectory: function () { return state.currentDirectory; },
93482                 emit: function (writeFile, customTransformers) {
93483                     if (step !== BuildStep.EmitBundle)
93484                         return invalidatedProjectOfBundle;
93485                     return emitBundle(writeFile, customTransformers);
93486                 },
93487                 done: done,
93488             };
93489         function done(cancellationToken, writeFile, customTransformers) {
93490             executeSteps(BuildStep.Done, cancellationToken, writeFile, customTransformers);
93491             return doneInvalidatedProject(state, projectPath);
93492         }
93493         function withProgramOrUndefined(action) {
93494             executeSteps(BuildStep.CreateProgram);
93495             return program && action(program);
93496         }
93497         function withProgramOrEmptyArray(action) {
93498             return withProgramOrUndefined(action) || ts.emptyArray;
93499         }
93500         function createProgram() {
93501             ts.Debug.assert(program === undefined);
93502             if (state.options.dry) {
93503                 reportStatus(state, ts.Diagnostics.A_non_dry_build_would_build_project_0, project);
93504                 buildResult = BuildResultFlags.Success;
93505                 step = BuildStep.QueueReferencingProjects;
93506                 return;
93507             }
93508             if (state.options.verbose)
93509                 reportStatus(state, ts.Diagnostics.Building_project_0, project);
93510             if (config.fileNames.length === 0) {
93511                 reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
93512                 buildResult = BuildResultFlags.None;
93513                 step = BuildStep.QueueReferencingProjects;
93514                 return;
93515             }
93516             var host = state.host, compilerHost = state.compilerHost;
93517             state.projectCompilerOptions = config.options;
93518             updateModuleResolutionCache(state, project, config);
93519             program = host.createProgram(config.fileNames, config.options, compilerHost, getOldProgram(state, projectPath, config), ts.getConfigFileParsingDiagnostics(config), config.projectReferences);
93520             if (state.watch) {
93521                 state.builderPrograms.set(projectPath, program);
93522             }
93523             step++;
93524         }
93525         function handleDiagnostics(diagnostics, errorFlags, errorType) {
93526             var _a;
93527             if (diagnostics.length) {
93528                 (_a = buildErrors(state, projectPath, program, config, diagnostics, errorFlags, errorType), buildResult = _a.buildResult, step = _a.step);
93529             }
93530             else {
93531                 step++;
93532             }
93533         }
93534         function getSyntaxDiagnostics(cancellationToken) {
93535             ts.Debug.assertIsDefined(program);
93536             handleDiagnostics(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], program.getConfigFileParsingDiagnostics()), program.getOptionsDiagnostics(cancellationToken)), program.getGlobalDiagnostics(cancellationToken)), program.getSyntacticDiagnostics(undefined, cancellationToken)), BuildResultFlags.SyntaxErrors, "Syntactic");
93537         }
93538         function getSemanticDiagnostics(cancellationToken) {
93539             handleDiagnostics(ts.Debug.checkDefined(program).getSemanticDiagnostics(undefined, cancellationToken), BuildResultFlags.TypeErrors, "Semantic");
93540         }
93541         function emit(writeFileCallback, cancellationToken, customTransformers) {
93542             var _a;
93543             ts.Debug.assertIsDefined(program);
93544             ts.Debug.assert(step === BuildStep.Emit);
93545             program.backupState();
93546             var declDiagnostics;
93547             var reportDeclarationDiagnostics = function (d) { return (declDiagnostics || (declDiagnostics = [])).push(d); };
93548             var outputFiles = [];
93549             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;
93550             if (declDiagnostics) {
93551                 program.restoreState();
93552                 (_a = buildErrors(state, projectPath, program, config, declDiagnostics, BuildResultFlags.DeclarationEmitErrors, "Declaration file"), buildResult = _a.buildResult, step = _a.step);
93553                 return {
93554                     emitSkipped: true,
93555                     diagnostics: emitResult.diagnostics
93556                 };
93557             }
93558             var host = state.host, compilerHost = state.compilerHost;
93559             var resultFlags = BuildResultFlags.DeclarationOutputUnchanged;
93560             var newestDeclarationFileContentChangedTime = minimumDate;
93561             var anyDtsChanged = false;
93562             var emitterDiagnostics = ts.createDiagnosticCollection();
93563             var emittedOutputs = new ts.Map();
93564             outputFiles.forEach(function (_a) {
93565                 var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
93566                 var priorChangeTime;
93567                 if (!anyDtsChanged && isDeclarationFile(name)) {
93568                     if (host.fileExists(name) && state.readFileWithCache(name) === text) {
93569                         priorChangeTime = host.getModifiedTime(name);
93570                     }
93571                     else {
93572                         resultFlags &= ~BuildResultFlags.DeclarationOutputUnchanged;
93573                         anyDtsChanged = true;
93574                     }
93575                 }
93576                 emittedOutputs.set(toPath(state, name), name);
93577                 ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
93578                 if (priorChangeTime !== undefined) {
93579                     newestDeclarationFileContentChangedTime = newer(priorChangeTime, newestDeclarationFileContentChangedTime);
93580                 }
93581             });
93582             finishEmit(emitterDiagnostics, emittedOutputs, newestDeclarationFileContentChangedTime, anyDtsChanged, outputFiles.length ? outputFiles[0].name : ts.getFirstProjectOutput(config, !host.useCaseSensitiveFileNames()), resultFlags);
93583             return emitResult;
93584         }
93585         function emitBuildInfo(writeFileCallback, cancellationToken) {
93586             ts.Debug.assertIsDefined(program);
93587             ts.Debug.assert(step === BuildStep.EmitBuildInfo);
93588             var emitResult = program.emitBuildInfo(writeFileCallback, cancellationToken);
93589             if (emitResult.diagnostics.length) {
93590                 reportErrors(state, emitResult.diagnostics);
93591                 state.diagnostics.set(projectPath, __spreadArray(__spreadArray([], state.diagnostics.get(projectPath)), emitResult.diagnostics));
93592                 buildResult = BuildResultFlags.EmitErrors & buildResult;
93593             }
93594             if (emitResult.emittedFiles && state.write) {
93595                 emitResult.emittedFiles.forEach(function (name) { return listEmittedFile(state, config, name); });
93596             }
93597             afterProgramDone(state, program, config);
93598             step = BuildStep.QueueReferencingProjects;
93599             return emitResult;
93600         }
93601         function finishEmit(emitterDiagnostics, emittedOutputs, priorNewestUpdateTime, newestDeclarationFileContentChangedTimeIsMaximumDate, oldestOutputFileName, resultFlags) {
93602             var _a;
93603             var emitDiagnostics = emitterDiagnostics.getDiagnostics();
93604             if (emitDiagnostics.length) {
93605                 (_a = buildErrors(state, projectPath, program, config, emitDiagnostics, BuildResultFlags.EmitErrors, "Emit"), buildResult = _a.buildResult, step = _a.step);
93606                 return emitDiagnostics;
93607             }
93608             if (state.write) {
93609                 emittedOutputs.forEach(function (name) { return listEmittedFile(state, config, name); });
93610             }
93611             var newestDeclarationFileContentChangedTime = updateOutputTimestampsWorker(state, config, priorNewestUpdateTime, ts.Diagnostics.Updating_unchanged_output_timestamps_of_project_0, emittedOutputs);
93612             state.diagnostics.delete(projectPath);
93613             state.projectStatus.set(projectPath, {
93614                 type: ts.UpToDateStatusType.UpToDate,
93615                 newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTimeIsMaximumDate ?
93616                     maximumDate :
93617                     newestDeclarationFileContentChangedTime,
93618                 oldestOutputFileName: oldestOutputFileName
93619             });
93620             afterProgramDone(state, program, config);
93621             step = BuildStep.QueueReferencingProjects;
93622             buildResult = resultFlags;
93623             return emitDiagnostics;
93624         }
93625         function emitBundle(writeFileCallback, customTransformers) {
93626             ts.Debug.assert(kind === InvalidatedProjectKind.UpdateBundle);
93627             if (state.options.dry) {
93628                 reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_output_of_project_0, project);
93629                 buildResult = BuildResultFlags.Success;
93630                 step = BuildStep.QueueReferencingProjects;
93631                 return undefined;
93632             }
93633             if (state.options.verbose)
93634                 reportStatus(state, ts.Diagnostics.Updating_output_of_project_0, project);
93635             var compilerHost = state.compilerHost;
93636             state.projectCompilerOptions = config.options;
93637             var outputFiles = ts.emitUsingBuildInfo(config, compilerHost, function (ref) {
93638                 var refName = resolveProjectName(state, ref.path);
93639                 return parseConfigFile(state, refName, toResolvedConfigFilePath(state, refName));
93640             }, customTransformers);
93641             if (ts.isString(outputFiles)) {
93642                 reportStatus(state, ts.Diagnostics.Cannot_update_output_of_project_0_because_there_was_error_reading_file_1, project, relName(state, outputFiles));
93643                 step = BuildStep.BuildInvalidatedProjectOfBundle;
93644                 return invalidatedProjectOfBundle = createBuildOrUpdateInvalidedProject(InvalidatedProjectKind.Build, state, project, projectPath, projectIndex, config, buildOrder);
93645             }
93646             ts.Debug.assert(!!outputFiles.length);
93647             var emitterDiagnostics = ts.createDiagnosticCollection();
93648             var emittedOutputs = new ts.Map();
93649             outputFiles.forEach(function (_a) {
93650                 var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
93651                 emittedOutputs.set(toPath(state, name), name);
93652                 ts.writeFile(writeFileCallback ? { writeFile: writeFileCallback } : compilerHost, emitterDiagnostics, name, text, writeByteOrderMark);
93653             });
93654             var emitDiagnostics = finishEmit(emitterDiagnostics, emittedOutputs, minimumDate, false, outputFiles[0].name, BuildResultFlags.DeclarationOutputUnchanged);
93655             return { emitSkipped: false, diagnostics: emitDiagnostics };
93656         }
93657         function executeSteps(till, cancellationToken, writeFile, customTransformers) {
93658             while (step <= till && step < BuildStep.Done) {
93659                 var currentStep = step;
93660                 switch (step) {
93661                     case BuildStep.CreateProgram:
93662                         createProgram();
93663                         break;
93664                     case BuildStep.SyntaxDiagnostics:
93665                         getSyntaxDiagnostics(cancellationToken);
93666                         break;
93667                     case BuildStep.SemanticDiagnostics:
93668                         getSemanticDiagnostics(cancellationToken);
93669                         break;
93670                     case BuildStep.Emit:
93671                         emit(writeFile, cancellationToken, customTransformers);
93672                         break;
93673                     case BuildStep.EmitBuildInfo:
93674                         emitBuildInfo(writeFile, cancellationToken);
93675                         break;
93676                     case BuildStep.EmitBundle:
93677                         emitBundle(writeFile, customTransformers);
93678                         break;
93679                     case BuildStep.BuildInvalidatedProjectOfBundle:
93680                         ts.Debug.checkDefined(invalidatedProjectOfBundle).done(cancellationToken);
93681                         step = BuildStep.Done;
93682                         break;
93683                     case BuildStep.QueueReferencingProjects:
93684                         queueReferencingProjects(state, project, projectPath, projectIndex, config, buildOrder, ts.Debug.checkDefined(buildResult));
93685                         step++;
93686                         break;
93687                     case BuildStep.Done:
93688                     default:
93689                         ts.assertType(step);
93690                 }
93691                 ts.Debug.assert(step > currentStep);
93692             }
93693         }
93694     }
93695     function needsBuild(_a, status, config) {
93696         var options = _a.options;
93697         if (status.type !== ts.UpToDateStatusType.OutOfDateWithPrepend || options.force)
93698             return true;
93699         return config.fileNames.length === 0 ||
93700             !!ts.getConfigFileParsingDiagnostics(config).length ||
93701             !ts.isIncrementalCompilation(config.options);
93702     }
93703     function getNextInvalidatedProject(state, buildOrder, reportQueue) {
93704         if (!state.projectPendingBuild.size)
93705             return undefined;
93706         if (isCircularBuildOrder(buildOrder))
93707             return undefined;
93708         if (state.currentInvalidatedProject) {
93709             return ts.arrayIsEqualTo(state.currentInvalidatedProject.buildOrder, buildOrder) ?
93710                 state.currentInvalidatedProject :
93711                 undefined;
93712         }
93713         var options = state.options, projectPendingBuild = state.projectPendingBuild;
93714         for (var projectIndex = 0; projectIndex < buildOrder.length; projectIndex++) {
93715             var project = buildOrder[projectIndex];
93716             var projectPath = toResolvedConfigFilePath(state, project);
93717             var reloadLevel = state.projectPendingBuild.get(projectPath);
93718             if (reloadLevel === undefined)
93719                 continue;
93720             if (reportQueue) {
93721                 reportQueue = false;
93722                 reportBuildQueue(state, buildOrder);
93723             }
93724             var config = parseConfigFile(state, project, projectPath);
93725             if (!config) {
93726                 reportParseConfigFileDiagnostic(state, projectPath);
93727                 projectPendingBuild.delete(projectPath);
93728                 continue;
93729             }
93730             if (reloadLevel === ts.ConfigFileProgramReloadLevel.Full) {
93731                 watchConfigFile(state, project, projectPath, config);
93732                 watchExtendedConfigFiles(state, projectPath, config);
93733                 watchWildCardDirectories(state, project, projectPath, config);
93734                 watchInputFiles(state, project, projectPath, config);
93735             }
93736             else if (reloadLevel === ts.ConfigFileProgramReloadLevel.Partial) {
93737                 config.fileNames = ts.getFileNamesFromConfigSpecs(config.options.configFile.configFileSpecs, ts.getDirectoryPath(project), config.options, state.parseConfigFileHost);
93738                 ts.updateErrorForNoInputFiles(config.fileNames, project, config.options.configFile.configFileSpecs, config.errors, ts.canJsonReportNoInputFiles(config.raw));
93739                 watchInputFiles(state, project, projectPath, config);
93740             }
93741             var status = getUpToDateStatus(state, config, projectPath);
93742             verboseReportProjectStatus(state, project, status);
93743             if (!options.force) {
93744                 if (status.type === ts.UpToDateStatusType.UpToDate) {
93745                     reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
93746                     projectPendingBuild.delete(projectPath);
93747                     if (options.dry) {
93748                         reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date, project);
93749                     }
93750                     continue;
93751                 }
93752                 if (status.type === ts.UpToDateStatusType.UpToDateWithUpstreamTypes) {
93753                     reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
93754                     return createUpdateOutputFileStampsProject(state, project, projectPath, config, buildOrder);
93755                 }
93756             }
93757             if (status.type === ts.UpToDateStatusType.UpstreamBlocked) {
93758                 reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
93759                 projectPendingBuild.delete(projectPath);
93760                 if (options.verbose) {
93761                     reportStatus(state, status.upstreamProjectBlocked ?
93762                         ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_was_not_built :
93763                         ts.Diagnostics.Skipping_build_of_project_0_because_its_dependency_1_has_errors, project, status.upstreamProjectName);
93764                 }
93765                 continue;
93766             }
93767             if (status.type === ts.UpToDateStatusType.ContainerOnly) {
93768                 reportAndStoreErrors(state, projectPath, ts.getConfigFileParsingDiagnostics(config));
93769                 projectPendingBuild.delete(projectPath);
93770                 continue;
93771             }
93772             return createBuildOrUpdateInvalidedProject(needsBuild(state, status, config) ?
93773                 InvalidatedProjectKind.Build :
93774                 InvalidatedProjectKind.UpdateBundle, state, project, projectPath, projectIndex, config, buildOrder);
93775         }
93776         return undefined;
93777     }
93778     function listEmittedFile(_a, proj, file) {
93779         var write = _a.write;
93780         if (write && proj.options.listEmittedFiles) {
93781             write("TSFILE: " + file);
93782         }
93783     }
93784     function getOldProgram(_a, proj, parsed) {
93785         var options = _a.options, builderPrograms = _a.builderPrograms, compilerHost = _a.compilerHost;
93786         if (options.force)
93787             return undefined;
93788         var value = builderPrograms.get(proj);
93789         if (value)
93790             return value;
93791         return ts.readBuilderProgram(parsed.options, compilerHost);
93792     }
93793     function afterProgramDone(state, program, config) {
93794         if (program) {
93795             if (program && state.write)
93796                 ts.listFiles(program, state.write);
93797             if (state.host.afterProgramEmitAndDiagnostics) {
93798                 state.host.afterProgramEmitAndDiagnostics(program);
93799             }
93800             program.releaseProgram();
93801         }
93802         else if (state.host.afterEmitBundle) {
93803             state.host.afterEmitBundle(config);
93804         }
93805         state.projectCompilerOptions = state.baseCompilerOptions;
93806     }
93807     function buildErrors(state, resolvedPath, program, config, diagnostics, buildResult, errorType) {
93808         var canEmitBuildInfo = !(buildResult & BuildResultFlags.SyntaxErrors) && program && !ts.outFile(program.getCompilerOptions());
93809         reportAndStoreErrors(state, resolvedPath, diagnostics);
93810         state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.Unbuildable, reason: errorType + " errors" });
93811         if (canEmitBuildInfo)
93812             return { buildResult: buildResult, step: BuildStep.EmitBuildInfo };
93813         afterProgramDone(state, program, config);
93814         return { buildResult: buildResult, step: BuildStep.QueueReferencingProjects };
93815     }
93816     function updateModuleResolutionCache(state, proj, config) {
93817         if (!state.moduleResolutionCache)
93818             return;
93819         var moduleResolutionCache = state.moduleResolutionCache;
93820         var projPath = toPath(state, proj);
93821         if (moduleResolutionCache.directoryToModuleNameMap.redirectsMap.size === 0) {
93822             ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size === 0);
93823             moduleResolutionCache.directoryToModuleNameMap.redirectsMap.set(projPath, moduleResolutionCache.directoryToModuleNameMap.ownMap);
93824             moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.set(projPath, moduleResolutionCache.moduleNameToDirectoryMap.ownMap);
93825         }
93826         else {
93827             ts.Debug.assert(moduleResolutionCache.moduleNameToDirectoryMap.redirectsMap.size > 0);
93828             var ref = {
93829                 sourceFile: config.options.configFile,
93830                 commandLine: config
93831             };
93832             moduleResolutionCache.directoryToModuleNameMap.setOwnMap(moduleResolutionCache.directoryToModuleNameMap.getOrCreateMapOfCacheRedirects(ref));
93833             moduleResolutionCache.moduleNameToDirectoryMap.setOwnMap(moduleResolutionCache.moduleNameToDirectoryMap.getOrCreateMapOfCacheRedirects(ref));
93834         }
93835         moduleResolutionCache.directoryToModuleNameMap.setOwnOptions(config.options);
93836         moduleResolutionCache.moduleNameToDirectoryMap.setOwnOptions(config.options);
93837     }
93838     function checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName) {
93839         var tsconfigTime = state.host.getModifiedTime(configFile) || ts.missingFileModifiedTime;
93840         if (oldestOutputFileTime < tsconfigTime) {
93841             return {
93842                 type: ts.UpToDateStatusType.OutOfDateWithSelf,
93843                 outOfDateOutputFileName: oldestOutputFileName,
93844                 newerInputFileName: configFile
93845             };
93846         }
93847     }
93848     function getUpToDateStatusWorker(state, project, resolvedPath) {
93849         var newestInputFileName = undefined;
93850         var newestInputFileTime = minimumDate;
93851         var host = state.host;
93852         for (var _i = 0, _a = project.fileNames; _i < _a.length; _i++) {
93853             var inputFile = _a[_i];
93854             if (!host.fileExists(inputFile)) {
93855                 return {
93856                     type: ts.UpToDateStatusType.Unbuildable,
93857                     reason: inputFile + " does not exist"
93858                 };
93859             }
93860             var inputTime = host.getModifiedTime(inputFile) || ts.missingFileModifiedTime;
93861             if (inputTime > newestInputFileTime) {
93862                 newestInputFileName = inputFile;
93863                 newestInputFileTime = inputTime;
93864             }
93865         }
93866         if (!project.fileNames.length && !ts.canJsonReportNoInputFiles(project.raw)) {
93867             return {
93868                 type: ts.UpToDateStatusType.ContainerOnly
93869             };
93870         }
93871         var outputs = ts.getAllProjectOutputs(project, !host.useCaseSensitiveFileNames());
93872         var oldestOutputFileName = "(none)";
93873         var oldestOutputFileTime = maximumDate;
93874         var newestOutputFileName = "(none)";
93875         var newestOutputFileTime = minimumDate;
93876         var missingOutputFileName;
93877         var newestDeclarationFileContentChangedTime = minimumDate;
93878         var isOutOfDateWithInputs = false;
93879         for (var _b = 0, outputs_1 = outputs; _b < outputs_1.length; _b++) {
93880             var output = outputs_1[_b];
93881             if (!host.fileExists(output)) {
93882                 missingOutputFileName = output;
93883                 break;
93884             }
93885             var outputTime = host.getModifiedTime(output) || ts.missingFileModifiedTime;
93886             if (outputTime < oldestOutputFileTime) {
93887                 oldestOutputFileTime = outputTime;
93888                 oldestOutputFileName = output;
93889             }
93890             if (outputTime < newestInputFileTime) {
93891                 isOutOfDateWithInputs = true;
93892                 break;
93893             }
93894             if (outputTime > newestOutputFileTime) {
93895                 newestOutputFileTime = outputTime;
93896                 newestOutputFileName = output;
93897             }
93898             if (isDeclarationFile(output)) {
93899                 var outputModifiedTime = host.getModifiedTime(output) || ts.missingFileModifiedTime;
93900                 newestDeclarationFileContentChangedTime = newer(newestDeclarationFileContentChangedTime, outputModifiedTime);
93901             }
93902         }
93903         var pseudoUpToDate = false;
93904         var usesPrepend = false;
93905         var upstreamChangedProject;
93906         if (project.projectReferences) {
93907             state.projectStatus.set(resolvedPath, { type: ts.UpToDateStatusType.ComputingUpstream });
93908             for (var _c = 0, _d = project.projectReferences; _c < _d.length; _c++) {
93909                 var ref = _d[_c];
93910                 usesPrepend = usesPrepend || !!(ref.prepend);
93911                 var resolvedRef = ts.resolveProjectReferencePath(ref);
93912                 var resolvedRefPath = toResolvedConfigFilePath(state, resolvedRef);
93913                 var refStatus = getUpToDateStatus(state, parseConfigFile(state, resolvedRef, resolvedRefPath), resolvedRefPath);
93914                 if (refStatus.type === ts.UpToDateStatusType.ComputingUpstream ||
93915                     refStatus.type === ts.UpToDateStatusType.ContainerOnly) {
93916                     continue;
93917                 }
93918                 if (refStatus.type === ts.UpToDateStatusType.Unbuildable ||
93919                     refStatus.type === ts.UpToDateStatusType.UpstreamBlocked) {
93920                     return {
93921                         type: ts.UpToDateStatusType.UpstreamBlocked,
93922                         upstreamProjectName: ref.path,
93923                         upstreamProjectBlocked: refStatus.type === ts.UpToDateStatusType.UpstreamBlocked
93924                     };
93925                 }
93926                 if (refStatus.type !== ts.UpToDateStatusType.UpToDate) {
93927                     return {
93928                         type: ts.UpToDateStatusType.UpstreamOutOfDate,
93929                         upstreamProjectName: ref.path
93930                     };
93931                 }
93932                 if (!missingOutputFileName) {
93933                     if (refStatus.newestInputFileTime && refStatus.newestInputFileTime <= oldestOutputFileTime) {
93934                         continue;
93935                     }
93936                     if (refStatus.newestDeclarationFileContentChangedTime && refStatus.newestDeclarationFileContentChangedTime <= oldestOutputFileTime) {
93937                         pseudoUpToDate = true;
93938                         upstreamChangedProject = ref.path;
93939                         continue;
93940                     }
93941                     ts.Debug.assert(oldestOutputFileName !== undefined, "Should have an oldest output filename here");
93942                     return {
93943                         type: ts.UpToDateStatusType.OutOfDateWithUpstream,
93944                         outOfDateOutputFileName: oldestOutputFileName,
93945                         newerProjectName: ref.path
93946                     };
93947                 }
93948             }
93949         }
93950         if (missingOutputFileName !== undefined) {
93951             return {
93952                 type: ts.UpToDateStatusType.OutputMissing,
93953                 missingOutputFileName: missingOutputFileName
93954             };
93955         }
93956         if (isOutOfDateWithInputs) {
93957             return {
93958                 type: ts.UpToDateStatusType.OutOfDateWithSelf,
93959                 outOfDateOutputFileName: oldestOutputFileName,
93960                 newerInputFileName: newestInputFileName
93961             };
93962         }
93963         else {
93964             var configStatus = checkConfigFileUpToDateStatus(state, project.options.configFilePath, oldestOutputFileTime, oldestOutputFileName);
93965             if (configStatus)
93966                 return configStatus;
93967             var extendedConfigStatus = ts.forEach(project.options.configFile.extendedSourceFiles || ts.emptyArray, function (configFile) { return checkConfigFileUpToDateStatus(state, configFile, oldestOutputFileTime, oldestOutputFileName); });
93968             if (extendedConfigStatus)
93969                 return extendedConfigStatus;
93970         }
93971         if (!state.buildInfoChecked.has(resolvedPath)) {
93972             state.buildInfoChecked.set(resolvedPath, true);
93973             var buildInfoPath = ts.getTsBuildInfoEmitOutputFilePath(project.options);
93974             if (buildInfoPath) {
93975                 var value = state.readFileWithCache(buildInfoPath);
93976                 var buildInfo = value && ts.getBuildInfo(value);
93977                 if (buildInfo && (buildInfo.bundle || buildInfo.program) && buildInfo.version !== ts.version) {
93978                     return {
93979                         type: ts.UpToDateStatusType.TsVersionOutputOfDate,
93980                         version: buildInfo.version
93981                     };
93982                 }
93983             }
93984         }
93985         if (usesPrepend && pseudoUpToDate) {
93986             return {
93987                 type: ts.UpToDateStatusType.OutOfDateWithPrepend,
93988                 outOfDateOutputFileName: oldestOutputFileName,
93989                 newerProjectName: upstreamChangedProject
93990             };
93991         }
93992         return {
93993             type: pseudoUpToDate ? ts.UpToDateStatusType.UpToDateWithUpstreamTypes : ts.UpToDateStatusType.UpToDate,
93994             newestDeclarationFileContentChangedTime: newestDeclarationFileContentChangedTime,
93995             newestInputFileTime: newestInputFileTime,
93996             newestOutputFileTime: newestOutputFileTime,
93997             newestInputFileName: newestInputFileName,
93998             newestOutputFileName: newestOutputFileName,
93999             oldestOutputFileName: oldestOutputFileName
94000         };
94001     }
94002     function getUpToDateStatus(state, project, resolvedPath) {
94003         if (project === undefined) {
94004             return { type: ts.UpToDateStatusType.Unbuildable, reason: "File deleted mid-build" };
94005         }
94006         var prior = state.projectStatus.get(resolvedPath);
94007         if (prior !== undefined) {
94008             return prior;
94009         }
94010         var actual = getUpToDateStatusWorker(state, project, resolvedPath);
94011         state.projectStatus.set(resolvedPath, actual);
94012         return actual;
94013     }
94014     function updateOutputTimestampsWorker(state, proj, priorNewestUpdateTime, verboseMessage, skipOutputs) {
94015         var host = state.host;
94016         var outputs = ts.getAllProjectOutputs(proj, !host.useCaseSensitiveFileNames());
94017         if (!skipOutputs || outputs.length !== skipOutputs.size) {
94018             var reportVerbose = !!state.options.verbose;
94019             var now = host.now ? host.now() : new Date();
94020             for (var _i = 0, outputs_2 = outputs; _i < outputs_2.length; _i++) {
94021                 var file = outputs_2[_i];
94022                 if (skipOutputs && skipOutputs.has(toPath(state, file))) {
94023                     continue;
94024                 }
94025                 if (reportVerbose) {
94026                     reportVerbose = false;
94027                     reportStatus(state, verboseMessage, proj.options.configFilePath);
94028                 }
94029                 if (isDeclarationFile(file)) {
94030                     priorNewestUpdateTime = newer(priorNewestUpdateTime, host.getModifiedTime(file) || ts.missingFileModifiedTime);
94031                 }
94032                 host.setModifiedTime(file, now);
94033             }
94034         }
94035         return priorNewestUpdateTime;
94036     }
94037     function updateOutputTimestamps(state, proj, resolvedPath) {
94038         if (state.options.dry) {
94039             return reportStatus(state, ts.Diagnostics.A_non_dry_build_would_update_timestamps_for_output_of_project_0, proj.options.configFilePath);
94040         }
94041         var priorNewestUpdateTime = updateOutputTimestampsWorker(state, proj, minimumDate, ts.Diagnostics.Updating_output_timestamps_of_project_0);
94042         state.projectStatus.set(resolvedPath, {
94043             type: ts.UpToDateStatusType.UpToDate,
94044             newestDeclarationFileContentChangedTime: priorNewestUpdateTime,
94045             oldestOutputFileName: ts.getFirstProjectOutput(proj, !state.host.useCaseSensitiveFileNames())
94046         });
94047     }
94048     function queueReferencingProjects(state, project, projectPath, projectIndex, config, buildOrder, buildResult) {
94049         if (buildResult & BuildResultFlags.AnyErrors)
94050             return;
94051         if (!config.options.composite)
94052             return;
94053         for (var index = projectIndex + 1; index < buildOrder.length; index++) {
94054             var nextProject = buildOrder[index];
94055             var nextProjectPath = toResolvedConfigFilePath(state, nextProject);
94056             if (state.projectPendingBuild.has(nextProjectPath))
94057                 continue;
94058             var nextProjectConfig = parseConfigFile(state, nextProject, nextProjectPath);
94059             if (!nextProjectConfig || !nextProjectConfig.projectReferences)
94060                 continue;
94061             for (var _i = 0, _a = nextProjectConfig.projectReferences; _i < _a.length; _i++) {
94062                 var ref = _a[_i];
94063                 var resolvedRefPath = resolveProjectName(state, ref.path);
94064                 if (toResolvedConfigFilePath(state, resolvedRefPath) !== projectPath)
94065                     continue;
94066                 var status = state.projectStatus.get(nextProjectPath);
94067                 if (status) {
94068                     switch (status.type) {
94069                         case ts.UpToDateStatusType.UpToDate:
94070                             if (buildResult & BuildResultFlags.DeclarationOutputUnchanged) {
94071                                 if (ref.prepend) {
94072                                     state.projectStatus.set(nextProjectPath, {
94073                                         type: ts.UpToDateStatusType.OutOfDateWithPrepend,
94074                                         outOfDateOutputFileName: status.oldestOutputFileName,
94075                                         newerProjectName: project
94076                                     });
94077                                 }
94078                                 else {
94079                                     status.type = ts.UpToDateStatusType.UpToDateWithUpstreamTypes;
94080                                 }
94081                                 break;
94082                             }
94083                         case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
94084                         case ts.UpToDateStatusType.OutOfDateWithPrepend:
94085                             if (!(buildResult & BuildResultFlags.DeclarationOutputUnchanged)) {
94086                                 state.projectStatus.set(nextProjectPath, {
94087                                     type: ts.UpToDateStatusType.OutOfDateWithUpstream,
94088                                     outOfDateOutputFileName: status.type === ts.UpToDateStatusType.OutOfDateWithPrepend ? status.outOfDateOutputFileName : status.oldestOutputFileName,
94089                                     newerProjectName: project
94090                                 });
94091                             }
94092                             break;
94093                         case ts.UpToDateStatusType.UpstreamBlocked:
94094                             if (toResolvedConfigFilePath(state, resolveProjectName(state, status.upstreamProjectName)) === projectPath) {
94095                                 clearProjectStatus(state, nextProjectPath);
94096                             }
94097                             break;
94098                     }
94099                 }
94100                 addProjToQueue(state, nextProjectPath, ts.ConfigFileProgramReloadLevel.None);
94101                 break;
94102             }
94103         }
94104     }
94105     function build(state, project, cancellationToken, onlyReferences) {
94106         var buildOrder = getBuildOrderFor(state, project, onlyReferences);
94107         if (!buildOrder)
94108             return ts.ExitStatus.InvalidProject_OutputsSkipped;
94109         setupInitialBuild(state, cancellationToken);
94110         var reportQueue = true;
94111         var successfulProjects = 0;
94112         while (true) {
94113             var invalidatedProject = getNextInvalidatedProject(state, buildOrder, reportQueue);
94114             if (!invalidatedProject)
94115                 break;
94116             reportQueue = false;
94117             invalidatedProject.done(cancellationToken);
94118             if (!state.diagnostics.has(invalidatedProject.projectPath))
94119                 successfulProjects++;
94120         }
94121         disableCache(state);
94122         reportErrorSummary(state, buildOrder);
94123         startWatching(state, buildOrder);
94124         return isCircularBuildOrder(buildOrder)
94125             ? ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped
94126             : !buildOrder.some(function (p) { return state.diagnostics.has(toResolvedConfigFilePath(state, p)); })
94127                 ? ts.ExitStatus.Success
94128                 : successfulProjects
94129                     ? ts.ExitStatus.DiagnosticsPresent_OutputsGenerated
94130                     : ts.ExitStatus.DiagnosticsPresent_OutputsSkipped;
94131     }
94132     function clean(state, project, onlyReferences) {
94133         var buildOrder = getBuildOrderFor(state, project, onlyReferences);
94134         if (!buildOrder)
94135             return ts.ExitStatus.InvalidProject_OutputsSkipped;
94136         if (isCircularBuildOrder(buildOrder)) {
94137             reportErrors(state, buildOrder.circularDiagnostics);
94138             return ts.ExitStatus.ProjectReferenceCycle_OutputsSkipped;
94139         }
94140         var options = state.options, host = state.host;
94141         var filesToDelete = options.dry ? [] : undefined;
94142         for (var _i = 0, buildOrder_1 = buildOrder; _i < buildOrder_1.length; _i++) {
94143             var proj = buildOrder_1[_i];
94144             var resolvedPath = toResolvedConfigFilePath(state, proj);
94145             var parsed = parseConfigFile(state, proj, resolvedPath);
94146             if (parsed === undefined) {
94147                 reportParseConfigFileDiagnostic(state, resolvedPath);
94148                 continue;
94149             }
94150             var outputs = ts.getAllProjectOutputs(parsed, !host.useCaseSensitiveFileNames());
94151             for (var _a = 0, outputs_3 = outputs; _a < outputs_3.length; _a++) {
94152                 var output = outputs_3[_a];
94153                 if (host.fileExists(output)) {
94154                     if (filesToDelete) {
94155                         filesToDelete.push(output);
94156                     }
94157                     else {
94158                         host.deleteFile(output);
94159                         invalidateProject(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None);
94160                     }
94161                 }
94162             }
94163         }
94164         if (filesToDelete) {
94165             reportStatus(state, ts.Diagnostics.A_non_dry_build_would_delete_the_following_files_Colon_0, filesToDelete.map(function (f) { return "\r\n * " + f; }).join(""));
94166         }
94167         return ts.ExitStatus.Success;
94168     }
94169     function invalidateProject(state, resolved, reloadLevel) {
94170         if (state.host.getParsedCommandLine && reloadLevel === ts.ConfigFileProgramReloadLevel.Partial) {
94171             reloadLevel = ts.ConfigFileProgramReloadLevel.Full;
94172         }
94173         if (reloadLevel === ts.ConfigFileProgramReloadLevel.Full) {
94174             state.configFileCache.delete(resolved);
94175             state.buildOrder = undefined;
94176         }
94177         state.needsSummary = true;
94178         clearProjectStatus(state, resolved);
94179         addProjToQueue(state, resolved, reloadLevel);
94180         enableCache(state);
94181     }
94182     function invalidateProjectAndScheduleBuilds(state, resolvedPath, reloadLevel) {
94183         state.reportFileChangeDetected = true;
94184         invalidateProject(state, resolvedPath, reloadLevel);
94185         scheduleBuildInvalidatedProject(state);
94186     }
94187     function scheduleBuildInvalidatedProject(state) {
94188         var hostWithWatch = state.hostWithWatch;
94189         if (!hostWithWatch.setTimeout || !hostWithWatch.clearTimeout) {
94190             return;
94191         }
94192         if (state.timerToBuildInvalidatedProject) {
94193             hostWithWatch.clearTimeout(state.timerToBuildInvalidatedProject);
94194         }
94195         state.timerToBuildInvalidatedProject = hostWithWatch.setTimeout(buildNextInvalidatedProject, 250, state);
94196     }
94197     function buildNextInvalidatedProject(state) {
94198         state.timerToBuildInvalidatedProject = undefined;
94199         if (state.reportFileChangeDetected) {
94200             state.reportFileChangeDetected = false;
94201             state.projectErrorsReported.clear();
94202             reportWatchStatus(state, ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
94203         }
94204         var buildOrder = getBuildOrder(state);
94205         var invalidatedProject = getNextInvalidatedProject(state, buildOrder, false);
94206         if (invalidatedProject) {
94207             invalidatedProject.done();
94208             if (state.projectPendingBuild.size) {
94209                 if (state.watch && !state.timerToBuildInvalidatedProject) {
94210                     scheduleBuildInvalidatedProject(state);
94211                 }
94212                 return;
94213             }
94214         }
94215         disableCache(state);
94216         reportErrorSummary(state, buildOrder);
94217     }
94218     function watchConfigFile(state, resolved, resolvedPath, parsed) {
94219         if (!state.watch || state.allWatchedConfigFiles.has(resolvedPath))
94220             return;
94221         state.allWatchedConfigFiles.set(resolvedPath, state.watchFile(resolved, function () {
94222             invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Full);
94223         }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ConfigFile, resolved));
94224     }
94225     function watchExtendedConfigFiles(state, resolvedPath, parsed) {
94226         ts.updateSharedExtendedConfigFileWatcher(resolvedPath, parsed, state.allWatchedExtendedConfigFiles, function (extendedConfigFileName, extendedConfigFilePath) { return state.watchFile(extendedConfigFileName, function () {
94227             var _a;
94228             return (_a = state.allWatchedExtendedConfigFiles.get(extendedConfigFilePath)) === null || _a === void 0 ? void 0 : _a.projects.forEach(function (projectConfigFilePath) {
94229                 return invalidateProjectAndScheduleBuilds(state, projectConfigFilePath, ts.ConfigFileProgramReloadLevel.Full);
94230             });
94231         }, ts.PollingInterval.High, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.ExtendedConfigFile); }, function (fileName) { return toPath(state, fileName); });
94232     }
94233     function watchWildCardDirectories(state, resolved, resolvedPath, parsed) {
94234         if (!state.watch)
94235             return;
94236         ts.updateWatchingWildcardDirectories(getOrCreateValueMapFromConfigFileMap(state.allWatchedWildcardDirectories, resolvedPath), new ts.Map(ts.getEntries(parsed.wildcardDirectories)), function (dir, flags) { return state.watchDirectory(dir, function (fileOrDirectory) {
94237             if (ts.isIgnoredFileFromWildCardWatching({
94238                 watchedDirPath: toPath(state, dir),
94239                 fileOrDirectory: fileOrDirectory,
94240                 fileOrDirectoryPath: toPath(state, fileOrDirectory),
94241                 configFileName: resolved,
94242                 currentDirectory: state.currentDirectory,
94243                 options: parsed.options,
94244                 program: state.builderPrograms.get(resolvedPath),
94245                 useCaseSensitiveFileNames: state.parseConfigFileHost.useCaseSensitiveFileNames,
94246                 writeLog: function (s) { return state.writeLog(s); }
94247             }))
94248                 return;
94249             invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.Partial);
94250         }, flags, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.WildcardDirectory, resolved); });
94251     }
94252     function watchInputFiles(state, resolved, resolvedPath, parsed) {
94253         if (!state.watch)
94254             return;
94255         ts.mutateMap(getOrCreateValueMapFromConfigFileMap(state.allWatchedInputFiles, resolvedPath), ts.arrayToMap(parsed.fileNames, function (fileName) { return toPath(state, fileName); }), {
94256             createNewValue: function (_path, input) { return state.watchFile(input, function () { return invalidateProjectAndScheduleBuilds(state, resolvedPath, ts.ConfigFileProgramReloadLevel.None); }, ts.PollingInterval.Low, parsed === null || parsed === void 0 ? void 0 : parsed.watchOptions, ts.WatchType.SourceFile, resolved); },
94257             onDeleteValue: ts.closeFileWatcher,
94258         });
94259     }
94260     function startWatching(state, buildOrder) {
94261         if (!state.watchAllProjectsPending)
94262             return;
94263         state.watchAllProjectsPending = false;
94264         for (var _i = 0, _a = getBuildOrderFromAnyBuildOrder(buildOrder); _i < _a.length; _i++) {
94265             var resolved = _a[_i];
94266             var resolvedPath = toResolvedConfigFilePath(state, resolved);
94267             var cfg = parseConfigFile(state, resolved, resolvedPath);
94268             watchConfigFile(state, resolved, resolvedPath, cfg);
94269             watchExtendedConfigFiles(state, resolvedPath, cfg);
94270             if (cfg) {
94271                 watchWildCardDirectories(state, resolved, resolvedPath, cfg);
94272                 watchInputFiles(state, resolved, resolvedPath, cfg);
94273             }
94274         }
94275     }
94276     function stopWatching(state) {
94277         ts.clearMap(state.allWatchedConfigFiles, ts.closeFileWatcher);
94278         ts.clearMap(state.allWatchedExtendedConfigFiles, function (watcher) {
94279             watcher.projects.clear();
94280             watcher.close();
94281         });
94282         ts.clearMap(state.allWatchedWildcardDirectories, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcherOf); });
94283         ts.clearMap(state.allWatchedInputFiles, function (watchedWildcardDirectories) { return ts.clearMap(watchedWildcardDirectories, ts.closeFileWatcher); });
94284     }
94285     function createSolutionBuilderWorker(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions) {
94286         var state = createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options, baseWatchOptions);
94287         return {
94288             build: function (project, cancellationToken) { return build(state, project, cancellationToken); },
94289             clean: function (project) { return clean(state, project); },
94290             buildReferences: function (project, cancellationToken) { return build(state, project, cancellationToken, true); },
94291             cleanReferences: function (project) { return clean(state, project, true); },
94292             getNextInvalidatedProject: function (cancellationToken) {
94293                 setupInitialBuild(state, cancellationToken);
94294                 return getNextInvalidatedProject(state, getBuildOrder(state), false);
94295             },
94296             getBuildOrder: function () { return getBuildOrder(state); },
94297             getUpToDateStatusOfProject: function (project) {
94298                 var configFileName = resolveProjectName(state, project);
94299                 var configFilePath = toResolvedConfigFilePath(state, configFileName);
94300                 return getUpToDateStatus(state, parseConfigFile(state, configFileName, configFilePath), configFilePath);
94301             },
94302             invalidateProject: function (configFilePath, reloadLevel) { return invalidateProject(state, configFilePath, reloadLevel || ts.ConfigFileProgramReloadLevel.None); },
94303             buildNextInvalidatedProject: function () { return buildNextInvalidatedProject(state); },
94304             getAllParsedConfigs: function () { return ts.arrayFrom(ts.mapDefinedIterator(state.configFileCache.values(), function (config) { return isParsedCommandLine(config) ? config : undefined; })); },
94305             close: function () { return stopWatching(state); },
94306         };
94307     }
94308     function relName(state, path) {
94309         return ts.convertToRelativePath(path, state.currentDirectory, function (f) { return state.getCanonicalFileName(f); });
94310     }
94311     function reportStatus(state, message) {
94312         var args = [];
94313         for (var _i = 2; _i < arguments.length; _i++) {
94314             args[_i - 2] = arguments[_i];
94315         }
94316         state.host.reportSolutionBuilderStatus(ts.createCompilerDiagnostic.apply(void 0, __spreadArray([message], args)));
94317     }
94318     function reportWatchStatus(state, message) {
94319         var _a, _b;
94320         var args = [];
94321         for (var _i = 2; _i < arguments.length; _i++) {
94322             args[_i - 2] = arguments[_i];
94323         }
94324         (_b = (_a = state.hostWithWatch).onWatchStatusChange) === null || _b === void 0 ? void 0 : _b.call(_a, ts.createCompilerDiagnostic.apply(void 0, __spreadArray([message], args)), state.host.getNewLine(), state.baseCompilerOptions);
94325     }
94326     function reportErrors(_a, errors) {
94327         var host = _a.host;
94328         errors.forEach(function (err) { return host.reportDiagnostic(err); });
94329     }
94330     function reportAndStoreErrors(state, proj, errors) {
94331         reportErrors(state, errors);
94332         state.projectErrorsReported.set(proj, true);
94333         if (errors.length) {
94334             state.diagnostics.set(proj, errors);
94335         }
94336     }
94337     function reportParseConfigFileDiagnostic(state, proj) {
94338         reportAndStoreErrors(state, proj, [state.configFileCache.get(proj)]);
94339     }
94340     function reportErrorSummary(state, buildOrder) {
94341         if (!state.needsSummary)
94342             return;
94343         state.needsSummary = false;
94344         var canReportSummary = state.watch || !!state.host.reportErrorSummary;
94345         var diagnostics = state.diagnostics;
94346         var totalErrors = 0;
94347         if (isCircularBuildOrder(buildOrder)) {
94348             reportBuildQueue(state, buildOrder.buildOrder);
94349             reportErrors(state, buildOrder.circularDiagnostics);
94350             if (canReportSummary)
94351                 totalErrors += ts.getErrorCountForSummary(buildOrder.circularDiagnostics);
94352         }
94353         else {
94354             buildOrder.forEach(function (project) {
94355                 var projectPath = toResolvedConfigFilePath(state, project);
94356                 if (!state.projectErrorsReported.has(projectPath)) {
94357                     reportErrors(state, diagnostics.get(projectPath) || ts.emptyArray);
94358                 }
94359             });
94360             if (canReportSummary)
94361                 diagnostics.forEach(function (singleProjectErrors) { return totalErrors += ts.getErrorCountForSummary(singleProjectErrors); });
94362         }
94363         if (state.watch) {
94364             reportWatchStatus(state, ts.getWatchErrorSummaryDiagnosticMessage(totalErrors), totalErrors);
94365         }
94366         else if (state.host.reportErrorSummary) {
94367             state.host.reportErrorSummary(totalErrors);
94368         }
94369     }
94370     function reportBuildQueue(state, buildQueue) {
94371         if (state.options.verbose) {
94372             reportStatus(state, ts.Diagnostics.Projects_in_this_build_Colon_0, buildQueue.map(function (s) { return "\r\n    * " + relName(state, s); }).join(""));
94373         }
94374     }
94375     function reportUpToDateStatus(state, configFileName, status) {
94376         switch (status.type) {
94377             case ts.UpToDateStatusType.OutOfDateWithSelf:
94378                 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));
94379             case ts.UpToDateStatusType.OutOfDateWithUpstream:
94380                 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));
94381             case ts.UpToDateStatusType.OutputMissing:
94382                 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));
94383             case ts.UpToDateStatusType.UpToDate:
94384                 if (status.newestInputFileTime !== undefined) {
94385                     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 || ""));
94386                 }
94387                 break;
94388             case ts.UpToDateStatusType.OutOfDateWithPrepend:
94389                 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));
94390             case ts.UpToDateStatusType.UpToDateWithUpstreamTypes:
94391                 return reportStatus(state, ts.Diagnostics.Project_0_is_up_to_date_with_d_ts_files_from_its_dependencies, relName(state, configFileName));
94392             case ts.UpToDateStatusType.UpstreamOutOfDate:
94393                 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));
94394             case ts.UpToDateStatusType.UpstreamBlocked:
94395                 return reportStatus(state, status.upstreamProjectBlocked ?
94396                     ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_was_not_built :
94397                     ts.Diagnostics.Project_0_can_t_be_built_because_its_dependency_1_has_errors, relName(state, configFileName), relName(state, status.upstreamProjectName));
94398             case ts.UpToDateStatusType.Unbuildable:
94399                 return reportStatus(state, ts.Diagnostics.Failed_to_parse_file_0_Colon_1, relName(state, configFileName), status.reason);
94400             case ts.UpToDateStatusType.TsVersionOutputOfDate:
94401                 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);
94402             case ts.UpToDateStatusType.ContainerOnly:
94403             case ts.UpToDateStatusType.ComputingUpstream:
94404                 break;
94405             default:
94406                 ts.assertType(status);
94407         }
94408     }
94409     function verboseReportProjectStatus(state, configFileName, status) {
94410         if (state.options.verbose) {
94411             reportUpToDateStatus(state, configFileName, status);
94412         }
94413     }
94414 })(ts || (ts = {}));
94415 var ts;
94416 (function (ts) {
94417     function countLines(program) {
94418         var counts = getCountsMap();
94419         ts.forEach(program.getSourceFiles(), function (file) {
94420             var key = getCountKey(program, file);
94421             var lineCount = ts.getLineStarts(file).length;
94422             counts.set(key, counts.get(key) + lineCount);
94423         });
94424         return counts;
94425     }
94426     function countNodes(program) {
94427         var counts = getCountsMap();
94428         ts.forEach(program.getSourceFiles(), function (file) {
94429             var key = getCountKey(program, file);
94430             counts.set(key, counts.get(key) + file.nodeCount);
94431         });
94432         return counts;
94433     }
94434     function getCountsMap() {
94435         var counts = ts.createMap();
94436         counts.set("Library", 0);
94437         counts.set("Definitions", 0);
94438         counts.set("TypeScript", 0);
94439         counts.set("JavaScript", 0);
94440         counts.set("JSON", 0);
94441         counts.set("Other", 0);
94442         return counts;
94443     }
94444     function getCountKey(program, file) {
94445         if (program.isSourceFileDefaultLibrary(file)) {
94446             return "Library";
94447         }
94448         else if (file.isDeclarationFile) {
94449             return "Definitions";
94450         }
94451         var path = file.path;
94452         if (ts.fileExtensionIsOneOf(path, ts.supportedTSExtensions)) {
94453             return "TypeScript";
94454         }
94455         else if (ts.fileExtensionIsOneOf(path, ts.supportedJSExtensions)) {
94456             return "JavaScript";
94457         }
94458         else if (ts.fileExtensionIs(path, ".json")) {
94459             return "JSON";
94460         }
94461         else {
94462             return "Other";
94463         }
94464     }
94465     function updateReportDiagnostic(sys, existing, options) {
94466         return shouldBePretty(sys, options) ?
94467             ts.createDiagnosticReporter(sys, true) :
94468             existing;
94469     }
94470     function defaultIsPretty(sys) {
94471         return !!sys.writeOutputIsTTY && sys.writeOutputIsTTY();
94472     }
94473     function shouldBePretty(sys, options) {
94474         if (!options || typeof options.pretty === "undefined") {
94475             return defaultIsPretty(sys);
94476         }
94477         return options.pretty;
94478     }
94479     function getOptionsForHelp(commandLine) {
94480         return !!commandLine.options.all ?
94481             ts.sort(ts.optionDeclarations, function (a, b) { return ts.compareStringsCaseInsensitive(a.name, b.name); }) :
94482             ts.filter(ts.optionDeclarations.slice(), function (v) { return !!v.showInSimplifiedHelpView; });
94483     }
94484     function printVersion(sys) {
94485         sys.write(ts.getDiagnosticText(ts.Diagnostics.Version_0, ts.version) + sys.newLine);
94486     }
94487     function printHelp(sys, optionsList, syntaxPrefix) {
94488         if (syntaxPrefix === void 0) { syntaxPrefix = ""; }
94489         var output = [];
94490         var syntaxLength = ts.getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, "").length;
94491         var examplesLength = ts.getDiagnosticText(ts.Diagnostics.Examples_Colon_0, "").length;
94492         var marginLength = Math.max(syntaxLength, examplesLength);
94493         var syntax = makePadding(marginLength - syntaxLength);
94494         syntax += "tsc " + syntaxPrefix + "[" + ts.getDiagnosticText(ts.Diagnostics.options) + "] [" + ts.getDiagnosticText(ts.Diagnostics.file) + "...]";
94495         output.push(ts.getDiagnosticText(ts.Diagnostics.Syntax_Colon_0, syntax));
94496         output.push(sys.newLine + sys.newLine);
94497         var padding = makePadding(marginLength);
94498         output.push(ts.getDiagnosticText(ts.Diagnostics.Examples_Colon_0, makePadding(marginLength - examplesLength) + "tsc hello.ts") + sys.newLine);
94499         output.push(padding + "tsc --outFile file.js file.ts" + sys.newLine);
94500         output.push(padding + "tsc @args.txt" + sys.newLine);
94501         output.push(padding + "tsc --build tsconfig.json" + sys.newLine);
94502         output.push(sys.newLine);
94503         output.push(ts.getDiagnosticText(ts.Diagnostics.Options_Colon) + sys.newLine);
94504         marginLength = 0;
94505         var usageColumn = [];
94506         var descriptionColumn = [];
94507         var optionsDescriptionMap = new ts.Map();
94508         for (var _i = 0, optionsList_1 = optionsList; _i < optionsList_1.length; _i++) {
94509             var option = optionsList_1[_i];
94510             if (!option.description) {
94511                 continue;
94512             }
94513             var usageText_1 = " ";
94514             if (option.shortName) {
94515                 usageText_1 += "-" + option.shortName;
94516                 usageText_1 += getParamType(option);
94517                 usageText_1 += ", ";
94518             }
94519             usageText_1 += "--" + option.name;
94520             usageText_1 += getParamType(option);
94521             usageColumn.push(usageText_1);
94522             var description = void 0;
94523             if (option.name === "lib") {
94524                 description = ts.getDiagnosticText(option.description);
94525                 var element = option.element;
94526                 var typeMap = element.type;
94527                 optionsDescriptionMap.set(description, ts.arrayFrom(typeMap.keys()).map(function (key) { return "'" + key + "'"; }));
94528             }
94529             else {
94530                 description = ts.getDiagnosticText(option.description);
94531             }
94532             descriptionColumn.push(description);
94533             marginLength = Math.max(usageText_1.length, marginLength);
94534         }
94535         var usageText = " @<" + ts.getDiagnosticText(ts.Diagnostics.file) + ">";
94536         usageColumn.push(usageText);
94537         descriptionColumn.push(ts.getDiagnosticText(ts.Diagnostics.Insert_command_line_options_and_files_from_a_file));
94538         marginLength = Math.max(usageText.length, marginLength);
94539         for (var i = 0; i < usageColumn.length; i++) {
94540             var usage = usageColumn[i];
94541             var description = descriptionColumn[i];
94542             var kindsList = optionsDescriptionMap.get(description);
94543             output.push(usage + makePadding(marginLength - usage.length + 2) + description + sys.newLine);
94544             if (kindsList) {
94545                 output.push(makePadding(marginLength + 4));
94546                 for (var _a = 0, kindsList_1 = kindsList; _a < kindsList_1.length; _a++) {
94547                     var kind = kindsList_1[_a];
94548                     output.push(kind + " ");
94549                 }
94550                 output.push(sys.newLine);
94551             }
94552         }
94553         for (var _b = 0, output_1 = output; _b < output_1.length; _b++) {
94554             var line = output_1[_b];
94555             sys.write(line);
94556         }
94557         return;
94558         function getParamType(option) {
94559             if (option.paramType !== undefined) {
94560                 return " " + ts.getDiagnosticText(option.paramType);
94561             }
94562             return "";
94563         }
94564         function makePadding(paddingLength) {
94565             return Array(paddingLength + 1).join(" ");
94566         }
94567     }
94568     function executeCommandLineWorker(sys, cb, commandLine) {
94569         var reportDiagnostic = ts.createDiagnosticReporter(sys);
94570         if (commandLine.options.build) {
94571             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_build_must_be_the_first_command_line_argument));
94572             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
94573         }
94574         var configFileName;
94575         if (commandLine.options.locale) {
94576             ts.validateLocaleAndSetLanguage(commandLine.options.locale, sys, commandLine.errors);
94577         }
94578         if (commandLine.errors.length > 0) {
94579             commandLine.errors.forEach(reportDiagnostic);
94580             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
94581         }
94582         if (commandLine.options.init) {
94583             writeConfigFile(sys, reportDiagnostic, commandLine.options, commandLine.fileNames);
94584             return sys.exit(ts.ExitStatus.Success);
94585         }
94586         if (commandLine.options.version) {
94587             printVersion(sys);
94588             return sys.exit(ts.ExitStatus.Success);
94589         }
94590         if (commandLine.options.help || commandLine.options.all) {
94591             printVersion(sys);
94592             printHelp(sys, getOptionsForHelp(commandLine));
94593             return sys.exit(ts.ExitStatus.Success);
94594         }
94595         if (commandLine.options.watch && commandLine.options.listFilesOnly) {
94596             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Options_0_and_1_cannot_be_combined, "watch", "listFilesOnly"));
94597             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
94598         }
94599         if (commandLine.options.project) {
94600             if (commandLine.fileNames.length !== 0) {
94601                 reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Option_project_cannot_be_mixed_with_source_files_on_a_command_line));
94602                 return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
94603             }
94604             var fileOrDirectory = ts.normalizePath(commandLine.options.project);
94605             if (!fileOrDirectory || sys.directoryExists(fileOrDirectory)) {
94606                 configFileName = ts.combinePaths(fileOrDirectory, "tsconfig.json");
94607                 if (!sys.fileExists(configFileName)) {
94608                     reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_specified_directory_Colon_0, commandLine.options.project));
94609                     return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
94610                 }
94611             }
94612             else {
94613                 configFileName = fileOrDirectory;
94614                 if (!sys.fileExists(configFileName)) {
94615                     reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_specified_path_does_not_exist_Colon_0, commandLine.options.project));
94616                     return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
94617                 }
94618             }
94619         }
94620         else if (commandLine.fileNames.length === 0) {
94621             var searchPath = ts.normalizePath(sys.getCurrentDirectory());
94622             configFileName = ts.findConfigFile(searchPath, function (fileName) { return sys.fileExists(fileName); });
94623         }
94624         if (commandLine.fileNames.length === 0 && !configFileName) {
94625             if (commandLine.options.showConfig) {
94626                 reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Cannot_find_a_tsconfig_json_file_at_the_current_directory_Colon_0, ts.normalizePath(sys.getCurrentDirectory())));
94627             }
94628             else {
94629                 printVersion(sys);
94630                 printHelp(sys, getOptionsForHelp(commandLine));
94631             }
94632             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
94633         }
94634         var currentDirectory = sys.getCurrentDirectory();
94635         var commandLineOptions = ts.convertToOptionsWithAbsolutePaths(commandLine.options, function (fileName) { return ts.getNormalizedAbsolutePath(fileName, currentDirectory); });
94636         if (configFileName) {
94637             var configParseResult = ts.parseConfigFileWithSystem(configFileName, commandLineOptions, commandLine.watchOptions, sys, reportDiagnostic);
94638             if (commandLineOptions.showConfig) {
94639                 if (configParseResult.errors.length !== 0) {
94640                     reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, configParseResult.options);
94641                     configParseResult.errors.forEach(reportDiagnostic);
94642                     return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
94643                 }
94644                 sys.write(JSON.stringify(ts.convertToTSConfig(configParseResult, configFileName, sys), null, 4) + sys.newLine);
94645                 return sys.exit(ts.ExitStatus.Success);
94646             }
94647             reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, configParseResult.options);
94648             if (ts.isWatchSet(configParseResult.options)) {
94649                 if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
94650                     return;
94651                 return createWatchOfConfigFile(sys, cb, reportDiagnostic, configParseResult, commandLineOptions, commandLine.watchOptions);
94652             }
94653             else if (ts.isIncrementalCompilation(configParseResult.options)) {
94654                 performIncrementalCompilation(sys, cb, reportDiagnostic, configParseResult);
94655             }
94656             else {
94657                 performCompilation(sys, cb, reportDiagnostic, configParseResult);
94658             }
94659         }
94660         else {
94661             if (commandLineOptions.showConfig) {
94662                 sys.write(JSON.stringify(ts.convertToTSConfig(commandLine, ts.combinePaths(currentDirectory, "tsconfig.json"), sys), null, 4) + sys.newLine);
94663                 return sys.exit(ts.ExitStatus.Success);
94664             }
94665             reportDiagnostic = updateReportDiagnostic(sys, reportDiagnostic, commandLineOptions);
94666             if (ts.isWatchSet(commandLineOptions)) {
94667                 if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
94668                     return;
94669                 return createWatchOfFilesAndCompilerOptions(sys, cb, reportDiagnostic, commandLine.fileNames, commandLineOptions, commandLine.watchOptions);
94670             }
94671             else if (ts.isIncrementalCompilation(commandLineOptions)) {
94672                 performIncrementalCompilation(sys, cb, reportDiagnostic, __assign(__assign({}, commandLine), { options: commandLineOptions }));
94673             }
94674             else {
94675                 performCompilation(sys, cb, reportDiagnostic, __assign(__assign({}, commandLine), { options: commandLineOptions }));
94676             }
94677         }
94678     }
94679     function isBuild(commandLineArgs) {
94680         if (commandLineArgs.length > 0 && commandLineArgs[0].charCodeAt(0) === 45) {
94681             var firstOption = commandLineArgs[0].slice(commandLineArgs[0].charCodeAt(1) === 45 ? 2 : 1).toLowerCase();
94682             return firstOption === "build" || firstOption === "b";
94683         }
94684         return false;
94685     }
94686     ts.isBuild = isBuild;
94687     function executeCommandLine(system, cb, commandLineArgs) {
94688         if (isBuild(commandLineArgs)) {
94689             var _a = ts.parseBuildCommand(commandLineArgs.slice(1)), buildOptions_1 = _a.buildOptions, watchOptions_1 = _a.watchOptions, projects_1 = _a.projects, errors_1 = _a.errors;
94690             if (buildOptions_1.generateCpuProfile && system.enableCPUProfiler) {
94691                 system.enableCPUProfiler(buildOptions_1.generateCpuProfile, function () { return performBuild(system, cb, buildOptions_1, watchOptions_1, projects_1, errors_1); });
94692             }
94693             else {
94694                 return performBuild(system, cb, buildOptions_1, watchOptions_1, projects_1, errors_1);
94695             }
94696         }
94697         var commandLine = ts.parseCommandLine(commandLineArgs, function (path) { return system.readFile(path); });
94698         if (commandLine.options.generateCpuProfile && system.enableCPUProfiler) {
94699             system.enableCPUProfiler(commandLine.options.generateCpuProfile, function () { return executeCommandLineWorker(system, cb, commandLine); });
94700         }
94701         else {
94702             return executeCommandLineWorker(system, cb, commandLine);
94703         }
94704     }
94705     ts.executeCommandLine = executeCommandLine;
94706     function reportWatchModeWithoutSysSupport(sys, reportDiagnostic) {
94707         if (!sys.watchFile || !sys.watchDirectory) {
94708             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--watch"));
94709             sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
94710             return true;
94711         }
94712         return false;
94713     }
94714     function performBuild(sys, cb, buildOptions, watchOptions, projects, errors) {
94715         var reportDiagnostic = updateReportDiagnostic(sys, ts.createDiagnosticReporter(sys), buildOptions);
94716         if (buildOptions.locale) {
94717             ts.validateLocaleAndSetLanguage(buildOptions.locale, sys, errors);
94718         }
94719         if (errors.length > 0) {
94720             errors.forEach(reportDiagnostic);
94721             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
94722         }
94723         if (buildOptions.help) {
94724             printVersion(sys);
94725             printHelp(sys, ts.buildOpts, "--build ");
94726             return sys.exit(ts.ExitStatus.Success);
94727         }
94728         if (projects.length === 0) {
94729             printVersion(sys);
94730             printHelp(sys, ts.buildOpts, "--build ");
94731             return sys.exit(ts.ExitStatus.Success);
94732         }
94733         if (!sys.getModifiedTime || !sys.setModifiedTime || (buildOptions.clean && !sys.deleteFile)) {
94734             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.The_current_host_does_not_support_the_0_option, "--build"));
94735             return sys.exit(ts.ExitStatus.DiagnosticsPresent_OutputsSkipped);
94736         }
94737         if (buildOptions.watch) {
94738             if (reportWatchModeWithoutSysSupport(sys, reportDiagnostic))
94739                 return;
94740             var buildHost_1 = ts.createSolutionBuilderWithWatchHost(sys, undefined, reportDiagnostic, ts.createBuilderStatusReporter(sys, shouldBePretty(sys, buildOptions)), createWatchStatusReporter(sys, buildOptions));
94741             updateSolutionBuilderHost(sys, cb, buildHost_1);
94742             var builder_1 = ts.createSolutionBuilderWithWatch(buildHost_1, projects, buildOptions, watchOptions);
94743             builder_1.build();
94744             return builder_1;
94745         }
94746         var buildHost = ts.createSolutionBuilderHost(sys, undefined, reportDiagnostic, ts.createBuilderStatusReporter(sys, shouldBePretty(sys, buildOptions)), createReportErrorSummary(sys, buildOptions));
94747         updateSolutionBuilderHost(sys, cb, buildHost);
94748         var builder = ts.createSolutionBuilder(buildHost, projects, buildOptions);
94749         var exitStatus = buildOptions.clean ? builder.clean() : builder.build();
94750         ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.dumpLegend();
94751         return sys.exit(exitStatus);
94752     }
94753     function createReportErrorSummary(sys, options) {
94754         return shouldBePretty(sys, options) ?
94755             function (errorCount) { return sys.write(ts.getErrorSummaryText(errorCount, sys.newLine)); } :
94756             undefined;
94757     }
94758     function performCompilation(sys, cb, reportDiagnostic, config) {
94759         var fileNames = config.fileNames, options = config.options, projectReferences = config.projectReferences;
94760         var host = ts.createCompilerHostWorker(options, undefined, sys);
94761         var currentDirectory = host.getCurrentDirectory();
94762         var getCanonicalFileName = ts.createGetCanonicalFileName(host.useCaseSensitiveFileNames());
94763         ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, currentDirectory, getCanonicalFileName); });
94764         enableStatisticsAndTracing(sys, options, false);
94765         var programOptions = {
94766             rootNames: fileNames,
94767             options: options,
94768             projectReferences: projectReferences,
94769             host: host,
94770             configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(config)
94771         };
94772         var program = ts.createProgram(programOptions);
94773         var exitStatus = ts.emitFilesAndReportErrorsAndGetExitStatus(program, reportDiagnostic, function (s) { return sys.write(s + sys.newLine); }, createReportErrorSummary(sys, options));
94774         reportStatistics(sys, program);
94775         cb(program);
94776         return sys.exit(exitStatus);
94777     }
94778     function performIncrementalCompilation(sys, cb, reportDiagnostic, config) {
94779         var options = config.options, fileNames = config.fileNames, projectReferences = config.projectReferences;
94780         enableStatisticsAndTracing(sys, options, false);
94781         var host = ts.createIncrementalCompilerHost(options, sys);
94782         var exitStatus = ts.performIncrementalCompilation({
94783             host: host,
94784             system: sys,
94785             rootNames: fileNames,
94786             options: options,
94787             configFileParsingDiagnostics: ts.getConfigFileParsingDiagnostics(config),
94788             projectReferences: projectReferences,
94789             reportDiagnostic: reportDiagnostic,
94790             reportErrorSummary: createReportErrorSummary(sys, options),
94791             afterProgramEmitAndDiagnostics: function (builderProgram) {
94792                 reportStatistics(sys, builderProgram.getProgram());
94793                 cb(builderProgram);
94794             }
94795         });
94796         return sys.exit(exitStatus);
94797     }
94798     function updateSolutionBuilderHost(sys, cb, buildHost) {
94799         updateCreateProgram(sys, buildHost);
94800         buildHost.afterProgramEmitAndDiagnostics = function (program) {
94801             reportStatistics(sys, program.getProgram());
94802             cb(program);
94803         };
94804         buildHost.afterEmitBundle = cb;
94805     }
94806     function updateCreateProgram(sys, host) {
94807         var compileUsingBuilder = host.createProgram;
94808         host.createProgram = function (rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences) {
94809             ts.Debug.assert(rootNames !== undefined || (options === undefined && !!oldProgram));
94810             if (options !== undefined) {
94811                 enableStatisticsAndTracing(sys, options, true);
94812             }
94813             return compileUsingBuilder(rootNames, options, host, oldProgram, configFileParsingDiagnostics, projectReferences);
94814         };
94815     }
94816     function updateWatchCompilationHost(sys, cb, watchCompilerHost) {
94817         updateCreateProgram(sys, watchCompilerHost);
94818         var emitFilesUsingBuilder = watchCompilerHost.afterProgramCreate;
94819         watchCompilerHost.afterProgramCreate = function (builderProgram) {
94820             emitFilesUsingBuilder(builderProgram);
94821             reportStatistics(sys, builderProgram.getProgram());
94822             cb(builderProgram);
94823         };
94824     }
94825     function createWatchStatusReporter(sys, options) {
94826         return ts.createWatchStatusReporter(sys, shouldBePretty(sys, options));
94827     }
94828     function createWatchOfConfigFile(system, cb, reportDiagnostic, configParseResult, optionsToExtend, watchOptionsToExtend) {
94829         var watchCompilerHost = ts.createWatchCompilerHostOfConfigFile({
94830             configFileName: configParseResult.options.configFilePath,
94831             optionsToExtend: optionsToExtend,
94832             watchOptionsToExtend: watchOptionsToExtend,
94833             system: system,
94834             reportDiagnostic: reportDiagnostic,
94835             reportWatchStatus: createWatchStatusReporter(system, configParseResult.options)
94836         });
94837         updateWatchCompilationHost(system, cb, watchCompilerHost);
94838         watchCompilerHost.configFileParsingResult = configParseResult;
94839         return ts.createWatchProgram(watchCompilerHost);
94840     }
94841     function createWatchOfFilesAndCompilerOptions(system, cb, reportDiagnostic, rootFiles, options, watchOptions) {
94842         var watchCompilerHost = ts.createWatchCompilerHostOfFilesAndCompilerOptions({
94843             rootFiles: rootFiles,
94844             options: options,
94845             watchOptions: watchOptions,
94846             system: system,
94847             reportDiagnostic: reportDiagnostic,
94848             reportWatchStatus: createWatchStatusReporter(system, options)
94849         });
94850         updateWatchCompilationHost(system, cb, watchCompilerHost);
94851         return ts.createWatchProgram(watchCompilerHost);
94852     }
94853     function canReportDiagnostics(system, compilerOptions) {
94854         return system === ts.sys && (compilerOptions.diagnostics || compilerOptions.extendedDiagnostics);
94855     }
94856     function canTrace(system, compilerOptions) {
94857         return system === ts.sys && compilerOptions.generateTrace;
94858     }
94859     function enableStatisticsAndTracing(system, compilerOptions, isBuildMode) {
94860         if (canReportDiagnostics(system, compilerOptions)) {
94861             ts.performance.enable(system);
94862         }
94863         if (canTrace(system, compilerOptions)) {
94864             ts.startTracing(isBuildMode ? 1 : 0, compilerOptions.generateTrace, compilerOptions.configFilePath);
94865         }
94866     }
94867     function reportStatistics(sys, program) {
94868         var compilerOptions = program.getCompilerOptions();
94869         if (canTrace(sys, compilerOptions)) {
94870             ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.stopTracing(program.getTypeCatalog());
94871         }
94872         var statistics;
94873         if (canReportDiagnostics(sys, compilerOptions)) {
94874             statistics = [];
94875             var memoryUsed = sys.getMemoryUsage ? sys.getMemoryUsage() : -1;
94876             reportCountStatistic("Files", program.getSourceFiles().length);
94877             var lineCounts = countLines(program);
94878             var nodeCounts = countNodes(program);
94879             if (compilerOptions.extendedDiagnostics) {
94880                 for (var _i = 0, _a = ts.arrayFrom(lineCounts.keys()); _i < _a.length; _i++) {
94881                     var key = _a[_i];
94882                     reportCountStatistic("Lines of " + key, lineCounts.get(key));
94883                 }
94884                 for (var _b = 0, _c = ts.arrayFrom(nodeCounts.keys()); _b < _c.length; _b++) {
94885                     var key = _c[_b];
94886                     reportCountStatistic("Nodes of " + key, nodeCounts.get(key));
94887                 }
94888             }
94889             else {
94890                 reportCountStatistic("Lines", ts.reduceLeftIterator(lineCounts.values(), function (sum, count) { return sum + count; }, 0));
94891                 reportCountStatistic("Nodes", ts.reduceLeftIterator(nodeCounts.values(), function (sum, count) { return sum + count; }, 0));
94892             }
94893             reportCountStatistic("Identifiers", program.getIdentifierCount());
94894             reportCountStatistic("Symbols", program.getSymbolCount());
94895             reportCountStatistic("Types", program.getTypeCount());
94896             reportCountStatistic("Instantiations", program.getInstantiationCount());
94897             if (memoryUsed >= 0) {
94898                 reportStatisticalValue("Memory used", Math.round(memoryUsed / 1000) + "K");
94899             }
94900             var isPerformanceEnabled = ts.performance.isEnabled();
94901             var programTime = isPerformanceEnabled ? ts.performance.getDuration("Program") : 0;
94902             var bindTime = isPerformanceEnabled ? ts.performance.getDuration("Bind") : 0;
94903             var checkTime = isPerformanceEnabled ? ts.performance.getDuration("Check") : 0;
94904             var emitTime = isPerformanceEnabled ? ts.performance.getDuration("Emit") : 0;
94905             if (compilerOptions.extendedDiagnostics) {
94906                 var caches = program.getRelationCacheSizes();
94907                 reportCountStatistic("Assignability cache size", caches.assignable);
94908                 reportCountStatistic("Identity cache size", caches.identity);
94909                 reportCountStatistic("Subtype cache size", caches.subtype);
94910                 reportCountStatistic("Strict subtype cache size", caches.strictSubtype);
94911                 if (isPerformanceEnabled) {
94912                     ts.performance.forEachMeasure(function (name, duration) { return reportTimeStatistic(name + " time", duration); });
94913                 }
94914             }
94915             else if (isPerformanceEnabled) {
94916                 reportTimeStatistic("I/O read", ts.performance.getDuration("I/O Read"));
94917                 reportTimeStatistic("I/O write", ts.performance.getDuration("I/O Write"));
94918                 reportTimeStatistic("Parse time", programTime);
94919                 reportTimeStatistic("Bind time", bindTime);
94920                 reportTimeStatistic("Check time", checkTime);
94921                 reportTimeStatistic("Emit time", emitTime);
94922             }
94923             if (isPerformanceEnabled) {
94924                 reportTimeStatistic("Total time", programTime + bindTime + checkTime + emitTime);
94925             }
94926             reportStatistics();
94927             if (!isPerformanceEnabled) {
94928                 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");
94929             }
94930             else {
94931                 ts.performance.disable();
94932             }
94933         }
94934         function reportStatistics() {
94935             var nameSize = 0;
94936             var valueSize = 0;
94937             for (var _i = 0, statistics_1 = statistics; _i < statistics_1.length; _i++) {
94938                 var _a = statistics_1[_i], name = _a.name, value = _a.value;
94939                 if (name.length > nameSize) {
94940                     nameSize = name.length;
94941                 }
94942                 if (value.length > valueSize) {
94943                     valueSize = value.length;
94944                 }
94945             }
94946             for (var _b = 0, statistics_2 = statistics; _b < statistics_2.length; _b++) {
94947                 var _c = statistics_2[_b], name = _c.name, value = _c.value;
94948                 sys.write(ts.padRight(name + ":", nameSize + 2) + ts.padLeft(value.toString(), valueSize) + sys.newLine);
94949             }
94950         }
94951         function reportStatisticalValue(name, value) {
94952             statistics.push({ name: name, value: value });
94953         }
94954         function reportCountStatistic(name, count) {
94955             reportStatisticalValue(name, "" + count);
94956         }
94957         function reportTimeStatistic(name, time) {
94958             reportStatisticalValue(name, (time / 1000).toFixed(2) + "s");
94959         }
94960     }
94961     function writeConfigFile(sys, reportDiagnostic, options, fileNames) {
94962         var currentDirectory = sys.getCurrentDirectory();
94963         var file = ts.normalizePath(ts.combinePaths(currentDirectory, "tsconfig.json"));
94964         if (sys.fileExists(file)) {
94965             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.A_tsconfig_json_file_is_already_defined_at_Colon_0, file));
94966         }
94967         else {
94968             sys.writeFile(file, ts.generateTSConfig(options, fileNames, sys.newLine));
94969             reportDiagnostic(ts.createCompilerDiagnostic(ts.Diagnostics.Successfully_created_a_tsconfig_json_file));
94970         }
94971         return;
94972     }
94973 })(ts || (ts = {}));
94974 // This file actually uses arguments passed on commandline and executes it
94975 ts.Debug.loggingHost = {
94976     log: function (_level, s) {
94977         ts.sys.write("" + (s || "") + ts.sys.newLine);
94978     }
94979 };
94980 if (ts.Debug.isDebugging) {
94981     ts.Debug.enableDebugInfo();
94982 }
94983 if (ts.sys.tryEnableSourceMapsForHost && /^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))) {
94984     ts.sys.tryEnableSourceMapsForHost();
94985 }
94986 if (ts.sys.setBlocking) {
94987     ts.sys.setBlocking();
94988 }
94989 ts.executeCommandLine(ts.sys, ts.noop, ts.sys.args);