typescript 4.6.0-dev.20220201 → 4.6.0-dev.20220205

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220201";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220205";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -1468,11 +1468,11 @@ var ts;
1468
1468
  return result;
1469
1469
  }
1470
1470
  ts.getAllKeys = getAllKeys;
1471
- function getOwnValues(sparseArray) {
1471
+ function getOwnValues(collection) {
1472
1472
  var values = [];
1473
- for (var key in sparseArray) {
1474
- if (hasOwnProperty.call(sparseArray, key)) {
1475
- values.push(sparseArray[key]);
1473
+ for (var key in collection) {
1474
+ if (hasOwnProperty.call(collection, key)) {
1475
+ values.push(collection[key]);
1476
1476
  }
1477
1477
  }
1478
1478
  return values;
@@ -5918,704 +5918,6 @@ var ts;
5918
5918
  },
5919
5919
  };
5920
5920
  })(ts || (ts = {}));
5921
- /* @internal */
5922
- var ts;
5923
- (function (ts) {
5924
- /**
5925
- * Internally, we represent paths as strings with '/' as the directory separator.
5926
- * When we make system calls (eg: LanguageServiceHost.getDirectory()),
5927
- * we expect the host to correctly handle paths in our specified format.
5928
- */
5929
- ts.directorySeparator = "/";
5930
- ts.altDirectorySeparator = "\\";
5931
- var urlSchemeSeparator = "://";
5932
- var backslashRegExp = /\\/g;
5933
- //// Path Tests
5934
- /**
5935
- * Determines whether a charCode corresponds to `/` or `\`.
5936
- */
5937
- function isAnyDirectorySeparator(charCode) {
5938
- return charCode === 47 /* slash */ || charCode === 92 /* backslash */;
5939
- }
5940
- ts.isAnyDirectorySeparator = isAnyDirectorySeparator;
5941
- /**
5942
- * Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.).
5943
- */
5944
- function isUrl(path) {
5945
- return getEncodedRootLength(path) < 0;
5946
- }
5947
- ts.isUrl = isUrl;
5948
- /**
5949
- * Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path
5950
- * like `c:`, `c:\` or `c:/`).
5951
- */
5952
- function isRootedDiskPath(path) {
5953
- return getEncodedRootLength(path) > 0;
5954
- }
5955
- ts.isRootedDiskPath = isRootedDiskPath;
5956
- /**
5957
- * Determines whether a path consists only of a path root.
5958
- */
5959
- function isDiskPathRoot(path) {
5960
- var rootLength = getEncodedRootLength(path);
5961
- return rootLength > 0 && rootLength === path.length;
5962
- }
5963
- ts.isDiskPathRoot = isDiskPathRoot;
5964
- /**
5965
- * Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.).
5966
- *
5967
- * ```ts
5968
- * // POSIX
5969
- * pathIsAbsolute("/path/to/file.ext") === true
5970
- * // DOS
5971
- * pathIsAbsolute("c:/path/to/file.ext") === true
5972
- * // URL
5973
- * pathIsAbsolute("file:///path/to/file.ext") === true
5974
- * // Non-absolute
5975
- * pathIsAbsolute("path/to/file.ext") === false
5976
- * pathIsAbsolute("./path/to/file.ext") === false
5977
- * ```
5978
- */
5979
- function pathIsAbsolute(path) {
5980
- return getEncodedRootLength(path) !== 0;
5981
- }
5982
- ts.pathIsAbsolute = pathIsAbsolute;
5983
- /**
5984
- * Determines whether a path starts with a relative path component (i.e. `.` or `..`).
5985
- */
5986
- function pathIsRelative(path) {
5987
- return /^\.\.?($|[\\/])/.test(path);
5988
- }
5989
- ts.pathIsRelative = pathIsRelative;
5990
- /**
5991
- * Determines whether a path is neither relative nor absolute, e.g. "path/to/file".
5992
- * Also known misleadingly as "non-relative".
5993
- */
5994
- function pathIsBareSpecifier(path) {
5995
- return !pathIsAbsolute(path) && !pathIsRelative(path);
5996
- }
5997
- ts.pathIsBareSpecifier = pathIsBareSpecifier;
5998
- function hasExtension(fileName) {
5999
- return ts.stringContains(getBaseFileName(fileName), ".");
6000
- }
6001
- ts.hasExtension = hasExtension;
6002
- function fileExtensionIs(path, extension) {
6003
- return path.length > extension.length && ts.endsWith(path, extension);
6004
- }
6005
- ts.fileExtensionIs = fileExtensionIs;
6006
- function fileExtensionIsOneOf(path, extensions) {
6007
- for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
6008
- var extension = extensions_1[_i];
6009
- if (fileExtensionIs(path, extension)) {
6010
- return true;
6011
- }
6012
- }
6013
- return false;
6014
- }
6015
- ts.fileExtensionIsOneOf = fileExtensionIsOneOf;
6016
- /**
6017
- * Determines whether a path has a trailing separator (`/` or `\\`).
6018
- */
6019
- function hasTrailingDirectorySeparator(path) {
6020
- return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1));
6021
- }
6022
- ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator;
6023
- //// Path Parsing
6024
- function isVolumeCharacter(charCode) {
6025
- return (charCode >= 97 /* a */ && charCode <= 122 /* z */) ||
6026
- (charCode >= 65 /* A */ && charCode <= 90 /* Z */);
6027
- }
6028
- function getFileUrlVolumeSeparatorEnd(url, start) {
6029
- var ch0 = url.charCodeAt(start);
6030
- if (ch0 === 58 /* colon */)
6031
- return start + 1;
6032
- if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) {
6033
- var ch2 = url.charCodeAt(start + 2);
6034
- if (ch2 === 97 /* a */ || ch2 === 65 /* A */)
6035
- return start + 3;
6036
- }
6037
- return -1;
6038
- }
6039
- /**
6040
- * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
6041
- * If the root is part of a URL, the twos-complement of the root length is returned.
6042
- */
6043
- function getEncodedRootLength(path) {
6044
- if (!path)
6045
- return 0;
6046
- var ch0 = path.charCodeAt(0);
6047
- // POSIX or UNC
6048
- if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) {
6049
- if (path.charCodeAt(1) !== ch0)
6050
- return 1; // POSIX: "/" (or non-normalized "\")
6051
- var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2);
6052
- if (p1 < 0)
6053
- return path.length; // UNC: "//server" or "\\server"
6054
- return p1 + 1; // UNC: "//server/" or "\\server\"
6055
- }
6056
- // DOS
6057
- if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) {
6058
- var ch2 = path.charCodeAt(2);
6059
- if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */)
6060
- return 3; // DOS: "c:/" or "c:\"
6061
- if (path.length === 2)
6062
- return 2; // DOS: "c:" (but not "c:d")
6063
- }
6064
- // URL
6065
- var schemeEnd = path.indexOf(urlSchemeSeparator);
6066
- if (schemeEnd !== -1) {
6067
- var authorityStart = schemeEnd + urlSchemeSeparator.length;
6068
- var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart);
6069
- if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path"
6070
- // For local "file" URLs, include the leading DOS volume (if present).
6071
- // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a
6072
- // special case interpreted as "the machine from which the URL is being interpreted".
6073
- var scheme = path.slice(0, schemeEnd);
6074
- var authority = path.slice(authorityStart, authorityEnd);
6075
- if (scheme === "file" && (authority === "" || authority === "localhost") &&
6076
- isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
6077
- var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
6078
- if (volumeSeparatorEnd !== -1) {
6079
- if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) {
6080
- // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/"
6081
- return ~(volumeSeparatorEnd + 1);
6082
- }
6083
- if (volumeSeparatorEnd === path.length) {
6084
- // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a"
6085
- // but not "file:///c:d" or "file:///c%3ad"
6086
- return ~volumeSeparatorEnd;
6087
- }
6088
- }
6089
- }
6090
- return ~(authorityEnd + 1); // URL: "file://server/", "http://server/"
6091
- }
6092
- return ~path.length; // URL: "file://server", "http://server"
6093
- }
6094
- // relative
6095
- return 0;
6096
- }
6097
- /**
6098
- * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
6099
- *
6100
- * For example:
6101
- * ```ts
6102
- * getRootLength("a") === 0 // ""
6103
- * getRootLength("/") === 1 // "/"
6104
- * getRootLength("c:") === 2 // "c:"
6105
- * getRootLength("c:d") === 0 // ""
6106
- * getRootLength("c:/") === 3 // "c:/"
6107
- * getRootLength("c:\\") === 3 // "c:\\"
6108
- * getRootLength("//server") === 7 // "//server"
6109
- * getRootLength("//server/share") === 8 // "//server/"
6110
- * getRootLength("\\\\server") === 7 // "\\\\server"
6111
- * getRootLength("\\\\server\\share") === 8 // "\\\\server\\"
6112
- * getRootLength("file:///path") === 8 // "file:///"
6113
- * getRootLength("file:///c:") === 10 // "file:///c:"
6114
- * getRootLength("file:///c:d") === 8 // "file:///"
6115
- * getRootLength("file:///c:/path") === 11 // "file:///c:/"
6116
- * getRootLength("file://server") === 13 // "file://server"
6117
- * getRootLength("file://server/path") === 14 // "file://server/"
6118
- * getRootLength("http://server") === 13 // "http://server"
6119
- * getRootLength("http://server/path") === 14 // "http://server/"
6120
- * ```
6121
- */
6122
- function getRootLength(path) {
6123
- var rootLength = getEncodedRootLength(path);
6124
- return rootLength < 0 ? ~rootLength : rootLength;
6125
- }
6126
- ts.getRootLength = getRootLength;
6127
- function getDirectoryPath(path) {
6128
- path = normalizeSlashes(path);
6129
- // If the path provided is itself the root, then return it.
6130
- var rootLength = getRootLength(path);
6131
- if (rootLength === path.length)
6132
- return path;
6133
- // return the leading portion of the path up to the last (non-terminal) directory separator
6134
- // but not including any trailing directory separator.
6135
- path = removeTrailingDirectorySeparator(path);
6136
- return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator)));
6137
- }
6138
- ts.getDirectoryPath = getDirectoryPath;
6139
- function getBaseFileName(path, extensions, ignoreCase) {
6140
- path = normalizeSlashes(path);
6141
- // if the path provided is itself the root, then it has not file name.
6142
- var rootLength = getRootLength(path);
6143
- if (rootLength === path.length)
6144
- return "";
6145
- // return the trailing portion of the path starting after the last (non-terminal) directory
6146
- // separator but not including any trailing directory separator.
6147
- path = removeTrailingDirectorySeparator(path);
6148
- var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1));
6149
- var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined;
6150
- return extension ? name.slice(0, name.length - extension.length) : name;
6151
- }
6152
- ts.getBaseFileName = getBaseFileName;
6153
- function tryGetExtensionFromPath(path, extension, stringEqualityComparer) {
6154
- if (!ts.startsWith(extension, "."))
6155
- extension = "." + extension;
6156
- if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) {
6157
- var pathExtension = path.slice(path.length - extension.length);
6158
- if (stringEqualityComparer(pathExtension, extension)) {
6159
- return pathExtension;
6160
- }
6161
- }
6162
- }
6163
- function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) {
6164
- if (typeof extensions === "string") {
6165
- return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || "";
6166
- }
6167
- for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) {
6168
- var extension = extensions_2[_i];
6169
- var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer);
6170
- if (result)
6171
- return result;
6172
- }
6173
- return "";
6174
- }
6175
- function getAnyExtensionFromPath(path, extensions, ignoreCase) {
6176
- // Retrieves any string from the final "." onwards from a base file name.
6177
- // Unlike extensionFromPath, which throws an exception on unrecognized extensions.
6178
- if (extensions) {
6179
- return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive);
6180
- }
6181
- var baseFileName = getBaseFileName(path);
6182
- var extensionIndex = baseFileName.lastIndexOf(".");
6183
- if (extensionIndex >= 0) {
6184
- return baseFileName.substring(extensionIndex);
6185
- }
6186
- return "";
6187
- }
6188
- ts.getAnyExtensionFromPath = getAnyExtensionFromPath;
6189
- function pathComponents(path, rootLength) {
6190
- var root = path.substring(0, rootLength);
6191
- var rest = path.substring(rootLength).split(ts.directorySeparator);
6192
- if (rest.length && !ts.lastOrUndefined(rest))
6193
- rest.pop();
6194
- return __spreadArray([root], rest, true);
6195
- }
6196
- /**
6197
- * Parse a path into an array containing a root component (at index 0) and zero or more path
6198
- * components (at indices > 0). The result is not normalized.
6199
- * If the path is relative, the root component is `""`.
6200
- * If the path is absolute, the root component includes the first path separator (`/`).
6201
- *
6202
- * ```ts
6203
- * // POSIX
6204
- * getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"]
6205
- * getPathComponents("/path/to/") === ["/", "path", "to"]
6206
- * getPathComponents("/") === ["/"]
6207
- * // DOS
6208
- * getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"]
6209
- * getPathComponents("c:/path/to/") === ["c:/", "path", "to"]
6210
- * getPathComponents("c:/") === ["c:/"]
6211
- * getPathComponents("c:") === ["c:"]
6212
- * // URL
6213
- * getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"]
6214
- * getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"]
6215
- * getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"]
6216
- * getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"]
6217
- * getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"]
6218
- * getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"]
6219
- * getPathComponents("file://server/") === ["file://server/"]
6220
- * getPathComponents("file://server") === ["file://server"]
6221
- * getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"]
6222
- * getPathComponents("file:///path/to/") === ["file:///", "path", "to"]
6223
- * getPathComponents("file:///") === ["file:///"]
6224
- * getPathComponents("file://") === ["file://"]
6225
- */
6226
- function getPathComponents(path, currentDirectory) {
6227
- if (currentDirectory === void 0) { currentDirectory = ""; }
6228
- path = combinePaths(currentDirectory, path);
6229
- return pathComponents(path, getRootLength(path));
6230
- }
6231
- ts.getPathComponents = getPathComponents;
6232
- //// Path Formatting
6233
- /**
6234
- * Formats a parsed path consisting of a root component (at index 0) and zero or more path
6235
- * segments (at indices > 0).
6236
- *
6237
- * ```ts
6238
- * getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext"
6239
- * ```
6240
- */
6241
- function getPathFromPathComponents(pathComponents) {
6242
- if (pathComponents.length === 0)
6243
- return "";
6244
- var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
6245
- return root + pathComponents.slice(1).join(ts.directorySeparator);
6246
- }
6247
- ts.getPathFromPathComponents = getPathFromPathComponents;
6248
- //// Path Normalization
6249
- /**
6250
- * Normalize path separators, converting `\` into `/`.
6251
- */
6252
- function normalizeSlashes(path) {
6253
- var index = path.indexOf("\\");
6254
- if (index === -1) {
6255
- return path;
6256
- }
6257
- backslashRegExp.lastIndex = index; // prime regex with known position
6258
- return path.replace(backslashRegExp, ts.directorySeparator);
6259
- }
6260
- ts.normalizeSlashes = normalizeSlashes;
6261
- /**
6262
- * Reduce an array of path components to a more simplified path by navigating any
6263
- * `"."` or `".."` entries in the path.
6264
- */
6265
- function reducePathComponents(components) {
6266
- if (!ts.some(components))
6267
- return [];
6268
- var reduced = [components[0]];
6269
- for (var i = 1; i < components.length; i++) {
6270
- var component = components[i];
6271
- if (!component)
6272
- continue;
6273
- if (component === ".")
6274
- continue;
6275
- if (component === "..") {
6276
- if (reduced.length > 1) {
6277
- if (reduced[reduced.length - 1] !== "..") {
6278
- reduced.pop();
6279
- continue;
6280
- }
6281
- }
6282
- else if (reduced[0])
6283
- continue;
6284
- }
6285
- reduced.push(component);
6286
- }
6287
- return reduced;
6288
- }
6289
- ts.reducePathComponents = reducePathComponents;
6290
- /**
6291
- * Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified.
6292
- *
6293
- * ```ts
6294
- * // Non-rooted
6295
- * combinePaths("path", "to", "file.ext") === "path/to/file.ext"
6296
- * combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext"
6297
- * // POSIX
6298
- * combinePaths("/path", "to", "file.ext") === "/path/to/file.ext"
6299
- * combinePaths("/path", "/to", "file.ext") === "/to/file.ext"
6300
- * // DOS
6301
- * combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext"
6302
- * combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext"
6303
- * // URL
6304
- * combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext"
6305
- * combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext"
6306
- * ```
6307
- */
6308
- function combinePaths(path) {
6309
- var paths = [];
6310
- for (var _i = 1; _i < arguments.length; _i++) {
6311
- paths[_i - 1] = arguments[_i];
6312
- }
6313
- if (path)
6314
- path = normalizeSlashes(path);
6315
- for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
6316
- var relativePath = paths_1[_a];
6317
- if (!relativePath)
6318
- continue;
6319
- relativePath = normalizeSlashes(relativePath);
6320
- if (!path || getRootLength(relativePath) !== 0) {
6321
- path = relativePath;
6322
- }
6323
- else {
6324
- path = ensureTrailingDirectorySeparator(path) + relativePath;
6325
- }
6326
- }
6327
- return path;
6328
- }
6329
- ts.combinePaths = combinePaths;
6330
- /**
6331
- * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any
6332
- * `.` and `..` path components are resolved. Trailing directory separators are preserved.
6333
- *
6334
- * ```ts
6335
- * resolvePath("/path", "to", "file.ext") === "path/to/file.ext"
6336
- * resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/"
6337
- * resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext"
6338
- * ```
6339
- */
6340
- function resolvePath(path) {
6341
- var paths = [];
6342
- for (var _i = 1; _i < arguments.length; _i++) {
6343
- paths[_i - 1] = arguments[_i];
6344
- }
6345
- return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArray([path], paths, false)) : normalizeSlashes(path));
6346
- }
6347
- ts.resolvePath = resolvePath;
6348
- /**
6349
- * Parse a path into an array containing a root component (at index 0) and zero or more path
6350
- * components (at indices > 0). The result is normalized.
6351
- * If the path is relative, the root component is `""`.
6352
- * If the path is absolute, the root component includes the first path separator (`/`).
6353
- *
6354
- * ```ts
6355
- * getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"]
6356
- * ```
6357
- */
6358
- function getNormalizedPathComponents(path, currentDirectory) {
6359
- return reducePathComponents(getPathComponents(path, currentDirectory));
6360
- }
6361
- ts.getNormalizedPathComponents = getNormalizedPathComponents;
6362
- function getNormalizedAbsolutePath(fileName, currentDirectory) {
6363
- return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
6364
- }
6365
- ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
6366
- function normalizePath(path) {
6367
- path = normalizeSlashes(path);
6368
- // Most paths don't require normalization
6369
- if (!relativePathSegmentRegExp.test(path)) {
6370
- return path;
6371
- }
6372
- // Some paths only require cleanup of `/./` or leading `./`
6373
- var simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, "");
6374
- if (simplified !== path) {
6375
- path = simplified;
6376
- if (!relativePathSegmentRegExp.test(path)) {
6377
- return path;
6378
- }
6379
- }
6380
- // Other paths require full normalization
6381
- var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
6382
- return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
6383
- }
6384
- ts.normalizePath = normalizePath;
6385
- function getPathWithoutRoot(pathComponents) {
6386
- if (pathComponents.length === 0)
6387
- return "";
6388
- return pathComponents.slice(1).join(ts.directorySeparator);
6389
- }
6390
- function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
6391
- return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
6392
- }
6393
- ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
6394
- function toPath(fileName, basePath, getCanonicalFileName) {
6395
- var nonCanonicalizedPath = isRootedDiskPath(fileName)
6396
- ? normalizePath(fileName)
6397
- : getNormalizedAbsolutePath(fileName, basePath);
6398
- return getCanonicalFileName(nonCanonicalizedPath);
6399
- }
6400
- ts.toPath = toPath;
6401
- function normalizePathAndParts(path) {
6402
- path = normalizeSlashes(path);
6403
- var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
6404
- if (parts.length) {
6405
- var joinedParts = root + parts.join(ts.directorySeparator);
6406
- return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
6407
- }
6408
- else {
6409
- return { path: root, parts: parts };
6410
- }
6411
- }
6412
- ts.normalizePathAndParts = normalizePathAndParts;
6413
- function removeTrailingDirectorySeparator(path) {
6414
- if (hasTrailingDirectorySeparator(path)) {
6415
- return path.substr(0, path.length - 1);
6416
- }
6417
- return path;
6418
- }
6419
- ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
6420
- function ensureTrailingDirectorySeparator(path) {
6421
- if (!hasTrailingDirectorySeparator(path)) {
6422
- return path + ts.directorySeparator;
6423
- }
6424
- return path;
6425
- }
6426
- ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator;
6427
- /**
6428
- * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed
6429
- * with `./` or `../`) so as not to be confused with an unprefixed module name.
6430
- *
6431
- * ```ts
6432
- * ensurePathIsNonModuleName("/path/to/file.ext") === "/path/to/file.ext"
6433
- * ensurePathIsNonModuleName("./path/to/file.ext") === "./path/to/file.ext"
6434
- * ensurePathIsNonModuleName("../path/to/file.ext") === "../path/to/file.ext"
6435
- * ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext"
6436
- * ```
6437
- */
6438
- function ensurePathIsNonModuleName(path) {
6439
- return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path;
6440
- }
6441
- ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName;
6442
- function changeAnyExtension(path, ext, extensions, ignoreCase) {
6443
- var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path);
6444
- return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
6445
- }
6446
- ts.changeAnyExtension = changeAnyExtension;
6447
- //// Path Comparisons
6448
- // check path for these segments: '', '.'. '..'
6449
- var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/;
6450
- function comparePathsWorker(a, b, componentComparer) {
6451
- if (a === b)
6452
- return 0 /* EqualTo */;
6453
- if (a === undefined)
6454
- return -1 /* LessThan */;
6455
- if (b === undefined)
6456
- return 1 /* GreaterThan */;
6457
- // NOTE: Performance optimization - shortcut if the root segments differ as there would be no
6458
- // need to perform path reduction.
6459
- var aRoot = a.substring(0, getRootLength(a));
6460
- var bRoot = b.substring(0, getRootLength(b));
6461
- var result = ts.compareStringsCaseInsensitive(aRoot, bRoot);
6462
- if (result !== 0 /* EqualTo */) {
6463
- return result;
6464
- }
6465
- // NOTE: Performance optimization - shortcut if there are no relative path segments in
6466
- // the non-root portion of the path
6467
- var aRest = a.substring(aRoot.length);
6468
- var bRest = b.substring(bRoot.length);
6469
- if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) {
6470
- return componentComparer(aRest, bRest);
6471
- }
6472
- // The path contains a relative path segment. Normalize the paths and perform a slower component
6473
- // by component comparison.
6474
- var aComponents = reducePathComponents(getPathComponents(a));
6475
- var bComponents = reducePathComponents(getPathComponents(b));
6476
- var sharedLength = Math.min(aComponents.length, bComponents.length);
6477
- for (var i = 1; i < sharedLength; i++) {
6478
- var result_2 = componentComparer(aComponents[i], bComponents[i]);
6479
- if (result_2 !== 0 /* EqualTo */) {
6480
- return result_2;
6481
- }
6482
- }
6483
- return ts.compareValues(aComponents.length, bComponents.length);
6484
- }
6485
- /**
6486
- * Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively.
6487
- */
6488
- function comparePathsCaseSensitive(a, b) {
6489
- return comparePathsWorker(a, b, ts.compareStringsCaseSensitive);
6490
- }
6491
- ts.comparePathsCaseSensitive = comparePathsCaseSensitive;
6492
- /**
6493
- * Performs a case-insensitive comparison of two paths.
6494
- */
6495
- function comparePathsCaseInsensitive(a, b) {
6496
- return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive);
6497
- }
6498
- ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive;
6499
- function comparePaths(a, b, currentDirectory, ignoreCase) {
6500
- if (typeof currentDirectory === "string") {
6501
- a = combinePaths(currentDirectory, a);
6502
- b = combinePaths(currentDirectory, b);
6503
- }
6504
- else if (typeof currentDirectory === "boolean") {
6505
- ignoreCase = currentDirectory;
6506
- }
6507
- return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase));
6508
- }
6509
- ts.comparePaths = comparePaths;
6510
- function containsPath(parent, child, currentDirectory, ignoreCase) {
6511
- if (typeof currentDirectory === "string") {
6512
- parent = combinePaths(currentDirectory, parent);
6513
- child = combinePaths(currentDirectory, child);
6514
- }
6515
- else if (typeof currentDirectory === "boolean") {
6516
- ignoreCase = currentDirectory;
6517
- }
6518
- if (parent === undefined || child === undefined)
6519
- return false;
6520
- if (parent === child)
6521
- return true;
6522
- var parentComponents = reducePathComponents(getPathComponents(parent));
6523
- var childComponents = reducePathComponents(getPathComponents(child));
6524
- if (childComponents.length < parentComponents.length) {
6525
- return false;
6526
- }
6527
- var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive;
6528
- for (var i = 0; i < parentComponents.length; i++) {
6529
- var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer;
6530
- if (!equalityComparer(parentComponents[i], childComponents[i])) {
6531
- return false;
6532
- }
6533
- }
6534
- return true;
6535
- }
6536
- ts.containsPath = containsPath;
6537
- /**
6538
- * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback.
6539
- * Comparison is case-sensitive between the canonical paths.
6540
- *
6541
- * Use `containsPath` if file names are not already reduced and absolute.
6542
- */
6543
- function startsWithDirectory(fileName, directoryName, getCanonicalFileName) {
6544
- var canonicalFileName = getCanonicalFileName(fileName);
6545
- var canonicalDirectoryName = getCanonicalFileName(directoryName);
6546
- return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\");
6547
- }
6548
- ts.startsWithDirectory = startsWithDirectory;
6549
- //// Relative Paths
6550
- function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) {
6551
- var fromComponents = reducePathComponents(getPathComponents(from));
6552
- var toComponents = reducePathComponents(getPathComponents(to));
6553
- var start;
6554
- for (start = 0; start < fromComponents.length && start < toComponents.length; start++) {
6555
- var fromComponent = getCanonicalFileName(fromComponents[start]);
6556
- var toComponent = getCanonicalFileName(toComponents[start]);
6557
- var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer;
6558
- if (!comparer(fromComponent, toComponent))
6559
- break;
6560
- }
6561
- if (start === 0) {
6562
- return toComponents;
6563
- }
6564
- var components = toComponents.slice(start);
6565
- var relative = [];
6566
- for (; start < fromComponents.length; start++) {
6567
- relative.push("..");
6568
- }
6569
- return __spreadArray(__spreadArray([""], relative, true), components, true);
6570
- }
6571
- ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo;
6572
- function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
6573
- ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
6574
- var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
6575
- var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
6576
- var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
6577
- return getPathFromPathComponents(pathComponents);
6578
- }
6579
- ts.getRelativePathFromDirectory = getRelativePathFromDirectory;
6580
- function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
6581
- return !isRootedDiskPath(absoluteOrRelativePath)
6582
- ? absoluteOrRelativePath
6583
- : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
6584
- }
6585
- ts.convertToRelativePath = convertToRelativePath;
6586
- function getRelativePathFromFile(from, to, getCanonicalFileName) {
6587
- return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName));
6588
- }
6589
- ts.getRelativePathFromFile = getRelativePathFromFile;
6590
- function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
6591
- var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName);
6592
- var firstComponent = pathComponents[0];
6593
- if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) {
6594
- var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///";
6595
- pathComponents[0] = prefix + firstComponent;
6596
- }
6597
- return getPathFromPathComponents(pathComponents);
6598
- }
6599
- ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl;
6600
- function forEachAncestorDirectory(directory, callback) {
6601
- while (true) {
6602
- var result = callback(directory);
6603
- if (result !== undefined) {
6604
- return result;
6605
- }
6606
- var parentPath = getDirectoryPath(directory);
6607
- if (parentPath === directory) {
6608
- return undefined;
6609
- }
6610
- directory = parentPath;
6611
- }
6612
- }
6613
- ts.forEachAncestorDirectory = forEachAncestorDirectory;
6614
- function isNodeModulesDirectory(dirPath) {
6615
- return ts.endsWith(dirPath, "/node_modules");
6616
- }
6617
- ts.isNodeModulesDirectory = isNodeModulesDirectory;
6618
- })(ts || (ts = {}));
6619
5921
  var ts;
