@typescript-deploys/pr-build 4.6.0-pr-47607-13 → 4.6.0-pr-47607-31

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-insiders.20220127";
297
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220207";
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;
@@ -5919,704 +5919,6 @@ var ts;
5919
5919
  },
5920
5920
  };
5921
5921
  })(ts || (ts = {}));
5922
- /* @internal */
5923
- var ts;
5924
- (function (ts) {
5925
- /**
5926
- * Internally, we represent paths as strings with '/' as the directory separator.
5927
- * When we make system calls (eg: LanguageServiceHost.getDirectory()),
5928
- * we expect the host to correctly handle paths in our specified format.
5929
- */
5930
- ts.directorySeparator = "/";
5931
- ts.altDirectorySeparator = "\\";
5932
- var urlSchemeSeparator = "://";
5933
- var backslashRegExp = /\\/g;
5934
- //// Path Tests
5935
- /**
5936
- * Determines whether a charCode corresponds to `/` or `\`.
5937
- */
5938
- function isAnyDirectorySeparator(charCode) {
5939
- return charCode === 47 /* slash */ || charCode === 92 /* backslash */;
5940
- }
5941
- ts.isAnyDirectorySeparator = isAnyDirectorySeparator;
5942
- /**
5943
- * Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.).
5944
- */
5945
- function isUrl(path) {
5946
- return getEncodedRootLength(path) < 0;
5947
- }
5948
- ts.isUrl = isUrl;
5949
- /**
5950
- * Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path
5951
- * like `c:`, `c:\` or `c:/`).
5952
- */
5953
- function isRootedDiskPath(path) {
5954
- return getEncodedRootLength(path) > 0;
5955
- }
5956
- ts.isRootedDiskPath = isRootedDiskPath;
5957
- /**
5958
- * Determines whether a path consists only of a path root.
5959
- */
5960
- function isDiskPathRoot(path) {
5961
- var rootLength = getEncodedRootLength(path);
5962
- return rootLength > 0 && rootLength === path.length;
5963
- }
5964
- ts.isDiskPathRoot = isDiskPathRoot;
5965
- /**
5966
- * Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.).
5967
- *
5968
- * ```ts
5969
- * // POSIX
5970
- * pathIsAbsolute("/path/to/file.ext") === true
5971
- * // DOS
5972
- * pathIsAbsolute("c:/path/to/file.ext") === true
5973
- * // URL
5974
- * pathIsAbsolute("file:///path/to/file.ext") === true
5975
- * // Non-absolute
5976
- * pathIsAbsolute("path/to/file.ext") === false
5977
- * pathIsAbsolute("./path/to/file.ext") === false
5978
- * ```
5979
- */
5980
- function pathIsAbsolute(path) {
5981
- return getEncodedRootLength(path) !== 0;
5982
- }
5983
- ts.pathIsAbsolute = pathIsAbsolute;
5984
- /**
5985
- * Determines whether a path starts with a relative path component (i.e. `.` or `..`).
5986
- */
5987
- function pathIsRelative(path) {
5988
- return /^\.\.?($|[\\/])/.test(path);
5989
- }
5990
- ts.pathIsRelative = pathIsRelative;
5991
- /**
5992
- * Determines whether a path is neither relative nor absolute, e.g. "path/to/file".
5993
- * Also known misleadingly as "non-relative".
5994
- */
5995
- function pathIsBareSpecifier(path) {
5996
- return !pathIsAbsolute(path) && !pathIsRelative(path);
5997
- }
5998
- ts.pathIsBareSpecifier = pathIsBareSpecifier;
5999
- function hasExtension(fileName) {
6000
- return ts.stringContains(getBaseFileName(fileName), ".");
6001
- }
6002
- ts.hasExtension = hasExtension;
6003
- function fileExtensionIs(path, extension) {
6004
- return path.length > extension.length && ts.endsWith(path, extension);
6005
- }
6006
- ts.fileExtensionIs = fileExtensionIs;
6007
- function fileExtensionIsOneOf(path, extensions) {
6008
- for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
6009
- var extension = extensions_1[_i];
6010
- if (fileExtensionIs(path, extension)) {
6011
- return true;
6012
- }
6013
- }
6014
- return false;
6015
- }
6016
- ts.fileExtensionIsOneOf = fileExtensionIsOneOf;
6017
- /**
6018
- * Determines whether a path has a trailing separator (`/` or `\\`).
6019
- */
6020
- function hasTrailingDirectorySeparator(path) {
6021
- return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1));
6022
- }
6023
- ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator;
6024
- //// Path Parsing
6025
- function isVolumeCharacter(charCode) {
6026
- return (charCode >= 97 /* a */ && charCode <= 122 /* z */) ||
6027
- (charCode >= 65 /* A */ && charCode <= 90 /* Z */);
6028
- }
6029
- function getFileUrlVolumeSeparatorEnd(url, start) {
6030
- var ch0 = url.charCodeAt(start);
6031
- if (ch0 === 58 /* colon */)
6032
- return start + 1;
6033
- if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) {
6034
- var ch2 = url.charCodeAt(start + 2);
6035
- if (ch2 === 97 /* a */ || ch2 === 65 /* A */)
6036
- return start + 3;
6037
- }
6038
- return -1;
6039
- }
6040
- /**
6041
- * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
6042
- * If the root is part of a URL, the twos-complement of the root length is returned.
6043
- */
6044
- function getEncodedRootLength(path) {
6045
- if (!path)
6046
- return 0;
6047
- var ch0 = path.charCodeAt(0);
6048
- // POSIX or UNC
6049
- if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) {
6050
- if (path.charCodeAt(1) !== ch0)
6051
- return 1; // POSIX: "/" (or non-normalized "\")
6052
- var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2);
6053
- if (p1 < 0)
6054
- return path.length; // UNC: "//server" or "\\server"
6055
- return p1 + 1; // UNC: "//server/" or "\\server\"
6056
- }
6057
- // DOS
6058
- if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) {
6059
- var ch2 = path.charCodeAt(2);
6060
- if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */)
6061
- return 3; // DOS: "c:/" or "c:\"
6062
- if (path.length === 2)
6063
- return 2; // DOS: "c:" (but not "c:d")
6064
- }
6065
- // URL
6066
- var schemeEnd = path.indexOf(urlSchemeSeparator);
6067
- if (schemeEnd !== -1) {
6068
- var authorityStart = schemeEnd + urlSchemeSeparator.length;
6069
- var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart);
6070
- if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path"
6071
- // For local "file" URLs, include the leading DOS volume (if present).
6072
- // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a
6073
- // special case interpreted as "the machine from which the URL is being interpreted".
6074
- var scheme = path.slice(0, schemeEnd);
6075
- var authority = path.slice(authorityStart, authorityEnd);
6076
- if (scheme === "file" && (authority === "" || authority === "localhost") &&
6077
- isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
6078
- var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
6079
- if (volumeSeparatorEnd !== -1) {
6080
- if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) {
6081
- // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/"
6082
- return ~(volumeSeparatorEnd + 1);
6083
- }
6084
- if (volumeSeparatorEnd === path.length) {
6085
- // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a"
6086
- // but not "file:///c:d" or "file:///c%3ad"
6087
- return ~volumeSeparatorEnd;
6088
- }
6089
- }
6090
- }
6091
- return ~(authorityEnd + 1); // URL: "file://server/", "http://server/"
6092
- }
6093
- return ~path.length; // URL: "file://server", "http://server"
6094
- }
6095
- // relative
6096
- return 0;
6097
- }
6098
- /**
6099
- * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
6100
- *
6101
- * For example:
6102
- * ```ts
6103
- * getRootLength("a") === 0 // ""
6104
- * getRootLength("/") === 1 // "/"
6105
- * getRootLength("c:") === 2 // "c:"
6106
- * getRootLength("c:d") === 0 // ""
6107
- * getRootLength("c:/") === 3 // "c:/"
6108
- * getRootLength("c:\\") === 3 // "c:\\"
6109
- * getRootLength("//server") === 7 // "//server"
6110
- * getRootLength("//server/share") === 8 // "//server/"
6111
- * getRootLength("\\\\server") === 7 // "\\\\server"
6112
- * getRootLength("\\\\server\\share") === 8 // "\\\\server\\"
6113
- * getRootLength("file:///path") === 8 // "file:///"
6114
- * getRootLength("file:///c:") === 10 // "file:///c:"
6115
- * getRootLength("file:///c:d") === 8 // "file:///"
6116
- * getRootLength("file:///c:/path") === 11 // "file:///c:/"
6117
- * getRootLength("file://server") === 13 // "file://server"
6118
- * getRootLength("file://server/path") === 14 // "file://server/"
6119
- * getRootLength("http://server") === 13 // "http://server"
6120
- * getRootLength("http://server/path") === 14 // "http://server/"
6121
- * ```
6122
- */
6123
- function getRootLength(path) {
6124
- var rootLength = getEncodedRootLength(path);
6125
- return rootLength < 0 ? ~rootLength : rootLength;
6126
- }
6127
- ts.getRootLength = getRootLength;
6128
- function getDirectoryPath(path) {
6129
- path = normalizeSlashes(path);
6130
- // If the path provided is itself the root, then return it.
6131
- var rootLength = getRootLength(path);
6132
- if (rootLength === path.length)
6133
- return path;
6134
- // return the leading portion of the path up to the last (non-terminal) directory separator
6135
- // but not including any trailing directory separator.
6136
- path = removeTrailingDirectorySeparator(path);
6137
- return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator)));
6138
- }
6139
- ts.getDirectoryPath = getDirectoryPath;
6140
- function getBaseFileName(path, extensions, ignoreCase) {
6141
- path = normalizeSlashes(path);
6142
- // if the path provided is itself the root, then it has not file name.
6143
- var rootLength = getRootLength(path);
6144
- if (rootLength === path.length)
6145
- return "";
6146
- // return the trailing portion of the path starting after the last (non-terminal) directory
6147
- // separator but not including any trailing directory separator.
6148
- path = removeTrailingDirectorySeparator(path);
6149
- var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1));
6150
- var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined;
6151
- return extension ? name.slice(0, name.length - extension.length) : name;
6152
- }
6153
- ts.getBaseFileName = getBaseFileName;
6154
- function tryGetExtensionFromPath(path, extension, stringEqualityComparer) {
6155
- if (!ts.startsWith(extension, "."))
6156
- extension = "." + extension;
6157
- if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) {
6158
- var pathExtension = path.slice(path.length - extension.length);
6159
- if (stringEqualityComparer(pathExtension, extension)) {
6160
- return pathExtension;
6161
- }
6162
- }
6163
- }
6164
- function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) {
6165
- if (typeof extensions === "string") {
6166
- return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || "";
6167
- }
6168
- for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) {
6169
- var extension = extensions_2[_i];
6170
- var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer);
6171
- if (result)
6172
- return result;
6173
- }
6174
- return "";
6175
- }
6176
- function getAnyExtensionFromPath(path, extensions, ignoreCase) {
6177
- // Retrieves any string from the final "." onwards from a base file name.
6178
- // Unlike extensionFromPath, which throws an exception on unrecognized extensions.
6179
- if (extensions) {
6180
- return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive);
6181
- }
6182
- var baseFileName = getBaseFileName(path);
6183
- var extensionIndex = baseFileName.lastIndexOf(".");
6184
- if (extensionIndex >= 0) {
6185
- return baseFileName.substring(extensionIndex);
6186
- }
6187
- return "";
6188
- }
6189
- ts.getAnyExtensionFromPath = getAnyExtensionFromPath;
6190
- function pathComponents(path, rootLength) {
6191
- var root = path.substring(0, rootLength);
6192
- var rest = path.substring(rootLength).split(ts.directorySeparator);
6193
- if (rest.length && !ts.lastOrUndefined(rest))
6194
- rest.pop();
6195
- return __spreadArray([root], rest, true);
6196
- }
6197
- /**
6198
- * Parse a path into an array containing a root component (at index 0) and zero or more path
6199
- * components (at indices > 0). The result is not normalized.
6200
- * If the path is relative, the root component is `""`.
6201
- * If the path is absolute, the root component includes the first path separator (`/`).
6202
- *
6203
- * ```ts
6204
- * // POSIX
6205
- * getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"]
6206
- * getPathComponents("/path/to/") === ["/", "path", "to"]
6207
- * getPathComponents("/") === ["/"]
6208
- * // DOS
6209
- * getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"]
6210
- * getPathComponents("c:/path/to/") === ["c:/", "path", "to"]
6211
- * getPathComponents("c:/") === ["c:/"]
6212
- * getPathComponents("c:") === ["c:"]
6213
- * // URL
6214
- * getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"]
6215
- * getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"]
6216
- * getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"]
6217
- * getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"]
6218
- * getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"]
6219
- * getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"]
6220
- * getPathComponents("file://server/") === ["file://server/"]
6221
- * getPathComponents("file://server") === ["file://server"]
6222
- * getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"]
6223
- * getPathComponents("file:///path/to/") === ["file:///", "path", "to"]
6224
- * getPathComponents("file:///") === ["file:///"]
6225
- * getPathComponents("file://") === ["file://"]
6226
- */
6227
- function getPathComponents(path, currentDirectory) {
6228
- if (currentDirectory === void 0) { currentDirectory = ""; }
6229
- path = combinePaths(currentDirectory, path);
6230
- return pathComponents(path, getRootLength(path));
6231
- }
6232
- ts.getPathComponents = getPathComponents;
6233
- //// Path Formatting
6234
- /**
6235
- * Formats a parsed path consisting of a root component (at index 0) and zero or more path
6236
- * segments (at indices > 0).
6237
- *
6238
- * ```ts
6239
- * getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext"
6240
- * ```
6241
- */
6242
- function getPathFromPathComponents(pathComponents) {
6243
- if (pathComponents.length === 0)
6244
- return "";
6245
- var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
6246
- return root + pathComponents.slice(1).join(ts.directorySeparator);
6247
- }
6248
- ts.getPathFromPathComponents = getPathFromPathComponents;
6249
- //// Path Normalization
6250
- /**
6251
- * Normalize path separators, converting `\` into `/`.
6252
- */
6253
- function normalizeSlashes(path) {
6254
- var index = path.indexOf("\\");
6255
- if (index === -1) {
6256
- return path;
6257
- }
6258
- backslashRegExp.lastIndex = index; // prime regex with known position
6259
- return path.replace(backslashRegExp, ts.directorySeparator);
6260
- }
6261
- ts.normalizeSlashes = normalizeSlashes;
6262
- /**
6263
- * Reduce an array of path components to a more simplified path by navigating any
6264
- * `"."` or `".."` entries in the path.
6265
- */
6266
- function reducePathComponents(components) {
6267
- if (!ts.some(components))
6268
- return [];
6269
- var reduced = [components[0]];
6270
- for (var i = 1; i < components.length; i++) {
6271
- var component = components[i];
6272
- if (!component)
6273
- continue;
6274
- if (component === ".")
6275
- continue;
6276
- if (component === "..") {
6277
- if (reduced.length > 1) {
6278
- if (reduced[reduced.length - 1] !== "..") {
6279
- reduced.pop();
6280
- continue;
6281
- }
6282
- }
6283
- else if (reduced[0])
6284
- continue;
6285
- }
6286
- reduced.push(component);
6287
- }
6288
- return reduced;
6289
- }
6290
- ts.reducePathComponents = reducePathComponents;
6291
- /**
6292
- * Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified.
6293
- *
6294
- * ```ts
6295
- * // Non-rooted
6296
- * combinePaths("path", "to", "file.ext") === "path/to/file.ext"
6297
- * combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext"
6298
- * // POSIX
6299
- * combinePaths("/path", "to", "file.ext") === "/path/to/file.ext"
6300
- * combinePaths("/path", "/to", "file.ext") === "/to/file.ext"
6301
- * // DOS
6302
- * combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext"
6303
- * combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext"
6304
- * // URL
6305
- * combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext"
6306
- * combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext"
6307
- * ```
6308
- */
6309
- function combinePaths(path) {
6310
- var paths = [];
6311
- for (var _i = 1; _i < arguments.length; _i++) {
6312
- paths[_i - 1] = arguments[_i];
6313
- }
6314
- if (path)
6315
- path = normalizeSlashes(path);
6316
- for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
6317
- var relativePath = paths_1[_a];
6318
- if (!relativePath)
6319
- continue;
6320
- relativePath = normalizeSlashes(relativePath);
6321
- if (!path || getRootLength(relativePath) !== 0) {
6322
- path = relativePath;
6323
- }
6324
- else {
6325
- path = ensureTrailingDirectorySeparator(path) + relativePath;
6326
- }
6327
- }
6328
- return path;
6329
- }
6330
- ts.combinePaths = combinePaths;
6331
- /**
6332
- * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any
6333
- * `.` and `..` path components are resolved. Trailing directory separators are preserved.
6334
- *
6335
- * ```ts
6336
- * resolvePath("/path", "to", "file.ext") === "path/to/file.ext"
6337
- * resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/"
6338
- * resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext"
6339
- * ```
6340
- */
6341
- function resolvePath(path) {
6342
- var paths = [];
6343
- for (var _i = 1; _i < arguments.length; _i++) {
6344
- paths[_i - 1] = arguments[_i];
6345
- }
6346
- return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArray([path], paths, false)) : normalizeSlashes(path));
6347
- }
6348
- ts.resolvePath = resolvePath;
6349
- /**
6350
- * Parse a path into an array containing a root component (at index 0) and zero or more path
6351
- * components (at indices > 0). The result is normalized.
6352
- * If the path is relative, the root component is `""`.
6353
- * If the path is absolute, the root component includes the first path separator (`/`).
6354
- *
6355
- * ```ts
6356
- * getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"]
6357
- * ```
6358
- */
6359
- function getNormalizedPathComponents(path, currentDirectory) {
6360
- return reducePathComponents(getPathComponents(path, currentDirectory));
6361
- }
6362
- ts.getNormalizedPathComponents = getNormalizedPathComponents;
6363
- function getNormalizedAbsolutePath(fileName, currentDirectory) {
6364
- return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
6365
- }
6366
- ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
6367
- function normalizePath(path) {
6368
- path = normalizeSlashes(path);
6369
- // Most paths don't require normalization
6370
- if (!relativePathSegmentRegExp.test(path)) {
6371
- return path;
6372
- }
6373
- // Some paths only require cleanup of `/./` or leading `./`
6374
- var simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, "");
6375
- if (simplified !== path) {
6376
- path = simplified;
6377
- if (!relativePathSegmentRegExp.test(path)) {
6378
- return path;
6379
- }
6380
- }
6381
- // Other paths require full normalization
6382
- var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
6383
- return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
6384
- }
6385
- ts.normalizePath = normalizePath;
6386
- function getPathWithoutRoot(pathComponents) {
6387
- if (pathComponents.length === 0)
6388
- return "";
6389
- return pathComponents.slice(1).join(ts.directorySeparator);
6390
- }
6391
- function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
6392
- return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
6393
- }
6394
- ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
6395
- function toPath(fileName, basePath, getCanonicalFileName) {
6396
- var nonCanonicalizedPath = isRootedDiskPath(fileName)
6397
- ? normalizePath(fileName)
6398
- : getNormalizedAbsolutePath(fileName, basePath);
6399
- return getCanonicalFileName(nonCanonicalizedPath);
6400
- }
6401
- ts.toPath = toPath;
6402
- function normalizePathAndParts(path) {
6403
- path = normalizeSlashes(path);
6404
- var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
6405
- if (parts.length) {
6406
- var joinedParts = root + parts.join(ts.directorySeparator);
6407
- return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
6408
- }
6409
- else {
6410
- return { path: root, parts: parts };
6411
- }
6412
- }
6413
- ts.normalizePathAndParts = normalizePathAndParts;
6414
- function removeTrailingDirectorySeparator(path) {
6415
- if (hasTrailingDirectorySeparator(path)) {
6416
- return path.substr(0, path.length - 1);
6417
- }
6418
- return path;
6419
- }
6420
- ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
6421
- function ensureTrailingDirectorySeparator(path) {
6422
- if (!hasTrailingDirectorySeparator(path)) {
6423
- return path + ts.directorySeparator;
6424
- }
6425
- return path;
6426
- }
6427
- ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator;
6428
- /**
6429
- * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed
6430
- * with `./` or `../`) so as not to be confused with an unprefixed module name.
6431
- *
6432
- * ```ts
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
- * ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext"
6437
- * ```
6438
- */
6439
- function ensurePathIsNonModuleName(path) {
6440
- return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path;
6441
- }
6442
- ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName;
6443
- function changeAnyExtension(path, ext, extensions, ignoreCase) {
6444
- var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path);
6445
- return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
6446
- }
6447
- ts.changeAnyExtension = changeAnyExtension;
6448
- //// Path Comparisons
6449
- // check path for these segments: '', '.'. '..'
6450
- var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/;
6451
- function comparePathsWorker(a, b, componentComparer) {
6452
- if (a === b)
6453
- return 0 /* EqualTo */;
6454
- if (a === undefined)
6455
- return -1 /* LessThan */;
6456
- if (b === undefined)
6457
- return 1 /* GreaterThan */;
6458
- // NOTE: Performance optimization - shortcut if the root segments differ as there would be no
6459
- // need to perform path reduction.
6460
- var aRoot = a.substring(0, getRootLength(a));
6461
- var bRoot = b.substring(0, getRootLength(b));
6462
- var result = ts.compareStringsCaseInsensitive(aRoot, bRoot);
6463
- if (result !== 0 /* EqualTo */) {
6464
- return result;
6465
- }
6466
- // NOTE: Performance optimization - shortcut if there are no relative path segments in
6467
- // the non-root portion of the path
6468
- var aRest = a.substring(aRoot.length);
6469
- var bRest = b.substring(bRoot.length);
6470
- if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) {
6471
- return componentComparer(aRest, bRest);
6472
- }
6473
- // The path contains a relative path segment. Normalize the paths and perform a slower component
6474
- // by component comparison.
6475
- var aComponents = reducePathComponents(getPathComponents(a));
6476
- var bComponents = reducePathComponents(getPathComponents(b));
6477
- var sharedLength = Math.min(aComponents.length, bComponents.length);
6478
- for (var i = 1; i < sharedLength; i++) {
6479
- var result_2 = componentComparer(aComponents[i], bComponents[i]);
6480
- if (result_2 !== 0 /* EqualTo */) {
6481
- return result_2;
6482
- }
6483
- }
6484
- return ts.compareValues(aComponents.length, bComponents.length);
6485
- }
6486
- /**
6487
- * Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively.
6488
- */
6489
- function comparePathsCaseSensitive(a, b) {
6490
- return comparePathsWorker(a, b, ts.compareStringsCaseSensitive);
6491
- }
6492
- ts.comparePathsCaseSensitive = comparePathsCaseSensitive;
6493
- /**
6494
- * Performs a case-insensitive comparison of two paths.
6495
- */
6496
- function comparePathsCaseInsensitive(a, b) {
6497
- return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive);
6498
- }
6499
- ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive;
6500
- function comparePaths(a, b, currentDirectory, ignoreCase) {
6501
- if (typeof currentDirectory === "string") {
6502
- a = combinePaths(currentDirectory, a);
6503
- b = combinePaths(currentDirectory, b);
6504
- }
6505
- else if (typeof currentDirectory === "boolean") {
6506
- ignoreCase = currentDirectory;
6507
- }
6508
- return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase));
6509
- }
6510
- ts.comparePaths = comparePaths;
6511
- function containsPath(parent, child, currentDirectory, ignoreCase) {
6512
- if (typeof currentDirectory === "string") {
6513
- parent = combinePaths(currentDirectory, parent);
6514
- child = combinePaths(currentDirectory, child);
6515
- }
6516
- else if (typeof currentDirectory === "boolean") {
6517
- ignoreCase = currentDirectory;
6518
- }
6519
- if (parent === undefined || child === undefined)
6520
- return false;
6521
- if (parent === child)
6522
- return true;
6523
- var parentComponents = reducePathComponents(getPathComponents(parent));
6524
- var childComponents = reducePathComponents(getPathComponents(child));
6525
- if (childComponents.length < parentComponents.length) {
6526
- return false;
6527
- }
6528
- var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive;
6529
- for (var i = 0; i < parentComponents.length; i++) {
6530
- var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer;
6531
- if (!equalityComparer(parentComponents[i], childComponents[i])) {
6532
- return false;
6533
- }
6534
- }
6535
- return true;
6536
- }
6537
- ts.containsPath = containsPath;
6538
- /**
6539
- * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback.
6540
- * Comparison is case-sensitive between the canonical paths.
6541
- *
6542
- * Use `containsPath` if file names are not already reduced and absolute.
6543
- */
6544
- function startsWithDirectory(fileName, directoryName, getCanonicalFileName) {
6545
- var canonicalFileName = getCanonicalFileName(fileName);
6546
- var canonicalDirectoryName = getCanonicalFileName(directoryName);
6547
- return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\");
6548
- }
6549
- ts.startsWithDirectory = startsWithDirectory;
6550
- //// Relative Paths
6551
- function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) {
6552
- var fromComponents = reducePathComponents(getPathComponents(from));
6553
- var toComponents = reducePathComponents(getPathComponents(to));
6554
- var start;
6555
- for (start = 0; start < fromComponents.length && start < toComponents.length; start++) {
6556
- var fromComponent = getCanonicalFileName(fromComponents[start]);
6557
- var toComponent = getCanonicalFileName(toComponents[start]);
6558
- var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer;
6559
- if (!comparer(fromComponent, toComponent))
6560
- break;
6561
- }
6562
- if (start === 0) {
6563
- return toComponents;
6564
- }
6565
- var components = toComponents.slice(start);
6566
- var relative = [];
6567
- for (; start < fromComponents.length; start++) {
6568
- relative.push("..");
6569
- }
6570
- return __spreadArray(__spreadArray([""], relative, true), components, true);
6571
- }
6572
- ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo;
6573
- function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
6574
- ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
6575
- var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
6576
- var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
6577
- var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
6578
- return getPathFromPathComponents(pathComponents);
6579
- }
6580
- ts.getRelativePathFromDirectory = getRelativePathFromDirectory;
6581
- function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
6582
- return !isRootedDiskPath(absoluteOrRelativePath)
6583
- ? absoluteOrRelativePath
6584
- : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
6585
- }
6586
- ts.convertToRelativePath = convertToRelativePath;
6587
- function getRelativePathFromFile(from, to, getCanonicalFileName) {
6588
- return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName));
6589
- }
6590
- ts.getRelativePathFromFile = getRelativePathFromFile;
6591
- function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
6592
- var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName);
6593
- var firstComponent = pathComponents[0];
6594
- if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) {
6595
- var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///";
6596
- pathComponents[0] = prefix + firstComponent;
6597
- }
6598
- return getPathFromPathComponents(pathComponents);
6599
- }
6600
- ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl;
6601
- function forEachAncestorDirectory(directory, callback) {
6602
- while (true) {
6603
- var result = callback(directory);
6604
- if (result !== undefined) {
6605
- return result;
6606
- }
6607
- var parentPath = getDirectoryPath(directory);
6608
- if (parentPath === directory) {
6609
- return undefined;
6610
- }
6611
- directory = parentPath;
6612
- }
6613
- }
6614
- ts.forEachAncestorDirectory = forEachAncestorDirectory;
6615
- function isNodeModulesDirectory(dirPath) {
6616
- return ts.endsWith(dirPath, "/node_modules");
6617
- }
6618
- ts.isNodeModulesDirectory = isNodeModulesDirectory;
6619
- })(ts || (ts = {}));
6620
5922
  var ts;
