typescript 4.6.0-dev.20220131 → 4.6.0-dev.20220204

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.
package/lib/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220131";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220204";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -5918,704 +5918,6 @@ var ts;
5918
5918
  },
5919
5919
  };
5920
5920
  })(ts || (ts = {}));
5921
- /* @internal */
5922
- var ts;
5923
- (function (ts) {
5924
- /**
5925
- * Internally, we represent paths as strings with '/' as the directory separator.
5926
- * When we make system calls (eg: LanguageServiceHost.getDirectory()),
5927
- * we expect the host to correctly handle paths in our specified format.
5928
- */
5929
- ts.directorySeparator = "/";
5930
- ts.altDirectorySeparator = "\\";
5931
- var urlSchemeSeparator = "://";
5932
- var backslashRegExp = /\\/g;
5933
- //// Path Tests
5934
- /**
5935
- * Determines whether a charCode corresponds to `/` or `\`.
5936
- */
5937
- function isAnyDirectorySeparator(charCode) {
5938
- return charCode === 47 /* slash */ || charCode === 92 /* backslash */;
5939
- }
5940
- ts.isAnyDirectorySeparator = isAnyDirectorySeparator;
5941
- /**
5942
- * Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.).
5943
- */
5944
- function isUrl(path) {
5945
- return getEncodedRootLength(path) < 0;
5946
- }
5947
- ts.isUrl = isUrl;
5948
- /**
5949
- * Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path
5950
- * like `c:`, `c:\` or `c:/`).
5951
- */
5952
- function isRootedDiskPath(path) {
5953
- return getEncodedRootLength(path) > 0;
5954
- }
5955
- ts.isRootedDiskPath = isRootedDiskPath;
5956
- /**
5957
- * Determines whether a path consists only of a path root.
5958
- */
5959
- function isDiskPathRoot(path) {
5960
- var rootLength = getEncodedRootLength(path);
5961
- return rootLength > 0 && rootLength === path.length;
5962
- }
5963
- ts.isDiskPathRoot = isDiskPathRoot;
5964
- /**
5965
- * Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.).
5966
- *
5967
- * ```ts
5968
- * // POSIX
5969
- * pathIsAbsolute("/path/to/file.ext") === true
5970
- * // DOS
5971
- * pathIsAbsolute("c:/path/to/file.ext") === true
5972
- * // URL
5973
- * pathIsAbsolute("file:///path/to/file.ext") === true
5974
- * // Non-absolute
5975
- * pathIsAbsolute("path/to/file.ext") === false
5976
- * pathIsAbsolute("./path/to/file.ext") === false
5977
- * ```
5978
- */
5979
- function pathIsAbsolute(path) {
5980
- return getEncodedRootLength(path) !== 0;
5981
- }
5982
- ts.pathIsAbsolute = pathIsAbsolute;
5983
- /**
5984
- * Determines whether a path starts with a relative path component (i.e. `.` or `..`).
5985
- */
5986
- function pathIsRelative(path) {
5987
- return /^\.\.?($|[\\/])/.test(path);
5988
- }
5989
- ts.pathIsRelative = pathIsRelative;
5990
- /**
5991
- * Determines whether a path is neither relative nor absolute, e.g. "path/to/file".
5992
- * Also known misleadingly as "non-relative".
5993
- */
5994
- function pathIsBareSpecifier(path) {
5995
- return !pathIsAbsolute(path) && !pathIsRelative(path);
5996
- }
5997
- ts.pathIsBareSpecifier = pathIsBareSpecifier;
5998
- function hasExtension(fileName) {
5999
- return ts.stringContains(getBaseFileName(fileName), ".");
6000
- }
6001
- ts.hasExtension = hasExtension;
6002
- function fileExtensionIs(path, extension) {
6003
- return path.length > extension.length && ts.endsWith(path, extension);
6004
- }
6005
- ts.fileExtensionIs = fileExtensionIs;
6006
- function fileExtensionIsOneOf(path, extensions) {
6007
- for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
6008
- var extension = extensions_1[_i];
6009
- if (fileExtensionIs(path, extension)) {
6010
- return true;
6011
- }
6012
- }
6013
- return false;
6014
- }
6015
- ts.fileExtensionIsOneOf = fileExtensionIsOneOf;
6016
- /**
6017
- * Determines whether a path has a trailing separator (`/` or `\\`).
6018
- */
6019
- function hasTrailingDirectorySeparator(path) {
6020
- return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1));
6021
- }
6022
- ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator;
6023
- //// Path Parsing
6024
- function isVolumeCharacter(charCode) {
6025
- return (charCode >= 97 /* a */ && charCode <= 122 /* z */) ||
6026
- (charCode >= 65 /* A */ && charCode <= 90 /* Z */);
6027
- }
6028
- function getFileUrlVolumeSeparatorEnd(url, start) {
6029
- var ch0 = url.charCodeAt(start);
6030
- if (ch0 === 58 /* colon */)
6031
- return start + 1;
6032
- if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) {
6033
- var ch2 = url.charCodeAt(start + 2);
6034
- if (ch2 === 97 /* a */ || ch2 === 65 /* A */)
6035
- return start + 3;
6036
- }
6037
- return -1;
6038
- }
6039
- /**
6040
- * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
6041
- * If the root is part of a URL, the twos-complement of the root length is returned.
6042
- */
6043
- function getEncodedRootLength(path) {
6044
- if (!path)
6045
- return 0;
6046
- var ch0 = path.charCodeAt(0);
6047
- // POSIX or UNC
6048
- if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) {
6049
- if (path.charCodeAt(1) !== ch0)
6050
- return 1; // POSIX: "/" (or non-normalized "\")
6051
- var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2);
6052
- if (p1 < 0)
6053
- return path.length; // UNC: "//server" or "\\server"
6054
- return p1 + 1; // UNC: "//server/" or "\\server\"
6055
- }
6056
- // DOS
6057
- if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) {
6058
- var ch2 = path.charCodeAt(2);
6059
- if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */)
6060
- return 3; // DOS: "c:/" or "c:\"
6061
- if (path.length === 2)
6062
- return 2; // DOS: "c:" (but not "c:d")
6063
- }
6064
- // URL
6065
- var schemeEnd = path.indexOf(urlSchemeSeparator);
6066
- if (schemeEnd !== -1) {
6067
- var authorityStart = schemeEnd + urlSchemeSeparator.length;
6068
- var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart);
6069
- if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path"
6070
- // For local "file" URLs, include the leading DOS volume (if present).
6071
- // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a
6072
- // special case interpreted as "the machine from which the URL is being interpreted".
6073
- var scheme = path.slice(0, schemeEnd);
6074
- var authority = path.slice(authorityStart, authorityEnd);
6075
- if (scheme === "file" && (authority === "" || authority === "localhost") &&
6076
- isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
6077
- var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
6078
- if (volumeSeparatorEnd !== -1) {
6079
- if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) {
6080
- // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/"
6081
- return ~(volumeSeparatorEnd + 1);
6082
- }
6083
- if (volumeSeparatorEnd === path.length) {
6084
- // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a"
6085
- // but not "file:///c:d" or "file:///c%3ad"
6086
- return ~volumeSeparatorEnd;
6087
- }
6088
- }
6089
- }
6090
- return ~(authorityEnd + 1); // URL: "file://server/", "http://server/"
6091
- }
6092
- return ~path.length; // URL: "file://server", "http://server"
6093
- }
6094
- // relative
6095
- return 0;
6096
- }
6097
- /**
6098
- * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
6099
- *
6100
- * For example:
6101
- * ```ts
6102
- * getRootLength("a") === 0 // ""
6103
- * getRootLength("/") === 1 // "/"
6104
- * getRootLength("c:") === 2 // "c:"
6105
- * getRootLength("c:d") === 0 // ""
6106
- * getRootLength("c:/") === 3 // "c:/"
6107
- * getRootLength("c:\\") === 3 // "c:\\"
6108
- * getRootLength("//server") === 7 // "//server"
6109
- * getRootLength("//server/share") === 8 // "//server/"
6110
- * getRootLength("\\\\server") === 7 // "\\\\server"
6111
- * getRootLength("\\\\server\\share") === 8 // "\\\\server\\"
6112
- * getRootLength("file:///path") === 8 // "file:///"
6113
- * getRootLength("file:///c:") === 10 // "file:///c:"
6114
- * getRootLength("file:///c:d") === 8 // "file:///"
6115
- * getRootLength("file:///c:/path") === 11 // "file:///c:/"
6116
- * getRootLength("file://server") === 13 // "file://server"
6117
- * getRootLength("file://server/path") === 14 // "file://server/"
6118
- * getRootLength("http://server") === 13 // "http://server"
6119
- * getRootLength("http://server/path") === 14 // "http://server/"
6120
- * ```
6121
- */
6122
- function getRootLength(path) {
6123
- var rootLength = getEncodedRootLength(path);
6124
- return rootLength < 0 ? ~rootLength : rootLength;
6125
- }
6126
- ts.getRootLength = getRootLength;
6127
- function getDirectoryPath(path) {
6128
- path = normalizeSlashes(path);
6129
- // If the path provided is itself the root, then return it.
6130
- var rootLength = getRootLength(path);
6131
- if (rootLength === path.length)
6132
- return path;
6133
- // return the leading portion of the path up to the last (non-terminal) directory separator
6134
- // but not including any trailing directory separator.
6135
- path = removeTrailingDirectorySeparator(path);
6136
- return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator)));
6137
- }
6138
- ts.getDirectoryPath = getDirectoryPath;
6139
- function getBaseFileName(path, extensions, ignoreCase) {
6140
- path = normalizeSlashes(path);
6141
- // if the path provided is itself the root, then it has not file name.
6142
- var rootLength = getRootLength(path);
6143
- if (rootLength === path.length)
6144
- return "";
6145
- // return the trailing portion of the path starting after the last (non-terminal) directory
6146
- // separator but not including any trailing directory separator.
6147
- path = removeTrailingDirectorySeparator(path);
6148
- var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1));
6149
- var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined;
6150
- return extension ? name.slice(0, name.length - extension.length) : name;
6151
- }
6152
- ts.getBaseFileName = getBaseFileName;
6153
- function tryGetExtensionFromPath(path, extension, stringEqualityComparer) {
6154
- if (!ts.startsWith(extension, "."))
6155
- extension = "." + extension;
6156
- if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) {
6157
- var pathExtension = path.slice(path.length - extension.length);
6158
- if (stringEqualityComparer(pathExtension, extension)) {
6159
- return pathExtension;
6160
- }
6161
- }
6162
- }
6163
- function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) {
6164
- if (typeof extensions === "string") {
6165
- return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || "";
6166
- }
6167
- for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) {
6168
- var extension = extensions_2[_i];
6169
- var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer);
6170
- if (result)
6171
- return result;
6172
- }
6173
- return "";
6174
- }
6175
- function getAnyExtensionFromPath(path, extensions, ignoreCase) {
6176
- // Retrieves any string from the final "." onwards from a base file name.
6177
- // Unlike extensionFromPath, which throws an exception on unrecognized extensions.
6178
- if (extensions) {
6179
- return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive);
6180
- }
6181
- var baseFileName = getBaseFileName(path);
6182
- var extensionIndex = baseFileName.lastIndexOf(".");
6183
- if (extensionIndex >= 0) {
6184
- return baseFileName.substring(extensionIndex);
6185
- }
6186
- return "";
6187
- }
6188
- ts.getAnyExtensionFromPath = getAnyExtensionFromPath;
6189
- function pathComponents(path, rootLength) {
6190
- var root = path.substring(0, rootLength);
6191
- var rest = path.substring(rootLength).split(ts.directorySeparator);
6192
- if (rest.length && !ts.lastOrUndefined(rest))
6193
- rest.pop();
6194
- return __spreadArray([root], rest, true);
6195
- }
6196
- /**
6197
- * Parse a path into an array containing a root component (at index 0) and zero or more path
6198
- * components (at indices > 0). The result is not normalized.
6199
- * If the path is relative, the root component is `""`.
6200
- * If the path is absolute, the root component includes the first path separator (`/`).
6201
- *
6202
- * ```ts
6203
- * // POSIX
6204
- * getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"]
6205
- * getPathComponents("/path/to/") === ["/", "path", "to"]
6206
- * getPathComponents("/") === ["/"]
6207
- * // DOS
6208
- * getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"]
6209
- * getPathComponents("c:/path/to/") === ["c:/", "path", "to"]
6210
- * getPathComponents("c:/") === ["c:/"]
6211
- * getPathComponents("c:") === ["c:"]
6212
- * // URL
6213
- * getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"]
6214
- * getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"]
6215
- * getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"]
6216
- * getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"]
6217
- * getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"]
6218
- * getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"]
6219
- * getPathComponents("file://server/") === ["file://server/"]
6220
- * getPathComponents("file://server") === ["file://server"]
6221
- * getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"]
6222
- * getPathComponents("file:///path/to/") === ["file:///", "path", "to"]
6223
- * getPathComponents("file:///") === ["file:///"]
6224
- * getPathComponents("file://") === ["file://"]
6225
- */
6226
- function getPathComponents(path, currentDirectory) {
6227
- if (currentDirectory === void 0) { currentDirectory = ""; }
6228
- path = combinePaths(currentDirectory, path);
6229
- return pathComponents(path, getRootLength(path));
6230
- }
6231
- ts.getPathComponents = getPathComponents;
6232
- //// Path Formatting
6233
- /**
6234
- * Formats a parsed path consisting of a root component (at index 0) and zero or more path
6235
- * segments (at indices > 0).
6236
- *
6237
- * ```ts
6238
- * getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext"
6239
- * ```
6240
- */
6241
- function getPathFromPathComponents(pathComponents) {
6242
- if (pathComponents.length === 0)
6243
- return "";
6244
- var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
6245
- return root + pathComponents.slice(1).join(ts.directorySeparator);
6246
- }
6247
- ts.getPathFromPathComponents = getPathFromPathComponents;
6248
- //// Path Normalization
6249
- /**
6250
- * Normalize path separators, converting `\` into `/`.
6251
- */
6252
- function normalizeSlashes(path) {
6253
- var index = path.indexOf("\\");
6254
- if (index === -1) {
6255
- return path;
6256
- }
6257
- backslashRegExp.lastIndex = index; // prime regex with known position
6258
- return path.replace(backslashRegExp, ts.directorySeparator);
6259
- }
6260
- ts.normalizeSlashes = normalizeSlashes;
6261
- /**
6262
- * Reduce an array of path components to a more simplified path by navigating any
6263
- * `"."` or `".."` entries in the path.
6264
- */
6265
- function reducePathComponents(components) {
6266
- if (!ts.some(components))
6267
- return [];
6268
- var reduced = [components[0]];
6269
- for (var i = 1; i < components.length; i++) {
6270
- var component = components[i];
6271
- if (!component)
6272
- continue;
6273
- if (component === ".")
6274
- continue;
6275
- if (component === "..") {
6276
- if (reduced.length > 1) {
6277
- if (reduced[reduced.length - 1] !== "..") {
6278
- reduced.pop();
6279
- continue;
6280
- }
6281
- }
6282
- else if (reduced[0])
6283
- continue;
6284
- }
6285
- reduced.push(component);
6286
- }
6287
- return reduced;
6288
- }
6289
- ts.reducePathComponents = reducePathComponents;
6290
- /**
6291
- * Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified.
6292
- *
6293
- * ```ts
6294
- * // Non-rooted
6295
- * combinePaths("path", "to", "file.ext") === "path/to/file.ext"
6296
- * combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext"
6297
- * // POSIX
6298
- * combinePaths("/path", "to", "file.ext") === "/path/to/file.ext"
6299
- * combinePaths("/path", "/to", "file.ext") === "/to/file.ext"
6300
- * // DOS
6301
- * combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext"
6302
- * combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext"
6303
- * // URL
6304
- * combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext"
6305
- * combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext"
6306
- * ```
6307
- */
6308
- function combinePaths(path) {
6309
- var paths = [];
6310
- for (var _i = 1; _i < arguments.length; _i++) {
6311
- paths[_i - 1] = arguments[_i];
6312
- }
6313
- if (path)
6314
- path = normalizeSlashes(path);
6315
- for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
6316
- var relativePath = paths_1[_a];
6317
- if (!relativePath)
6318
- continue;
6319
- relativePath = normalizeSlashes(relativePath);
6320
- if (!path || getRootLength(relativePath) !== 0) {
6321
- path = relativePath;
6322
- }
6323
- else {
6324
- path = ensureTrailingDirectorySeparator(path) + relativePath;
6325
- }
6326
- }
6327
- return path;
6328
- }
6329
- ts.combinePaths = combinePaths;
6330
- /**
6331
- * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any
6332
- * `.` and `..` path components are resolved. Trailing directory separators are preserved.
6333
- *
6334
- * ```ts
6335
- * resolvePath("/path", "to", "file.ext") === "path/to/file.ext"
6336
- * resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/"
6337
- * resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext"
6338
- * ```
6339
- */
6340
- function resolvePath(path) {
6341
- var paths = [];
6342
- for (var _i = 1; _i < arguments.length; _i++) {
6343
- paths[_i - 1] = arguments[_i];
6344
- }
6345
- return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArray([path], paths, false)) : normalizeSlashes(path));
6346
- }
6347
- ts.resolvePath = resolvePath;
6348
- /**
6349
- * Parse a path into an array containing a root component (at index 0) and zero or more path
6350
- * components (at indices > 0). The result is normalized.
6351
- * If the path is relative, the root component is `""`.
6352
- * If the path is absolute, the root component includes the first path separator (`/`).
6353
- *
6354
- * ```ts
6355
- * getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"]
6356
- * ```
6357
- */
6358
- function getNormalizedPathComponents(path, currentDirectory) {
6359
- return reducePathComponents(getPathComponents(path, currentDirectory));
6360
- }
6361
- ts.getNormalizedPathComponents = getNormalizedPathComponents;
6362
- function getNormalizedAbsolutePath(fileName, currentDirectory) {
6363
- return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
6364
- }
6365
- ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
6366
- function normalizePath(path) {
6367
- path = normalizeSlashes(path);
6368
- // Most paths don't require normalization
6369
- if (!relativePathSegmentRegExp.test(path)) {
6370
- return path;
6371
- }
6372
- // Some paths only require cleanup of `/./` or leading `./`
6373
- var simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, "");
6374
- if (simplified !== path) {
6375
- path = simplified;
6376
- if (!relativePathSegmentRegExp.test(path)) {
6377
- return path;
6378
- }
6379
- }
6380
- // Other paths require full normalization
6381
- var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
6382
- return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
6383
- }
6384
- ts.normalizePath = normalizePath;
6385
- function getPathWithoutRoot(pathComponents) {
6386
- if (pathComponents.length === 0)
6387
- return "";
6388
- return pathComponents.slice(1).join(ts.directorySeparator);
6389
- }
6390
- function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
6391
- return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
6392
- }
6393
- ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
6394
- function toPath(fileName, basePath, getCanonicalFileName) {
6395
- var nonCanonicalizedPath = isRootedDiskPath(fileName)
6396
- ? normalizePath(fileName)
6397
- : getNormalizedAbsolutePath(fileName, basePath);
6398
- return getCanonicalFileName(nonCanonicalizedPath);
6399
- }
6400
- ts.toPath = toPath;
6401
- function normalizePathAndParts(path) {
6402
- path = normalizeSlashes(path);
6403
- var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
6404
- if (parts.length) {
6405
- var joinedParts = root + parts.join(ts.directorySeparator);
6406
- return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
6407
- }
6408
- else {
6409
- return { path: root, parts: parts };
6410
- }
6411
- }
6412
- ts.normalizePathAndParts = normalizePathAndParts;
6413
- function removeTrailingDirectorySeparator(path) {
6414
- if (hasTrailingDirectorySeparator(path)) {
6415
- return path.substr(0, path.length - 1);
6416
- }
6417
- return path;
6418
- }
6419
- ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
6420
- function ensureTrailingDirectorySeparator(path) {
6421
- if (!hasTrailingDirectorySeparator(path)) {
6422
- return path + ts.directorySeparator;
6423
- }
6424
- return path;
6425
- }
6426
- ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator;
6427
- /**
6428
- * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed
6429
- * with `./` or `../`) so as not to be confused with an unprefixed module name.
6430
- *
6431
- * ```ts
6432
- * ensurePathIsNonModuleName("/path/to/file.ext") === "/path/to/file.ext"
6433
- * ensurePathIsNonModuleName("./path/to/file.ext") === "./path/to/file.ext"
6434
- * ensurePathIsNonModuleName("../path/to/file.ext") === "../path/to/file.ext"
6435
- * ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext"
6436
- * ```
6437
- */
6438
- function ensurePathIsNonModuleName(path) {
6439
- return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path;
6440
- }
6441
- ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName;
6442
- function changeAnyExtension(path, ext, extensions, ignoreCase) {
6443
- var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path);
6444
- return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
6445
- }
6446
- ts.changeAnyExtension = changeAnyExtension;
6447
- //// Path Comparisons
6448
- // check path for these segments: '', '.'. '..'
6449
- var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/;
6450
- function comparePathsWorker(a, b, componentComparer) {
6451
- if (a === b)
6452
- return 0 /* EqualTo */;
6453
- if (a === undefined)
6454
- return -1 /* LessThan */;
6455
- if (b === undefined)
6456
- return 1 /* GreaterThan */;
6457
- // NOTE: Performance optimization - shortcut if the root segments differ as there would be no
6458
- // need to perform path reduction.
6459
- var aRoot = a.substring(0, getRootLength(a));
6460
- var bRoot = b.substring(0, getRootLength(b));
6461
- var result = ts.compareStringsCaseInsensitive(aRoot, bRoot);
6462
- if (result !== 0 /* EqualTo */) {
6463
- return result;
6464
- }
6465
- // NOTE: Performance optimization - shortcut if there are no relative path segments in
6466
- // the non-root portion of the path
6467
- var aRest = a.substring(aRoot.length);
6468
- var bRest = b.substring(bRoot.length);
6469
- if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) {
6470
- return componentComparer(aRest, bRest);
6471
- }
6472
- // The path contains a relative path segment. Normalize the paths and perform a slower component
6473
- // by component comparison.
6474
- var aComponents = reducePathComponents(getPathComponents(a));
6475
- var bComponents = reducePathComponents(getPathComponents(b));
6476
- var sharedLength = Math.min(aComponents.length, bComponents.length);
6477
- for (var i = 1; i < sharedLength; i++) {
6478
- var result_2 = componentComparer(aComponents[i], bComponents[i]);
6479
- if (result_2 !== 0 /* EqualTo */) {
6480
- return result_2;
6481
- }
6482
- }
6483
- return ts.compareValues(aComponents.length, bComponents.length);
6484
- }
6485
- /**
6486
- * Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively.
6487
- */
6488
- function comparePathsCaseSensitive(a, b) {
6489
- return comparePathsWorker(a, b, ts.compareStringsCaseSensitive);
6490
- }
6491
- ts.comparePathsCaseSensitive = comparePathsCaseSensitive;
6492
- /**
6493
- * Performs a case-insensitive comparison of two paths.
6494
- */
6495
- function comparePathsCaseInsensitive(a, b) {
6496
- return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive);
6497
- }
6498
- ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive;
6499
- function comparePaths(a, b, currentDirectory, ignoreCase) {
6500
- if (typeof currentDirectory === "string") {
6501
- a = combinePaths(currentDirectory, a);
6502
- b = combinePaths(currentDirectory, b);
6503
- }
6504
- else if (typeof currentDirectory === "boolean") {
6505
- ignoreCase = currentDirectory;
6506
- }
6507
- return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase));
6508
- }
6509
- ts.comparePaths = comparePaths;
6510
- function containsPath(parent, child, currentDirectory, ignoreCase) {
6511
- if (typeof currentDirectory === "string") {
6512
- parent = combinePaths(currentDirectory, parent);
6513
- child = combinePaths(currentDirectory, child);
6514
- }
6515
- else if (typeof currentDirectory === "boolean") {
6516
- ignoreCase = currentDirectory;
6517
- }
6518
- if (parent === undefined || child === undefined)
6519
- return false;
6520
- if (parent === child)
6521
- return true;
6522
- var parentComponents = reducePathComponents(getPathComponents(parent));
6523
- var childComponents = reducePathComponents(getPathComponents(child));
6524
- if (childComponents.length < parentComponents.length) {
6525
- return false;
6526
- }
6527
- var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive;
6528
- for (var i = 0; i < parentComponents.length; i++) {
6529
- var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer;
6530
- if (!equalityComparer(parentComponents[i], childComponents[i])) {
6531
- return false;
6532
- }
6533
- }
6534
- return true;
6535
- }
6536
- ts.containsPath = containsPath;
6537
- /**
6538
- * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback.
6539
- * Comparison is case-sensitive between the canonical paths.
6540
- *
6541
- * Use `containsPath` if file names are not already reduced and absolute.
6542
- */
6543
- function startsWithDirectory(fileName, directoryName, getCanonicalFileName) {
6544
- var canonicalFileName = getCanonicalFileName(fileName);
6545
- var canonicalDirectoryName = getCanonicalFileName(directoryName);
6546
- return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\");
6547
- }
6548
- ts.startsWithDirectory = startsWithDirectory;
6549
- //// Relative Paths
6550
- function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) {
6551
- var fromComponents = reducePathComponents(getPathComponents(from));
6552
- var toComponents = reducePathComponents(getPathComponents(to));
6553
- var start;
6554
- for (start = 0; start < fromComponents.length && start < toComponents.length; start++) {
6555
- var fromComponent = getCanonicalFileName(fromComponents[start]);
6556
- var toComponent = getCanonicalFileName(toComponents[start]);
6557
- var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer;
6558
- if (!comparer(fromComponent, toComponent))
6559
- break;
6560
- }
6561
- if (start === 0) {
6562
- return toComponents;
6563
- }
6564
- var components = toComponents.slice(start);
6565
- var relative = [];
6566
- for (; start < fromComponents.length; start++) {
6567
- relative.push("..");
6568
- }
6569
- return __spreadArray(__spreadArray([""], relative, true), components, true);
6570
- }
6571
- ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo;
6572
- function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
6573
- ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
6574
- var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
6575
- var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
6576
- var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
6577
- return getPathFromPathComponents(pathComponents);
6578
- }
6579
- ts.getRelativePathFromDirectory = getRelativePathFromDirectory;
6580
- function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
6581
- return !isRootedDiskPath(absoluteOrRelativePath)
6582
- ? absoluteOrRelativePath
6583
- : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
6584
- }
6585
- ts.convertToRelativePath = convertToRelativePath;
6586
- function getRelativePathFromFile(from, to, getCanonicalFileName) {
6587
- return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName));
6588
- }
6589
- ts.getRelativePathFromFile = getRelativePathFromFile;
6590
- function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
6591
- var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName);
6592
- var firstComponent = pathComponents[0];
6593
- if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) {
6594
- var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///";
6595
- pathComponents[0] = prefix + firstComponent;
6596
- }
6597
- return getPathFromPathComponents(pathComponents);
6598
- }
6599
- ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl;
6600
- function forEachAncestorDirectory(directory, callback) {
6601
- while (true) {
6602
- var result = callback(directory);
6603
- if (result !== undefined) {
6604
- return result;
6605
- }
6606
- var parentPath = getDirectoryPath(directory);
6607
- if (parentPath === directory) {
6608
- return undefined;
6609
- }
6610
- directory = parentPath;
6611
- }
6612
- }
6613
- ts.forEachAncestorDirectory = forEachAncestorDirectory;
6614
- function isNodeModulesDirectory(dirPath) {
6615
- return ts.endsWith(dirPath, "/node_modules");
6616
- }
6617
- ts.isNodeModulesDirectory = isNodeModulesDirectory;
6618
- })(ts || (ts = {}));
6619
5921
  var ts;