6620
5922
  (function (ts) {
6621
5923
  /**
@@ -8048,6 +7350,704 @@ var ts;
8048
7350
  ts.Debug.isDebugging = true;
8049
7351
  }
8050
7352
  })(ts || (ts = {}));
7353
+ /* @internal */
7354
+ var ts;
7355
+ (function (ts) {
7356
+ /**
7357
+ * Internally, we represent paths as strings with '/' as the directory separator.
7358
+ * When we make system calls (eg: LanguageServiceHost.getDirectory()),
7359
+ * we expect the host to correctly handle paths in our specified format.
7360
+ */
7361
+ ts.directorySeparator = "/";
7362
+ ts.altDirectorySeparator = "\\";
7363
+ var urlSchemeSeparator = "://";
7364
+ var backslashRegExp = /\\/g;
7365
+ //// Path Tests
7366
+ /**
7367
+ * Determines whether a charCode corresponds to `/` or `\`.
7368
+ */
7369
+ function isAnyDirectorySeparator(charCode) {
7370
+ return charCode === 47 /* slash */ || charCode === 92 /* backslash */;
7371
+ }
7372
+ ts.isAnyDirectorySeparator = isAnyDirectorySeparator;
7373
+ /**
7374
+ * Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.).
7375
+ */
7376
+ function isUrl(path) {
7377
+ return getEncodedRootLength(path) < 0;
7378
+ }
7379
+ ts.isUrl = isUrl;
7380
+ /**
7381
+ * Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path
7382
+ * like `c:`, `c:\` or `c:/`).
7383
+ */
7384
+ function isRootedDiskPath(path) {
7385
+ return getEncodedRootLength(path) > 0;
7386
+ }
7387
+ ts.isRootedDiskPath = isRootedDiskPath;
7388
+ /**
7389
+ * Determines whether a path consists only of a path root.
7390
+ */
7391
+ function isDiskPathRoot(path) {
7392
+ var rootLength = getEncodedRootLength(path);
7393
+ return rootLength > 0 && rootLength === path.length;
7394
+ }
7395
+ ts.isDiskPathRoot = isDiskPathRoot;
7396
+ /**
7397
+ * Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.).
7398
+ *
7399
+ * ```ts
7400
+ * // POSIX
7401
+ * pathIsAbsolute("/path/to/file.ext") === true
7402
+ * // DOS
7403
+ * pathIsAbsolute("c:/path/to/file.ext") === true
7404
+ * // URL
7405
+ * pathIsAbsolute("file:///path/to/file.ext") === true
7406
+ * // Non-absolute
7407
+ * pathIsAbsolute("path/to/file.ext") === false
7408
+ * pathIsAbsolute("./path/to/file.ext") === false
7409
+ * ```
7410
+ */
7411
+ function pathIsAbsolute(path) {
7412
+ return getEncodedRootLength(path) !== 0;
7413
+ }
7414
+ ts.pathIsAbsolute = pathIsAbsolute;
7415
+ /**
7416
+ * Determines whether a path starts with a relative path component (i.e. `.` or `..`).
7417
+ */
7418
+ function pathIsRelative(path) {
7419
+ return /^\.\.?($|[\\/])/.test(path);
7420
+ }
7421
+ ts.pathIsRelative = pathIsRelative;
7422
+ /**
7423
+ * Determines whether a path is neither relative nor absolute, e.g. "path/to/file".
7424
+ * Also known misleadingly as "non-relative".
7425
+ */
7426
+ function pathIsBareSpecifier(path) {
7427
+ return !pathIsAbsolute(path) && !pathIsRelative(path);
7428
+ }
7429
+ ts.pathIsBareSpecifier = pathIsBareSpecifier;
7430
+ function hasExtension(fileName) {
7431
+ return ts.stringContains(getBaseFileName(fileName), ".");
7432
+ }
7433
+ ts.hasExtension = hasExtension;
7434
+ function fileExtensionIs(path, extension) {
7435
+ return path.length > extension.length && ts.endsWith(path, extension);
7436
+ }
7437
+ ts.fileExtensionIs = fileExtensionIs;
7438
+ function fileExtensionIsOneOf(path, extensions) {
7439
+ for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
7440
+ var extension = extensions_1[_i];
7441
+ if (fileExtensionIs(path, extension)) {
7442
+ return true;
7443
+ }
7444
+ }
7445
+ return false;
7446
+ }
7447
+ ts.fileExtensionIsOneOf = fileExtensionIsOneOf;
7448
+ /**
7449
+ * Determines whether a path has a trailing separator (`/` or `\\`).
7450
+ */
7451
+ function hasTrailingDirectorySeparator(path) {
7452
+ return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1));
7453
+ }
7454
+ ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator;
7455
+ //// Path Parsing
7456
+ function isVolumeCharacter(charCode) {
7457
+ return (charCode >= 97 /* a */ && charCode <= 122 /* z */) ||
7458
+ (charCode >= 65 /* A */ && charCode <= 90 /* Z */);
7459
+ }
7460
+ function getFileUrlVolumeSeparatorEnd(url, start) {
7461
+ var ch0 = url.charCodeAt(start);
7462
+ if (ch0 === 58 /* colon */)
7463
+ return start + 1;
7464
+ if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) {
7465
+ var ch2 = url.charCodeAt(start + 2);
7466
+ if (ch2 === 97 /* a */ || ch2 === 65 /* A */)
7467
+ return start + 3;
7468
+ }
7469
+ return -1;
7470
+ }
7471
+ /**
7472
+ * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
7473
+ * If the root is part of a URL, the twos-complement of the root length is returned.
7474
+ */
7475
+ function getEncodedRootLength(path) {
7476
+ if (!path)
7477
+ return 0;
7478
+ var ch0 = path.charCodeAt(0);
7479
+ // POSIX or UNC
7480
+ if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) {
7481
+ if (path.charCodeAt(1) !== ch0)
7482
+ return 1; // POSIX: "/" (or non-normalized "\")
7483
+ var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2);
7484
+ if (p1 < 0)
7485
+ return path.length; // UNC: "//server" or "\\server"
7486
+ return p1 + 1; // UNC: "//server/" or "\\server\"
7487
+ }
7488
+ // DOS
7489
+ if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) {
7490
+ var ch2 = path.charCodeAt(2);
7491
+ if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */)
7492
+ return 3; // DOS: "c:/" or "c:\"
7493
+ if (path.length === 2)
7494
+ return 2; // DOS: "c:" (but not "c:d")
7495
+ }
7496
+ // URL
7497
+ var schemeEnd = path.indexOf(urlSchemeSeparator);
7498
+ if (schemeEnd !== -1) {
7499
+ var authorityStart = schemeEnd + urlSchemeSeparator.length;
7500
+ var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart);
7501
+ if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path"
7502
+ // For local "file" URLs, include the leading DOS volume (if present).
7503
+ // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a
7504
+ // special case interpreted as "the machine from which the URL is being interpreted".
7505
+ var scheme = path.slice(0, schemeEnd);
7506
+ var authority = path.slice(authorityStart, authorityEnd);
7507
+ if (scheme === "file" && (authority === "" || authority === "localhost") &&
7508
+ isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
7509
+ var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
7510
+ if (volumeSeparatorEnd !== -1) {
7511
+ if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) {
7512
+ // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/"
7513
+ return ~(volumeSeparatorEnd + 1);
7514
+ }
7515
+ if (volumeSeparatorEnd === path.length) {
7516
+ // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a"
7517
+ // but not "file:///c:d" or "file:///c%3ad"
7518
+ return ~volumeSeparatorEnd;
7519
+ }
7520
+ }
7521
+ }
7522
+ return ~(authorityEnd + 1); // URL: "file://server/", "http://server/"
7523
+ }
7524
+ return ~path.length; // URL: "file://server", "http://server"
7525
+ }
7526
+ // relative
7527
+ return 0;
7528
+ }
7529
+ /**
7530
+ * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
7531
+ *
7532
+ * For example:
7533
+ * ```ts
7534
+ * getRootLength("a") === 0 // ""
7535
+ * getRootLength("/") === 1 // "/"
7536
+ * getRootLength("c:") === 2 // "c:"
7537
+ * getRootLength("c:d") === 0 // ""
7538
+ * getRootLength("c:/") === 3 // "c:/"
7539
+ * getRootLength("c:\\") === 3 // "c:\\"
7540
+ * getRootLength("//server") === 7 // "//server"
7541
+ * getRootLength("//server/share") === 8 // "//server/"
7542
+ * getRootLength("\\\\server") === 7 // "\\\\server"
7543
+ * getRootLength("\\\\server\\share") === 8 // "\\\\server\\"
7544
+ * getRootLength("file:///path") === 8 // "file:///"
7545
+ * getRootLength("file:///c:") === 10 // "file:///c:"
7546
+ * getRootLength("file:///c:d") === 8 // "file:///"
7547
+ * getRootLength("file:///c:/path") === 11 // "file:///c:/"
7548
+ * getRootLength("file://server") === 13 // "file://server"
7549
+ * getRootLength("file://server/path") === 14 // "file://server/"
7550
+ * getRootLength("http://server") === 13 // "http://server"
7551
+ * getRootLength("http://server/path") === 14 // "http://server/"
7552
+ * ```
7553
+ */
7554
+ function getRootLength(path) {
7555
+ var rootLength = getEncodedRootLength(path);
7556
+ return rootLength < 0 ? ~rootLength : rootLength;
7557
+ }
7558
+ ts.getRootLength = getRootLength;
7559
+ function getDirectoryPath(path) {
7560
+ path = normalizeSlashes(path);
7561
+ // If the path provided is itself the root, then return it.
7562
+ var rootLength = getRootLength(path);
7563
+ if (rootLength === path.length)
7564
+ return path;
7565
+ // return the leading portion of the path up to the last (non-terminal) directory separator
7566
+ // but not including any trailing directory separator.
7567
+ path = removeTrailingDirectorySeparator(path);
7568
+ return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator)));
7569
+ }
7570
+ ts.getDirectoryPath = getDirectoryPath;
7571
+ function getBaseFileName(path, extensions, ignoreCase) {
7572
+ path = normalizeSlashes(path);
7573
+ // if the path provided is itself the root, then it has not file name.
7574
+ var rootLength = getRootLength(path);
7575
+ if (rootLength === path.length)
7576
+ return "";
7577
+ // return the trailing portion of the path starting after the last (non-terminal) directory
7578
+ // separator but not including any trailing directory separator.
7579
+ path = removeTrailingDirectorySeparator(path);
7580
+ var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1));
7581
+ var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined;
7582
+ return extension ? name.slice(0, name.length - extension.length) : name;
7583
+ }
7584
+ ts.getBaseFileName = getBaseFileName;
7585
+ function tryGetExtensionFromPath(path, extension, stringEqualityComparer) {
7586
+ if (!ts.startsWith(extension, "."))
7587
+ extension = "." + extension;
7588
+ if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) {
7589
+ var pathExtension = path.slice(path.length - extension.length);
7590
+ if (stringEqualityComparer(pathExtension, extension)) {
7591
+ return pathExtension;
7592
+ }
7593
+ }
7594
+ }
7595
+ function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) {
7596
+ if (typeof extensions === "string") {
7597
+ return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || "";
7598
+ }
7599
+ for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) {
7600
+ var extension = extensions_2[_i];
7601
+ var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer);
7602
+ if (result)
7603
+ return result;
7604
+ }
7605
+ return "";
7606
+ }
7607
+ function getAnyExtensionFromPath(path, extensions, ignoreCase) {
7608
+ // Retrieves any string from the final "." onwards from a base file name.
7609
+ // Unlike extensionFromPath, which throws an exception on unrecognized extensions.
7610
+ if (extensions) {
7611
+ return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive);
7612
+ }
7613
+ var baseFileName = getBaseFileName(path);
7614
+ var extensionIndex = baseFileName.lastIndexOf(".");
7615
+ if (extensionIndex >= 0) {
7616
+ return baseFileName.substring(extensionIndex);
7617
+ }
7618
+ return "";
7619
+ }
7620
+ ts.getAnyExtensionFromPath = getAnyExtensionFromPath;
7621
+ function pathComponents(path, rootLength) {
7622
+ var root = path.substring(0, rootLength);
7623
+ var rest = path.substring(rootLength).split(ts.directorySeparator);
7624
+ if (rest.length && !ts.lastOrUndefined(rest))
7625
+ rest.pop();
7626
+ return __spreadArray([root], rest, true);
7627
+ }
7628
+ /**
7629
+ * Parse a path into an array containing a root component (at index 0) and zero or more path
7630
+ * components (at indices > 0). The result is not normalized.
7631
+ * If the path is relative, the root component is `""`.
7632
+ * If the path is absolute, the root component includes the first path separator (`/`).
7633
+ *
7634
+ * ```ts
7635
+ * // POSIX
7636
+ * getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"]
7637
+ * getPathComponents("/path/to/") === ["/", "path", "to"]
7638
+ * getPathComponents("/") === ["/"]
7639
+ * // DOS
7640
+ * getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"]
7641
+ * getPathComponents("c:/path/to/") === ["c:/", "path", "to"]
7642
+ * getPathComponents("c:/") === ["c:/"]
7643
+ * getPathComponents("c:") === ["c:"]
7644
+ * // URL
7645
+ * getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"]
7646
+ * getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"]
7647
+ * getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"]
7648
+ * getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"]
7649
+ * getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"]
7650
+ * getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"]
7651
+ * getPathComponents("file://server/") === ["file://server/"]
7652
+ * getPathComponents("file://server") === ["file://server"]
7653
+ * getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"]
7654
+ * getPathComponents("file:///path/to/") === ["file:///", "path", "to"]
7655
+ * getPathComponents("file:///") === ["file:///"]
7656
+ * getPathComponents("file://") === ["file://"]
7657
+ */
7658
+ function getPathComponents(path, currentDirectory) {
7659
+ if (currentDirectory === void 0) { currentDirectory = ""; }
7660
+ path = combinePaths(currentDirectory, path);
7661
+ return pathComponents(path, getRootLength(path));
7662
+ }
7663
+ ts.getPathComponents = getPathComponents;
7664
+ //// Path Formatting
7665
+ /**
7666
+ * Formats a parsed path consisting of a root component (at index 0) and zero or more path
7667
+ * segments (at indices > 0).
7668
+ *
7669
+ * ```ts
7670
+ * getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext"
7671
+ * ```
7672
+ */
7673
+ function getPathFromPathComponents(pathComponents) {
7674
+ if (pathComponents.length === 0)
7675
+ return "";
7676
+ var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
7677
+ return root + pathComponents.slice(1).join(ts.directorySeparator);
7678
+ }
7679
+ ts.getPathFromPathComponents = getPathFromPathComponents;
7680
+ //// Path Normalization
7681
+ /**
7682
+ * Normalize path separators, converting `\` into `/`.
7683
+ */
7684
+ function normalizeSlashes(path) {
7685
+ var index = path.indexOf("\\");
7686
+ if (index === -1) {
7687
+ return path;
7688
+ }
7689
+ backslashRegExp.lastIndex = index; // prime regex with known position
7690
+ return path.replace(backslashRegExp, ts.directorySeparator);
7691
+ }
7692
+ ts.normalizeSlashes = normalizeSlashes;
7693
+ /**
7694
+ * Reduce an array of path components to a more simplified path by navigating any
7695
+ * `"."` or `".."` entries in the path.
7696
+ */
7697
+ function reducePathComponents(components) {
7698
+ if (!ts.some(components))
7699
+ return [];
7700
+ var reduced = [components[0]];
7701
+ for (var i = 1; i < components.length; i++) {
7702
+ var component = components[i];
7703
+ if (!component)
7704
+ continue;
7705
+ if (component === ".")
7706
+ continue;
7707
+ if (component === "..") {
7708
+ if (reduced.length > 1) {
7709
+ if (reduced[reduced.length - 1] !== "..") {
7710
+ reduced.pop();
7711
+ continue;
7712
+ }
7713
+ }
7714
+ else if (reduced[0])
7715
+ continue;
7716
+ }
7717
+ reduced.push(component);
7718
+ }
7719
+ return reduced;
7720
+ }
7721
+ ts.reducePathComponents = reducePathComponents;
7722
+ /**
7723
+ * Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified.
7724
+ *
7725
+ * ```ts
7726
+ * // Non-rooted
7727
+ * combinePaths("path", "to", "file.ext") === "path/to/file.ext"
7728
+ * combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext"
7729
+ * // POSIX
7730
+ * combinePaths("/path", "to", "file.ext") === "/path/to/file.ext"
7731
+ * combinePaths("/path", "/to", "file.ext") === "/to/file.ext"
7732
+ * // DOS
7733
+ * combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext"
7734
+ * combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext"
7735
+ * // URL
7736
+ * combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext"
7737
+ * combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext"
7738
+ * ```
7739
+ */
7740
+ function combinePaths(path) {
7741
+ var paths = [];
7742
+ for (var _i = 1; _i < arguments.length; _i++) {
7743
+ paths[_i - 1] = arguments[_i];
7744
+ }
7745
+ if (path)
7746
+ path = normalizeSlashes(path);
7747
+ for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
7748
+ var relativePath = paths_1[_a];
7749
+ if (!relativePath)
7750
+ continue;
7751
+ relativePath = normalizeSlashes(relativePath);
7752
+ if (!path || getRootLength(relativePath) !== 0) {
7753
+ path = relativePath;
7754
+ }
7755
+ else {
7756
+ path = ensureTrailingDirectorySeparator(path) + relativePath;
7757
+ }
7758
+ }
7759
+ return path;
7760
+ }
7761
+ ts.combinePaths = combinePaths;
7762
+ /**
7763
+ * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any
7764
+ * `.` and `..` path components are resolved. Trailing directory separators are preserved.
7765
+ *
7766
+ * ```ts
7767
+ * resolvePath("/path", "to", "file.ext") === "path/to/file.ext"
7768
+ * resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/"
7769
+ * resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext"
7770
+ * ```
7771
+ */
7772
+ function resolvePath(path) {
7773
+ var paths = [];
7774
+ for (var _i = 1; _i < arguments.length; _i++) {
7775
+ paths[_i - 1] = arguments[_i];
7776
+ }
7777
+ return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArray([path], paths, false)) : normalizeSlashes(path));
7778
+ }
7779
+ ts.resolvePath = resolvePath;
7780
+ /**
7781
+ * Parse a path into an array containing a root component (at index 0) and zero or more path
7782
+ * components (at indices > 0). The result is normalized.
7783
+ * If the path is relative, the root component is `""`.
7784
+ * If the path is absolute, the root component includes the first path separator (`/`).
7785
+ *
7786
+ * ```ts
7787
+ * getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"]
7788
+ * ```
7789
+ */
7790
+ function getNormalizedPathComponents(path, currentDirectory) {
7791
+ return reducePathComponents(getPathComponents(path, currentDirectory));
7792
+ }
7793
+ ts.getNormalizedPathComponents = getNormalizedPathComponents;
7794
+ function getNormalizedAbsolutePath(fileName, currentDirectory) {
7795
+ return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
7796
+ }
7797
+ ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
7798
+ function normalizePath(path) {
7799
+ path = normalizeSlashes(path);
7800
+ // Most paths don't require normalization
7801
+ if (!relativePathSegmentRegExp.test(path)) {
7802
+ return path;
7803
+ }
7804
+ // Some paths only require cleanup of `/./` or leading `./`
7805
+ var simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, "");
7806
+ if (simplified !== path) {
7807
+ path = simplified;
7808
+ if (!relativePathSegmentRegExp.test(path)) {
7809
+ return path;
7810
+ }
7811
+ }
7812
+ // Other paths require full normalization
7813
+ var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
7814
+ return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
7815
+ }
7816
+ ts.normalizePath = normalizePath;
7817
+ function getPathWithoutRoot(pathComponents) {
7818
+ if (pathComponents.length === 0)
7819
+ return "";
7820
+ return pathComponents.slice(1).join(ts.directorySeparator);
7821
+ }
7822
+ function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
7823
+ return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
7824
+ }
7825
+ ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
7826
+ function toPath(fileName, basePath, getCanonicalFileName) {
7827
+ var nonCanonicalizedPath = isRootedDiskPath(fileName)
7828
+ ? normalizePath(fileName)
7829
+ : getNormalizedAbsolutePath(fileName, basePath);
7830
+ return getCanonicalFileName(nonCanonicalizedPath);
7831
+ }
7832
+ ts.toPath = toPath;
7833
+ function normalizePathAndParts(path) {
7834
+ path = normalizeSlashes(path);
7835
+ var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
7836
+ if (parts.length) {
7837
+ var joinedParts = root + parts.join(ts.directorySeparator);
7838
+ return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
7839
+ }
7840
+ else {
7841
+ return { path: root, parts: parts };
7842
+ }
7843
+ }
7844
+ ts.normalizePathAndParts = normalizePathAndParts;
7845
+ function removeTrailingDirectorySeparator(path) {
7846
+ if (hasTrailingDirectorySeparator(path)) {
7847
+ return path.substr(0, path.length - 1);
7848
+ }
7849
+ return path;
7850
+ }
7851
+ ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
7852
+ function ensureTrailingDirectorySeparator(path) {
7853
+ if (!hasTrailingDirectorySeparator(path)) {
7854
+ return path + ts.directorySeparator;
7855
+ }
7856
+ return path;
7857
+ }
7858
+ ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator;
7859
+ /**
7860
+ * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed
7861
+ * with `./` or `../`) so as not to be confused with an unprefixed module name.
7862
+ *
7863
+ * ```ts
7864
+ * ensurePathIsNonModuleName("/path/to/file.ext") === "/path/to/file.ext"
7865
+ * ensurePathIsNonModuleName("./path/to/file.ext") === "./path/to/file.ext"
7866
+ * ensurePathIsNonModuleName("../path/to/file.ext") === "../path/to/file.ext"
7867
+ * ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext"
7868
+ * ```
7869
+ */
7870
+ function ensurePathIsNonModuleName(path) {
7871
+ return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path;
7872
+ }
7873
+ ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName;
7874
+ function changeAnyExtension(path, ext, extensions, ignoreCase) {
7875
+ var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path);
7876
+ return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
7877
+ }
7878
+ ts.changeAnyExtension = changeAnyExtension;
7879
+ //// Path Comparisons
7880
+ // check path for these segments: '', '.'. '..'
7881
+ var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/;
7882
+ function comparePathsWorker(a, b, componentComparer) {
7883
+ if (a === b)
7884
+ return 0 /* EqualTo */;
7885
+ if (a === undefined)
7886
+ return -1 /* LessThan */;
7887
+ if (b === undefined)
7888
+ return 1 /* GreaterThan */;
7889
+ // NOTE: Performance optimization - shortcut if the root segments differ as there would be no
7890
+ // need to perform path reduction.
7891
+ var aRoot = a.substring(0, getRootLength(a));
7892
+ var bRoot = b.substring(0, getRootLength(b));
7893
+ var result = ts.compareStringsCaseInsensitive(aRoot, bRoot);
7894
+ if (result !== 0 /* EqualTo */) {
7895
+ return result;
7896
+ }
7897
+ // NOTE: Performance optimization - shortcut if there are no relative path segments in
7898
+ // the non-root portion of the path
7899
+ var aRest = a.substring(aRoot.length);
7900
+ var bRest = b.substring(bRoot.length);
7901
+ if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) {
7902
+ return componentComparer(aRest, bRest);
7903
+ }
7904
+ // The path contains a relative path segment. Normalize the paths and perform a slower component
7905
+ // by component comparison.
7906
+ var aComponents = reducePathComponents(getPathComponents(a));
7907
+ var bComponents = reducePathComponents(getPathComponents(b));
7908
+ var sharedLength = Math.min(aComponents.length, bComponents.length);
7909
+ for (var i = 1; i < sharedLength; i++) {
7910
+ var result_2 = componentComparer(aComponents[i], bComponents[i]);
7911
+ if (result_2 !== 0 /* EqualTo */) {
7912
+ return result_2;
7913
+ }
7914
+ }
7915
+ return ts.compareValues(aComponents.length, bComponents.length);
7916
+ }
7917
+ /**
7918
+ * Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively.
7919
+ */
7920
+ function comparePathsCaseSensitive(a, b) {
7921
+ return comparePathsWorker(a, b, ts.compareStringsCaseSensitive);
7922
+ }
7923
+ ts.comparePathsCaseSensitive = comparePathsCaseSensitive;
7924
+ /**
7925
+ * Performs a case-insensitive comparison of two paths.
7926
+ */
7927
+ function comparePathsCaseInsensitive(a, b) {
7928
+ return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive);
7929
+ }
7930
+ ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive;
7931
+ function comparePaths(a, b, currentDirectory, ignoreCase) {
7932
+ if (typeof currentDirectory === "string") {
7933
+ a = combinePaths(currentDirectory, a);
7934
+ b = combinePaths(currentDirectory, b);
7935
+ }
7936
+ else if (typeof currentDirectory === "boolean") {
7937
+ ignoreCase = currentDirectory;
7938
+ }
7939
+ return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase));
7940
+ }
7941
+ ts.comparePaths = comparePaths;
7942
+ function containsPath(parent, child, currentDirectory, ignoreCase) {
7943
+ if (typeof currentDirectory === "string") {
7944
+ parent = combinePaths(currentDirectory, parent);
7945
+ child = combinePaths(currentDirectory, child);
7946
+ }
7947
+ else if (typeof currentDirectory === "boolean") {
7948
+ ignoreCase = currentDirectory;
7949
+ }
7950
+ if (parent === undefined || child === undefined)
7951
+ return false;
7952
+ if (parent === child)
7953
+ return true;
7954
+ var parentComponents = reducePathComponents(getPathComponents(parent));
7955
+ var childComponents = reducePathComponents(getPathComponents(child));
7956
+ if (childComponents.length < parentComponents.length) {
7957
+ return false;
7958
+ }
7959
+ var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive;
7960
+ for (var i = 0; i < parentComponents.length; i++) {
7961
+ var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer;
7962
+ if (!equalityComparer(parentComponents[i], childComponents[i])) {
7963
+ return false;
7964
+ }
7965
+ }
7966
+ return true;
7967
+ }
7968
+ ts.containsPath = containsPath;
7969
+ /**
7970
+ * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback.
7971
+ * Comparison is case-sensitive between the canonical paths.
7972
+ *
7973
+ * Use `containsPath` if file names are not already reduced and absolute.
7974
+ */
7975
+ function startsWithDirectory(fileName, directoryName, getCanonicalFileName) {
7976
+ var canonicalFileName = getCanonicalFileName(fileName);
7977
+ var canonicalDirectoryName = getCanonicalFileName(directoryName);
7978
+ return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\");
7979
+ }
7980
+ ts.startsWithDirectory = startsWithDirectory;
7981
+ //// Relative Paths
7982
+ function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) {
7983
+ var fromComponents = reducePathComponents(getPathComponents(from));
7984
+ var toComponents = reducePathComponents(getPathComponents(to));
7985
+ var start;
7986
+ for (start = 0; start < fromComponents.length && start < toComponents.length; start++) {
7987
+ var fromComponent = getCanonicalFileName(fromComponents[start]);
7988
+ var toComponent = getCanonicalFileName(toComponents[start]);
7989
+ var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer;
7990
+ if (!comparer(fromComponent, toComponent))
7991
+ break;
7992
+ }
7993
+ if (start === 0) {
7994
+ return toComponents;
7995
+ }
7996
+ var components = toComponents.slice(start);
7997
+ var relative = [];
7998
+ for (; start < fromComponents.length; start++) {
7999
+ relative.push("..");
8000
+ }
8001
+ return __spreadArray(__spreadArray([""], relative, true), components, true);
8002
+ }
8003
+ ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo;
8004
+ function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
8005
+ ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
8006
+ var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
8007
+ var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
8008
+ var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
8009
+ return getPathFromPathComponents(pathComponents);
8010
+ }
8011
+ ts.getRelativePathFromDirectory = getRelativePathFromDirectory;
8012
+ function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
8013
+ return !isRootedDiskPath(absoluteOrRelativePath)
8014
+ ? absoluteOrRelativePath
8015
+ : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
8016
+ }
8017
+ ts.convertToRelativePath = convertToRelativePath;
8018
+ function getRelativePathFromFile(from, to, getCanonicalFileName) {
8019
+ return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName));
8020
+ }
8021
+ ts.getRelativePathFromFile = getRelativePathFromFile;
8022
+ function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
8023
+ var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName);
8024
+ var firstComponent = pathComponents[0];
8025
+ if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) {
8026
+ var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///";
8027
+ pathComponents[0] = prefix + firstComponent;
8028
+ }
8029
+ return getPathFromPathComponents(pathComponents);
8030
+ }
8031
+ ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl;
8032
+ function forEachAncestorDirectory(directory, callback) {
8033
+ while (true) {
8034
+ var result = callback(directory);
8035
+ if (result !== undefined) {
8036
+ return result;
8037
+ }
8038
+ var parentPath = getDirectoryPath(directory);
8039
+ if (parentPath === directory) {
8040
+ return undefined;
8041
+ }
8042
+ directory = parentPath;
8043
+ }
8044
+ }
8045
+ ts.forEachAncestorDirectory = forEachAncestorDirectory;
8046
+ function isNodeModulesDirectory(dirPath) {
8047
+ return ts.endsWith(dirPath, "/node_modules");
8048
+ }
8049
+ ts.isNodeModulesDirectory = isNodeModulesDirectory;
8050
+ })(ts || (ts = {}));
8051
8051
  // <auto-generated />