6621
5923
  (function (ts) {
6622
5924
  /**
@@ -8049,8 +7351,706 @@ var ts;
8049
7351
  ts.Debug.isDebugging = true;
8050
7352
  }
8051
7353
  })(ts || (ts = {}));
7354
+ /* @internal */
7355
+ var ts;
7356
+ (function (ts) {
7357
+ /**
7358
+ * Internally, we represent paths as strings with '/' as the directory separator.
7359
+ * When we make system calls (eg: LanguageServiceHost.getDirectory()),
7360
+ * we expect the host to correctly handle paths in our specified format.
7361
+ */
7362
+ ts.directorySeparator = "/";
7363
+ ts.altDirectorySeparator = "\\";
7364
+ var urlSchemeSeparator = "://";
7365
+ var backslashRegExp = /\\/g;
7366
+ //// Path Tests
7367
+ /**
7368
+ * Determines whether a charCode corresponds to `/` or `\`.
7369
+ */
7370
+ function isAnyDirectorySeparator(charCode) {
7371
+ return charCode === 47 /* slash */ || charCode === 92 /* backslash */;
7372
+ }
7373
+ ts.isAnyDirectorySeparator = isAnyDirectorySeparator;
7374
+ /**
7375
+ * Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.).
7376
+ */
7377
+ function isUrl(path) {
7378
+ return getEncodedRootLength(path) < 0;
7379
+ }
7380
+ ts.isUrl = isUrl;
7381
+ /**
7382
+ * Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path
7383
+ * like `c:`, `c:\` or `c:/`).
7384
+ */
7385
+ function isRootedDiskPath(path) {
7386
+ return getEncodedRootLength(path) > 0;
7387
+ }
7388
+ ts.isRootedDiskPath = isRootedDiskPath;
7389
+ /**
7390
+ * Determines whether a path consists only of a path root.
7391
+ */
7392
+ function isDiskPathRoot(path) {
7393
+ var rootLength = getEncodedRootLength(path);
7394
+ return rootLength > 0 && rootLength === path.length;
7395
+ }
7396
+ ts.isDiskPathRoot = isDiskPathRoot;
7397
+ /**
7398
+ * Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.).
7399
+ *
7400
+ * ```ts
7401
+ * // POSIX
7402
+ * pathIsAbsolute("/path/to/file.ext") === true
7403
+ * // DOS
7404
+ * pathIsAbsolute("c:/path/to/file.ext") === true
7405
+ * // URL
7406
+ * pathIsAbsolute("file:///path/to/file.ext") === true
7407
+ * // Non-absolute
7408
+ * pathIsAbsolute("path/to/file.ext") === false
7409
+ * pathIsAbsolute("./path/to/file.ext") === false
7410
+ * ```
7411
+ */
7412
+ function pathIsAbsolute(path) {
7413
+ return getEncodedRootLength(path) !== 0;
7414
+ }
7415
+ ts.pathIsAbsolute = pathIsAbsolute;
7416
+ /**
7417
+ * Determines whether a path starts with a relative path component (i.e. `.` or `..`).
7418
+ */
7419
+ function pathIsRelative(path) {
7420
+ return /^\.\.?($|[\\/])/.test(path);
7421
+ }
7422
+ ts.pathIsRelative = pathIsRelative;
7423
+ /**
7424
+ * Determines whether a path is neither relative nor absolute, e.g. "path/to/file".
7425
+ * Also known misleadingly as "non-relative".
7426
+ */
7427
+ function pathIsBareSpecifier(path) {
7428
+ return !pathIsAbsolute(path) && !pathIsRelative(path);
7429
+ }
7430
+ ts.pathIsBareSpecifier = pathIsBareSpecifier;
7431
+ function hasExtension(fileName) {
7432
+ return ts.stringContains(getBaseFileName(fileName), ".");
7433
+ }
7434
+ ts.hasExtension = hasExtension;
7435
+ function fileExtensionIs(path, extension) {
7436
+ return path.length > extension.length && ts.endsWith(path, extension);
7437
+ }
7438
+ ts.fileExtensionIs = fileExtensionIs;
7439
+ function fileExtensionIsOneOf(path, extensions) {
7440
+ for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
7441
+ var extension = extensions_1[_i];
7442
+ if (fileExtensionIs(path, extension)) {
7443
+ return true;
7444
+ }
7445
+ }
7446
+ return false;
7447
+ }
7448
+ ts.fileExtensionIsOneOf = fileExtensionIsOneOf;
7449
+ /**
7450
+ * Determines whether a path has a trailing separator (`/` or `\\`).
7451
+ */
7452
+ function hasTrailingDirectorySeparator(path) {
7453
+ return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1));
7454
+ }
7455
+ ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator;
7456
+ //// Path Parsing
7457
+ function isVolumeCharacter(charCode) {
7458
+ return (charCode >= 97 /* a */ && charCode <= 122 /* z */) ||
7459
+ (charCode >= 65 /* A */ && charCode <= 90 /* Z */);
7460
+ }
7461
+ function getFileUrlVolumeSeparatorEnd(url, start) {
7462
+ var ch0 = url.charCodeAt(start);
7463
+ if (ch0 === 58 /* colon */)
7464
+ return start + 1;
7465
+ if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) {
7466
+ var ch2 = url.charCodeAt(start + 2);
7467
+ if (ch2 === 97 /* a */ || ch2 === 65 /* A */)
7468
+ return start + 3;
7469
+ }
7470
+ return -1;
7471
+ }
7472
+ /**
7473
+ * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
7474
+ * If the root is part of a URL, the twos-complement of the root length is returned.
7475
+ */
7476
+ function getEncodedRootLength(path) {
7477
+ if (!path)
7478
+ return 0;
7479
+ var ch0 = path.charCodeAt(0);
7480
+ // POSIX or UNC
7481
+ if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) {
7482
+ if (path.charCodeAt(1) !== ch0)
7483
+ return 1; // POSIX: "/" (or non-normalized "\")
7484
+ var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2);
7485
+ if (p1 < 0)
7486
+ return path.length; // UNC: "//server" or "\\server"
7487
+ return p1 + 1; // UNC: "//server/" or "\\server\"
7488
+ }
7489
+ // DOS
7490
+ if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) {
7491
+ var ch2 = path.charCodeAt(2);
7492
+ if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */)
7493
+ return 3; // DOS: "c:/" or "c:\"
7494
+ if (path.length === 2)
7495
+ return 2; // DOS: "c:" (but not "c:d")
7496
+ }
7497
+ // URL
7498
+ var schemeEnd = path.indexOf(urlSchemeSeparator);
7499
+ if (schemeEnd !== -1) {
7500
+ var authorityStart = schemeEnd + urlSchemeSeparator.length;
7501
+ var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart);
7502
+ if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path"
7503
+ // For local "file" URLs, include the leading DOS volume (if present).
7504
+ // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a
7505
+ // special case interpreted as "the machine from which the URL is being interpreted".
7506
+ var scheme = path.slice(0, schemeEnd);
7507
+ var authority = path.slice(authorityStart, authorityEnd);
7508
+ if (scheme === "file" && (authority === "" || authority === "localhost") &&
7509
+ isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
7510
+ var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
7511
+ if (volumeSeparatorEnd !== -1) {
7512
+ if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) {
7513
+ // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/"
7514
+ return ~(volumeSeparatorEnd + 1);
7515
+ }
7516
+ if (volumeSeparatorEnd === path.length) {
7517
+ // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a"
7518
+ // but not "file:///c:d" or "file:///c%3ad"
7519
+ return ~volumeSeparatorEnd;
7520
+ }
7521
+ }
7522
+ }
7523
+ return ~(authorityEnd + 1); // URL: "file://server/", "http://server/"
7524
+ }
7525
+ return ~path.length; // URL: "file://server", "http://server"
7526
+ }
7527
+ // relative
7528
+ return 0;
7529
+ }
7530
+ /**
7531
+ * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
7532
+ *
7533
+ * For example:
7534
+ * ```ts
7535
+ * getRootLength("a") === 0 // ""
7536
+ * getRootLength("/") === 1 // "/"
7537
+ * getRootLength("c:") === 2 // "c:"
7538
+ * getRootLength("c:d") === 0 // ""
7539
+ * getRootLength("c:/") === 3 // "c:/"
7540
+ * getRootLength("c:\\") === 3 // "c:\\"
7541
+ * getRootLength("//server") === 7 // "//server"
7542
+ * getRootLength("//server/share") === 8 // "//server/"
7543
+ * getRootLength("\\\\server") === 7 // "\\\\server"
7544
+ * getRootLength("\\\\server\\share") === 8 // "\\\\server\\"
7545
+ * getRootLength("file:///path") === 8 // "file:///"
7546
+ * getRootLength("file:///c:") === 10 // "file:///c:"
7547
+ * getRootLength("file:///c:d") === 8 // "file:///"
7548
+ * getRootLength("file:///c:/path") === 11 // "file:///c:/"
7549
+ * getRootLength("file://server") === 13 // "file://server"
7550
+ * getRootLength("file://server/path") === 14 // "file://server/"
7551
+ * getRootLength("http://server") === 13 // "http://server"
7552
+ * getRootLength("http://server/path") === 14 // "http://server/"
7553
+ * ```
7554
+ */
7555
+ function getRootLength(path) {
7556
+ var rootLength = getEncodedRootLength(path);
7557
+ return rootLength < 0 ? ~rootLength : rootLength;
7558
+ }
7559
+ ts.getRootLength = getRootLength;
7560
+ function getDirectoryPath(path) {
7561
+ path = normalizeSlashes(path);
7562
+ // If the path provided is itself the root, then return it.
7563
+ var rootLength = getRootLength(path);
7564
+ if (rootLength === path.length)
7565
+ return path;
7566
+ // return the leading portion of the path up to the last (non-terminal) directory separator
7567
+ // but not including any trailing directory separator.
7568
+ path = removeTrailingDirectorySeparator(path);
7569
+ return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator)));
7570
+ }
7571
+ ts.getDirectoryPath = getDirectoryPath;
7572
+ function getBaseFileName(path, extensions, ignoreCase) {
7573
+ path = normalizeSlashes(path);
7574
+ // if the path provided is itself the root, then it has not file name.
7575
+ var rootLength = getRootLength(path);
7576
+ if (rootLength === path.length)
7577
+ return "";
7578
+ // return the trailing portion of the path starting after the last (non-terminal) directory
7579
+ // separator but not including any trailing directory separator.
7580
+ path = removeTrailingDirectorySeparator(path);
7581
+ var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1));
7582
+ var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined;
7583
+ return extension ? name.slice(0, name.length - extension.length) : name;
7584
+ }
7585
+ ts.getBaseFileName = getBaseFileName;
7586
+ function tryGetExtensionFromPath(path, extension, stringEqualityComparer) {
7587
+ if (!ts.startsWith(extension, "."))
7588
+ extension = "." + extension;
7589
+ if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) {
7590
+ var pathExtension = path.slice(path.length - extension.length);
7591
+ if (stringEqualityComparer(pathExtension, extension)) {
7592
+ return pathExtension;
7593
+ }
7594
+ }
7595
+ }
7596
+ function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) {
7597
+ if (typeof extensions === "string") {
7598
+ return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || "";
7599
+ }
7600
+ for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) {
7601
+ var extension = extensions_2[_i];
7602
+ var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer);
7603
+ if (result)
7604
+ return result;
7605
+ }
7606
+ return "";
7607
+ }
7608
+ function getAnyExtensionFromPath(path, extensions, ignoreCase) {
7609
+ // Retrieves any string from the final "." onwards from a base file name.
7610
+ // Unlike extensionFromPath, which throws an exception on unrecognized extensions.
7611
+ if (extensions) {
7612
+ return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive);
7613
+ }
7614
+ var baseFileName = getBaseFileName(path);
7615
+ var extensionIndex = baseFileName.lastIndexOf(".");
7616
+ if (extensionIndex >= 0) {
7617
+ return baseFileName.substring(extensionIndex);
7618
+ }
7619
+ return "";
7620
+ }
7621
+ ts.getAnyExtensionFromPath = getAnyExtensionFromPath;
7622
+ function pathComponents(path, rootLength) {
7623
+ var root = path.substring(0, rootLength);
7624
+ var rest = path.substring(rootLength).split(ts.directorySeparator);
7625
+ if (rest.length && !ts.lastOrUndefined(rest))
7626
+ rest.pop();
7627
+ return __spreadArray([root], rest, true);
7628
+ }
7629
+ /**
7630
+ * Parse a path into an array containing a root component (at index 0) and zero or more path
7631
+ * components (at indices > 0). The result is not normalized.
7632
+ * If the path is relative, the root component is `""`.
7633
+ * If the path is absolute, the root component includes the first path separator (`/`).
7634
+ *
7635
+ * ```ts
7636
+ * // POSIX
7637
+ * getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"]
7638
+ * getPathComponents("/path/to/") === ["/", "path", "to"]
7639
+ * getPathComponents("/") === ["/"]
7640
+ * // DOS
7641
+ * getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"]
7642
+ * getPathComponents("c:/path/to/") === ["c:/", "path", "to"]
7643
+ * getPathComponents("c:/") === ["c:/"]
7644
+ * getPathComponents("c:") === ["c:"]
7645
+ * // URL
7646
+ * getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"]
7647
+ * getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"]
7648
+ * getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"]
7649
+ * getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"]
7650
+ * getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"]
7651
+ * getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"]
7652
+ * getPathComponents("file://server/") === ["file://server/"]
7653
+ * getPathComponents("file://server") === ["file://server"]
7654
+ * getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"]
7655
+ * getPathComponents("file:///path/to/") === ["file:///", "path", "to"]
7656
+ * getPathComponents("file:///") === ["file:///"]
7657
+ * getPathComponents("file://") === ["file://"]
7658
+ */
7659
+ function getPathComponents(path, currentDirectory) {
7660
+ if (currentDirectory === void 0) { currentDirectory = ""; }
7661
+ path = combinePaths(currentDirectory, path);
7662
+ return pathComponents(path, getRootLength(path));
7663
+ }
7664
+ ts.getPathComponents = getPathComponents;
7665
+ //// Path Formatting
7666
+ /**
7667
+ * Formats a parsed path consisting of a root component (at index 0) and zero or more path
7668
+ * segments (at indices > 0).
7669
+ *
7670
+ * ```ts
7671
+ * getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext"
7672
+ * ```
7673
+ */
7674
+ function getPathFromPathComponents(pathComponents) {
7675
+ if (pathComponents.length === 0)
7676
+ return "";
7677
+ var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
7678
+ return root + pathComponents.slice(1).join(ts.directorySeparator);
7679
+ }
7680
+ ts.getPathFromPathComponents = getPathFromPathComponents;
7681
+ //// Path Normalization
7682
+ /**
7683
+ * Normalize path separators, converting `\` into `/`.
7684
+ */
7685
+ function normalizeSlashes(path) {
7686
+ var index = path.indexOf("\\");
7687
+ if (index === -1) {
7688
+ return path;
7689
+ }
7690
+ backslashRegExp.lastIndex = index; // prime regex with known position
7691
+ return path.replace(backslashRegExp, ts.directorySeparator);
7692
+ }
7693
+ ts.normalizeSlashes = normalizeSlashes;
7694
+ /**
7695
+ * Reduce an array of path components to a more simplified path by navigating any
7696
+ * `"."` or `".."` entries in the path.
7697
+ */
7698
+ function reducePathComponents(components) {
7699
+ if (!ts.some(components))
7700
+ return [];
7701
+ var reduced = [components[0]];
7702
+ for (var i = 1; i < components.length; i++) {
7703
+ var component = components[i];
7704
+ if (!component)
7705
+ continue;
7706
+ if (component === ".")
7707
+ continue;
7708
+ if (component === "..") {
7709
+ if (reduced.length > 1) {
7710
+ if (reduced[reduced.length - 1] !== "..") {
7711
+ reduced.pop();
7712
+ continue;
7713
+ }
7714
+ }
7715
+ else if (reduced[0])
7716
+ continue;
7717
+ }
7718
+ reduced.push(component);
7719
+ }
7720
+ return reduced;
7721
+ }
7722
+ ts.reducePathComponents = reducePathComponents;
7723
+ /**
7724
+ * Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified.
7725
+ *
7726
+ * ```ts
7727
+ * // Non-rooted
7728
+ * combinePaths("path", "to", "file.ext") === "path/to/file.ext"
7729
+ * combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext"
7730
+ * // POSIX
7731
+ * combinePaths("/path", "to", "file.ext") === "/path/to/file.ext"
7732
+ * combinePaths("/path", "/to", "file.ext") === "/to/file.ext"
7733
+ * // DOS
7734
+ * combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext"
7735
+ * combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext"
7736
+ * // URL
7737
+ * combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext"
7738
+ * combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext"
7739
+ * ```
7740
+ */
7741
+ function combinePaths(path) {
7742
+ var paths = [];
7743
+ for (var _i = 1; _i < arguments.length; _i++) {
7744
+ paths[_i - 1] = arguments[_i];
7745
+ }
7746
+ if (path)
7747
+ path = normalizeSlashes(path);
7748
+ for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
7749
+ var relativePath = paths_1[_a];
7750
+ if (!relativePath)
7751
+ continue;
7752
+ relativePath = normalizeSlashes(relativePath);
7753
+ if (!path || getRootLength(relativePath) !== 0) {
7754
+ path = relativePath;
7755
+ }
7756
+ else {
7757
+ path = ensureTrailingDirectorySeparator(path) + relativePath;
7758
+ }
7759
+ }
7760
+ return path;
7761
+ }
7762
+ ts.combinePaths = combinePaths;
7763
+ /**
7764
+ * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any
7765
+ * `.` and `..` path components are resolved. Trailing directory separators are preserved.
7766
+ *
7767
+ * ```ts
7768
+ * resolvePath("/path", "to", "file.ext") === "path/to/file.ext"
7769
+ * resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/"
7770
+ * resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext"
7771
+ * ```
7772
+ */
7773
+ function resolvePath(path) {
7774
+ var paths = [];
7775
+ for (var _i = 1; _i < arguments.length; _i++) {
7776
+ paths[_i - 1] = arguments[_i];
7777
+ }
7778
+ return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArray([path], paths, false)) : normalizeSlashes(path));
7779
+ }
7780
+ ts.resolvePath = resolvePath;
7781
+ /**
7782
+ * Parse a path into an array containing a root component (at index 0) and zero or more path
7783
+ * components (at indices > 0). The result is normalized.
7784
+ * If the path is relative, the root component is `""`.
7785
+ * If the path is absolute, the root component includes the first path separator (`/`).
7786
+ *
7787
+ * ```ts
7788
+ * getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"]
7789
+ * ```
7790
+ */
7791
+ function getNormalizedPathComponents(path, currentDirectory) {
7792
+ return reducePathComponents(getPathComponents(path, currentDirectory));
7793
+ }
7794
+ ts.getNormalizedPathComponents = getNormalizedPathComponents;
7795
+ function getNormalizedAbsolutePath(fileName, currentDirectory) {
7796
+ return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
7797
+ }
7798
+ ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
7799
+ function normalizePath(path) {
7800
+ path = normalizeSlashes(path);
7801
+ // Most paths don't require normalization
7802
+ if (!relativePathSegmentRegExp.test(path)) {
7803
+ return path;
7804
+ }
7805
+ // Some paths only require cleanup of `/./` or leading `./`
7806
+ var simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, "");
7807
+ if (simplified !== path) {
7808
+ path = simplified;
7809
+ if (!relativePathSegmentRegExp.test(path)) {
7810
+ return path;
7811
+ }
7812
+ }
7813
+ // Other paths require full normalization
7814
+ var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
7815
+ return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
7816
+ }
7817
+ ts.normalizePath = normalizePath;
7818
+ function getPathWithoutRoot(pathComponents) {
7819
+ if (pathComponents.length === 0)
7820
+ return "";
7821
+ return pathComponents.slice(1).join(ts.directorySeparator);
7822
+ }
7823
+ function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
7824
+ return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
7825
+ }
7826
+ ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
7827
+ function toPath(fileName, basePath, getCanonicalFileName) {
7828
+ var nonCanonicalizedPath = isRootedDiskPath(fileName)
7829
+ ? normalizePath(fileName)
7830
+ : getNormalizedAbsolutePath(fileName, basePath);
7831
+ return getCanonicalFileName(nonCanonicalizedPath);
7832
+ }
7833
+ ts.toPath = toPath;
7834
+ function normalizePathAndParts(path) {
7835
+ path = normalizeSlashes(path);
7836
+ var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
7837
+ if (parts.length) {
7838
+ var joinedParts = root + parts.join(ts.directorySeparator);
7839
+ return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
7840
+ }
7841
+ else {
7842
+ return { path: root, parts: parts };
7843
+ }
7844
+ }
7845
+ ts.normalizePathAndParts = normalizePathAndParts;
7846
+ function removeTrailingDirectorySeparator(path) {
7847
+ if (hasTrailingDirectorySeparator(path)) {
7848
+ return path.substr(0, path.length - 1);
7849
+ }
7850
+ return path;
7851
+ }
7852
+ ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
7853
+ function ensureTrailingDirectorySeparator(path) {
7854
+ if (!hasTrailingDirectorySeparator(path)) {
7855
+ return path + ts.directorySeparator;
7856
+ }
7857
+ return path;
7858
+ }
7859
+ ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator;
7860
+ /**
7861
+ * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed
7862
+ * with `./` or `../`) so as not to be confused with an unprefixed module name.
7863
+ *
7864
+ * ```ts
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
+ * ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext"
7869
+ * ```
7870
+ */
7871
+ function ensurePathIsNonModuleName(path) {
7872
+ return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path;
7873
+ }
7874
+ ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName;
7875
+ function changeAnyExtension(path, ext, extensions, ignoreCase) {
7876
+ var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path);
7877
+ return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
7878
+ }
7879
+ ts.changeAnyExtension = changeAnyExtension;
7880
+ //// Path Comparisons
7881
+ // check path for these segments: '', '.'. '..'
7882
+ var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/;
7883
+ function comparePathsWorker(a, b, componentComparer) {
7884
+ if (a === b)
7885
+ return 0 /* EqualTo */;
7886
+ if (a === undefined)
7887
+ return -1 /* LessThan */;
7888
+ if (b === undefined)
7889
+ return 1 /* GreaterThan */;
7890
+ // NOTE: Performance optimization - shortcut if the root segments differ as there would be no
7891
+ // need to perform path reduction.
7892
+ var aRoot = a.substring(0, getRootLength(a));
7893
+ var bRoot = b.substring(0, getRootLength(b));
7894
+ var result = ts.compareStringsCaseInsensitive(aRoot, bRoot);
7895
+ if (result !== 0 /* EqualTo */) {
7896
+ return result;
7897
+ }
7898
+ // NOTE: Performance optimization - shortcut if there are no relative path segments in
7899
+ // the non-root portion of the path
7900
+ var aRest = a.substring(aRoot.length);
7901
+ var bRest = b.substring(bRoot.length);
7902
+ if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) {
7903
+ return componentComparer(aRest, bRest);
7904
+ }
7905
+ // The path contains a relative path segment. Normalize the paths and perform a slower component
7906
+ // by component comparison.
7907
+ var aComponents = reducePathComponents(getPathComponents(a));
7908
+ var bComponents = reducePathComponents(getPathComponents(b));
7909
+ var sharedLength = Math.min(aComponents.length, bComponents.length);
7910
+ for (var i = 1; i < sharedLength; i++) {
7911
+ var result_2 = componentComparer(aComponents[i], bComponents[i]);
7912
+ if (result_2 !== 0 /* EqualTo */) {
7913
+ return result_2;
7914
+ }
7915
+ }
7916
+ return ts.compareValues(aComponents.length, bComponents.length);
7917
+ }
7918
+ /**
7919
+ * Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively.
7920
+ */
7921
+ function comparePathsCaseSensitive(a, b) {
7922
+ return comparePathsWorker(a, b, ts.compareStringsCaseSensitive);
7923
+ }
7924
+ ts.comparePathsCaseSensitive = comparePathsCaseSensitive;
7925
+ /**
7926
+ * Performs a case-insensitive comparison of two paths.
7927
+ */
7928
+ function comparePathsCaseInsensitive(a, b) {
7929
+ return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive);
7930
+ }
7931
+ ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive;
7932
+ function comparePaths(a, b, currentDirectory, ignoreCase) {
7933
+ if (typeof currentDirectory === "string") {
7934
+ a = combinePaths(currentDirectory, a);
7935
+ b = combinePaths(currentDirectory, b);
7936
+ }
7937
+ else if (typeof currentDirectory === "boolean") {
7938
+ ignoreCase = currentDirectory;
7939
+ }
7940
+ return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase));
7941
+ }
7942
+ ts.comparePaths = comparePaths;
7943
+ function containsPath(parent, child, currentDirectory, ignoreCase) {
7944
+ if (typeof currentDirectory === "string") {
7945
+ parent = combinePaths(currentDirectory, parent);
7946
+ child = combinePaths(currentDirectory, child);
7947
+ }
7948
+ else if (typeof currentDirectory === "boolean") {
7949
+ ignoreCase = currentDirectory;
7950
+ }
7951
+ if (parent === undefined || child === undefined)
7952
+ return false;
7953
+ if (parent === child)
7954
+ return true;
7955
+ var parentComponents = reducePathComponents(getPathComponents(parent));
7956
+ var childComponents = reducePathComponents(getPathComponents(child));
7957
+ if (childComponents.length < parentComponents.length) {
7958
+ return false;
7959
+ }
7960
+ var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive;
7961
+ for (var i = 0; i < parentComponents.length; i++) {
7962
+ var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer;
7963
+ if (!equalityComparer(parentComponents[i], childComponents[i])) {
7964
+ return false;
7965
+ }
7966
+ }
7967
+ return true;
7968
+ }
7969
+ ts.containsPath = containsPath;
7970
+ /**
7971
+ * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback.
7972
+ * Comparison is case-sensitive between the canonical paths.
7973
+ *
7974
+ * Use `containsPath` if file names are not already reduced and absolute.
7975
+ */
7976
+ function startsWithDirectory(fileName, directoryName, getCanonicalFileName) {
7977
+ var canonicalFileName = getCanonicalFileName(fileName);
7978
+ var canonicalDirectoryName = getCanonicalFileName(directoryName);
7979
+ return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\");
7980
+ }
7981
+ ts.startsWithDirectory = startsWithDirectory;
7982
+ //// Relative Paths
7983
+ function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) {
7984
+ var fromComponents = reducePathComponents(getPathComponents(from));
7985
+ var toComponents = reducePathComponents(getPathComponents(to));
7986
+ var start;
7987
+ for (start = 0; start < fromComponents.length && start < toComponents.length; start++) {
7988
+ var fromComponent = getCanonicalFileName(fromComponents[start]);
7989
+ var toComponent = getCanonicalFileName(toComponents[start]);
7990
+ var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer;
7991
+ if (!comparer(fromComponent, toComponent))
7992
+ break;
7993
+ }
7994
+ if (start === 0) {
7995
+ return toComponents;
7996
+ }
7997
+ var components = toComponents.slice(start);
7998
+ var relative = [];
7999
+ for (; start < fromComponents.length; start++) {
8000
+ relative.push("..");
8001
+ }
8002
+ return __spreadArray(__spreadArray([""], relative, true), components, true);
8003
+ }
8004
+ ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo;
8005
+ function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
8006
+ ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
8007
+ var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
8008
+ var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
8009
+ var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
8010
+ return getPathFromPathComponents(pathComponents);
8011
+ }
8012
+ ts.getRelativePathFromDirectory = getRelativePathFromDirectory;
8013
+ function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
8014
+ return !isRootedDiskPath(absoluteOrRelativePath)
8015
+ ? absoluteOrRelativePath
8016
+ : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
8017
+ }
8018
+ ts.convertToRelativePath = convertToRelativePath;
8019
+ function getRelativePathFromFile(from, to, getCanonicalFileName) {
8020
+ return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName));
8021
+ }
8022
+ ts.getRelativePathFromFile = getRelativePathFromFile;
8023
+ function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
8024
+ var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName);
8025
+ var firstComponent = pathComponents[0];
8026
+ if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) {
8027
+ var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///";
8028
+ pathComponents[0] = prefix + firstComponent;
8029
+ }
8030
+ return getPathFromPathComponents(pathComponents);
8031
+ }
8032
+ ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl;
8033
+ function forEachAncestorDirectory(directory, callback) {
8034
+ while (true) {
8035
+ var result = callback(directory);
8036
+ if (result !== undefined) {
8037
+ return result;
8038
+ }
8039
+ var parentPath = getDirectoryPath(directory);
8040
+ if (parentPath === directory) {
8041
+ return undefined;
8042
+ }
8043
+ directory = parentPath;
8044
+ }
8045
+ }
8046
+ ts.forEachAncestorDirectory = forEachAncestorDirectory;
8047
+ function isNodeModulesDirectory(dirPath) {
8048
+ return ts.endsWith(dirPath, "/node_modules");
8049
+ }
8050
+ ts.isNodeModulesDirectory = isNodeModulesDirectory;
8051
+ })(ts || (ts = {}));
8052
8052
  // <auto-generated />