6620
5922
  (function (ts) {
6621
5923
  /**
@@ -8048,6 +7350,704 @@ var ts;
8048
7350
  ts.Debug.isDebugging = true;
8049
7351
  }
8050
7352
  })(ts || (ts = {}));
7353
+ /* @internal */
7354
+ var ts;
7355
+ (function (ts) {
7356
+ /**
7357
+ * Internally, we represent paths as strings with '/' as the directory separator.
7358
+ * When we make system calls (eg: LanguageServiceHost.getDirectory()),
7359
+ * we expect the host to correctly handle paths in our specified format.
7360
+ */
7361
+ ts.directorySeparator = "/";
7362
+ ts.altDirectorySeparator = "\\";
7363
+ var urlSchemeSeparator = "://";
7364
+ var backslashRegExp = /\\/g;
7365
+ //// Path Tests
7366
+ /**
7367
+ * Determines whether a charCode corresponds to `/` or `\`.
7368
+ */
7369
+ function isAnyDirectorySeparator(charCode) {
7370
+ return charCode === 47 /* slash */ || charCode === 92 /* backslash */;
7371
+ }
7372
+ ts.isAnyDirectorySeparator = isAnyDirectorySeparator;
7373
+ /**
7374
+ * Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.).
7375
+ */
7376
+ function isUrl(path) {
7377
+ return getEncodedRootLength(path) < 0;
7378
+ }
7379
+ ts.isUrl = isUrl;
7380
+ /**
7381
+ * Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path
7382
+ * like `c:`, `c:\` or `c:/`).
7383
+ */
7384
+ function isRootedDiskPath(path) {
7385
+ return getEncodedRootLength(path) > 0;
7386
+ }
7387
+ ts.isRootedDiskPath = isRootedDiskPath;
7388
+ /**
7389
+ * Determines whether a path consists only of a path root.
7390
+ */
7391
+ function isDiskPathRoot(path) {
7392
+ var rootLength = getEncodedRootLength(path);
7393
+ return rootLength > 0 && rootLength === path.length;
7394
+ }
7395
+ ts.isDiskPathRoot = isDiskPathRoot;
7396
+ /**
7397
+ * Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.).
7398
+ *
7399
+ * ```ts
7400
+ * // POSIX
7401
+ * pathIsAbsolute("/path/to/file.ext") === true
7402
+ * // DOS
7403
+ * pathIsAbsolute("c:/path/to/file.ext") === true
7404
+ * // URL
7405
+ * pathIsAbsolute("file:///path/to/file.ext") === true
7406
+ * // Non-absolute
7407
+ * pathIsAbsolute("path/to/file.ext") === false
7408
+ * pathIsAbsolute("./path/to/file.ext") === false
7409
+ * ```
7410
+ */
7411
+ function pathIsAbsolute(path) {
7412
+ return getEncodedRootLength(path) !== 0;
7413
+ }
7414
+ ts.pathIsAbsolute = pathIsAbsolute;
7415
+ /**
7416
+ * Determines whether a path starts with a relative path component (i.e. `.` or `..`).
7417
+ */
7418
+ function pathIsRelative(path) {
7419
+ return /^\.\.?($|[\\/])/.test(path);
7420
+ }
7421
+ ts.pathIsRelative = pathIsRelative;
7422
+ /**
7423
+ * Determines whether a path is neither relative nor absolute, e.g. "path/to/file".
7424
+ * Also known misleadingly as "non-relative".
7425
+ */
7426
+ function pathIsBareSpecifier(path) {
7427
+ return !pathIsAbsolute(path) && !pathIsRelative(path);
7428
+ }
7429
+ ts.pathIsBareSpecifier = pathIsBareSpecifier;
7430
+ function hasExtension(fileName) {
7431
+ return ts.stringContains(getBaseFileName(fileName), ".");
7432
+ }
7433
+ ts.hasExtension = hasExtension;
7434
+ function fileExtensionIs(path, extension) {
7435
+ return path.length > extension.length && ts.endsWith(path, extension);
7436
+ }
7437
+ ts.fileExtensionIs = fileExtensionIs;
7438
+ function fileExtensionIsOneOf(path, extensions) {
7439
+ for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
7440
+ var extension = extensions_1[_i];
7441
+ if (fileExtensionIs(path, extension)) {
7442
+ return true;
7443
+ }
7444
+ }
7445
+ return false;
7446
+ }
7447
+ ts.fileExtensionIsOneOf = fileExtensionIsOneOf;
7448
+ /**
7449
+ * Determines whether a path has a trailing separator (`/` or `\\`).
7450
+ */
7451
+ function hasTrailingDirectorySeparator(path) {
7452
+ return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1));
7453
+ }
7454
+ ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator;
7455
+ //// Path Parsing
7456
+ function isVolumeCharacter(charCode) {
7457
+ return (charCode >= 97 /* a */ && charCode <= 122 /* z */) ||
7458
+ (charCode >= 65 /* A */ && charCode <= 90 /* Z */);
7459
+ }
7460
+ function getFileUrlVolumeSeparatorEnd(url, start) {
7461
+ var ch0 = url.charCodeAt(start);
7462
+ if (ch0 === 58 /* colon */)
7463
+ return start + 1;
7464
+ if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) {
7465
+ var ch2 = url.charCodeAt(start + 2);
7466
+ if (ch2 === 97 /* a */ || ch2 === 65 /* A */)
7467
+ return start + 3;
7468
+ }
7469
+ return -1;
7470
+ }
7471
+ /**
7472
+ * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
7473
+ * If the root is part of a URL, the twos-complement of the root length is returned.
7474
+ */
7475
+ function getEncodedRootLength(path) {
7476
+ if (!path)
7477
+ return 0;
7478
+ var ch0 = path.charCodeAt(0);
7479
+ // POSIX or UNC
7480
+ if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) {
7481
+ if (path.charCodeAt(1) !== ch0)
7482
+ return 1; // POSIX: "/" (or non-normalized "\")
7483
+ var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2);
7484
+ if (p1 < 0)
7485
+ return path.length; // UNC: "//server" or "\\server"
7486
+ return p1 + 1; // UNC: "//server/" or "\\server\"
7487
+ }
7488
+ // DOS
7489
+ if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) {
7490
+ var ch2 = path.charCodeAt(2);
7491
+ if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */)
7492
+ return 3; // DOS: "c:/" or "c:\"
7493
+ if (path.length === 2)
7494
+ return 2; // DOS: "c:" (but not "c:d")
7495
+ }
7496
+ // URL
7497
+ var schemeEnd = path.indexOf(urlSchemeSeparator);
7498
+ if (schemeEnd !== -1) {
7499
+ var authorityStart = schemeEnd + urlSchemeSeparator.length;
7500
+ var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart);
7501
+ if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path"
7502
+ // For local "file" URLs, include the leading DOS volume (if present).
7503
+ // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a
7504
+ // special case interpreted as "the machine from which the URL is being interpreted".
7505
+ var scheme = path.slice(0, schemeEnd);
7506
+ var authority = path.slice(authorityStart, authorityEnd);
7507
+ if (scheme === "file" && (authority === "" || authority === "localhost") &&
7508
+ isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
7509
+ var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
7510
+ if (volumeSeparatorEnd !== -1) {
7511
+ if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) {
7512
+ // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/"
7513
+ return ~(volumeSeparatorEnd + 1);
7514
+ }
7515
+ if (volumeSeparatorEnd === path.length) {
7516
+ // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a"
7517
+ // but not "file:///c:d" or "file:///c%3ad"
7518
+ return ~volumeSeparatorEnd;
7519
+ }
7520
+ }
7521
+ }
7522
+ return ~(authorityEnd + 1); // URL: "file://server/", "http://server/"
7523
+ }
7524
+ return ~path.length; // URL: "file://server", "http://server"
7525
+ }
7526
+ // relative
7527
+ return 0;
7528
+ }
7529
+ /**
7530
+ * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
7531
+ *
7532
+ * For example:
7533
+ * ```ts
7534
+ * getRootLength("a") === 0 // ""
7535
+ * getRootLength("/") === 1 // "/"
7536
+ * getRootLength("c:") === 2 // "c:"
7537
+ * getRootLength("c:d") === 0 // ""
7538
+ * getRootLength("c:/") === 3 // "c:/"
7539
+ * getRootLength("c:\\") === 3 // "c:\\"
7540
+ * getRootLength("//server") === 7 // "//server"
7541
+ * getRootLength("//server/share") === 8 // "//server/"
7542
+ * getRootLength("\\\\server") === 7 // "\\\\server"
7543
+ * getRootLength("\\\\server\\share") === 8 // "\\\\server\\"
7544
+ * getRootLength("file:///path") === 8 // "file:///"
7545
+ * getRootLength("file:///c:") === 10 // "file:///c:"
7546
+ * getRootLength("file:///c:d") === 8 // "file:///"
7547
+ * getRootLength("file:///c:/path") === 11 // "file:///c:/"
7548
+ * getRootLength("file://server") === 13 // "file://server"
7549
+ * getRootLength("file://server/path") === 14 // "file://server/"
7550
+ * getRootLength("http://server") === 13 // "http://server"
7551
+ * getRootLength("http://server/path") === 14 // "http://server/"
7552
+ * ```
7553
+ */
7554
+ function getRootLength(path) {
7555
+ var rootLength = getEncodedRootLength(path);
7556
+ return rootLength < 0 ? ~rootLength : rootLength;
7557
+ }
7558
+ ts.getRootLength = getRootLength;
7559
+ function getDirectoryPath(path) {
7560
+ path = normalizeSlashes(path);
7561
+ // If the path provided is itself the root, then return it.
7562
+ var rootLength = getRootLength(path);
7563
+ if (rootLength === path.length)
7564
+ return path;
7565
+ // return the leading portion of the path up to the last (non-terminal) directory separator
7566
+ // but not including any trailing directory separator.
7567
+ path = removeTrailingDirectorySeparator(path);
7568
+ return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator)));
7569
+ }
7570
+ ts.getDirectoryPath = getDirectoryPath;
7571
+ function getBaseFileName(path, extensions, ignoreCase) {
7572
+ path = normalizeSlashes(path);
7573
+ // if the path provided is itself the root, then it has not file name.
7574
+ var rootLength = getRootLength(path);
7575
+ if (rootLength === path.length)
7576
+ return "";
7577
+ // return the trailing portion of the path starting after the last (non-terminal) directory
7578
+ // separator but not including any trailing directory separator.
7579
+ path = removeTrailingDirectorySeparator(path);
7580
+ var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1));
7581
+ var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined;
7582
+ return extension ? name.slice(0, name.length - extension.length) : name;
7583
+ }
7584
+ ts.getBaseFileName = getBaseFileName;
7585
+ function tryGetExtensionFromPath(path, extension, stringEqualityComparer) {
7586
+ if (!ts.startsWith(extension, "."))
7587
+ extension = "." + extension;
7588
+ if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) {
7589
+ var pathExtension = path.slice(path.length - extension.length);
7590
+ if (stringEqualityComparer(pathExtension, extension)) {
7591
+ return pathExtension;
7592
+ }
7593
+ }
7594
+ }
7595
+ function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) {
7596
+ if (typeof extensions === "string") {
7597
+ return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || "";
7598
+ }
7599
+ for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) {
7600
+ var extension = extensions_2[_i];
7601
+ var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer);
7602
+ if (result)
7603
+ return result;
7604
+ }
7605
+ return "";
7606
+ }
7607
+ function getAnyExtensionFromPath(path, extensions, ignoreCase) {
7608
+ // Retrieves any string from the final "." onwards from a base file name.
7609
+ // Unlike extensionFromPath, which throws an exception on unrecognized extensions.
7610
+ if (extensions) {
7611
+ return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive);
7612
+ }
7613
+ var baseFileName = getBaseFileName(path);
7614
+ var extensionIndex = baseFileName.lastIndexOf(".");
7615
+ if (extensionIndex >= 0) {
7616
+ return baseFileName.substring(extensionIndex);
7617
+ }
7618
+ return "";
7619
+ }
7620
+ ts.getAnyExtensionFromPath = getAnyExtensionFromPath;
7621
+ function pathComponents(path, rootLength) {
7622
+ var root = path.substring(0, rootLength);
7623
+ var rest = path.substring(rootLength).split(ts.directorySeparator);
7624
+ if (rest.length && !ts.lastOrUndefined(rest))
7625
+ rest.pop();
7626
+ return __spreadArray([root], rest, true);
7627
+ }
7628
+ /**
7629
+ * Parse a path into an array containing a root component (at index 0) and zero or more path
7630
+ * components (at indices > 0). The result is not normalized.
7631
+ * If the path is relative, the root component is `""`.
7632
+ * If the path is absolute, the root component includes the first path separator (`/`).
7633
+ *
7634
+ * ```ts
7635
+ * // POSIX
7636
+ * getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"]
7637
+ * getPathComponents("/path/to/") === ["/", "path", "to"]
7638
+ * getPathComponents("/") === ["/"]
7639
+ * // DOS
7640
+ * getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"]
7641
+ * getPathComponents("c:/path/to/") === ["c:/", "path", "to"]
7642
+ * getPathComponents("c:/") === ["c:/"]
7643
+ * getPathComponents("c:") === ["c:"]
7644
+ * // URL
7645
+ * getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"]
7646
+ * getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"]
7647
+ * getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"]
7648
+ * getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"]
7649
+ * getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"]
7650
+ * getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"]
7651
+ * getPathComponents("file://server/") === ["file://server/"]
7652
+ * getPathComponents("file://server") === ["file://server"]
7653
+ * getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"]
7654
+ * getPathComponents("file:///path/to/") === ["file:///", "path", "to"]
7655
+ * getPathComponents("file:///") === ["file:///"]
7656
+ * getPathComponents("file://") === ["file://"]
7657
+ */
7658
+ function getPathComponents(path, currentDirectory) {
7659
+ if (currentDirectory === void 0) { currentDirectory = ""; }
7660
+ path = combinePaths(currentDirectory, path);
7661
+ return pathComponents(path, getRootLength(path));
7662
+ }
7663
+ ts.getPathComponents = getPathComponents;
7664
+ //// Path Formatting
7665
+ /**
7666
+ * Formats a parsed path consisting of a root component (at index 0) and zero or more path
7667
+ * segments (at indices > 0).
7668
+ *
7669
+ * ```ts
7670
+ * getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext"
7671
+ * ```
7672
+ */
7673
+ function getPathFromPathComponents(pathComponents) {
7674
+ if (pathComponents.length === 0)
7675
+ return "";
7676
+ var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
7677
+ return root + pathComponents.slice(1).join(ts.directorySeparator);
7678
+ }
7679
+ ts.getPathFromPathComponents = getPathFromPathComponents;
7680
+ //// Path Normalization
7681
+ /**
7682
+ * Normalize path separators, converting `\` into `/`.
7683
+ */
7684
+ function normalizeSlashes(path) {
7685
+ var index = path.indexOf("\\");
7686
+ if (index === -1) {
7687
+ return path;
7688
+ }
7689
+ backslashRegExp.lastIndex = index; // prime regex with known position
7690
+ return path.replace(backslashRegExp, ts.directorySeparator);
7691
+ }
7692
+ ts.normalizeSlashes = normalizeSlashes;
7693
+ /**
7694
+ * Reduce an array of path components to a more simplified path by navigating any
7695
+ * `"."` or `".."` entries in the path.
7696
+ */
7697
+ function reducePathComponents(components) {
7698
+ if (!ts.some(components))
7699
+ return [];
7700
+ var reduced = [components[0]];
7701
+ for (var i = 1; i < components.length; i++) {
7702
+ var component = components[i];
7703
+ if (!component)
7704
+ continue;
7705
+ if (component === ".")
7706
+ continue;
7707
+ if (component === "..") {
7708
+ if (reduced.length > 1) {
7709
+ if (reduced[reduced.length - 1] !== "..") {
7710
+ reduced.pop();
7711
+ continue;
7712
+ }
7713
+ }
7714
+ else if (reduced[0])
7715
+ continue;
7716
+ }
7717
+ reduced.push(component);
7718
+ }
7719
+ return reduced;
7720
+ }
7721
+ ts.reducePathComponents = reducePathComponents;
7722
+ /**
7723
+ * Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified.
7724
+ *
7725
+ * ```ts
7726
+ * // Non-rooted
7727
+ * combinePaths("path", "to", "file.ext") === "path/to/file.ext"
7728
+ * combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext"
7729
+ * // POSIX
7730
+ * combinePaths("/path", "to", "file.ext") === "/path/to/file.ext"
7731
+ * combinePaths("/path", "/to", "file.ext") === "/to/file.ext"
7732
+ * // DOS
7733
+ * combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext"
7734
+ * combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext"
7735
+ * // URL
7736
+ * combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext"
7737
+ * combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext"
7738
+ * ```
7739
+ */
7740
+ function combinePaths(path) {
7741
+ var paths = [];
7742
+ for (var _i = 1; _i < arguments.length; _i++) {
7743
+ paths[_i - 1] = arguments[_i];
7744
+ }
7745
+ if (path)
7746
+ path = normalizeSlashes(path);
7747
+ for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
7748
+ var relativePath = paths_1[_a];
7749
+ if (!relativePath)
7750
+ continue;
7751
+ relativePath = normalizeSlashes(relativePath);
7752
+ if (!path || getRootLength(relativePath) !== 0) {
7753
+ path = relativePath;
7754
+ }
7755
+ else {
7756
+ path = ensureTrailingDirectorySeparator(path) + relativePath;
7757
+ }
7758
+ }
7759
+ return path;
7760
+ }
7761
+ ts.combinePaths = combinePaths;
7762
+ /**
7763
+ * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any
7764
+ * `.` and `..` path components are resolved. Trailing directory separators are preserved.
7765
+ *
7766
+ * ```ts
7767
+ * resolvePath("/path", "to", "file.ext") === "path/to/file.ext"
7768
+ * resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/"
7769
+ * resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext"
7770
+ * ```
7771
+ */
7772
+ function resolvePath(path) {
7773
+ var paths = [];
7774
+ for (var _i = 1; _i < arguments.length; _i++) {
7775
+ paths[_i - 1] = arguments[_i];
7776
+ }
7777
+ return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArray([path], paths, false)) : normalizeSlashes(path));
7778
+ }
7779
+ ts.resolvePath = resolvePath;
7780
+ /**
7781
+ * Parse a path into an array containing a root component (at index 0) and zero or more path
7782
+ * components (at indices > 0). The result is normalized.
7783
+ * If the path is relative, the root component is `""`.
7784
+ * If the path is absolute, the root component includes the first path separator (`/`).
7785
+ *
7786
+ * ```ts
7787
+ * getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"]
7788
+ * ```
7789
+ */
7790
+ function getNormalizedPathComponents(path, currentDirectory) {
7791
+ return reducePathComponents(getPathComponents(path, currentDirectory));
7792
+ }
7793
+ ts.getNormalizedPathComponents = getNormalizedPathComponents;
7794
+ function getNormalizedAbsolutePath(fileName, currentDirectory) {
7795
+ return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
7796
+ }
7797
+ ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
7798
+ function normalizePath(path) {
7799
+ path = normalizeSlashes(path);
7800
+ // Most paths don't require normalization
7801
+ if (!relativePathSegmentRegExp.test(path)) {
7802
+ return path;
7803
+ }
7804
+ // Some paths only require cleanup of `/./` or leading `./`
7805
+ var simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, "");
7806
+ if (simplified !== path) {
7807
+ path = simplified;
7808
+ if (!relativePathSegmentRegExp.test(path)) {
7809
+ return path;
7810
+ }
7811
+ }
7812
+ // Other paths require full normalization
7813
+ var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
7814
+ return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
7815
+ }
7816
+ ts.normalizePath = normalizePath;
7817
+ function getPathWithoutRoot(pathComponents) {
7818
+ if (pathComponents.length === 0)
7819
+ return "";
7820
+ return pathComponents.slice(1).join(ts.directorySeparator);
7821
+ }
7822
+ function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
7823
+ return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
7824
+ }
7825
+ ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
7826
+ function toPath(fileName, basePath, getCanonicalFileName) {
7827
+ var nonCanonicalizedPath = isRootedDiskPath(fileName)
7828
+ ? normalizePath(fileName)
7829
+ : getNormalizedAbsolutePath(fileName, basePath);
7830
+ return getCanonicalFileName(nonCanonicalizedPath);
7831
+ }
7832
+ ts.toPath = toPath;
7833
+ function normalizePathAndParts(path) {
7834
+ path = normalizeSlashes(path);
7835
+ var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
7836
+ if (parts.length) {
7837
+ var joinedParts = root + parts.join(ts.directorySeparator);
7838
+ return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
7839
+ }
7840
+ else {
7841
+ return { path: root, parts: parts };
7842
+ }
7843
+ }
7844
+ ts.normalizePathAndParts = normalizePathAndParts;
7845
+ function removeTrailingDirectorySeparator(path) {
7846
+ if (hasTrailingDirectorySeparator(path)) {
7847
+ return path.substr(0, path.length - 1);
7848
+ }
7849
+ return path;
7850
+ }
7851
+ ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
7852
+ function ensureTrailingDirectorySeparator(path) {
7853
+ if (!hasTrailingDirectorySeparator(path)) {
7854
+ return path + ts.directorySeparator;
7855
+ }
7856
+ return path;
7857
+ }
7858
+ ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator;
7859
+ /**
7860
+ * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed
7861
+ * with `./` or `../`) so as not to be confused with an unprefixed module name.
7862
+ *
7863
+ * ```ts
7864
+ * ensurePathIsNonModuleName("/path/to/file.ext") === "/path/to/file.ext"
7865
+ * ensurePathIsNonModuleName("./path/to/file.ext") === "./path/to/file.ext"
7866
+ * ensurePathIsNonModuleName("../path/to/file.ext") === "../path/to/file.ext"
7867
+ * ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext"
7868
+ * ```
7869
+ */
7870
+ function ensurePathIsNonModuleName(path) {
7871
+ return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path;
7872
+ }
7873
+ ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName;
7874
+ function changeAnyExtension(path, ext, extensions, ignoreCase) {
7875
+ var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path);
7876
+ return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
7877
+ }
7878
+ ts.changeAnyExtension = changeAnyExtension;
7879
+ //// Path Comparisons
7880
+ // check path for these segments: '', '.'. '..'
7881
+ var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/;
7882
+ function comparePathsWorker(a, b, componentComparer) {
7883
+ if (a === b)
7884
+ return 0 /* EqualTo */;
7885
+ if (a === undefined)
7886
+ return -1 /* LessThan */;
7887
+ if (b === undefined)
7888
+ return 1 /* GreaterThan */;
7889
+ // NOTE: Performance optimization - shortcut if the root segments differ as there would be no
7890
+ // need to perform path reduction.
7891
+ var aRoot = a.substring(0, getRootLength(a));
7892
+ var bRoot = b.substring(0, getRootLength(b));
7893
+ var result = ts.compareStringsCaseInsensitive(aRoot, bRoot);
7894
+ if (result !== 0 /* EqualTo */) {
7895
+ return result;
7896
+ }
7897
+ // NOTE: Performance optimization - shortcut if there are no relative path segments in
7898
+ // the non-root portion of the path
7899
+ var aRest = a.substring(aRoot.length);
7900
+ var bRest = b.substring(bRoot.length);
7901
+ if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) {
7902
+ return componentComparer(aRest, bRest);
7903
+ }
7904
+ // The path contains a relative path segment. Normalize the paths and perform a slower component
7905
+ // by component comparison.
7906
+ var aComponents = reducePathComponents(getPathComponents(a));
7907
+ var bComponents = reducePathComponents(getPathComponents(b));
7908
+ var sharedLength = Math.min(aComponents.length, bComponents.length);
7909
+ for (var i = 1; i < sharedLength; i++) {
7910
+ var result_2 = componentComparer(aComponents[i], bComponents[i]);
7911
+ if (result_2 !== 0 /* EqualTo */) {
7912
+ return result_2;
7913
+ }
7914
+ }
7915
+ return ts.compareValues(aComponents.length, bComponents.length);
7916
+ }
7917
+ /**
7918
+ * Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively.
7919
+ */
7920
+ function comparePathsCaseSensitive(a, b) {
7921
+ return comparePathsWorker(a, b, ts.compareStringsCaseSensitive);
7922
+ }
7923
+ ts.comparePathsCaseSensitive = comparePathsCaseSensitive;
7924
+ /**
7925
+ * Performs a case-insensitive comparison of two paths.
7926
+ */
7927
+ function comparePathsCaseInsensitive(a, b) {
7928
+ return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive);
7929
+ }
7930
+ ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive;
7931
+ function comparePaths(a, b, currentDirectory, ignoreCase) {
7932
+ if (typeof currentDirectory === "string") {
7933
+ a = combinePaths(currentDirectory, a);
7934
+ b = combinePaths(currentDirectory, b);
7935
+ }
7936
+ else if (typeof currentDirectory === "boolean") {
7937
+ ignoreCase = currentDirectory;
7938
+ }
7939
+ return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase));
7940
+ }
7941
+ ts.comparePaths = comparePaths;
7942
+ function containsPath(parent, child, currentDirectory, ignoreCase) {
7943
+ if (typeof currentDirectory === "string") {
7944
+ parent = combinePaths(currentDirectory, parent);
7945
+ child = combinePaths(currentDirectory, child);
7946
+ }
7947
+ else if (typeof currentDirectory === "boolean") {
7948
+ ignoreCase = currentDirectory;
7949
+ }
7950
+ if (parent === undefined || child === undefined)
7951
+ return false;
7952
+ if (parent === child)
7953
+ return true;
7954
+ var parentComponents = reducePathComponents(getPathComponents(parent));
7955
+ var childComponents = reducePathComponents(getPathComponents(child));
7956
+ if (childComponents.length < parentComponents.length) {
7957
+ return false;
7958
+ }
7959
+ var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive;
7960
+ for (var i = 0; i < parentComponents.length; i++) {
7961
+ var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer;
7962
+ if (!equalityComparer(parentComponents[i], childComponents[i])) {
7963
+ return false;
7964
+ }
7965
+ }
7966
+ return true;
7967
+ }
7968
+ ts.containsPath = containsPath;
7969
+ /**
7970
+ * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback.
7971
+ * Comparison is case-sensitive between the canonical paths.
7972
+ *
7973
+ * Use `containsPath` if file names are not already reduced and absolute.
7974
+ */
7975
+ function startsWithDirectory(fileName, directoryName, getCanonicalFileName) {
7976
+ var canonicalFileName = getCanonicalFileName(fileName);
7977
+ var canonicalDirectoryName = getCanonicalFileName(directoryName);
7978
+ return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\");
7979
+ }
7980
+ ts.startsWithDirectory = startsWithDirectory;
7981
+ //// Relative Paths
7982
+ function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) {
7983
+ var fromComponents = reducePathComponents(getPathComponents(from));
7984
+ var toComponents = reducePathComponents(getPathComponents(to));
7985
+ var start;
7986
+ for (start = 0; start < fromComponents.length && start < toComponents.length; start++) {
7987
+ var fromComponent = getCanonicalFileName(fromComponents[start]);
7988
+ var toComponent = getCanonicalFileName(toComponents[start]);
7989
+ var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer;
7990
+ if (!comparer(fromComponent, toComponent))
7991
+ break;
7992
+ }
7993
+ if (start === 0) {
7994
+ return toComponents;
7995
+ }
7996
+ var components = toComponents.slice(start);
7997
+ var relative = [];
7998
+ for (; start < fromComponents.length; start++) {
7999
+ relative.push("..");
8000
+ }
8001
+ return __spreadArray(__spreadArray([""], relative, true), components, true);
8002
+ }
8003
+ ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo;
8004
+ function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
8005
+ ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
8006
+ var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
8007
+ var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
8008
+ var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
8009
+ return getPathFromPathComponents(pathComponents);
8010
+ }
8011
+ ts.getRelativePathFromDirectory = getRelativePathFromDirectory;
8012
+ function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
8013
+ return !isRootedDiskPath(absoluteOrRelativePath)
8014
+ ? absoluteOrRelativePath
8015
+ : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
8016
+ }
8017
+ ts.convertToRelativePath = convertToRelativePath;
8018
+ function getRelativePathFromFile(from, to, getCanonicalFileName) {
8019
+ return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName));
8020
+ }
8021
+ ts.getRelativePathFromFile = getRelativePathFromFile;
8022
+ function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
8023
+ var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName);
8024
+ var firstComponent = pathComponents[0];
8025
+ if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) {
8026
+ var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///";
8027
+ pathComponents[0] = prefix + firstComponent;
8028
+ }
8029
+ return getPathFromPathComponents(pathComponents);
8030
+ }
8031
+ ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl;
8032
+ function forEachAncestorDirectory(directory, callback) {
8033
+ while (true) {
8034
+ var result = callback(directory);
8035
+ if (result !== undefined) {
8036
+ return result;
8037
+ }
8038
+ var parentPath = getDirectoryPath(directory);
8039
+ if (parentPath === directory) {
8040
+ return undefined;
8041
+ }
8042
+ directory = parentPath;
8043
+ }
8044
+ }
8045
+ ts.forEachAncestorDirectory = forEachAncestorDirectory;
8046
+ function isNodeModulesDirectory(dirPath) {
8047
+ return ts.endsWith(dirPath, "/node_modules");
8048
+ }
8049
+ ts.isNodeModulesDirectory = isNodeModulesDirectory;
8050
+ })(ts || (ts = {}));
8051
8051
  // <auto-generated />