8052
8052
  // generated from './diagnosticMessages.json' in 'src/compiler'
8053
8053
  /* @internal */
@@ -8875,12 +8875,10 @@ var ts;
8875
8875
  Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher: diag(2802, ts.DiagnosticCategory.Error, "Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es201_2802", "Type '{0}' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher."),
8876
8876
  Cannot_assign_to_private_method_0_Private_methods_are_not_writable: diag(2803, ts.DiagnosticCategory.Error, "Cannot_assign_to_private_method_0_Private_methods_are_not_writable_2803", "Cannot assign to private method '{0}'. Private methods are not writable."),
8877
8877
  Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name: diag(2804, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name_2804", "Duplicate identifier '{0}'. Static and instance elements cannot share the same private name."),
8878
- Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag: diag(2805, ts.DiagnosticCategory.Error, "Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_no_2805", "Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag."),
8879
8878
  Private_accessor_was_defined_without_a_getter: diag(2806, ts.DiagnosticCategory.Error, "Private_accessor_was_defined_without_a_getter_2806", "Private accessor was defined without a getter."),
8880
8879
  This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."),
8881
8880
  A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"),
8882
8881
  Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."),
8883
- Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false: diag(2810, ts.DiagnosticCategory.Error, "Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnex_2810", "Property '{0}' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'."),
8884
8882
  Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"),
8885
8883
  Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."),
8886
8884
  Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."),
@@ -9831,6 +9829,7 @@ var ts;
9831
9829
  Add_missing_attributes: diag(95167, ts.DiagnosticCategory.Message, "Add_missing_attributes_95167", "Add missing attributes"),
9832
9830
  Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"),
9833
9831
  Add_undefined_to_optional_property_type: diag(95169, ts.DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"),
9832
+ Convert_named_imports_to_default_import: diag(95170, ts.DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"),
9834
9833
  No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
9835
9834
  Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
9836
9835
  JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
@@ -13003,12 +13002,17 @@ var ts;
13003
13002
  /** Gets the text of a jsdoc comment, flattening links to their text. */
13004
13003
  function getTextOfJSDocComment(comment) {
13005
13004
  return typeof comment === "string" ? comment
13006
- : comment === null || comment === void 0 ? void 0 : comment.map(function (c) {
13007
- // TODO: Other kinds here
13008
- return c.kind === 319 /* JSDocText */ ? c.text : "{@link " + (c.name ? ts.entityNameToString(c.name) + " " : "") + c.text + "}";
13009
- }).join("");
13005
+ : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 319 /* JSDocText */ ? c.text : formatJSDocLink(c); }).join("");
13010
13006
  }
13011
13007
  ts.getTextOfJSDocComment = getTextOfJSDocComment;
13008
+ function formatJSDocLink(link) {
13009
+ var kind = link.kind === 322 /* JSDocLink */ ? "link"
13010
+ : link.kind === 323 /* JSDocLinkCode */ ? "linkcode"
13011
+ : "linkplain";
13012
+ var name = link.name ? ts.entityNameToString(link.name) : "";
13013
+ var space = link.name && link.text.startsWith("://") ? "" : " ";
13014
+ return "{@" + kind + " " + name + space + link.text + "}";
13015
+ }
13012
13016
  /**
13013
13017
  * Gets the effective type parameters. If the node was parsed in a
13014
13018
  * JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
@@ -47057,8 +47061,8 @@ var ts;
47057
47061
  TypeFacts[TypeFacts["AllTypeofNE"] = 556800] = "AllTypeofNE";
47058
47062
  TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts";
47059
47063
  // Masks
47060
- TypeFacts[TypeFacts["OrFactsMask"] = 8288] = "OrFactsMask";
47061
- TypeFacts[TypeFacts["AndFactsMask"] = 16768927] = "AndFactsMask";
47064
+ TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
47065
+ TypeFacts[TypeFacts["AndFactsMask"] = 16768959] = "AndFactsMask";
47062
47066
  })(TypeFacts || (TypeFacts = {}));
47063
47067
  var typeofEQFacts = new ts.Map(ts.getEntries({
47064
47068
  string: 1 /* TypeofEQString */,
@@ -68166,7 +68170,10 @@ var ts;
68166
68170
  (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ :
68167
68171
  (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
68168
68172
  }
68169
- if (flags & 524288 /* Object */ && !ignoreObjects) {
68173
+ if (flags & 524288 /* Object */) {
68174
+ if (ignoreObjects) {
68175
+ return 16768959 /* AndFactsMask */; // This is the identity element for computing type facts of intersection.
68176
+ }
68170
68177
  return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ?
68171
68178
  strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ :
68172
68179
  isFunctionObjectType(type) ?
@@ -68214,7 +68221,7 @@ var ts;
68214
68221
  oredFacts |= f;
68215
68222
  andedFacts &= f;
68216
68223
  }
68217
- return oredFacts & 8288 /* OrFactsMask */ | andedFacts & 16768927 /* AndFactsMask */;
68224
+ return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 16768959 /* AndFactsMask */;
68218
68225
  }
68219
68226
  function getTypeWithFacts(type, include) {
68220
68227
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
@@ -70174,6 +70181,9 @@ var ts;
70174
70181
  return getTypeOfSymbol(symbol);
70175
70182
  }
70176
70183
  function checkIdentifier(node, checkMode) {
70184
+ if (ts.isThisInTypeQuery(node)) {
70185
+ return checkThisExpression(node);
70186
+ }
70177
70187
  var symbol = getResolvedSymbol(node);
70178
70188
  if (symbol === unknownSymbol) {
70179
70189
  return errorType;
@@ -71965,7 +71975,8 @@ var ts;
71965
71975
  var links = getNodeLinks(node.expression);
71966
71976
  if (!links.resolvedType) {
71967
71977
  if ((ts.isTypeLiteralNode(node.parent.parent) || ts.isClassLike(node.parent.parent) || ts.isInterfaceDeclaration(node.parent.parent))
71968
- && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */) {
71978
+ && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */
71979
+ && node.parent.kind !== 171 /* GetAccessor */ && node.parent.kind !== 172 /* SetAccessor */) {
71969
71980
  return links.resolvedType = errorType;
71970
71981
  }
71971
71982
  links.resolvedType = checkExpression(node.expression);
@@ -73134,23 +73145,6 @@ var ts;
73134
73145
  if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) {
73135
73146
  grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right));
73136
73147
  }
73137
- if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && !useDefineForClassFields)) {
73138
- var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration);
73139
- var parentStaticFieldInitializer = ts.findAncestor(node, function (n) {
73140
- if (n === lexicalClass_1)
73141
- return "quit";
73142
- if (ts.isPropertyDeclaration(n.parent) && ts.hasStaticModifier(n.parent) && n.parent.initializer === n && n.parent.parent === lexicalClass_1) {
73143
- return true;
73144
- }
73145
- return false;
73146
- });
73147
- if (parentStaticFieldInitializer) {
73148
- var parentStaticFieldInitializerSymbol = getSymbolOfNode(parentStaticFieldInitializer.parent);
73149
- ts.Debug.assert(parentStaticFieldInitializerSymbol, "Initializer without declaration symbol");
73150
- var diagnostic = error(node, ts.Diagnostics.Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false, ts.symbolName(lexicallyScopedSymbol));
73151
- ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(parentStaticFieldInitializer.parent, ts.Diagnostics.Initializer_for_property_0, ts.symbolName(parentStaticFieldInitializerSymbol)));
73152
- }
73153
- }
73154
73148
  if (isAnyLike) {
73155
73149
  if (lexicallyScopedSymbol) {
73156
73150
  return isErrorType(apparentType) ? errorType : apparentType;
@@ -75913,6 +75907,10 @@ var ts;
75913
75907
  return restParameter.escapedName;
75914
75908
  }
75915
75909
  function getParameterIdentifierNameAtPosition(signature, pos) {
75910
+ var _a;
75911
+ if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 315 /* JSDocFunctionType */) {
75912
+ return undefined;
75913
+ }
75916
75914
  var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
75917
75915
  if (pos < paramCount) {
75918
75916
  var param = signature.parameters[pos];
@@ -78782,9 +78780,6 @@ var ts;
78782
78780
  checkGrammarComputedPropertyName(node.name);
78783
78781
  checkVariableLikeDeclaration(node);
78784
78782
  setNodeLinksForPrivateIdentifierScope(node);
78785
- if (ts.isPrivateIdentifier(node.name) && ts.hasStaticModifier(node) && node.initializer && languageVersion === 99 /* ESNext */ && !compilerOptions.useDefineForClassFields) {
78786
- error(node.initializer, ts.Diagnostics.Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag);
78787
- }
78788
78783
  // property signatures already report "initializer not allowed in ambient context" elsewhere
78789
78784
  if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 166 /* PropertyDeclaration */ && node.initializer) {
78790
78785
  error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name));