8053
- // generated from './diagnosticInformationMap.generated.ts' by 'src/compiler'
8053
+ // generated from './diagnosticMessages.json' in 'src/compiler'
8054
8054
  /* @internal */
8055
8055
  var ts;
8056
8056
  (function (ts) {
@@ -8343,7 +8343,6 @@ var ts;
8343
8343
  Unexpected_token_Did_you_mean_or_rbrace: diag(1381, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_rbrace_1381", "Unexpected token. Did you mean `{'}'}` or `&rbrace;`?"),
8344
8344
  Unexpected_token_Did_you_mean_or_gt: diag(1382, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_gt_1382", "Unexpected token. Did you mean `{'>'}` or `&gt;`?"),
8345
8345
  Only_named_exports_may_use_export_type: diag(1383, ts.DiagnosticCategory.Error, "Only_named_exports_may_use_export_type_1383", "Only named exports may use 'export type'."),
8346
- A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list: diag(1384, ts.DiagnosticCategory.Error, "A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list_1384", "A 'new' expression with type arguments must always be followed by a parenthesized argument list."),
8347
8346
  Function_type_notation_must_be_parenthesized_when_used_in_a_union_type: diag(1385, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_a_union_type_1385", "Function type notation must be parenthesized when used in a union type."),
8348
8347
  Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type: diag(1386, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type_1386", "Constructor type notation must be parenthesized when used in a union type."),
8349
8348
  Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1387, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1387", "Function type notation must be parenthesized when used in an intersection type."),
@@ -8877,12 +8876,10 @@ var ts;
8877
8876
  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."),
8878
8877
  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."),
8879
8878
  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."),
8880
- 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."),
8881
8879
  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."),
8882
8880
  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}'."),
8883
8881
  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"),
8884
8882
  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."),
8885
- 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'."),
8886
8883
  Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"),
8887
8884
  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'."),
8888
8885
  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}'."),
@@ -9639,9 +9636,8 @@ var ts;
9639
9636
  Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"),
9640
9637
  Remove_template_tag: diag(90011, ts.DiagnosticCategory.Message, "Remove_template_tag_90011", "Remove template tag"),
9641
9638
  Remove_type_parameters: diag(90012, ts.DiagnosticCategory.Message, "Remove_type_parameters_90012", "Remove type parameters"),
9642
- Import_0_from_module_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_module_1_90013", "Import '{0}' from module \"{1}\""),
9639
+ Import_0_from_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_1_90013", "Import '{0}' from \"{1}\""),
9643
9640
  Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"),
9644
- Add_0_to_existing_import_declaration_from_1: diag(90015, ts.DiagnosticCategory.Message, "Add_0_to_existing_import_declaration_from_1_90015", "Add '{0}' to existing import declaration from \"{1}\""),
9645
9641
  Declare_property_0: diag(90016, ts.DiagnosticCategory.Message, "Declare_property_0_90016", "Declare property '{0}'"),
9646
9642
  Add_index_signature_for_property_0: diag(90017, ts.DiagnosticCategory.Message, "Add_index_signature_for_property_0_90017", "Add index signature for property '{0}'"),
9647
9643
  Disable_checking_for_this_file: diag(90018, ts.DiagnosticCategory.Message, "Disable_checking_for_this_file_90018", "Disable checking for this file"),
@@ -9658,8 +9654,6 @@ var ts;
9658
9654
  Add_async_modifier_to_containing_function: diag(90029, ts.DiagnosticCategory.Message, "Add_async_modifier_to_containing_function_90029", "Add async modifier to containing function"),
9659
9655
  Replace_infer_0_with_unknown: diag(90030, ts.DiagnosticCategory.Message, "Replace_infer_0_with_unknown_90030", "Replace 'infer {0}' with 'unknown'"),
9660
9656
  Replace_all_unused_infer_with_unknown: diag(90031, ts.DiagnosticCategory.Message, "Replace_all_unused_infer_with_unknown_90031", "Replace all unused 'infer' with 'unknown'"),
9661
- Import_default_0_from_module_1: diag(90032, ts.DiagnosticCategory.Message, "Import_default_0_from_module_1_90032", "Import default '{0}' from module \"{1}\""),
9662
- Add_default_import_0_to_existing_import_declaration_from_1: diag(90033, ts.DiagnosticCategory.Message, "Add_default_import_0_to_existing_import_declaration_from_1_90033", "Add default import '{0}' to existing import declaration from \"{1}\""),
9663
9657
  Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"),
9664
9658
  Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"),
9665
9659
  Replace_0_with_Promise_1: diag(90036, ts.DiagnosticCategory.Message, "Replace_0_with_Promise_1_90036", "Replace '{0}' with 'Promise<{1}>'"),
@@ -9671,6 +9665,8 @@ var ts;
9671
9665
  Includes_imports_of_types_referenced_by_0: diag(90054, ts.DiagnosticCategory.Message, "Includes_imports_of_types_referenced_by_0_90054", "Includes imports of types referenced by '{0}'"),
9672
9666
  Remove_type_from_import_declaration_from_0: diag(90055, ts.DiagnosticCategory.Message, "Remove_type_from_import_declaration_from_0_90055", "Remove 'type' from import declaration from \"{0}\""),
9673
9667
  Remove_type_from_import_of_0_from_1: diag(90056, ts.DiagnosticCategory.Message, "Remove_type_from_import_of_0_from_1_90056", "Remove 'type' from import of '{0}' from \"{1}\""),
9668
+ Add_import_from_0: diag(90057, ts.DiagnosticCategory.Message, "Add_import_from_0_90057", "Add import from \"{0}\""),
9669
+ Update_import_from_0: diag(90058, ts.DiagnosticCategory.Message, "Update_import_from_0_90058", "Update import from \"{0}\""),
9674
9670
  Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
9675
9671
  Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
9676
9672
  Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
@@ -9834,6 +9830,7 @@ var ts;
9834
9830
  Add_missing_attributes: diag(95167, ts.DiagnosticCategory.Message, "Add_missing_attributes_95167", "Add missing attributes"),
9835
9831
  Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"),
9836
9832
  Add_undefined_to_optional_property_type: diag(95169, ts.DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"),
9833
+ Convert_named_imports_to_default_import: diag(95170, ts.DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"),
9837
9834
  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."),
9838
9835
  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'."),
9839
9836
  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?"),
@@ -13006,12 +13003,17 @@ var ts;
13006
13003
  /** Gets the text of a jsdoc comment, flattening links to their text. */
13007
13004
  function getTextOfJSDocComment(comment) {
13008
13005
  return typeof comment === "string" ? comment
13009
- : comment === null || comment === void 0 ? void 0 : comment.map(function (c) {
13010
- // TODO: Other kinds here
13011
- return c.kind === 319 /* JSDocText */ ? c.text : "{@link " + (c.name ? ts.entityNameToString(c.name) + " " : "") + c.text + "}";
13012
- }).join("");
13006
+ : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 319 /* JSDocText */ ? c.text : formatJSDocLink(c); }).join("");
13013
13007
  }
13014
13008
  ts.getTextOfJSDocComment = getTextOfJSDocComment;
13009
+ function formatJSDocLink(link) {
13010
+ var kind = link.kind === 322 /* JSDocLink */ ? "link"
13011
+ : link.kind === 323 /* JSDocLinkCode */ ? "linkcode"
13012
+ : "linkplain";
13013
+ var name = link.name ? ts.entityNameToString(link.name) : "";
13014
+ var space = link.name && link.text.startsWith("://") ? "" : " ";
13015
+ return "{@" + kind + " " + name + space + link.text + "}";
13016
+ }
13015
13017
  /**
13016
13018
  * Gets the effective type parameters. If the node was parsed in a
13017
13019
  * JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
@@ -21070,6 +21072,59 @@ var ts;
21070
21072
  return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
21071
21073
  }
21072
21074
  ts.isThisTypeParameter = isThisTypeParameter;
21075
+ function getNodeModulePathParts(fullPath) {
21076
+ // If fullPath can't be valid module file within node_modules, returns undefined.
21077
+ // Example of expected pattern: /base/path/node_modules/[@scope/otherpackage/@otherscope/node_modules/]package/[subdirectory/]file.js
21078
+ // Returns indices: ^ ^ ^ ^
21079
+ var topLevelNodeModulesIndex = 0;
21080
+ var topLevelPackageNameIndex = 0;
21081
+ var packageRootIndex = 0;
21082
+ var fileNameIndex = 0;
21083
+ var States;
21084
+ (function (States) {
21085
+ States[States["BeforeNodeModules"] = 0] = "BeforeNodeModules";
21086
+ States[States["NodeModules"] = 1] = "NodeModules";
21087
+ States[States["Scope"] = 2] = "Scope";
21088
+ States[States["PackageContent"] = 3] = "PackageContent";
21089
+ })(States || (States = {}));
21090
+ var partStart = 0;
21091
+ var partEnd = 0;
21092
+ var state = 0 /* BeforeNodeModules */;
21093
+ while (partEnd >= 0) {
21094
+ partStart = partEnd;
21095
+ partEnd = fullPath.indexOf("/", partStart + 1);
21096
+ switch (state) {
21097
+ case 0 /* BeforeNodeModules */:
21098
+ if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
21099
+ topLevelNodeModulesIndex = partStart;
21100
+ topLevelPackageNameIndex = partEnd;
21101
+ state = 1 /* NodeModules */;
21102
+ }
21103
+ break;
21104
+ case 1 /* NodeModules */:
21105
+ case 2 /* Scope */:
21106
+ if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") {
21107
+ state = 2 /* Scope */;
21108
+ }
21109
+ else {
21110
+ packageRootIndex = partEnd;
21111
+ state = 3 /* PackageContent */;
21112
+ }
21113
+ break;
21114
+ case 3 /* PackageContent */:
21115
+ if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
21116
+ state = 1 /* NodeModules */;
21117
+ }
21118
+ else {
21119
+ state = 3 /* PackageContent */;
21120
+ }
21121
+ break;
21122
+ }
21123
+ }
21124
+ fileNameIndex = partStart;
21125
+ return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
21126
+ }
21127
+ ts.getNodeModulePathParts = getNodeModulePathParts;
21073
21128
  })(ts || (ts = {}));