8052
8052
  // generated from './diagnosticMessages.json' in 'src/compiler'
8053
8053
  /* @internal */
@@ -13003,12 +13003,17 @@ var ts;
13003
13003
  /** Gets the text of a jsdoc comment, flattening links to their text. */
13004
13004
  function getTextOfJSDocComment(comment) {
13005
13005
  return typeof comment === "string" ? comment
13006
- : comment === null || comment === void 0 ? void 0 : comment.map(function (c) {
13007
- // TODO: Other kinds here
13008
- return c.kind === 319 /* JSDocText */ ? c.text : "{@link " + (c.name ? ts.entityNameToString(c.name) + " " : "") + c.text + "}";
13009
- }).join("");
13006
+ : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 319 /* JSDocText */ ? c.text : formatJSDocLink(c); }).join("");
13010
13007
  }
13011
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
+ }
13012
13017
  /**
13013
13018
  * Gets the effective type parameters. If the node was parsed in a
13014
13019
  * JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
@@ -47057,8 +47062,8 @@ var ts;
47057
47062
  TypeFacts[TypeFacts["AllTypeofNE"] = 556800] = "AllTypeofNE";
47058
47063
  TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts";
47059
47064
  // Masks
47060
- TypeFacts[TypeFacts["OrFactsMask"] = 8288] = "OrFactsMask";
47061
- TypeFacts[TypeFacts["AndFactsMask"] = 16768927] = "AndFactsMask";
47065
+ TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
47066
+ TypeFacts[TypeFacts["AndFactsMask"] = 16768959] = "AndFactsMask";
47062
47067
  })(TypeFacts || (TypeFacts = {}));
47063
47068
  var typeofEQFacts = new ts.Map(ts.getEntries({
47064
47069
  string: 1 /* TypeofEQString */,