@@ -84677,7 +84672,10 @@ var ts;
84677
84672
  case 80 /* PrivateIdentifier */:
84678
84673
  case 205 /* PropertyAccessExpression */:
84679
84674
  case 160 /* QualifiedName */:
84680
- return getSymbolOfNameOrPropertyAccessExpression(node);
84675
+ if (!ts.isThisInTypeQuery(node)) {
84676
+ return getSymbolOfNameOrPropertyAccessExpression(node);
84677
+ }
84678
+ // falls through
84681
84679
  case 108 /* ThisKeyword */:
84682
84680
  var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false);
84683
84681
  if (ts.isFunctionLike(container)) {
@@ -92471,10 +92469,12 @@ var ts;
92471
92469
  var languageVersion = ts.getEmitScriptTarget(compilerOptions);
92472
92470
  var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions);
92473
92471
  var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ES2022 */;
92472
+ // We need to transform `this` in a static initializer into a reference to the class
92473
+ // when targeting < ES2022 since the assignment will be moved outside of the class body.
92474
+ var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ES2022 */;
92474
92475
  // We don't need to transform `super` property access when targeting ES5, ES3 because
92475
92476
  // the es2015 transformation handles those.
92476
- var shouldTransformSuperInStaticInitializers = (languageVersion <= 8 /* ES2021 */ || !useDefineForClassFields) && languageVersion >= 2 /* ES2015 */;
92477
- var shouldTransformThisInStaticInitializers = languageVersion <= 8 /* ES2021 */ || !useDefineForClassFields;
92477
+ var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */;
92478
92478
  var previousOnSubstituteNode = context.onSubstituteNode;