21074
21129
  /* @internal */
21075
21130
  var ts;
@@ -34720,20 +34775,30 @@ var ts;
34720
34775
  expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken);
34721
34776
  continue;
34722
34777
  }
34723
- if (!questionDotToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) {
34724
- nextToken();
34725
- expression = finishNode(factory.createNonNullExpression(expression), pos);
34726
- continue;
34727
- }
34728
34778
  // when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName
34729
34779
  if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) {
34730
34780
  expression = parseElementAccessExpressionRest(pos, expression, questionDotToken);
34731
34781
  continue;
34732
34782
  }
34733
34783
  if (isTemplateStartOfTaggedTemplate()) {
34734
- expression = parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined);
34784
+ // Absorb type arguments into TemplateExpression when preceding expression is ExpressionWithTypeArguments
34785
+ expression = !questionDotToken && expression.kind === 227 /* ExpressionWithTypeArguments */ ?
34786
+ parseTaggedTemplateRest(pos, expression.expression, questionDotToken, expression.typeArguments) :
34787
+ parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined);
34735
34788
  continue;
34736
34789
  }
34790
+ if (!questionDotToken) {
34791
+ if (token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) {
34792
+ nextToken();
34793
+ expression = finishNode(factory.createNonNullExpression(expression), pos);
34794
+ continue;
34795
+ }
34796
+ var typeArguments = tryParse(parseTypeArgumentsInExpression);
34797
+ if (typeArguments) {
34798
+ expression = finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
34799
+ continue;
34800
+ }
34801
+ }
34737
34802
  return expression;
34738
34803
  }
34739
34804
  }
@@ -34753,42 +34818,30 @@ var ts;
34753
34818
  function parseCallExpressionRest(pos, expression) {
34754
34819
  while (true) {
34755
34820
  expression = parseMemberExpressionRest(pos, expression, /*allowOptionalChain*/ true);
34821
+ var typeArguments = void 0;
34756
34822
  var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */);
34757
- // handle 'foo<<T>()'
34758
- // parse template arguments only in TypeScript files (not in JavaScript files).
34759
- if ((contextFlags & 131072 /* JavaScriptFile */) === 0 && (token() === 29 /* LessThanToken */ || token() === 47 /* LessThanLessThanToken */)) {
34760
- // See if this is the start of a generic invocation. If so, consume it and
34761
- // keep checking for postfix expressions. Otherwise, it's just a '<' that's
34762
- // part of an arithmetic expression. Break out so we consume it higher in the
34763
- // stack.
34764
- var typeArguments = tryParse(parseTypeArgumentsInExpression);
34765
- if (typeArguments) {
34766
- if (isTemplateStartOfTaggedTemplate()) {
34767
- expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
34768
- continue;
34769
- }
34770
- if (questionDotToken || token() === 20 /* OpenParenToken */) {
34771
- var argumentList = parseArgumentList();
34772
- var callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
34773
- factory.createCallChain(expression, questionDotToken, typeArguments, argumentList) :
34774
- factory.createCallExpression(expression, typeArguments, argumentList);
34775
- expression = finishNode(callExpr, pos);
34776
- continue;
34777
- }
34778
- expression = finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
34779
- break;
34823
+ if (questionDotToken) {
34824
+ typeArguments = tryParse(parseTypeArgumentsInExpression);
34825
+ if (isTemplateStartOfTaggedTemplate()) {
34826
+ expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
34827
+ continue;
34780
34828
  }
34781
34829
  }
34782
- else if (token() === 20 /* OpenParenToken */) {
34830
+ if (typeArguments || token() === 20 /* OpenParenToken */) {
34831
+ // Absorb type arguments into CallExpression when preceding expression is ExpressionWithTypeArguments
34832
+ if (!questionDotToken && expression.kind === 227 /* ExpressionWithTypeArguments */) {
34833
+ typeArguments = expression.typeArguments;
34834
+ expression = expression.expression;
34835
+ }
34783
34836
  var argumentList = parseArgumentList();
34784
34837
  var callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
34785
- factory.createCallChain(expression, questionDotToken, /*typeArguments*/ undefined, argumentList) :
34786
- factory.createCallExpression(expression, /*typeArguments*/ undefined, argumentList);
34838
+ factory.createCallChain(expression, questionDotToken, typeArguments, argumentList) :
34839
+ factory.createCallExpression(expression, typeArguments, argumentList);
34787
34840
  expression = finishNode(callExpr, pos);
34788
34841
  continue;
34789
34842
  }
34790
34843
  if (questionDotToken) {
34791
- // We failed to parse anything, so report a missing identifier here.
34844
+ // We parsed `?.` but then failed to parse anything, so report a missing identifier here.
34792
34845
  var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected);
34793
34846
  expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos);
34794
34847
  }
@@ -34834,6 +34887,7 @@ var ts;
34834
34887
  // falls through
34835
34888
  case 27 /* CommaToken */: // foo<x>,
34836
34889
  case 24 /* DotToken */: // foo<x>.
34890
+ case 28 /* QuestionDotToken */: // foo<x>?.
34837
34891
  case 21 /* CloseParenToken */: // foo<x>)
34838
34892
  case 23 /* CloseBracketToken */: // foo<x>]
34839
34893
  case 58 /* ColonToken */: // foo<x>:
@@ -35036,20 +35090,14 @@ var ts;
35036
35090
  }
35037
35091
  var expressionPos = getNodePos();
35038
35092
  var expression = parseMemberExpressionRest(expressionPos, parsePrimaryExpression(), /*allowOptionalChain*/ false);
35039
- var typeArguments = tryParse(parseTypeArgumentsInExpression);
35040
- if (isTemplateStartOfTaggedTemplate()) {
35041
- ts.Debug.assert(!!typeArguments, "Expected a type argument list; all plain tagged template starts should be consumed in 'parseMemberExpressionRest'");
35042
- expression = parseTaggedTemplateRest(expressionPos, expression, /*optionalChain*/ undefined, typeArguments);
35043
- typeArguments = undefined;
35044
- }
35045
- var argumentsArray;
35046
- if (token() === 20 /* OpenParenToken */) {
35047
- argumentsArray = parseArgumentList();
35048
- }
35049
- else if (typeArguments) {
35050
- parseErrorAt(pos, scanner.getStartPos(), ts.Diagnostics.A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list);
35093
+ var typeArguments;
35094
+ // Absorb type arguments into NewExpression when preceding expression is ExpressionWithTypeArguments
35095
+ if (expression.kind === 227 /* ExpressionWithTypeArguments */) {
35096
+ typeArguments = expression.typeArguments;
35097
+ expression = expression.expression;
35051
35098
  }
35052
- return finishNode(factory.createNewExpression(expression, typeArguments, argumentsArray), pos);
35099
+ var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined;
35100
+ return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos);
35053
35101
  }
35054
35102
  // STATEMENTS
35055
35103
  function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) {
@@ -47008,8 +47056,8 @@ var ts;
47008
47056
  TypeFacts[TypeFacts["AllTypeofNE"] = 556800] = "AllTypeofNE";
47009
47057
  TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts";
47010
47058
  // Masks
47011
- TypeFacts[TypeFacts["OrFactsMask"] = 8288] = "OrFactsMask";
47012
- TypeFacts[TypeFacts["AndFactsMask"] = 16768927] = "AndFactsMask";
47059
+ TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
47060
+ TypeFacts[TypeFacts["AndFactsMask"] = 16768959] = "AndFactsMask";
47013
47061
  })(TypeFacts || (TypeFacts = {}));
47014
47062
  var typeofEQFacts = new ts.Map(ts.getEntries({
47015
47063
  string: 1 /* TypeofEQString */,
@@ -48964,24 +49012,19 @@ var ts;
48964
49012
  error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
48965
49013
  }
48966
49014
  }
48967
- if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */) {
48968
- checkSymbolUsageInExpressionContext(result, name, errorLocation);
49015
+ if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
49016
+ var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
49017
+ if (typeOnlyDeclaration) {
49018
+ var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
49019
+ ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
49020
+ : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
49021
+ var unescapedName = ts.unescapeLeadingUnderscores(name);
49022
+ addTypeOnlyDeclarationRelatedInfo(error(errorLocation, message, unescapedName), typeOnlyDeclaration, unescapedName);
49023
+ }
48969
49024
  }
48970
49025
  }
48971
49026
  return result;
48972
49027
  }
48973
- function checkSymbolUsageInExpressionContext(symbol, name, useSite) {
48974
- if (!ts.isValidTypeOnlyAliasUseSite(useSite)) {
48975
- var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
48976
- if (typeOnlyDeclaration) {
48977
- var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
48978
- ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
48979
- : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
48980
- var unescapedName = ts.unescapeLeadingUnderscores(name);
48981
- addTypeOnlyDeclarationRelatedInfo(error(useSite, message, unescapedName), typeOnlyDeclaration, unescapedName);
48982
- }
48983
- }
48984
- }
48985
49028
  function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) {
48986
49029
  if (!typeOnlyDeclaration)
48987
49030
  return diagnostic;
@@ -68127,7 +68170,10 @@ var ts;
68127
68170
  (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ :
68128
68171
  (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
68129
68172
  }
68130
- 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
+ }
68131
68177
  return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ?
68132
68178
  strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ :
68133
68179
  isFunctionObjectType(type) ?
@@ -68175,7 +68221,7 @@ var ts;
68175
68221
  oredFacts |= f;
68176
68222
  andedFacts &= f;
68177
68223
  }
68178
- return oredFacts & 8288 /* OrFactsMask */ | andedFacts & 16768927 /* AndFactsMask */;
68224
+ return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 16768959 /* AndFactsMask */;
68179
68225
  }