@@ -68166,7 +68171,10 @@ var ts;
68166
68171
  (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ :
68167
68172
  (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
68168
68173
  }
68169
- if (flags & 524288 /* Object */ && !ignoreObjects) {
68174
+ if (flags & 524288 /* Object */) {
68175
+ if (ignoreObjects) {
68176
+ return 16768959 /* AndFactsMask */; // This is the identity element for computing type facts of intersection.
68177
+ }
68170
68178
  return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ?
68171
68179
  strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ :
68172
68180
  isFunctionObjectType(type) ?
@@ -68214,7 +68222,7 @@ var ts;
68214
68222
  oredFacts |= f;
68215
68223
  andedFacts &= f;
68216
68224
  }
68217
- return oredFacts & 8288 /* OrFactsMask */ | andedFacts & 16768927 /* AndFactsMask */;
68225
+ return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 16768959 /* AndFactsMask */;
68218
68226
  }
68219
68227
  function getTypeWithFacts(type, include) {
68220
68228
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
@@ -70174,6 +70182,9 @@ var ts;
70174
70182
  return getTypeOfSymbol(symbol);
70175
70183
  }
70176
70184
  function checkIdentifier(node, checkMode) {
70185
+ if (ts.isThisInTypeQuery(node)) {
70186
+ return checkThisExpression(node);
70187
+ }
70177
70188
  var symbol = getResolvedSymbol(node);
70178
70189
  if (symbol === unknownSymbol) {
70179
70190
  return errorType;
@@ -71965,7 +71976,8 @@ var ts;
71965
71976
  var links = getNodeLinks(node.expression);
71966
71977
  if (!links.resolvedType) {
71967
71978
  if ((ts.isTypeLiteralNode(node.parent.parent) || ts.isClassLike(node.parent.parent) || ts.isInterfaceDeclaration(node.parent.parent))
71968
- && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */) {
71979
+ && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */
71980
+ && node.parent.kind !== 171 /* GetAccessor */ && node.parent.kind !== 172 /* SetAccessor */) {
71969
71981
  return links.resolvedType = errorType;
71970
71982
  }
71971
71983
  links.resolvedType = checkExpression(node.expression);
@@ -75913,6 +75925,10 @@ var ts;
75913
75925
  return restParameter.escapedName;
75914
75926
  }
75915
75927
  function getParameterIdentifierNameAtPosition(signature, pos) {
75928
+ var _a;
75929
+ if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 315 /* JSDocFunctionType */) {
75930
+ return undefined;
75931
+ }
75916
75932
  var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
75917
75933
  if (pos < paramCount) {
75918
75934
  var param = signature.parameters[pos];
@@ -84677,7 +84693,10 @@ var ts;
84677
84693
  case 80 /* PrivateIdentifier */:
84678
84694
  case 205 /* PropertyAccessExpression */:
84679
84695
  case 160 /* QualifiedName */:
84680
- return getSymbolOfNameOrPropertyAccessExpression(node);
84696
+ if (!ts.isThisInTypeQuery(node)) {
84697
+ return getSymbolOfNameOrPropertyAccessExpression(node);
84698
+ }
84699
+ // falls through
84681
84700
  case 108 /* ThisKeyword */:
84682
84701
  var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false);
84683
84702
  if (ts.isFunctionLike(container)) {
@@ -94651,6 +94670,7 @@ var ts;
94651
94670
  var exportedVariableStatement = false;
94652
94671
  var enabledSubstitutions;
94653
94672
  var enclosingFunctionFlags;
94673
+ var parametersWithPrecedingObjectRestOrSpread;
94654
94674
  var enclosingSuperContainerFlags = 0;
94655
94675
  var hierarchyFacts = 0;
94656
94676
  var currentSourceFile;
@@ -95107,6 +95127,7 @@ var ts;
95107
95127
  /*incrementor*/ undefined,
95108
95128
  /*statement*/ convertForOfStatementHead(node, getValue)),
95109
95129
  /*location*/ node), 256 /* NoTokenTrailingSourceMaps */);
95130
+ ts.setOriginalNode(forStatement, node);
95110
95131
  return factory.createTryStatement(factory.createBlock([
95111
95132
  factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement)
95112
95133
  ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([
@@ -95124,7 +95145,19 @@ var ts;
95124
95145
  ]), 1 /* SingleLine */))
95125
95146
  ]));