92479
92479
  context.onSubstituteNode = onSubstituteNode;
92480
92480
  var previousOnEmitNode = context.onEmitNode;
@@ -92703,6 +92703,10 @@ var ts;
92703
92703
  ts.Debug.assert(!ts.some(node.decorators));
92704
92704
  if (ts.isPrivateIdentifier(node.name)) {
92705
92705
  if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
92706
+ if (ts.isStatic(node)) {
92707
+ // static fields are left as is
92708
+ return ts.visitEachChild(node, visitor, context);
92709
+ }
92706
92710
  // Initializer is elided as the field is initialized in transformConstructor.
92707
92711
  return factory.updatePropertyDeclaration(node,
92708
92712
  /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name,
@@ -92724,6 +92728,22 @@ var ts;
92724
92728
  if (expr && !ts.isSimpleInlineableExpression(expr)) {
92725
92729
  getPendingExpressions().push(expr);
92726
92730
  }
92731
+ if (ts.isStatic(node) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
92732
+ var initializerStatement = transformPropertyOrClassStaticBlock(node, factory.createThis());
92733
+ if (initializerStatement) {
92734
+ var staticBlock = factory.createClassStaticBlockDeclaration(
92735
+ /*decorators*/ undefined,
92736
+ /*modifiers*/ undefined, factory.createBlock([initializerStatement]));
92737
+ ts.setOriginalNode(staticBlock, node);
92738
+ ts.setCommentRange(staticBlock, node);
92739
+ // Set the comment range for the statement to an empty synthetic range
92740
+ // and drop synthetic comments from the statement to avoid printing them twice.
92741
+ ts.setCommentRange(initializerStatement, { pos: -1, end: -1 });
92742
+ ts.setSyntheticLeadingComments(initializerStatement, undefined);
92743
+ ts.setSyntheticTrailingComments(initializerStatement, undefined);
92744
+ return staticBlock;
92745
+ }
92746
+ }
92727
92747
  return undefined;
92728
92748
  }
92729
92749
  function createPrivateIdentifierAccess(info, receiver) {
@@ -93111,7 +93131,6 @@ var ts;
93111
93131
  if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) {
93112
93132
  enableSubstitutionForClassStaticThisOrSuperReference();
93113
93133
  }
93114
- var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
93115
93134
  // If a class has private static fields, or a static field has a `this` or `super` reference,
93116
93135
  // then we need to allocate a temp variable to hold on to that reference.
93117
93136
  var pendingClassReferenceAssignment;
@@ -93139,6 +93158,7 @@ var ts;
93139
93158
  // From ES6 specification:
93140
93159
  // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using
93141
93160
  // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration.
93161
+ var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
93142
93162
  if (ts.some(staticProperties)) {
93143
93163
  addPropertyOrClassStaticBlockStatements(statements, staticProperties, factory.getInternalName(node));
93144
93164
  }
@@ -93177,7 +93197,7 @@ var ts;
93177
93197
  }
93178
93198
  var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), node.modifiers, node.name,
93179
93199
  /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, heritageClauseVisitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass));
93180
- var hasTransformableStatics = ts.some(staticPropertiesOrClassStaticBlocks, function (p) { return ts.isClassStaticBlockDeclaration(p) || !!p.initializer || (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifier(p.name)); });
93200
+ var hasTransformableStatics = shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(staticPropertiesOrClassStaticBlocks, function (p) { return ts.isClassStaticBlockDeclaration(p) || !!p.initializer || ts.isPrivateIdentifier(p.name); });
93181
93201
  if (hasTransformableStatics || ts.some(pendingExpressions)) {
93182
93202
  if (isDecoratedClassDeclaration) {
93183
93203
  ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration.");
@@ -93224,6 +93244,7 @@ var ts;
93224
93244
  return undefined;
93225
93245
  }
93226
93246
  function transformClassMembers(node, isDerivedClass) {
93247
+ var members = [];
93227
93248
  if (shouldTransformPrivateElementsOrClassStaticBlocks) {
93228
93249
  // Declare private names.
93229
93250
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
@@ -93236,12 +93257,20 @@ var ts;
93236
93257
  createBrandCheckWeakSetForPrivateMethods();
93237
93258
  }
93238
93259
  }
93239
- var members = [];
93240
93260
  var constructor = transformConstructor(node, isDerivedClass);
93261
+ var visitedMembers = ts.visitNodes(node.members, classElementVisitor, ts.isClassElement);
93241
93262
  if (constructor) {
93242
93263
  members.push(constructor);
93243
93264
  }
93244
- ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
93265
+ if (!shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(pendingExpressions)) {
93266
+ members.push(factory.createClassStaticBlockDeclaration(
93267
+ /*decorators*/ undefined,
93268
+ /*modifiers*/ undefined, factory.createBlock([
93269
+ factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))
93270
+ ])));
93271
+ pendingExpressions = undefined;
93272
+ }
93273
+ ts.addRange(members, visitedMembers);
93245
93274
  return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members);