68180
68226
  function getTypeWithFacts(type, include) {
68181
68227
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
@@ -70135,6 +70181,9 @@ var ts;
70135
70181
  return getTypeOfSymbol(symbol);
70136
70182
  }
70137
70183
  function checkIdentifier(node, checkMode) {
70184
+ if (ts.isThisInTypeQuery(node)) {
70185
+ return checkThisExpression(node);
70186
+ }
70138
70187
  var symbol = getResolvedSymbol(node);
70139
70188
  if (symbol === unknownSymbol) {
70140
70189
  return errorType;
@@ -71926,7 +71975,8 @@ var ts;
71926
71975
  var links = getNodeLinks(node.expression);
71927
71976
  if (!links.resolvedType) {
71928
71977
  if ((ts.isTypeLiteralNode(node.parent.parent) || ts.isClassLike(node.parent.parent) || ts.isInterfaceDeclaration(node.parent.parent))
71929
- && 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 */) {
71930
71980
  return links.resolvedType = errorType;
71931
71981
  }
71932
71982
  links.resolvedType = checkExpression(node.expression);
@@ -73095,23 +73145,6 @@ var ts;
73095
73145
  if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) {
73096
73146
  grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right));
73097
73147
  }
73098
- if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && !useDefineForClassFields)) {
73099
- var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration);
73100
- var parentStaticFieldInitializer = ts.findAncestor(node, function (n) {
73101
- if (n === lexicalClass_1)
73102
- return "quit";
73103
- if (ts.isPropertyDeclaration(n.parent) && ts.hasStaticModifier(n.parent) && n.parent.initializer === n && n.parent.parent === lexicalClass_1) {
73104
- return true;
73105
- }
73106
- return false;
73107
- });
73108
- if (parentStaticFieldInitializer) {
73109
- var parentStaticFieldInitializerSymbol = getSymbolOfNode(parentStaticFieldInitializer.parent);
73110
- ts.Debug.assert(parentStaticFieldInitializerSymbol, "Initializer without declaration symbol");
73111
- 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));
73112
- ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(parentStaticFieldInitializer.parent, ts.Diagnostics.Initializer_for_property_0, ts.symbolName(parentStaticFieldInitializerSymbol)));
73113
- }
73114
- }
73115
73148
  if (isAnyLike) {
73116
73149
  if (lexicallyScopedSymbol) {
73117
73150
  return isErrorType(apparentType) ? errorType : apparentType;
@@ -75802,51 +75835,57 @@ var ts;
75802
75835
  ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) :
75803
75836
  checkExpression(node.exprName);
75804
75837
  var typeArguments = node.typeArguments;
75805
- if (!ts.some(typeArguments)) {
75838
+ if (exprType === silentNeverType || isErrorType(exprType) || !ts.some(typeArguments)) {
75806
75839
  return exprType;
75807
75840
  }
75808
- var funcType = getApparentType(exprType);
75809
- if (funcType === silentNeverType || isErrorType(funcType)) {
75810
- return funcType;
75811
- }
75812
75841
  var hasSomeApplicableSignature = false;
75813
75842
  var nonApplicableType;
75814
- var hasSignatures;
75815
- var hasApplicableSignature;
75816
- var result = mapType(funcType, getInstantiatedType);
75817
- var errorType = hasSomeApplicableSignature ? nonApplicableType : funcType;
75843
+ var result = getInstantiatedType(exprType);
75844
+ var errorType = hasSomeApplicableSignature ? nonApplicableType : exprType;
75818
75845
  if (errorType) {
75819
75846
  diagnostics.add(ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable, typeToString(errorType)));
75820
75847
  }
75821
75848
  return result;
75822
75849
  function getInstantiatedType(type) {
75823
- hasSignatures = false;
75824
- hasApplicableSignature = false;
75825
- var result = getInstantiatedTypeWorker(type);
75850
+ var hasSignatures = false;
75851
+ var hasApplicableSignature = false;
75852
+ var result = getInstantiatedTypePart(type);
75826
75853
  hasSomeApplicableSignature || (hasSomeApplicableSignature = hasApplicableSignature);
75827
75854
  if (hasSignatures && !hasApplicableSignature) {
75828
75855
  nonApplicableType !== null && nonApplicableType !== void 0 ? nonApplicableType : (nonApplicableType = type);
75829
75856
  }
75830
75857
  return result;
75831
- }
75832
- function getInstantiatedTypeWorker(type) {
75833
- if (type.flags & 524288 /* Object */) {
75834
- var resolved = resolveStructuredTypeMembers(type);
75835
- var callSignatures = getInstantiatedSignatures(resolved.callSignatures);
75836
- var constructSignatures = getInstantiatedSignatures(resolved.constructSignatures);
75837
- hasSignatures || (hasSignatures = resolved.callSignatures.length !== 0 || resolved.constructSignatures.length !== 0);
75838
- hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0);
75839
- if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) {
75840
- var result_11 = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos);
75841
- result_11.objectFlags |= 16777216 /* InstantiationExpressionType */;
75842
- result_11.node = node;
75843
- return result_11;
75858
+ function getInstantiatedTypePart(type) {
75859
+ if (type.flags & 524288 /* Object */) {
75860
+ var resolved = resolveStructuredTypeMembers(type);
75861
+ var callSignatures = getInstantiatedSignatures(resolved.callSignatures);
75862
+ var constructSignatures = getInstantiatedSignatures(resolved.constructSignatures);
75863
+ hasSignatures || (hasSignatures = resolved.callSignatures.length !== 0 || resolved.constructSignatures.length !== 0);
75864
+ hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0);
75865
+ if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) {
75866
+ var result_11 = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos);
75867
+ result_11.objectFlags |= 16777216 /* InstantiationExpressionType */;
75868
+ result_11.node = node;
75869
+ return result_11;
75870
+ }
75871
+ }
75872
+ else if (type.flags & 58982400 /* InstantiableNonPrimitive */) {
75873
+ var constraint = getBaseConstraintOfType(type);
75874
+ if (constraint) {
75875
+ var instantiated = getInstantiatedTypePart(constraint);
75876
+ if (instantiated !== constraint) {
75877
+ return instantiated;
75878
+ }
75879
+ }
75844
75880
  }
75881
+ else if (type.flags & 1048576 /* Union */) {
75882
+ return mapType(type, getInstantiatedType);
75883
+ }
75884
+ else if (type.flags & 2097152 /* Intersection */) {
75885
+ return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypePart));
75886
+ }
75887
+ return type;
75845
75888
  }
75846
- else if (type.flags & 2097152 /* Intersection */) {
75847
- return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypeWorker));
75848
- }
75849
- return type;
75850
75889
  }
75851
75890
  function getInstantiatedSignatures(signatures) {
75852
75891
  var applicableSignatures = ts.filter(signatures, function (sig) { return !!sig.typeParameters && hasCorrectTypeArgumentArity(sig, typeArguments); });
@@ -75934,6 +75973,10 @@ var ts;
75934
75973
  return restParameter.escapedName;
75935
75974
  }
75936
75975
  function getParameterIdentifierNameAtPosition(signature, pos) {
75976
+ var _a;
75977
+ if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 315 /* JSDocFunctionType */) {
75978
+ return undefined;
75979
+ }
75937
75980
  var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
75938
75981
  if (pos < paramCount) {
75939
75982
  var param = signature.parameters[pos];
@@ -78805,9 +78848,6 @@ var ts;
78805
78848
  checkGrammarComputedPropertyName(node.name);
78806
78849
  checkVariableLikeDeclaration(node);
78807
78850
  setNodeLinksForPrivateIdentifierScope(node);
78808
- if (ts.isPrivateIdentifier(node.name) && ts.hasStaticModifier(node) && node.initializer && languageVersion === 99 /* ESNext */ && !compilerOptions.useDefineForClassFields) {
78809
- 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);
78810
- }
78811
78851
  // property signatures already report "initializer not allowed in ambient context" elsewhere
78812
78852
  if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 166 /* PropertyDeclaration */ && node.initializer) {
78813
78853
  error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name));
@@ -84700,7 +84740,10 @@ var ts;
84700
84740
  case 80 /* PrivateIdentifier */:
84701
84741
  case 205 /* PropertyAccessExpression */:
84702
84742
  case 160 /* QualifiedName */:
84703
- return getSymbolOfNameOrPropertyAccessExpression(node);
84743
+ if (!ts.isThisInTypeQuery(node)) {
84744
+ return getSymbolOfNameOrPropertyAccessExpression(node);
84745
+ }
84746
+ // falls through
84704
84747
  case 108 /* ThisKeyword */:
84705
84748
  var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false);
84706
84749
  if (ts.isFunctionLike(container)) {
@@ -85945,7 +85988,7 @@ var ts;
85945
85988
  if (quickResult !== undefined) {
85946
85989
  return quickResult;
85947
85990
  }
85948
- var lastStatic, lastDeclare, lastAsync, lastReadonly, lastOverride;
85991
+ var lastStatic, lastDeclare, lastAsync, lastOverride;
85949
85992
  var flags = 0 /* None */;
85950
85993
  for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
85951
85994
  var modifier = _a[_i];
@@ -86049,7 +86092,6 @@ var ts;
86049
86092
  return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature);
86050
86093
  }
86051
86094
  flags |= 64 /* Readonly */;
86052
- lastReadonly = modifier;
86053
86095
  break;
86054
86096
  case 93 /* ExportKeyword */:
86055
86097
  if (flags & 1 /* Export */) {
@@ -86162,18 +86204,12 @@ var ts;
86162
86204
  if (flags & 32 /* Static */) {
86163
86205
  return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static");
86164
86206
  }
86165
- if (flags & 128 /* Abstract */) {
86166
- return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); // TODO: GH#18217
86167
- }
86168
86207
  if (flags & 16384 /* Override */) {
86169
86208
  return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217
86170
86209
  }
86171
- else if (flags & 256 /* Async */) {
86210
+ if (flags & 256 /* Async */) {
86172
86211
  return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async");
86173
86212
  }
86174
- else if (flags & 64 /* Readonly */) {
86175
- return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly");
86176
- }
86177
86213
  return false;
86178
86214
  }
86179
86215
  else if ((node.kind === 265 /* ImportDeclaration */ || node.kind === 264 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) {
@@ -92501,10 +92537,12 @@ var ts;
92501
92537
  var languageVersion = ts.getEmitScriptTarget(compilerOptions);
92502
92538
  var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions);
92503
92539
  var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ES2022 */;
92540
+ // We need to transform `this` in a static initializer into a reference to the class
92541
+ // when targeting < ES2022 since the assignment will be moved outside of the class body.
92542
+ var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ES2022 */;
92504
92543
  // We don't need to transform `super` property access when targeting ES5, ES3 because
92505
92544
  // the es2015 transformation handles those.
92506
- var shouldTransformSuperInStaticInitializers = (languageVersion <= 8 /* ES2021 */ || !useDefineForClassFields) && languageVersion >= 2 /* ES2015 */;
92507
- var shouldTransformThisInStaticInitializers = languageVersion <= 8 /* ES2021 */ || !useDefineForClassFields;
92545
+ var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */;
92508
92546
  var previousOnSubstituteNode = context.onSubstituteNode;
92509
92547
  context.onSubstituteNode = onSubstituteNode;
92510
92548
  var previousOnEmitNode = context.onEmitNode;
@@ -92733,6 +92771,10 @@ var ts;
92733
92771
  ts.Debug.assert(!ts.some(node.decorators));
92734
92772
  if (ts.isPrivateIdentifier(node.name)) {
92735
92773
  if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
92774
+ if (ts.isStatic(node)) {
92775
+ // static fields are left as is
92776
+ return ts.visitEachChild(node, visitor, context);
92777
+ }
92736
92778
  // Initializer is elided as the field is initialized in transformConstructor.
92737
92779
  return factory.updatePropertyDeclaration(node,
92738
92780
  /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name,
@@ -92754,6 +92796,22 @@ var ts;
92754
92796
  if (expr && !ts.isSimpleInlineableExpression(expr)) {
92755
92797
  getPendingExpressions().push(expr);
92756
92798
  }
92799
+ if (ts.isStatic(node) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
92800
+ var initializerStatement = transformPropertyOrClassStaticBlock(node, factory.createThis());
92801
+ if (initializerStatement) {
92802
+ var staticBlock = factory.createClassStaticBlockDeclaration(
92803
+ /*decorators*/ undefined,
92804
+ /*modifiers*/ undefined, factory.createBlock([initializerStatement]));
92805
+ ts.setOriginalNode(staticBlock, node);
92806
+ ts.setCommentRange(staticBlock, node);
92807
+ // Set the comment range for the statement to an empty synthetic range
92808
+ // and drop synthetic comments from the statement to avoid printing them twice.
92809
+ ts.setCommentRange(initializerStatement, { pos: -1, end: -1 });
92810
+ ts.setSyntheticLeadingComments(initializerStatement, undefined);
92811
+ ts.setSyntheticTrailingComments(initializerStatement, undefined);
92812
+ return staticBlock;
92813
+ }
92814
+ }
92757
92815
  return undefined;
92758
92816
  }
92759
92817
  function createPrivateIdentifierAccess(info, receiver) {
@@ -93141,7 +93199,6 @@ var ts;
93141
93199
  if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) {
93142
93200
  enableSubstitutionForClassStaticThisOrSuperReference();
93143
93201
  }
93144
- var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
93145
93202
  // If a class has private static fields, or a static field has a `this` or `super` reference,
93146
93203
  // then we need to allocate a temp variable to hold on to that reference.
93147
93204
  var pendingClassReferenceAssignment;
@@ -93169,6 +93226,7 @@ var ts;
93169
93226
  // From ES6 specification:
93170
93227
  // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using
93171
93228
  // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration.
93229
+ var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
93172
93230
  if (ts.some(staticProperties)) {
93173
93231
  addPropertyOrClassStaticBlockStatements(statements, staticProperties, factory.getInternalName(node));
93174
93232
  }
@@ -93207,7 +93265,7 @@ var ts;
93207
93265
  }
93208
93266
  var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), node.modifiers, node.name,
93209
93267
  /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, heritageClauseVisitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass));
93210
- var hasTransformableStatics = ts.some(staticPropertiesOrClassStaticBlocks, function (p) { return ts.isClassStaticBlockDeclaration(p) || !!p.initializer || (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifier(p.name)); });
93268
+ var hasTransformableStatics = shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(staticPropertiesOrClassStaticBlocks, function (p) { return ts.isClassStaticBlockDeclaration(p) || !!p.initializer || ts.isPrivateIdentifier(p.name); });
93211
93269
  if (hasTransformableStatics || ts.some(pendingExpressions)) {
93212
93270
  if (isDecoratedClassDeclaration) {
93213
93271
  ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration.");
@@ -93254,6 +93312,7 @@ var ts;
93254
93312
  return undefined;
93255
93313
  }
93256
93314
  function transformClassMembers(node, isDerivedClass) {
93315
+ var members = [];
93257
93316
  if (shouldTransformPrivateElementsOrClassStaticBlocks) {
93258
93317
  // Declare private names.
93259
93318
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
@@ -93266,12 +93325,20 @@ var ts;
93266
93325
  createBrandCheckWeakSetForPrivateMethods();
93267
93326
  }
93268
93327
  }
93269
- var members = [];
93270
93328
  var constructor = transformConstructor(node, isDerivedClass);
93329
+ var visitedMembers = ts.visitNodes(node.members, classElementVisitor, ts.isClassElement);
93271
93330
  if (constructor) {
93272
93331
  members.push(constructor);
93273
93332
  }
93274
- ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
93333
+ if (!shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(pendingExpressions)) {
93334
+ members.push(factory.createClassStaticBlockDeclaration(
93335
+ /*decorators*/ undefined,
93336
+ /*modifiers*/ undefined, factory.createBlock([
93337
+ factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))
93338
+ ])));
93339
+ pendingExpressions = undefined;
93340
+ }
93341
+ ts.addRange(members, visitedMembers);
93275
93342
  return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members);
93276
93343
  }
93277
93344
  function createBrandCheckWeakSetForPrivateMethods() {
@@ -93414,24 +93481,34 @@ var ts;
93414
93481
  function addPropertyOrClassStaticBlockStatements(statements, properties, receiver) {
93415
93482
  for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
93416
93483
  var property = properties_7[_i];
93417
- var expression = ts.isClassStaticBlockDeclaration(property) ?
93418
- transformClassStaticBlockDeclaration(property) :
93419
- transformProperty(property, receiver);
93420
- if (!expression) {
93484
+ if (ts.isStatic(property) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
93485
+ continue;
93486
+ }
93487
+ var statement = transformPropertyOrClassStaticBlock(property, receiver);
93488
+ if (!statement) {
93421
93489
  continue;
93422
93490
  }
93423
- var statement = factory.createExpressionStatement(expression);
93424
- ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
93425
- ts.setCommentRange(statement, property);
93426
- ts.setOriginalNode(statement, property);
93427
- // `setOriginalNode` *copies* the `emitNode` from `property`, so now both
93428
- // `statement` and `expression` have a copy of the synthesized comments.
93429
- // Drop the comments from expression to avoid printing them twice.
93430
- ts.setSyntheticLeadingComments(expression, undefined);
93431
- ts.setSyntheticTrailingComments(expression, undefined);
93432
93491
  statements.push(statement);
93433
93492
  }
93434
93493
  }
93494
+ function transformPropertyOrClassStaticBlock(property, receiver) {
93495
+ var expression = ts.isClassStaticBlockDeclaration(property) ?
93496
+ transformClassStaticBlockDeclaration(property) :
93497
+ transformProperty(property, receiver);
93498
+ if (!expression) {
93499
+ return undefined;
93500
+ }
93501
+ var statement = factory.createExpressionStatement(expression);
93502
+ ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
93503
+ ts.setCommentRange(statement, property);
93504
+ ts.setOriginalNode(statement, property);
93505
+ // `setOriginalNode` *copies* the `emitNode` from `property`, so now both
93506
+ // `statement` and `expression` have a copy of the synthesized comments.
93507
+ // Drop the comments from expression to avoid printing them twice.
93508
+ ts.setSyntheticLeadingComments(expression, undefined);
93509
+ ts.setSyntheticTrailingComments(expression, undefined);
93510
+ return statement;
93511
+ }
93435
93512
  /**
93436
93513
  * Generates assignment expressions for property initializers.
93437
93514
  *
@@ -94681,6 +94758,7 @@ var ts;
94681
94758
  var exportedVariableStatement = false;
94682
94759
  var enabledSubstitutions;
94683
94760
  var enclosingFunctionFlags;
94761
+ var parametersWithPrecedingObjectRestOrSpread;
94684
94762
  var enclosingSuperContainerFlags = 0;
94685
94763
  var hierarchyFacts = 0;
94686
94764
  var currentSourceFile;
@@ -95137,6 +95215,7 @@ var ts;
95137
95215
  /*incrementor*/ undefined,
95138
95216
  /*statement*/ convertForOfStatementHead(node, getValue)),
95139
95217
  /*location*/ node), 256 /* NoTokenTrailingSourceMaps */);