95126
95147
  }
95148
+ function parameterVisitor(node) {
95149
+ ts.Debug.assertNode(node, ts.isParameter);
95150
+ return visitParameter(node);
95151
+ }
95127
95152
  function visitParameter(node) {
95153
+ if (parametersWithPrecedingObjectRestOrSpread === null || parametersWithPrecedingObjectRestOrSpread === void 0 ? void 0 : parametersWithPrecedingObjectRestOrSpread.has(node)) {
95154
+ return factory.updateParameterDeclaration(node,
95155
+ /*decorators*/ undefined,
95156
+ /*modifiers*/ undefined, node.dotDotDotToken, ts.isBindingPattern(node.name) ? factory.getGeneratedNameForNode(node) : node.name,
95157
+ /*questionToken*/ undefined,
95158
+ /*type*/ undefined,
95159
+ /*initializer*/ undefined);
95160
+ }
95128
95161
  if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
95129
95162
  // Binding patterns are converted into a generated name and are
95130
95163
  // evaluated inside the function body.
@@ -95136,85 +95169,119 @@ var ts;
95136
95169
  }
95137
95170
  return ts.visitEachChild(node, visitor, context);
95138
95171
  }
95172
+ function collectParametersWithPrecedingObjectRestOrSpread(node) {
95173
+ var parameters;
95174
+ for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
95175
+ var parameter = _a[_i];
95176
+ if (parameters) {
95177
+ parameters.add(parameter);
95178
+ }
95179
+ else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
95180
+ parameters = new ts.Set();
95181
+ }
95182
+ }
95183
+ return parameters;
95184
+ }
95139
95185
  function visitConstructorDeclaration(node) {
95140
95186
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95141
- enclosingFunctionFlags = 0 /* Normal */;
95187
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95188
+ enclosingFunctionFlags = ts.getFunctionFlags(node);
95189
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95142
95190
  var updated = factory.updateConstructorDeclaration(node,
95143
- /*decorators*/ undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
95191
+ /*decorators*/ undefined, node.modifiers, ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node));
95144
95192
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95193
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95145
95194
  return updated;