93246
93275
  }
93247
93276
  function createBrandCheckWeakSetForPrivateMethods() {
@@ -93384,24 +93413,34 @@ var ts;
93384
93413
  function addPropertyOrClassStaticBlockStatements(statements, properties, receiver) {
93385
93414
  for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
93386
93415
  var property = properties_7[_i];
93387
- var expression = ts.isClassStaticBlockDeclaration(property) ?
93388
- transformClassStaticBlockDeclaration(property) :
93389
- transformProperty(property, receiver);
93390
- if (!expression) {
93416
+ if (ts.isStatic(property) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
93417
+ continue;
93418
+ }
93419
+ var statement = transformPropertyOrClassStaticBlock(property, receiver);
93420
+ if (!statement) {
93391
93421
  continue;
93392
93422
  }
93393
- var statement = factory.createExpressionStatement(expression);
93394
- ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
93395
- ts.setCommentRange(statement, property);
93396
- ts.setOriginalNode(statement, property);
93397
- // `setOriginalNode` *copies* the `emitNode` from `property`, so now both
93398
- // `statement` and `expression` have a copy of the synthesized comments.
93399
- // Drop the comments from expression to avoid printing them twice.
93400
- ts.setSyntheticLeadingComments(expression, undefined);
93401
- ts.setSyntheticTrailingComments(expression, undefined);
93402
93423
  statements.push(statement);
93403
93424
  }
93404
93425
  }
93426
+ function transformPropertyOrClassStaticBlock(property, receiver) {
93427
+ var expression = ts.isClassStaticBlockDeclaration(property) ?
93428
+ transformClassStaticBlockDeclaration(property) :
93429
+ transformProperty(property, receiver);
93430
+ if (!expression) {
93431
+ return undefined;
93432
+ }
93433
+ var statement = factory.createExpressionStatement(expression);
93434
+ ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
93435
+ ts.setCommentRange(statement, property);
93436
+ ts.setOriginalNode(statement, property);
93437
+ // `setOriginalNode` *copies* the `emitNode` from `property`, so now both
93438
+ // `statement` and `expression` have a copy of the synthesized comments.
93439
+ // Drop the comments from expression to avoid printing them twice.
93440
+ ts.setSyntheticLeadingComments(expression, undefined);
93441
+ ts.setSyntheticTrailingComments(expression, undefined);
93442
+ return statement;
93443
+ }
93405
93444
  /**
93406
93445
  * Generates assignment expressions for property initializers.
93407
93446
  *
@@ -94651,6 +94690,7 @@ var ts;
94651
94690
  var exportedVariableStatement = false;
94652
94691
  var enabledSubstitutions;
94653
94692
  var enclosingFunctionFlags;
94693
+ var parametersWithPrecedingObjectRestOrSpread;
94654
94694
  var enclosingSuperContainerFlags = 0;
94655
94695
  var hierarchyFacts = 0;
94656
94696
  var currentSourceFile;
@@ -95107,6 +95147,7 @@ var ts;
95107
95147
  /*incrementor*/ undefined,
95108
95148
  /*statement*/ convertForOfStatementHead(node, getValue)),
95109
95149
  /*location*/ node), 256 /* NoTokenTrailingSourceMaps */);
95150
+ ts.setOriginalNode(forStatement, node);
95110
95151
  return factory.createTryStatement(factory.createBlock([
95111
95152
  factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement)
95112
95153
  ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([
@@ -95124,7 +95165,19 @@ var ts;
95124
95165
  ]), 1 /* SingleLine */))
95125
95166
  ]));
95126
95167
  }
95168
+ function parameterVisitor(node) {
95169
+ ts.Debug.assertNode(node, ts.isParameter);
95170
+ return visitParameter(node);
95171
+ }
95127
95172
  function visitParameter(node) {
95173
+ if (parametersWithPrecedingObjectRestOrSpread === null || parametersWithPrecedingObjectRestOrSpread === void 0 ? void 0 : parametersWithPrecedingObjectRestOrSpread.has(node)) {
95174
+ return factory.updateParameterDeclaration(node,
95175
+ /*decorators*/ undefined,
95176
+ /*modifiers*/ undefined, node.dotDotDotToken, ts.isBindingPattern(node.name) ? factory.getGeneratedNameForNode(node) : node.name,
95177
+ /*questionToken*/ undefined,
95178
+ /*type*/ undefined,
95179
+ /*initializer*/ undefined);
95180
+ }
95128
95181
  if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
95129
95182
  // Binding patterns are converted into a generated name and are
95130
95183
  // evaluated inside the function body.
@@ -95136,85 +95189,119 @@ var ts;
95136
95189
  }
95137
95190
  return ts.visitEachChild(node, visitor, context);
95138
95191
  }
95192
+ function collectParametersWithPrecedingObjectRestOrSpread(node) {
95193
+ var parameters;
95194
+ for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
95195
+ var parameter = _a[_i];
95196
+ if (parameters) {
95197
+ parameters.add(parameter);
95198
+ }
95199
+ else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
95200
+ parameters = new ts.Set();
95201
+ }
95202
+ }
95203
+ return parameters;
95204
+ }
95139
95205
  function visitConstructorDeclaration(node) {
95140
95206
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95141
- enclosingFunctionFlags = 0 /* Normal */;
95207
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95208
+ enclosingFunctionFlags = ts.getFunctionFlags(node);
95209
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95142
95210
  var updated = factory.updateConstructorDeclaration(node,
95143
- /*decorators*/ undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
95211
+ /*decorators*/ undefined, node.modifiers, ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node));
95144
95212
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95213
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95145
95214
  return updated;
95146
95215
  }
95147
95216
  function visitGetAccessorDeclaration(node) {
95148
95217
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95149
- enclosingFunctionFlags = 0 /* Normal */;
95218
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95219
+ enclosingFunctionFlags = ts.getFunctionFlags(node);
95220
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95150
95221
  var updated = factory.updateGetAccessorDeclaration(node,
95151
- /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context),
95222
+ /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context),
95152
95223
  /*type*/ undefined, transformFunctionBody(node));
95153
95224
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95225
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95154
95226
  return updated;
95155
95227
  }
95156
95228
  function visitSetAccessorDeclaration(node) {
95157
95229
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95158
- enclosingFunctionFlags = 0 /* Normal */;
95230
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95231
+ enclosingFunctionFlags = ts.getFunctionFlags(node);
95232
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95159
95233
  var updated = factory.updateSetAccessorDeclaration(node,
95160
- /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
95234
+ /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node));
95161
95235
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95236
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95162
95237
  return updated;
95163
95238
  }
95164
95239
  function visitMethodDeclaration(node) {
95165
95240
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95241
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95166
95242
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95243
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95167
95244
  var updated = factory.updateMethodDeclaration(node,
95168
95245
  /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */
95169
95246
  ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
95170
95247
  : node.modifiers, enclosingFunctionFlags & 2 /* Async */
95171
95248
  ? undefined
95172
95249
  : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(/*questionToken*/ undefined, visitor, ts.isToken),
95173
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95250
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
95174
95251
  /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
95175
95252
  ? transformAsyncGeneratorFunctionBody(node)
95176
95253
  : transformFunctionBody(node));
95177
95254
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95255
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95178
95256
  return updated;
95179
95257
  }
95180
95258
  function visitFunctionDeclaration(node) {
95181
95259
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95260
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95182
95261
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95262
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95183
95263
  var updated = factory.updateFunctionDeclaration(node,
95184
95264
  /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */
95185
95265
  ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
95186
95266
  : node.modifiers, enclosingFunctionFlags & 2 /* Async */
95187
95267
  ? undefined
95188
95268
  : node.asteriskToken, node.name,
95189
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95269
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
95190
95270
  /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
95191
95271
  ? transformAsyncGeneratorFunctionBody(node)
95192
95272
  : transformFunctionBody(node));
95193
95273
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95274
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95194
95275
  return updated;
95195
95276
  }
95196
95277
  function visitArrowFunction(node) {
95197
95278
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95279
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95198
95280
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95281
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95199
95282
  var updated = factory.updateArrowFunction(node, node.modifiers,
95200
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95283
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
95201
95284
  /*type*/ undefined, node.equalsGreaterThanToken, transformFunctionBody(node));
95202
95285
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95286
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95203
95287
  return updated;
95204
95288
  }
95205
95289
  function visitFunctionExpression(node) {
95206
95290
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95291
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95207
95292
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95293
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95208
95294
  var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */
95209
95295
  ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
95210
95296
  : node.modifiers, enclosingFunctionFlags & 2 /* Async */
95211
95297
  ? undefined
95212
95298
  : node.asteriskToken, node.name,
95213
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95299
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
95214
95300
  /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
95215
95301
  ? transformAsyncGeneratorFunctionBody(node)
95216
95302
  : transformFunctionBody(node));
95217
95303
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95304
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95218
95305
  return updated;
95219
95306
  }
95220
95307
  function transformAsyncGeneratorFunctionBody(node) {
@@ -95275,16 +95362,71 @@ var ts;
95275
95362
  return body;
95276
95363
  }
95277
95364
  function appendObjectRestAssignmentsIfNeeded(statements, node) {
95365
+ var containsPrecedingObjectRestOrSpread = false;
95278
95366
  for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
95279
95367
  var parameter = _a[_i];
95280
- if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
95281
- var temp = factory.getGeneratedNameForNode(parameter);
95282
- var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, temp,
95368
+ if (containsPrecedingObjectRestOrSpread) {
95369
+ if (ts.isBindingPattern(parameter.name)) {
95370
+ // In cases where a binding pattern is simply '[]' or '{}',
95371
+ // we usually don't want to emit a var declaration; however, in the presence
95372
+ // of an initializer, we must emit that expression to preserve side effects.
95373
+ //
95374
+ // NOTE: see `insertDefaultValueAssignmentForBindingPattern` in es2015.ts
95375
+ if (parameter.name.elements.length > 0) {
95376
+ var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter));
95377
+ if (ts.some(declarations)) {
95378
+ var declarationList = factory.createVariableDeclarationList(declarations);
95379
+ var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList);
95380
+ ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
95381
+ statements = ts.append(statements, statement);
95382
+ }
95383
+ }
95384
+ else if (parameter.initializer) {
95385
+ var name = factory.getGeneratedNameForNode(parameter);
95386
+ var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression);
95387
+ var assignment = factory.createAssignment(name, initializer);
95388
+ var statement = factory.createExpressionStatement(assignment);
95389
+ ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
95390
+ statements = ts.append(statements, statement);
95391
+ }
95392
+ }
95393
+ else if (parameter.initializer) {
95394
+ // Converts a parameter initializer into a function body statement, i.e.:
95395
+ //
95396
+ // function f(x = 1) { }
95397
+ //
95398
+ // becomes
95399
+ //
95400
+ // function f(x) {
95401
+ // if (typeof x === "undefined") { x = 1; }
95402
+ // }
95403
+ var name = factory.cloneNode(parameter.name);
95404
+ ts.setTextRange(name, parameter.name);
95405
+ ts.setEmitFlags(name, 48 /* NoSourceMap */);
95406
+ var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression);
95407
+ ts.addEmitFlags(initializer, 48 /* NoSourceMap */ | 1536 /* NoComments */);
95408
+ var assignment = factory.createAssignment(name, initializer);
95409
+ ts.setTextRange(assignment, parameter);
95410
+ ts.setEmitFlags(assignment, 1536 /* NoComments */);
95411
+ var block = factory.createBlock([factory.createExpressionStatement(assignment)]);
95412
+ ts.setTextRange(block, parameter);
95413
+ ts.setEmitFlags(block, 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */);
95414
+ var typeCheck = factory.createTypeCheck(factory.cloneNode(parameter.name), "undefined");
95415
+ var statement = factory.createIfStatement(typeCheck, block);
95416
+ ts.startOnNewLine(statement);
95417
+ ts.setTextRange(statement, parameter);
95418
+ ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */);
95419
+ statements = ts.append(statements, statement);
95420
+ }
95421
+ }
95422
+ else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
95423
+ containsPrecedingObjectRestOrSpread = true;
95424
+ var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter),
95283
95425
  /*doNotRecordTempVariablesInLine*/ false,
95284
95426
  /*skipInitializer*/ true);
95285
95427
  if (ts.some(declarations)) {
95286
- var statement = factory.createVariableStatement(
95287
- /*modifiers*/ undefined, factory.createVariableDeclarationList(declarations));
95428
+ var declarationList = factory.createVariableDeclarationList(declarations);
95429
+ var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList);
95288
95430
  ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
95289
95431
  statements = ts.append(statements, statement);
95290
95432
  }
@@ -98535,10 +98677,12 @@ var ts;
98535
98677
  // variables declared in the loop initializer that will be changed inside the loop
98536
98678
  var loopOutParameters = [];
98537
98679
  if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) {
98538
- var hasCapturedBindingsInForInitializer = shouldConvertInitializerOfForStatement(node);
98680
+ var hasCapturedBindingsInForHead = shouldConvertInitializerOfForStatement(node) ||
98681
+ shouldConvertConditionOfForStatement(node) ||
98682
+ shouldConvertIncrementorOfForStatement(node);
98539
98683
  for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) {
98540
98684
  var decl = _a[_i];
98541
- processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
98685
+ processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForHead);
98542
98686
  }
98543
98687
  }
98544
98688
  var currentState = { loopParameters: loopParameters, loopOutParameters: loopOutParameters };
@@ -98892,27 +99036,33 @@ var ts;
98892
99036
  caseClauses.push(factory.createCaseClause(factory.createStringLiteral(labelMarker), statements));
98893
99037
  });
98894
99038
  }
98895
- function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer) {
99039
+ function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForHead) {
98896
99040
  var name = decl.name;
98897
99041
  if (ts.isBindingPattern(name)) {
98898
99042
  for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
98899
99043
  var element = _a[_i];
98900
99044
  if (!ts.isOmittedExpression(element)) {
98901
- processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
99045
+ processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForHead);
98902
99046
  }
98903
99047
  }