95218
+ ts.setOriginalNode(forStatement, node);
95140
95219
  return factory.createTryStatement(factory.createBlock([
95141
95220
  factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement)
95142
95221
  ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([
@@ -95154,7 +95233,19 @@ var ts;
95154
95233
  ]), 1 /* SingleLine */))
95155
95234
  ]));
95156
95235
  }
95236
+ function parameterVisitor(node) {
95237
+ ts.Debug.assertNode(node, ts.isParameter);
95238
+ return visitParameter(node);
95239
+ }
95157
95240
  function visitParameter(node) {
95241
+ if (parametersWithPrecedingObjectRestOrSpread === null || parametersWithPrecedingObjectRestOrSpread === void 0 ? void 0 : parametersWithPrecedingObjectRestOrSpread.has(node)) {
95242
+ return factory.updateParameterDeclaration(node,
95243
+ /*decorators*/ undefined,
95244
+ /*modifiers*/ undefined, node.dotDotDotToken, ts.isBindingPattern(node.name) ? factory.getGeneratedNameForNode(node) : node.name,
95245
+ /*questionToken*/ undefined,
95246
+ /*type*/ undefined,
95247
+ /*initializer*/ undefined);
95248
+ }
95158
95249
  if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
95159
95250
  // Binding patterns are converted into a generated name and are
95160
95251
  // evaluated inside the function body.
@@ -95166,85 +95257,119 @@ var ts;
95166
95257
  }
95167
95258
  return ts.visitEachChild(node, visitor, context);
95168
95259
  }
95260
+ function collectParametersWithPrecedingObjectRestOrSpread(node) {
95261
+ var parameters;
95262
+ for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
95263
+ var parameter = _a[_i];
95264
+ if (parameters) {
95265
+ parameters.add(parameter);
95266
+ }
95267
+ else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
95268
+ parameters = new ts.Set();
95269
+ }
95270
+ }
95271
+ return parameters;
95272
+ }
95169
95273
  function visitConstructorDeclaration(node) {
95170
95274
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95171
- enclosingFunctionFlags = 0 /* Normal */;
95275
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95276
+ enclosingFunctionFlags = ts.getFunctionFlags(node);
95277
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95172
95278
  var updated = factory.updateConstructorDeclaration(node,
95173
- /*decorators*/ undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
95279
+ /*decorators*/ undefined, node.modifiers, ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node));
95174
95280
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95281
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95175
95282
  return updated;
95176
95283
  }
95177
95284
  function visitGetAccessorDeclaration(node) {
95178
95285
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95179
- enclosingFunctionFlags = 0 /* Normal */;
95286
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95287
+ enclosingFunctionFlags = ts.getFunctionFlags(node);
95288
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95180
95289
  var updated = factory.updateGetAccessorDeclaration(node,
95181
- /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context),
95290
+ /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context),
95182
95291
  /*type*/ undefined, transformFunctionBody(node));
95183
95292
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95293
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95184
95294
  return updated;
95185
95295
  }
95186
95296
  function visitSetAccessorDeclaration(node) {
95187
95297
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95188
- enclosingFunctionFlags = 0 /* Normal */;
95298
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95299
+ enclosingFunctionFlags = ts.getFunctionFlags(node);
95300
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95189
95301
  var updated = factory.updateSetAccessorDeclaration(node,
95190
- /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
95302
+ /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node));
95191
95303
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95304
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95192
95305
  return updated;
95193
95306
  }
95194
95307
  function visitMethodDeclaration(node) {
95195
95308
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95309
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95196
95310
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95311
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95197
95312
  var updated = factory.updateMethodDeclaration(node,
95198
95313
  /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */
95199
95314
  ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
95200
95315
  : node.modifiers, enclosingFunctionFlags & 2 /* Async */
95201
95316
  ? undefined
95202
95317
  : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(/*questionToken*/ undefined, visitor, ts.isToken),
95203
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95318
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
95204
95319
  /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
95205
95320
  ? transformAsyncGeneratorFunctionBody(node)
95206
95321
  : transformFunctionBody(node));
95207
95322
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95323
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95208
95324
  return updated;
95209
95325
  }
95210
95326
  function visitFunctionDeclaration(node) {
95211
95327
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95328
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95212
95329
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95330
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95213
95331
  var updated = factory.updateFunctionDeclaration(node,
95214
95332
  /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */
95215
95333
  ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
95216
95334
  : node.modifiers, enclosingFunctionFlags & 2 /* Async */
95217
95335
  ? undefined
95218
95336
  : node.asteriskToken, node.name,
95219
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95337
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
95220
95338
  /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
95221
95339
  ? transformAsyncGeneratorFunctionBody(node)
95222
95340
  : transformFunctionBody(node));
95223
95341
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95342
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95224
95343
  return updated;
95225
95344
  }
95226
95345
  function visitArrowFunction(node) {
95227
95346
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95347
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95228
95348
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95349
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95229
95350
  var updated = factory.updateArrowFunction(node, node.modifiers,
95230
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95351
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
95231
95352
  /*type*/ undefined, node.equalsGreaterThanToken, transformFunctionBody(node));
95232
95353
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95354
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95233
95355
  return updated;
95234
95356
  }
95235
95357
  function visitFunctionExpression(node) {
95236
95358
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95359
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95237
95360
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95361
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95238
95362
  var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */
95239
95363
  ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
95240
95364
  : node.modifiers, enclosingFunctionFlags & 2 /* Async */
95241
95365
  ? undefined
95242
95366
  : node.asteriskToken, node.name,
95243
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95367
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
95244
95368
  /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
95245
95369
  ? transformAsyncGeneratorFunctionBody(node)
95246
95370
  : transformFunctionBody(node));
95247
95371
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95372
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95248
95373
  return updated;
95249
95374
  }
95250
95375
  function transformAsyncGeneratorFunctionBody(node) {
@@ -95305,16 +95430,71 @@ var ts;
95305
95430
  return body;
95306
95431
  }
95307
95432
  function appendObjectRestAssignmentsIfNeeded(statements, node) {
95433
+ var containsPrecedingObjectRestOrSpread = false;
95308
95434
  for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
95309
95435
  var parameter = _a[_i];
95310
- if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
95311
- var temp = factory.getGeneratedNameForNode(parameter);
95312
- var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, temp,
95436
+ if (containsPrecedingObjectRestOrSpread) {
95437
+ if (ts.isBindingPattern(parameter.name)) {
95438
+ // In cases where a binding pattern is simply '[]' or '{}',
95439
+ // we usually don't want to emit a var declaration; however, in the presence
95440
+ // of an initializer, we must emit that expression to preserve side effects.
95441
+ //
95442
+ // NOTE: see `insertDefaultValueAssignmentForBindingPattern` in es2015.ts
95443
+ if (parameter.name.elements.length > 0) {
95444
+ var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter));
95445
+ if (ts.some(declarations)) {
95446
+ var declarationList = factory.createVariableDeclarationList(declarations);
95447
+ var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList);
95448
+ ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
95449
+ statements = ts.append(statements, statement);
95450
+ }
95451
+ }
95452
+ else if (parameter.initializer) {
95453
+ var name = factory.getGeneratedNameForNode(parameter);
95454
+ var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression);
95455
+ var assignment = factory.createAssignment(name, initializer);
95456
+ var statement = factory.createExpressionStatement(assignment);
95457
+ ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
95458
+ statements = ts.append(statements, statement);
95459
+ }
95460
+ }
95461
+ else if (parameter.initializer) {
95462
+ // Converts a parameter initializer into a function body statement, i.e.:
95463
+ //
95464
+ // function f(x = 1) { }
95465
+ //
95466
+ // becomes
95467
+ //
95468
+ // function f(x) {
95469
+ // if (typeof x === "undefined") { x = 1; }
95470
+ // }
95471
+ var name = factory.cloneNode(parameter.name);
95472
+ ts.setTextRange(name, parameter.name);
95473
+ ts.setEmitFlags(name, 48 /* NoSourceMap */);
95474
+ var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression);
95475
+ ts.addEmitFlags(initializer, 48 /* NoSourceMap */ | 1536 /* NoComments */);
95476
+ var assignment = factory.createAssignment(name, initializer);
95477
+ ts.setTextRange(assignment, parameter);
95478
+ ts.setEmitFlags(assignment, 1536 /* NoComments */);
95479
+ var block = factory.createBlock([factory.createExpressionStatement(assignment)]);
95480
+ ts.setTextRange(block, parameter);
95481
+ ts.setEmitFlags(block, 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */);
95482
+ var typeCheck = factory.createTypeCheck(factory.cloneNode(parameter.name), "undefined");
95483
+ var statement = factory.createIfStatement(typeCheck, block);
95484
+ ts.startOnNewLine(statement);
95485
+ ts.setTextRange(statement, parameter);
95486
+ ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */);
95487
+ statements = ts.append(statements, statement);
95488
+ }
95489
+ }
95490
+ else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
95491
+ containsPrecedingObjectRestOrSpread = true;
95492
+ var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter),
95313
95493
  /*doNotRecordTempVariablesInLine*/ false,
95314
95494
  /*skipInitializer*/ true);
95315
95495
  if (ts.some(declarations)) {
95316
- var statement = factory.createVariableStatement(
95317
- /*modifiers*/ undefined, factory.createVariableDeclarationList(declarations));
95496
+ var declarationList = factory.createVariableDeclarationList(declarations);
95497
+ var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList);
95318
95498
  ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
95319
95499
  statements = ts.append(statements, statement);
95320
95500
  }
@@ -98565,10 +98745,12 @@ var ts;
98565
98745
  // variables declared in the loop initializer that will be changed inside the loop
98566
98746
  var loopOutParameters = [];
98567
98747
  if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) {
98568
- var hasCapturedBindingsInForInitializer = shouldConvertInitializerOfForStatement(node);
98748
+ var hasCapturedBindingsInForHead = shouldConvertInitializerOfForStatement(node) ||
98749
+ shouldConvertConditionOfForStatement(node) ||
98750
+ shouldConvertIncrementorOfForStatement(node);
98569
98751
  for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) {
98570
98752
  var decl = _a[_i];
98571
- processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
98753
+ processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForHead);
98572
98754
  }
98573
98755
  }
98574
98756
  var currentState = { loopParameters: loopParameters, loopOutParameters: loopOutParameters };
@@ -98922,27 +99104,33 @@ var ts;
98922
99104
  caseClauses.push(factory.createCaseClause(factory.createStringLiteral(labelMarker), statements));
98923
99105
  });
98924
99106
  }
98925
- function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer) {
99107
+ function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForHead) {
98926
99108
  var name = decl.name;
98927
99109
  if (ts.isBindingPattern(name)) {
98928
99110
  for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
98929
99111
  var element = _a[_i];
98930
99112
  if (!ts.isOmittedExpression(element)) {
98931
- processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
99113
+ processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForHead);
98932
99114
  }
98933
99115
  }
98934
99116
  }
98935
99117
  else {
98936
99118
  loopParameters.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name));
98937
99119
  var checkFlags = resolver.getNodeCheckFlags(decl);
98938
- if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForInitializer) {
99120
+ if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) {
98939
99121
  var outParamName = factory.createUniqueName("out_" + ts.idText(name));
98940
99122
  var flags = 0;
98941
99123
  if (checkFlags & 4194304 /* NeedsLoopOutParameter */) {
98942
99124
  flags |= 1 /* Body */;
98943
99125
  }
98944
- if (ts.isForStatement(container) && container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
98945
- flags |= 2 /* Initializer */;
99126
+ if (ts.isForStatement(container)) {
99127
+ if (container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
99128
+ flags |= 2 /* Initializer */;
99129
+ }
99130
+ if (container.condition && resolver.isBindingCapturedByNode(container.condition, decl) ||
99131
+ container.incrementor && resolver.isBindingCapturedByNode(container.incrementor, decl)) {
99132
+ flags |= 1 /* Body */;
99133
+ }
98946
99134
  }
98947
99135
  loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName });
98948
99136
  }
@@ -120317,7 +120505,7 @@ var ts;
120317
120505
  if (!host.fileExists || !host.readFile) {
120318
120506
  return undefined;
120319
120507
  }
120320
- var parts = getNodeModulePathParts(path);
120508
+ var parts = ts.getNodeModulePathParts(path);
120321
120509
  if (!parts) {
120322
120510
  return undefined;
120323
120511
  }
@@ -120440,58 +120628,6 @@ var ts;
120440
120628
  }
120441
120629
  }
120442
120630
  }
120443
- function getNodeModulePathParts(fullPath) {
120444
- // If fullPath can't be valid module file within node_modules, returns undefined.
120445
- // Example of expected pattern: /base/path/node_modules/[@scope/otherpackage/@otherscope/node_modules/]package/[subdirectory/]file.js
120446
- // Returns indices: ^ ^ ^ ^
120447
- var topLevelNodeModulesIndex = 0;
120448
- var topLevelPackageNameIndex = 0;
120449
- var packageRootIndex = 0;
120450
- var fileNameIndex = 0;
120451
- var States;
120452
- (function (States) {
120453
- States[States["BeforeNodeModules"] = 0] = "BeforeNodeModules";
120454
- States[States["NodeModules"] = 1] = "NodeModules";
120455
- States[States["Scope"] = 2] = "Scope";
120456
- States[States["PackageContent"] = 3] = "PackageContent";
120457
- })(States || (States = {}));
120458
- var partStart = 0;
120459
- var partEnd = 0;
120460
- var state = 0 /* BeforeNodeModules */;
120461
- while (partEnd >= 0) {
120462
- partStart = partEnd;
120463
- partEnd = fullPath.indexOf("/", partStart + 1);
120464
- switch (state) {
120465
- case 0 /* BeforeNodeModules */:
120466
- if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
120467
- topLevelNodeModulesIndex = partStart;
120468
- topLevelPackageNameIndex = partEnd;
120469
- state = 1 /* NodeModules */;
120470
- }
120471
- break;
120472
- case 1 /* NodeModules */:
120473
- case 2 /* Scope */:
120474
- if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") {
120475
- state = 2 /* Scope */;
120476
- }
120477
- else {
120478
- packageRootIndex = partEnd;
120479
- state = 3 /* PackageContent */;
120480
- }
120481
- break;
120482
- case 3 /* PackageContent */:
120483
- if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
120484
- state = 1 /* NodeModules */;
120485
- }
120486
- else {
120487
- state = 3 /* PackageContent */;
120488
- }
120489
- break;
120490
- }
120491
- }
120492
- fileNameIndex = partStart;
120493
- return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
120494
- }
120495
120631
  function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
120496
120632
  return ts.firstDefined(rootDirs, function (rootDir) {
120497
120633
  var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
@@ -126434,7 +126570,7 @@ var ts;
126434
126570
  parts.push(linkTextPart(text));
126435
126571
  }
126436
126572
  else {
126437
- parts.push(linkTextPart(name + (suffix ? "" : " ") + text));
126573
+ parts.push(linkTextPart(name + (suffix || text.indexOf("://") === 0 ? "" : " ") + text));
126438
126574
  }
126439
126575
  }
126440
126576
  parts.push(linkPart("}"));
@@ -127255,15 +127391,35 @@ var ts;
127255
127391
  return ts.isArray(valueOrArray) ? ts.first(valueOrArray) : valueOrArray;
127256
127392
  }
127257
127393
  ts.firstOrOnly = firstOrOnly;
127394
+ function getNamesForExportedSymbol(symbol, scriptTarget) {
127395
+ if (needsNameFromDeclaration(symbol)) {
127396
+ var fromDeclaration = getDefaultLikeExportNameFromDeclaration(symbol);
127397
+ if (fromDeclaration)
127398
+ return fromDeclaration;
127399
+ var fileNameCase = ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, /*preferCapitalized*/ false);
127400
+ var capitalized = ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, /*preferCapitalized*/ true);
127401
+ if (fileNameCase === capitalized)
127402
+ return fileNameCase;
127403
+ return [fileNameCase, capitalized];
127404
+ }
127405
+ return symbol.name;
127406
+ }
127407
+ ts.getNamesForExportedSymbol = getNamesForExportedSymbol;
127258
127408
  function getNameForExportedSymbol(symbol, scriptTarget, preferCapitalized) {
127259
- if (!(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */)) {
127409
+ if (needsNameFromDeclaration(symbol)) {
127260
127410
  // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase.
127261
- 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; })
127411
+ return getDefaultLikeExportNameFromDeclaration(symbol)
127262
127412
  || ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, !!preferCapitalized);
127263
127413
  }
127264
127414
  return symbol.name;
127265
127415
  }
127266
127416
  ts.getNameForExportedSymbol = getNameForExportedSymbol;