95146
95195
  }
95147
95196
  function visitGetAccessorDeclaration(node) {
95148
95197
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95149
- enclosingFunctionFlags = 0 /* Normal */;
95198
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95199
+ enclosingFunctionFlags = ts.getFunctionFlags(node);
95200
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95150
95201
  var updated = factory.updateGetAccessorDeclaration(node,
95151
- /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context),
95202
+ /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context),
95152
95203
  /*type*/ undefined, transformFunctionBody(node));
95153
95204
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95205
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95154
95206
  return updated;
95155
95207
  }
95156
95208
  function visitSetAccessorDeclaration(node) {
95157
95209
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95158
- enclosingFunctionFlags = 0 /* Normal */;
95210
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95211
+ enclosingFunctionFlags = ts.getFunctionFlags(node);
95212
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95159
95213
  var updated = factory.updateSetAccessorDeclaration(node,
95160
- /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
95214
+ /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node));
95161
95215
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95216
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95162
95217
  return updated;
95163
95218
  }
95164
95219
  function visitMethodDeclaration(node) {
95165
95220
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95221
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95166
95222
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95223
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95167
95224
  var updated = factory.updateMethodDeclaration(node,
95168
95225
  /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */
95169
95226
  ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
95170
95227
  : node.modifiers, enclosingFunctionFlags & 2 /* Async */
95171
95228
  ? undefined
95172
95229
  : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(/*questionToken*/ undefined, visitor, ts.isToken),
95173
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95230
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
95174
95231
  /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
95175
95232
  ? transformAsyncGeneratorFunctionBody(node)
95176
95233
  : transformFunctionBody(node));
95177
95234
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95235
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95178
95236
  return updated;
95179
95237
  }
