diff --git a/doc/api/cli.md b/doc/api/cli.md
index 51a84cebb79678..100bccc5fb22db 100644
--- a/doc/api/cli.md
+++ b/doc/api/cli.md
@@ -100,6 +100,62 @@ If this flag is passed, the behavior can still be set to not abort through
[`process.setUncaughtExceptionCaptureCallback()`][] (and through usage of the
`node:domain` module that uses it).
+### `--build-snapshot`
+
+
+
+> Stability: 1 - Experimental
+
+Generates a snapshot blob when the process exits and writes it to
+disk, which can be loaded later with `--snapshot-blob`.
+
+When building the snapshot, if `--snapshot-blob` is not specified,
+the generated blob will be written, by default, to `snapshot.blob`
+in the current working directory. Otherwise it will be written to
+the path specified by `--snapshot-blob`.
+
+```console
+$ echo "globalThis.foo = 'I am from the snapshot'" > snapshot.js
+
+# Run snapshot.js to intialize the application and snapshot the
+# state of it into snapshot.blob.
+$ node --snapshot-blob snapshot.blob --build-snapshot snapshot.js
+
+$ echo "console.log(globalThis.foo)" > index.js
+
+# Load the generated snapshot and start the application from index.js.
+$ node --snapshot-blob snapshot.blob index.js
+I am from the snapshot
+```
+
+The [`v8.startupSnapshot` API][] can be used to specify an entry point at
+snapshot building time, thus avoiding the need of an additional entry
+script at deserialization time:
+
+```console
+$ echo "require('v8').startupSnapshot.setDeserializeMainFunction(() => console.log('I am from the snapshot'))" > snapshot.js
+$ node --snapshot-blob snapshot.blob --build-snapshot snapshot.js
+$ node --snapshot-blob snapshot.blob
+I am from the snapshot
+```
+
+For more information, check out the [`v8.startupSnapshot` API][] documentation.
+
+Currently the support for run-time snapshot is experimental in that:
+
+1. User-land modules are not yet supported in the snapshot, so only
+ one single file can be snapshotted. Users can bundle their applications
+ into a single script with their bundler of choice before building
+ a snapshot, however.
+2. Only a subset of the built-in modules work in the snapshot, though the
+ Node.js core test suite checks that a few fairly complex applications
+ can be snapshotted. Support for more modules are being added. If any
+ crashes or buggy behaviors occur when building a snapshot, please file
+ a report in the [Node.js issue tracker][] and link to it in the
+ [tracking issue for user-land snapshots][].
+
### `--completion-bash`
+
+> Stability: 1 - Experimental
+
+When used with `--build-snapshot`, `--snapshot-blob` specifies the path
+where the generated snapshot blob will be written to. If not specified,
+the generated blob will be written, by default, to `snapshot.blob`
+in the current working directory.
+
+When used without `--build-snapshot`, `--snapshot-blob` specifies the
+path to the blob that will be used to restore the application state.
+
### `--test`
|$)/;
+ block$1.html = edit(block$1.html, 'i').replace('comment', block$1._comment).replace('tag', block$1._tag).replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
+ block$1.paragraph = edit(block$1._paragraph).replace('hr', block$1.hr).replace('heading', ' {0,3}#{1,6} ').replace('|lheading', '') // setex headings don't interrupt commonmark paragraphs
+ .replace('blockquote', ' {0,3}>').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
+ .replace('html', '?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)').replace('tag', block$1._tag) // pars can be interrupted by type (6) html blocks
+ .getRegex();
+ block$1.blockquote = edit(block$1.blockquote).replace('paragraph', block$1.paragraph).getRegex();
+ /**
+ * Normal Block Grammar
+ */
+
+ block$1.normal = merge$1({}, block$1);
+ /**
+ * GFM Block Grammar
+ */
+
+ block$1.gfm = merge$1({}, block$1.normal, {
+ table: '^ *([^\\n ].*\\|.*)\\n' // Header
+ + ' {0,3}(?:\\| *)?(:?-+:? *(?:\\| *:?-+:? *)*)(?:\\| *)?' // Align
+ + '(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)' // Cells
+
+ });
+ block$1.gfm.table = edit(block$1.gfm.table).replace('hr', block$1.hr).replace('heading', ' {0,3}#{1,6} ').replace('blockquote', ' {0,3}>').replace('code', ' {4}[^\\n]').replace('fences', ' {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n').replace('list', ' {0,3}(?:[*+-]|1[.)]) ') // only lists starting from 1 can interrupt
+ .replace('html', '?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)').replace('tag', block$1._tag) // tables can be interrupted by type (6) html blocks
+ .getRegex();
+ /**
+ * Pedantic grammar (original John Gruber's loose markdown specification)
+ */
+
+ block$1.pedantic = merge$1({}, block$1.normal, {
+ html: edit('^ *(?:comment *(?:\\n|\\s*$)' + '|<(tag)[\\s\\S]+?\\1> *(?:\\n{2,}|\\s*$)' // closed tag
+ + '|
' + (escaped ? _code : escape$1(_code, true)) + '
\n';
+ }
+
+ return '' + (escaped ? _code : escape$1(_code, true)) + '
\n';
+ };
+
+ _proto.blockquote = function blockquote(quote) {
+ return '\n' + quote + '\n'; + }; + + _proto.html = function html(_html) { + return _html; + }; + + _proto.heading = function heading(text, level, raw, slugger) { + if (this.options.headerIds) { + return '
' + text + '
\n'; + }; + + _proto.table = function table(header, body) { + if (body) body = '' + body + ''; + return '' + text + '
';
+ };
+
+ _proto.br = function br() {
+ return this.options.xhtml ? 'An error occurred:
' + escape(e.message + '', true) + ''; + } + + throw e; + } + } + /** + * Options + */ + + + marked.options = marked.setOptions = function (opt) { + merge(marked.defaults, opt); + changeDefaults(marked.defaults); + return marked; + }; + + marked.getDefaults = getDefaults; + marked.defaults = defaults; + /** + * Use Extension + */ + + marked.use = function () { + var _this = this; + + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + var opts = merge.apply(void 0, [{}].concat(args)); + var extensions = marked.defaults.extensions || { + renderers: {}, + childTokens: {} + }; + var hasExtensions; + args.forEach(function (pack) { + // ==-- Parse "addon" extensions --== // + if (pack.extensions) { + hasExtensions = true; + pack.extensions.forEach(function (ext) { + if (!ext.name) { + throw new Error('extension name required'); + } + + if (ext.renderer) { + // Renderer extensions + var prevRenderer = extensions.renderers ? extensions.renderers[ext.name] : null; + + if (prevRenderer) { + // Replace extension with func to run new extension but fall back if false + extensions.renderers[ext.name] = function () { + for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { + args[_key2] = arguments[_key2]; + } + + var ret = ext.renderer.apply(this, args); + + if (ret === false) { + ret = prevRenderer.apply(this, args); + } + + return ret; + }; + } else { + extensions.renderers[ext.name] = ext.renderer; + } + } + + if (ext.tokenizer) { + // Tokenizer Extensions + if (!ext.level || ext.level !== 'block' && ext.level !== 'inline') { + throw new Error("extension level must be 'block' or 'inline'"); + } + + if (extensions[ext.level]) { + extensions[ext.level].unshift(ext.tokenizer); + } else { + extensions[ext.level] = [ext.tokenizer]; + } + + if (ext.start) { + // Function to check for start of token + if (ext.level === 'block') { + if (extensions.startBlock) { + extensions.startBlock.push(ext.start); + } else { + extensions.startBlock = [ext.start]; + } + } else if (ext.level === 'inline') { + if (extensions.startInline) { + extensions.startInline.push(ext.start); + } else { + extensions.startInline = [ext.start]; + } + } + } + } + + if (ext.childTokens) { + // Child tokens to be visited by walkTokens + extensions.childTokens[ext.name] = ext.childTokens; + } + }); + } // ==-- Parse "overwrite" extensions --== // + + + if (pack.renderer) { + (function () { + var renderer = marked.defaults.renderer || new Renderer(); + + var _loop = function _loop(prop) { + var prevRenderer = renderer[prop]; // Replace renderer with func to run extension, but fall back if false + + renderer[prop] = function () { + for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + var ret = pack.renderer[prop].apply(renderer, args); + + if (ret === false) { + ret = prevRenderer.apply(renderer, args); + } + + return ret; + }; + }; + + for (var prop in pack.renderer) { + _loop(prop); + } + + opts.renderer = renderer; + })(); + } + + if (pack.tokenizer) { + (function () { + var tokenizer = marked.defaults.tokenizer || new Tokenizer(); + + var _loop2 = function _loop2(prop) { + var prevTokenizer = tokenizer[prop]; // Replace tokenizer with func to run extension, but fall back if false + + tokenizer[prop] = function () { + for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) { + args[_key4] = arguments[_key4]; + } + + var ret = pack.tokenizer[prop].apply(tokenizer, args); + + if (ret === false) { + ret = prevTokenizer.apply(tokenizer, args); + } + + return ret; + }; + }; + + for (var prop in pack.tokenizer) { + _loop2(prop); + } + + opts.tokenizer = tokenizer; + })(); + } // ==-- Parse WalkTokens extensions --== // + + + if (pack.walkTokens) { + var walkTokens = marked.defaults.walkTokens; + + opts.walkTokens = function (token) { + pack.walkTokens.call(_this, token); + + if (walkTokens) { + walkTokens(token); + } + }; + } + + if (hasExtensions) { + opts.extensions = extensions; + } + + marked.setOptions(opts); + }); + }; + /** + * Run callback for every token + */ + + + marked.walkTokens = function (tokens, callback) { + var _loop3 = function _loop3() { + var token = _step.value; + callback(token); + + switch (token.type) { + case 'table': + { + for (var _iterator2 = _createForOfIteratorHelperLoose(token.header), _step2; !(_step2 = _iterator2()).done;) { + var cell = _step2.value; + marked.walkTokens(cell.tokens, callback); + } + + for (var _iterator3 = _createForOfIteratorHelperLoose(token.rows), _step3; !(_step3 = _iterator3()).done;) { + var row = _step3.value; + + for (var _iterator4 = _createForOfIteratorHelperLoose(row), _step4; !(_step4 = _iterator4()).done;) { + var _cell = _step4.value; + marked.walkTokens(_cell.tokens, callback); + } + } + + break; + } + + case 'list': + { + marked.walkTokens(token.items, callback); + break; + } + + default: + { + if (marked.defaults.extensions && marked.defaults.extensions.childTokens && marked.defaults.extensions.childTokens[token.type]) { + // Walk any extensions + marked.defaults.extensions.childTokens[token.type].forEach(function (childTokens) { + marked.walkTokens(token[childTokens], callback); + }); + } else if (token.tokens) { + marked.walkTokens(token.tokens, callback); + } + } + } + }; + + for (var _iterator = _createForOfIteratorHelperLoose(tokens), _step; !(_step = _iterator()).done;) { + _loop3(); + } + }; + /** + * Parse Inline + */ + + + marked.parseInline = function (src, opt) { + // throw error in case of non string input + if (typeof src === 'undefined' || src === null) { + throw new Error('marked.parseInline(): input parameter is undefined or null'); + } + + if (typeof src !== 'string') { + throw new Error('marked.parseInline(): input parameter is of type ' + Object.prototype.toString.call(src) + ', string expected'); + } + + opt = merge({}, marked.defaults, opt || {}); + checkSanitizeDeprecation(opt); + + try { + var tokens = Lexer.lexInline(src, opt); + + if (opt.walkTokens) { + marked.walkTokens(tokens, opt.walkTokens); + } + + return Parser.parseInline(tokens, opt); + } catch (e) { + e.message += '\nPlease report this to https://github.com/markedjs/marked.'; + + if (opt.silent) { + return '
An error occurred:
' + escape(e.message + '', true) + ''; + } + + throw e; + } + }; + /** + * Expose + */ + + + marked.Parser = Parser; + marked.parser = Parser.parse; + marked.Renderer = Renderer; + marked.TextRenderer = TextRenderer; + marked.Lexer = Lexer; + marked.lexer = Lexer.lex; + marked.Tokenizer = Tokenizer; + marked.Slugger = Slugger; + marked.parse = marked; + var marked_1 = marked; + + return marked_1; + +}))); diff --git a/test/fixtures/snapshot/mutate-fs.js b/test/fixtures/snapshot/mutate-fs.js new file mode 100644 index 00000000000000..f789ab63db54f9 --- /dev/null +++ b/test/fixtures/snapshot/mutate-fs.js @@ -0,0 +1,5 @@ +'use strict'; + +const fs = require('fs'); + +fs.foo = 'I am from the snapshot'; diff --git a/test/fixtures/snapshot/ts-example.js b/test/fixtures/snapshot/ts-example.js new file mode 100644 index 00000000000000..c0faffd7c9cafc --- /dev/null +++ b/test/fixtures/snapshot/ts-example.js @@ -0,0 +1,8 @@ +var VirtualPoint = /** @class */ (function () { + function VirtualPoint(x, y) { + this.x = x; + this.y = y; + } + return VirtualPoint; +}()); +var newVPoint = new VirtualPoint(13, 56); diff --git a/test/fixtures/snapshot/ts-example.ts b/test/fixtures/snapshot/ts-example.ts new file mode 100644 index 00000000000000..46b5409179671c --- /dev/null +++ b/test/fixtures/snapshot/ts-example.ts @@ -0,0 +1,11 @@ +class VirtualPoint { + x: number; + y: number; + + constructor(x: number, y: number) { + this.x = x; + this.y = y; + } +} + +const newVPoint = new VirtualPoint(13, 56); diff --git a/test/fixtures/snapshot/typescript-main.js b/test/fixtures/snapshot/typescript-main.js new file mode 100644 index 00000000000000..4b0c8274cec312 --- /dev/null +++ b/test/fixtures/snapshot/typescript-main.js @@ -0,0 +1,28 @@ +// This file is to be concatenated with +// https://github.com/microsoft/TypeScript/blob/main/lib/typescript.js +// to produce a snapshot that reads a file path from the command +// line and compile it into JavaScript, then write the +// result into another file. + +const fs = require('fs'); +const v8 = require('v8'); +const assert = require('assert'); + +v8.startupSnapshot.setDeserializeMainFunction(( { ts }) => { + const input = process.argv[1]; + const output = process.argv[2]; + console.error(`Compiling ${input} to ${output}`); + assert(input); + assert(output); + const source = fs.readFileSync(input, 'utf8'); + + let result = ts.transpileModule( + source, + { + compilerOptions: { + module: ts.ModuleKind.CommonJS + } + }); + + fs.writeFileSync(output, result.outputText, 'utf8'); +}, { ts }); diff --git a/test/fixtures/snapshot/typescript.js b/test/fixtures/snapshot/typescript.js new file mode 100644 index 00000000000000..e8734a648d0bcd --- /dev/null +++ b/test/fixtures/snapshot/typescript.js @@ -0,0 +1,168725 @@ +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. All rights reserved. +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +this file except in compliance with the License. You may obtain a copy of the +License at http://www.apache.org/licenses/LICENSE-2.0 + +THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED +WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, +MERCHANTABLITY OR NON-INFRINGEMENT. + +See the Apache Version 2.0 License for specific language governing permissions +and limitations under the License. +***************************************************************************** */ + +"use strict"; +var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +}; +var __assign = (this && this.__assign) || function () { + __assign = Object.assign || function(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) + t[p] = s[p]; + } + return t; + }; + return __assign.apply(this, arguments); +}; +var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (_) try { + 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; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __rest = (this && this.__rest) || function (s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; +}; +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +/* @internal */ +var ts; +(function (ts) { + function createMapData() { + var sentinel = {}; + sentinel.prev = sentinel; + return { head: sentinel, tail: sentinel, size: 0 }; + } + function createMapEntry(key, value) { + return { key: key, value: value, next: undefined, prev: undefined }; + } + function sameValueZero(x, y) { + // Treats -0 === 0 and NaN === NaN + return x === y || x !== x && y !== y; + } + function getPrev(entry) { + var prev = entry.prev; + // Entries without a 'prev' have been removed from the map. + // An entry whose 'prev' points to itself is the head of the list and is invalid here. + if (!prev || prev === entry) + throw new Error("Illegal state"); + return prev; + } + function getNext(entry) { + while (entry) { + // Entries without a 'prev' have been removed from the map. Their 'next' + // pointer should point to the previous entry prior to deletion and + // that entry should be skipped to resume iteration. + var skipNext = !entry.prev; + entry = entry.next; + if (skipNext) { + continue; + } + return entry; + } + } + function getEntry(data, key) { + // We walk backwards from 'tail' to prioritize recently added entries. + // We skip 'head' because it is an empty entry used to track iteration start. + for (var entry = data.tail; entry !== data.head; entry = getPrev(entry)) { + if (sameValueZero(entry.key, key)) { + return entry; + } + } + } + function addOrUpdateEntry(data, key, value) { + var existing = getEntry(data, key); + if (existing) { + existing.value = value; + return; + } + var entry = createMapEntry(key, value); + entry.prev = data.tail; + data.tail.next = entry; + data.tail = entry; + data.size++; + return entry; + } + function deleteEntry(data, key) { + // We walk backwards from 'tail' to prioritize recently added entries. + // We skip 'head' because it is an empty entry used to track iteration start. + for (var entry = data.tail; entry !== data.head; entry = getPrev(entry)) { + // all entries in the map should have a 'prev' pointer. + if (entry.prev === undefined) + throw new Error("Illegal state"); + if (sameValueZero(entry.key, key)) { + if (entry.next) { + entry.next.prev = entry.prev; + } + else { + // an entry in the map without a 'next' pointer must be the 'tail'. + if (data.tail !== entry) + throw new Error("Illegal state"); + data.tail = entry.prev; + } + entry.prev.next = entry.next; + entry.next = entry.prev; + entry.prev = undefined; + data.size--; + return entry; + } + } + } + function clearEntries(data) { + var node = data.tail; + while (node !== data.head) { + var prev = getPrev(node); + node.next = data.head; + node.prev = undefined; + node = prev; + } + data.head.next = undefined; + data.tail = data.head; + data.size = 0; + } + function forEachEntry(data, action) { + var entry = data.head; + while (entry) { + entry = getNext(entry); + if (entry) { + action(entry.value, entry.key); + } + } + } + function forEachIteration(iterator, action) { + if (iterator) { + for (var step = iterator.next(); !step.done; step = iterator.next()) { + action(step.value); + } + } + } + function createIteratorData(data, selector) { + return { current: data.head, selector: selector }; + } + function iteratorNext(data) { + // Navigate to the next entry. + data.current = getNext(data.current); + if (data.current) { + return { value: data.selector(data.current.key, data.current.value), done: false }; + } + else { + return { value: undefined, done: true }; + } + } + /* @internal */ + var ShimCollections; + (function (ShimCollections) { + function createMapShim(getIterator) { + var MapIterator = /** @class */ (function () { + function MapIterator(data, selector) { + this._data = createIteratorData(data, selector); + } + MapIterator.prototype.next = function () { return iteratorNext(this._data); }; + return MapIterator; + }()); + return /** @class */ (function () { + function Map(iterable) { + var _this = this; + this._mapData = createMapData(); + forEachIteration(getIterator(iterable), function (_a) { + var key = _a[0], value = _a[1]; + return _this.set(key, value); + }); + } + Object.defineProperty(Map.prototype, "size", { + get: function () { return this._mapData.size; }, + enumerable: false, + configurable: true + }); + Map.prototype.get = function (key) { var _a; return (_a = getEntry(this._mapData, key)) === null || _a === void 0 ? void 0 : _a.value; }; + Map.prototype.set = function (key, value) { return addOrUpdateEntry(this._mapData, key, value), this; }; + Map.prototype.has = function (key) { return !!getEntry(this._mapData, key); }; + Map.prototype.delete = function (key) { return !!deleteEntry(this._mapData, key); }; + Map.prototype.clear = function () { clearEntries(this._mapData); }; + Map.prototype.keys = function () { return new MapIterator(this._mapData, function (key, _value) { return key; }); }; + Map.prototype.values = function () { return new MapIterator(this._mapData, function (_key, value) { return value; }); }; + Map.prototype.entries = function () { return new MapIterator(this._mapData, function (key, value) { return [key, value]; }); }; + Map.prototype.forEach = function (action) { forEachEntry(this._mapData, action); }; + return Map; + }()); + } + ShimCollections.createMapShim = createMapShim; + function createSetShim(getIterator) { + var SetIterator = /** @class */ (function () { + function SetIterator(data, selector) { + this._data = createIteratorData(data, selector); + } + SetIterator.prototype.next = function () { return iteratorNext(this._data); }; + return SetIterator; + }()); + return /** @class */ (function () { + function Set(iterable) { + var _this = this; + this._mapData = createMapData(); + forEachIteration(getIterator(iterable), function (value) { return _this.add(value); }); + } + Object.defineProperty(Set.prototype, "size", { + get: function () { return this._mapData.size; }, + enumerable: false, + configurable: true + }); + Set.prototype.add = function (value) { return addOrUpdateEntry(this._mapData, value, value), this; }; + Set.prototype.has = function (value) { return !!getEntry(this._mapData, value); }; + Set.prototype.delete = function (value) { return !!deleteEntry(this._mapData, value); }; + Set.prototype.clear = function () { clearEntries(this._mapData); }; + Set.prototype.keys = function () { return new SetIterator(this._mapData, function (key, _value) { return key; }); }; + Set.prototype.values = function () { return new SetIterator(this._mapData, function (_key, value) { return value; }); }; + Set.prototype.entries = function () { return new SetIterator(this._mapData, function (key, value) { return [key, value]; }); }; + Set.prototype.forEach = function (action) { forEachEntry(this._mapData, action); }; + return Set; + }()); + } + ShimCollections.createSetShim = createSetShim; + })(ShimCollections = ts.ShimCollections || (ts.ShimCollections = {})); +})(ts || (ts = {})); +var ts; +(function (ts) { + // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values. + // If changing the text in this section, be sure to test `configurePrerelease` too. + ts.versionMajorMinor = "4.7"; + // The following is baselined as a literal template type without intervention + /** The version of the TypeScript compiler release */ + // eslint-disable-next-line @typescript-eslint/no-inferrable-types + ts.version = "4.7.4"; + /* @internal */ + var Comparison; + (function (Comparison) { + Comparison[Comparison["LessThan"] = -1] = "LessThan"; + Comparison[Comparison["EqualTo"] = 0] = "EqualTo"; + Comparison[Comparison["GreaterThan"] = 1] = "GreaterThan"; + })(Comparison = ts.Comparison || (ts.Comparison = {})); + /* @internal */ + var NativeCollections; + (function (NativeCollections) { + var globals = typeof globalThis !== "undefined" ? globalThis : + typeof global !== "undefined" ? global : + typeof self !== "undefined" ? self : + undefined; + /** + * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). + */ + function tryGetNativeMap() { + // Internet Explorer's Map doesn't support iteration, so don't use it. + var gMap = globals === null || globals === void 0 ? void 0 : globals.Map; + // eslint-disable-next-line no-in-operator + return typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined; + } + NativeCollections.tryGetNativeMap = tryGetNativeMap; + /** + * Returns the native Set implementation if it is available and compatible (i.e. supports iteration). + */ + function tryGetNativeSet() { + // Internet Explorer's Set doesn't support iteration, so don't use it. + var gSet = globals === null || globals === void 0 ? void 0 : globals.Set; + // eslint-disable-next-line no-in-operator + return typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined; + } + NativeCollections.tryGetNativeSet = tryGetNativeSet; + })(NativeCollections || (NativeCollections = {})); + /* @internal */ + ts.Map = getCollectionImplementation("Map", "tryGetNativeMap", "createMapShim"); + /* @internal */ + ts.Set = getCollectionImplementation("Set", "tryGetNativeSet", "createSetShim"); + /* @internal */ + function getCollectionImplementation(name, nativeFactory, shimFactory) { + var _a; + // NOTE: ts.ShimCollections will be defined for typescriptServices.js but not for tsc.js, so we must test for it. + var constructor = (_a = NativeCollections[nativeFactory]()) !== null && _a !== void 0 ? _a : ts.ShimCollections === null || ts.ShimCollections === void 0 ? void 0 : ts.ShimCollections[shimFactory](ts.getIterator); + if (constructor) + return constructor; + throw new Error("TypeScript requires an environment that provides a compatible native ".concat(name, " implementation.")); + } +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + function getIterator(iterable) { + if (iterable) { + if (isArray(iterable)) + return arrayIterator(iterable); + if (iterable instanceof ts.Map) + return iterable.entries(); + if (iterable instanceof ts.Set) + return iterable.values(); + throw new Error("Iteration not supported."); + } + } + ts.getIterator = getIterator; + ts.emptyArray = []; + ts.emptyMap = new ts.Map(); + ts.emptySet = new ts.Set(); + function length(array) { + return array ? array.length : 0; + } + ts.length = length; + /** + * Iterates through 'array' by index and performs the callback on each element of array until the callback + * returns a truthy value, then returns that value. + * If no such value is found, the callback is applied to each element of array and undefined is returned. + */ + function forEach(array, callback) { + if (array) { + for (var i = 0; i < array.length; i++) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + return undefined; + } + ts.forEach = forEach; + /** + * Like `forEach`, but iterates in reverse order. + */ + function forEachRight(array, callback) { + if (array) { + for (var i = array.length - 1; i >= 0; i--) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + } + return undefined; + } + ts.forEachRight = forEachRight; + /** Like `forEach`, but suitable for use with numbers and strings (which may be falsy). */ + function firstDefined(array, callback) { + if (array === undefined) { + return undefined; + } + for (var i = 0; i < array.length; i++) { + var result = callback(array[i], i); + if (result !== undefined) { + return result; + } + } + return undefined; + } + ts.firstDefined = firstDefined; + function firstDefinedIterator(iter, callback) { + while (true) { + var iterResult = iter.next(); + if (iterResult.done) { + return undefined; + } + var result = callback(iterResult.value); + if (result !== undefined) { + return result; + } + } + } + ts.firstDefinedIterator = firstDefinedIterator; + function reduceLeftIterator(iterator, f, initial) { + var result = initial; + if (iterator) { + for (var step = iterator.next(), pos = 0; !step.done; step = iterator.next(), pos++) { + result = f(result, step.value, pos); + } + } + return result; + } + ts.reduceLeftIterator = reduceLeftIterator; + function zipWith(arrayA, arrayB, callback) { + var result = []; + ts.Debug.assertEqual(arrayA.length, arrayB.length); + for (var i = 0; i < arrayA.length; i++) { + result.push(callback(arrayA[i], arrayB[i], i)); + } + return result; + } + ts.zipWith = zipWith; + function zipToIterator(arrayA, arrayB) { + ts.Debug.assertEqual(arrayA.length, arrayB.length); + var i = 0; + return { + next: function () { + if (i === arrayA.length) { + return { value: undefined, done: true }; + } + i++; + return { value: [arrayA[i - 1], arrayB[i - 1]], done: false }; + } + }; + } + ts.zipToIterator = zipToIterator; + function zipToMap(keys, values) { + ts.Debug.assert(keys.length === values.length); + var map = new ts.Map(); + for (var i = 0; i < keys.length; ++i) { + map.set(keys[i], values[i]); + } + return map; + } + ts.zipToMap = zipToMap; + /** + * Creates a new array with `element` interspersed in between each element of `input` + * if there is more than 1 value in `input`. Otherwise, returns the existing array. + */ + function intersperse(input, element) { + if (input.length <= 1) { + return input; + } + var result = []; + for (var i = 0, n = input.length; i < n; i++) { + if (i) + result.push(element); + result.push(input[i]); + } + return result; + } + ts.intersperse = intersperse; + /** + * Iterates through `array` by index and performs the callback on each element of array until the callback + * returns a falsey value, then returns false. + * If no such value is found, the callback is applied to each element of array and `true` is returned. + */ + function every(array, callback) { + if (array) { + for (var i = 0; i < array.length; i++) { + if (!callback(array[i], i)) { + return false; + } + } + } + return true; + } + ts.every = every; + function find(array, predicate) { + for (var i = 0; i < array.length; i++) { + var value = array[i]; + if (predicate(value, i)) { + return value; + } + } + return undefined; + } + ts.find = find; + function findLast(array, predicate) { + for (var i = array.length - 1; i >= 0; i--) { + var value = array[i]; + if (predicate(value, i)) { + return value; + } + } + return undefined; + } + ts.findLast = findLast; + /** Works like Array.prototype.findIndex, returning `-1` if no element satisfying the predicate is found. */ + function findIndex(array, predicate, startIndex) { + for (var i = startIndex || 0; i < array.length; i++) { + if (predicate(array[i], i)) { + return i; + } + } + return -1; + } + ts.findIndex = findIndex; + function findLastIndex(array, predicate, startIndex) { + for (var i = startIndex === undefined ? array.length - 1 : startIndex; i >= 0; i--) { + if (predicate(array[i], i)) { + return i; + } + } + return -1; + } + ts.findLastIndex = findLastIndex; + /** + * Returns the first truthy result of `callback`, or else fails. + * This is like `forEach`, but never returns undefined. + */ + function findMap(array, callback) { + for (var i = 0; i < array.length; i++) { + var result = callback(array[i], i); + if (result) { + return result; + } + } + return ts.Debug.fail(); + } + ts.findMap = findMap; + function contains(array, value, equalityComparer) { + if (equalityComparer === void 0) { equalityComparer = equateValues; } + if (array) { + for (var _i = 0, array_1 = array; _i < array_1.length; _i++) { + var v = array_1[_i]; + if (equalityComparer(v, value)) { + return true; + } + } + } + return false; + } + ts.contains = contains; + function arraysEqual(a, b, equalityComparer) { + if (equalityComparer === void 0) { equalityComparer = equateValues; } + return a.length === b.length && a.every(function (x, i) { return equalityComparer(x, b[i]); }); + } + ts.arraysEqual = arraysEqual; + function indexOfAnyCharCode(text, charCodes, start) { + for (var i = start || 0; i < text.length; i++) { + if (contains(charCodes, text.charCodeAt(i))) { + return i; + } + } + return -1; + } + ts.indexOfAnyCharCode = indexOfAnyCharCode; + function countWhere(array, predicate) { + var count = 0; + if (array) { + for (var i = 0; i < array.length; i++) { + var v = array[i]; + if (predicate(v, i)) { + count++; + } + } + } + return count; + } + ts.countWhere = countWhere; + function filter(array, f) { + if (array) { + var len = array.length; + var i = 0; + while (i < len && f(array[i])) + i++; + if (i < len) { + var result = array.slice(0, i); + i++; + while (i < len) { + var item = array[i]; + if (f(item)) { + result.push(item); + } + i++; + } + return result; + } + } + return array; + } + ts.filter = filter; + function filterMutate(array, f) { + var outIndex = 0; + for (var i = 0; i < array.length; i++) { + if (f(array[i], i, array)) { + array[outIndex] = array[i]; + outIndex++; + } + } + array.length = outIndex; + } + ts.filterMutate = filterMutate; + function clear(array) { + array.length = 0; + } + ts.clear = clear; + function map(array, f) { + var result; + if (array) { + result = []; + for (var i = 0; i < array.length; i++) { + result.push(f(array[i], i)); + } + } + return result; + } + ts.map = map; + function mapIterator(iter, mapFn) { + return { + next: function () { + var iterRes = iter.next(); + return iterRes.done ? iterRes : { value: mapFn(iterRes.value), done: false }; + } + }; + } + ts.mapIterator = mapIterator; + function sameMap(array, f) { + if (array) { + for (var i = 0; i < array.length; i++) { + var item = array[i]; + var mapped = f(item, i); + if (item !== mapped) { + var result = array.slice(0, i); + result.push(mapped); + for (i++; i < array.length; i++) { + result.push(f(array[i], i)); + } + return result; + } + } + } + return array; + } + ts.sameMap = sameMap; + /** + * Flattens an array containing a mix of array or non-array elements. + * + * @param array The array to flatten. + */ + function flatten(array) { + var result = []; + for (var _i = 0, array_2 = array; _i < array_2.length; _i++) { + var v = array_2[_i]; + if (v) { + if (isArray(v)) { + addRange(result, v); + } + else { + result.push(v); + } + } + } + return result; + } + ts.flatten = flatten; + /** + * Maps an array. If the mapped value is an array, it is spread into the result. + * + * @param array The array to map. + * @param mapfn The callback used to map the result into one or more values. + */ + function flatMap(array, mapfn) { + var result; + if (array) { + for (var i = 0; i < array.length; i++) { + var v = mapfn(array[i], i); + if (v) { + if (isArray(v)) { + result = addRange(result, v); + } + else { + result = append(result, v); + } + } + } + } + return result || ts.emptyArray; + } + ts.flatMap = flatMap; + function flatMapToMutable(array, mapfn) { + var result = []; + if (array) { + for (var i = 0; i < array.length; i++) { + var v = mapfn(array[i], i); + if (v) { + if (isArray(v)) { + addRange(result, v); + } + else { + result.push(v); + } + } + } + } + return result; + } + ts.flatMapToMutable = flatMapToMutable; + function flatMapIterator(iter, mapfn) { + var first = iter.next(); + if (first.done) { + return ts.emptyIterator; + } + var currentIter = getIterator(first.value); + return { + next: function () { + while (true) { + var currentRes = currentIter.next(); + if (!currentRes.done) { + return currentRes; + } + var iterRes = iter.next(); + if (iterRes.done) { + return iterRes; + } + currentIter = getIterator(iterRes.value); + } + }, + }; + function getIterator(x) { + var res = mapfn(x); + return res === undefined ? ts.emptyIterator : isArray(res) ? arrayIterator(res) : res; + } + } + ts.flatMapIterator = flatMapIterator; + function sameFlatMap(array, mapfn) { + var result; + if (array) { + for (var i = 0; i < array.length; i++) { + var item = array[i]; + var mapped = mapfn(item, i); + if (result || item !== mapped || isArray(mapped)) { + if (!result) { + result = array.slice(0, i); + } + if (isArray(mapped)) { + addRange(result, mapped); + } + else { + result.push(mapped); + } + } + } + } + return result || array; + } + ts.sameFlatMap = sameFlatMap; + function mapAllOrFail(array, mapFn) { + var result = []; + for (var i = 0; i < array.length; i++) { + var mapped = mapFn(array[i], i); + if (mapped === undefined) { + return undefined; + } + result.push(mapped); + } + return result; + } + ts.mapAllOrFail = mapAllOrFail; + function mapDefined(array, mapFn) { + var result = []; + if (array) { + for (var i = 0; i < array.length; i++) { + var mapped = mapFn(array[i], i); + if (mapped !== undefined) { + result.push(mapped); + } + } + } + return result; + } + ts.mapDefined = mapDefined; + function mapDefinedIterator(iter, mapFn) { + return { + next: function () { + while (true) { + var res = iter.next(); + if (res.done) { + return res; + } + var value = mapFn(res.value); + if (value !== undefined) { + return { value: value, done: false }; + } + } + } + }; + } + ts.mapDefinedIterator = mapDefinedIterator; + function mapDefinedEntries(map, f) { + if (!map) { + return undefined; + } + var result = new ts.Map(); + map.forEach(function (value, key) { + var entry = f(key, value); + if (entry !== undefined) { + var newKey = entry[0], newValue = entry[1]; + if (newKey !== undefined && newValue !== undefined) { + result.set(newKey, newValue); + } + } + }); + return result; + } + ts.mapDefinedEntries = mapDefinedEntries; + function mapDefinedValues(set, f) { + if (set) { + var result_1 = new ts.Set(); + set.forEach(function (value) { + var newValue = f(value); + if (newValue !== undefined) { + result_1.add(newValue); + } + }); + return result_1; + } + } + ts.mapDefinedValues = mapDefinedValues; + function getOrUpdate(map, key, callback) { + if (map.has(key)) { + return map.get(key); + } + var value = callback(); + map.set(key, value); + return value; + } + ts.getOrUpdate = getOrUpdate; + function tryAddToSet(set, value) { + if (!set.has(value)) { + set.add(value); + return true; + } + return false; + } + ts.tryAddToSet = tryAddToSet; + ts.emptyIterator = { next: function () { return ({ value: undefined, done: true }); } }; + function singleIterator(value) { + var done = false; + return { + next: function () { + var wasDone = done; + done = true; + return wasDone ? { value: undefined, done: true } : { value: value, done: false }; + } + }; + } + ts.singleIterator = singleIterator; + function spanMap(array, keyfn, mapfn) { + var result; + if (array) { + result = []; + var len = array.length; + var previousKey = void 0; + var key = void 0; + var start = 0; + var pos = 0; + while (start < len) { + while (pos < len) { + var value = array[pos]; + key = keyfn(value, pos); + if (pos === 0) { + previousKey = key; + } + else if (key !== previousKey) { + break; + } + pos++; + } + if (start < pos) { + var v = mapfn(array.slice(start, pos), previousKey, start, pos); + if (v) { + result.push(v); + } + start = pos; + } + previousKey = key; + pos++; + } + } + return result; + } + ts.spanMap = spanMap; + function mapEntries(map, f) { + if (!map) { + return undefined; + } + var result = new ts.Map(); + map.forEach(function (value, key) { + var _a = f(key, value), newKey = _a[0], newValue = _a[1]; + result.set(newKey, newValue); + }); + return result; + } + ts.mapEntries = mapEntries; + function some(array, predicate) { + if (array) { + if (predicate) { + for (var _i = 0, array_3 = array; _i < array_3.length; _i++) { + var v = array_3[_i]; + if (predicate(v)) { + return true; + } + } + } + else { + return array.length > 0; + } + } + return false; + } + ts.some = some; + /** Calls the callback with (start, afterEnd) index pairs for each range where 'pred' is true. */ + function getRangesWhere(arr, pred, cb) { + var start; + for (var i = 0; i < arr.length; i++) { + if (pred(arr[i])) { + start = start === undefined ? i : start; + } + else { + if (start !== undefined) { + cb(start, i); + start = undefined; + } + } + } + if (start !== undefined) + cb(start, arr.length); + } + ts.getRangesWhere = getRangesWhere; + function concatenate(array1, array2) { + if (!some(array2)) + return array1; + if (!some(array1)) + return array2; + return __spreadArray(__spreadArray([], array1, true), array2, true); + } + ts.concatenate = concatenate; + function selectIndex(_, i) { + return i; + } + function indicesOf(array) { + return array.map(selectIndex); + } + ts.indicesOf = indicesOf; + function deduplicateRelational(array, equalityComparer, comparer) { + // Perform a stable sort of the array. This ensures the first entry in a list of + // duplicates remains the first entry in the result. + var indices = indicesOf(array); + stableSortIndices(array, indices, comparer); + var last = array[indices[0]]; + var deduplicated = [indices[0]]; + for (var i = 1; i < indices.length; i++) { + var index = indices[i]; + var item = array[index]; + if (!equalityComparer(last, item)) { + deduplicated.push(index); + last = item; + } + } + // restore original order + deduplicated.sort(); + return deduplicated.map(function (i) { return array[i]; }); + } + function deduplicateEquality(array, equalityComparer) { + var result = []; + for (var _i = 0, array_4 = array; _i < array_4.length; _i++) { + var item = array_4[_i]; + pushIfUnique(result, item, equalityComparer); + } + return result; + } + /** + * Deduplicates an unsorted array. + * @param equalityComparer An `EqualityComparer` used to determine if two values are duplicates. + * @param comparer An optional `Comparer` used to sort entries before comparison, though the + * result will remain in the original order in `array`. + */ + function deduplicate(array, equalityComparer, comparer) { + return array.length === 0 ? [] : + array.length === 1 ? array.slice() : + comparer ? deduplicateRelational(array, equalityComparer, comparer) : + deduplicateEquality(array, equalityComparer); + } + ts.deduplicate = deduplicate; + /** + * Deduplicates an array that has already been sorted. + */ + function deduplicateSorted(array, comparer) { + if (array.length === 0) + return ts.emptyArray; + var last = array[0]; + var deduplicated = [last]; + for (var i = 1; i < array.length; i++) { + var next = array[i]; + switch (comparer(next, last)) { + // equality comparison + case true: + // relational comparison + // falls through + case 0 /* Comparison.EqualTo */: + continue; + case -1 /* Comparison.LessThan */: + // If `array` is sorted, `next` should **never** be less than `last`. + return ts.Debug.fail("Array is unsorted."); + } + deduplicated.push(last = next); + } + return deduplicated; + } + function createSortedArray() { + return []; // TODO: GH#19873 + } + ts.createSortedArray = createSortedArray; + function insertSorted(array, insert, compare, allowDuplicates) { + if (array.length === 0) { + array.push(insert); + return; + } + var insertIndex = binarySearch(array, insert, identity, compare); + if (insertIndex < 0) { + array.splice(~insertIndex, 0, insert); + } + else if (allowDuplicates) { + array.splice(insertIndex, 0, insert); + } + } + ts.insertSorted = insertSorted; + function sortAndDeduplicate(array, comparer, equalityComparer) { + return deduplicateSorted(sort(array, comparer), equalityComparer || comparer || compareStringsCaseSensitive); + } + ts.sortAndDeduplicate = sortAndDeduplicate; + function arrayIsSorted(array, comparer) { + if (array.length < 2) + return true; + var prevElement = array[0]; + for (var _i = 0, _a = array.slice(1); _i < _a.length; _i++) { + var element = _a[_i]; + if (comparer(prevElement, element) === 1 /* Comparison.GreaterThan */) { + return false; + } + prevElement = element; + } + return true; + } + ts.arrayIsSorted = arrayIsSorted; + function arrayIsEqualTo(array1, array2, equalityComparer) { + if (equalityComparer === void 0) { equalityComparer = equateValues; } + if (!array1 || !array2) { + return array1 === array2; + } + if (array1.length !== array2.length) { + return false; + } + for (var i = 0; i < array1.length; i++) { + if (!equalityComparer(array1[i], array2[i], i)) { + return false; + } + } + return true; + } + ts.arrayIsEqualTo = arrayIsEqualTo; + function compact(array) { + var result; + if (array) { + for (var i = 0; i < array.length; i++) { + var v = array[i]; + if (result || !v) { + if (!result) { + result = array.slice(0, i); + } + if (v) { + result.push(v); + } + } + } + } + return result || array; + } + ts.compact = compact; + /** + * Gets the relative complement of `arrayA` with respect to `arrayB`, returning the elements that + * are not present in `arrayA` but are present in `arrayB`. Assumes both arrays are sorted + * based on the provided comparer. + */ + function relativeComplement(arrayA, arrayB, comparer) { + if (!arrayB || !arrayA || arrayB.length === 0 || arrayA.length === 0) + return arrayB; + var result = []; + loopB: for (var offsetA = 0, offsetB = 0; offsetB < arrayB.length; offsetB++) { + if (offsetB > 0) { + // Ensure `arrayB` is properly sorted. + ts.Debug.assertGreaterThanOrEqual(comparer(arrayB[offsetB], arrayB[offsetB - 1]), 0 /* Comparison.EqualTo */); + } + loopA: for (var startA = offsetA; offsetA < arrayA.length; offsetA++) { + if (offsetA > startA) { + // Ensure `arrayA` is properly sorted. We only need to perform this check if + // `offsetA` has changed since we entered the loop. + ts.Debug.assertGreaterThanOrEqual(comparer(arrayA[offsetA], arrayA[offsetA - 1]), 0 /* Comparison.EqualTo */); + } + switch (comparer(arrayB[offsetB], arrayA[offsetA])) { + case -1 /* Comparison.LessThan */: + // If B is less than A, B does not exist in arrayA. Add B to the result and + // move to the next element in arrayB without changing the current position + // in arrayA. + result.push(arrayB[offsetB]); + continue loopB; + case 0 /* Comparison.EqualTo */: + // If B is equal to A, B exists in arrayA. Move to the next element in + // arrayB without adding B to the result or changing the current position + // in arrayA. + continue loopB; + case 1 /* Comparison.GreaterThan */: + // If B is greater than A, we need to keep looking for B in arrayA. Move to + // the next element in arrayA and recheck. + continue loopA; + } + } + } + return result; + } + ts.relativeComplement = relativeComplement; + function sum(array, prop) { + var result = 0; + for (var _i = 0, array_5 = array; _i < array_5.length; _i++) { + var v = array_5[_i]; + result += v[prop]; + } + return result; + } + ts.sum = sum; + function append(to, value) { + if (value === undefined) + return to; + if (to === undefined) + return [value]; + to.push(value); + return to; + } + ts.append = append; + function combine(xs, ys) { + if (xs === undefined) + return ys; + if (ys === undefined) + return xs; + if (isArray(xs)) + return isArray(ys) ? concatenate(xs, ys) : append(xs, ys); + if (isArray(ys)) + return append(ys, xs); + return [xs, ys]; + } + ts.combine = combine; + /** + * Gets the actual offset into an array for a relative offset. Negative offsets indicate a + * position offset from the end of the array. + */ + function toOffset(array, offset) { + return offset < 0 ? array.length + offset : offset; + } + function addRange(to, from, start, end) { + if (from === undefined || from.length === 0) + return to; + if (to === undefined) + return from.slice(start, end); + start = start === undefined ? 0 : toOffset(from, start); + end = end === undefined ? from.length : toOffset(from, end); + for (var i = start; i < end && i < from.length; i++) { + if (from[i] !== undefined) { + to.push(from[i]); + } + } + return to; + } + ts.addRange = addRange; + /** + * @return Whether the value was added. + */ + function pushIfUnique(array, toAdd, equalityComparer) { + if (contains(array, toAdd, equalityComparer)) { + return false; + } + else { + array.push(toAdd); + return true; + } + } + ts.pushIfUnique = pushIfUnique; + /** + * Unlike `pushIfUnique`, this can take `undefined` as an input, and returns a new array. + */ + function appendIfUnique(array, toAdd, equalityComparer) { + if (array) { + pushIfUnique(array, toAdd, equalityComparer); + return array; + } + else { + return [toAdd]; + } + } + ts.appendIfUnique = appendIfUnique; + function stableSortIndices(array, indices, comparer) { + // sort indices by value then position + indices.sort(function (x, y) { return comparer(array[x], array[y]) || compareValues(x, y); }); + } + /** + * Returns a new sorted array. + */ + function sort(array, comparer) { + return (array.length === 0 ? array : array.slice().sort(comparer)); + } + ts.sort = sort; + function arrayIterator(array) { + var i = 0; + return { next: function () { + if (i === array.length) { + return { value: undefined, done: true }; + } + else { + i++; + return { value: array[i - 1], done: false }; + } + } }; + } + ts.arrayIterator = arrayIterator; + function arrayReverseIterator(array) { + var i = array.length; + return { + next: function () { + if (i === 0) { + return { value: undefined, done: true }; + } + else { + i--; + return { value: array[i], done: false }; + } + } + }; + } + ts.arrayReverseIterator = arrayReverseIterator; + /** + * Stable sort of an array. Elements equal to each other maintain their relative position in the array. + */ + function stableSort(array, comparer) { + var indices = indicesOf(array); + stableSortIndices(array, indices, comparer); + return indices.map(function (i) { return array[i]; }); + } + ts.stableSort = stableSort; + function rangeEquals(array1, array2, pos, end) { + while (pos < end) { + if (array1[pos] !== array2[pos]) { + return false; + } + pos++; + } + return true; + } + ts.rangeEquals = rangeEquals; + /** + * Returns the element at a specific offset in an array if non-empty, `undefined` otherwise. + * A negative offset indicates the element should be retrieved from the end of the array. + */ + function elementAt(array, offset) { + if (array) { + offset = toOffset(array, offset); + if (offset < array.length) { + return array[offset]; + } + } + return undefined; + } + ts.elementAt = elementAt; + /** + * Returns the first element of an array if non-empty, `undefined` otherwise. + */ + function firstOrUndefined(array) { + return array.length === 0 ? undefined : array[0]; + } + ts.firstOrUndefined = firstOrUndefined; + function first(array) { + ts.Debug.assert(array.length !== 0); + return array[0]; + } + ts.first = first; + /** + * Returns the last element of an array if non-empty, `undefined` otherwise. + */ + function lastOrUndefined(array) { + return array.length === 0 ? undefined : array[array.length - 1]; + } + ts.lastOrUndefined = lastOrUndefined; + function last(array) { + ts.Debug.assert(array.length !== 0); + return array[array.length - 1]; + } + ts.last = last; + /** + * Returns the only element of an array if it contains only one element, `undefined` otherwise. + */ + function singleOrUndefined(array) { + return array && array.length === 1 + ? array[0] + : undefined; + } + ts.singleOrUndefined = singleOrUndefined; + function singleOrMany(array) { + return array && array.length === 1 + ? array[0] + : array; + } + ts.singleOrMany = singleOrMany; + function replaceElement(array, index, value) { + var result = array.slice(0); + result[index] = value; + return result; + } + ts.replaceElement = replaceElement; + /** + * Performs a binary search, finding the index at which `value` occurs in `array`. + * If no such index is found, returns the 2's-complement of first index at which + * `array[index]` exceeds `value`. + * @param array A sorted array whose first element must be no larger than number + * @param value The value to be searched for in the array. + * @param keySelector A callback used to select the search key from `value` and each element of + * `array`. + * @param keyComparer A callback used to compare two keys in a sorted array. + * @param offset An offset into `array` at which to start the search. + */ + function binarySearch(array, value, keySelector, keyComparer, offset) { + return binarySearchKey(array, keySelector(value), keySelector, keyComparer, offset); + } + ts.binarySearch = binarySearch; + /** + * Performs a binary search, finding the index at which an object with `key` occurs in `array`. + * If no such index is found, returns the 2's-complement of first index at which + * `array[index]` exceeds `key`. + * @param array A sorted array whose first element must be no larger than number + * @param key The key to be searched for in the array. + * @param keySelector A callback used to select the search key from each element of `array`. + * @param keyComparer A callback used to compare two keys in a sorted array. + * @param offset An offset into `array` at which to start the search. + */ + function binarySearchKey(array, key, keySelector, keyComparer, offset) { + if (!some(array)) { + return -1; + } + var low = offset || 0; + var high = array.length - 1; + while (low <= high) { + var middle = low + ((high - low) >> 1); + var midKey = keySelector(array[middle], middle); + switch (keyComparer(midKey, key)) { + case -1 /* Comparison.LessThan */: + low = middle + 1; + break; + case 0 /* Comparison.EqualTo */: + return middle; + case 1 /* Comparison.GreaterThan */: + high = middle - 1; + break; + } + } + return ~low; + } + ts.binarySearchKey = binarySearchKey; + function reduceLeft(array, f, initial, start, count) { + if (array && array.length > 0) { + var size = array.length; + if (size > 0) { + var pos = start === undefined || start < 0 ? 0 : start; + var end = count === undefined || pos + count > size - 1 ? size - 1 : pos + count; + var result = void 0; + if (arguments.length <= 2) { + result = array[pos]; + pos++; + } + else { + result = initial; + } + while (pos <= end) { + result = f(result, array[pos], pos); + pos++; + } + return result; + } + } + return initial; + } + ts.reduceLeft = reduceLeft; + var hasOwnProperty = Object.prototype.hasOwnProperty; + /** + * Indicates whether a map-like contains an own property with the specified key. + * + * @param map A map-like. + * @param key A property key. + */ + function hasProperty(map, key) { + return hasOwnProperty.call(map, key); + } + ts.hasProperty = hasProperty; + /** + * Gets the value of an owned property in a map-like. + * + * @param map A map-like. + * @param key A property key. + */ + function getProperty(map, key) { + return hasOwnProperty.call(map, key) ? map[key] : undefined; + } + ts.getProperty = getProperty; + /** + * Gets the owned, enumerable property keys of a map-like. + */ + function getOwnKeys(map) { + var keys = []; + for (var key in map) { + if (hasOwnProperty.call(map, key)) { + keys.push(key); + } + } + return keys; + } + ts.getOwnKeys = getOwnKeys; + function getAllKeys(obj) { + var result = []; + do { + var names = Object.getOwnPropertyNames(obj); + for (var _i = 0, names_1 = names; _i < names_1.length; _i++) { + var name = names_1[_i]; + pushIfUnique(result, name); + } + } while (obj = Object.getPrototypeOf(obj)); + return result; + } + ts.getAllKeys = getAllKeys; + function getOwnValues(collection) { + var values = []; + for (var key in collection) { + if (hasOwnProperty.call(collection, key)) { + values.push(collection[key]); + } + } + return values; + } + ts.getOwnValues = getOwnValues; + var _entries = Object.entries || (function (obj) { + var keys = getOwnKeys(obj); + var result = Array(keys.length); + for (var i = 0; i < keys.length; i++) { + result[i] = [keys[i], obj[keys[i]]]; + } + return result; + }); + function getEntries(obj) { + return obj ? _entries(obj) : []; + } + ts.getEntries = getEntries; + function arrayOf(count, f) { + var result = new Array(count); + for (var i = 0; i < count; i++) { + result[i] = f(i); + } + return result; + } + ts.arrayOf = arrayOf; + function arrayFrom(iterator, map) { + var result = []; + for (var iterResult = iterator.next(); !iterResult.done; iterResult = iterator.next()) { + result.push(map ? map(iterResult.value) : iterResult.value); + } + return result; + } + ts.arrayFrom = arrayFrom; + function assign(t) { + var args = []; + for (var _i = 1; _i < arguments.length; _i++) { + args[_i - 1] = arguments[_i]; + } + for (var _a = 0, args_1 = args; _a < args_1.length; _a++) { + var arg = args_1[_a]; + if (arg === undefined) + continue; + for (var p in arg) { + if (hasProperty(arg, p)) { + t[p] = arg[p]; + } + } + } + return t; + } + ts.assign = assign; + /** + * Performs a shallow equality comparison of the contents of two map-likes. + * + * @param left A map-like whose properties should be compared. + * @param right A map-like whose properties should be compared. + */ + function equalOwnProperties(left, right, equalityComparer) { + if (equalityComparer === void 0) { equalityComparer = equateValues; } + if (left === right) + return true; + if (!left || !right) + return false; + for (var key in left) { + if (hasOwnProperty.call(left, key)) { + if (!hasOwnProperty.call(right, key)) + return false; + if (!equalityComparer(left[key], right[key])) + return false; + } + } + for (var key in right) { + if (hasOwnProperty.call(right, key)) { + if (!hasOwnProperty.call(left, key)) + return false; + } + } + return true; + } + ts.equalOwnProperties = equalOwnProperties; + function arrayToMap(array, makeKey, makeValue) { + if (makeValue === void 0) { makeValue = identity; } + var result = new ts.Map(); + for (var _i = 0, array_6 = array; _i < array_6.length; _i++) { + var value = array_6[_i]; + var key = makeKey(value); + if (key !== undefined) + result.set(key, makeValue(value)); + } + return result; + } + ts.arrayToMap = arrayToMap; + function arrayToNumericMap(array, makeKey, makeValue) { + if (makeValue === void 0) { makeValue = identity; } + var result = []; + for (var _i = 0, array_7 = array; _i < array_7.length; _i++) { + var value = array_7[_i]; + result[makeKey(value)] = makeValue(value); + } + return result; + } + ts.arrayToNumericMap = arrayToNumericMap; + function arrayToMultiMap(values, makeKey, makeValue) { + if (makeValue === void 0) { makeValue = identity; } + var result = createMultiMap(); + for (var _i = 0, values_1 = values; _i < values_1.length; _i++) { + var value = values_1[_i]; + result.add(makeKey(value), makeValue(value)); + } + return result; + } + ts.arrayToMultiMap = arrayToMultiMap; + function group(values, getGroupId, resultSelector) { + if (resultSelector === void 0) { resultSelector = identity; } + return arrayFrom(arrayToMultiMap(values, getGroupId).values(), resultSelector); + } + ts.group = group; + function clone(object) { + var result = {}; + for (var id in object) { + if (hasOwnProperty.call(object, id)) { + result[id] = object[id]; + } + } + return result; + } + ts.clone = clone; + /** + * Creates a new object by adding the own properties of `second`, then the own properties of `first`. + * + * NOTE: This means that if a property exists in both `first` and `second`, the property in `first` will be chosen. + */ + function extend(first, second) { + var result = {}; + for (var id in second) { + if (hasOwnProperty.call(second, id)) { + result[id] = second[id]; + } + } + for (var id in first) { + if (hasOwnProperty.call(first, id)) { + result[id] = first[id]; + } + } + return result; + } + ts.extend = extend; + function copyProperties(first, second) { + for (var id in second) { + if (hasOwnProperty.call(second, id)) { + first[id] = second[id]; + } + } + } + ts.copyProperties = copyProperties; + function maybeBind(obj, fn) { + return fn ? fn.bind(obj) : undefined; + } + ts.maybeBind = maybeBind; + function createMultiMap() { + var map = new ts.Map(); + map.add = multiMapAdd; + map.remove = multiMapRemove; + return map; + } + ts.createMultiMap = createMultiMap; + function multiMapAdd(key, value) { + var values = this.get(key); + if (values) { + values.push(value); + } + else { + this.set(key, values = [value]); + } + return values; + } + function multiMapRemove(key, value) { + var values = this.get(key); + if (values) { + unorderedRemoveItem(values, value); + if (!values.length) { + this.delete(key); + } + } + } + function createUnderscoreEscapedMultiMap() { + return createMultiMap(); + } + ts.createUnderscoreEscapedMultiMap = createUnderscoreEscapedMultiMap; + /** + * Creates a Set with custom equality and hash code functionality. This is useful when you + * want to use something looser than object identity - e.g. "has the same span". + * + * If `equals(a, b)`, it must be the case that `getHashCode(a) === getHashCode(b)`. + * The converse is not required. + * + * To facilitate a perf optimization (lazy allocation of bucket arrays), `TElement` is + * assumed not to be an array type. + */ + function createSet(getHashCode, equals) { + var multiMap = new ts.Map(); + var size = 0; + function getElementIterator() { + var valueIt = multiMap.values(); + var arrayIt; + return { + next: function () { + while (true) { + if (arrayIt) { + var n = arrayIt.next(); + if (!n.done) { + return { value: n.value }; + } + arrayIt = undefined; + } + else { + var n = valueIt.next(); + if (n.done) { + return { value: undefined, done: true }; + } + if (!isArray(n.value)) { + return { value: n.value }; + } + arrayIt = arrayIterator(n.value); + } + } + } + }; + } + var set = { + has: function (element) { + var hash = getHashCode(element); + if (!multiMap.has(hash)) + return false; + var candidates = multiMap.get(hash); + if (!isArray(candidates)) + return equals(candidates, element); + for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) { + var candidate = candidates_1[_i]; + if (equals(candidate, element)) { + return true; + } + } + return false; + }, + add: function (element) { + var hash = getHashCode(element); + if (multiMap.has(hash)) { + var values = multiMap.get(hash); + if (isArray(values)) { + if (!contains(values, element, equals)) { + values.push(element); + size++; + } + } + else { + var value = values; + if (!equals(value, element)) { + multiMap.set(hash, [value, element]); + size++; + } + } + } + else { + multiMap.set(hash, element); + size++; + } + return this; + }, + delete: function (element) { + var hash = getHashCode(element); + if (!multiMap.has(hash)) + return false; + var candidates = multiMap.get(hash); + if (isArray(candidates)) { + for (var i = 0; i < candidates.length; i++) { + if (equals(candidates[i], element)) { + if (candidates.length === 1) { + multiMap.delete(hash); + } + else if (candidates.length === 2) { + multiMap.set(hash, candidates[1 - i]); + } + else { + unorderedRemoveItemAt(candidates, i); + } + size--; + return true; + } + } + } + else { + var candidate = candidates; + if (equals(candidate, element)) { + multiMap.delete(hash); + size--; + return true; + } + } + return false; + }, + clear: function () { + multiMap.clear(); + size = 0; + }, + get size() { + return size; + }, + forEach: function (action) { + for (var _i = 0, _a = arrayFrom(multiMap.values()); _i < _a.length; _i++) { + var elements = _a[_i]; + if (isArray(elements)) { + for (var _b = 0, elements_1 = elements; _b < elements_1.length; _b++) { + var element = elements_1[_b]; + action(element, element); + } + } + else { + var element = elements; + action(element, element); + } + } + }, + keys: function () { + return getElementIterator(); + }, + values: function () { + return getElementIterator(); + }, + entries: function () { + var it = getElementIterator(); + return { + next: function () { + var n = it.next(); + return n.done ? n : { value: [n.value, n.value] }; + } + }; + }, + }; + return set; + } + ts.createSet = createSet; + /** + * Tests whether a value is an array. + */ + function isArray(value) { + return Array.isArray ? Array.isArray(value) : value instanceof Array; + } + ts.isArray = isArray; + function toArray(value) { + return isArray(value) ? value : [value]; + } + ts.toArray = toArray; + /** + * Tests whether a value is string + */ + function isString(text) { + return typeof text === "string"; + } + ts.isString = isString; + function isNumber(x) { + return typeof x === "number"; + } + ts.isNumber = isNumber; + function tryCast(value, test) { + return value !== undefined && test(value) ? value : undefined; + } + ts.tryCast = tryCast; + function cast(value, test) { + if (value !== undefined && test(value)) + return value; + return ts.Debug.fail("Invalid cast. The supplied value ".concat(value, " did not pass the test '").concat(ts.Debug.getFunctionName(test), "'.")); + } + ts.cast = cast; + /** Does nothing. */ + function noop(_) { } + ts.noop = noop; + /** Do nothing and return false */ + function returnFalse() { + return false; + } + ts.returnFalse = returnFalse; + /** Do nothing and return true */ + function returnTrue() { + return true; + } + ts.returnTrue = returnTrue; + /** Do nothing and return undefined */ + function returnUndefined() { + return undefined; + } + ts.returnUndefined = returnUndefined; + /** Returns its argument. */ + function identity(x) { + return x; + } + ts.identity = identity; + /** Returns lower case string */ + function toLowerCase(x) { + return x.toLowerCase(); + } + ts.toLowerCase = toLowerCase; + // We convert the file names to lower case as key for file name on case insensitive file system + // While doing so we need to handle special characters (eg \u0130) to ensure that we dont convert + // it to lower case, fileName with its lowercase form can exist along side it. + // Handle special characters and make those case sensitive instead + // + // |-#--|-Unicode--|-Char code-|-Desc-------------------------------------------------------------------| + // | 1. | i | 105 | Ascii i | + // | 2. | I | 73 | Ascii I | + // |-------- Special characters ------------------------------------------------------------------------| + // | 3. | \u0130 | 304 | Upper case I with dot above | + // | 4. | i,\u0307 | 105,775 | i, followed by 775: Lower case of (3rd item) | + // | 5. | I,\u0307 | 73,775 | I, followed by 775: Upper case of (4th item), lower case is (4th item) | + // | 6. | \u0131 | 305 | Lower case i without dot, upper case is I (2nd item) | + // | 7. | \u00DF | 223 | Lower case sharp s | + // + // Because item 3 is special where in its lowercase character has its own + // upper case form we cant convert its case. + // Rest special characters are either already in lower case format or + // they have corresponding upper case character so they dont need special handling + // + // But to avoid having to do string building for most common cases, also ignore + // a-z, 0-9, \u0131, \u00DF, \, /, ., : and space + var fileNameLowerCaseRegExp = /[^\u0130\u0131\u00DFa-z0-9\\/:\-_\. ]+/g; + /** + * Case insensitive file systems have descripencies in how they handle some characters (eg. turkish Upper case I with dot on top - \u0130) + * This function is used in places where we want to make file name as a key on these systems + * It is possible on mac to be able to refer to file name with I with dot on top as a fileName with its lower case form + * But on windows we cannot. Windows can have fileName with I with dot on top next to its lower case and they can not each be referred with the lowercase forms + * Technically we would want this function to be platform sepcific as well but + * our api has till now only taken caseSensitive as the only input and just for some characters we dont want to update API and ensure all customers use those api + * We could use upper case and we would still need to deal with the descripencies but + * we want to continue using lower case since in most cases filenames are lowercasewe and wont need any case changes and avoid having to store another string for the key + * So for this function purpose, we go ahead and assume character I with dot on top it as case sensitive since its very unlikely to use lower case form of that special character + */ + function toFileNameLowerCase(x) { + return fileNameLowerCaseRegExp.test(x) ? + x.replace(fileNameLowerCaseRegExp, toLowerCase) : + x; + } + ts.toFileNameLowerCase = toFileNameLowerCase; + /** Throws an error because a function is not implemented. */ + function notImplemented() { + throw new Error("Not implemented"); + } + ts.notImplemented = notImplemented; + function memoize(callback) { + var value; + return function () { + if (callback) { + value = callback(); + callback = undefined; + } + return value; + }; + } + ts.memoize = memoize; + /** A version of `memoize` that supports a single primitive argument */ + function memoizeOne(callback) { + var map = new ts.Map(); + return function (arg) { + var key = "".concat(typeof arg, ":").concat(arg); + var value = map.get(key); + if (value === undefined && !map.has(key)) { + value = callback(arg); + map.set(key, value); + } + return value; + }; + } + ts.memoizeOne = memoizeOne; + function compose(a, b, c, d, e) { + if (!!e) { + var args_2 = []; + for (var i = 0; i < arguments.length; i++) { + args_2[i] = arguments[i]; + } + return function (t) { return reduceLeft(args_2, function (u, f) { return f(u); }, t); }; + } + else if (d) { + return function (t) { return d(c(b(a(t)))); }; + } + else if (c) { + return function (t) { return c(b(a(t))); }; + } + else if (b) { + return function (t) { return b(a(t)); }; + } + else if (a) { + return function (t) { return a(t); }; + } + else { + return function (t) { return t; }; + } + } + ts.compose = compose; + var AssertionLevel; + (function (AssertionLevel) { + AssertionLevel[AssertionLevel["None"] = 0] = "None"; + AssertionLevel[AssertionLevel["Normal"] = 1] = "Normal"; + AssertionLevel[AssertionLevel["Aggressive"] = 2] = "Aggressive"; + AssertionLevel[AssertionLevel["VeryAggressive"] = 3] = "VeryAggressive"; + })(AssertionLevel = ts.AssertionLevel || (ts.AssertionLevel = {})); + function equateValues(a, b) { + return a === b; + } + ts.equateValues = equateValues; + /** + * Compare the equality of two strings using a case-sensitive ordinal comparison. + * + * Case-sensitive comparisons compare both strings one code-point at a time using the integer + * value of each code-point after applying `toUpperCase` to each string. We always map both + * strings to their upper-case form as some unicode characters do not properly round-trip to + * lowercase (such as `ẞ` (German sharp capital s)). + */ + function equateStringsCaseInsensitive(a, b) { + return a === b + || a !== undefined + && b !== undefined + && a.toUpperCase() === b.toUpperCase(); + } + ts.equateStringsCaseInsensitive = equateStringsCaseInsensitive; + /** + * Compare the equality of two strings using a case-sensitive ordinal comparison. + * + * Case-sensitive comparisons compare both strings one code-point at a time using the + * integer value of each code-point. + */ + function equateStringsCaseSensitive(a, b) { + return equateValues(a, b); + } + ts.equateStringsCaseSensitive = equateStringsCaseSensitive; + function compareComparableValues(a, b) { + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : + a < b ? -1 /* Comparison.LessThan */ : + 1 /* Comparison.GreaterThan */; + } + /** + * Compare two numeric values for their order relative to each other. + * To compare strings, use any of the `compareStrings` functions. + */ + function compareValues(a, b) { + return compareComparableValues(a, b); + } + ts.compareValues = compareValues; + /** + * Compare two TextSpans, first by `start`, then by `length`. + */ + function compareTextSpans(a, b) { + 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); + } + ts.compareTextSpans = compareTextSpans; + function min(a, b, compare) { + return compare(a, b) === -1 /* Comparison.LessThan */ ? a : b; + } + ts.min = min; + /** + * Compare two strings using a case-insensitive ordinal comparison. + * + * Ordinal comparisons are based on the difference between the unicode code points of both + * strings. Characters with multiple unicode representations are considered unequal. Ordinal + * comparisons provide predictable ordering, but place "a" after "B". + * + * Case-insensitive comparisons compare both strings one code-point at a time using the integer + * value of each code-point after applying `toUpperCase` to each string. We always map both + * strings to their upper-case form as some unicode characters do not properly round-trip to + * lowercase (such as `ẞ` (German sharp capital s)). + */ + function compareStringsCaseInsensitive(a, b) { + if (a === b) + return 0 /* Comparison.EqualTo */; + if (a === undefined) + return -1 /* Comparison.LessThan */; + if (b === undefined) + return 1 /* Comparison.GreaterThan */; + a = a.toUpperCase(); + b = b.toUpperCase(); + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; + } + ts.compareStringsCaseInsensitive = compareStringsCaseInsensitive; + /** + * Compare two strings using a case-sensitive ordinal comparison. + * + * Ordinal comparisons are based on the difference between the unicode code points of both + * strings. Characters with multiple unicode representations are considered unequal. Ordinal + * comparisons provide predictable ordering, but place "a" after "B". + * + * Case-sensitive comparisons compare both strings one code-point at a time using the integer + * value of each code-point. + */ + function compareStringsCaseSensitive(a, b) { + return compareComparableValues(a, b); + } + ts.compareStringsCaseSensitive = compareStringsCaseSensitive; + function getStringComparer(ignoreCase) { + return ignoreCase ? compareStringsCaseInsensitive : compareStringsCaseSensitive; + } + ts.getStringComparer = getStringComparer; + /** + * Creates a string comparer for use with string collation in the UI. + */ + var createUIStringComparer = (function () { + var defaultComparer; + var enUSComparer; + var stringComparerFactory = getStringComparerFactory(); + return createStringComparer; + function compareWithCallback(a, b, comparer) { + if (a === b) + return 0 /* Comparison.EqualTo */; + if (a === undefined) + return -1 /* Comparison.LessThan */; + if (b === undefined) + return 1 /* Comparison.GreaterThan */; + var value = comparer(a, b); + return value < 0 ? -1 /* Comparison.LessThan */ : value > 0 ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; + } + function createIntlCollatorStringComparer(locale) { + // Intl.Collator.prototype.compare is bound to the collator. See NOTE in + // http://www.ecma-international.org/ecma-402/2.0/#sec-Intl.Collator.prototype.compare + var comparer = new Intl.Collator(locale, { usage: "sort", sensitivity: "variant" }).compare; + return function (a, b) { return compareWithCallback(a, b, comparer); }; + } + function createLocaleCompareStringComparer(locale) { + // if the locale is not the default locale (`undefined`), use the fallback comparer. + if (locale !== undefined) + return createFallbackStringComparer(); + return function (a, b) { return compareWithCallback(a, b, compareStrings); }; + function compareStrings(a, b) { + return a.localeCompare(b); + } + } + function createFallbackStringComparer() { + // An ordinal comparison puts "A" after "b", but for the UI we want "A" before "b". + // We first sort case insensitively. So "Aaa" will come before "baa". + // Then we sort case sensitively, so "aaa" will come before "Aaa". + // + // For case insensitive comparisons we always map both strings to their + // upper-case form as some unicode characters do not properly round-trip to + // lowercase (such as `ẞ` (German sharp capital s)). + return function (a, b) { return compareWithCallback(a, b, compareDictionaryOrder); }; + function compareDictionaryOrder(a, b) { + return compareStrings(a.toUpperCase(), b.toUpperCase()) || compareStrings(a, b); + } + function compareStrings(a, b) { + return a < b ? -1 /* Comparison.LessThan */ : a > b ? 1 /* Comparison.GreaterThan */ : 0 /* Comparison.EqualTo */; + } + } + function getStringComparerFactory() { + // If the host supports Intl, we use it for comparisons using the default locale. + if (typeof Intl === "object" && typeof Intl.Collator === "function") { + return createIntlCollatorStringComparer; + } + // If the host does not support Intl, we fall back to localeCompare. + // localeCompare in Node v0.10 is just an ordinal comparison, so don't use it. + if (typeof String.prototype.localeCompare === "function" && + typeof String.prototype.toLocaleUpperCase === "function" && + "a".localeCompare("B") < 0) { + return createLocaleCompareStringComparer; + } + // Otherwise, fall back to ordinal comparison: + return createFallbackStringComparer; + } + function createStringComparer(locale) { + // Hold onto common string comparers. This avoids constantly reallocating comparers during + // tests. + if (locale === undefined) { + return defaultComparer || (defaultComparer = stringComparerFactory(locale)); + } + else if (locale === "en-US") { + return enUSComparer || (enUSComparer = stringComparerFactory(locale)); + } + else { + return stringComparerFactory(locale); + } + } + })(); + var uiComparerCaseSensitive; + var uiLocale; + function getUILocale() { + return uiLocale; + } + ts.getUILocale = getUILocale; + function setUILocale(value) { + if (uiLocale !== value) { + uiLocale = value; + uiComparerCaseSensitive = undefined; + } + } + ts.setUILocale = setUILocale; + /** + * Compare two strings in a using the case-sensitive sort behavior of the UI locale. + * + * Ordering is not predictable between different host locales, but is best for displaying + * ordered data for UI presentation. Characters with multiple unicode representations may + * be considered equal. + * + * Case-sensitive comparisons compare strings that differ in base characters, or + * accents/diacritic marks, or case as unequal. + */ + function compareStringsCaseSensitiveUI(a, b) { + var comparer = uiComparerCaseSensitive || (uiComparerCaseSensitive = createUIStringComparer(uiLocale)); + return comparer(a, b); + } + ts.compareStringsCaseSensitiveUI = compareStringsCaseSensitiveUI; + function compareProperties(a, b, key, comparer) { + return a === b ? 0 /* Comparison.EqualTo */ : + a === undefined ? -1 /* Comparison.LessThan */ : + b === undefined ? 1 /* Comparison.GreaterThan */ : + comparer(a[key], b[key]); + } + ts.compareProperties = compareProperties; + /** True is greater than false. */ + function compareBooleans(a, b) { + return compareValues(a ? 1 : 0, b ? 1 : 0); + } + ts.compareBooleans = compareBooleans; + /** + * Given a name and a list of names that are *not* equal to the name, return a spelling suggestion if there is one that is close enough. + * Names less than length 3 only check for case-insensitive equality. + * + * find the candidate with the smallest Levenshtein distance, + * except for candidates: + * * With no name + * * Whose length differs from the target name by more than 0.34 of the length of the name. + * * Whose levenshtein distance is more than 0.4 of the length of the name + * (0.4 allows 1 substitution/transposition for every 5 characters, + * and 1 insertion/deletion at 3 characters) + */ + function getSpellingSuggestion(name, candidates, getName) { + var maximumLengthDifference = Math.min(2, Math.floor(name.length * 0.34)); + var bestDistance = Math.floor(name.length * 0.4) + 1; // If the best result is worse than this, don't bother. + var bestCandidate; + for (var _i = 0, candidates_2 = candidates; _i < candidates_2.length; _i++) { + var candidate = candidates_2[_i]; + var candidateName = getName(candidate); + if (candidateName !== undefined && Math.abs(candidateName.length - name.length) <= maximumLengthDifference) { + if (candidateName === name) { + continue; + } + // Only consider candidates less than 3 characters long when they differ by case. + // Otherwise, don't bother, since a user would usually notice differences of a 2-character name. + if (candidateName.length < 3 && candidateName.toLowerCase() !== name.toLowerCase()) { + continue; + } + var distance = levenshteinWithMax(name, candidateName, bestDistance - 0.1); + if (distance === undefined) { + continue; + } + ts.Debug.assert(distance < bestDistance); // Else `levenshteinWithMax` should return undefined + bestDistance = distance; + bestCandidate = candidate; + } + } + return bestCandidate; + } + ts.getSpellingSuggestion = getSpellingSuggestion; + function levenshteinWithMax(s1, s2, max) { + var previous = new Array(s2.length + 1); + var current = new Array(s2.length + 1); + /** Represents any value > max. We don't care about the particular value. */ + var big = max + 0.01; + for (var i = 0; i <= s2.length; i++) { + previous[i] = i; + } + for (var i = 1; i <= s1.length; i++) { + var c1 = s1.charCodeAt(i - 1); + var minJ = Math.ceil(i > max ? i - max : 1); + var maxJ = Math.floor(s2.length > max + i ? max + i : s2.length); + current[0] = i; + /** Smallest value of the matrix in the ith column. */ + var colMin = i; + for (var j = 1; j < minJ; j++) { + current[j] = big; + } + for (var j = minJ; j <= maxJ; j++) { + // case difference should be significantly cheaper than other differences + var substitutionDistance = s1[i - 1].toLowerCase() === s2[j - 1].toLowerCase() + ? (previous[j - 1] + 0.1) + : (previous[j - 1] + 2); + var dist = c1 === s2.charCodeAt(j - 1) + ? previous[j - 1] + : Math.min(/*delete*/ previous[j] + 1, /*insert*/ current[j - 1] + 1, /*substitute*/ substitutionDistance); + current[j] = dist; + colMin = Math.min(colMin, dist); + } + for (var j = maxJ + 1; j <= s2.length; j++) { + current[j] = big; + } + if (colMin > max) { + // Give up -- everything in this column is > max and it can't get better in future columns. + return undefined; + } + var temp = previous; + previous = current; + current = temp; + } + var res = previous[s2.length]; + return res > max ? undefined : res; + } + function endsWith(str, suffix) { + var expectedPos = str.length - suffix.length; + return expectedPos >= 0 && str.indexOf(suffix, expectedPos) === expectedPos; + } + ts.endsWith = endsWith; + function removeSuffix(str, suffix) { + return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : str; + } + ts.removeSuffix = removeSuffix; + function tryRemoveSuffix(str, suffix) { + return endsWith(str, suffix) ? str.slice(0, str.length - suffix.length) : undefined; + } + ts.tryRemoveSuffix = tryRemoveSuffix; + function stringContains(str, substring) { + return str.indexOf(substring) !== -1; + } + ts.stringContains = stringContains; + /** + * Takes a string like "jquery-min.4.2.3" and returns "jquery" + */ + function removeMinAndVersionNumbers(fileName) { + // We used to use the regex /[.-]((min)|(\d+(\.\d+)*))$/ and would just .replace it twice. + // Unfortunately, that regex has O(n^2) performance because v8 doesn't match from the end of the string. + // Instead, we now essentially scan the filename (backwards) ourselves. + var end = fileName.length; + for (var pos = end - 1; pos > 0; pos--) { + var ch = fileName.charCodeAt(pos); + if (ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */) { + // Match a \d+ segment + do { + --pos; + ch = fileName.charCodeAt(pos); + } while (pos > 0 && ch >= 48 /* CharacterCodes._0 */ && ch <= 57 /* CharacterCodes._9 */); + } + else if (pos > 4 && (ch === 110 /* CharacterCodes.n */ || ch === 78 /* CharacterCodes.N */)) { + // Looking for "min" or "min" + // Already matched the 'n' + --pos; + ch = fileName.charCodeAt(pos); + if (ch !== 105 /* CharacterCodes.i */ && ch !== 73 /* CharacterCodes.I */) { + break; + } + --pos; + ch = fileName.charCodeAt(pos); + if (ch !== 109 /* CharacterCodes.m */ && ch !== 77 /* CharacterCodes.M */) { + break; + } + --pos; + ch = fileName.charCodeAt(pos); + } + else { + // This character is not part of either suffix pattern + break; + } + if (ch !== 45 /* CharacterCodes.minus */ && ch !== 46 /* CharacterCodes.dot */) { + break; + } + end = pos; + } + // end might be fileName.length, in which case this should internally no-op + return end === fileName.length ? fileName : fileName.slice(0, end); + } + ts.removeMinAndVersionNumbers = removeMinAndVersionNumbers; + /** Remove an item from an array, moving everything to its right one space left. */ + function orderedRemoveItem(array, item) { + for (var i = 0; i < array.length; i++) { + if (array[i] === item) { + orderedRemoveItemAt(array, i); + return true; + } + } + return false; + } + ts.orderedRemoveItem = orderedRemoveItem; + /** Remove an item by index from an array, moving everything to its right one space left. */ + function orderedRemoveItemAt(array, index) { + // This seems to be faster than either `array.splice(i, 1)` or `array.copyWithin(i, i+ 1)`. + for (var i = index; i < array.length - 1; i++) { + array[i] = array[i + 1]; + } + array.pop(); + } + ts.orderedRemoveItemAt = orderedRemoveItemAt; + function unorderedRemoveItemAt(array, index) { + // Fill in the "hole" left at `index`. + array[index] = array[array.length - 1]; + array.pop(); + } + ts.unorderedRemoveItemAt = unorderedRemoveItemAt; + /** Remove the *first* occurrence of `item` from the array. */ + function unorderedRemoveItem(array, item) { + return unorderedRemoveFirstItemWhere(array, function (element) { return element === item; }); + } + ts.unorderedRemoveItem = unorderedRemoveItem; + /** Remove the *first* element satisfying `predicate`. */ + function unorderedRemoveFirstItemWhere(array, predicate) { + for (var i = 0; i < array.length; i++) { + if (predicate(array[i])) { + unorderedRemoveItemAt(array, i); + return true; + } + } + return false; + } + function createGetCanonicalFileName(useCaseSensitiveFileNames) { + return useCaseSensitiveFileNames ? identity : toFileNameLowerCase; + } + ts.createGetCanonicalFileName = createGetCanonicalFileName; + function patternText(_a) { + var prefix = _a.prefix, suffix = _a.suffix; + return "".concat(prefix, "*").concat(suffix); + } + ts.patternText = patternText; + /** + * Given that candidate matches pattern, returns the text matching the '*'. + * E.g.: matchedText(tryParsePattern("foo*baz"), "foobarbaz") === "bar" + */ + function matchedText(pattern, candidate) { + ts.Debug.assert(isPatternMatch(pattern, candidate)); + return candidate.substring(pattern.prefix.length, candidate.length - pattern.suffix.length); + } + ts.matchedText = matchedText; + /** Return the object corresponding to the best pattern to match `candidate`. */ + function findBestPatternMatch(values, getPattern, candidate) { + var matchedValue; + // use length of prefix as betterness criteria + var longestMatchPrefixLength = -1; + for (var _i = 0, values_2 = values; _i < values_2.length; _i++) { + var v = values_2[_i]; + var pattern = getPattern(v); + if (isPatternMatch(pattern, candidate) && pattern.prefix.length > longestMatchPrefixLength) { + longestMatchPrefixLength = pattern.prefix.length; + matchedValue = v; + } + } + return matchedValue; + } + ts.findBestPatternMatch = findBestPatternMatch; + function startsWith(str, prefix) { + return str.lastIndexOf(prefix, 0) === 0; + } + ts.startsWith = startsWith; + function removePrefix(str, prefix) { + return startsWith(str, prefix) ? str.substr(prefix.length) : str; + } + ts.removePrefix = removePrefix; + function tryRemovePrefix(str, prefix, getCanonicalFileName) { + if (getCanonicalFileName === void 0) { getCanonicalFileName = identity; } + return startsWith(getCanonicalFileName(str), getCanonicalFileName(prefix)) ? str.substring(prefix.length) : undefined; + } + ts.tryRemovePrefix = tryRemovePrefix; + function isPatternMatch(_a, candidate) { + var prefix = _a.prefix, suffix = _a.suffix; + return candidate.length >= prefix.length + suffix.length && + startsWith(candidate, prefix) && + endsWith(candidate, suffix); + } + function and(f, g) { + return function (arg) { return f(arg) && g(arg); }; + } + ts.and = and; + function or() { + var fs = []; + for (var _i = 0; _i < arguments.length; _i++) { + fs[_i] = arguments[_i]; + } + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + var lastResult; + for (var _a = 0, fs_1 = fs; _a < fs_1.length; _a++) { + var f = fs_1[_a]; + lastResult = f.apply(void 0, args); + if (lastResult) { + return lastResult; + } + } + return lastResult; + }; + } + ts.or = or; + function not(fn) { + return function () { + var args = []; + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + return !fn.apply(void 0, args); + }; + } + ts.not = not; + function assertType(_) { } + ts.assertType = assertType; + function singleElementArray(t) { + return t === undefined ? undefined : [t]; + } + ts.singleElementArray = singleElementArray; + function enumerateInsertsAndDeletes(newItems, oldItems, comparer, inserted, deleted, unchanged) { + unchanged = unchanged || noop; + var newIndex = 0; + var oldIndex = 0; + var newLen = newItems.length; + var oldLen = oldItems.length; + var hasChanges = false; + while (newIndex < newLen && oldIndex < oldLen) { + var newItem = newItems[newIndex]; + var oldItem = oldItems[oldIndex]; + var compareResult = comparer(newItem, oldItem); + if (compareResult === -1 /* Comparison.LessThan */) { + inserted(newItem); + newIndex++; + hasChanges = true; + } + else if (compareResult === 1 /* Comparison.GreaterThan */) { + deleted(oldItem); + oldIndex++; + hasChanges = true; + } + else { + unchanged(oldItem, newItem); + newIndex++; + oldIndex++; + } + } + while (newIndex < newLen) { + inserted(newItems[newIndex++]); + hasChanges = true; + } + while (oldIndex < oldLen) { + deleted(oldItems[oldIndex++]); + hasChanges = true; + } + return hasChanges; + } + ts.enumerateInsertsAndDeletes = enumerateInsertsAndDeletes; + function fill(length, cb) { + var result = Array(length); + for (var i = 0; i < length; i++) { + result[i] = cb(i); + } + return result; + } + ts.fill = fill; + function cartesianProduct(arrays) { + var result = []; + cartesianProductWorker(arrays, result, /*outer*/ undefined, 0); + return result; + } + ts.cartesianProduct = cartesianProduct; + function cartesianProductWorker(arrays, result, outer, index) { + for (var _i = 0, _a = arrays[index]; _i < _a.length; _i++) { + var element = _a[_i]; + var inner = void 0; + if (outer) { + inner = outer.slice(); + inner.push(element); + } + else { + inner = [element]; + } + if (index === arrays.length - 1) { + result.push(inner); + } + else { + cartesianProductWorker(arrays, result, inner, index + 1); + } + } + } + /** + * Returns string left-padded with spaces or zeros until it reaches the given length. + * + * @param s String to pad. + * @param length Final padded length. If less than or equal to 's.length', returns 's' unchanged. + * @param padString Character to use as padding (default " "). + */ + function padLeft(s, length, padString) { + if (padString === void 0) { padString = " "; } + return length <= s.length ? s : padString.repeat(length - s.length) + s; + } + ts.padLeft = padLeft; + /** + * Returns string right-padded with spaces until it reaches the given length. + * + * @param s String to pad. + * @param length Final padded length. If less than or equal to 's.length', returns 's' unchanged. + * @param padString Character to use as padding (default " "). + */ + function padRight(s, length, padString) { + if (padString === void 0) { padString = " "; } + return length <= s.length ? s : s + padString.repeat(length - s.length); + } + ts.padRight = padRight; + function takeWhile(array, predicate) { + var len = array.length; + var index = 0; + while (index < len && predicate(array[index])) { + index++; + } + return array.slice(0, index); + } + ts.takeWhile = takeWhile; + /** + * Removes the leading and trailing white space and line terminator characters from a string. + */ + ts.trimString = !!String.prototype.trim ? (function (s) { return s.trim(); }) : function (s) { return ts.trimStringEnd(ts.trimStringStart(s)); }; + /** + * Returns a copy with trailing whitespace removed. + */ + ts.trimStringEnd = !!String.prototype.trimEnd ? (function (s) { return s.trimEnd(); }) : trimEndImpl; + /** + * Returns a copy with leading whitespace removed. + */ + ts.trimStringStart = !!String.prototype.trimStart ? (function (s) { return s.trimStart(); }) : function (s) { return s.replace(/^\s+/g, ""); }; + /** + * https://jsbench.me/gjkoxld4au/1 + * The simple regex for this, /\s+$/g is O(n^2) in v8. + * The native .trimEnd method is by far best, but since that's technically ES2019, + * we provide a (still much faster than the simple regex) fallback. + */ + function trimEndImpl(s) { + var end = s.length - 1; + while (end >= 0) { + if (!ts.isWhiteSpaceLike(s.charCodeAt(end))) + break; + end--; + } + return s.slice(0, end + 1); + } +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var LogLevel; + (function (LogLevel) { + LogLevel[LogLevel["Off"] = 0] = "Off"; + LogLevel[LogLevel["Error"] = 1] = "Error"; + LogLevel[LogLevel["Warning"] = 2] = "Warning"; + LogLevel[LogLevel["Info"] = 3] = "Info"; + LogLevel[LogLevel["Verbose"] = 4] = "Verbose"; + })(LogLevel = ts.LogLevel || (ts.LogLevel = {})); + var Debug; + (function (Debug) { + var typeScriptVersion; + /* eslint-disable prefer-const */ + var currentAssertionLevel = 0 /* AssertionLevel.None */; + Debug.currentLogLevel = LogLevel.Warning; + Debug.isDebugging = false; + function getTypeScriptVersion() { + return typeScriptVersion !== null && typeScriptVersion !== void 0 ? typeScriptVersion : (typeScriptVersion = new ts.Version(ts.version)); + } + Debug.getTypeScriptVersion = getTypeScriptVersion; + function shouldLog(level) { + return Debug.currentLogLevel <= level; + } + Debug.shouldLog = shouldLog; + function logMessage(level, s) { + if (Debug.loggingHost && shouldLog(level)) { + Debug.loggingHost.log(level, s); + } + } + function log(s) { + logMessage(LogLevel.Info, s); + } + Debug.log = log; + (function (log_1) { + function error(s) { + logMessage(LogLevel.Error, s); + } + log_1.error = error; + function warn(s) { + logMessage(LogLevel.Warning, s); + } + log_1.warn = warn; + function log(s) { + logMessage(LogLevel.Info, s); + } + log_1.log = log; + function trace(s) { + logMessage(LogLevel.Verbose, s); + } + log_1.trace = trace; + })(log = Debug.log || (Debug.log = {})); + var assertionCache = {}; + function getAssertionLevel() { + return currentAssertionLevel; + } + Debug.getAssertionLevel = getAssertionLevel; + function setAssertionLevel(level) { + var prevAssertionLevel = currentAssertionLevel; + currentAssertionLevel = level; + if (level > prevAssertionLevel) { + // restore assertion functions for the current assertion level (see `shouldAssertFunction`). + for (var _i = 0, _a = ts.getOwnKeys(assertionCache); _i < _a.length; _i++) { + var key = _a[_i]; + var cachedFunc = assertionCache[key]; + if (cachedFunc !== undefined && Debug[key] !== cachedFunc.assertion && level >= cachedFunc.level) { + Debug[key] = cachedFunc; + assertionCache[key] = undefined; + } + } + } + } + Debug.setAssertionLevel = setAssertionLevel; + function shouldAssert(level) { + return currentAssertionLevel >= level; + } + Debug.shouldAssert = shouldAssert; + /** + * Tests whether an assertion function should be executed. If it shouldn't, it is cached and replaced with `ts.noop`. + * Replaced assertion functions are restored when `Debug.setAssertionLevel` is set to a high enough level. + * @param level The minimum assertion level required. + * @param name The name of the current assertion function. + */ + function shouldAssertFunction(level, name) { + if (!shouldAssert(level)) { + assertionCache[name] = { level: level, assertion: Debug[name] }; + Debug[name] = ts.noop; + return false; + } + return true; + } + function fail(message, stackCrawlMark) { + debugger; + var e = new Error(message ? "Debug Failure. ".concat(message) : "Debug Failure."); + if (Error.captureStackTrace) { + Error.captureStackTrace(e, stackCrawlMark || fail); + } + throw e; + } + Debug.fail = fail; + function failBadSyntaxKind(node, message, stackCrawlMark) { + return fail("".concat(message || "Unexpected node.", "\r\nNode ").concat(formatSyntaxKind(node.kind), " was unexpected."), stackCrawlMark || failBadSyntaxKind); + } + Debug.failBadSyntaxKind = failBadSyntaxKind; + function assert(expression, message, verboseDebugInfo, stackCrawlMark) { + if (!expression) { + message = message ? "False expression: ".concat(message) : "False expression."; + if (verboseDebugInfo) { + message += "\r\nVerbose Debug Information: " + (typeof verboseDebugInfo === "string" ? verboseDebugInfo : verboseDebugInfo()); + } + fail(message, stackCrawlMark || assert); + } + } + Debug.assert = assert; + function assertEqual(a, b, msg, msg2, stackCrawlMark) { + if (a !== b) { + var message = msg ? msg2 ? "".concat(msg, " ").concat(msg2) : msg : ""; + fail("Expected ".concat(a, " === ").concat(b, ". ").concat(message), stackCrawlMark || assertEqual); + } + } + Debug.assertEqual = assertEqual; + function assertLessThan(a, b, msg, stackCrawlMark) { + if (a >= b) { + fail("Expected ".concat(a, " < ").concat(b, ". ").concat(msg || ""), stackCrawlMark || assertLessThan); + } + } + Debug.assertLessThan = assertLessThan; + function assertLessThanOrEqual(a, b, stackCrawlMark) { + if (a > b) { + fail("Expected ".concat(a, " <= ").concat(b), stackCrawlMark || assertLessThanOrEqual); + } + } + Debug.assertLessThanOrEqual = assertLessThanOrEqual; + function assertGreaterThanOrEqual(a, b, stackCrawlMark) { + if (a < b) { + fail("Expected ".concat(a, " >= ").concat(b), stackCrawlMark || assertGreaterThanOrEqual); + } + } + Debug.assertGreaterThanOrEqual = assertGreaterThanOrEqual; + function assertIsDefined(value, message, stackCrawlMark) { + // eslint-disable-next-line no-null/no-null + if (value === undefined || value === null) { + fail(message, stackCrawlMark || assertIsDefined); + } + } + Debug.assertIsDefined = assertIsDefined; + function checkDefined(value, message, stackCrawlMark) { + assertIsDefined(value, message, stackCrawlMark || checkDefined); + return value; + } + Debug.checkDefined = checkDefined; + function assertEachIsDefined(value, message, stackCrawlMark) { + for (var _i = 0, value_1 = value; _i < value_1.length; _i++) { + var v = value_1[_i]; + assertIsDefined(v, message, stackCrawlMark || assertEachIsDefined); + } + } + Debug.assertEachIsDefined = assertEachIsDefined; + function checkEachDefined(value, message, stackCrawlMark) { + assertEachIsDefined(value, message, stackCrawlMark || checkEachDefined); + return value; + } + Debug.checkEachDefined = checkEachDefined; + function assertNever(member, message, stackCrawlMark) { + if (message === void 0) { message = "Illegal value:"; } + var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member); + return fail("".concat(message, " ").concat(detail), stackCrawlMark || assertNever); + } + Debug.assertNever = assertNever; + function assertEachNode(nodes, test, message, stackCrawlMark) { + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertEachNode")) { + assert(test === undefined || ts.every(nodes, test), message || "Unexpected node.", function () { return "Node array did not pass test '".concat(getFunctionName(test), "'."); }, stackCrawlMark || assertEachNode); + } + } + Debug.assertEachNode = assertEachNode; + function assertNode(node, test, message, stackCrawlMark) { + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNode")) { + assert(node !== undefined && (test === undefined || test(node)), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNode); + } + } + Debug.assertNode = assertNode; + function assertNotNode(node, test, message, stackCrawlMark) { + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertNotNode")) { + assert(node === undefined || test === undefined || !test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " should not have passed test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertNotNode); + } + } + Debug.assertNotNode = assertNotNode; + function assertOptionalNode(node, test, message, stackCrawlMark) { + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalNode")) { + assert(test === undefined || node === undefined || test(node), message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " did not pass test '").concat(getFunctionName(test), "'."); }, stackCrawlMark || assertOptionalNode); + } + } + Debug.assertOptionalNode = assertOptionalNode; + function assertOptionalToken(node, kind, message, stackCrawlMark) { + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertOptionalToken")) { + assert(kind === undefined || node === undefined || node.kind === kind, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node === null || node === void 0 ? void 0 : node.kind), " was not a '").concat(formatSyntaxKind(kind), "' token."); }, stackCrawlMark || assertOptionalToken); + } + } + Debug.assertOptionalToken = assertOptionalToken; + function assertMissingNode(node, message, stackCrawlMark) { + if (shouldAssertFunction(1 /* AssertionLevel.Normal */, "assertMissingNode")) { + assert(node === undefined, message || "Unexpected node.", function () { return "Node ".concat(formatSyntaxKind(node.kind), " was unexpected'."); }, stackCrawlMark || assertMissingNode); + } + } + Debug.assertMissingNode = assertMissingNode; + function type(_value) { } + Debug.type = type; + function getFunctionName(func) { + if (typeof func !== "function") { + return ""; + } + else if (func.hasOwnProperty("name")) { + return func.name; + } + else { + var text = Function.prototype.toString.call(func); + var match = /^function\s+([\w\$]+)\s*\(/.exec(text); + return match ? match[1] : ""; + } + } + Debug.getFunctionName = getFunctionName; + function formatSymbol(symbol) { + return "{ name: ".concat(ts.unescapeLeadingUnderscores(symbol.escapedName), "; flags: ").concat(formatSymbolFlags(symbol.flags), "; declarations: ").concat(ts.map(symbol.declarations, function (node) { return formatSyntaxKind(node.kind); }), " }"); + } + Debug.formatSymbol = formatSymbol; + /** + * Formats an enum value as a string for debugging and debug assertions. + */ + function formatEnum(value, enumObject, isFlags) { + if (value === void 0) { value = 0; } + var members = getEnumMembers(enumObject); + if (value === 0) { + return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0"; + } + if (isFlags) { + var result = ""; + var remainingFlags = value; + for (var _i = 0, members_1 = members; _i < members_1.length; _i++) { + var _a = members_1[_i], enumValue = _a[0], enumName = _a[1]; + if (enumValue > value) { + break; + } + if (enumValue !== 0 && enumValue & value) { + result = "".concat(result).concat(result ? "|" : "").concat(enumName); + remainingFlags &= ~enumValue; + } + } + if (remainingFlags === 0) { + return result; + } + } + else { + for (var _b = 0, members_2 = members; _b < members_2.length; _b++) { + var _c = members_2[_b], enumValue = _c[0], enumName = _c[1]; + if (enumValue === value) { + return enumName; + } + } + } + return value.toString(); + } + Debug.formatEnum = formatEnum; + function getEnumMembers(enumObject) { + var result = []; + for (var name in enumObject) { + var value = enumObject[name]; + if (typeof value === "number") { + result.push([value, name]); + } + } + return ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); }); + } + function formatSyntaxKind(kind) { + return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false); + } + Debug.formatSyntaxKind = formatSyntaxKind; + function formatSnippetKind(kind) { + return formatEnum(kind, ts.SnippetKind, /*isFlags*/ false); + } + Debug.formatSnippetKind = formatSnippetKind; + function formatNodeFlags(flags) { + return formatEnum(flags, ts.NodeFlags, /*isFlags*/ true); + } + Debug.formatNodeFlags = formatNodeFlags; + function formatModifierFlags(flags) { + return formatEnum(flags, ts.ModifierFlags, /*isFlags*/ true); + } + Debug.formatModifierFlags = formatModifierFlags; + function formatTransformFlags(flags) { + return formatEnum(flags, ts.TransformFlags, /*isFlags*/ true); + } + Debug.formatTransformFlags = formatTransformFlags; + function formatEmitFlags(flags) { + return formatEnum(flags, ts.EmitFlags, /*isFlags*/ true); + } + Debug.formatEmitFlags = formatEmitFlags; + function formatSymbolFlags(flags) { + return formatEnum(flags, ts.SymbolFlags, /*isFlags*/ true); + } + Debug.formatSymbolFlags = formatSymbolFlags; + function formatTypeFlags(flags) { + return formatEnum(flags, ts.TypeFlags, /*isFlags*/ true); + } + Debug.formatTypeFlags = formatTypeFlags; + function formatSignatureFlags(flags) { + return formatEnum(flags, ts.SignatureFlags, /*isFlags*/ true); + } + Debug.formatSignatureFlags = formatSignatureFlags; + function formatObjectFlags(flags) { + return formatEnum(flags, ts.ObjectFlags, /*isFlags*/ true); + } + Debug.formatObjectFlags = formatObjectFlags; + function formatFlowFlags(flags) { + return formatEnum(flags, ts.FlowFlags, /*isFlags*/ true); + } + Debug.formatFlowFlags = formatFlowFlags; + var isDebugInfoEnabled = false; + var extendedDebugModule; + function extendedDebug() { + enableDebugInfo(); + if (!extendedDebugModule) { + throw new Error("Debugging helpers could not be loaded."); + } + return extendedDebugModule; + } + function printControlFlowGraph(flowNode) { + return console.log(formatControlFlowGraph(flowNode)); + } + Debug.printControlFlowGraph = printControlFlowGraph; + function formatControlFlowGraph(flowNode) { + return extendedDebug().formatControlFlowGraph(flowNode); + } + Debug.formatControlFlowGraph = formatControlFlowGraph; + var flowNodeProto; + function attachFlowNodeDebugInfoWorker(flowNode) { + if (!("__debugFlowFlags" in flowNode)) { // eslint-disable-line no-in-operator + Object.defineProperties(flowNode, { + // for use with vscode-js-debug's new customDescriptionGenerator in launch.json + __tsDebuggerDisplay: { + value: function () { + var flowHeader = this.flags & 2 /* FlowFlags.Start */ ? "FlowStart" : + this.flags & 4 /* FlowFlags.BranchLabel */ ? "FlowBranchLabel" : + this.flags & 8 /* FlowFlags.LoopLabel */ ? "FlowLoopLabel" : + this.flags & 16 /* FlowFlags.Assignment */ ? "FlowAssignment" : + this.flags & 32 /* FlowFlags.TrueCondition */ ? "FlowTrueCondition" : + this.flags & 64 /* FlowFlags.FalseCondition */ ? "FlowFalseCondition" : + this.flags & 128 /* FlowFlags.SwitchClause */ ? "FlowSwitchClause" : + this.flags & 256 /* FlowFlags.ArrayMutation */ ? "FlowArrayMutation" : + this.flags & 512 /* FlowFlags.Call */ ? "FlowCall" : + this.flags & 1024 /* FlowFlags.ReduceLabel */ ? "FlowReduceLabel" : + this.flags & 1 /* FlowFlags.Unreachable */ ? "FlowUnreachable" : + "UnknownFlow"; + var remainingFlags = this.flags & ~(2048 /* FlowFlags.Referenced */ - 1); + return "".concat(flowHeader).concat(remainingFlags ? " (".concat(formatFlowFlags(remainingFlags), ")") : ""); + } + }, + __debugFlowFlags: { get: function () { return formatEnum(this.flags, ts.FlowFlags, /*isFlags*/ true); } }, + __debugToString: { value: function () { return formatControlFlowGraph(this); } } + }); + } + } + function attachFlowNodeDebugInfo(flowNode) { + if (isDebugInfoEnabled) { + if (typeof Object.setPrototypeOf === "function") { + // if we're in es2015, attach the method to a shared prototype for `FlowNode` + // so the method doesn't show up in the watch window. + if (!flowNodeProto) { + flowNodeProto = Object.create(Object.prototype); + attachFlowNodeDebugInfoWorker(flowNodeProto); + } + Object.setPrototypeOf(flowNode, flowNodeProto); + } + else { + // not running in an es2015 environment, attach the method directly. + attachFlowNodeDebugInfoWorker(flowNode); + } + } + } + Debug.attachFlowNodeDebugInfo = attachFlowNodeDebugInfo; + var nodeArrayProto; + function attachNodeArrayDebugInfoWorker(array) { + if (!("__tsDebuggerDisplay" in array)) { // eslint-disable-line no-in-operator + Object.defineProperties(array, { + __tsDebuggerDisplay: { + value: function (defaultValue) { + // An `Array` with extra properties is rendered as `[A, B, prop1: 1, prop2: 2]`. Most of + // these aren't immediately useful so we trim off the `prop1: ..., prop2: ...` part from the + // formatted string. + // This regex can trigger slow backtracking because of overlapping potential captures. + // We don't care, this is debug code that's only enabled with a debugger attached - + // we're just taking note of it for anyone checking regex performance in the future. + defaultValue = String(defaultValue).replace(/(?:,[\s\w\d_]+:[^,]+)+\]$/, "]"); + return "NodeArray ".concat(defaultValue); + } + } + }); + } + } + function attachNodeArrayDebugInfo(array) { + if (isDebugInfoEnabled) { + if (typeof Object.setPrototypeOf === "function") { + // if we're in es2015, attach the method to a shared prototype for `NodeArray` + // so the method doesn't show up in the watch window. + if (!nodeArrayProto) { + nodeArrayProto = Object.create(Array.prototype); + attachNodeArrayDebugInfoWorker(nodeArrayProto); + } + Object.setPrototypeOf(array, nodeArrayProto); + } + else { + // not running in an es2015 environment, attach the method directly. + attachNodeArrayDebugInfoWorker(array); + } + } + } + Debug.attachNodeArrayDebugInfo = attachNodeArrayDebugInfo; + /** + * Injects debug information into frequently used types. + */ + function enableDebugInfo() { + if (isDebugInfoEnabled) + return; + // avoid recomputing + var weakTypeTextMap; + var weakNodeTextMap; + function getWeakTypeTextMap() { + if (weakTypeTextMap === undefined) { + if (typeof WeakMap === "function") + weakTypeTextMap = new WeakMap(); + } + return weakTypeTextMap; + } + function getWeakNodeTextMap() { + if (weakNodeTextMap === undefined) { + if (typeof WeakMap === "function") + weakNodeTextMap = new WeakMap(); + } + return weakNodeTextMap; + } + // Add additional properties in debug mode to assist with debugging. + Object.defineProperties(ts.objectAllocator.getSymbolConstructor().prototype, { + // for use with vscode-js-debug's new customDescriptionGenerator in launch.json + __tsDebuggerDisplay: { + value: function () { + var symbolHeader = this.flags & 33554432 /* SymbolFlags.Transient */ ? "TransientSymbol" : + "Symbol"; + var remainingSymbolFlags = this.flags & ~33554432 /* SymbolFlags.Transient */; + return "".concat(symbolHeader, " '").concat(ts.symbolName(this), "'").concat(remainingSymbolFlags ? " (".concat(formatSymbolFlags(remainingSymbolFlags), ")") : ""); + } + }, + __debugFlags: { get: function () { return formatSymbolFlags(this.flags); } } + }); + Object.defineProperties(ts.objectAllocator.getTypeConstructor().prototype, { + // for use with vscode-js-debug's new customDescriptionGenerator in launch.json + __tsDebuggerDisplay: { + value: function () { + var typeHeader = this.flags & 98304 /* TypeFlags.Nullable */ ? "NullableType" : + this.flags & 384 /* TypeFlags.StringOrNumberLiteral */ ? "LiteralType ".concat(JSON.stringify(this.value)) : + this.flags & 2048 /* TypeFlags.BigIntLiteral */ ? "LiteralType ".concat(this.value.negative ? "-" : "").concat(this.value.base10Value, "n") : + this.flags & 8192 /* TypeFlags.UniqueESSymbol */ ? "UniqueESSymbolType" : + this.flags & 32 /* TypeFlags.Enum */ ? "EnumType" : + this.flags & 67359327 /* TypeFlags.Intrinsic */ ? "IntrinsicType ".concat(this.intrinsicName) : + this.flags & 1048576 /* TypeFlags.Union */ ? "UnionType" : + this.flags & 2097152 /* TypeFlags.Intersection */ ? "IntersectionType" : + this.flags & 4194304 /* TypeFlags.Index */ ? "IndexType" : + this.flags & 8388608 /* TypeFlags.IndexedAccess */ ? "IndexedAccessType" : + this.flags & 16777216 /* TypeFlags.Conditional */ ? "ConditionalType" : + this.flags & 33554432 /* TypeFlags.Substitution */ ? "SubstitutionType" : + this.flags & 262144 /* TypeFlags.TypeParameter */ ? "TypeParameter" : + this.flags & 524288 /* TypeFlags.Object */ ? + this.objectFlags & 3 /* ObjectFlags.ClassOrInterface */ ? "InterfaceType" : + this.objectFlags & 4 /* ObjectFlags.Reference */ ? "TypeReference" : + this.objectFlags & 8 /* ObjectFlags.Tuple */ ? "TupleType" : + this.objectFlags & 16 /* ObjectFlags.Anonymous */ ? "AnonymousType" : + this.objectFlags & 32 /* ObjectFlags.Mapped */ ? "MappedType" : + this.objectFlags & 1024 /* ObjectFlags.ReverseMapped */ ? "ReverseMappedType" : + this.objectFlags & 256 /* ObjectFlags.EvolvingArray */ ? "EvolvingArrayType" : + "ObjectType" : + "Type"; + var remainingObjectFlags = this.flags & 524288 /* TypeFlags.Object */ ? this.objectFlags & ~1343 /* ObjectFlags.ObjectTypeKindMask */ : 0; + return "".concat(typeHeader).concat(this.symbol ? " '".concat(ts.symbolName(this.symbol), "'") : "").concat(remainingObjectFlags ? " (".concat(formatObjectFlags(remainingObjectFlags), ")") : ""); + } + }, + __debugFlags: { get: function () { return formatTypeFlags(this.flags); } }, + __debugObjectFlags: { get: function () { return this.flags & 524288 /* TypeFlags.Object */ ? formatObjectFlags(this.objectFlags) : ""; } }, + __debugTypeToString: { + value: function () { + // avoid recomputing + var map = getWeakTypeTextMap(); + var text = map === null || map === void 0 ? void 0 : map.get(this); + if (text === undefined) { + text = this.checker.typeToString(this); + map === null || map === void 0 ? void 0 : map.set(this, text); + } + return text; + } + }, + }); + Object.defineProperties(ts.objectAllocator.getSignatureConstructor().prototype, { + __debugFlags: { get: function () { return formatSignatureFlags(this.flags); } }, + __debugSignatureToString: { value: function () { var _a; return (_a = this.checker) === null || _a === void 0 ? void 0 : _a.signatureToString(this); } } + }); + var nodeConstructors = [ + ts.objectAllocator.getNodeConstructor(), + ts.objectAllocator.getIdentifierConstructor(), + ts.objectAllocator.getTokenConstructor(), + ts.objectAllocator.getSourceFileConstructor() + ]; + for (var _i = 0, nodeConstructors_1 = nodeConstructors; _i < nodeConstructors_1.length; _i++) { + var ctor = nodeConstructors_1[_i]; + if (!ctor.prototype.hasOwnProperty("__debugKind")) { + Object.defineProperties(ctor.prototype, { + // for use with vscode-js-debug's new customDescriptionGenerator in launch.json + __tsDebuggerDisplay: { + value: function () { + var nodeHeader = ts.isGeneratedIdentifier(this) ? "GeneratedIdentifier" : + ts.isIdentifier(this) ? "Identifier '".concat(ts.idText(this), "'") : + ts.isPrivateIdentifier(this) ? "PrivateIdentifier '".concat(ts.idText(this), "'") : + ts.isStringLiteral(this) ? "StringLiteral ".concat(JSON.stringify(this.text.length < 10 ? this.text : this.text.slice(10) + "...")) : + ts.isNumericLiteral(this) ? "NumericLiteral ".concat(this.text) : + ts.isBigIntLiteral(this) ? "BigIntLiteral ".concat(this.text, "n") : + ts.isTypeParameterDeclaration(this) ? "TypeParameterDeclaration" : + ts.isParameter(this) ? "ParameterDeclaration" : + ts.isConstructorDeclaration(this) ? "ConstructorDeclaration" : + ts.isGetAccessorDeclaration(this) ? "GetAccessorDeclaration" : + ts.isSetAccessorDeclaration(this) ? "SetAccessorDeclaration" : + ts.isCallSignatureDeclaration(this) ? "CallSignatureDeclaration" : + ts.isConstructSignatureDeclaration(this) ? "ConstructSignatureDeclaration" : + ts.isIndexSignatureDeclaration(this) ? "IndexSignatureDeclaration" : + ts.isTypePredicateNode(this) ? "TypePredicateNode" : + ts.isTypeReferenceNode(this) ? "TypeReferenceNode" : + ts.isFunctionTypeNode(this) ? "FunctionTypeNode" : + ts.isConstructorTypeNode(this) ? "ConstructorTypeNode" : + ts.isTypeQueryNode(this) ? "TypeQueryNode" : + ts.isTypeLiteralNode(this) ? "TypeLiteralNode" : + ts.isArrayTypeNode(this) ? "ArrayTypeNode" : + ts.isTupleTypeNode(this) ? "TupleTypeNode" : + ts.isOptionalTypeNode(this) ? "OptionalTypeNode" : + ts.isRestTypeNode(this) ? "RestTypeNode" : + ts.isUnionTypeNode(this) ? "UnionTypeNode" : + ts.isIntersectionTypeNode(this) ? "IntersectionTypeNode" : + ts.isConditionalTypeNode(this) ? "ConditionalTypeNode" : + ts.isInferTypeNode(this) ? "InferTypeNode" : + ts.isParenthesizedTypeNode(this) ? "ParenthesizedTypeNode" : + ts.isThisTypeNode(this) ? "ThisTypeNode" : + ts.isTypeOperatorNode(this) ? "TypeOperatorNode" : + ts.isIndexedAccessTypeNode(this) ? "IndexedAccessTypeNode" : + ts.isMappedTypeNode(this) ? "MappedTypeNode" : + ts.isLiteralTypeNode(this) ? "LiteralTypeNode" : + ts.isNamedTupleMember(this) ? "NamedTupleMember" : + ts.isImportTypeNode(this) ? "ImportTypeNode" : + formatSyntaxKind(this.kind); + return "".concat(nodeHeader).concat(this.flags ? " (".concat(formatNodeFlags(this.flags), ")") : ""); + } + }, + __debugKind: { get: function () { return formatSyntaxKind(this.kind); } }, + __debugNodeFlags: { get: function () { return formatNodeFlags(this.flags); } }, + __debugModifierFlags: { get: function () { return formatModifierFlags(ts.getEffectiveModifierFlagsNoCache(this)); } }, + __debugTransformFlags: { get: function () { return formatTransformFlags(this.transformFlags); } }, + __debugIsParseTreeNode: { get: function () { return ts.isParseTreeNode(this); } }, + __debugEmitFlags: { get: function () { return formatEmitFlags(ts.getEmitFlags(this)); } }, + __debugGetText: { + value: function (includeTrivia) { + if (ts.nodeIsSynthesized(this)) + return ""; + // avoid recomputing + var map = getWeakNodeTextMap(); + var text = map === null || map === void 0 ? void 0 : map.get(this); + if (text === undefined) { + var parseNode = ts.getParseTreeNode(this); + var sourceFile = parseNode && ts.getSourceFileOfNode(parseNode); + text = sourceFile ? ts.getSourceTextOfNodeFromSourceFile(sourceFile, parseNode, includeTrivia) : ""; + map === null || map === void 0 ? void 0 : map.set(this, text); + } + return text; + } + } + }); + } + } + // attempt to load extended debugging information + try { + if (ts.sys && ts.sys.require) { + var basePath = ts.getDirectoryPath(ts.resolvePath(ts.sys.getExecutingFilePath())); + var result = ts.sys.require(basePath, "./compiler-debug"); + if (!result.error) { + result.module.init(ts); + extendedDebugModule = result.module; + } + } + } + catch (_a) { + // do nothing + } + isDebugInfoEnabled = true; + } + Debug.enableDebugInfo = enableDebugInfo; + function formatDeprecationMessage(name, error, errorAfter, since, message) { + var deprecationMessage = error ? "DeprecationError: " : "DeprecationWarning: "; + deprecationMessage += "'".concat(name, "' "); + deprecationMessage += since ? "has been deprecated since v".concat(since) : "is deprecated"; + deprecationMessage += error ? " and can no longer be used." : errorAfter ? " and will no longer be usable after v".concat(errorAfter, ".") : "."; + deprecationMessage += message ? " ".concat(ts.formatStringFromArgs(message, [name], 0)) : ""; + return deprecationMessage; + } + function createErrorDeprecation(name, errorAfter, since, message) { + var deprecationMessage = formatDeprecationMessage(name, /*error*/ true, errorAfter, since, message); + return function () { + throw new TypeError(deprecationMessage); + }; + } + function createWarningDeprecation(name, errorAfter, since, message) { + var hasWrittenDeprecation = false; + return function () { + if (!hasWrittenDeprecation) { + log.warn(formatDeprecationMessage(name, /*error*/ false, errorAfter, since, message)); + hasWrittenDeprecation = true; + } + }; + } + function createDeprecation(name, options) { + var _a, _b; + if (options === void 0) { options = {}; } + var version = typeof options.typeScriptVersion === "string" ? new ts.Version(options.typeScriptVersion) : (_a = options.typeScriptVersion) !== null && _a !== void 0 ? _a : getTypeScriptVersion(); + var errorAfter = typeof options.errorAfter === "string" ? new ts.Version(options.errorAfter) : options.errorAfter; + var warnAfter = typeof options.warnAfter === "string" ? new ts.Version(options.warnAfter) : options.warnAfter; + var since = typeof options.since === "string" ? new ts.Version(options.since) : (_b = options.since) !== null && _b !== void 0 ? _b : warnAfter; + var error = options.error || errorAfter && version.compareTo(errorAfter) <= 0; + var warn = !warnAfter || version.compareTo(warnAfter) >= 0; + return error ? createErrorDeprecation(name, errorAfter, since, options.message) : + warn ? createWarningDeprecation(name, errorAfter, since, options.message) : + ts.noop; + } + function wrapFunction(deprecation, func) { + return function () { + deprecation(); + return func.apply(this, arguments); + }; + } + function deprecate(func, options) { + var deprecation = createDeprecation(getFunctionName(func), options); + return wrapFunction(deprecation, func); + } + Debug.deprecate = deprecate; + })(Debug = ts.Debug || (ts.Debug = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + // https://semver.org/#spec-item-2 + // > A normal version number MUST take the form X.Y.Z where X, Y, and Z are non-negative + // > integers, and MUST NOT contain leading zeroes. X is the major version, Y is the minor + // > version, and Z is the patch version. Each element MUST increase numerically. + // + // NOTE: We differ here in that we allow X and X.Y, with missing parts having the default + // value of `0`. + var versionRegExp = /^(0|[1-9]\d*)(?:\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*)(?:\-([a-z0-9-.]+))?(?:\+([a-z0-9-.]+))?)?)?$/i; + // https://semver.org/#spec-item-9 + // > A pre-release version MAY be denoted by appending a hyphen and a series of dot separated + // > identifiers immediately following the patch version. Identifiers MUST comprise only ASCII + // > alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Numeric identifiers + // > MUST NOT include leading zeroes. + var prereleaseRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)(?:\.(?:0|[1-9]\d*|[a-z-][a-z0-9-]*))*$/i; + // https://semver.org/#spec-item-10 + // > Build metadata MAY be denoted by appending a plus sign and a series of dot separated + // > identifiers immediately following the patch or pre-release version. Identifiers MUST + // > comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. + var buildRegExp = /^[a-z0-9-]+(?:\.[a-z0-9-]+)*$/i; + // https://semver.org/#spec-item-9 + // > Numeric identifiers MUST NOT include leading zeroes. + var numericIdentifierRegExp = /^(0|[1-9]\d*)$/; + /** + * Describes a precise semantic version number, https://semver.org + */ + var Version = /** @class */ (function () { + function Version(major, minor, patch, prerelease, build) { + if (minor === void 0) { minor = 0; } + if (patch === void 0) { patch = 0; } + if (prerelease === void 0) { prerelease = ""; } + if (build === void 0) { build = ""; } + if (typeof major === "string") { + var result = ts.Debug.checkDefined(tryParseComponents(major), "Invalid version"); + (major = result.major, minor = result.minor, patch = result.patch, prerelease = result.prerelease, build = result.build); + } + ts.Debug.assert(major >= 0, "Invalid argument: major"); + ts.Debug.assert(minor >= 0, "Invalid argument: minor"); + ts.Debug.assert(patch >= 0, "Invalid argument: patch"); + ts.Debug.assert(!prerelease || prereleaseRegExp.test(prerelease), "Invalid argument: prerelease"); + ts.Debug.assert(!build || buildRegExp.test(build), "Invalid argument: build"); + this.major = major; + this.minor = minor; + this.patch = patch; + this.prerelease = prerelease ? prerelease.split(".") : ts.emptyArray; + this.build = build ? build.split(".") : ts.emptyArray; + } + Version.tryParse = function (text) { + var result = tryParseComponents(text); + if (!result) + return undefined; + var major = result.major, minor = result.minor, patch = result.patch, prerelease = result.prerelease, build = result.build; + return new Version(major, minor, patch, prerelease, build); + }; + Version.prototype.compareTo = function (other) { + // https://semver.org/#spec-item-11 + // > Precedence is determined by the first difference when comparing each of these + // > identifiers from left to right as follows: Major, minor, and patch versions are + // > always compared numerically. + // + // https://semver.org/#spec-item-11 + // > Precedence for two pre-release versions with the same major, minor, and patch version + // > MUST be determined by comparing each dot separated identifier from left to right until + // > a difference is found [...] + // + // https://semver.org/#spec-item-11 + // > Build metadata does not figure into precedence + if (this === other) + return 0 /* Comparison.EqualTo */; + if (other === undefined) + return 1 /* Comparison.GreaterThan */; + return ts.compareValues(this.major, other.major) + || ts.compareValues(this.minor, other.minor) + || ts.compareValues(this.patch, other.patch) + || comparePrereleaseIdentifiers(this.prerelease, other.prerelease); + }; + Version.prototype.increment = function (field) { + switch (field) { + case "major": return new Version(this.major + 1, 0, 0); + case "minor": return new Version(this.major, this.minor + 1, 0); + case "patch": return new Version(this.major, this.minor, this.patch + 1); + default: return ts.Debug.assertNever(field); + } + }; + Version.prototype.toString = function () { + var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch); + if (ts.some(this.prerelease)) + result += "-".concat(this.prerelease.join(".")); + if (ts.some(this.build)) + result += "+".concat(this.build.join(".")); + return result; + }; + Version.zero = new Version(0, 0, 0); + return Version; + }()); + ts.Version = Version; + function tryParseComponents(text) { + var match = versionRegExp.exec(text); + if (!match) + return undefined; + 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; + if (prerelease && !prereleaseRegExp.test(prerelease)) + return undefined; + if (build && !buildRegExp.test(build)) + return undefined; + return { + major: parseInt(major, 10), + minor: parseInt(minor, 10), + patch: parseInt(patch, 10), + prerelease: prerelease, + build: build + }; + } + function comparePrereleaseIdentifiers(left, right) { + // https://semver.org/#spec-item-11 + // > When major, minor, and patch are equal, a pre-release version has lower precedence + // > than a normal version. + if (left === right) + return 0 /* Comparison.EqualTo */; + if (left.length === 0) + return right.length === 0 ? 0 /* Comparison.EqualTo */ : 1 /* Comparison.GreaterThan */; + if (right.length === 0) + return -1 /* Comparison.LessThan */; + // https://semver.org/#spec-item-11 + // > Precedence for two pre-release versions with the same major, minor, and patch version + // > MUST be determined by comparing each dot separated identifier from left to right until + // > a difference is found [...] + var length = Math.min(left.length, right.length); + for (var i = 0; i < length; i++) { + var leftIdentifier = left[i]; + var rightIdentifier = right[i]; + if (leftIdentifier === rightIdentifier) + continue; + var leftIsNumeric = numericIdentifierRegExp.test(leftIdentifier); + var rightIsNumeric = numericIdentifierRegExp.test(rightIdentifier); + if (leftIsNumeric || rightIsNumeric) { + // https://semver.org/#spec-item-11 + // > Numeric identifiers always have lower precedence than non-numeric identifiers. + if (leftIsNumeric !== rightIsNumeric) + return leftIsNumeric ? -1 /* Comparison.LessThan */ : 1 /* Comparison.GreaterThan */; + // https://semver.org/#spec-item-11 + // > identifiers consisting of only digits are compared numerically + var result = ts.compareValues(+leftIdentifier, +rightIdentifier); + if (result) + return result; + } + else { + // https://semver.org/#spec-item-11 + // > identifiers with letters or hyphens are compared lexically in ASCII sort order. + var result = ts.compareStringsCaseSensitive(leftIdentifier, rightIdentifier); + if (result) + return result; + } + } + // https://semver.org/#spec-item-11 + // > A larger set of pre-release fields has a higher precedence than a smaller set, if all + // > of the preceding identifiers are equal. + return ts.compareValues(left.length, right.length); + } + /** + * Describes a semantic version range, per https://github.com/npm/node-semver#ranges + */ + var VersionRange = /** @class */ (function () { + function VersionRange(spec) { + this._alternatives = spec ? ts.Debug.checkDefined(parseRange(spec), "Invalid range spec.") : ts.emptyArray; + } + VersionRange.tryParse = function (text) { + var sets = parseRange(text); + if (sets) { + var range = new VersionRange(""); + range._alternatives = sets; + return range; + } + return undefined; + }; + VersionRange.prototype.test = function (version) { + if (typeof version === "string") + version = new Version(version); + return testDisjunction(version, this._alternatives); + }; + VersionRange.prototype.toString = function () { + return formatDisjunction(this._alternatives); + }; + return VersionRange; + }()); + ts.VersionRange = VersionRange; + // https://github.com/npm/node-semver#range-grammar + // + // range-set ::= range ( logical-or range ) * + // range ::= hyphen | simple ( ' ' simple ) * | '' + // logical-or ::= ( ' ' ) * '||' ( ' ' ) * + var logicalOrRegExp = /\|\|/g; + var whitespaceRegExp = /\s+/g; + // https://github.com/npm/node-semver#range-grammar + // + // partial ::= xr ( '.' xr ( '.' xr qualifier ? )? )? + // xr ::= 'x' | 'X' | '*' | nr + // nr ::= '0' | ['1'-'9'] ( ['0'-'9'] ) * + // qualifier ::= ( '-' pre )? ( '+' build )? + // pre ::= parts + // build ::= parts + // parts ::= part ( '.' part ) * + // part ::= nr | [-0-9A-Za-z]+ + var partialRegExp = /^([xX*0]|[1-9]\d*)(?:\.([xX*0]|[1-9]\d*)(?:\.([xX*0]|[1-9]\d*)(?:-([a-z0-9-.]+))?(?:\+([a-z0-9-.]+))?)?)?$/i; + // https://github.com/npm/node-semver#range-grammar + // + // hyphen ::= partial ' - ' partial + var hyphenRegExp = /^\s*([a-z0-9-+.*]+)\s+-\s+([a-z0-9-+.*]+)\s*$/i; + // https://github.com/npm/node-semver#range-grammar + // + // simple ::= primitive | partial | tilde | caret + // primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial + // tilde ::= '~' partial + // caret ::= '^' partial + var rangeRegExp = /^(~|\^|<|<=|>|>=|=)?\s*([a-z0-9-+.*]+)$/i; + function parseRange(text) { + var alternatives = []; + for (var _i = 0, _a = ts.trimString(text).split(logicalOrRegExp); _i < _a.length; _i++) { + var range = _a[_i]; + if (!range) + continue; + var comparators = []; + range = ts.trimString(range); + var match = hyphenRegExp.exec(range); + if (match) { + if (!parseHyphen(match[1], match[2], comparators)) + return undefined; + } + else { + for (var _b = 0, _c = range.split(whitespaceRegExp); _b < _c.length; _b++) { + var simple = _c[_b]; + var match_1 = rangeRegExp.exec(ts.trimString(simple)); + if (!match_1 || !parseComparator(match_1[1], match_1[2], comparators)) + return undefined; + } + } + alternatives.push(comparators); + } + return alternatives; + } + function parsePartial(text) { + var match = partialRegExp.exec(text); + if (!match) + return undefined; + 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]; + 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); + return { version: version, major: major, minor: minor, patch: patch }; + } + function parseHyphen(left, right, comparators) { + var leftResult = parsePartial(left); + if (!leftResult) + return false; + var rightResult = parsePartial(right); + if (!rightResult) + return false; + if (!isWildcard(leftResult.major)) { + comparators.push(createComparator(">=", leftResult.version)); + } + if (!isWildcard(rightResult.major)) { + comparators.push(isWildcard(rightResult.minor) ? createComparator("<", rightResult.version.increment("major")) : + isWildcard(rightResult.patch) ? createComparator("<", rightResult.version.increment("minor")) : + createComparator("<=", rightResult.version)); + } + return true; + } + function parseComparator(operator, text, comparators) { + var result = parsePartial(text); + if (!result) + return false; + var version = result.version, major = result.major, minor = result.minor, patch = result.patch; + if (!isWildcard(major)) { + switch (operator) { + case "~": + comparators.push(createComparator(">=", version)); + comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : + "minor"))); + break; + case "^": + comparators.push(createComparator(">=", version)); + comparators.push(createComparator("<", version.increment(version.major > 0 || isWildcard(minor) ? "major" : + version.minor > 0 || isWildcard(patch) ? "minor" : + "patch"))); + break; + case "<": + case ">=": + comparators.push(createComparator(operator, version)); + break; + case "<=": + case ">": + comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major")) : + isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor")) : + createComparator(operator, version)); + break; + case "=": + case undefined: + if (isWildcard(minor) || isWildcard(patch)) { + comparators.push(createComparator(">=", version)); + comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor"))); + } + else { + comparators.push(createComparator("=", version)); + } + break; + default: + // unrecognized + return false; + } + } + else if (operator === "<" || operator === ">") { + comparators.push(createComparator("<", Version.zero)); + } + return true; + } + function isWildcard(part) { + return part === "*" || part === "x" || part === "X"; + } + function createComparator(operator, operand) { + return { operator: operator, operand: operand }; + } + function testDisjunction(version, alternatives) { + // an empty disjunction is treated as "*" (all versions) + if (alternatives.length === 0) + return true; + for (var _i = 0, alternatives_1 = alternatives; _i < alternatives_1.length; _i++) { + var alternative = alternatives_1[_i]; + if (testAlternative(version, alternative)) + return true; + } + return false; + } + function testAlternative(version, comparators) { + for (var _i = 0, comparators_1 = comparators; _i < comparators_1.length; _i++) { + var comparator = comparators_1[_i]; + if (!testComparator(version, comparator.operator, comparator.operand)) + return false; + } + return true; + } + function testComparator(version, operator, operand) { + var cmp = version.compareTo(operand); + switch (operator) { + case "<": return cmp < 0; + case "<=": return cmp <= 0; + case ">": return cmp > 0; + case ">=": return cmp >= 0; + case "=": return cmp === 0; + default: return ts.Debug.assertNever(operator); + } + } + function formatDisjunction(alternatives) { + return ts.map(alternatives, formatAlternative).join(" || ") || "*"; + } + function formatAlternative(comparators) { + return ts.map(comparators, formatComparator).join(" "); + } + function formatComparator(comparator) { + return "".concat(comparator.operator).concat(comparator.operand); + } +})(ts || (ts = {})); +/*@internal*/ +var ts; +(function (ts) { + // The following definitions provide the minimum compatible support for the Web Performance User Timings API + // between browsers and NodeJS: + // eslint-disable-next-line @typescript-eslint/naming-convention + function hasRequiredAPI(performance, PerformanceObserver) { + return typeof performance === "object" && + typeof performance.timeOrigin === "number" && + typeof performance.mark === "function" && + typeof performance.measure === "function" && + typeof performance.now === "function" && + typeof PerformanceObserver === "function"; + } + function tryGetWebPerformanceHooks() { + if (typeof performance === "object" && + typeof PerformanceObserver === "function" && + hasRequiredAPI(performance, PerformanceObserver)) { + return { + // For now we always write native performance events when running in the browser. We may + // make this conditional in the future if we find that native web performance hooks + // in the browser also slow down compilation. + shouldWriteNativeEvents: true, + performance: performance, + PerformanceObserver: PerformanceObserver + }; + } + } + function tryGetNodePerformanceHooks() { + if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof module === "object" && typeof require === "function") { + try { + var performance_1; + var _a = require("perf_hooks"), nodePerformance_1 = _a.performance, PerformanceObserver_1 = _a.PerformanceObserver; + if (hasRequiredAPI(nodePerformance_1, PerformanceObserver_1)) { + performance_1 = nodePerformance_1; + // There is a bug in Node's performance.measure prior to 12.16.3/13.13.0 that does not + // match the Web Performance API specification. Node's implementation did not allow + // optional `start` and `end` arguments for `performance.measure`. + // See https://github.com/nodejs/node/pull/32651 for more information. + var version_1 = new ts.Version(process.versions.node); + var range = new ts.VersionRange("<12.16.3 || 13 <13.13"); + if (range.test(version_1)) { + performance_1 = { + get timeOrigin() { return nodePerformance_1.timeOrigin; }, + now: function () { return nodePerformance_1.now(); }, + mark: function (name) { return nodePerformance_1.mark(name); }, + measure: function (name, start, end) { + if (start === void 0) { start = "nodeStart"; } + if (end === undefined) { + end = "__performance.measure-fix__"; + nodePerformance_1.mark(end); + } + nodePerformance_1.measure(name, start, end); + if (end === "__performance.measure-fix__") { + nodePerformance_1.clearMarks("__performance.measure-fix__"); + } + } + }; + } + return { + // By default, only write native events when generating a cpu profile or using the v8 profiler. + shouldWriteNativeEvents: false, + performance: performance_1, + PerformanceObserver: PerformanceObserver_1 + }; + } + } + catch (_b) { + // ignore errors + } + } + } + // Unlike with the native Map/Set 'tryGet' functions in corePublic.ts, we eagerly evaluate these + // since we will need them for `timestamp`, below. + var nativePerformanceHooks = tryGetWebPerformanceHooks() || tryGetNodePerformanceHooks(); + var nativePerformance = nativePerformanceHooks === null || nativePerformanceHooks === void 0 ? void 0 : nativePerformanceHooks.performance; + function tryGetNativePerformanceHooks() { + return nativePerformanceHooks; + } + ts.tryGetNativePerformanceHooks = tryGetNativePerformanceHooks; + /** Gets a timestamp with (at least) ms resolution */ + ts.timestamp = nativePerformance ? function () { return nativePerformance.now(); } : + Date.now ? Date.now : + function () { return +(new Date()); }; +})(ts || (ts = {})); +/*@internal*/ +/** Performance measurements for the compiler. */ +var ts; +(function (ts) { + var performance; + (function (performance) { + var perfHooks; + // when set, indicates the implementation of `Performance` to use for user timing. + // when unset, indicates user timing is unavailable or disabled. + var performanceImpl; + function createTimerIf(condition, measureName, startMarkName, endMarkName) { + return condition ? createTimer(measureName, startMarkName, endMarkName) : performance.nullTimer; + } + performance.createTimerIf = createTimerIf; + function createTimer(measureName, startMarkName, endMarkName) { + var enterCount = 0; + return { + enter: enter, + exit: exit + }; + function enter() { + if (++enterCount === 1) { + mark(startMarkName); + } + } + function exit() { + if (--enterCount === 0) { + mark(endMarkName); + measure(measureName, startMarkName, endMarkName); + } + else if (enterCount < 0) { + ts.Debug.fail("enter/exit count does not match."); + } + } + } + performance.createTimer = createTimer; + performance.nullTimer = { enter: ts.noop, exit: ts.noop }; + var enabled = false; + var timeorigin = ts.timestamp(); + var marks = new ts.Map(); + var counts = new ts.Map(); + var durations = new ts.Map(); + /** + * Marks a performance event. + * + * @param markName The name of the mark. + */ + function mark(markName) { + var _a; + if (enabled) { + var count = (_a = counts.get(markName)) !== null && _a !== void 0 ? _a : 0; + counts.set(markName, count + 1); + marks.set(markName, ts.timestamp()); + performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.mark(markName); + } + } + performance.mark = mark; + /** + * Adds a performance measurement with the specified name. + * + * @param measureName The name of the performance measurement. + * @param startMarkName The name of the starting mark. If not supplied, the point at which the + * profiler was enabled is used. + * @param endMarkName The name of the ending mark. If not supplied, the current timestamp is + * used. + */ + function measure(measureName, startMarkName, endMarkName) { + var _a, _b; + if (enabled) { + var end = (_a = (endMarkName !== undefined ? marks.get(endMarkName) : undefined)) !== null && _a !== void 0 ? _a : ts.timestamp(); + var start = (_b = (startMarkName !== undefined ? marks.get(startMarkName) : undefined)) !== null && _b !== void 0 ? _b : timeorigin; + var previousDuration = durations.get(measureName) || 0; + durations.set(measureName, previousDuration + (end - start)); + performanceImpl === null || performanceImpl === void 0 ? void 0 : performanceImpl.measure(measureName, startMarkName, endMarkName); + } + } + performance.measure = measure; + /** + * Gets the number of times a marker was encountered. + * + * @param markName The name of the mark. + */ + function getCount(markName) { + return counts.get(markName) || 0; + } + performance.getCount = getCount; + /** + * Gets the total duration of all measurements with the supplied name. + * + * @param measureName The name of the measure whose durations should be accumulated. + */ + function getDuration(measureName) { + return durations.get(measureName) || 0; + } + performance.getDuration = getDuration; + /** + * Iterate over each measure, performing some action + * + * @param cb The action to perform for each measure + */ + function forEachMeasure(cb) { + durations.forEach(function (duration, measureName) { return cb(measureName, duration); }); + } + performance.forEachMeasure = forEachMeasure; + /** + * Indicates whether the performance API is enabled. + */ + function isEnabled() { + return enabled; + } + performance.isEnabled = isEnabled; + /** Enables (and resets) performance measurements for the compiler. */ + function enable(system) { + var _a; + if (system === void 0) { system = ts.sys; } + if (!enabled) { + enabled = true; + perfHooks || (perfHooks = ts.tryGetNativePerformanceHooks()); + if (perfHooks) { + timeorigin = perfHooks.performance.timeOrigin; + // NodeJS's Web Performance API is currently slower than expected, but we'd still like + // to be able to leverage native trace events when node is run with either `--cpu-prof` + // or `--prof`, if we're running with our own `--generateCpuProfile` flag, or when + // running in debug mode (since its possible to generate a cpu profile while debugging). + 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)) { + performanceImpl = perfHooks.performance; + } + } + } + return true; + } + performance.enable = enable; + /** Disables performance measurements for the compiler. */ + function disable() { + if (enabled) { + marks.clear(); + counts.clear(); + durations.clear(); + performanceImpl = undefined; + enabled = false; + } + } + performance.disable = disable; + })(performance = ts.performance || (ts.performance = {})); +})(ts || (ts = {})); +/* @internal */ +var ts; +(function (ts) { + var _a; + var nullLogger = { + logEvent: ts.noop, + logErrEvent: ts.noop, + logPerfEvent: ts.noop, + logInfoEvent: ts.noop, + logStartCommand: ts.noop, + logStopCommand: ts.noop, + logStartUpdateProgram: ts.noop, + logStopUpdateProgram: ts.noop, + logStartUpdateGraph: ts.noop, + logStopUpdateGraph: ts.noop, + logStartResolveModule: ts.noop, + logStopResolveModule: ts.noop, + logStartParseSourceFile: ts.noop, + logStopParseSourceFile: ts.noop, + logStartReadFile: ts.noop, + logStopReadFile: ts.noop, + logStartBindFile: ts.noop, + logStopBindFile: ts.noop, + logStartScheduledOperation: ts.noop, + logStopScheduledOperation: ts.noop, + }; + // Load optional module to enable Event Tracing for Windows + // See https://github.com/microsoft/typescript-etw for more information + var etwModule; + try { + var etwModulePath = (_a = process.env.TS_ETW_MODULE_PATH) !== null && _a !== void 0 ? _a : "./node_modules/@microsoft/typescript-etw"; + // require() will throw an exception if the module is not found + // It may also return undefined if not installed properly + etwModule = require(etwModulePath); + } + catch (e) { + etwModule = undefined; + } + /** Performance logger that will generate ETW events if possible - check for `logEvent` member, as `etwModule` will be `{}` when browserified */ + ts.perfLogger = etwModule && etwModule.logEvent ? etwModule : nullLogger; +})(ts || (ts = {})); +/* Tracing events for the compiler. */ +/*@internal*/ +var ts; +(function (ts) { + // enable the above using startTracing() + // `tracingEnabled` should never be used directly, only through the above + var tracingEnabled; + (function (tracingEnabled) { + var fs; + var traceCount = 0; + var traceFd = 0; + var mode; + var typeCatalog = []; // NB: id is index + 1 + var legendPath; + var legend = []; + ; + /** Starts tracing for the given project. */ + function startTracing(tracingMode, traceDir, configFilePath) { + ts.Debug.assert(!ts.tracing, "Tracing already started"); + if (fs === undefined) { + try { + fs = require("fs"); + } + catch (e) { + throw new Error("tracing requires having fs\n(original error: ".concat(e.message || e, ")")); + } + } + mode = tracingMode; + typeCatalog.length = 0; + if (legendPath === undefined) { + legendPath = ts.combinePaths(traceDir, "legend.json"); + } + // Note that writing will fail later on if it exists and is not a directory + if (!fs.existsSync(traceDir)) { + fs.mkdirSync(traceDir, { recursive: true }); + } + var countPart = mode === "build" ? ".".concat(process.pid, "-").concat(++traceCount) + : mode === "server" ? ".".concat(process.pid) + : ""; + var tracePath = ts.combinePaths(traceDir, "trace".concat(countPart, ".json")); + var typesPath = ts.combinePaths(traceDir, "types".concat(countPart, ".json")); + legend.push({ + configFilePath: configFilePath, + tracePath: tracePath, + typesPath: typesPath, + }); + traceFd = fs.openSync(tracePath, "w"); + ts.tracing = tracingEnabled; // only when traceFd is properly set + // Start with a prefix that contains some metadata that the devtools profiler expects (also avoids a warning on import) + var meta = { cat: "__metadata", ph: "M", ts: 1000 * ts.timestamp(), pid: 1, tid: 1 }; + fs.writeSync(traceFd, "[\n" + + [__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" })] + .map(function (v) { return JSON.stringify(v); }).join(",\n")); + } + tracingEnabled.startTracing = startTracing; + /** Stops tracing for the in-progress project and dumps the type catalog. */ + function stopTracing() { + ts.Debug.assert(ts.tracing, "Tracing is not in progress"); + ts.Debug.assert(!!typeCatalog.length === (mode !== "server")); // Have a type catalog iff not in server mode + fs.writeSync(traceFd, "\n]\n"); + fs.closeSync(traceFd); + ts.tracing = undefined; + if (typeCatalog.length) { + dumpTypes(typeCatalog); + } + else { + // We pre-computed this path for convenience, but clear it + // now that the file won't be created. + legend[legend.length - 1].typesPath = undefined; + } + } + tracingEnabled.stopTracing = stopTracing; + function recordType(type) { + if (mode !== "server") { + typeCatalog.push(type); + } + } + tracingEnabled.recordType = recordType; + var Phase; + (function (Phase) { + Phase["Parse"] = "parse"; + Phase["Program"] = "program"; + Phase["Bind"] = "bind"; + Phase["Check"] = "check"; + Phase["CheckTypes"] = "checkTypes"; + Phase["Emit"] = "emit"; + Phase["Session"] = "session"; + })(Phase = tracingEnabled.Phase || (tracingEnabled.Phase = {})); + function instant(phase, name, args) { + writeEvent("I", phase, name, args, "\"s\":\"g\""); + } + tracingEnabled.instant = instant; + var eventStack = []; + /** + * @param separateBeginAndEnd - used for special cases where we need the trace point even if the event + * never terminates (typically for reducing a scenario too big to trace to one that can be completed). + * In the future we might implement an exit handler to dump unfinished events which would deprecate + * these operations. + */ + function push(phase, name, args, separateBeginAndEnd) { + if (separateBeginAndEnd === void 0) { separateBeginAndEnd = false; } + if (separateBeginAndEnd) { + writeEvent("B", phase, name, args); + } + eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd }); + } + tracingEnabled.push = push; + function pop() { + ts.Debug.assert(eventStack.length > 0); + writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp()); + eventStack.length--; + } + tracingEnabled.pop = pop; + function popAll() { + var endTime = 1000 * ts.timestamp(); + for (var i = eventStack.length - 1; i >= 0; i--) { + writeStackEvent(i, endTime); + } + eventStack.length = 0; + } + tracingEnabled.popAll = popAll; + // sample every 10ms + var sampleInterval = 1000 * 10; + function writeStackEvent(index, endTime) { + var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd; + if (separateBeginAndEnd) { + writeEvent("E", phase, name, args, /*extras*/ undefined, endTime); + } + // test if [time,endTime) straddles a sampling point + else if (sampleInterval - (time % sampleInterval) <= endTime - time) { + writeEvent("X", phase, name, args, "\"dur\":".concat(endTime - time), time); + } + } + function writeEvent(eventType, phase, name, args, extras, time) { + if (time === void 0) { time = 1000 * ts.timestamp(); } + // In server mode, there's no easy way to dump type information, so we drop events that would require it. + if (mode === "server" && phase === "checkTypes" /* Phase.CheckTypes */) + return; + ts.performance.mark("beginTracing"); + fs.writeSync(traceFd, ",\n{\"pid\":1,\"tid\":1,\"ph\":\"".concat(eventType, "\",\"cat\":\"").concat(phase, "\",\"ts\":").concat(time, ",\"name\":\"").concat(name, "\"")); + if (extras) + fs.writeSync(traceFd, ",".concat(extras)); + if (args) + fs.writeSync(traceFd, ",\"args\":".concat(JSON.stringify(args))); + fs.writeSync(traceFd, "}"); + ts.performance.mark("endTracing"); + ts.performance.measure("Tracing", "beginTracing", "endTracing"); + } + function getLocation(node) { + var file = ts.getSourceFileOfNode(node); + return !file + ? undefined + : { + path: file.path, + start: indexFromOne(ts.getLineAndCharacterOfPosition(file, node.pos)), + end: indexFromOne(ts.getLineAndCharacterOfPosition(file, node.end)), + }; + function indexFromOne(lc) { + return { + line: lc.line + 1, + character: lc.character + 1, + }; + } + } + function dumpTypes(types) { + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x; + ts.performance.mark("beginDumpTypes"); + var typesPath = legend[legend.length - 1].typesPath; + var typesFd = fs.openSync(typesPath, "w"); + var recursionIdentityMap = new ts.Map(); + // Cleverness: no line break here so that the type ID will match the line number + fs.writeSync(typesFd, "["); + var numTypes = types.length; + for (var i = 0; i < numTypes; i++) { + var type = types[i]; + var objectFlags = type.objectFlags; + var symbol = (_a = type.aliasSymbol) !== null && _a !== void 0 ? _a : type.symbol; + // It's slow to compute the display text, so skip it unless it's really valuable (or cheap) + var display = void 0; + if ((objectFlags & 16 /* ObjectFlags.Anonymous */) | (type.flags & 2944 /* TypeFlags.Literal */)) { + try { + display = (_b = type.checker) === null || _b === void 0 ? void 0 : _b.typeToString(type); + } + catch (_y) { + display = undefined; + } + } + var indexedAccessProperties = {}; + if (type.flags & 8388608 /* TypeFlags.IndexedAccess */) { + var indexedAccessType = type; + indexedAccessProperties = { + indexedAccessObjectType: (_c = indexedAccessType.objectType) === null || _c === void 0 ? void 0 : _c.id, + indexedAccessIndexType: (_d = indexedAccessType.indexType) === null || _d === void 0 ? void 0 : _d.id, + }; + } + var referenceProperties = {}; + if (objectFlags & 4 /* ObjectFlags.Reference */) { + var referenceType = type; + referenceProperties = { + instantiatedType: (_e = referenceType.target) === null || _e === void 0 ? void 0 : _e.id, + typeArguments: (_f = referenceType.resolvedTypeArguments) === null || _f === void 0 ? void 0 : _f.map(function (t) { return t.id; }), + referenceLocation: getLocation(referenceType.node), + }; + } + var conditionalProperties = {}; + if (type.flags & 16777216 /* TypeFlags.Conditional */) { + var conditionalType = type; + conditionalProperties = { + conditionalCheckType: (_g = conditionalType.checkType) === null || _g === void 0 ? void 0 : _g.id, + conditionalExtendsType: (_h = conditionalType.extendsType) === null || _h === void 0 ? void 0 : _h.id, + conditionalTrueType: (_k = (_j = conditionalType.resolvedTrueType) === null || _j === void 0 ? void 0 : _j.id) !== null && _k !== void 0 ? _k : -1, + conditionalFalseType: (_m = (_l = conditionalType.resolvedFalseType) === null || _l === void 0 ? void 0 : _l.id) !== null && _m !== void 0 ? _m : -1, + }; + } + var substitutionProperties = {}; + if (type.flags & 33554432 /* TypeFlags.Substitution */) { + var substitutionType = type; + substitutionProperties = { + substitutionBaseType: (_o = substitutionType.baseType) === null || _o === void 0 ? void 0 : _o.id, + substituteType: (_p = substitutionType.substitute) === null || _p === void 0 ? void 0 : _p.id, + }; + } + var reverseMappedProperties = {}; + if (objectFlags & 1024 /* ObjectFlags.ReverseMapped */) { + var reverseMappedType = type; + reverseMappedProperties = { + reverseMappedSourceType: (_q = reverseMappedType.source) === null || _q === void 0 ? void 0 : _q.id, + reverseMappedMappedType: (_r = reverseMappedType.mappedType) === null || _r === void 0 ? void 0 : _r.id, + reverseMappedConstraintType: (_s = reverseMappedType.constraintType) === null || _s === void 0 ? void 0 : _s.id, + }; + } + var evolvingArrayProperties = {}; + if (objectFlags & 256 /* ObjectFlags.EvolvingArray */) { + var evolvingArrayType = type; + evolvingArrayProperties = { + evolvingArrayElementType: evolvingArrayType.elementType.id, + evolvingArrayFinalType: (_t = evolvingArrayType.finalArrayType) === null || _t === void 0 ? void 0 : _t.id, + }; + } + // We can't print out an arbitrary object, so just assign each one a unique number. + // Don't call it an "id" so people don't treat it as a type id. + var recursionToken = void 0; + var recursionIdentity = type.checker.getRecursionIdentity(type); + if (recursionIdentity) { + recursionToken = recursionIdentityMap.get(recursionIdentity); + if (!recursionToken) { + recursionToken = recursionIdentityMap.size; + recursionIdentityMap.set(recursionIdentity, recursionToken); + } + } + var descriptor = __assign(__assign(__assign(__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, isTuple: objectFlags & 8 /* ObjectFlags.Tuple */ ? true : undefined, unionTypes: (type.flags & 1048576 /* TypeFlags.Union */) ? (_u = type.types) === null || _u === void 0 ? void 0 : _u.map(function (t) { return t.id; }) : undefined, intersectionTypes: (type.flags & 2097152 /* TypeFlags.Intersection */) ? type.types.map(function (t) { return t.id; }) : undefined, aliasTypeArguments: (_v = type.aliasTypeArguments) === null || _v === void 0 ? void 0 : _v.map(function (t) { return t.id; }), keyofType: (type.flags & 4194304 /* TypeFlags.Index */) ? (_w = type.type) === null || _w === void 0 ? void 0 : _w.id : undefined }, indexedAccessProperties), referenceProperties), conditionalProperties), substitutionProperties), reverseMappedProperties), evolvingArrayProperties), { destructuringPattern: getLocation(type.pattern), firstDeclaration: getLocation((_x = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _x === void 0 ? void 0 : _x[0]), flags: ts.Debug.formatTypeFlags(type.flags).split("|"), display: display }); + fs.writeSync(typesFd, JSON.stringify(descriptor)); + if (i < numTypes - 1) { + fs.writeSync(typesFd, ",\n"); + } + } + fs.writeSync(typesFd, "]\n"); + fs.closeSync(typesFd); + ts.performance.mark("endDumpTypes"); + ts.performance.measure("Dump types", "beginDumpTypes", "endDumpTypes"); + } + function dumpLegend() { + if (!legendPath) { + return; + } + fs.writeFileSync(legendPath, JSON.stringify(legend)); + } + tracingEnabled.dumpLegend = dumpLegend; + })(tracingEnabled || (tracingEnabled = {})); + // define after tracingEnabled is initialized + ts.startTracing = tracingEnabled.startTracing; + ts.dumpTracingLegend = tracingEnabled.dumpLegend; +})(ts || (ts = {})); +var ts; +(function (ts) { + // token > SyntaxKind.Identifier => token is a keyword + // Also, If you add a new SyntaxKind be sure to keep the `Markers` section at the bottom in sync + var SyntaxKind; + (function (SyntaxKind) { + SyntaxKind[SyntaxKind["Unknown"] = 0] = "Unknown"; + SyntaxKind[SyntaxKind["EndOfFileToken"] = 1] = "EndOfFileToken"; + SyntaxKind[SyntaxKind["SingleLineCommentTrivia"] = 2] = "SingleLineCommentTrivia"; + SyntaxKind[SyntaxKind["MultiLineCommentTrivia"] = 3] = "MultiLineCommentTrivia"; + SyntaxKind[SyntaxKind["NewLineTrivia"] = 4] = "NewLineTrivia"; + SyntaxKind[SyntaxKind["WhitespaceTrivia"] = 5] = "WhitespaceTrivia"; + // We detect and preserve #! on the first line + SyntaxKind[SyntaxKind["ShebangTrivia"] = 6] = "ShebangTrivia"; + // We detect and provide better error recovery when we encounter a git merge marker. This + // allows us to edit files with git-conflict markers in them in a much more pleasant manner. + SyntaxKind[SyntaxKind["ConflictMarkerTrivia"] = 7] = "ConflictMarkerTrivia"; + // Literals + SyntaxKind[SyntaxKind["NumericLiteral"] = 8] = "NumericLiteral"; + SyntaxKind[SyntaxKind["BigIntLiteral"] = 9] = "BigIntLiteral"; + SyntaxKind[SyntaxKind["StringLiteral"] = 10] = "StringLiteral"; + SyntaxKind[SyntaxKind["JsxText"] = 11] = "JsxText"; + SyntaxKind[SyntaxKind["JsxTextAllWhiteSpaces"] = 12] = "JsxTextAllWhiteSpaces"; + SyntaxKind[SyntaxKind["RegularExpressionLiteral"] = 13] = "RegularExpressionLiteral"; + SyntaxKind[SyntaxKind["NoSubstitutionTemplateLiteral"] = 14] = "NoSubstitutionTemplateLiteral"; + // Pseudo-literals + SyntaxKind[SyntaxKind["TemplateHead"] = 15] = "TemplateHead"; + SyntaxKind[SyntaxKind["TemplateMiddle"] = 16] = "TemplateMiddle"; + SyntaxKind[SyntaxKind["TemplateTail"] = 17] = "TemplateTail"; + // Punctuation + SyntaxKind[SyntaxKind["OpenBraceToken"] = 18] = "OpenBraceToken"; + SyntaxKind[SyntaxKind["CloseBraceToken"] = 19] = "CloseBraceToken"; + SyntaxKind[SyntaxKind["OpenParenToken"] = 20] = "OpenParenToken"; + SyntaxKind[SyntaxKind["CloseParenToken"] = 21] = "CloseParenToken"; + SyntaxKind[SyntaxKind["OpenBracketToken"] = 22] = "OpenBracketToken"; + SyntaxKind[SyntaxKind["CloseBracketToken"] = 23] = "CloseBracketToken"; + SyntaxKind[SyntaxKind["DotToken"] = 24] = "DotToken"; + SyntaxKind[SyntaxKind["DotDotDotToken"] = 25] = "DotDotDotToken"; + SyntaxKind[SyntaxKind["SemicolonToken"] = 26] = "SemicolonToken"; + SyntaxKind[SyntaxKind["CommaToken"] = 27] = "CommaToken"; + SyntaxKind[SyntaxKind["QuestionDotToken"] = 28] = "QuestionDotToken"; + SyntaxKind[SyntaxKind["LessThanToken"] = 29] = "LessThanToken"; + SyntaxKind[SyntaxKind["LessThanSlashToken"] = 30] = "LessThanSlashToken"; + SyntaxKind[SyntaxKind["GreaterThanToken"] = 31] = "GreaterThanToken"; + SyntaxKind[SyntaxKind["LessThanEqualsToken"] = 32] = "LessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanEqualsToken"] = 33] = "GreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsToken"] = 34] = "EqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsToken"] = 35] = "ExclamationEqualsToken"; + SyntaxKind[SyntaxKind["EqualsEqualsEqualsToken"] = 36] = "EqualsEqualsEqualsToken"; + SyntaxKind[SyntaxKind["ExclamationEqualsEqualsToken"] = 37] = "ExclamationEqualsEqualsToken"; + SyntaxKind[SyntaxKind["EqualsGreaterThanToken"] = 38] = "EqualsGreaterThanToken"; + SyntaxKind[SyntaxKind["PlusToken"] = 39] = "PlusToken"; + SyntaxKind[SyntaxKind["MinusToken"] = 40] = "MinusToken"; + SyntaxKind[SyntaxKind["AsteriskToken"] = 41] = "AsteriskToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskToken"] = 42] = "AsteriskAsteriskToken"; + SyntaxKind[SyntaxKind["SlashToken"] = 43] = "SlashToken"; + SyntaxKind[SyntaxKind["PercentToken"] = 44] = "PercentToken"; + SyntaxKind[SyntaxKind["PlusPlusToken"] = 45] = "PlusPlusToken"; + SyntaxKind[SyntaxKind["MinusMinusToken"] = 46] = "MinusMinusToken"; + SyntaxKind[SyntaxKind["LessThanLessThanToken"] = 47] = "LessThanLessThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanToken"] = 48] = "GreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanToken"] = 49] = "GreaterThanGreaterThanGreaterThanToken"; + SyntaxKind[SyntaxKind["AmpersandToken"] = 50] = "AmpersandToken"; + SyntaxKind[SyntaxKind["BarToken"] = 51] = "BarToken"; + SyntaxKind[SyntaxKind["CaretToken"] = 52] = "CaretToken"; + SyntaxKind[SyntaxKind["ExclamationToken"] = 53] = "ExclamationToken"; + SyntaxKind[SyntaxKind["TildeToken"] = 54] = "TildeToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandToken"] = 55] = "AmpersandAmpersandToken"; + SyntaxKind[SyntaxKind["BarBarToken"] = 56] = "BarBarToken"; + SyntaxKind[SyntaxKind["QuestionToken"] = 57] = "QuestionToken"; + SyntaxKind[SyntaxKind["ColonToken"] = 58] = "ColonToken"; + SyntaxKind[SyntaxKind["AtToken"] = 59] = "AtToken"; + SyntaxKind[SyntaxKind["QuestionQuestionToken"] = 60] = "QuestionQuestionToken"; + /** Only the JSDoc scanner produces BacktickToken. The normal scanner produces NoSubstitutionTemplateLiteral and related kinds. */ + SyntaxKind[SyntaxKind["BacktickToken"] = 61] = "BacktickToken"; + /** Only the JSDoc scanner produces HashToken. The normal scanner produces PrivateIdentifier. */ + SyntaxKind[SyntaxKind["HashToken"] = 62] = "HashToken"; + // Assignments + SyntaxKind[SyntaxKind["EqualsToken"] = 63] = "EqualsToken"; + SyntaxKind[SyntaxKind["PlusEqualsToken"] = 64] = "PlusEqualsToken"; + SyntaxKind[SyntaxKind["MinusEqualsToken"] = 65] = "MinusEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskEqualsToken"] = 66] = "AsteriskEqualsToken"; + SyntaxKind[SyntaxKind["AsteriskAsteriskEqualsToken"] = 67] = "AsteriskAsteriskEqualsToken"; + SyntaxKind[SyntaxKind["SlashEqualsToken"] = 68] = "SlashEqualsToken"; + SyntaxKind[SyntaxKind["PercentEqualsToken"] = 69] = "PercentEqualsToken"; + SyntaxKind[SyntaxKind["LessThanLessThanEqualsToken"] = 70] = "LessThanLessThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanEqualsToken"] = 71] = "GreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["GreaterThanGreaterThanGreaterThanEqualsToken"] = 72] = "GreaterThanGreaterThanGreaterThanEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandEqualsToken"] = 73] = "AmpersandEqualsToken"; + SyntaxKind[SyntaxKind["BarEqualsToken"] = 74] = "BarEqualsToken"; + SyntaxKind[SyntaxKind["BarBarEqualsToken"] = 75] = "BarBarEqualsToken"; + SyntaxKind[SyntaxKind["AmpersandAmpersandEqualsToken"] = 76] = "AmpersandAmpersandEqualsToken"; + SyntaxKind[SyntaxKind["QuestionQuestionEqualsToken"] = 77] = "QuestionQuestionEqualsToken"; + SyntaxKind[SyntaxKind["CaretEqualsToken"] = 78] = "CaretEqualsToken"; + // Identifiers and PrivateIdentifiers + SyntaxKind[SyntaxKind["Identifier"] = 79] = "Identifier"; + SyntaxKind[SyntaxKind["PrivateIdentifier"] = 80] = "PrivateIdentifier"; + // Reserved words + SyntaxKind[SyntaxKind["BreakKeyword"] = 81] = "BreakKeyword"; + SyntaxKind[SyntaxKind["CaseKeyword"] = 82] = "CaseKeyword"; + SyntaxKind[SyntaxKind["CatchKeyword"] = 83] = "CatchKeyword"; + SyntaxKind[SyntaxKind["ClassKeyword"] = 84] = "ClassKeyword"; + SyntaxKind[SyntaxKind["ConstKeyword"] = 85] = "ConstKeyword"; + SyntaxKind[SyntaxKind["ContinueKeyword"] = 86] = "ContinueKeyword"; + SyntaxKind[SyntaxKind["DebuggerKeyword"] = 87] = "DebuggerKeyword"; + SyntaxKind[SyntaxKind["DefaultKeyword"] = 88] = "DefaultKeyword"; + SyntaxKind[SyntaxKind["DeleteKeyword"] = 89] = "DeleteKeyword"; + SyntaxKind[SyntaxKind["DoKeyword"] = 90] = "DoKeyword"; + SyntaxKind[SyntaxKind["ElseKeyword"] = 91] = "ElseKeyword"; + SyntaxKind[SyntaxKind["EnumKeyword"] = 92] = "EnumKeyword"; + SyntaxKind[SyntaxKind["ExportKeyword"] = 93] = "ExportKeyword"; + SyntaxKind[SyntaxKind["ExtendsKeyword"] = 94] = "ExtendsKeyword"; + SyntaxKind[SyntaxKind["FalseKeyword"] = 95] = "FalseKeyword"; + SyntaxKind[SyntaxKind["FinallyKeyword"] = 96] = "FinallyKeyword"; + SyntaxKind[SyntaxKind["ForKeyword"] = 97] = "ForKeyword"; + SyntaxKind[SyntaxKind["FunctionKeyword"] = 98] = "FunctionKeyword"; + SyntaxKind[SyntaxKind["IfKeyword"] = 99] = "IfKeyword"; + SyntaxKind[SyntaxKind["ImportKeyword"] = 100] = "ImportKeyword"; + SyntaxKind[SyntaxKind["InKeyword"] = 101] = "InKeyword"; + SyntaxKind[SyntaxKind["InstanceOfKeyword"] = 102] = "InstanceOfKeyword"; + SyntaxKind[SyntaxKind["NewKeyword"] = 103] = "NewKeyword"; + SyntaxKind[SyntaxKind["NullKeyword"] = 104] = "NullKeyword"; + SyntaxKind[SyntaxKind["ReturnKeyword"] = 105] = "ReturnKeyword"; + SyntaxKind[SyntaxKind["SuperKeyword"] = 106] = "SuperKeyword"; + SyntaxKind[SyntaxKind["SwitchKeyword"] = 107] = "SwitchKeyword"; + SyntaxKind[SyntaxKind["ThisKeyword"] = 108] = "ThisKeyword"; + SyntaxKind[SyntaxKind["ThrowKeyword"] = 109] = "ThrowKeyword"; + SyntaxKind[SyntaxKind["TrueKeyword"] = 110] = "TrueKeyword"; + SyntaxKind[SyntaxKind["TryKeyword"] = 111] = "TryKeyword"; + SyntaxKind[SyntaxKind["TypeOfKeyword"] = 112] = "TypeOfKeyword"; + SyntaxKind[SyntaxKind["VarKeyword"] = 113] = "VarKeyword"; + SyntaxKind[SyntaxKind["VoidKeyword"] = 114] = "VoidKeyword"; + SyntaxKind[SyntaxKind["WhileKeyword"] = 115] = "WhileKeyword"; + SyntaxKind[SyntaxKind["WithKeyword"] = 116] = "WithKeyword"; + // Strict mode reserved words + SyntaxKind[SyntaxKind["ImplementsKeyword"] = 117] = "ImplementsKeyword"; + SyntaxKind[SyntaxKind["InterfaceKeyword"] = 118] = "InterfaceKeyword"; + SyntaxKind[SyntaxKind["LetKeyword"] = 119] = "LetKeyword"; + SyntaxKind[SyntaxKind["PackageKeyword"] = 120] = "PackageKeyword"; + SyntaxKind[SyntaxKind["PrivateKeyword"] = 121] = "PrivateKeyword"; + SyntaxKind[SyntaxKind["ProtectedKeyword"] = 122] = "ProtectedKeyword"; + SyntaxKind[SyntaxKind["PublicKeyword"] = 123] = "PublicKeyword"; + SyntaxKind[SyntaxKind["StaticKeyword"] = 124] = "StaticKeyword"; + SyntaxKind[SyntaxKind["YieldKeyword"] = 125] = "YieldKeyword"; + // Contextual keywords + SyntaxKind[SyntaxKind["AbstractKeyword"] = 126] = "AbstractKeyword"; + SyntaxKind[SyntaxKind["AsKeyword"] = 127] = "AsKeyword"; + SyntaxKind[SyntaxKind["AssertsKeyword"] = 128] = "AssertsKeyword"; + SyntaxKind[SyntaxKind["AssertKeyword"] = 129] = "AssertKeyword"; + SyntaxKind[SyntaxKind["AnyKeyword"] = 130] = "AnyKeyword"; + SyntaxKind[SyntaxKind["AsyncKeyword"] = 131] = "AsyncKeyword"; + SyntaxKind[SyntaxKind["AwaitKeyword"] = 132] = "AwaitKeyword"; + SyntaxKind[SyntaxKind["BooleanKeyword"] = 133] = "BooleanKeyword"; + SyntaxKind[SyntaxKind["ConstructorKeyword"] = 134] = "ConstructorKeyword"; + SyntaxKind[SyntaxKind["DeclareKeyword"] = 135] = "DeclareKeyword"; + SyntaxKind[SyntaxKind["GetKeyword"] = 136] = "GetKeyword"; + SyntaxKind[SyntaxKind["InferKeyword"] = 137] = "InferKeyword"; + SyntaxKind[SyntaxKind["IntrinsicKeyword"] = 138] = "IntrinsicKeyword"; + SyntaxKind[SyntaxKind["IsKeyword"] = 139] = "IsKeyword"; + SyntaxKind[SyntaxKind["KeyOfKeyword"] = 140] = "KeyOfKeyword"; + SyntaxKind[SyntaxKind["ModuleKeyword"] = 141] = "ModuleKeyword"; + SyntaxKind[SyntaxKind["NamespaceKeyword"] = 142] = "NamespaceKeyword"; + SyntaxKind[SyntaxKind["NeverKeyword"] = 143] = "NeverKeyword"; + SyntaxKind[SyntaxKind["OutKeyword"] = 144] = "OutKeyword"; + SyntaxKind[SyntaxKind["ReadonlyKeyword"] = 145] = "ReadonlyKeyword"; + SyntaxKind[SyntaxKind["RequireKeyword"] = 146] = "RequireKeyword"; + SyntaxKind[SyntaxKind["NumberKeyword"] = 147] = "NumberKeyword"; + SyntaxKind[SyntaxKind["ObjectKeyword"] = 148] = "ObjectKeyword"; + SyntaxKind[SyntaxKind["SetKeyword"] = 149] = "SetKeyword"; + SyntaxKind[SyntaxKind["StringKeyword"] = 150] = "StringKeyword"; + SyntaxKind[SyntaxKind["SymbolKeyword"] = 151] = "SymbolKeyword"; + SyntaxKind[SyntaxKind["TypeKeyword"] = 152] = "TypeKeyword"; + SyntaxKind[SyntaxKind["UndefinedKeyword"] = 153] = "UndefinedKeyword"; + SyntaxKind[SyntaxKind["UniqueKeyword"] = 154] = "UniqueKeyword"; + SyntaxKind[SyntaxKind["UnknownKeyword"] = 155] = "UnknownKeyword"; + SyntaxKind[SyntaxKind["FromKeyword"] = 156] = "FromKeyword"; + SyntaxKind[SyntaxKind["GlobalKeyword"] = 157] = "GlobalKeyword"; + SyntaxKind[SyntaxKind["BigIntKeyword"] = 158] = "BigIntKeyword"; + SyntaxKind[SyntaxKind["OverrideKeyword"] = 159] = "OverrideKeyword"; + SyntaxKind[SyntaxKind["OfKeyword"] = 160] = "OfKeyword"; + // Parse tree nodes + // Names + SyntaxKind[SyntaxKind["QualifiedName"] = 161] = "QualifiedName"; + SyntaxKind[SyntaxKind["ComputedPropertyName"] = 162] = "ComputedPropertyName"; + // Signature elements + SyntaxKind[SyntaxKind["TypeParameter"] = 163] = "TypeParameter"; + SyntaxKind[SyntaxKind["Parameter"] = 164] = "Parameter"; + SyntaxKind[SyntaxKind["Decorator"] = 165] = "Decorator"; + // TypeMember + SyntaxKind[SyntaxKind["PropertySignature"] = 166] = "PropertySignature"; + SyntaxKind[SyntaxKind["PropertyDeclaration"] = 167] = "PropertyDeclaration"; + SyntaxKind[SyntaxKind["MethodSignature"] = 168] = "MethodSignature"; + SyntaxKind[SyntaxKind["MethodDeclaration"] = 169] = "MethodDeclaration"; + SyntaxKind[SyntaxKind["ClassStaticBlockDeclaration"] = 170] = "ClassStaticBlockDeclaration"; + SyntaxKind[SyntaxKind["Constructor"] = 171] = "Constructor"; + SyntaxKind[SyntaxKind["GetAccessor"] = 172] = "GetAccessor"; + SyntaxKind[SyntaxKind["SetAccessor"] = 173] = "SetAccessor"; + SyntaxKind[SyntaxKind["CallSignature"] = 174] = "CallSignature"; + SyntaxKind[SyntaxKind["ConstructSignature"] = 175] = "ConstructSignature"; + SyntaxKind[SyntaxKind["IndexSignature"] = 176] = "IndexSignature"; + // Type + SyntaxKind[SyntaxKind["TypePredicate"] = 177] = "TypePredicate"; + SyntaxKind[SyntaxKind["TypeReference"] = 178] = "TypeReference"; + SyntaxKind[SyntaxKind["FunctionType"] = 179] = "FunctionType"; + SyntaxKind[SyntaxKind["ConstructorType"] = 180] = "ConstructorType"; + SyntaxKind[SyntaxKind["TypeQuery"] = 181] = "TypeQuery"; + SyntaxKind[SyntaxKind["TypeLiteral"] = 182] = "TypeLiteral"; + SyntaxKind[SyntaxKind["ArrayType"] = 183] = "ArrayType"; + SyntaxKind[SyntaxKind["TupleType"] = 184] = "TupleType"; + SyntaxKind[SyntaxKind["OptionalType"] = 185] = "OptionalType"; + SyntaxKind[SyntaxKind["RestType"] = 186] = "RestType"; + SyntaxKind[SyntaxKind["UnionType"] = 187] = "UnionType"; + SyntaxKind[SyntaxKind["IntersectionType"] = 188] = "IntersectionType"; + SyntaxKind[SyntaxKind["ConditionalType"] = 189] = "ConditionalType"; + SyntaxKind[SyntaxKind["InferType"] = 190] = "InferType"; + SyntaxKind[SyntaxKind["ParenthesizedType"] = 191] = "ParenthesizedType"; + SyntaxKind[SyntaxKind["ThisType"] = 192] = "ThisType"; + SyntaxKind[SyntaxKind["TypeOperator"] = 193] = "TypeOperator"; + SyntaxKind[SyntaxKind["IndexedAccessType"] = 194] = "IndexedAccessType"; + SyntaxKind[SyntaxKind["MappedType"] = 195] = "MappedType"; + SyntaxKind[SyntaxKind["LiteralType"] = 196] = "LiteralType"; + SyntaxKind[SyntaxKind["NamedTupleMember"] = 197] = "NamedTupleMember"; + SyntaxKind[SyntaxKind["TemplateLiteralType"] = 198] = "TemplateLiteralType"; + SyntaxKind[SyntaxKind["TemplateLiteralTypeSpan"] = 199] = "TemplateLiteralTypeSpan"; + SyntaxKind[SyntaxKind["ImportType"] = 200] = "ImportType"; + // Binding patterns + SyntaxKind[SyntaxKind["ObjectBindingPattern"] = 201] = "ObjectBindingPattern"; + SyntaxKind[SyntaxKind["ArrayBindingPattern"] = 202] = "ArrayBindingPattern"; + SyntaxKind[SyntaxKind["BindingElement"] = 203] = "BindingElement"; + // Expression + SyntaxKind[SyntaxKind["ArrayLiteralExpression"] = 204] = "ArrayLiteralExpression"; + SyntaxKind[SyntaxKind["ObjectLiteralExpression"] = 205] = "ObjectLiteralExpression"; + SyntaxKind[SyntaxKind["PropertyAccessExpression"] = 206] = "PropertyAccessExpression"; + SyntaxKind[SyntaxKind["ElementAccessExpression"] = 207] = "ElementAccessExpression"; + SyntaxKind[SyntaxKind["CallExpression"] = 208] = "CallExpression"; + SyntaxKind[SyntaxKind["NewExpression"] = 209] = "NewExpression"; + SyntaxKind[SyntaxKind["TaggedTemplateExpression"] = 210] = "TaggedTemplateExpression"; + SyntaxKind[SyntaxKind["TypeAssertionExpression"] = 211] = "TypeAssertionExpression"; + SyntaxKind[SyntaxKind["ParenthesizedExpression"] = 212] = "ParenthesizedExpression"; + SyntaxKind[SyntaxKind["FunctionExpression"] = 213] = "FunctionExpression"; + SyntaxKind[SyntaxKind["ArrowFunction"] = 214] = "ArrowFunction"; + SyntaxKind[SyntaxKind["DeleteExpression"] = 215] = "DeleteExpression"; + SyntaxKind[SyntaxKind["TypeOfExpression"] = 216] = "TypeOfExpression"; + SyntaxKind[SyntaxKind["VoidExpression"] = 217] = "VoidExpression"; + SyntaxKind[SyntaxKind["AwaitExpression"] = 218] = "AwaitExpression"; + SyntaxKind[SyntaxKind["PrefixUnaryExpression"] = 219] = "PrefixUnaryExpression"; + SyntaxKind[SyntaxKind["PostfixUnaryExpression"] = 220] = "PostfixUnaryExpression"; + SyntaxKind[SyntaxKind["BinaryExpression"] = 221] = "BinaryExpression"; + SyntaxKind[SyntaxKind["ConditionalExpression"] = 222] = "ConditionalExpression"; + SyntaxKind[SyntaxKind["TemplateExpression"] = 223] = "TemplateExpression"; + SyntaxKind[SyntaxKind["YieldExpression"] = 224] = "YieldExpression"; + SyntaxKind[SyntaxKind["SpreadElement"] = 225] = "SpreadElement"; + SyntaxKind[SyntaxKind["ClassExpression"] = 226] = "ClassExpression"; + SyntaxKind[SyntaxKind["OmittedExpression"] = 227] = "OmittedExpression"; + SyntaxKind[SyntaxKind["ExpressionWithTypeArguments"] = 228] = "ExpressionWithTypeArguments"; + SyntaxKind[SyntaxKind["AsExpression"] = 229] = "AsExpression"; + SyntaxKind[SyntaxKind["NonNullExpression"] = 230] = "NonNullExpression"; + SyntaxKind[SyntaxKind["MetaProperty"] = 231] = "MetaProperty"; + SyntaxKind[SyntaxKind["SyntheticExpression"] = 232] = "SyntheticExpression"; + // Misc + SyntaxKind[SyntaxKind["TemplateSpan"] = 233] = "TemplateSpan"; + SyntaxKind[SyntaxKind["SemicolonClassElement"] = 234] = "SemicolonClassElement"; + // Element + SyntaxKind[SyntaxKind["Block"] = 235] = "Block"; + SyntaxKind[SyntaxKind["EmptyStatement"] = 236] = "EmptyStatement"; + SyntaxKind[SyntaxKind["VariableStatement"] = 237] = "VariableStatement"; + SyntaxKind[SyntaxKind["ExpressionStatement"] = 238] = "ExpressionStatement"; + SyntaxKind[SyntaxKind["IfStatement"] = 239] = "IfStatement"; + SyntaxKind[SyntaxKind["DoStatement"] = 240] = "DoStatement"; + SyntaxKind[SyntaxKind["WhileStatement"] = 241] = "WhileStatement"; + SyntaxKind[SyntaxKind["ForStatement"] = 242] = "ForStatement"; + SyntaxKind[SyntaxKind["ForInStatement"] = 243] = "ForInStatement"; + SyntaxKind[SyntaxKind["ForOfStatement"] = 244] = "ForOfStatement"; + SyntaxKind[SyntaxKind["ContinueStatement"] = 245] = "ContinueStatement"; + SyntaxKind[SyntaxKind["BreakStatement"] = 246] = "BreakStatement"; + SyntaxKind[SyntaxKind["ReturnStatement"] = 247] = "ReturnStatement"; + SyntaxKind[SyntaxKind["WithStatement"] = 248] = "WithStatement"; + SyntaxKind[SyntaxKind["SwitchStatement"] = 249] = "SwitchStatement"; + SyntaxKind[SyntaxKind["LabeledStatement"] = 250] = "LabeledStatement"; + SyntaxKind[SyntaxKind["ThrowStatement"] = 251] = "ThrowStatement"; + SyntaxKind[SyntaxKind["TryStatement"] = 252] = "TryStatement"; + SyntaxKind[SyntaxKind["DebuggerStatement"] = 253] = "DebuggerStatement"; + SyntaxKind[SyntaxKind["VariableDeclaration"] = 254] = "VariableDeclaration"; + SyntaxKind[SyntaxKind["VariableDeclarationList"] = 255] = "VariableDeclarationList"; + SyntaxKind[SyntaxKind["FunctionDeclaration"] = 256] = "FunctionDeclaration"; + SyntaxKind[SyntaxKind["ClassDeclaration"] = 257] = "ClassDeclaration"; + SyntaxKind[SyntaxKind["InterfaceDeclaration"] = 258] = "InterfaceDeclaration"; + SyntaxKind[SyntaxKind["TypeAliasDeclaration"] = 259] = "TypeAliasDeclaration"; + SyntaxKind[SyntaxKind["EnumDeclaration"] = 260] = "EnumDeclaration"; + SyntaxKind[SyntaxKind["ModuleDeclaration"] = 261] = "ModuleDeclaration"; + SyntaxKind[SyntaxKind["ModuleBlock"] = 262] = "ModuleBlock"; + SyntaxKind[SyntaxKind["CaseBlock"] = 263] = "CaseBlock"; + SyntaxKind[SyntaxKind["NamespaceExportDeclaration"] = 264] = "NamespaceExportDeclaration"; + SyntaxKind[SyntaxKind["ImportEqualsDeclaration"] = 265] = "ImportEqualsDeclaration"; + SyntaxKind[SyntaxKind["ImportDeclaration"] = 266] = "ImportDeclaration"; + SyntaxKind[SyntaxKind["ImportClause"] = 267] = "ImportClause"; + SyntaxKind[SyntaxKind["NamespaceImport"] = 268] = "NamespaceImport"; + SyntaxKind[SyntaxKind["NamedImports"] = 269] = "NamedImports"; + SyntaxKind[SyntaxKind["ImportSpecifier"] = 270] = "ImportSpecifier"; + SyntaxKind[SyntaxKind["ExportAssignment"] = 271] = "ExportAssignment"; + SyntaxKind[SyntaxKind["ExportDeclaration"] = 272] = "ExportDeclaration"; + SyntaxKind[SyntaxKind["NamedExports"] = 273] = "NamedExports"; + SyntaxKind[SyntaxKind["NamespaceExport"] = 274] = "NamespaceExport"; + SyntaxKind[SyntaxKind["ExportSpecifier"] = 275] = "ExportSpecifier"; + SyntaxKind[SyntaxKind["MissingDeclaration"] = 276] = "MissingDeclaration"; + // Module references + SyntaxKind[SyntaxKind["ExternalModuleReference"] = 277] = "ExternalModuleReference"; + // JSX + SyntaxKind[SyntaxKind["JsxElement"] = 278] = "JsxElement"; + SyntaxKind[SyntaxKind["JsxSelfClosingElement"] = 279] = "JsxSelfClosingElement"; + SyntaxKind[SyntaxKind["JsxOpeningElement"] = 280] = "JsxOpeningElement"; + SyntaxKind[SyntaxKind["JsxClosingElement"] = 281] = "JsxClosingElement"; + SyntaxKind[SyntaxKind["JsxFragment"] = 282] = "JsxFragment"; + SyntaxKind[SyntaxKind["JsxOpeningFragment"] = 283] = "JsxOpeningFragment"; + SyntaxKind[SyntaxKind["JsxClosingFragment"] = 284] = "JsxClosingFragment"; + SyntaxKind[SyntaxKind["JsxAttribute"] = 285] = "JsxAttribute"; + SyntaxKind[SyntaxKind["JsxAttributes"] = 286] = "JsxAttributes"; + SyntaxKind[SyntaxKind["JsxSpreadAttribute"] = 287] = "JsxSpreadAttribute"; + SyntaxKind[SyntaxKind["JsxExpression"] = 288] = "JsxExpression"; + // Clauses + SyntaxKind[SyntaxKind["CaseClause"] = 289] = "CaseClause"; + SyntaxKind[SyntaxKind["DefaultClause"] = 290] = "DefaultClause"; + SyntaxKind[SyntaxKind["HeritageClause"] = 291] = "HeritageClause"; + SyntaxKind[SyntaxKind["CatchClause"] = 292] = "CatchClause"; + SyntaxKind[SyntaxKind["AssertClause"] = 293] = "AssertClause"; + SyntaxKind[SyntaxKind["AssertEntry"] = 294] = "AssertEntry"; + SyntaxKind[SyntaxKind["ImportTypeAssertionContainer"] = 295] = "ImportTypeAssertionContainer"; + // Property assignments + SyntaxKind[SyntaxKind["PropertyAssignment"] = 296] = "PropertyAssignment"; + SyntaxKind[SyntaxKind["ShorthandPropertyAssignment"] = 297] = "ShorthandPropertyAssignment"; + SyntaxKind[SyntaxKind["SpreadAssignment"] = 298] = "SpreadAssignment"; + // Enum + SyntaxKind[SyntaxKind["EnumMember"] = 299] = "EnumMember"; + // Unparsed + SyntaxKind[SyntaxKind["UnparsedPrologue"] = 300] = "UnparsedPrologue"; + SyntaxKind[SyntaxKind["UnparsedPrepend"] = 301] = "UnparsedPrepend"; + SyntaxKind[SyntaxKind["UnparsedText"] = 302] = "UnparsedText"; + SyntaxKind[SyntaxKind["UnparsedInternalText"] = 303] = "UnparsedInternalText"; + SyntaxKind[SyntaxKind["UnparsedSyntheticReference"] = 304] = "UnparsedSyntheticReference"; + // Top-level nodes + SyntaxKind[SyntaxKind["SourceFile"] = 305] = "SourceFile"; + SyntaxKind[SyntaxKind["Bundle"] = 306] = "Bundle"; + SyntaxKind[SyntaxKind["UnparsedSource"] = 307] = "UnparsedSource"; + SyntaxKind[SyntaxKind["InputFiles"] = 308] = "InputFiles"; + // JSDoc nodes + SyntaxKind[SyntaxKind["JSDocTypeExpression"] = 309] = "JSDocTypeExpression"; + SyntaxKind[SyntaxKind["JSDocNameReference"] = 310] = "JSDocNameReference"; + SyntaxKind[SyntaxKind["JSDocMemberName"] = 311] = "JSDocMemberName"; + SyntaxKind[SyntaxKind["JSDocAllType"] = 312] = "JSDocAllType"; + SyntaxKind[SyntaxKind["JSDocUnknownType"] = 313] = "JSDocUnknownType"; + SyntaxKind[SyntaxKind["JSDocNullableType"] = 314] = "JSDocNullableType"; + SyntaxKind[SyntaxKind["JSDocNonNullableType"] = 315] = "JSDocNonNullableType"; + SyntaxKind[SyntaxKind["JSDocOptionalType"] = 316] = "JSDocOptionalType"; + SyntaxKind[SyntaxKind["JSDocFunctionType"] = 317] = "JSDocFunctionType"; + SyntaxKind[SyntaxKind["JSDocVariadicType"] = 318] = "JSDocVariadicType"; + SyntaxKind[SyntaxKind["JSDocNamepathType"] = 319] = "JSDocNamepathType"; + /** @deprecated Use SyntaxKind.JSDoc */ + SyntaxKind[SyntaxKind["JSDocComment"] = 320] = "JSDocComment"; + SyntaxKind[SyntaxKind["JSDocText"] = 321] = "JSDocText"; + SyntaxKind[SyntaxKind["JSDocTypeLiteral"] = 322] = "JSDocTypeLiteral"; + SyntaxKind[SyntaxKind["JSDocSignature"] = 323] = "JSDocSignature"; + SyntaxKind[SyntaxKind["JSDocLink"] = 324] = "JSDocLink"; + SyntaxKind[SyntaxKind["JSDocLinkCode"] = 325] = "JSDocLinkCode"; + SyntaxKind[SyntaxKind["JSDocLinkPlain"] = 326] = "JSDocLinkPlain"; + SyntaxKind[SyntaxKind["JSDocTag"] = 327] = "JSDocTag"; + SyntaxKind[SyntaxKind["JSDocAugmentsTag"] = 328] = "JSDocAugmentsTag"; + SyntaxKind[SyntaxKind["JSDocImplementsTag"] = 329] = "JSDocImplementsTag"; + SyntaxKind[SyntaxKind["JSDocAuthorTag"] = 330] = "JSDocAuthorTag"; + SyntaxKind[SyntaxKind["JSDocDeprecatedTag"] = 331] = "JSDocDeprecatedTag"; + SyntaxKind[SyntaxKind["JSDocClassTag"] = 332] = "JSDocClassTag"; + SyntaxKind[SyntaxKind["JSDocPublicTag"] = 333] = "JSDocPublicTag"; + SyntaxKind[SyntaxKind["JSDocPrivateTag"] = 334] = "JSDocPrivateTag"; + SyntaxKind[SyntaxKind["JSDocProtectedTag"] = 335] = "JSDocProtectedTag"; + SyntaxKind[SyntaxKind["JSDocReadonlyTag"] = 336] = "JSDocReadonlyTag"; + SyntaxKind[SyntaxKind["JSDocOverrideTag"] = 337] = "JSDocOverrideTag"; + SyntaxKind[SyntaxKind["JSDocCallbackTag"] = 338] = "JSDocCallbackTag"; + SyntaxKind[SyntaxKind["JSDocEnumTag"] = 339] = "JSDocEnumTag"; + SyntaxKind[SyntaxKind["JSDocParameterTag"] = 340] = "JSDocParameterTag"; + SyntaxKind[SyntaxKind["JSDocReturnTag"] = 341] = "JSDocReturnTag"; + SyntaxKind[SyntaxKind["JSDocThisTag"] = 342] = "JSDocThisTag"; + SyntaxKind[SyntaxKind["JSDocTypeTag"] = 343] = "JSDocTypeTag"; + SyntaxKind[SyntaxKind["JSDocTemplateTag"] = 344] = "JSDocTemplateTag"; + SyntaxKind[SyntaxKind["JSDocTypedefTag"] = 345] = "JSDocTypedefTag"; + SyntaxKind[SyntaxKind["JSDocSeeTag"] = 346] = "JSDocSeeTag"; + SyntaxKind[SyntaxKind["JSDocPropertyTag"] = 347] = "JSDocPropertyTag"; + // Synthesized list + SyntaxKind[SyntaxKind["SyntaxList"] = 348] = "SyntaxList"; + // Transformation nodes + SyntaxKind[SyntaxKind["NotEmittedStatement"] = 349] = "NotEmittedStatement"; + SyntaxKind[SyntaxKind["PartiallyEmittedExpression"] = 350] = "PartiallyEmittedExpression"; + SyntaxKind[SyntaxKind["CommaListExpression"] = 351] = "CommaListExpression"; + SyntaxKind[SyntaxKind["MergeDeclarationMarker"] = 352] = "MergeDeclarationMarker"; + SyntaxKind[SyntaxKind["EndOfDeclarationMarker"] = 353] = "EndOfDeclarationMarker"; + SyntaxKind[SyntaxKind["SyntheticReferenceExpression"] = 354] = "SyntheticReferenceExpression"; + // Enum value count + SyntaxKind[SyntaxKind["Count"] = 355] = "Count"; + // Markers + SyntaxKind[SyntaxKind["FirstAssignment"] = 63] = "FirstAssignment"; + SyntaxKind[SyntaxKind["LastAssignment"] = 78] = "LastAssignment"; + SyntaxKind[SyntaxKind["FirstCompoundAssignment"] = 64] = "FirstCompoundAssignment"; + SyntaxKind[SyntaxKind["LastCompoundAssignment"] = 78] = "LastCompoundAssignment"; + SyntaxKind[SyntaxKind["FirstReservedWord"] = 81] = "FirstReservedWord"; + SyntaxKind[SyntaxKind["LastReservedWord"] = 116] = "LastReservedWord"; + SyntaxKind[SyntaxKind["FirstKeyword"] = 81] = "FirstKeyword"; + SyntaxKind[SyntaxKind["LastKeyword"] = 160] = "LastKeyword"; + SyntaxKind[SyntaxKind["FirstFutureReservedWord"] = 117] = "FirstFutureReservedWord"; + SyntaxKind[SyntaxKind["LastFutureReservedWord"] = 125] = "LastFutureReservedWord"; + SyntaxKind[SyntaxKind["FirstTypeNode"] = 177] = "FirstTypeNode"; + SyntaxKind[SyntaxKind["LastTypeNode"] = 200] = "LastTypeNode"; + SyntaxKind[SyntaxKind["FirstPunctuation"] = 18] = "FirstPunctuation"; + SyntaxKind[SyntaxKind["LastPunctuation"] = 78] = "LastPunctuation"; + SyntaxKind[SyntaxKind["FirstToken"] = 0] = "FirstToken"; + SyntaxKind[SyntaxKind["LastToken"] = 160] = "LastToken"; + SyntaxKind[SyntaxKind["FirstTriviaToken"] = 2] = "FirstTriviaToken"; + SyntaxKind[SyntaxKind["LastTriviaToken"] = 7] = "LastTriviaToken"; + SyntaxKind[SyntaxKind["FirstLiteralToken"] = 8] = "FirstLiteralToken"; + SyntaxKind[SyntaxKind["LastLiteralToken"] = 14] = "LastLiteralToken"; + SyntaxKind[SyntaxKind["FirstTemplateToken"] = 14] = "FirstTemplateToken"; + SyntaxKind[SyntaxKind["LastTemplateToken"] = 17] = "LastTemplateToken"; + SyntaxKind[SyntaxKind["FirstBinaryOperator"] = 29] = "FirstBinaryOperator"; + SyntaxKind[SyntaxKind["LastBinaryOperator"] = 78] = "LastBinaryOperator"; + SyntaxKind[SyntaxKind["FirstStatement"] = 237] = "FirstStatement"; + SyntaxKind[SyntaxKind["LastStatement"] = 253] = "LastStatement"; + SyntaxKind[SyntaxKind["FirstNode"] = 161] = "FirstNode"; + SyntaxKind[SyntaxKind["FirstJSDocNode"] = 309] = "FirstJSDocNode"; + SyntaxKind[SyntaxKind["LastJSDocNode"] = 347] = "LastJSDocNode"; + SyntaxKind[SyntaxKind["FirstJSDocTagNode"] = 327] = "FirstJSDocTagNode"; + SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 347] = "LastJSDocTagNode"; + /* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 126] = "FirstContextualKeyword"; + /* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 160] = "LastContextualKeyword"; + SyntaxKind[SyntaxKind["JSDoc"] = 320] = "JSDoc"; + })(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {})); + var NodeFlags; + (function (NodeFlags) { + NodeFlags[NodeFlags["None"] = 0] = "None"; + NodeFlags[NodeFlags["Let"] = 1] = "Let"; + NodeFlags[NodeFlags["Const"] = 2] = "Const"; + NodeFlags[NodeFlags["NestedNamespace"] = 4] = "NestedNamespace"; + NodeFlags[NodeFlags["Synthesized"] = 8] = "Synthesized"; + NodeFlags[NodeFlags["Namespace"] = 16] = "Namespace"; + NodeFlags[NodeFlags["OptionalChain"] = 32] = "OptionalChain"; + NodeFlags[NodeFlags["ExportContext"] = 64] = "ExportContext"; + NodeFlags[NodeFlags["ContainsThis"] = 128] = "ContainsThis"; + NodeFlags[NodeFlags["HasImplicitReturn"] = 256] = "HasImplicitReturn"; + NodeFlags[NodeFlags["HasExplicitReturn"] = 512] = "HasExplicitReturn"; + NodeFlags[NodeFlags["GlobalAugmentation"] = 1024] = "GlobalAugmentation"; + NodeFlags[NodeFlags["HasAsyncFunctions"] = 2048] = "HasAsyncFunctions"; + NodeFlags[NodeFlags["DisallowInContext"] = 4096] = "DisallowInContext"; + NodeFlags[NodeFlags["YieldContext"] = 8192] = "YieldContext"; + NodeFlags[NodeFlags["DecoratorContext"] = 16384] = "DecoratorContext"; + NodeFlags[NodeFlags["AwaitContext"] = 32768] = "AwaitContext"; + NodeFlags[NodeFlags["DisallowConditionalTypesContext"] = 65536] = "DisallowConditionalTypesContext"; + NodeFlags[NodeFlags["ThisNodeHasError"] = 131072] = "ThisNodeHasError"; + NodeFlags[NodeFlags["JavaScriptFile"] = 262144] = "JavaScriptFile"; + NodeFlags[NodeFlags["ThisNodeOrAnySubNodesHasError"] = 524288] = "ThisNodeOrAnySubNodesHasError"; + NodeFlags[NodeFlags["HasAggregatedChildData"] = 1048576] = "HasAggregatedChildData"; + // These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid + // walking the tree if the flags are not set. However, these flags are just a approximation + // (hence why it's named "PossiblyContainsDynamicImport") because once set, the flags never get cleared. + // During editing, if a dynamic import is removed, incremental parsing will *NOT* clear this flag. + // This means that the tree will always be traversed during module resolution, or when looking for external module indicators. + // However, the removal operation should not occur often and in the case of the + // removal, it is likely that users will add the import anyway. + // The advantage of this approach is its simplicity. For the case of batch compilation, + // we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used. + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsDynamicImport"] = 2097152] = "PossiblyContainsDynamicImport"; + /* @internal */ NodeFlags[NodeFlags["PossiblyContainsImportMeta"] = 4194304] = "PossiblyContainsImportMeta"; + NodeFlags[NodeFlags["JSDoc"] = 8388608] = "JSDoc"; + /* @internal */ NodeFlags[NodeFlags["Ambient"] = 16777216] = "Ambient"; + /* @internal */ NodeFlags[NodeFlags["InWithStatement"] = 33554432] = "InWithStatement"; + NodeFlags[NodeFlags["JsonFile"] = 67108864] = "JsonFile"; + /* @internal */ NodeFlags[NodeFlags["TypeCached"] = 134217728] = "TypeCached"; + /* @internal */ NodeFlags[NodeFlags["Deprecated"] = 268435456] = "Deprecated"; + NodeFlags[NodeFlags["BlockScoped"] = 3] = "BlockScoped"; + NodeFlags[NodeFlags["ReachabilityCheckFlags"] = 768] = "ReachabilityCheckFlags"; + NodeFlags[NodeFlags["ReachabilityAndEmitFlags"] = 2816] = "ReachabilityAndEmitFlags"; + // Parsing context flags + NodeFlags[NodeFlags["ContextFlags"] = 50720768] = "ContextFlags"; + // Exclude these flags when parsing a Type + NodeFlags[NodeFlags["TypeExcludesFlags"] = 40960] = "TypeExcludesFlags"; + // Represents all flags that are potentially set once and + // never cleared on SourceFiles which get re-used in between incremental parses. + // See the comment above on `PossiblyContainsDynamicImport` and `PossiblyContainsImportMeta`. + /* @internal */ NodeFlags[NodeFlags["PermanentlySetIncrementalFlags"] = 6291456] = "PermanentlySetIncrementalFlags"; + })(NodeFlags = ts.NodeFlags || (ts.NodeFlags = {})); + var ModifierFlags; + (function (ModifierFlags) { + ModifierFlags[ModifierFlags["None"] = 0] = "None"; + ModifierFlags[ModifierFlags["Export"] = 1] = "Export"; + ModifierFlags[ModifierFlags["Ambient"] = 2] = "Ambient"; + ModifierFlags[ModifierFlags["Public"] = 4] = "Public"; + ModifierFlags[ModifierFlags["Private"] = 8] = "Private"; + ModifierFlags[ModifierFlags["Protected"] = 16] = "Protected"; + ModifierFlags[ModifierFlags["Static"] = 32] = "Static"; + ModifierFlags[ModifierFlags["Readonly"] = 64] = "Readonly"; + ModifierFlags[ModifierFlags["Abstract"] = 128] = "Abstract"; + ModifierFlags[ModifierFlags["Async"] = 256] = "Async"; + ModifierFlags[ModifierFlags["Default"] = 512] = "Default"; + ModifierFlags[ModifierFlags["Const"] = 2048] = "Const"; + ModifierFlags[ModifierFlags["HasComputedJSDocModifiers"] = 4096] = "HasComputedJSDocModifiers"; + ModifierFlags[ModifierFlags["Deprecated"] = 8192] = "Deprecated"; + ModifierFlags[ModifierFlags["Override"] = 16384] = "Override"; + ModifierFlags[ModifierFlags["In"] = 32768] = "In"; + ModifierFlags[ModifierFlags["Out"] = 65536] = "Out"; + ModifierFlags[ModifierFlags["HasComputedFlags"] = 536870912] = "HasComputedFlags"; + ModifierFlags[ModifierFlags["AccessibilityModifier"] = 28] = "AccessibilityModifier"; + // Accessibility modifiers and 'readonly' can be attached to a parameter in a constructor to make it a property. + ModifierFlags[ModifierFlags["ParameterPropertyModifier"] = 16476] = "ParameterPropertyModifier"; + ModifierFlags[ModifierFlags["NonPublicAccessibilityModifier"] = 24] = "NonPublicAccessibilityModifier"; + ModifierFlags[ModifierFlags["TypeScriptModifier"] = 116958] = "TypeScriptModifier"; + ModifierFlags[ModifierFlags["ExportDefault"] = 513] = "ExportDefault"; + ModifierFlags[ModifierFlags["All"] = 125951] = "All"; + })(ModifierFlags = ts.ModifierFlags || (ts.ModifierFlags = {})); + var JsxFlags; + (function (JsxFlags) { + JsxFlags[JsxFlags["None"] = 0] = "None"; + /** An element from a named property of the JSX.IntrinsicElements interface */ + JsxFlags[JsxFlags["IntrinsicNamedElement"] = 1] = "IntrinsicNamedElement"; + /** An element inferred from the string index signature of the JSX.IntrinsicElements interface */ + JsxFlags[JsxFlags["IntrinsicIndexedElement"] = 2] = "IntrinsicIndexedElement"; + JsxFlags[JsxFlags["IntrinsicElement"] = 3] = "IntrinsicElement"; + })(JsxFlags = ts.JsxFlags || (ts.JsxFlags = {})); + /* @internal */ + var RelationComparisonResult; + (function (RelationComparisonResult) { + RelationComparisonResult[RelationComparisonResult["Succeeded"] = 1] = "Succeeded"; + RelationComparisonResult[RelationComparisonResult["Failed"] = 2] = "Failed"; + RelationComparisonResult[RelationComparisonResult["Reported"] = 4] = "Reported"; + RelationComparisonResult[RelationComparisonResult["ReportsUnmeasurable"] = 8] = "ReportsUnmeasurable"; + RelationComparisonResult[RelationComparisonResult["ReportsUnreliable"] = 16] = "ReportsUnreliable"; + RelationComparisonResult[RelationComparisonResult["ReportsMask"] = 24] = "ReportsMask"; + })(RelationComparisonResult = ts.RelationComparisonResult || (ts.RelationComparisonResult = {})); + var GeneratedIdentifierFlags; + (function (GeneratedIdentifierFlags) { + // Kinds + GeneratedIdentifierFlags[GeneratedIdentifierFlags["None"] = 0] = "None"; + /*@internal*/ GeneratedIdentifierFlags[GeneratedIdentifierFlags["Auto"] = 1] = "Auto"; + /*@internal*/ GeneratedIdentifierFlags[GeneratedIdentifierFlags["Loop"] = 2] = "Loop"; + /*@internal*/ GeneratedIdentifierFlags[GeneratedIdentifierFlags["Unique"] = 3] = "Unique"; + /*@internal*/ GeneratedIdentifierFlags[GeneratedIdentifierFlags["Node"] = 4] = "Node"; + /*@internal*/ GeneratedIdentifierFlags[GeneratedIdentifierFlags["KindMask"] = 7] = "KindMask"; + // Flags + GeneratedIdentifierFlags[GeneratedIdentifierFlags["ReservedInNestedScopes"] = 8] = "ReservedInNestedScopes"; + GeneratedIdentifierFlags[GeneratedIdentifierFlags["Optimistic"] = 16] = "Optimistic"; + GeneratedIdentifierFlags[GeneratedIdentifierFlags["FileLevel"] = 32] = "FileLevel"; + GeneratedIdentifierFlags[GeneratedIdentifierFlags["AllowNameSubstitution"] = 64] = "AllowNameSubstitution"; + })(GeneratedIdentifierFlags = ts.GeneratedIdentifierFlags || (ts.GeneratedIdentifierFlags = {})); + var TokenFlags; + (function (TokenFlags) { + TokenFlags[TokenFlags["None"] = 0] = "None"; + /* @internal */ + TokenFlags[TokenFlags["PrecedingLineBreak"] = 1] = "PrecedingLineBreak"; + /* @internal */ + TokenFlags[TokenFlags["PrecedingJSDocComment"] = 2] = "PrecedingJSDocComment"; + /* @internal */ + TokenFlags[TokenFlags["Unterminated"] = 4] = "Unterminated"; + /* @internal */ + TokenFlags[TokenFlags["ExtendedUnicodeEscape"] = 8] = "ExtendedUnicodeEscape"; + TokenFlags[TokenFlags["Scientific"] = 16] = "Scientific"; + TokenFlags[TokenFlags["Octal"] = 32] = "Octal"; + TokenFlags[TokenFlags["HexSpecifier"] = 64] = "HexSpecifier"; + TokenFlags[TokenFlags["BinarySpecifier"] = 128] = "BinarySpecifier"; + TokenFlags[TokenFlags["OctalSpecifier"] = 256] = "OctalSpecifier"; + /* @internal */ + TokenFlags[TokenFlags["ContainsSeparator"] = 512] = "ContainsSeparator"; + /* @internal */ + TokenFlags[TokenFlags["UnicodeEscape"] = 1024] = "UnicodeEscape"; + /* @internal */ + TokenFlags[TokenFlags["ContainsInvalidEscape"] = 2048] = "ContainsInvalidEscape"; + /* @internal */ + TokenFlags[TokenFlags["BinaryOrOctalSpecifier"] = 384] = "BinaryOrOctalSpecifier"; + /* @internal */ + TokenFlags[TokenFlags["NumericLiteralFlags"] = 1008] = "NumericLiteralFlags"; + /* @internal */ + TokenFlags[TokenFlags["TemplateLiteralLikeFlags"] = 2048] = "TemplateLiteralLikeFlags"; + })(TokenFlags = ts.TokenFlags || (ts.TokenFlags = {})); + // NOTE: Ensure this is up-to-date with src/debug/debug.ts + var FlowFlags; + (function (FlowFlags) { + FlowFlags[FlowFlags["Unreachable"] = 1] = "Unreachable"; + FlowFlags[FlowFlags["Start"] = 2] = "Start"; + FlowFlags[FlowFlags["BranchLabel"] = 4] = "BranchLabel"; + FlowFlags[FlowFlags["LoopLabel"] = 8] = "LoopLabel"; + FlowFlags[FlowFlags["Assignment"] = 16] = "Assignment"; + FlowFlags[FlowFlags["TrueCondition"] = 32] = "TrueCondition"; + FlowFlags[FlowFlags["FalseCondition"] = 64] = "FalseCondition"; + FlowFlags[FlowFlags["SwitchClause"] = 128] = "SwitchClause"; + FlowFlags[FlowFlags["ArrayMutation"] = 256] = "ArrayMutation"; + FlowFlags[FlowFlags["Call"] = 512] = "Call"; + FlowFlags[FlowFlags["ReduceLabel"] = 1024] = "ReduceLabel"; + FlowFlags[FlowFlags["Referenced"] = 2048] = "Referenced"; + FlowFlags[FlowFlags["Shared"] = 4096] = "Shared"; + FlowFlags[FlowFlags["Label"] = 12] = "Label"; + FlowFlags[FlowFlags["Condition"] = 96] = "Condition"; + })(FlowFlags = ts.FlowFlags || (ts.FlowFlags = {})); + /* @internal */ + var CommentDirectiveType; + (function (CommentDirectiveType) { + CommentDirectiveType[CommentDirectiveType["ExpectError"] = 0] = "ExpectError"; + CommentDirectiveType[CommentDirectiveType["Ignore"] = 1] = "Ignore"; + })(CommentDirectiveType = ts.CommentDirectiveType || (ts.CommentDirectiveType = {})); + var OperationCanceledException = /** @class */ (function () { + function OperationCanceledException() { + } + return OperationCanceledException; + }()); + ts.OperationCanceledException = OperationCanceledException; + /*@internal*/ + var FileIncludeKind; + (function (FileIncludeKind) { + FileIncludeKind[FileIncludeKind["RootFile"] = 0] = "RootFile"; + FileIncludeKind[FileIncludeKind["SourceFromProjectReference"] = 1] = "SourceFromProjectReference"; + FileIncludeKind[FileIncludeKind["OutputFromProjectReference"] = 2] = "OutputFromProjectReference"; + FileIncludeKind[FileIncludeKind["Import"] = 3] = "Import"; + FileIncludeKind[FileIncludeKind["ReferenceFile"] = 4] = "ReferenceFile"; + FileIncludeKind[FileIncludeKind["TypeReferenceDirective"] = 5] = "TypeReferenceDirective"; + FileIncludeKind[FileIncludeKind["LibFile"] = 6] = "LibFile"; + FileIncludeKind[FileIncludeKind["LibReferenceDirective"] = 7] = "LibReferenceDirective"; + FileIncludeKind[FileIncludeKind["AutomaticTypeDirectiveFile"] = 8] = "AutomaticTypeDirectiveFile"; + })(FileIncludeKind = ts.FileIncludeKind || (ts.FileIncludeKind = {})); + /*@internal*/ + var FilePreprocessingDiagnosticsKind; + (function (FilePreprocessingDiagnosticsKind) { + FilePreprocessingDiagnosticsKind[FilePreprocessingDiagnosticsKind["FilePreprocessingReferencedDiagnostic"] = 0] = "FilePreprocessingReferencedDiagnostic"; + FilePreprocessingDiagnosticsKind[FilePreprocessingDiagnosticsKind["FilePreprocessingFileExplainingDiagnostic"] = 1] = "FilePreprocessingFileExplainingDiagnostic"; + })(FilePreprocessingDiagnosticsKind = ts.FilePreprocessingDiagnosticsKind || (ts.FilePreprocessingDiagnosticsKind = {})); + /* @internal */ + var StructureIsReused; + (function (StructureIsReused) { + StructureIsReused[StructureIsReused["Not"] = 0] = "Not"; + StructureIsReused[StructureIsReused["SafeModules"] = 1] = "SafeModules"; + StructureIsReused[StructureIsReused["Completely"] = 2] = "Completely"; + })(StructureIsReused = ts.StructureIsReused || (ts.StructureIsReused = {})); + /** Return code used by getEmitOutput function to indicate status of the function */ + var ExitStatus; + (function (ExitStatus) { + // Compiler ran successfully. Either this was a simple do-nothing compilation (for example, + // when -version or -help was provided, or this was a normal compilation, no diagnostics + // were produced, and all outputs were generated successfully. + ExitStatus[ExitStatus["Success"] = 0] = "Success"; + // Diagnostics were produced and because of them no code was generated. + ExitStatus[ExitStatus["DiagnosticsPresent_OutputsSkipped"] = 1] = "DiagnosticsPresent_OutputsSkipped"; + // Diagnostics were produced and outputs were generated in spite of them. + ExitStatus[ExitStatus["DiagnosticsPresent_OutputsGenerated"] = 2] = "DiagnosticsPresent_OutputsGenerated"; + // When build skipped because passed in project is invalid + ExitStatus[ExitStatus["InvalidProject_OutputsSkipped"] = 3] = "InvalidProject_OutputsSkipped"; + // When build is skipped because project references form cycle + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkipped"] = 4] = "ProjectReferenceCycle_OutputsSkipped"; + /** @deprecated Use ProjectReferenceCycle_OutputsSkipped instead. */ + ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped"; + })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {})); + /* @internal */ + var MemberOverrideStatus; + (function (MemberOverrideStatus) { + MemberOverrideStatus[MemberOverrideStatus["Ok"] = 0] = "Ok"; + MemberOverrideStatus[MemberOverrideStatus["NeedsOverride"] = 1] = "NeedsOverride"; + MemberOverrideStatus[MemberOverrideStatus["HasInvalidOverride"] = 2] = "HasInvalidOverride"; + })(MemberOverrideStatus = ts.MemberOverrideStatus || (ts.MemberOverrideStatus = {})); + /* @internal */ + var UnionReduction; + (function (UnionReduction) { + UnionReduction[UnionReduction["None"] = 0] = "None"; + UnionReduction[UnionReduction["Literal"] = 1] = "Literal"; + UnionReduction[UnionReduction["Subtype"] = 2] = "Subtype"; + })(UnionReduction = ts.UnionReduction || (ts.UnionReduction = {})); + /* @internal */ + var ContextFlags; + (function (ContextFlags) { + ContextFlags[ContextFlags["None"] = 0] = "None"; + ContextFlags[ContextFlags["Signature"] = 1] = "Signature"; + ContextFlags[ContextFlags["NoConstraints"] = 2] = "NoConstraints"; + ContextFlags[ContextFlags["Completions"] = 4] = "Completions"; + ContextFlags[ContextFlags["SkipBindingPatterns"] = 8] = "SkipBindingPatterns"; + })(ContextFlags = ts.ContextFlags || (ts.ContextFlags = {})); + // NOTE: If modifying this enum, must modify `TypeFormatFlags` too! + var NodeBuilderFlags; + (function (NodeBuilderFlags) { + NodeBuilderFlags[NodeBuilderFlags["None"] = 0] = "None"; + // Options + NodeBuilderFlags[NodeBuilderFlags["NoTruncation"] = 1] = "NoTruncation"; + NodeBuilderFlags[NodeBuilderFlags["WriteArrayAsGenericType"] = 2] = "WriteArrayAsGenericType"; + NodeBuilderFlags[NodeBuilderFlags["GenerateNamesForShadowedTypeParams"] = 4] = "GenerateNamesForShadowedTypeParams"; + NodeBuilderFlags[NodeBuilderFlags["UseStructuralFallback"] = 8] = "UseStructuralFallback"; + NodeBuilderFlags[NodeBuilderFlags["ForbidIndexedAccessSymbolReferences"] = 16] = "ForbidIndexedAccessSymbolReferences"; + NodeBuilderFlags[NodeBuilderFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature"; + NodeBuilderFlags[NodeBuilderFlags["UseFullyQualifiedType"] = 64] = "UseFullyQualifiedType"; + NodeBuilderFlags[NodeBuilderFlags["UseOnlyExternalAliasing"] = 128] = "UseOnlyExternalAliasing"; + NodeBuilderFlags[NodeBuilderFlags["SuppressAnyReturnType"] = 256] = "SuppressAnyReturnType"; + NodeBuilderFlags[NodeBuilderFlags["WriteTypeParametersInQualifiedName"] = 512] = "WriteTypeParametersInQualifiedName"; + NodeBuilderFlags[NodeBuilderFlags["MultilineObjectLiterals"] = 1024] = "MultilineObjectLiterals"; + NodeBuilderFlags[NodeBuilderFlags["WriteClassExpressionAsTypeLiteral"] = 2048] = "WriteClassExpressionAsTypeLiteral"; + NodeBuilderFlags[NodeBuilderFlags["UseTypeOfFunction"] = 4096] = "UseTypeOfFunction"; + NodeBuilderFlags[NodeBuilderFlags["OmitParameterModifiers"] = 8192] = "OmitParameterModifiers"; + NodeBuilderFlags[NodeBuilderFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; + NodeBuilderFlags[NodeBuilderFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType"; + NodeBuilderFlags[NodeBuilderFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction"; + // Error handling + NodeBuilderFlags[NodeBuilderFlags["AllowThisInObjectLiteral"] = 32768] = "AllowThisInObjectLiteral"; + NodeBuilderFlags[NodeBuilderFlags["AllowQualifiedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifiedNameInPlaceOfIdentifier"; + /** @deprecated AllowQualifedNameInPlaceOfIdentifier. Use AllowQualifiedNameInPlaceOfIdentifier instead. */ + NodeBuilderFlags[NodeBuilderFlags["AllowQualifedNameInPlaceOfIdentifier"] = 65536] = "AllowQualifedNameInPlaceOfIdentifier"; + NodeBuilderFlags[NodeBuilderFlags["AllowAnonymousIdentifier"] = 131072] = "AllowAnonymousIdentifier"; + NodeBuilderFlags[NodeBuilderFlags["AllowEmptyUnionOrIntersection"] = 262144] = "AllowEmptyUnionOrIntersection"; + NodeBuilderFlags[NodeBuilderFlags["AllowEmptyTuple"] = 524288] = "AllowEmptyTuple"; + NodeBuilderFlags[NodeBuilderFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; + NodeBuilderFlags[NodeBuilderFlags["AllowEmptyIndexInfoType"] = 2097152] = "AllowEmptyIndexInfoType"; + // Errors (cont.) + NodeBuilderFlags[NodeBuilderFlags["AllowNodeModulesRelativePaths"] = 67108864] = "AllowNodeModulesRelativePaths"; + /* @internal */ NodeBuilderFlags[NodeBuilderFlags["DoNotIncludeSymbolChain"] = 134217728] = "DoNotIncludeSymbolChain"; + NodeBuilderFlags[NodeBuilderFlags["IgnoreErrors"] = 70221824] = "IgnoreErrors"; + // State + NodeBuilderFlags[NodeBuilderFlags["InObjectTypeLiteral"] = 4194304] = "InObjectTypeLiteral"; + NodeBuilderFlags[NodeBuilderFlags["InTypeAlias"] = 8388608] = "InTypeAlias"; + NodeBuilderFlags[NodeBuilderFlags["InInitialEntityName"] = 16777216] = "InInitialEntityName"; + })(NodeBuilderFlags = ts.NodeBuilderFlags || (ts.NodeBuilderFlags = {})); + // Ensure the shared flags between this and `NodeBuilderFlags` stay in alignment + var TypeFormatFlags; + (function (TypeFormatFlags) { + TypeFormatFlags[TypeFormatFlags["None"] = 0] = "None"; + TypeFormatFlags[TypeFormatFlags["NoTruncation"] = 1] = "NoTruncation"; + TypeFormatFlags[TypeFormatFlags["WriteArrayAsGenericType"] = 2] = "WriteArrayAsGenericType"; + // hole because there's a hole in node builder flags + TypeFormatFlags[TypeFormatFlags["UseStructuralFallback"] = 8] = "UseStructuralFallback"; + // hole because there's a hole in node builder flags + TypeFormatFlags[TypeFormatFlags["WriteTypeArgumentsOfSignature"] = 32] = "WriteTypeArgumentsOfSignature"; + TypeFormatFlags[TypeFormatFlags["UseFullyQualifiedType"] = 64] = "UseFullyQualifiedType"; + // hole because `UseOnlyExternalAliasing` is here in node builder flags, but functions which take old flags use `SymbolFormatFlags` instead + TypeFormatFlags[TypeFormatFlags["SuppressAnyReturnType"] = 256] = "SuppressAnyReturnType"; + // hole because `WriteTypeParametersInQualifiedName` is here in node builder flags, but functions which take old flags use `SymbolFormatFlags` for this instead + TypeFormatFlags[TypeFormatFlags["MultilineObjectLiterals"] = 1024] = "MultilineObjectLiterals"; + TypeFormatFlags[TypeFormatFlags["WriteClassExpressionAsTypeLiteral"] = 2048] = "WriteClassExpressionAsTypeLiteral"; + TypeFormatFlags[TypeFormatFlags["UseTypeOfFunction"] = 4096] = "UseTypeOfFunction"; + TypeFormatFlags[TypeFormatFlags["OmitParameterModifiers"] = 8192] = "OmitParameterModifiers"; + TypeFormatFlags[TypeFormatFlags["UseAliasDefinedOutsideCurrentScope"] = 16384] = "UseAliasDefinedOutsideCurrentScope"; + TypeFormatFlags[TypeFormatFlags["UseSingleQuotesForStringLiteralType"] = 268435456] = "UseSingleQuotesForStringLiteralType"; + TypeFormatFlags[TypeFormatFlags["NoTypeReduction"] = 536870912] = "NoTypeReduction"; + // Error Handling + TypeFormatFlags[TypeFormatFlags["AllowUniqueESSymbolType"] = 1048576] = "AllowUniqueESSymbolType"; + // TypeFormatFlags exclusive + TypeFormatFlags[TypeFormatFlags["AddUndefined"] = 131072] = "AddUndefined"; + TypeFormatFlags[TypeFormatFlags["WriteArrowStyleSignature"] = 262144] = "WriteArrowStyleSignature"; + // State + TypeFormatFlags[TypeFormatFlags["InArrayType"] = 524288] = "InArrayType"; + TypeFormatFlags[TypeFormatFlags["InElementType"] = 2097152] = "InElementType"; + TypeFormatFlags[TypeFormatFlags["InFirstTypeArgument"] = 4194304] = "InFirstTypeArgument"; + TypeFormatFlags[TypeFormatFlags["InTypeAlias"] = 8388608] = "InTypeAlias"; + /** @deprecated */ TypeFormatFlags[TypeFormatFlags["WriteOwnNameForAnyLike"] = 0] = "WriteOwnNameForAnyLike"; + TypeFormatFlags[TypeFormatFlags["NodeBuilderFlagsMask"] = 814775659] = "NodeBuilderFlagsMask"; + })(TypeFormatFlags = ts.TypeFormatFlags || (ts.TypeFormatFlags = {})); + var SymbolFormatFlags; + (function (SymbolFormatFlags) { + SymbolFormatFlags[SymbolFormatFlags["None"] = 0] = "None"; + // Write symbols's type argument if it is instantiated symbol + // eg. class C
]: X }, to simply N` where `Q` is mapped by `mapper` into `number` - `B` is constrained to `T`
+ // which is in turn instantiated as `Q`, which is in turn instantiated as `number`.
+ // So we need to:
+ // * Clone the type parameters so their constraints can be instantiated in the context of `mapper` (otherwise theyd only get inference context information)
+ // * Set the clones to both map the conditional's enclosing `mapper` and the original params
+ // * instantiate the extends type with the clones
+ // * incorporate all of the component mappers into the combined mapper for the true and false members
+ // This means we have three mappers that need applying:
+ // * The original `mapper` used to create this conditional
+ // * The mapper that maps the old root type parameter to the clone (`freshMapper`)
+ // * The mapper that maps the clone to its inference result (`context.mapper`)
+ var freshParams = ts.sameMap(root.inferTypeParameters, maybeCloneTypeParameter);
+ var freshMapper = freshParams !== root.inferTypeParameters ? createTypeMapper(root.inferTypeParameters, freshParams) : undefined;
+ var context = createInferenceContext(freshParams, /*signature*/ undefined, 0 /* InferenceFlags.None */);
+ if (freshMapper) {
+ var freshCombinedMapper = combineTypeMappers(mapper, freshMapper);
+ for (var _i = 0, freshParams_1 = freshParams; _i < freshParams_1.length; _i++) {
+ var p = freshParams_1[_i];
+ if (root.inferTypeParameters.indexOf(p) === -1) {
+ p.mapper = freshCombinedMapper;
+ }
+ }
+ }
+ // We skip inference of the possible `infer` types unles the `extendsType` _is_ an infer type
+ // if it was, it's trivial to say that extendsType = checkType, however such a pattern is used to
+ // "reset" the type being build up during constraint calculation and avoid making an apparently "infinite" constraint
+ // so in those cases we refain from performing inference and retain the uninfered type parameter
+ if (!checkTypeInstantiable || !ts.some(root.inferTypeParameters, function (t) { return t === extendsType; })) {
+ // We don't want inferences from constraints as they may cause us to eagerly resolve the
+ // conditional type instead of deferring resolution. Also, we always want strict function
+ // types rules (i.e. proper contravariance) for inferences.
+ inferTypes(context.inferences, checkType, instantiateType(extendsType, freshMapper), 512 /* InferencePriority.NoConstraints */ | 1024 /* InferencePriority.AlwaysStrict */);
+ }
+ var innerMapper = combineTypeMappers(freshMapper, context.mapper);
+ // It's possible for 'infer T' type paramteters to be given uninstantiated constraints when the
+ // those type parameters are used in type references (see getInferredTypeParameterConstraint). For
+ // that reason we need context.mapper to be first in the combined mapper. See #42636 for examples.
+ combinedMapper = mapper ? combineTypeMappers(innerMapper, mapper) : innerMapper;
+ }
+ // Instantiate the extends type including inferences for 'infer T' type parameters
+ var inferredExtendsType = combinedMapper ? instantiateType(unwrapNondistributiveConditionalTuple(root, root.extendsType), combinedMapper) : extendsType;
+ // We attempt to resolve the conditional type only when the check and extends types are non-generic
+ if (!checkTypeInstantiable && !isGenericType(inferredExtendsType)) {
+ // Return falseType for a definitely false extends check. We check an instantiations of the two
+ // types with type parameters mapped to the wildcard type, the most permissive instantiations
+ // possible (the wildcard type is assignable to and from all types). If those are not related,
+ // then no instantiations will be and we can just return the false branch type.
+ if (!(inferredExtendsType.flags & 3 /* TypeFlags.AnyOrUnknown */) && ((checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) || !isTypeAssignableTo(getPermissiveInstantiation(checkType), getPermissiveInstantiation(inferredExtendsType)))) {
+ // Return union of trueType and falseType for 'any' since it matches anything
+ if (checkType.flags & 1 /* TypeFlags.Any */ && !isUnwrapped) {
+ (extraTypes || (extraTypes = [])).push(instantiateType(getTypeFromTypeNode(root.node.trueType), combinedMapper || mapper));
+ }
+ // If falseType is an immediately nested conditional type that isn't distributive or has an
+ // identical checkType, switch to that type and loop.
+ var falseType_1 = getTypeFromTypeNode(root.node.falseType);
+ if (falseType_1.flags & 16777216 /* TypeFlags.Conditional */) {
+ var newRoot = falseType_1.root;
+ if (newRoot.node.parent === root.node && (!newRoot.isDistributive || newRoot.checkType === root.checkType)) {
+ root = newRoot;
+ return "continue";
+ }
+ if (canTailRecurse(falseType_1, mapper)) {
+ return "continue";
+ }
+ }
+ result = instantiateType(falseType_1, mapper);
+ return "break";
+ }
+ // Return trueType for a definitely true extends check. We check instantiations of the two
+ // types with type parameters mapped to their restrictive form, i.e. a form of the type parameter
+ // that has no constraint. This ensures that, for example, the type
+ // type Foo