98904
99048
  }
98905
99049
  else {
98906
99050
  loopParameters.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name));
98907
99051
  var checkFlags = resolver.getNodeCheckFlags(decl);
98908
- if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForInitializer) {
99052
+ if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) {
98909
99053
  var outParamName = factory.createUniqueName("out_" + ts.idText(name));
98910
99054
  var flags = 0;
98911
99055
  if (checkFlags & 4194304 /* NeedsLoopOutParameter */) {
98912
99056
  flags |= 1 /* Body */;
98913
99057
  }
98914
- if (ts.isForStatement(container) && container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
98915
- flags |= 2 /* Initializer */;
99058
+ if (ts.isForStatement(container)) {
99059
+ if (container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
99060
+ flags |= 2 /* Initializer */;
99061
+ }
99062
+ if (container.condition && resolver.isBindingCapturedByNode(container.condition, decl) ||
99063
+ container.incrementor && resolver.isBindingCapturedByNode(container.incrementor, decl)) {
99064
+ flags |= 1 /* Body */;
99065
+ }
98916
99066
  }
98917
99067
  loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName });
98918
99068
  }
@@ -126349,7 +126499,7 @@ var ts;
126349
126499
  parts.push(linkTextPart(text));
126350
126500
  }
126351
126501
  else {
126352
- parts.push(linkTextPart(name + (suffix ? "" : " ") + text));
126502
+ parts.push(linkTextPart(name + (suffix || text.indexOf("://") === 0 ? "" : " ") + text));
126353
126503
  }
126354
126504
  }
126355
126505
  parts.push(linkPart("}"));
@@ -127170,15 +127320,35 @@ var ts;
127170
127320
  return ts.isArray(valueOrArray) ? ts.first(valueOrArray) : valueOrArray;
127171
127321
  }
127172
127322
  ts.firstOrOnly = firstOrOnly;
127323
+ function getNamesForExportedSymbol(symbol, scriptTarget) {
127324
+ if (needsNameFromDeclaration(symbol)) {
127325
+ var fromDeclaration = getDefaultLikeExportNameFromDeclaration(symbol);
127326
+ if (fromDeclaration)
127327
+ return fromDeclaration;
127328
+ var fileNameCase = ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, /*preferCapitalized*/ false);
127329
+ var capitalized = ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, /*preferCapitalized*/ true);
127330
+ if (fileNameCase === capitalized)
127331
+ return fileNameCase;
127332
+ return [fileNameCase, capitalized];
127333
+ }
127334
+ return symbol.name;
127335
+ }
127336
+ ts.getNamesForExportedSymbol = getNamesForExportedSymbol;
127173
127337
  function getNameForExportedSymbol(symbol, scriptTarget, preferCapitalized) {
127174
- if (!(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */)) {
127338
+ if (needsNameFromDeclaration(symbol)) {
127175
127339
  // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase.
127176
- return ts.firstDefined(symbol.declarations, function (d) { var _a; return ts.isExportAssignment(d) ? (_a = ts.tryCast(ts.skipOuterExpressions(d.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text : undefined; })
127340
+ return getDefaultLikeExportNameFromDeclaration(symbol)
127177
127341
  || ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, !!preferCapitalized);
127178
127342
  }
127179
127343
  return symbol.name;
127180
127344
  }
127181
127345
  ts.getNameForExportedSymbol = getNameForExportedSymbol;
127346
+ function needsNameFromDeclaration(symbol) {
127347
+ return !(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */);
127348
+ }
127349
+ function getDefaultLikeExportNameFromDeclaration(symbol) {
127350
+ return ts.firstDefined(symbol.declarations, function (d) { var _a; return ts.isExportAssignment(d) ? (_a = ts.tryCast(ts.skipOuterExpressions(d.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text : undefined; });
127351
+ }
127182
127352
  function getSymbolParentOrFail(symbol) {
127183
127353
  var _a;
127184
127354
  return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: " + ts.Debug.formatSymbolFlags(symbol.flags) + ". " +
@@ -127348,9 +127518,11 @@ var ts;
127348
127518
  // 3. Otherwise, we have a default/namespace import that can be imported by any name, and
127349
127519
  // `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to
127350
127520
  // get a better name.
127351
- var importedName = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
127521
+ var names = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
127352
127522
  ? ts.unescapeLeadingUnderscores(symbolTableKey)
127353
- : ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
127523
+ : ts.getNamesForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
127524
+ var symbolName = typeof names === "string" ? names : names[0];
127525
+ var capitalizedSymbolName = typeof names === "string" ? undefined : names[1];
127354
127526
  var moduleName = ts.stripQuotes(moduleSymbol.name);
127355
127527
  var id = exportInfoId++;
127356
127528
  var target = ts.skipAlias(symbol, checker);
@@ -127358,10 +127530,11 @@ var ts;
127358
127530
  var storedModuleSymbol = moduleSymbol.flags & 33554432 /* Transient */ ? undefined : moduleSymbol;
127359
127531
  if (!storedSymbol || !storedModuleSymbol)
127360
127532
  symbols.set(id, [symbol, moduleSymbol]);
127361
- exportInfo.add(key(importedName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), {
127533
+ exportInfo.add(key(symbolName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), {
127362
127534
  id: id,
127363
127535
  symbolTableKey: symbolTableKey,
127364
- symbolName: importedName,
127536
+ symbolName: symbolName,
127537
+ capitalizedSymbolName: capitalizedSymbolName,
127365
127538
  moduleName: moduleName,
127366
127539
  moduleFile: moduleFile,
127367
127540
  moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName,
@@ -127379,21 +127552,18 @@ var ts;
127379
127552
  var result = exportInfo.get(key);
127380
127553
  return result === null || result === void 0 ? void 0 : result.map(rehydrateCachedInfo);
127381
127554
  },
127382
- forEach: function (importingFile, action) {
127555
+ search: function (importingFile, preferCapitalized, matches, action) {
127383
127556
  if (importingFile !== usableByFileName)
127384
127557
  return;
127385
127558
  exportInfo.forEach(function (info, key) {
127386
127559
  var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
127387
- var rehydrated = info.map(rehydrateCachedInfo);
127388
- var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
127389
- if (filtered.length) {
127390
- action(filtered, function (preferCapitalized) {
127391
- var _a = rehydrated[0], symbol = _a.symbol, exportKind = _a.exportKind;
127392
- var namedSymbol = exportKind === 1 /* Default */ && ts.getLocalSymbolForExportDefault(symbol) || symbol;
127393
- return preferCapitalized
127394
- ? ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined, /*preferCapitalized*/ true)
127395
- : symbolName;
127396
- }, !!ambientModuleName, key);
127560
+ var name = preferCapitalized && info[0].capitalizedSymbolName || symbolName;
127561
+ if (matches(name, info[0].targetFlags)) {
127562
+ var rehydrated = info.map(rehydrateCachedInfo);
127563
+ var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
127564
+ if (filtered.length) {
127565
+ action(filtered, name, !!ambientModuleName, key);
127566
+ }
127397
127567
  }
127398
127568
  });
127399
127569
  },
@@ -131509,44 +131679,47 @@ var ts;
131509
131679
  var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
131510
131680
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
131511
131681
  resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
131512
- exportInfo.forEach(sourceFile.path, function (info, getSymbolName, isFromAmbientModule, exportMapKey) {
131513
- var symbolName = getSymbolName(/*preferCapitalized*/ isRightOfOpenTag);
131682
+ exportInfo.search(sourceFile.path,
131683
+ /*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
131514
131684
  if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
131515
- return;
131685
+ return false;
131516
131686
  if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
131517
- return;
131518
- // `targetFlags` should be the same for each `info`
131519
- if (!isTypeOnlyLocation && !importCompletionNode && !(info[0].targetFlags & 111551 /* Value */))
131520
- return;
131521
- if (isTypeOnlyLocation && !(info[0].targetFlags & (1536 /* Module */ | 788968 /* Type */)))
131522
- return;
131687
+ return false;
131688
+ if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* Value */))
131689
+ return false;
131690
+ if (isTypeOnlyLocation && !(targetFlags & (1536 /* Module */ | 788968 /* Type */)))
131691
+ return false;
131523
131692
  // Do not try to auto-import something with a lowercase first letter for a JSX tag
131524
131693
  var firstChar = symbolName.charCodeAt(0);
131525
131694
  if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */))
131695
+ return false;
131696
+ if (detailsEntryId)
131697
+ return true;
131698
+ return charactersFuzzyMatchInString(symbolName, lowerCaseTokenText);
131699
+ }, function (info, symbolName, isFromAmbientModule, exportMapKey) {
131700
+ if (detailsEntryId && !ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); })) {
131526
131701
  return;
131527
- var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); });
131528
- if (isCompletionDetailsMatch || !detailsEntryId && charactersFuzzyMatchInString(symbolName, lowerCaseTokenText)) {
131529
- var defaultExportInfo = ts.find(info, isImportableExportInfo);
131530
- if (!defaultExportInfo) {
131531
- return;
131532
- }
131533
- // If we don't need to resolve module specifiers, we can use any re-export that is importable at all
131534
- // (We need to ensure that at least one is importable to show a completion.)
131535
- var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo_1 = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
131536
- var isDefaultExport = exportInfo_1.exportKind === 1 /* Default */;
131537
- var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo_1.symbol) || exportInfo_1.symbol;
131538
- pushAutoImportSymbol(symbol, {
131539
- kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
131540
- moduleSpecifier: moduleSpecifier,
131541
- symbolName: symbolName,
131542
- exportMapKey: exportMapKey,
131543
- exportName: exportInfo_1.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo_1.symbol.name,
131544
- fileName: exportInfo_1.moduleFileName,
131545
- isDefaultExport: isDefaultExport,
131546
- moduleSymbol: exportInfo_1.moduleSymbol,
131547
- isFromPackageJson: exportInfo_1.isFromPackageJson,
131548
- });
131549
131702
  }
131703
+ var defaultExportInfo = ts.find(info, isImportableExportInfo);
131704
+ if (!defaultExportInfo) {
131705
+ return;
131706
+ }
131707
+ // If we don't need to resolve module specifiers, we can use any re-export that is importable at all
131708
+ // (We need to ensure that at least one is importable to show a completion.)
131709
+ var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
131710
+ var isDefaultExport = exportInfo.exportKind === 1 /* Default */;
131711
+ var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol;
131712
+ pushAutoImportSymbol(symbol, {
131713
+ kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
131714
+ moduleSpecifier: moduleSpecifier,
131715
+ symbolName: symbolName,
131716
+ exportMapKey: exportMapKey,
131717
+ exportName: exportInfo.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo.symbol.name,
131718
+ fileName: exportInfo.moduleFileName,
131719
+ isDefaultExport: isDefaultExport,
131720
+ moduleSymbol: exportInfo.moduleSymbol,
131721
+ isFromPackageJson: exportInfo.isFromPackageJson,
131722
+ });
131550
131723
  });
131551
131724
  hasUnresolvedAutoImports = context.resolutionLimitExceeded();
131552
131725
  });
@@ -137485,7 +137658,27 @@ var ts;
137485
137658
  case 326 /* JSDocAugmentsTag */:
137486
137659
  return withNode(tag.class);
137487
137660
  case 342 /* JSDocTemplateTag */:
137488
- return addComment(tag.typeParameters.map(function (tp) { return tp.getText(); }).join(", "));
137661
+ var templateTag = tag;
137662
+ var displayParts_3 = [];
137663
+ if (templateTag.constraint) {
137664
+ displayParts_3.push(ts.textPart(templateTag.constraint.getText()));
137665
+ }
137666
+ if (ts.length(templateTag.typeParameters)) {
137667
+ if (ts.length(displayParts_3)) {
137668
+ displayParts_3.push(ts.spacePart());
137669
+ }
137670
+ var lastTypeParameter_1 = templateTag.typeParameters[templateTag.typeParameters.length - 1];
137671
+ ts.forEach(templateTag.typeParameters, function (tp) {
137672
+ displayParts_3.push(namePart(tp.getText()));
137673
+ if (lastTypeParameter_1 !== tp) {
137674
+ displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]);
137675
+ }
137676
+ });
137677
+ }
137678
+ if (comment) {
137679
+ displayParts_3.push.apply(displayParts_3, __spreadArray([ts.spacePart()], getDisplayPartsFromComment(comment, checker), true));
137680
+ }
137681
+ return displayParts_3;
137489
137682
  case 341 /* JSDocTypeTag */:
137490
137683
  return withNode(tag.typeExpression);
137491
137684
  case 343 /* JSDocTypedefTag */:
@@ -138973,7 +139166,7 @@ var ts;
138973
139166
  newImportSpecifiers.push(ts.factory.createImportSpecifier(/*isTypeOnly*/ false, ts.factory.createIdentifier("default"), defaultImport.importClause.name)); // TODO: GH#18217
138974
139167
  }
138975
139168
  }
138976
- newImportSpecifiers.push.apply(newImportSpecifiers, ts.flatMap(namedImports, function (i) { return i.importClause.namedBindings.elements; })); // TODO: GH#18217
139169
+ newImportSpecifiers.push.apply(newImportSpecifiers, getNewImportSpecifiers(namedImports));
138977
139170
  var sortedImportSpecifiers = sortSpecifiers(newImportSpecifiers);
138978
139171
  var importDecl = defaultImports.length > 0
138979
139172
  ? defaultImports[0]
@@ -139183,6 +139376,21 @@ var ts;
139183
139376
  return 6;
139184
139377
  }
139185
139378
  }
139379
+ function getNewImportSpecifiers(namedImports) {
139380
+ return ts.flatMap(namedImports, function (namedImport) {
139381
+ return ts.map(tryGetNamedBindingElements(namedImport), function (importSpecifier) {
139382
+ return importSpecifier.name && importSpecifier.propertyName && importSpecifier.name.escapedText === importSpecifier.propertyName.escapedText
139383
+ ? ts.factory.updateImportSpecifier(importSpecifier, importSpecifier.isTypeOnly, /*propertyName*/ undefined, importSpecifier.name)
139384
+ : importSpecifier;
139385
+ });
139386
+ });
139387
+ }
139388
+ function tryGetNamedBindingElements(namedImport) {
139389
+ var _a;
139390
+ return ((_a = namedImport.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings) && ts.isNamedImports(namedImport.importClause.namedBindings)
139391
+ ? namedImport.importClause.namedBindings.elements
139392
+ : undefined;
139393
+ }
139186
139394
  })(OrganizeImports = ts.OrganizeImports || (ts.OrganizeImports = {}));