95180
95238
  function visitFunctionDeclaration(node) {
95181
95239
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95240
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95182
95241
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95242
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95183
95243
  var updated = factory.updateFunctionDeclaration(node,
95184
95244
  /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */
95185
95245
  ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
95186
95246
  : node.modifiers, enclosingFunctionFlags & 2 /* Async */
95187
95247
  ? undefined
95188
95248
  : node.asteriskToken, node.name,
95189
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95249
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
95190
95250
  /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
95191
95251
  ? transformAsyncGeneratorFunctionBody(node)
95192
95252
  : transformFunctionBody(node));
95193
95253
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95254
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95194
95255
  return updated;
95195
95256
  }
95196
95257
  function visitArrowFunction(node) {
95197
95258
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95259
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95198
95260
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95261
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95199
95262
  var updated = factory.updateArrowFunction(node, node.modifiers,
95200
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95263
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
95201
95264
  /*type*/ undefined, node.equalsGreaterThanToken, transformFunctionBody(node));
95202
95265
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95266
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95203
95267
  return updated;
95204
95268
  }
95205
95269
  function visitFunctionExpression(node) {
95206
95270
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95271
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95207
95272
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95273
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95208
95274
  var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */
95209
95275
  ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
95210
95276
  : node.modifiers, enclosingFunctionFlags & 2 /* Async */
95211
95277
  ? undefined
95212
95278
  : node.asteriskToken, node.name,
95213
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95279
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
95214
95280
  /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
95215
95281
  ? transformAsyncGeneratorFunctionBody(node)
95216
95282
  : transformFunctionBody(node));
95217
95283
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95284
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95218
95285
  return updated;
95219
95286
  }
95220
95287
  function transformAsyncGeneratorFunctionBody(node) {
@@ -95275,16 +95342,71 @@ var ts;
95275
95342
  return body;
95276
95343
  }