127417
+ function needsNameFromDeclaration(symbol) {
127418
+ return !(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */);
127419
+ }
127420
+ function getDefaultLikeExportNameFromDeclaration(symbol) {
127421
+ 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; });
127422
+ }
127267
127423
  function getSymbolParentOrFail(symbol) {
127268
127424
  var _a;
127269
127425
  return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: " + ts.Debug.formatSymbolFlags(symbol.flags) + ". " +
@@ -127378,6 +127534,17 @@ var ts;
127378
127534
  var exportInfoId = 1;
127379
127535
  var exportInfo = ts.createMultiMap();
127380
127536
  var symbols = new ts.Map();
127537
+ /**
127538
+ * Key: node_modules package name (no @types).
127539
+ * Value: path to deepest node_modules folder seen that is
127540
+ * both visible to `usableByFileName` and contains the package.
127541
+ *
127542
+ * Later, we can see if a given SymbolExportInfo is shadowed by
127543
+ * a another installation of the same package in a deeper
127544
+ * node_modules folder by seeing if its path starts with the
127545
+ * value stored here.
127546
+ */
127547
+ var packages = new ts.Map();
127381
127548
  var usableByFileName;
127382
127549
  var cache = {
127383
127550
  isUsableByFile: function (importingFile) { return importingFile === usableByFileName; },
@@ -127392,6 +127559,27 @@ var ts;
127392
127559
  cache.clear();
127393
127560
  usableByFileName = importingFile;
127394
127561
  }
127562
+ var packageName;
127563
+ if (moduleFile) {
127564
+ var nodeModulesPathParts = ts.getNodeModulePathParts(moduleFile.fileName);
127565
+ if (nodeModulesPathParts) {
127566
+ var topLevelNodeModulesIndex = nodeModulesPathParts.topLevelNodeModulesIndex, topLevelPackageNameIndex = nodeModulesPathParts.topLevelPackageNameIndex, packageRootIndex = nodeModulesPathParts.packageRootIndex;
127567
+ packageName = ts.unmangleScopedPackageName(ts.getPackageNameFromTypesPackageName(moduleFile.fileName.substring(topLevelPackageNameIndex + 1, packageRootIndex)));
127568
+ if (ts.startsWith(importingFile, moduleFile.path.substring(0, topLevelNodeModulesIndex))) {
127569
+ var prevDeepestNodeModulesPath = packages.get(packageName);
127570
+ var nodeModulesPath = moduleFile.fileName.substring(0, topLevelPackageNameIndex);
127571
+ if (prevDeepestNodeModulesPath) {
127572
+ var prevDeepestNodeModulesIndex = prevDeepestNodeModulesPath.indexOf(ts.nodeModulesPathPart);
127573
+ if (topLevelNodeModulesIndex > prevDeepestNodeModulesIndex) {
127574
+ packages.set(packageName, nodeModulesPath);
127575
+ }
127576
+ }
127577
+ else {
127578
+ packages.set(packageName, nodeModulesPath);
127579
+ }
127580
+ }
127581
+ }
127582
+ }
127395
127583
  var isDefault = exportKind === 1 /* Default */;
127396
127584
  var namedSymbol = isDefault && ts.getLocalSymbolForExportDefault(symbol) || symbol;
127397
127585
  // 1. A named export must be imported by its key in `moduleSymbol.exports` or `moduleSymbol.members`.
@@ -127401,9 +127589,11 @@ var ts;
127401
127589
  // 3. Otherwise, we have a default/namespace import that can be imported by any name, and
127402
127590
  // `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to
127403
127591
  // get a better name.
127404
- var importedName = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
127592
+ var names = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
127405
127593
  ? ts.unescapeLeadingUnderscores(symbolTableKey)
127406
- : ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
127594
+ : ts.getNamesForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
127595
+ var symbolName = typeof names === "string" ? names : names[0];
127596
+ var capitalizedSymbolName = typeof names === "string" ? undefined : names[1];
127407
127597
  var moduleName = ts.stripQuotes(moduleSymbol.name);
127408
127598
  var id = exportInfoId++;
127409
127599
  var target = ts.skipAlias(symbol, checker);
@@ -127411,13 +127601,15 @@ var ts;
127411
127601
  var storedModuleSymbol = moduleSymbol.flags & 33554432 /* Transient */ ? undefined : moduleSymbol;
127412
127602
  if (!storedSymbol || !storedModuleSymbol)
127413
127603
  symbols.set(id, [symbol, moduleSymbol]);
127414
- exportInfo.add(key(importedName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), {
127604
+ exportInfo.add(key(symbolName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), {
127415
127605
  id: id,
127416
127606
  symbolTableKey: symbolTableKey,
127417
- symbolName: importedName,
127607
+ symbolName: symbolName,
127608
+ capitalizedSymbolName: capitalizedSymbolName,
127418
127609
  moduleName: moduleName,
127419
127610
  moduleFile: moduleFile,
127420
127611
  moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName,
127612
+ packageName: packageName,
127421
127613
  exportKind: exportKind,
127422
127614
  targetFlags: target.flags,
127423
127615
  isFromPackageJson: isFromPackageJson,
@@ -127431,19 +127623,19 @@ var ts;
127431
127623
  var result = exportInfo.get(key);
127432
127624
  return result === null || result === void 0 ? void 0 : result.map(rehydrateCachedInfo);
127433
127625
  },
127434
- forEach: function (importingFile, action) {
127626
+ search: function (importingFile, preferCapitalized, matches, action) {
127435
127627
  if (importingFile !== usableByFileName)
127436
127628
  return;
127437
127629
  exportInfo.forEach(function (info, key) {
127438
127630
  var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
127439
- var rehydrated = info.map(rehydrateCachedInfo);
127440
- action(rehydrated, function (preferCapitalized) {
127441
- var _a = rehydrated[0], symbol = _a.symbol, exportKind = _a.exportKind;
127442
- var namedSymbol = exportKind === 1 /* Default */ && ts.getLocalSymbolForExportDefault(symbol) || symbol;
127443
- return preferCapitalized
127444
- ? ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined, /*preferCapitalized*/ true)
127445
- : symbolName;
127446
- }, !!ambientModuleName, key);
127631
+ var name = preferCapitalized && info[0].capitalizedSymbolName || symbolName;
127632
+ if (matches(name, info[0].targetFlags)) {
127633
+ var rehydrated = info.map(rehydrateCachedInfo);
127634
+ var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
127635
+ if (filtered.length) {
127636
+ action(filtered, name, !!ambientModuleName, key);
127637
+ }
127638
+ }
127447
127639
  });
127448
127640
  },
127449
127641
  releaseSymbols: function () {
@@ -127543,6 +127735,12 @@ var ts;
127543
127735
  }
127544
127736
  return true;
127545
127737
  }
127738
+ function isNotShadowedByDeeperNodeModulesPackage(info, packageName) {
127739
+ if (!packageName || !info.moduleFileName)
127740
+ return true;
127741
+ var packageDeepestNodeModulesPath = packages.get(packageName);
127742
+ return !packageDeepestNodeModulesPath || ts.startsWith(info.moduleFileName, packageDeepestNodeModulesPath);
127743
+ }
127546
127744
  }
127547
127745
  ts.createCacheableExportInfoMap = createCacheableExportInfoMap;
127548
127746
  function isImportableFile(program, from, to, preferences, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) {
@@ -129853,7 +130051,7 @@ var ts;
129853
130051
  }
129854
130052
  switch (completionData.kind) {
129855
130053
  case 0 /* Data */:
129856
- var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext);
130054
+ var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position);
129857
130055
  if (response === null || response === void 0 ? void 0 : response.isIncomplete) {
129858
130056
  incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response);
129859
130057
  }
@@ -129973,7 +130171,7 @@ var ts;
129973
130171
  // StringLiteralLike locations are handled separately in stringCompletions.ts
129974
130172
  return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
129975
130173
  }
129976
- function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext) {
130174
+ function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) {
129977
130175
  var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
129978
130176
  // Verify if the file is JSX language variant
129979
130177
  if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
@@ -129986,7 +130184,7 @@ var ts;
129986
130184
  if (isUncheckedFile(sourceFile, compilerOptions)) {
129987
130185
  var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
129988
130186
  /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
129989
- getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
130187
+ getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
129990
130188
  }
129991
130189
  else {
129992
130190
  if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
@@ -129996,16 +130194,23 @@ var ts;
129996
130194
  /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
129997
130195
  }
129998
130196
  if (keywordFilters !== 0 /* None */) {
129999
- var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
130197
+ var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; }));
130000
130198
  for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
130001
130199
  var keywordEntry = _a[_i];
130002
- if (!entryNames.has(keywordEntry.name)) {
130200
+ if (!entryNames_1.has(keywordEntry.name)) {
130003
130201
  ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
130004
130202
  }
130005
130203
  }
130006
130204
  }
130007
- for (var _b = 0, literals_1 = literals; _b < literals_1.length; _b++) {
130008
- var literal = literals_1[_b];
130205
+ var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
130206
+ for (var _b = 0, _c = getContextualKeywords(contextToken, position); _b < _c.length; _b++) {
130207
+ var keywordEntry = _c[_b];
130208
+ if (!entryNames.has(keywordEntry.name)) {
130209
+ ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
130210
+ }
130211
+ }
130212
+ for (var _d = 0, literals_1 = literals; _d < literals_1.length; _d++) {
130213
+ var literal = literals_1[_d];
130009
130214
  ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
130010
130215
  }
130011
130216
  return {
@@ -131545,44 +131750,47 @@ var ts;
131545
131750
  var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
131546
131751
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
131547
131752
  resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
131548
- exportInfo.forEach(sourceFile.path, function (info, getSymbolName, isFromAmbientModule, exportMapKey) {
131549
- var symbolName = getSymbolName(/*preferCapitalized*/ isRightOfOpenTag);
131753
+ exportInfo.search(sourceFile.path,
131754
+ /*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
131550
131755
  if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
131551
- return;
131756
+ return false;
131552
131757
  if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
131553
- return;
131554
- // `targetFlags` should be the same for each `info`
131555
- if (!isTypeOnlyLocation && !importCompletionNode && !(info[0].targetFlags & 111551 /* Value */))
131556
- return;
131557
- if (isTypeOnlyLocation && !(info[0].targetFlags & (1536 /* Module */ | 788968 /* Type */)))
131558
- return;
131758
+ return false;
131759
+ if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* Value */))
131760
+ return false;
131761
+ if (isTypeOnlyLocation && !(targetFlags & (1536 /* Module */ | 788968 /* Type */)))
131762
+ return false;
131559
131763
  // Do not try to auto-import something with a lowercase first letter for a JSX tag
131560
131764
  var firstChar = symbolName.charCodeAt(0);
131561
131765
  if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */))
131766
+ return false;
131767
+ if (detailsEntryId)
131768
+ return true;
131769
+ return charactersFuzzyMatchInString(symbolName, lowerCaseTokenText);
131770
+ }, function (info, symbolName, isFromAmbientModule, exportMapKey) {
131771
+ if (detailsEntryId && !ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); })) {
131562
131772
  return;
131563
- var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); });
131564
- if (isCompletionDetailsMatch || !detailsEntryId && charactersFuzzyMatchInString(symbolName, lowerCaseTokenText)) {
131565
- var defaultExportInfo = ts.find(info, isImportableExportInfo);
131566
- if (!defaultExportInfo) {
131567
- return;
131568
- }
131569
- // If we don't need to resolve module specifiers, we can use any re-export that is importable at all
131570
- // (We need to ensure that at least one is importable to show a completion.)
131571
- var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo_1 = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
131572
- var isDefaultExport = exportInfo_1.exportKind === 1 /* Default */;
131573
- var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo_1.symbol) || exportInfo_1.symbol;
131574
- pushAutoImportSymbol(symbol, {
131575
- kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
131576
- moduleSpecifier: moduleSpecifier,
131577
- symbolName: symbolName,
131578
- exportMapKey: exportMapKey,
131579
- exportName: exportInfo_1.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo_1.symbol.name,
131580
- fileName: exportInfo_1.moduleFileName,
131581
- isDefaultExport: isDefaultExport,
131582
- moduleSymbol: exportInfo_1.moduleSymbol,
131583
- isFromPackageJson: exportInfo_1.isFromPackageJson,
131584
- });
131585
131773
  }
131774
+ var defaultExportInfo = ts.find(info, isImportableExportInfo);
131775
+ if (!defaultExportInfo) {
131776
+ return;
131777
+ }
131778
+ // If we don't need to resolve module specifiers, we can use any re-export that is importable at all
131779
+ // (We need to ensure that at least one is importable to show a completion.)
131780
+ var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
131781
+ var isDefaultExport = exportInfo.exportKind === 1 /* Default */;
131782
+ var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol;
131783
+ pushAutoImportSymbol(symbol, {
131784
+ kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
131785
+ moduleSpecifier: moduleSpecifier,
131786
+ symbolName: symbolName,
131787
+ exportMapKey: exportMapKey,
131788
+ exportName: exportInfo.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo.symbol.name,
131789
+ fileName: exportInfo.moduleFileName,
131790
+ isDefaultExport: isDefaultExport,
131791
+ moduleSymbol: exportInfo.moduleSymbol,
131792
+ isFromPackageJson: exportInfo.isFromPackageJson,
131793
+ });
131586
131794
  });
131587
131795
  hasUnresolvedAutoImports = context.resolutionLimitExceeded();
131588
131796
  });
@@ -132555,6 +132763,34 @@ var ts;
132555
132763
  function keywordForNode(node) {
132556
132764
  return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind;
132557
132765
  }
132766
+ function getContextualKeywords(contextToken, position) {
132767
+ var entries = [];
132768
+ /**
132769
+ * An `AssertClause` can come after an import declaration:
132770
+ * import * from "foo" |
132771
+ * import "foo" |
132772
+ * or after a re-export declaration that has a module specifier:
132773
+ * export { foo } from "foo" |
132774
+ * Source: https://tc39.es/proposal-import-assertions/
132775
+ */
132776
+ if (contextToken) {
132777
+ var file = contextToken.getSourceFile();
132778
+ var parent = contextToken.parent;
132779
+ var tokenLine = file.getLineAndCharacterOfPosition(contextToken.end).line;
132780
+ var currentLine = file.getLineAndCharacterOfPosition(position).line;
132781
+ if ((ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent) && parent.moduleSpecifier)
132782
+ && contextToken === parent.moduleSpecifier
132783
+ && tokenLine === currentLine) {
132784
+ entries.push({
132785
+ name: ts.tokenToString(129 /* AssertKeyword */),
132786
+ kind: "keyword" /* keyword */,
132787
+ kindModifiers: "" /* none */,
132788
+ sortText: SortText.GlobalsOrKeywords,
132789
+ });
132790
+ }
132791
+ }
132792
+ return entries;
132793
+ }
132558
132794
  /** Get the corresponding JSDocTag node if the position is in a jsDoc comment */
132559
132795
  function getJsDocTagAtPosition(node, position) {
132560
132796
  return ts.findAncestor(node, function (n) {
@@ -137493,7 +137729,27 @@ var ts;
137493
137729
  case 326 /* JSDocAugmentsTag */:
137494
137730
  return withNode(tag.class);
137495
137731
  case 342 /* JSDocTemplateTag */:
137496
- return addComment(tag.typeParameters.map(function (tp) { return tp.getText(); }).join(", "));
137732
+ var templateTag = tag;
137733
+ var displayParts_3 = [];
137734
+ if (templateTag.constraint) {
137735
+ displayParts_3.push(ts.textPart(templateTag.constraint.getText()));
137736
+ }
137737
+ if (ts.length(templateTag.typeParameters)) {
137738
+ if (ts.length(displayParts_3)) {
137739
+ displayParts_3.push(ts.spacePart());
137740
+ }
137741
+ var lastTypeParameter_1 = templateTag.typeParameters[templateTag.typeParameters.length - 1];
137742
+ ts.forEach(templateTag.typeParameters, function (tp) {
137743
+ displayParts_3.push(namePart(tp.getText()));
137744
+ if (lastTypeParameter_1 !== tp) {
137745
+ displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]);
137746
+ }
137747
+ });
137748
+ }
137749
+ if (comment) {
137750
+ displayParts_3.push.apply(displayParts_3, __spreadArray([ts.spacePart()], getDisplayPartsFromComment(comment, checker), true));
137751
+ }
137752
+ return displayParts_3;
137497
137753
  case 341 /* JSDocTypeTag */:
137498
137754
  return withNode(tag.typeExpression);
137499
137755
  case 343 /* JSDocTypedefTag */:
@@ -138981,7 +139237,7 @@ var ts;
138981
139237
  newImportSpecifiers.push(ts.factory.createImportSpecifier(/*isTypeOnly*/ false, ts.factory.createIdentifier("default"), defaultImport.importClause.name)); // TODO: GH#18217
138982
139238
  }
138983
139239
  }
138984
- newImportSpecifiers.push.apply(newImportSpecifiers, ts.flatMap(namedImports, function (i) { return i.importClause.namedBindings.elements; })); // TODO: GH#18217
139240
+ newImportSpecifiers.push.apply(newImportSpecifiers, getNewImportSpecifiers(namedImports));
138985
139241
  var sortedImportSpecifiers = sortSpecifiers(newImportSpecifiers);
138986
139242
  var importDecl = defaultImports.length > 0
138987
139243
  ? defaultImports[0]
@@ -139191,6 +139447,21 @@ var ts;
139191
139447
  return 6;
139192
139448
  }
139193
139449
  }
139450
+ function getNewImportSpecifiers(namedImports) {
139451
+ return ts.flatMap(namedImports, function (namedImport) {
139452
+ return ts.map(tryGetNamedBindingElements(namedImport), function (importSpecifier) {
139453
+ return importSpecifier.name && importSpecifier.propertyName && importSpecifier.name.escapedText === importSpecifier.propertyName.escapedText
139454
+ ? ts.factory.updateImportSpecifier(importSpecifier, importSpecifier.isTypeOnly, /*propertyName*/ undefined, importSpecifier.name)
139455
+ : importSpecifier;
139456
+ });
139457
+ });
139458
+ }
139459
+ function tryGetNamedBindingElements(namedImport) {
139460
+ var _a;
139461
+ return ((_a = namedImport.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings) && ts.isNamedImports(namedImport.importClause.namedBindings)
139462
+ ? namedImport.importClause.namedBindings.elements
139463
+ : undefined;
139464
+ }
139194
139465
  })(OrganizeImports = ts.OrganizeImports || (ts.OrganizeImports = {}));
139195
139466
  })(ts || (ts = {}));
139196
139467
  /* @internal */
@@ -140904,12 +141175,12 @@ var ts;
140904
141175
  : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex };
140905
141176
  }
140906
141177
  SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions;
140907
- function getArgumentOrParameterListInfo(node, sourceFile) {
141178
+ function getArgumentOrParameterListInfo(node, position, sourceFile) {
140908
141179
  var info = getArgumentOrParameterListAndIndex(node, sourceFile);
140909
141180
  if (!info)
140910
141181
  return undefined;
140911
141182
  var list = info.list, argumentIndex = info.argumentIndex;
140912
- var argumentCount = getArgumentCount(list);
141183
+ var argumentCount = getArgumentCount(list, /*ignoreTrailingComma*/ ts.isInString(sourceFile, position, node));
140913
141184
  if (argumentIndex !== 0) {
140914
141185
  ts.Debug.assertLessThan(argumentIndex, argumentCount);
140915
141186
  }
@@ -140955,7 +141226,7 @@ var ts;
140955
141226
  // Case 3:
140956
141227
  // foo<T#, U#>(a#, #b#) -> The token is buried inside a list, and should give signature help
140957
141228
  // Find out if 'node' is an argument, a type argument, or neither
140958
- var info = getArgumentOrParameterListInfo(node, sourceFile);
141229
+ var info = getArgumentOrParameterListInfo(node, position, sourceFile);
140959
141230
  if (!info)
140960
141231
  return undefined;
140961
141232
  var list = info.list, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
@@ -141024,8 +141295,8 @@ var ts;
141024
141295
  function countBinaryExpressionParameters(b) {
141025
141296
  return ts.isBinaryExpression(b.left) ? countBinaryExpressionParameters(b.left) + 1 : 2;
141026
141297
  }
141027
- function tryGetParameterInfo(startingToken, _position, sourceFile, checker) {
141028
- var info = getContextualSignatureLocationInfo(startingToken, sourceFile, checker);
141298
+ function tryGetParameterInfo(startingToken, position, sourceFile, checker) {
141299
+ var info = getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker);
141029
141300
  if (!info)
141030
141301
  return undefined;
141031
141302
  var contextualType = info.contextualType, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
@@ -141037,7 +141308,7 @@ var ts;
141037
141308
  var invocation = { kind: 2 /* Contextual */, signature: ts.first(signatures), node: startingToken, symbol: chooseBetterSymbol(nonNullableContextualType.symbol) };
141038
141309
  return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount };
141039
141310
  }
141040
- function getContextualSignatureLocationInfo(startingToken, sourceFile, checker) {
141311
+ function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) {
141041
141312
  if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */)
141042
141313
  return undefined;
141043
141314
  var parent = startingToken.parent;
@@ -141046,7 +141317,7 @@ var ts;
141046
141317
  case 168 /* MethodDeclaration */:
141047
141318
  case 212 /* FunctionExpression */:
141048
141319
  case 213 /* ArrowFunction */:
141049
- var info = getArgumentOrParameterListInfo(startingToken, sourceFile);
141320
+ var info = getArgumentOrParameterListInfo(startingToken, position, sourceFile);
141050
141321
  if (!info)
141051
141322
  return undefined;
141052
141323
  var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
@@ -141093,7 +141364,7 @@ var ts;
141093
141364
  }
141094
141365
  return argumentIndex;