139187
139395
  })(ts || (ts = {}));
139188
139396
  /* @internal */
@@ -140896,12 +141104,12 @@ var ts;
140896
141104
  : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex };
140897
141105
  }
140898
141106
  SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions;
140899
- function getArgumentOrParameterListInfo(node, sourceFile) {
141107
+ function getArgumentOrParameterListInfo(node, position, sourceFile) {
140900
141108
  var info = getArgumentOrParameterListAndIndex(node, sourceFile);
140901
141109
  if (!info)
140902
141110
  return undefined;
140903
141111
  var list = info.list, argumentIndex = info.argumentIndex;
140904
- var argumentCount = getArgumentCount(list);
141112
+ var argumentCount = getArgumentCount(list, /*ignoreTrailingComma*/ ts.isInString(sourceFile, position, node));
140905
141113
  if (argumentIndex !== 0) {
140906
141114
  ts.Debug.assertLessThan(argumentIndex, argumentCount);
140907
141115
  }
@@ -140947,7 +141155,7 @@ var ts;
140947
141155
  // Case 3:
140948
141156
  // foo<T#, U#>(a#, #b#) -> The token is buried inside a list, and should give signature help
140949
141157
  // Find out if 'node' is an argument, a type argument, or neither
140950
- var info = getArgumentOrParameterListInfo(node, sourceFile);
141158
+ var info = getArgumentOrParameterListInfo(node, position, sourceFile);
140951
141159
  if (!info)
140952
141160
  return undefined;
140953
141161
  var list = info.list, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
@@ -141016,8 +141224,8 @@ var ts;
141016
141224
  function countBinaryExpressionParameters(b) {
141017
141225
  return ts.isBinaryExpression(b.left) ? countBinaryExpressionParameters(b.left) + 1 : 2;
141018
141226
  }
141019
- function tryGetParameterInfo(startingToken, _position, sourceFile, checker) {
141020
- var info = getContextualSignatureLocationInfo(startingToken, sourceFile, checker);
141227
+ function tryGetParameterInfo(startingToken, position, sourceFile, checker) {
141228
+ var info = getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker);
141021
141229
  if (!info)
141022
141230
  return undefined;
141023
141231
  var contextualType = info.contextualType, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
@@ -141029,7 +141237,7 @@ var ts;
141029
141237
  var invocation = { kind: 2 /* Contextual */, signature: ts.first(signatures), node: startingToken, symbol: chooseBetterSymbol(nonNullableContextualType.symbol) };
141030
141238
  return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount };
141031
141239
  }
141032
- function getContextualSignatureLocationInfo(startingToken, sourceFile, checker) {
141240
+ function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) {
141033
141241
  if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */)
141034
141242
  return undefined;
141035
141243
  var parent = startingToken.parent;
@@ -141038,7 +141246,7 @@ var ts;
141038
141246
  case 168 /* MethodDeclaration */:
141039
141247
  case 212 /* FunctionExpression */:
141040
141248
  case 213 /* ArrowFunction */:
141041
- var info = getArgumentOrParameterListInfo(startingToken, sourceFile);
141249
+ var info = getArgumentOrParameterListInfo(startingToken, position, sourceFile);
141042
141250
  if (!info)
141043
141251
  return undefined;
141044
141252
  var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
@@ -141085,7 +141293,7 @@ var ts;
141085
141293
  }
141086
141294
  return argumentIndex;
141087
141295
  }
141088
- function getArgumentCount(argumentsList) {
141296
+ function getArgumentCount(argumentsList, ignoreTrailingComma) {
141089
141297
  // The argument count for a list is normally the number of non-comma children it has.
141090
141298
  // For example, if you have "Foo(a,b)" then there will be three children of the arg
141091
141299
  // list 'a' '<comma>' 'b'. So, in this case the arg count will be 2. However, there
@@ -141099,7 +141307,7 @@ var ts;
141099
141307
  // arg count of 3.
141100
141308
  var listChildren = argumentsList.getChildren();
141101
141309
  var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; });
141102
- if (listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) {
141310
+ if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) {
141103
141311
  argumentCount++;
141104
141312
  }
141105
141313
  return argumentCount;
@@ -142045,7 +142253,7 @@ var ts;
142045
142253
  if (typeChecker.isArgumentsSymbol(symbol)) {
142046
142254
  return "local var" /* localVariableElement */;
142047
142255
  }
142048
- if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location)) {
142256
+ if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) {
142049
142257
  return "parameter" /* parameterElement */;
142050
142258
  }
142051
142259
  var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol);
@@ -142140,7 +142348,7 @@ var ts;
142140
142348
  var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol);
142141
142349
  var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */;
142142
142350
  var hasAddedSymbolInfo = false;
142143
- var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location);
142351
+ var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location);
142144
142352
  var type;
142145
142353
  var printer;
142146
142354
  var documentationFromAlias;
@@ -142553,6 +142761,18 @@ var ts;
142553
142761
  }
142554
142762
  }
142555
142763
  }
142764
+ if (documentation.length === 0 && ts.isIdentifier(location) && symbol.valueDeclaration && ts.isBindingElement(symbol.valueDeclaration)) {
142765
+ var declaration = symbol.valueDeclaration;
142766
+ var parent = declaration.parent;
142767
+ if (ts.isIdentifier(declaration.name) && ts.isObjectBindingPattern(parent)) {
142768
+ var name_4 = ts.getTextOfIdentifierOrLiteral(declaration.name);
142769
+ var objectType = typeChecker.getTypeAtLocation(parent);
142770
+ documentation = ts.firstDefined(objectType.isUnion() ? objectType.types : [objectType], function (t) {
142771
+ var prop = t.getProperty(name_4);
142772
+ return prop ? prop.getDocumentationComment(typeChecker) : undefined;
142773
+ }) || ts.emptyArray;
142774
+ }
142775
+ }
142556
142776
  if (tags.length === 0 && !hasMultipleSignatures) {
142557
142777
  tags = symbol.getContextualJsDocTags(enclosingDeclaration, typeChecker);
142558
142778
  }
@@ -156086,51 +156306,53 @@ var ts;
156086
156306
  (function (ts) {
156087
156307
  var refactor;
156088
156308
  (function (refactor) {
156309
+ var _a;
156089
156310
  var refactorName = "Convert import";
156090
- var namespaceToNamedAction = {
156091
- name: "Convert namespace import to named imports",
156092
- description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message,
156093
- kind: "refactor.rewrite.import.named",
156094
- };
156095
- var namedToNamespaceAction = {
156096
- name: "Convert named imports to namespace import",
156097
- description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message,
156098
- kind: "refactor.rewrite.import.namespace",
156099
- };
156311
+ var actions = (_a = {},
156312
+ _a[0 /* Named */] = {
156313
+ name: "Convert namespace import to named imports",
156314
+ description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message,
156315
+ kind: "refactor.rewrite.import.named",
156316
+ },
156317
+ _a[2 /* Namespace */] = {
156318
+ name: "Convert named imports to namespace import",
156319
+ description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message,
156320
+ kind: "refactor.rewrite.import.namespace",
156321
+ },
156322
+ _a[1 /* Default */] = {
156323
+ name: "Convert named imports to default import",
156324
+ description: ts.Diagnostics.Convert_named_imports_to_default_import.message,
156325
+ kind: "refactor.rewrite.import.default",
156326
+ },
156327
+ _a);
156100
156328
  refactor.registerRefactor(refactorName, {
156101
- kinds: [
156102
- namespaceToNamedAction.kind,
156103
- namedToNamespaceAction.kind
156104
- ],
156329
+ kinds: ts.getOwnValues(actions).map(function (a) { return a.kind; }),
156105
156330
  getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndNamespacedImports(context) {
156106
- var info = getImportToConvert(context, context.triggerReason === "invoked");
156331
+ var info = getImportConversionInfo(context, context.triggerReason === "invoked");
156107
156332
  if (!info)
156108
156333
  return ts.emptyArray;
156109
156334
  if (!refactor.isRefactorErrorInfo(info)) {
156110
- var namespaceImport = info.kind === 267 /* NamespaceImport */;
156111
- var action = namespaceImport ? namespaceToNamedAction : namedToNamespaceAction;
156335
+ var action = actions[info.convertTo];
156112
156336
  return [{ name: refactorName, description: action.description, actions: [action] }];
156113
156337
  }
156114
156338
  if (context.preferences.provideRefactorNotApplicableReason) {
156115
- return [
156116
- { name: refactorName, description: namespaceToNamedAction.description,
156117
- actions: [__assign(__assign({}, namespaceToNamedAction), { notApplicableReason: info.error })] },
156118
- { name: refactorName, description: namedToNamespaceAction.description,
156119
- actions: [__assign(__assign({}, namedToNamespaceAction), { notApplicableReason: info.error })] }
156120
- ];
156339
+ return ts.getOwnValues(actions).map(function (action) { return ({
156340
+ name: refactorName,
156341
+ description: action.description,
156342
+ actions: [__assign(__assign({}, action), { notApplicableReason: info.error })]
156343
+ }); });
156121
156344
  }
156122
156345
  return ts.emptyArray;
156123
156346
  },
156124
156347
  getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndNamespacedImports(context, actionName) {
156125
- ts.Debug.assert(actionName === namespaceToNamedAction.name || actionName === namedToNamespaceAction.name, "Unexpected action name");
156126
- var info = getImportToConvert(context);
156348
+ ts.Debug.assert(ts.some(ts.getOwnValues(actions), function (action) { return action.name === actionName; }), "Unexpected action name");
156349
+ var info = getImportConversionInfo(context);
156127
156350
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
156128
156351
  var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, info); });
156129
156352
  return { edits: edits, renameFilename: undefined, renameLocation: undefined };
156130
156353
  }
156131
156354
  });
156132
- // Can convert imports of the form `import * as m from "m";` or `import d, { x, y } from "m";`.
156133
- function getImportToConvert(context, considerPartialSpans) {
156355
+ function getImportConversionInfo(context, considerPartialSpans) {
156134
156356
  if (considerPartialSpans === void 0) { considerPartialSpans = true; }
156135
156357
  var file = context.file;
156136
156358
  var span = ts.getRefactorContextSpan(context);
@@ -156149,15 +156371,23 @@ var ts;
156149
156371
  if (!importClause.namedBindings) {
156150
156372
  return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_namespace_import_or_named_imports) };
156151
156373
  }
156152
- return importClause.namedBindings;
156374
+ if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
156375
+ return { convertTo: 0 /* Named */, import: importClause.namedBindings };
156376
+ }
156377
+ var compilerOptions = context.program.getCompilerOptions();
156378
+ var shouldUseDefault = ts.getAllowSyntheticDefaultImports(compilerOptions)
156379
+ && isExportEqualsModule(importClause.parent.moduleSpecifier, context.program.getTypeChecker());
156380
+ return shouldUseDefault
156381
+ ? { convertTo: 1 /* Default */, import: importClause.namedBindings }
156382
+ : { convertTo: 2 /* Namespace */, import: importClause.namedBindings };
156153
156383
  }
156154
- function doChange(sourceFile, program, changes, toConvert) {
156384
+ function doChange(sourceFile, program, changes, info) {
156155
156385
  var checker = program.getTypeChecker();
156156
- if (toConvert.kind === 267 /* NamespaceImport */) {
156157
- doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
156386
+ if (info.convertTo === 0 /* Named */) {
156387
+ doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
156158
156388
  }
156159
156389
  else {
156160
- doChangeNamedToNamespace(sourceFile, checker, changes, toConvert);
156390
+ doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, info.import, info.convertTo === 1 /* Default */);
156161
156391
  }
156162
156392
  }
156163
156393
  function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) {
@@ -156207,7 +156437,7 @@ var ts;
156207
156437
  function getLeftOfPropertyAccessOrQualifiedName(propertyAccessOrQualifiedName) {
156208
156438
  return ts.isPropertyAccessExpression(propertyAccessOrQualifiedName) ? propertyAccessOrQualifiedName.expression : propertyAccessOrQualifiedName.left;
156209
156439
  }
156210
- function doChangeNamedToNamespace(sourceFile, checker, changes, toConvert) {
156440
+ function doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, toConvert, shouldUseDefault) {
156211
156441
  var importDecl = toConvert.parent.parent;
156212
156442
  var moduleSpecifier = importDecl.moduleSpecifier;
156213
156443
  var toConvertSymbols = new ts.Set();
@@ -156258,7 +156488,9 @@ var ts;
156258
156488
  var element = _a[_i];
156259
156489
  _loop_17(element);
156260
156490
  }
156261
- changes.replaceNode(sourceFile, toConvert, ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName)));
156491
+ changes.replaceNode(sourceFile, toConvert, shouldUseDefault
156492
+ ? ts.factory.createIdentifier(namespaceImportName)
156493
+ : ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName)));
156262
156494
  if (neededNamedImports.size) {
156263
156495
  var newNamedImports = ts.arrayFrom(neededNamedImports.values()).map(function (element) {
156264
156496
  return ts.factory.createImportSpecifier(element.isTypeOnly, element.propertyName && ts.factory.createIdentifier(element.propertyName.text), ts.factory.createIdentifier(element.name.text));
@@ -156266,6 +156498,13 @@ var ts;
156266
156498
  changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, newNamedImports));
156267
156499
  }
156268
156500
  }
156501
+ function isExportEqualsModule(moduleSpecifier, checker) {
156502
+ var externalModule = checker.resolveExternalModuleName(moduleSpecifier);
156503
+ if (!externalModule)
156504
+ return false;
156505
+ var exportEquals = checker.resolveExternalModuleSymbol(externalModule);
156506
+ return externalModule !== exportEquals;
156507
+ }
156269
156508
  function updateImport(old, defaultImportName, elements) {
156270
156509
  return ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImportName, elements && elements.length ? ts.factory.createNamedImports(elements) : undefined), old.moduleSpecifier, /*assertClause*/ undefined);
156271
156510
  }
@@ -159545,7 +159784,7 @@ var ts;
159545
159784
  var convertParamsToDestructuredObject;
159546
159785
  (function (convertParamsToDestructuredObject) {
159547
159786
  var refactorName = "Convert parameters to destructured object";
159548
- var minimumParameterLength = 2;
159787
+ var minimumParameterLength = 1;
159549
159788
  var refactorDescription = ts.getLocaleSpecificMessage(ts.Diagnostics.Convert_parameters_to_destructured_object);
159550
159789
  var toDestructuredAction = {
159551
159790
  name: refactorName,