95277
95344
  function appendObjectRestAssignmentsIfNeeded(statements, node) {
95345
+ var containsPrecedingObjectRestOrSpread = false;
95278
95346
  for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
95279
95347
  var parameter = _a[_i];
95280
- if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
95281
- var temp = factory.getGeneratedNameForNode(parameter);
95282
- var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, temp,
95348
+ if (containsPrecedingObjectRestOrSpread) {
95349
+ if (ts.isBindingPattern(parameter.name)) {
95350
+ // In cases where a binding pattern is simply '[]' or '{}',
95351
+ // we usually don't want to emit a var declaration; however, in the presence
95352
+ // of an initializer, we must emit that expression to preserve side effects.
95353
+ //
95354
+ // NOTE: see `insertDefaultValueAssignmentForBindingPattern` in es2015.ts
95355
+ if (parameter.name.elements.length > 0) {
95356
+ var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter));
95357
+ if (ts.some(declarations)) {
95358
+ var declarationList = factory.createVariableDeclarationList(declarations);
95359
+ var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList);
95360
+ ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
95361
+ statements = ts.append(statements, statement);
95362
+ }
95363
+ }
95364
+ else if (parameter.initializer) {
95365
+ var name = factory.getGeneratedNameForNode(parameter);
95366
+ var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression);
95367
+ var assignment = factory.createAssignment(name, initializer);
95368
+ var statement = factory.createExpressionStatement(assignment);
95369
+ ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
95370
+ statements = ts.append(statements, statement);
95371
+ }
95372
+ }
95373
+ else if (parameter.initializer) {
95374
+ // Converts a parameter initializer into a function body statement, i.e.:
95375
+ //
95376
+ // function f(x = 1) { }
95377
+ //
95378
+ // becomes
95379
+ //
95380
+ // function f(x) {
95381
+ // if (typeof x === "undefined") { x = 1; }
95382
+ // }
95383
+ var name = factory.cloneNode(parameter.name);
95384
+ ts.setTextRange(name, parameter.name);
95385
+ ts.setEmitFlags(name, 48 /* NoSourceMap */);
95386
+ var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression);
95387
+ ts.addEmitFlags(initializer, 48 /* NoSourceMap */ | 1536 /* NoComments */);
95388
+ var assignment = factory.createAssignment(name, initializer);
95389
+ ts.setTextRange(assignment, parameter);
95390
+ ts.setEmitFlags(assignment, 1536 /* NoComments */);
95391
+ var block = factory.createBlock([factory.createExpressionStatement(assignment)]);
95392
+ ts.setTextRange(block, parameter);
95393
+ ts.setEmitFlags(block, 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */);
95394
+ var typeCheck = factory.createTypeCheck(factory.cloneNode(parameter.name), "undefined");
95395
+ var statement = factory.createIfStatement(typeCheck, block);
95396
+ ts.startOnNewLine(statement);
95397
+ ts.setTextRange(statement, parameter);
95398
+ ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */);
95399
+ statements = ts.append(statements, statement);
95400
+ }
95401
+ }
95402
+ else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
95403
+ containsPrecedingObjectRestOrSpread = true;
95404
+ var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter),
95283
95405
  /*doNotRecordTempVariablesInLine*/ false,
95284
95406
  /*skipInitializer*/ true);
95285
95407
  if (ts.some(declarations)) {
95286
- var statement = factory.createVariableStatement(
95287
- /*modifiers*/ undefined, factory.createVariableDeclarationList(declarations));
95408
+ var declarationList = factory.createVariableDeclarationList(declarations);
95409
+ var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList);
95288
95410
  ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
95289
95411
  statements = ts.append(statements, statement);
95290
95412
  }
@@ -98535,10 +98657,12 @@ var ts;
98535
98657
  // variables declared in the loop initializer that will be changed inside the loop
98536
98658
  var loopOutParameters = [];
98537
98659
  if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) {
98538
- var hasCapturedBindingsInForInitializer = shouldConvertInitializerOfForStatement(node);
98660
+ var hasCapturedBindingsInForHead = shouldConvertInitializerOfForStatement(node) ||
98661
+ shouldConvertConditionOfForStatement(node) ||
98662
+ shouldConvertIncrementorOfForStatement(node);
98539
98663
  for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) {
98540
98664
  var decl = _a[_i];
98541
- processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
98665
+ processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForHead);
98542
98666
  }
98543
98667
  }
98544
98668
  var currentState = { loopParameters: loopParameters, loopOutParameters: loopOutParameters };
@@ -98892,27 +99016,33 @@ var ts;
98892
99016
  caseClauses.push(factory.createCaseClause(factory.createStringLiteral(labelMarker), statements));
98893
99017
  });
98894
99018
  }
98895
- function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer) {
99019
+ function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForHead) {
98896
99020
  var name = decl.name;
98897
99021
  if (ts.isBindingPattern(name)) {
98898
99022
  for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
98899
99023
  var element = _a[_i];
98900
99024
  if (!ts.isOmittedExpression(element)) {
98901
- processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
99025
+ processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForHead);
98902
99026
  }
98903
99027
  }
98904
99028
  }
98905
99029
  else {
98906
99030
  loopParameters.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name));
98907
99031
  var checkFlags = resolver.getNodeCheckFlags(decl);
98908
- if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForInitializer) {
99032
+ if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) {
98909
99033
  var outParamName = factory.createUniqueName("out_" + ts.idText(name));
98910
99034
  var flags = 0;
98911
99035
  if (checkFlags & 4194304 /* NeedsLoopOutParameter */) {
98912
99036
  flags |= 1 /* Body */;
98913
99037
  }
98914
- if (ts.isForStatement(container) && container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
98915
- flags |= 2 /* Initializer */;
99038
+ if (ts.isForStatement(container)) {
99039
+ if (container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
99040
+ flags |= 2 /* Initializer */;
99041
+ }
99042
+ if (container.condition && resolver.isBindingCapturedByNode(container.condition, decl) ||
99043
+ container.incrementor && resolver.isBindingCapturedByNode(container.incrementor, decl)) {
99044
+ flags |= 1 /* Body */;
99045
+ }
98916
99046
  }
98917
99047
  loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName });
98918
99048
  }
@@ -126349,7 +126479,7 @@ var ts;
126349
126479
  parts.push(linkTextPart(text));
126350
126480
  }
126351
126481
  else {
126352
- parts.push(linkTextPart(name + (suffix ? "" : " ") + text));
126482
+ parts.push(linkTextPart(name + (suffix || text.indexOf("://") === 0 ? "" : " ") + text));
126353
126483
  }
126354
126484
  }
126355
126485
  parts.push(linkPart("}"));
@@ -138973,7 +139103,7 @@ var ts;
138973
139103
  newImportSpecifiers.push(ts.factory.createImportSpecifier(/*isTypeOnly*/ false, ts.factory.createIdentifier("default"), defaultImport.importClause.name)); // TODO: GH#18217
138974
139104
  }
138975
139105
  }
138976
- newImportSpecifiers.push.apply(newImportSpecifiers, ts.flatMap(namedImports, function (i) { return i.importClause.namedBindings.elements; })); // TODO: GH#18217
139106
+ newImportSpecifiers.push.apply(newImportSpecifiers, getNewImportSpecifiers(namedImports));
138977
139107
  var sortedImportSpecifiers = sortSpecifiers(newImportSpecifiers);
138978
139108
  var importDecl = defaultImports.length > 0
138979
139109
  ? defaultImports[0]
@@ -139183,6 +139313,21 @@ var ts;
139183
139313
  return 6;
139184
139314
  }
139185
139315
  }
139316
+ function getNewImportSpecifiers(namedImports) {
139317
+ return ts.flatMap(namedImports, function (namedImport) {
139318
+ return ts.map(tryGetNamedBindingElements(namedImport), function (importSpecifier) {
139319
+ return importSpecifier.name && importSpecifier.propertyName && importSpecifier.name.escapedText === importSpecifier.propertyName.escapedText
139320
+ ? ts.factory.updateImportSpecifier(importSpecifier, importSpecifier.isTypeOnly, /*propertyName*/ undefined, importSpecifier.name)
139321
+ : importSpecifier;
139322
+ });
139323
+ });
139324
+ }
139325
+ function tryGetNamedBindingElements(namedImport) {
139326
+ var _a;
139327
+ return ((_a = namedImport.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings) && ts.isNamedImports(namedImport.importClause.namedBindings)
139328
+ ? namedImport.importClause.namedBindings.elements
139329
+ : undefined;
139330
+ }
139186
139331
  })(OrganizeImports = ts.OrganizeImports || (ts.OrganizeImports = {}));
139187
139332
  })(ts || (ts = {}));
139188
139333
  /* @internal */
@@ -142045,7 +142190,7 @@ var ts;
142045
142190
  if (typeChecker.isArgumentsSymbol(symbol)) {
142046
142191
  return "local var" /* localVariableElement */;
142047
142192
  }
142048
- if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location)) {
142193
+ if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) {
142049
142194
  return "parameter" /* parameterElement */;
142050
142195
  }
142051
142196
  var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol);
@@ -142140,7 +142285,7 @@ var ts;
142140
142285
  var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol);
142141
142286
  var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */;
142142
142287
  var hasAddedSymbolInfo = false;
142143
- var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location);
142288
+ var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location);
142144
142289
  var type;
142145
142290
  var printer;
142146
142291
  var documentationFromAlias;
@@ -142553,6 +142698,18 @@ var ts;
142553
142698
  }
142554
142699
  }
142555
142700
  }
142701
+ if (documentation.length === 0 && ts.isIdentifier(location) && symbol.valueDeclaration && ts.isBindingElement(symbol.valueDeclaration)) {
142702
+ var declaration = symbol.valueDeclaration;
142703
+ var parent = declaration.parent;
142704
+ if (ts.isIdentifier(declaration.name) && ts.isObjectBindingPattern(parent)) {
142705
+ var name_4 = ts.getTextOfIdentifierOrLiteral(declaration.name);
142706
+ var objectType = typeChecker.getTypeAtLocation(parent);
142707
+ documentation = ts.firstDefined(objectType.isUnion() ? objectType.types : [objectType], function (t) {
142708
+ var prop = t.getProperty(name_4);
142709
+ return prop ? prop.getDocumentationComment(typeChecker) : undefined;
142710
+ }) || ts.emptyArray;
142711
+ }
142712
+ }
142556
142713
  if (tags.length === 0 && !hasMultipleSignatures) {
142557
142714
  tags = symbol.getContextualJsDocTags(enclosingDeclaration, typeChecker);
142558
142715
  }
@@ -159545,7 +159702,7 @@ var ts;
159545
159702
  var convertParamsToDestructuredObject;
159546
159703
  (function (convertParamsToDestructuredObject) {
159547
159704
  var refactorName = "Convert parameters to destructured object";
159548
- var minimumParameterLength = 2;
159705
+ var minimumParameterLength = 1;
159549
159706
  var refactorDescription = ts.getLocaleSpecificMessage(ts.Diagnostics.Convert_parameters_to_destructured_object);
159550
159707
  var toDestructuredAction = {
159551
159708
  name: refactorName,