141095
141366
  }
141096
- function getArgumentCount(argumentsList) {
141367
+ function getArgumentCount(argumentsList, ignoreTrailingComma) {
141097
141368
  // The argument count for a list is normally the number of non-comma children it has.
141098
141369
  // For example, if you have "Foo(a,b)" then there will be three children of the arg
141099
141370
  // list 'a' '<comma>' 'b'. So, in this case the arg count will be 2. However, there
@@ -141107,7 +141378,7 @@ var ts;
141107
141378
  // arg count of 3.
141108
141379
  var listChildren = argumentsList.getChildren();
141109
141380
  var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; });
141110
- if (listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) {
141381
+ if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) {
141111
141382
  argumentCount++;
141112
141383
  }
141113
141384
  return argumentCount;
@@ -142053,7 +142324,7 @@ var ts;
142053
142324
  if (typeChecker.isArgumentsSymbol(symbol)) {
142054
142325
  return "local var" /* localVariableElement */;
142055
142326
  }
142056
- if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location)) {
142327
+ if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) {
142057
142328
  return "parameter" /* parameterElement */;
142058
142329
  }
142059
142330
  var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol);
@@ -142148,7 +142419,7 @@ var ts;
142148
142419
  var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol);
142149
142420
  var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */;
142150
142421
  var hasAddedSymbolInfo = false;
142151
- var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location);
142422
+ var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location);
142152
142423
  var type;
142153
142424
  var printer;
142154
142425
  var documentationFromAlias;
@@ -142561,6 +142832,18 @@ var ts;
142561
142832
  }
142562
142833
  }
142563
142834
  }
142835
+ if (documentation.length === 0 && ts.isIdentifier(location) && symbol.valueDeclaration && ts.isBindingElement(symbol.valueDeclaration)) {
142836
+ var declaration = symbol.valueDeclaration;
142837
+ var parent = declaration.parent;
142838
+ if (ts.isIdentifier(declaration.name) && ts.isObjectBindingPattern(parent)) {
142839
+ var name_4 = ts.getTextOfIdentifierOrLiteral(declaration.name);
142840
+ var objectType = typeChecker.getTypeAtLocation(parent);
142841
+ documentation = ts.firstDefined(objectType.isUnion() ? objectType.types : [objectType], function (t) {
142842
+ var prop = t.getProperty(name_4);
142843
+ return prop ? prop.getDocumentationComment(typeChecker) : undefined;
142844
+ }) || ts.emptyArray;
142845
+ }
142846
+ }
142564
142847
  if (tags.length === 0 && !hasMultipleSignatures) {
142565
142848
  tags = symbol.getContextualJsDocTags(enclosingDeclaration, typeChecker);
142566
142849
  }
@@ -149907,9 +150190,10 @@ var ts;
149907
150190
  var info = getFixesInfo(context, errorCode, span.start, /*useAutoImportProvider*/ true);
149908
150191
  if (!info)
149909
150192
  return undefined;
149910
- var fixes = info.fixes, symbolName = info.symbolName;
150193
+ var fixes = info.fixes, symbolName = info.symbolName, errorIdentifierText = info.errorIdentifierText;
149911
150194
  var quotePreference = ts.getQuotePreference(sourceFile, preferences);
149912
- return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix, quotePreference, program.getCompilerOptions()); });
150195
+ return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix,
150196
+ /*includeSymbolNameInDescription*/ symbolName !== errorIdentifierText, quotePreference, program.getCompilerOptions()); });
149913
150197
  },
149914
150198
  fixIds: [importFixId],
149915
150199
  getAllCodeActions: function (context) {
@@ -149948,7 +150232,7 @@ var ts;
149948
150232
  var useRequire = shouldUseRequire(sourceFile, program);
149949
150233
  var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
149950
150234
  if (fix) {
149951
- addImport({ fixes: [fix], symbolName: symbolName });
150235
+ addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
149952
150236
  }
149953
150237
  }
149954
150238
  function addImport(info) {
@@ -150119,7 +150403,8 @@ var ts;
150119
150403
  var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences));
150120
150404
  return {
150121
150405
  moduleSpecifier: fix.moduleSpecifier,
150122
- codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences), compilerOptions))
150406
+ codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix,
150407
+ /*includeSymbolNameInDescription*/ false, ts.getQuotePreference(sourceFile, preferences), compilerOptions))
150123
150408
  };
150124
150409
  }
150125
150410
  codefix.getImportCompletionAction = getImportCompletionAction;
@@ -150127,7 +150412,8 @@ var ts;
150127
150412
  var compilerOptions = program.getCompilerOptions();
150128
150413
  var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions);
150129
150414
  var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program);
150130
- return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, 1 /* Double */, compilerOptions));
150415
+ var includeSymbolNameInDescription = symbolName !== symbolToken.text;
150416
+ return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions));
150131
150417
  }
150132
150418
  codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction;
150133
150419
  function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
@@ -150420,7 +150706,7 @@ var ts;
150420
150706
  else if (errorCode === ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code) {
150421
150707
  var symbolName_1 = getSymbolName(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions());
150422
150708
  var fix = getTypeOnlyPromotionFix(context.sourceFile, symbolToken, symbolName_1, context.program);
150423
- return fix && { fixes: [fix], symbolName: symbolName_1 };
150709
+ return fix && { fixes: [fix], symbolName: symbolName_1, errorIdentifierText: symbolToken.text };
150424
150710
  }
150425
150711
  else {
150426
150712
  info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
@@ -150465,6 +150751,7 @@ var ts;
150465
150751
  return 0 /* EqualTo */;
150466
150752
  }
150467
150753
  function getFixesInfoForUMDImport(_a, token) {
150754
+ var _b;
150468
150755
  var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences;
150469
150756
  var checker = program.getTypeChecker();
150470
150757
  var umdSymbol = getUmdSymbol(token, checker);
@@ -150475,7 +150762,7 @@ var ts;
150475
150762
  var exportInfos = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
150476
150763
  var useRequire = shouldUseRequire(sourceFile, program);
150477
150764
  var fixes = getImportFixes(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
150478
- return { fixes: fixes, symbolName: symbolName };
150765
+ return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
150479
150766
  }
150480
150767
  function getUmdSymbol(token, checker) {
150481
150768
  // try the identifier to see if it is the umd symbol
@@ -150546,7 +150833,7 @@ var ts;
150546
150833
  var _ = _a[0], exportInfos = _a[1];
150547
150834
  return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
150548
150835
  }));
150549
- return { fixes: fixes, symbolName: symbolName };
150836
+ return { fixes: fixes, symbolName: symbolName, errorIdentifierText: symbolToken.text };
150550
150837
  }
150551
150838
  function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) {
150552
150839
  var checker = program.getTypeChecker();
@@ -150641,14 +150928,14 @@ var ts;
150641
150928
  // allowSyntheticDefaultImports/esModuleInterop is enabled.
150642
150929
  return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */;
150643
150930
  }
150644
- function codeActionForFix(context, sourceFile, symbolName, fix, quotePreference, compilerOptions) {
150931
+ function codeActionForFix(context, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) {
150645
150932
  var diag;
150646
150933
  var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) {
150647
- diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, quotePreference, compilerOptions);
150934
+ diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions);
150648
150935
  });
150649
150936
  return codefix.createCodeFixAction(codefix.importFixName, changes, diag, importFixId, ts.Diagnostics.Add_all_missing_imports);
150650
150937
  }
150651
- function codeActionForFixWorker(changes, sourceFile, symbolName, fix, quotePreference, compilerOptions) {
150938
+ function codeActionForFixWorker(changes, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) {
150652
150939
  switch (fix.kind) {
150653
150940
  case 0 /* UseNamespace */:
150654
150941
  addNamespaceQualifier(changes, sourceFile, fix);
@@ -150660,11 +150947,9 @@ var ts;
150660
150947
  var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly, moduleSpecifier = fix.moduleSpecifier;
150661
150948
  doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions);
150662
150949
  var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier);
150663
- return [
150664
- importKind === 1 /* Default */ ? ts.Diagnostics.Add_default_import_0_to_existing_import_declaration_from_1 : ts.Diagnostics.Add_0_to_existing_import_declaration_from_1,
150665
- symbolName,
150666
- moduleSpecifierWithoutQuotes
150667
- ]; // you too!
150950
+ return includeSymbolNameInDescription
150951
+ ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifierWithoutQuotes]
150952
+ : [ts.Diagnostics.Update_import_from_0, moduleSpecifierWithoutQuotes];
150668
150953
  }
150669
150954
  case 3 /* AddNew */: {
150670
150955
  var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, addAsTypeOnly = fix.addAsTypeOnly, useRequire = fix.useRequire;
@@ -150673,7 +150958,9 @@ var ts;
150673
150958
  var namedImports = importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined;
150674
150959
  var namespaceLikeImport = importKind === 2 /* Namespace */ || importKind === 3 /* CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined;
150675
150960
  ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true);
150676
- return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier];
150961
+ return includeSymbolNameInDescription
150962
+ ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifier]
150963
+ : [ts.Diagnostics.Add_import_from_0, moduleSpecifier];
150677
150964
  }
150678
150965
  case 4 /* PromoteTypeOnly */: {
150679
150966
  var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration;
@@ -156090,51 +156377,53 @@ var ts;
156090
156377
  (function (ts) {
156091
156378
  var refactor;
156092
156379
  (function (refactor) {
156380
+ var _a;
156093
156381
  var refactorName = "Convert import";
156094
- var namespaceToNamedAction = {
156095
- name: "Convert namespace import to named imports",
156096
- description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message,
156097
- kind: "refactor.rewrite.import.named",
156098
- };
156099
- var namedToNamespaceAction = {
156100
- name: "Convert named imports to namespace import",
156101
- description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message,
156102
- kind: "refactor.rewrite.import.namespace",
156103
- };
156382
+ var actions = (_a = {},
156383
+ _a[0 /* Named */] = {
156384
+ name: "Convert namespace import to named imports",
156385
+ description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message,
156386
+ kind: "refactor.rewrite.import.named",
156387
+ },
156388
+ _a[2 /* Namespace */] = {
156389
+ name: "Convert named imports to namespace import",
156390
+ description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message,
156391
+ kind: "refactor.rewrite.import.namespace",
156392
+ },
156393
+ _a[1 /* Default */] = {
156394
+ name: "Convert named imports to default import",
156395
+ description: ts.Diagnostics.Convert_named_imports_to_default_import.message,
156396
+ kind: "refactor.rewrite.import.default",
156397
+ },
156398
+ _a);
156104
156399
  refactor.registerRefactor(refactorName, {
156105
- kinds: [
156106
- namespaceToNamedAction.kind,
156107
- namedToNamespaceAction.kind
156108
- ],
156400
+ kinds: ts.getOwnValues(actions).map(function (a) { return a.kind; }),
156109
156401
  getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndNamespacedImports(context) {
156110
- var info = getImportToConvert(context, context.triggerReason === "invoked");
156402
+ var info = getImportConversionInfo(context, context.triggerReason === "invoked");
156111
156403
  if (!info)
156112
156404
  return ts.emptyArray;
156113
156405
  if (!refactor.isRefactorErrorInfo(info)) {
156114
- var namespaceImport = info.kind === 267 /* NamespaceImport */;
156115
- var action = namespaceImport ? namespaceToNamedAction : namedToNamespaceAction;
156406
+ var action = actions[info.convertTo];
156116
156407
  return [{ name: refactorName, description: action.description, actions: [action] }];
156117
156408
  }
156118
156409
  if (context.preferences.provideRefactorNotApplicableReason) {
156119
- return [
156120
- { name: refactorName, description: namespaceToNamedAction.description,
156121
- actions: [__assign(__assign({}, namespaceToNamedAction), { notApplicableReason: info.error })] },
156122
- { name: refactorName, description: namedToNamespaceAction.description,
156123
- actions: [__assign(__assign({}, namedToNamespaceAction), { notApplicableReason: info.error })] }
156124
- ];
156410
+ return ts.getOwnValues(actions).map(function (action) { return ({
156411
+ name: refactorName,
156412
+ description: action.description,
156413
+ actions: [__assign(__assign({}, action), { notApplicableReason: info.error })]
156414
+ }); });
156125
156415
  }
156126
156416
  return ts.emptyArray;
156127
156417
  },
156128
156418
  getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndNamespacedImports(context, actionName) {
156129
- ts.Debug.assert(actionName === namespaceToNamedAction.name || actionName === namedToNamespaceAction.name, "Unexpected action name");
156130
- var info = getImportToConvert(context);
156419
+ ts.Debug.assert(ts.some(ts.getOwnValues(actions), function (action) { return action.name === actionName; }), "Unexpected action name");
156420
+ var info = getImportConversionInfo(context);
156131
156421
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
156132
156422
  var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, info); });
156133
156423
  return { edits: edits, renameFilename: undefined, renameLocation: undefined };
156134
156424
  }
156135
156425
  });
156136
- // Can convert imports of the form `import * as m from "m";` or `import d, { x, y } from "m";`.
156137
- function getImportToConvert(context, considerPartialSpans) {
156426
+ function getImportConversionInfo(context, considerPartialSpans) {
156138
156427
  if (considerPartialSpans === void 0) { considerPartialSpans = true; }
156139
156428
  var file = context.file;
156140
156429
  var span = ts.getRefactorContextSpan(context);
@@ -156153,15 +156442,23 @@ var ts;
156153
156442
  if (!importClause.namedBindings) {
156154
156443
  return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_namespace_import_or_named_imports) };
156155
156444
  }
156156
- return importClause.namedBindings;
156445
+ if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
156446
+ return { convertTo: 0 /* Named */, import: importClause.namedBindings };
156447
+ }
156448
+ var compilerOptions = context.program.getCompilerOptions();
156449
+ var shouldUseDefault = ts.getAllowSyntheticDefaultImports(compilerOptions)
156450
+ && isExportEqualsModule(importClause.parent.moduleSpecifier, context.program.getTypeChecker());
156451
+ return shouldUseDefault
156452
+ ? { convertTo: 1 /* Default */, import: importClause.namedBindings }
156453
+ : { convertTo: 2 /* Namespace */, import: importClause.namedBindings };
156157
156454
  }
156158
- function doChange(sourceFile, program, changes, toConvert) {
156455
+ function doChange(sourceFile, program, changes, info) {
156159
156456
  var checker = program.getTypeChecker();
156160
- if (toConvert.kind === 267 /* NamespaceImport */) {
156161
- doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
156457
+ if (info.convertTo === 0 /* Named */) {
156458
+ doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
156162
156459
  }
156163
156460
  else {
156164
- doChangeNamedToNamespace(sourceFile, checker, changes, toConvert);
156461
+ doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, info.import, info.convertTo === 1 /* Default */);
156165
156462
  }
156166
156463
  }
156167
156464
  function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) {
@@ -156211,7 +156508,7 @@ var ts;
156211
156508
  function getLeftOfPropertyAccessOrQualifiedName(propertyAccessOrQualifiedName) {
156212
156509
  return ts.isPropertyAccessExpression(propertyAccessOrQualifiedName) ? propertyAccessOrQualifiedName.expression : propertyAccessOrQualifiedName.left;
156213
156510
  }
156214
- function doChangeNamedToNamespace(sourceFile, checker, changes, toConvert) {
156511
+ function doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, toConvert, shouldUseDefault) {
156215
156512
  var importDecl = toConvert.parent.parent;
156216
156513
  var moduleSpecifier = importDecl.moduleSpecifier;
156217
156514
  var toConvertSymbols = new ts.Set();
@@ -156262,7 +156559,9 @@ var ts;
156262
156559
  var element = _a[_i];
156263
156560
  _loop_17(element);
156264
156561
  }
156265
- changes.replaceNode(sourceFile, toConvert, ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName)));
156562
+ changes.replaceNode(sourceFile, toConvert, shouldUseDefault
156563
+ ? ts.factory.createIdentifier(namespaceImportName)
156564
+ : ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName)));
156266
156565
  if (neededNamedImports.size) {
156267
156566
  var newNamedImports = ts.arrayFrom(neededNamedImports.values()).map(function (element) {
156268
156567
  return ts.factory.createImportSpecifier(element.isTypeOnly, element.propertyName && ts.factory.createIdentifier(element.propertyName.text), ts.factory.createIdentifier(element.name.text));
@@ -156270,6 +156569,13 @@ var ts;
156270
156569
  changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, newNamedImports));
156271
156570
  }
156272
156571
  }
156572
+ function isExportEqualsModule(moduleSpecifier, checker) {
156573
+ var externalModule = checker.resolveExternalModuleName(moduleSpecifier);
156574
+ if (!externalModule)
156575
+ return false;
156576
+ var exportEquals = checker.resolveExternalModuleSymbol(externalModule);
156577
+ return externalModule !== exportEquals;
156578
+ }
156273
156579
  function updateImport(old, defaultImportName, elements) {
156274
156580
  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);
156275
156581
  }
@@ -158533,14 +158839,22 @@ var ts;
158533
158839
  var result = [];
158534
158840
  return visitor(selection) ? undefined : result;
158535
158841
  function visitor(node) {
158536
- var _a;
158537
158842
  if (ts.isTypeReferenceNode(node)) {
158538
158843
  if (ts.isIdentifier(node.typeName)) {
158539
- var symbol = checker.resolveName(node.typeName.text, node.typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true);
158540
- var declaration = ts.tryCast((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0], ts.isTypeParameterDeclaration);
158541
- if (declaration) {
158542
- if (rangeContainsSkipTrivia(statement, declaration, file) && !rangeContainsSkipTrivia(selection, declaration, file)) {
158543
- ts.pushIfUnique(result, declaration);
158844
+ var typeName = node.typeName;
158845
+ var symbol = checker.resolveName(typeName.text, typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true);
158846
+ for (var _i = 0, _a = (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray; _i < _a.length; _i++) {
158847
+ var decl = _a[_i];
158848
+ if (ts.isTypeParameterDeclaration(decl) && decl.getSourceFile() === file) {
158849
+ // skip extraction if the type node is in the range of the type parameter declaration.
158850
+ // function foo<T extends { a?: /**/T }>(): void;
158851
+ if (decl.name.escapedText === typeName.escapedText && rangeContainsSkipTrivia(decl, selection, file)) {
158852
+ return true;
158853
+ }
158854
+ if (rangeContainsSkipTrivia(statement, decl, file) && !rangeContainsSkipTrivia(selection, decl, file)) {
158855
+ ts.pushIfUnique(result, decl);
158856
+ break;
158857
+ }
158544
158858
  }
158545
158859
  }
158546
158860
  }
@@ -159541,7 +159855,7 @@ var ts;
159541
159855
  var convertParamsToDestructuredObject;
159542
159856
  (function (convertParamsToDestructuredObject) {
159543
159857
  var refactorName = "Convert parameters to destructured object";
159544
- var minimumParameterLength = 2;
159858
+ var minimumParameterLength = 1;
159545
159859
  var refactorDescription = ts.getLocaleSpecificMessage(ts.Diagnostics.Convert_parameters_to_destructured_object);
159546
159860
  var toDestructuredAction = {
159547
159861
  name: refactorName,