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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20220201";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220205";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -1274,11 +1274,11 @@ var ts;
1274
1274
  return result;
1275
1275
  }
1276
1276
  ts.getAllKeys = getAllKeys;
1277
- function getOwnValues(sparseArray) {
1277
+ function getOwnValues(collection) {
1278
1278
  var values = [];
1279
- for (var key in sparseArray) {
1280
- if (hasOwnProperty.call(sparseArray, key)) {
1281
- values.push(sparseArray[key]);
1279
+ for (var key in collection) {
1280
+ if (hasOwnProperty.call(collection, key)) {
1281
+ values.push(collection[key]);
1282
1282
  }
1283
1283
  }
1284
1284
  return values;
@@ -5724,704 +5724,6 @@ var ts;
5724
5724
  },
5725
5725
  };
5726
5726
  })(ts || (ts = {}));
5727
- /* @internal */
5728
- var ts;
5729
- (function (ts) {
5730
- /**
5731
- * Internally, we represent paths as strings with '/' as the directory separator.
5732
- * When we make system calls (eg: LanguageServiceHost.getDirectory()),
5733
- * we expect the host to correctly handle paths in our specified format.
5734
- */
5735
- ts.directorySeparator = "/";
5736
- ts.altDirectorySeparator = "\\";
5737
- var urlSchemeSeparator = "://";
5738
- var backslashRegExp = /\\/g;
5739
- //// Path Tests
5740
- /**
5741
- * Determines whether a charCode corresponds to `/` or `\`.
5742
- */
5743
- function isAnyDirectorySeparator(charCode) {
5744
- return charCode === 47 /* slash */ || charCode === 92 /* backslash */;
5745
- }
5746
- ts.isAnyDirectorySeparator = isAnyDirectorySeparator;
5747
- /**
5748
- * Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.).
5749
- */
5750
- function isUrl(path) {
5751
- return getEncodedRootLength(path) < 0;
5752
- }
5753
- ts.isUrl = isUrl;
5754
- /**
5755
- * Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path
5756
- * like `c:`, `c:\` or `c:/`).
5757
- */
5758
- function isRootedDiskPath(path) {
5759
- return getEncodedRootLength(path) > 0;
5760
- }
5761
- ts.isRootedDiskPath = isRootedDiskPath;
5762
- /**
5763
- * Determines whether a path consists only of a path root.
5764
- */
5765
- function isDiskPathRoot(path) {
5766
- var rootLength = getEncodedRootLength(path);
5767
- return rootLength > 0 && rootLength === path.length;
5768
- }
5769
- ts.isDiskPathRoot = isDiskPathRoot;
5770
- /**
5771
- * Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.).
5772
- *
5773
- * ```ts
5774
- * // POSIX
5775
- * pathIsAbsolute("/path/to/file.ext") === true
5776
- * // DOS
5777
- * pathIsAbsolute("c:/path/to/file.ext") === true
5778
- * // URL
5779
- * pathIsAbsolute("file:///path/to/file.ext") === true
5780
- * // Non-absolute
5781
- * pathIsAbsolute("path/to/file.ext") === false
5782
- * pathIsAbsolute("./path/to/file.ext") === false
5783
- * ```
5784
- */
5785
- function pathIsAbsolute(path) {
5786
- return getEncodedRootLength(path) !== 0;
5787
- }
5788
- ts.pathIsAbsolute = pathIsAbsolute;
5789
- /**
5790
- * Determines whether a path starts with a relative path component (i.e. `.` or `..`).
5791
- */
5792
- function pathIsRelative(path) {
5793
- return /^\.\.?($|[\\/])/.test(path);
5794
- }
5795
- ts.pathIsRelative = pathIsRelative;
5796
- /**
5797
- * Determines whether a path is neither relative nor absolute, e.g. "path/to/file".
5798
- * Also known misleadingly as "non-relative".
5799
- */
5800
- function pathIsBareSpecifier(path) {
5801
- return !pathIsAbsolute(path) && !pathIsRelative(path);
5802
- }
5803
- ts.pathIsBareSpecifier = pathIsBareSpecifier;
5804
- function hasExtension(fileName) {
5805
- return ts.stringContains(getBaseFileName(fileName), ".");
5806
- }
5807
- ts.hasExtension = hasExtension;
5808
- function fileExtensionIs(path, extension) {
5809
- return path.length > extension.length && ts.endsWith(path, extension);
5810
- }
5811
- ts.fileExtensionIs = fileExtensionIs;
5812
- function fileExtensionIsOneOf(path, extensions) {
5813
- for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
5814
- var extension = extensions_1[_i];
5815
- if (fileExtensionIs(path, extension)) {
5816
- return true;
5817
- }
5818
- }
5819
- return false;
5820
- }
5821
- ts.fileExtensionIsOneOf = fileExtensionIsOneOf;
5822
- /**
5823
- * Determines whether a path has a trailing separator (`/` or `\\`).
5824
- */
5825
- function hasTrailingDirectorySeparator(path) {
5826
- return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1));
5827
- }
5828
- ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator;
5829
- //// Path Parsing
5830
- function isVolumeCharacter(charCode) {
5831
- return (charCode >= 97 /* a */ && charCode <= 122 /* z */) ||
5832
- (charCode >= 65 /* A */ && charCode <= 90 /* Z */);
5833
- }
5834
- function getFileUrlVolumeSeparatorEnd(url, start) {
5835
- var ch0 = url.charCodeAt(start);
5836
- if (ch0 === 58 /* colon */)
5837
- return start + 1;
5838
- if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) {
5839
- var ch2 = url.charCodeAt(start + 2);
5840
- if (ch2 === 97 /* a */ || ch2 === 65 /* A */)
5841
- return start + 3;
5842
- }
5843
- return -1;
5844
- }
5845
- /**
5846
- * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
5847
- * If the root is part of a URL, the twos-complement of the root length is returned.
5848
- */
5849
- function getEncodedRootLength(path) {
5850
- if (!path)
5851
- return 0;
5852
- var ch0 = path.charCodeAt(0);
5853
- // POSIX or UNC
5854
- if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) {
5855
- if (path.charCodeAt(1) !== ch0)
5856
- return 1; // POSIX: "/" (or non-normalized "\")
5857
- var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2);
5858
- if (p1 < 0)
5859
- return path.length; // UNC: "//server" or "\\server"
5860
- return p1 + 1; // UNC: "//server/" or "\\server\"
5861
- }
5862
- // DOS
5863
- if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) {
5864
- var ch2 = path.charCodeAt(2);
5865
- if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */)
5866
- return 3; // DOS: "c:/" or "c:\"
5867
- if (path.length === 2)
5868
- return 2; // DOS: "c:" (but not "c:d")
5869
- }
5870
- // URL
5871
- var schemeEnd = path.indexOf(urlSchemeSeparator);
5872
- if (schemeEnd !== -1) {
5873
- var authorityStart = schemeEnd + urlSchemeSeparator.length;
5874
- var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart);
5875
- if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path"
5876
- // For local "file" URLs, include the leading DOS volume (if present).
5877
- // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a
5878
- // special case interpreted as "the machine from which the URL is being interpreted".
5879
- var scheme = path.slice(0, schemeEnd);
5880
- var authority = path.slice(authorityStart, authorityEnd);
5881
- if (scheme === "file" && (authority === "" || authority === "localhost") &&
5882
- isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
5883
- var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
5884
- if (volumeSeparatorEnd !== -1) {
5885
- if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) {
5886
- // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/"
5887
- return ~(volumeSeparatorEnd + 1);
5888
- }
5889
- if (volumeSeparatorEnd === path.length) {
5890
- // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a"
5891
- // but not "file:///c:d" or "file:///c%3ad"
5892
- return ~volumeSeparatorEnd;
5893
- }
5894
- }
5895
- }
5896
- return ~(authorityEnd + 1); // URL: "file://server/", "http://server/"
5897
- }
5898
- return ~path.length; // URL: "file://server", "http://server"
5899
- }
5900
- // relative
5901
- return 0;
5902
- }
5903
- /**
5904
- * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
5905
- *
5906
- * For example:
5907
- * ```ts
5908
- * getRootLength("a") === 0 // ""
5909
- * getRootLength("/") === 1 // "/"
5910
- * getRootLength("c:") === 2 // "c:"
5911
- * getRootLength("c:d") === 0 // ""
5912
- * getRootLength("c:/") === 3 // "c:/"
5913
- * getRootLength("c:\\") === 3 // "c:\\"
5914
- * getRootLength("//server") === 7 // "//server"
5915
- * getRootLength("//server/share") === 8 // "//server/"
5916
- * getRootLength("\\\\server") === 7 // "\\\\server"
5917
- * getRootLength("\\\\server\\share") === 8 // "\\\\server\\"
5918
- * getRootLength("file:///path") === 8 // "file:///"
5919
- * getRootLength("file:///c:") === 10 // "file:///c:"
5920
- * getRootLength("file:///c:d") === 8 // "file:///"
5921
- * getRootLength("file:///c:/path") === 11 // "file:///c:/"
5922
- * getRootLength("file://server") === 13 // "file://server"
5923
- * getRootLength("file://server/path") === 14 // "file://server/"
5924
- * getRootLength("http://server") === 13 // "http://server"
5925
- * getRootLength("http://server/path") === 14 // "http://server/"
5926
- * ```
5927
- */
5928
- function getRootLength(path) {
5929
- var rootLength = getEncodedRootLength(path);
5930
- return rootLength < 0 ? ~rootLength : rootLength;
5931
- }
5932
- ts.getRootLength = getRootLength;
5933
- function getDirectoryPath(path) {
5934
- path = normalizeSlashes(path);
5935
- // If the path provided is itself the root, then return it.
5936
- var rootLength = getRootLength(path);
5937
- if (rootLength === path.length)
5938
- return path;
5939
- // return the leading portion of the path up to the last (non-terminal) directory separator
5940
- // but not including any trailing directory separator.
5941
- path = removeTrailingDirectorySeparator(path);
5942
- return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator)));
5943
- }
5944
- ts.getDirectoryPath = getDirectoryPath;
5945
- function getBaseFileName(path, extensions, ignoreCase) {
5946
- path = normalizeSlashes(path);
5947
- // if the path provided is itself the root, then it has not file name.
5948
- var rootLength = getRootLength(path);
5949
- if (rootLength === path.length)
5950
- return "";
5951
- // return the trailing portion of the path starting after the last (non-terminal) directory
5952
- // separator but not including any trailing directory separator.
5953
- path = removeTrailingDirectorySeparator(path);
5954
- var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1));
5955
- var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined;
5956
- return extension ? name.slice(0, name.length - extension.length) : name;
5957
- }
5958
- ts.getBaseFileName = getBaseFileName;
5959
- function tryGetExtensionFromPath(path, extension, stringEqualityComparer) {
5960
- if (!ts.startsWith(extension, "."))
5961
- extension = "." + extension;
5962
- if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) {
5963
- var pathExtension = path.slice(path.length - extension.length);
5964
- if (stringEqualityComparer(pathExtension, extension)) {
5965
- return pathExtension;
5966
- }
5967
- }
5968
- }
5969
- function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) {
5970
- if (typeof extensions === "string") {
5971
- return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || "";
5972
- }
5973
- for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) {
5974
- var extension = extensions_2[_i];
5975
- var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer);
5976
- if (result)
5977
- return result;
5978
- }
5979
- return "";
5980
- }
5981
- function getAnyExtensionFromPath(path, extensions, ignoreCase) {
5982
- // Retrieves any string from the final "." onwards from a base file name.
5983
- // Unlike extensionFromPath, which throws an exception on unrecognized extensions.
5984
- if (extensions) {
5985
- return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive);
5986
- }
5987
- var baseFileName = getBaseFileName(path);
5988
- var extensionIndex = baseFileName.lastIndexOf(".");
5989
- if (extensionIndex >= 0) {
5990
- return baseFileName.substring(extensionIndex);
5991
- }
5992
- return "";
5993
- }
5994
- ts.getAnyExtensionFromPath = getAnyExtensionFromPath;
5995
- function pathComponents(path, rootLength) {
5996
- var root = path.substring(0, rootLength);
5997
- var rest = path.substring(rootLength).split(ts.directorySeparator);
5998
- if (rest.length && !ts.lastOrUndefined(rest))
5999
- rest.pop();
6000
- return __spreadArray([root], rest, true);
6001
- }
6002
- /**
6003
- * Parse a path into an array containing a root component (at index 0) and zero or more path
6004
- * components (at indices > 0). The result is not normalized.
6005
- * If the path is relative, the root component is `""`.
6006
- * If the path is absolute, the root component includes the first path separator (`/`).
6007
- *
6008
- * ```ts
6009
- * // POSIX
6010
- * getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"]
6011
- * getPathComponents("/path/to/") === ["/", "path", "to"]
6012
- * getPathComponents("/") === ["/"]
6013
- * // DOS
6014
- * getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"]
6015
- * getPathComponents("c:/path/to/") === ["c:/", "path", "to"]
6016
- * getPathComponents("c:/") === ["c:/"]
6017
- * getPathComponents("c:") === ["c:"]
6018
- * // URL
6019
- * getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"]
6020
- * getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"]
6021
- * getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"]
6022
- * getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"]
6023
- * getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"]
6024
- * getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"]
6025
- * getPathComponents("file://server/") === ["file://server/"]
6026
- * getPathComponents("file://server") === ["file://server"]
6027
- * getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"]
6028
- * getPathComponents("file:///path/to/") === ["file:///", "path", "to"]
6029
- * getPathComponents("file:///") === ["file:///"]
6030
- * getPathComponents("file://") === ["file://"]
6031
- */
6032
- function getPathComponents(path, currentDirectory) {
6033
- if (currentDirectory === void 0) { currentDirectory = ""; }
6034
- path = combinePaths(currentDirectory, path);
6035
- return pathComponents(path, getRootLength(path));
6036
- }
6037
- ts.getPathComponents = getPathComponents;
6038
- //// Path Formatting
6039
- /**
6040
- * Formats a parsed path consisting of a root component (at index 0) and zero or more path
6041
- * segments (at indices > 0).
6042
- *
6043
- * ```ts
6044
- * getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext"
6045
- * ```
6046
- */
6047
- function getPathFromPathComponents(pathComponents) {
6048
- if (pathComponents.length === 0)
6049
- return "";
6050
- var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
6051
- return root + pathComponents.slice(1).join(ts.directorySeparator);
6052
- }
6053
- ts.getPathFromPathComponents = getPathFromPathComponents;
6054
- //// Path Normalization
6055
- /**
6056
- * Normalize path separators, converting `\` into `/`.
6057
- */
6058
- function normalizeSlashes(path) {
6059
- var index = path.indexOf("\\");
6060
- if (index === -1) {
6061
- return path;
6062
- }
6063
- backslashRegExp.lastIndex = index; // prime regex with known position
6064
- return path.replace(backslashRegExp, ts.directorySeparator);
6065
- }
6066
- ts.normalizeSlashes = normalizeSlashes;
6067
- /**
6068
- * Reduce an array of path components to a more simplified path by navigating any
6069
- * `"."` or `".."` entries in the path.
6070
- */
6071
- function reducePathComponents(components) {
6072
- if (!ts.some(components))
6073
- return [];
6074
- var reduced = [components[0]];
6075
- for (var i = 1; i < components.length; i++) {
6076
- var component = components[i];
6077
- if (!component)
6078
- continue;
6079
- if (component === ".")
6080
- continue;
6081
- if (component === "..") {
6082
- if (reduced.length > 1) {
6083
- if (reduced[reduced.length - 1] !== "..") {
6084
- reduced.pop();
6085
- continue;
6086
- }
6087
- }
6088
- else if (reduced[0])
6089
- continue;
6090
- }
6091
- reduced.push(component);
6092
- }
6093
- return reduced;
6094
- }
6095
- ts.reducePathComponents = reducePathComponents;
6096
- /**
6097
- * Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified.
6098
- *
6099
- * ```ts
6100
- * // Non-rooted
6101
- * combinePaths("path", "to", "file.ext") === "path/to/file.ext"
6102
- * combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext"
6103
- * // POSIX
6104
- * combinePaths("/path", "to", "file.ext") === "/path/to/file.ext"
6105
- * combinePaths("/path", "/to", "file.ext") === "/to/file.ext"
6106
- * // DOS
6107
- * combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext"
6108
- * combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext"
6109
- * // URL
6110
- * combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext"
6111
- * combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext"
6112
- * ```
6113
- */
6114
- function combinePaths(path) {
6115
- var paths = [];
6116
- for (var _i = 1; _i < arguments.length; _i++) {
6117
- paths[_i - 1] = arguments[_i];
6118
- }
6119
- if (path)
6120
- path = normalizeSlashes(path);
6121
- for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
6122
- var relativePath = paths_1[_a];
6123
- if (!relativePath)
6124
- continue;
6125
- relativePath = normalizeSlashes(relativePath);
6126
- if (!path || getRootLength(relativePath) !== 0) {
6127
- path = relativePath;
6128
- }
6129
- else {
6130
- path = ensureTrailingDirectorySeparator(path) + relativePath;
6131
- }
6132
- }
6133
- return path;
6134
- }
6135
- ts.combinePaths = combinePaths;
6136
- /**
6137
- * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any
6138
- * `.` and `..` path components are resolved. Trailing directory separators are preserved.
6139
- *
6140
- * ```ts
6141
- * resolvePath("/path", "to", "file.ext") === "path/to/file.ext"
6142
- * resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/"
6143
- * resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext"
6144
- * ```
6145
- */
6146
- function resolvePath(path) {
6147
- var paths = [];
6148
- for (var _i = 1; _i < arguments.length; _i++) {
6149
- paths[_i - 1] = arguments[_i];
6150
- }
6151
- return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArray([path], paths, false)) : normalizeSlashes(path));
6152
- }
6153
- ts.resolvePath = resolvePath;
6154
- /**
6155
- * Parse a path into an array containing a root component (at index 0) and zero or more path
6156
- * components (at indices > 0). The result is normalized.
6157
- * If the path is relative, the root component is `""`.
6158
- * If the path is absolute, the root component includes the first path separator (`/`).
6159
- *
6160
- * ```ts
6161
- * getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"]
6162
- * ```
6163
- */
6164
- function getNormalizedPathComponents(path, currentDirectory) {
6165
- return reducePathComponents(getPathComponents(path, currentDirectory));
6166
- }
6167
- ts.getNormalizedPathComponents = getNormalizedPathComponents;
6168
- function getNormalizedAbsolutePath(fileName, currentDirectory) {
6169
- return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
6170
- }
6171
- ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
6172
- function normalizePath(path) {
6173
- path = normalizeSlashes(path);
6174
- // Most paths don't require normalization
6175
- if (!relativePathSegmentRegExp.test(path)) {
6176
- return path;
6177
- }
6178
- // Some paths only require cleanup of `/./` or leading `./`
6179
- var simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, "");
6180
- if (simplified !== path) {
6181
- path = simplified;
6182
- if (!relativePathSegmentRegExp.test(path)) {
6183
- return path;
6184
- }
6185
- }
6186
- // Other paths require full normalization
6187
- var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
6188
- return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
6189
- }
6190
- ts.normalizePath = normalizePath;
6191
- function getPathWithoutRoot(pathComponents) {
6192
- if (pathComponents.length === 0)
6193
- return "";
6194
- return pathComponents.slice(1).join(ts.directorySeparator);
6195
- }
6196
- function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
6197
- return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
6198
- }
6199
- ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
6200
- function toPath(fileName, basePath, getCanonicalFileName) {
6201
- var nonCanonicalizedPath = isRootedDiskPath(fileName)
6202
- ? normalizePath(fileName)
6203
- : getNormalizedAbsolutePath(fileName, basePath);
6204
- return getCanonicalFileName(nonCanonicalizedPath);
6205
- }
6206
- ts.toPath = toPath;
6207
- function normalizePathAndParts(path) {
6208
- path = normalizeSlashes(path);
6209
- var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
6210
- if (parts.length) {
6211
- var joinedParts = root + parts.join(ts.directorySeparator);
6212
- return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
6213
- }
6214
- else {
6215
- return { path: root, parts: parts };
6216
- }
6217
- }
6218
- ts.normalizePathAndParts = normalizePathAndParts;
6219
- function removeTrailingDirectorySeparator(path) {
6220
- if (hasTrailingDirectorySeparator(path)) {
6221
- return path.substr(0, path.length - 1);
6222
- }
6223
- return path;
6224
- }
6225
- ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
6226
- function ensureTrailingDirectorySeparator(path) {
6227
- if (!hasTrailingDirectorySeparator(path)) {
6228
- return path + ts.directorySeparator;
6229
- }
6230
- return path;
6231
- }
6232
- ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator;
6233
- /**
6234
- * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed
6235
- * with `./` or `../`) so as not to be confused with an unprefixed module name.
6236
- *
6237
- * ```ts
6238
- * ensurePathIsNonModuleName("/path/to/file.ext") === "/path/to/file.ext"
6239
- * ensurePathIsNonModuleName("./path/to/file.ext") === "./path/to/file.ext"
6240
- * ensurePathIsNonModuleName("../path/to/file.ext") === "../path/to/file.ext"
6241
- * ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext"
6242
- * ```
6243
- */
6244
- function ensurePathIsNonModuleName(path) {
6245
- return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path;
6246
- }
6247
- ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName;
6248
- function changeAnyExtension(path, ext, extensions, ignoreCase) {
6249
- var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path);
6250
- return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
6251
- }
6252
- ts.changeAnyExtension = changeAnyExtension;
6253
- //// Path Comparisons
6254
- // check path for these segments: '', '.'. '..'
6255
- var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/;
6256
- function comparePathsWorker(a, b, componentComparer) {
6257
- if (a === b)
6258
- return 0 /* EqualTo */;
6259
- if (a === undefined)
6260
- return -1 /* LessThan */;
6261
- if (b === undefined)
6262
- return 1 /* GreaterThan */;
6263
- // NOTE: Performance optimization - shortcut if the root segments differ as there would be no
6264
- // need to perform path reduction.
6265
- var aRoot = a.substring(0, getRootLength(a));
6266
- var bRoot = b.substring(0, getRootLength(b));
6267
- var result = ts.compareStringsCaseInsensitive(aRoot, bRoot);
6268
- if (result !== 0 /* EqualTo */) {
6269
- return result;
6270
- }
6271
- // NOTE: Performance optimization - shortcut if there are no relative path segments in
6272
- // the non-root portion of the path
6273
- var aRest = a.substring(aRoot.length);
6274
- var bRest = b.substring(bRoot.length);
6275
- if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) {
6276
- return componentComparer(aRest, bRest);
6277
- }
6278
- // The path contains a relative path segment. Normalize the paths and perform a slower component
6279
- // by component comparison.
6280
- var aComponents = reducePathComponents(getPathComponents(a));
6281
- var bComponents = reducePathComponents(getPathComponents(b));
6282
- var sharedLength = Math.min(aComponents.length, bComponents.length);
6283
- for (var i = 1; i < sharedLength; i++) {
6284
- var result_2 = componentComparer(aComponents[i], bComponents[i]);
6285
- if (result_2 !== 0 /* EqualTo */) {
6286
- return result_2;
6287
- }
6288
- }
6289
- return ts.compareValues(aComponents.length, bComponents.length);
6290
- }
6291
- /**
6292
- * Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively.
6293
- */
6294
- function comparePathsCaseSensitive(a, b) {
6295
- return comparePathsWorker(a, b, ts.compareStringsCaseSensitive);
6296
- }
6297
- ts.comparePathsCaseSensitive = comparePathsCaseSensitive;
6298
- /**
6299
- * Performs a case-insensitive comparison of two paths.
6300
- */
6301
- function comparePathsCaseInsensitive(a, b) {
6302
- return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive);
6303
- }
6304
- ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive;
6305
- function comparePaths(a, b, currentDirectory, ignoreCase) {
6306
- if (typeof currentDirectory === "string") {
6307
- a = combinePaths(currentDirectory, a);
6308
- b = combinePaths(currentDirectory, b);
6309
- }
6310
- else if (typeof currentDirectory === "boolean") {
6311
- ignoreCase = currentDirectory;
6312
- }
6313
- return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase));
6314
- }
6315
- ts.comparePaths = comparePaths;
6316
- function containsPath(parent, child, currentDirectory, ignoreCase) {
6317
- if (typeof currentDirectory === "string") {
6318
- parent = combinePaths(currentDirectory, parent);
6319
- child = combinePaths(currentDirectory, child);
6320
- }
6321
- else if (typeof currentDirectory === "boolean") {
6322
- ignoreCase = currentDirectory;
6323
- }
6324
- if (parent === undefined || child === undefined)
6325
- return false;
6326
- if (parent === child)
6327
- return true;
6328
- var parentComponents = reducePathComponents(getPathComponents(parent));
6329
- var childComponents = reducePathComponents(getPathComponents(child));
6330
- if (childComponents.length < parentComponents.length) {
6331
- return false;
6332
- }
6333
- var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive;
6334
- for (var i = 0; i < parentComponents.length; i++) {
6335
- var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer;
6336
- if (!equalityComparer(parentComponents[i], childComponents[i])) {
6337
- return false;
6338
- }
6339
- }
6340
- return true;
6341
- }
6342
- ts.containsPath = containsPath;
6343
- /**
6344
- * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback.
6345
- * Comparison is case-sensitive between the canonical paths.
6346
- *
6347
- * Use `containsPath` if file names are not already reduced and absolute.
6348
- */
6349
- function startsWithDirectory(fileName, directoryName, getCanonicalFileName) {
6350
- var canonicalFileName = getCanonicalFileName(fileName);
6351
- var canonicalDirectoryName = getCanonicalFileName(directoryName);
6352
- return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\");
6353
- }
6354
- ts.startsWithDirectory = startsWithDirectory;
6355
- //// Relative Paths
6356
- function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) {
6357
- var fromComponents = reducePathComponents(getPathComponents(from));
6358
- var toComponents = reducePathComponents(getPathComponents(to));
6359
- var start;
6360
- for (start = 0; start < fromComponents.length && start < toComponents.length; start++) {
6361
- var fromComponent = getCanonicalFileName(fromComponents[start]);
6362
- var toComponent = getCanonicalFileName(toComponents[start]);
6363
- var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer;
6364
- if (!comparer(fromComponent, toComponent))
6365
- break;
6366
- }
6367
- if (start === 0) {
6368
- return toComponents;
6369
- }
6370
- var components = toComponents.slice(start);
6371
- var relative = [];
6372
- for (; start < fromComponents.length; start++) {
6373
- relative.push("..");
6374
- }
6375
- return __spreadArray(__spreadArray([""], relative, true), components, true);
6376
- }
6377
- ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo;
6378
- function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
6379
- ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
6380
- var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
6381
- var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
6382
- var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
6383
- return getPathFromPathComponents(pathComponents);
6384
- }
6385
- ts.getRelativePathFromDirectory = getRelativePathFromDirectory;
6386
- function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
6387
- return !isRootedDiskPath(absoluteOrRelativePath)
6388
- ? absoluteOrRelativePath
6389
- : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
6390
- }
6391
- ts.convertToRelativePath = convertToRelativePath;
6392
- function getRelativePathFromFile(from, to, getCanonicalFileName) {
6393
- return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName));
6394
- }
6395
- ts.getRelativePathFromFile = getRelativePathFromFile;
6396
- function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
6397
- var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName);
6398
- var firstComponent = pathComponents[0];
6399
- if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) {
6400
- var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///";
6401
- pathComponents[0] = prefix + firstComponent;
6402
- }
6403
- return getPathFromPathComponents(pathComponents);
6404
- }
6405
- ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl;
6406
- function forEachAncestorDirectory(directory, callback) {
6407
- while (true) {
6408
- var result = callback(directory);
6409
- if (result !== undefined) {
6410
- return result;
6411
- }
6412
- var parentPath = getDirectoryPath(directory);
6413
- if (parentPath === directory) {
6414
- return undefined;
6415
- }
6416
- directory = parentPath;
6417
- }
6418
- }
6419
- ts.forEachAncestorDirectory = forEachAncestorDirectory;
6420
- function isNodeModulesDirectory(dirPath) {
6421
- return ts.endsWith(dirPath, "/node_modules");
6422
- }
6423
- ts.isNodeModulesDirectory = isNodeModulesDirectory;
6424
- })(ts || (ts = {}));
6425
5727
  var ts;
6426
5728
  (function (ts) {
6427
5729
  /**
@@ -7854,6 +7156,704 @@ var ts;
7854
7156
  ts.Debug.isDebugging = true;
7855
7157
  }
7856
7158
  })(ts || (ts = {}));
7159
+ /* @internal */
7160
+ var ts;
7161
+ (function (ts) {
7162
+ /**
7163
+ * Internally, we represent paths as strings with '/' as the directory separator.
7164
+ * When we make system calls (eg: LanguageServiceHost.getDirectory()),
7165
+ * we expect the host to correctly handle paths in our specified format.
7166
+ */
7167
+ ts.directorySeparator = "/";
7168
+ ts.altDirectorySeparator = "\\";
7169
+ var urlSchemeSeparator = "://";
7170
+ var backslashRegExp = /\\/g;
7171
+ //// Path Tests
7172
+ /**
7173
+ * Determines whether a charCode corresponds to `/` or `\`.
7174
+ */
7175
+ function isAnyDirectorySeparator(charCode) {
7176
+ return charCode === 47 /* slash */ || charCode === 92 /* backslash */;
7177
+ }
7178
+ ts.isAnyDirectorySeparator = isAnyDirectorySeparator;
7179
+ /**
7180
+ * Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.).
7181
+ */
7182
+ function isUrl(path) {
7183
+ return getEncodedRootLength(path) < 0;
7184
+ }
7185
+ ts.isUrl = isUrl;
7186
+ /**
7187
+ * Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path
7188
+ * like `c:`, `c:\` or `c:/`).
7189
+ */
7190
+ function isRootedDiskPath(path) {
7191
+ return getEncodedRootLength(path) > 0;
7192
+ }
7193
+ ts.isRootedDiskPath = isRootedDiskPath;
7194
+ /**
7195
+ * Determines whether a path consists only of a path root.
7196
+ */
7197
+ function isDiskPathRoot(path) {
7198
+ var rootLength = getEncodedRootLength(path);
7199
+ return rootLength > 0 && rootLength === path.length;
7200
+ }
7201
+ ts.isDiskPathRoot = isDiskPathRoot;
7202
+ /**
7203
+ * Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.).
7204
+ *
7205
+ * ```ts
7206
+ * // POSIX
7207
+ * pathIsAbsolute("/path/to/file.ext") === true
7208
+ * // DOS
7209
+ * pathIsAbsolute("c:/path/to/file.ext") === true
7210
+ * // URL
7211
+ * pathIsAbsolute("file:///path/to/file.ext") === true
7212
+ * // Non-absolute
7213
+ * pathIsAbsolute("path/to/file.ext") === false
7214
+ * pathIsAbsolute("./path/to/file.ext") === false
7215
+ * ```
7216
+ */
7217
+ function pathIsAbsolute(path) {
7218
+ return getEncodedRootLength(path) !== 0;
7219
+ }
7220
+ ts.pathIsAbsolute = pathIsAbsolute;
7221
+ /**
7222
+ * Determines whether a path starts with a relative path component (i.e. `.` or `..`).
7223
+ */
7224
+ function pathIsRelative(path) {
7225
+ return /^\.\.?($|[\\/])/.test(path);
7226
+ }
7227
+ ts.pathIsRelative = pathIsRelative;
7228
+ /**
7229
+ * Determines whether a path is neither relative nor absolute, e.g. "path/to/file".
7230
+ * Also known misleadingly as "non-relative".
7231
+ */
7232
+ function pathIsBareSpecifier(path) {
7233
+ return !pathIsAbsolute(path) && !pathIsRelative(path);
7234
+ }
7235
+ ts.pathIsBareSpecifier = pathIsBareSpecifier;
7236
+ function hasExtension(fileName) {
7237
+ return ts.stringContains(getBaseFileName(fileName), ".");
7238
+ }
7239
+ ts.hasExtension = hasExtension;
7240
+ function fileExtensionIs(path, extension) {
7241
+ return path.length > extension.length && ts.endsWith(path, extension);
7242
+ }
7243
+ ts.fileExtensionIs = fileExtensionIs;
7244
+ function fileExtensionIsOneOf(path, extensions) {
7245
+ for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
7246
+ var extension = extensions_1[_i];
7247
+ if (fileExtensionIs(path, extension)) {
7248
+ return true;
7249
+ }
7250
+ }
7251
+ return false;
7252
+ }
7253
+ ts.fileExtensionIsOneOf = fileExtensionIsOneOf;
7254
+ /**
7255
+ * Determines whether a path has a trailing separator (`/` or `\\`).
7256
+ */
7257
+ function hasTrailingDirectorySeparator(path) {
7258
+ return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1));
7259
+ }
7260
+ ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator;
7261
+ //// Path Parsing
7262
+ function isVolumeCharacter(charCode) {
7263
+ return (charCode >= 97 /* a */ && charCode <= 122 /* z */) ||
7264
+ (charCode >= 65 /* A */ && charCode <= 90 /* Z */);
7265
+ }
7266
+ function getFileUrlVolumeSeparatorEnd(url, start) {
7267
+ var ch0 = url.charCodeAt(start);
7268
+ if (ch0 === 58 /* colon */)
7269
+ return start + 1;
7270
+ if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) {
7271
+ var ch2 = url.charCodeAt(start + 2);
7272
+ if (ch2 === 97 /* a */ || ch2 === 65 /* A */)
7273
+ return start + 3;
7274
+ }
7275
+ return -1;
7276
+ }
7277
+ /**
7278
+ * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
7279
+ * If the root is part of a URL, the twos-complement of the root length is returned.
7280
+ */
7281
+ function getEncodedRootLength(path) {
7282
+ if (!path)
7283
+ return 0;
7284
+ var ch0 = path.charCodeAt(0);
7285
+ // POSIX or UNC
7286
+ if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) {
7287
+ if (path.charCodeAt(1) !== ch0)
7288
+ return 1; // POSIX: "/" (or non-normalized "\")
7289
+ var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2);
7290
+ if (p1 < 0)
7291
+ return path.length; // UNC: "//server" or "\\server"
7292
+ return p1 + 1; // UNC: "//server/" or "\\server\"
7293
+ }
7294
+ // DOS
7295
+ if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) {
7296
+ var ch2 = path.charCodeAt(2);
7297
+ if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */)
7298
+ return 3; // DOS: "c:/" or "c:\"
7299
+ if (path.length === 2)
7300
+ return 2; // DOS: "c:" (but not "c:d")
7301
+ }
7302
+ // URL
7303
+ var schemeEnd = path.indexOf(urlSchemeSeparator);
7304
+ if (schemeEnd !== -1) {
7305
+ var authorityStart = schemeEnd + urlSchemeSeparator.length;
7306
+ var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart);
7307
+ if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path"
7308
+ // For local "file" URLs, include the leading DOS volume (if present).
7309
+ // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a
7310
+ // special case interpreted as "the machine from which the URL is being interpreted".
7311
+ var scheme = path.slice(0, schemeEnd);
7312
+ var authority = path.slice(authorityStart, authorityEnd);
7313
+ if (scheme === "file" && (authority === "" || authority === "localhost") &&
7314
+ isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
7315
+ var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
7316
+ if (volumeSeparatorEnd !== -1) {
7317
+ if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) {
7318
+ // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/"
7319
+ return ~(volumeSeparatorEnd + 1);
7320
+ }
7321
+ if (volumeSeparatorEnd === path.length) {
7322
+ // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a"
7323
+ // but not "file:///c:d" or "file:///c%3ad"
7324
+ return ~volumeSeparatorEnd;
7325
+ }
7326
+ }
7327
+ }
7328
+ return ~(authorityEnd + 1); // URL: "file://server/", "http://server/"
7329
+ }
7330
+ return ~path.length; // URL: "file://server", "http://server"
7331
+ }
7332
+ // relative
7333
+ return 0;
7334
+ }
7335
+ /**
7336
+ * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
7337
+ *
7338
+ * For example:
7339
+ * ```ts
7340
+ * getRootLength("a") === 0 // ""
7341
+ * getRootLength("/") === 1 // "/"
7342
+ * getRootLength("c:") === 2 // "c:"
7343
+ * getRootLength("c:d") === 0 // ""
7344
+ * getRootLength("c:/") === 3 // "c:/"
7345
+ * getRootLength("c:\\") === 3 // "c:\\"
7346
+ * getRootLength("//server") === 7 // "//server"
7347
+ * getRootLength("//server/share") === 8 // "//server/"
7348
+ * getRootLength("\\\\server") === 7 // "\\\\server"
7349
+ * getRootLength("\\\\server\\share") === 8 // "\\\\server\\"
7350
+ * getRootLength("file:///path") === 8 // "file:///"
7351
+ * getRootLength("file:///c:") === 10 // "file:///c:"
7352
+ * getRootLength("file:///c:d") === 8 // "file:///"
7353
+ * getRootLength("file:///c:/path") === 11 // "file:///c:/"
7354
+ * getRootLength("file://server") === 13 // "file://server"
7355
+ * getRootLength("file://server/path") === 14 // "file://server/"
7356
+ * getRootLength("http://server") === 13 // "http://server"
7357
+ * getRootLength("http://server/path") === 14 // "http://server/"
7358
+ * ```
7359
+ */
7360
+ function getRootLength(path) {
7361
+ var rootLength = getEncodedRootLength(path);
7362
+ return rootLength < 0 ? ~rootLength : rootLength;
7363
+ }
7364
+ ts.getRootLength = getRootLength;
7365
+ function getDirectoryPath(path) {
7366
+ path = normalizeSlashes(path);
7367
+ // If the path provided is itself the root, then return it.
7368
+ var rootLength = getRootLength(path);
7369
+ if (rootLength === path.length)
7370
+ return path;
7371
+ // return the leading portion of the path up to the last (non-terminal) directory separator
7372
+ // but not including any trailing directory separator.
7373
+ path = removeTrailingDirectorySeparator(path);
7374
+ return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator)));
7375
+ }
7376
+ ts.getDirectoryPath = getDirectoryPath;
7377
+ function getBaseFileName(path, extensions, ignoreCase) {
7378
+ path = normalizeSlashes(path);
7379
+ // if the path provided is itself the root, then it has not file name.
7380
+ var rootLength = getRootLength(path);
7381
+ if (rootLength === path.length)
7382
+ return "";
7383
+ // return the trailing portion of the path starting after the last (non-terminal) directory
7384
+ // separator but not including any trailing directory separator.
7385
+ path = removeTrailingDirectorySeparator(path);
7386
+ var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1));
7387
+ var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined;
7388
+ return extension ? name.slice(0, name.length - extension.length) : name;
7389
+ }
7390
+ ts.getBaseFileName = getBaseFileName;
7391
+ function tryGetExtensionFromPath(path, extension, stringEqualityComparer) {
7392
+ if (!ts.startsWith(extension, "."))
7393
+ extension = "." + extension;
7394
+ if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) {
7395
+ var pathExtension = path.slice(path.length - extension.length);
7396
+ if (stringEqualityComparer(pathExtension, extension)) {
7397
+ return pathExtension;
7398
+ }
7399
+ }
7400
+ }
7401
+ function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) {
7402
+ if (typeof extensions === "string") {
7403
+ return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || "";
7404
+ }
7405
+ for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) {
7406
+ var extension = extensions_2[_i];
7407
+ var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer);
7408
+ if (result)
7409
+ return result;
7410
+ }
7411
+ return "";
7412
+ }
7413
+ function getAnyExtensionFromPath(path, extensions, ignoreCase) {
7414
+ // Retrieves any string from the final "." onwards from a base file name.
7415
+ // Unlike extensionFromPath, which throws an exception on unrecognized extensions.
7416
+ if (extensions) {
7417
+ return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive);
7418
+ }
7419
+ var baseFileName = getBaseFileName(path);
7420
+ var extensionIndex = baseFileName.lastIndexOf(".");
7421
+ if (extensionIndex >= 0) {
7422
+ return baseFileName.substring(extensionIndex);
7423
+ }
7424
+ return "";
7425
+ }
7426
+ ts.getAnyExtensionFromPath = getAnyExtensionFromPath;
7427
+ function pathComponents(path, rootLength) {
7428
+ var root = path.substring(0, rootLength);
7429
+ var rest = path.substring(rootLength).split(ts.directorySeparator);
7430
+ if (rest.length && !ts.lastOrUndefined(rest))
7431
+ rest.pop();
7432
+ return __spreadArray([root], rest, true);
7433
+ }
7434
+ /**
7435
+ * Parse a path into an array containing a root component (at index 0) and zero or more path
7436
+ * components (at indices > 0). The result is not normalized.
7437
+ * If the path is relative, the root component is `""`.
7438
+ * If the path is absolute, the root component includes the first path separator (`/`).
7439
+ *
7440
+ * ```ts
7441
+ * // POSIX
7442
+ * getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"]
7443
+ * getPathComponents("/path/to/") === ["/", "path", "to"]
7444
+ * getPathComponents("/") === ["/"]
7445
+ * // DOS
7446
+ * getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"]
7447
+ * getPathComponents("c:/path/to/") === ["c:/", "path", "to"]
7448
+ * getPathComponents("c:/") === ["c:/"]
7449
+ * getPathComponents("c:") === ["c:"]
7450
+ * // URL
7451
+ * getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"]
7452
+ * getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"]
7453
+ * getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"]
7454
+ * getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"]
7455
+ * getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"]
7456
+ * getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"]
7457
+ * getPathComponents("file://server/") === ["file://server/"]
7458
+ * getPathComponents("file://server") === ["file://server"]
7459
+ * getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"]
7460
+ * getPathComponents("file:///path/to/") === ["file:///", "path", "to"]
7461
+ * getPathComponents("file:///") === ["file:///"]
7462
+ * getPathComponents("file://") === ["file://"]
7463
+ */
7464
+ function getPathComponents(path, currentDirectory) {
7465
+ if (currentDirectory === void 0) { currentDirectory = ""; }
7466
+ path = combinePaths(currentDirectory, path);
7467
+ return pathComponents(path, getRootLength(path));
7468
+ }
7469
+ ts.getPathComponents = getPathComponents;
7470
+ //// Path Formatting
7471
+ /**
7472
+ * Formats a parsed path consisting of a root component (at index 0) and zero or more path
7473
+ * segments (at indices > 0).
7474
+ *
7475
+ * ```ts
7476
+ * getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext"
7477
+ * ```
7478
+ */
7479
+ function getPathFromPathComponents(pathComponents) {
7480
+ if (pathComponents.length === 0)
7481
+ return "";
7482
+ var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
7483
+ return root + pathComponents.slice(1).join(ts.directorySeparator);
7484
+ }
7485
+ ts.getPathFromPathComponents = getPathFromPathComponents;
7486
+ //// Path Normalization
7487
+ /**
7488
+ * Normalize path separators, converting `\` into `/`.
7489
+ */
7490
+ function normalizeSlashes(path) {
7491
+ var index = path.indexOf("\\");
7492
+ if (index === -1) {
7493
+ return path;
7494
+ }
7495
+ backslashRegExp.lastIndex = index; // prime regex with known position
7496
+ return path.replace(backslashRegExp, ts.directorySeparator);
7497
+ }
7498
+ ts.normalizeSlashes = normalizeSlashes;
7499
+ /**
7500
+ * Reduce an array of path components to a more simplified path by navigating any
7501
+ * `"."` or `".."` entries in the path.
7502
+ */
7503
+ function reducePathComponents(components) {
7504
+ if (!ts.some(components))
7505
+ return [];
7506
+ var reduced = [components[0]];
7507
+ for (var i = 1; i < components.length; i++) {
7508
+ var component = components[i];
7509
+ if (!component)
7510
+ continue;
7511
+ if (component === ".")
7512
+ continue;
7513
+ if (component === "..") {
7514
+ if (reduced.length > 1) {
7515
+ if (reduced[reduced.length - 1] !== "..") {
7516
+ reduced.pop();
7517
+ continue;
7518
+ }
7519
+ }
7520
+ else if (reduced[0])
7521
+ continue;
7522
+ }
7523
+ reduced.push(component);
7524
+ }
7525
+ return reduced;
7526
+ }
7527
+ ts.reducePathComponents = reducePathComponents;
7528
+ /**
7529
+ * Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified.
7530
+ *
7531
+ * ```ts
7532
+ * // Non-rooted
7533
+ * combinePaths("path", "to", "file.ext") === "path/to/file.ext"
7534
+ * combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext"
7535
+ * // POSIX
7536
+ * combinePaths("/path", "to", "file.ext") === "/path/to/file.ext"
7537
+ * combinePaths("/path", "/to", "file.ext") === "/to/file.ext"
7538
+ * // DOS
7539
+ * combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext"
7540
+ * combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext"
7541
+ * // URL
7542
+ * combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext"
7543
+ * combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext"
7544
+ * ```
7545
+ */
7546
+ function combinePaths(path) {
7547
+ var paths = [];
7548
+ for (var _i = 1; _i < arguments.length; _i++) {
7549
+ paths[_i - 1] = arguments[_i];
7550
+ }
7551
+ if (path)
7552
+ path = normalizeSlashes(path);
7553
+ for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
7554
+ var relativePath = paths_1[_a];
7555
+ if (!relativePath)
7556
+ continue;
7557
+ relativePath = normalizeSlashes(relativePath);
7558
+ if (!path || getRootLength(relativePath) !== 0) {
7559
+ path = relativePath;
7560
+ }
7561
+ else {
7562
+ path = ensureTrailingDirectorySeparator(path) + relativePath;
7563
+ }
7564
+ }
7565
+ return path;
7566
+ }
7567
+ ts.combinePaths = combinePaths;
7568
+ /**
7569
+ * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any
7570
+ * `.` and `..` path components are resolved. Trailing directory separators are preserved.
7571
+ *
7572
+ * ```ts
7573
+ * resolvePath("/path", "to", "file.ext") === "path/to/file.ext"
7574
+ * resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/"
7575
+ * resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext"
7576
+ * ```
7577
+ */
7578
+ function resolvePath(path) {
7579
+ var paths = [];
7580
+ for (var _i = 1; _i < arguments.length; _i++) {
7581
+ paths[_i - 1] = arguments[_i];
7582
+ }
7583
+ return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArray([path], paths, false)) : normalizeSlashes(path));
7584
+ }
7585
+ ts.resolvePath = resolvePath;
7586
+ /**
7587
+ * Parse a path into an array containing a root component (at index 0) and zero or more path
7588
+ * components (at indices > 0). The result is normalized.
7589
+ * If the path is relative, the root component is `""`.
7590
+ * If the path is absolute, the root component includes the first path separator (`/`).
7591
+ *
7592
+ * ```ts
7593
+ * getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"]
7594
+ * ```
7595
+ */
7596
+ function getNormalizedPathComponents(path, currentDirectory) {
7597
+ return reducePathComponents(getPathComponents(path, currentDirectory));
7598
+ }
7599
+ ts.getNormalizedPathComponents = getNormalizedPathComponents;
7600
+ function getNormalizedAbsolutePath(fileName, currentDirectory) {
7601
+ return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
7602
+ }
7603
+ ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
7604
+ function normalizePath(path) {
7605
+ path = normalizeSlashes(path);
7606
+ // Most paths don't require normalization
7607
+ if (!relativePathSegmentRegExp.test(path)) {
7608
+ return path;
7609
+ }
7610
+ // Some paths only require cleanup of `/./` or leading `./`
7611
+ var simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, "");
7612
+ if (simplified !== path) {
7613
+ path = simplified;
7614
+ if (!relativePathSegmentRegExp.test(path)) {
7615
+ return path;
7616
+ }
7617
+ }
7618
+ // Other paths require full normalization
7619
+ var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
7620
+ return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
7621
+ }
7622
+ ts.normalizePath = normalizePath;
7623
+ function getPathWithoutRoot(pathComponents) {
7624
+ if (pathComponents.length === 0)
7625
+ return "";
7626
+ return pathComponents.slice(1).join(ts.directorySeparator);
7627
+ }
7628
+ function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
7629
+ return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
7630
+ }
7631
+ ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
7632
+ function toPath(fileName, basePath, getCanonicalFileName) {
7633
+ var nonCanonicalizedPath = isRootedDiskPath(fileName)
7634
+ ? normalizePath(fileName)
7635
+ : getNormalizedAbsolutePath(fileName, basePath);
7636
+ return getCanonicalFileName(nonCanonicalizedPath);
7637
+ }
7638
+ ts.toPath = toPath;
7639
+ function normalizePathAndParts(path) {
7640
+ path = normalizeSlashes(path);
7641
+ var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
7642
+ if (parts.length) {
7643
+ var joinedParts = root + parts.join(ts.directorySeparator);
7644
+ return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
7645
+ }
7646
+ else {
7647
+ return { path: root, parts: parts };
7648
+ }
7649
+ }
7650
+ ts.normalizePathAndParts = normalizePathAndParts;
7651
+ function removeTrailingDirectorySeparator(path) {
7652
+ if (hasTrailingDirectorySeparator(path)) {
7653
+ return path.substr(0, path.length - 1);
7654
+ }
7655
+ return path;
7656
+ }
7657
+ ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
7658
+ function ensureTrailingDirectorySeparator(path) {
7659
+ if (!hasTrailingDirectorySeparator(path)) {
7660
+ return path + ts.directorySeparator;
7661
+ }
7662
+ return path;
7663
+ }
7664
+ ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator;
7665
+ /**
7666
+ * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed
7667
+ * with `./` or `../`) so as not to be confused with an unprefixed module name.
7668
+ *
7669
+ * ```ts
7670
+ * ensurePathIsNonModuleName("/path/to/file.ext") === "/path/to/file.ext"
7671
+ * ensurePathIsNonModuleName("./path/to/file.ext") === "./path/to/file.ext"
7672
+ * ensurePathIsNonModuleName("../path/to/file.ext") === "../path/to/file.ext"
7673
+ * ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext"
7674
+ * ```
7675
+ */
7676
+ function ensurePathIsNonModuleName(path) {
7677
+ return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path;
7678
+ }
7679
+ ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName;
7680
+ function changeAnyExtension(path, ext, extensions, ignoreCase) {
7681
+ var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path);
7682
+ return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
7683
+ }
7684
+ ts.changeAnyExtension = changeAnyExtension;
7685
+ //// Path Comparisons
7686
+ // check path for these segments: '', '.'. '..'
7687
+ var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/;
7688
+ function comparePathsWorker(a, b, componentComparer) {
7689
+ if (a === b)
7690
+ return 0 /* EqualTo */;
7691
+ if (a === undefined)
7692
+ return -1 /* LessThan */;
7693
+ if (b === undefined)
7694
+ return 1 /* GreaterThan */;
7695
+ // NOTE: Performance optimization - shortcut if the root segments differ as there would be no
7696
+ // need to perform path reduction.
7697
+ var aRoot = a.substring(0, getRootLength(a));
7698
+ var bRoot = b.substring(0, getRootLength(b));
7699
+ var result = ts.compareStringsCaseInsensitive(aRoot, bRoot);
7700
+ if (result !== 0 /* EqualTo */) {
7701
+ return result;
7702
+ }
7703
+ // NOTE: Performance optimization - shortcut if there are no relative path segments in
7704
+ // the non-root portion of the path
7705
+ var aRest = a.substring(aRoot.length);
7706
+ var bRest = b.substring(bRoot.length);
7707
+ if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) {
7708
+ return componentComparer(aRest, bRest);
7709
+ }
7710
+ // The path contains a relative path segment. Normalize the paths and perform a slower component
7711
+ // by component comparison.
7712
+ var aComponents = reducePathComponents(getPathComponents(a));
7713
+ var bComponents = reducePathComponents(getPathComponents(b));
7714
+ var sharedLength = Math.min(aComponents.length, bComponents.length);
7715
+ for (var i = 1; i < sharedLength; i++) {
7716
+ var result_2 = componentComparer(aComponents[i], bComponents[i]);
7717
+ if (result_2 !== 0 /* EqualTo */) {
7718
+ return result_2;
7719
+ }
7720
+ }
7721
+ return ts.compareValues(aComponents.length, bComponents.length);
7722
+ }
7723
+ /**
7724
+ * Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively.
7725
+ */
7726
+ function comparePathsCaseSensitive(a, b) {
7727
+ return comparePathsWorker(a, b, ts.compareStringsCaseSensitive);
7728
+ }
7729
+ ts.comparePathsCaseSensitive = comparePathsCaseSensitive;
7730
+ /**
7731
+ * Performs a case-insensitive comparison of two paths.
7732
+ */
7733
+ function comparePathsCaseInsensitive(a, b) {
7734
+ return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive);
7735
+ }
7736
+ ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive;
7737
+ function comparePaths(a, b, currentDirectory, ignoreCase) {
7738
+ if (typeof currentDirectory === "string") {
7739
+ a = combinePaths(currentDirectory, a);
7740
+ b = combinePaths(currentDirectory, b);
7741
+ }
7742
+ else if (typeof currentDirectory === "boolean") {
7743
+ ignoreCase = currentDirectory;
7744
+ }
7745
+ return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase));
7746
+ }
7747
+ ts.comparePaths = comparePaths;
7748
+ function containsPath(parent, child, currentDirectory, ignoreCase) {
7749
+ if (typeof currentDirectory === "string") {
7750
+ parent = combinePaths(currentDirectory, parent);
7751
+ child = combinePaths(currentDirectory, child);
7752
+ }
7753
+ else if (typeof currentDirectory === "boolean") {
7754
+ ignoreCase = currentDirectory;
7755
+ }
7756
+ if (parent === undefined || child === undefined)
7757
+ return false;
7758
+ if (parent === child)
7759
+ return true;
7760
+ var parentComponents = reducePathComponents(getPathComponents(parent));
7761
+ var childComponents = reducePathComponents(getPathComponents(child));
7762
+ if (childComponents.length < parentComponents.length) {
7763
+ return false;
7764
+ }
7765
+ var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive;
7766
+ for (var i = 0; i < parentComponents.length; i++) {
7767
+ var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer;
7768
+ if (!equalityComparer(parentComponents[i], childComponents[i])) {
7769
+ return false;
7770
+ }
7771
+ }
7772
+ return true;
7773
+ }
7774
+ ts.containsPath = containsPath;
7775
+ /**
7776
+ * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback.
7777
+ * Comparison is case-sensitive between the canonical paths.
7778
+ *
7779
+ * Use `containsPath` if file names are not already reduced and absolute.
7780
+ */
7781
+ function startsWithDirectory(fileName, directoryName, getCanonicalFileName) {
7782
+ var canonicalFileName = getCanonicalFileName(fileName);
7783
+ var canonicalDirectoryName = getCanonicalFileName(directoryName);
7784
+ return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\");
7785
+ }
7786
+ ts.startsWithDirectory = startsWithDirectory;
7787
+ //// Relative Paths
7788
+ function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) {
7789
+ var fromComponents = reducePathComponents(getPathComponents(from));
7790
+ var toComponents = reducePathComponents(getPathComponents(to));
7791
+ var start;
7792
+ for (start = 0; start < fromComponents.length && start < toComponents.length; start++) {
7793
+ var fromComponent = getCanonicalFileName(fromComponents[start]);
7794
+ var toComponent = getCanonicalFileName(toComponents[start]);
7795
+ var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer;
7796
+ if (!comparer(fromComponent, toComponent))
7797
+ break;
7798
+ }
7799
+ if (start === 0) {
7800
+ return toComponents;
7801
+ }
7802
+ var components = toComponents.slice(start);
7803
+ var relative = [];
7804
+ for (; start < fromComponents.length; start++) {
7805
+ relative.push("..");
7806
+ }
7807
+ return __spreadArray(__spreadArray([""], relative, true), components, true);
7808
+ }
7809
+ ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo;
7810
+ function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
7811
+ ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
7812
+ var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
7813
+ var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
7814
+ var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
7815
+ return getPathFromPathComponents(pathComponents);
7816
+ }
7817
+ ts.getRelativePathFromDirectory = getRelativePathFromDirectory;
7818
+ function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
7819
+ return !isRootedDiskPath(absoluteOrRelativePath)
7820
+ ? absoluteOrRelativePath
7821
+ : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
7822
+ }
7823
+ ts.convertToRelativePath = convertToRelativePath;
7824
+ function getRelativePathFromFile(from, to, getCanonicalFileName) {
7825
+ return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName));
7826
+ }
7827
+ ts.getRelativePathFromFile = getRelativePathFromFile;
7828
+ function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
7829
+ var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName);
7830
+ var firstComponent = pathComponents[0];
7831
+ if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) {
7832
+ var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///";
7833
+ pathComponents[0] = prefix + firstComponent;
7834
+ }
7835
+ return getPathFromPathComponents(pathComponents);
7836
+ }
7837
+ ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl;
7838
+ function forEachAncestorDirectory(directory, callback) {
7839
+ while (true) {
7840
+ var result = callback(directory);
7841
+ if (result !== undefined) {
7842
+ return result;
7843
+ }
7844
+ var parentPath = getDirectoryPath(directory);
7845
+ if (parentPath === directory) {
7846
+ return undefined;
7847
+ }
7848
+ directory = parentPath;
7849
+ }
7850
+ }
7851
+ ts.forEachAncestorDirectory = forEachAncestorDirectory;
7852
+ function isNodeModulesDirectory(dirPath) {
7853
+ return ts.endsWith(dirPath, "/node_modules");
7854
+ }
7855
+ ts.isNodeModulesDirectory = isNodeModulesDirectory;
7856
+ })(ts || (ts = {}));
7857
7857
  // <auto-generated />
7858
7858
  // generated from './diagnosticMessages.json' in 'src/compiler'
7859
7859
  /* @internal */
@@ -8681,12 +8681,10 @@ var ts;
8681
8681
  Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher: diag(2802, ts.DiagnosticCategory.Error, "Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es201_2802", "Type '{0}' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher."),
8682
8682
  Cannot_assign_to_private_method_0_Private_methods_are_not_writable: diag(2803, ts.DiagnosticCategory.Error, "Cannot_assign_to_private_method_0_Private_methods_are_not_writable_2803", "Cannot assign to private method '{0}'. Private methods are not writable."),
8683
8683
  Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name: diag(2804, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name_2804", "Duplicate identifier '{0}'. Static and instance elements cannot share the same private name."),
8684
- Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag: diag(2805, ts.DiagnosticCategory.Error, "Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_no_2805", "Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag."),
8685
8684
  Private_accessor_was_defined_without_a_getter: diag(2806, ts.DiagnosticCategory.Error, "Private_accessor_was_defined_without_a_getter_2806", "Private accessor was defined without a getter."),
8686
8685
  This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."),
8687
8686
  A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"),
8688
8687
  Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."),
8689
- Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false: diag(2810, ts.DiagnosticCategory.Error, "Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnex_2810", "Property '{0}' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'."),
8690
8688
  Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"),
8691
8689
  Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."),
8692
8690
  Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."),
@@ -9637,6 +9635,7 @@ var ts;
9637
9635
  Add_missing_attributes: diag(95167, ts.DiagnosticCategory.Message, "Add_missing_attributes_95167", "Add missing attributes"),
9638
9636
  Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"),
9639
9637
  Add_undefined_to_optional_property_type: diag(95169, ts.DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"),
9638
+ Convert_named_imports_to_default_import: diag(95170, ts.DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"),
9640
9639
  No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
9641
9640
  Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
9642
9641
  JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
@@ -12809,12 +12808,17 @@ var ts;
12809
12808
  /** Gets the text of a jsdoc comment, flattening links to their text. */
12810
12809
  function getTextOfJSDocComment(comment) {
12811
12810
  return typeof comment === "string" ? comment
12812
- : comment === null || comment === void 0 ? void 0 : comment.map(function (c) {
12813
- // TODO: Other kinds here
12814
- return c.kind === 319 /* JSDocText */ ? c.text : "{@link " + (c.name ? ts.entityNameToString(c.name) + " " : "") + c.text + "}";
12815
- }).join("");
12811
+ : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 319 /* JSDocText */ ? c.text : formatJSDocLink(c); }).join("");
12816
12812
  }
12817
12813
  ts.getTextOfJSDocComment = getTextOfJSDocComment;
12814
+ function formatJSDocLink(link) {
12815
+ var kind = link.kind === 322 /* JSDocLink */ ? "link"
12816
+ : link.kind === 323 /* JSDocLinkCode */ ? "linkcode"
12817
+ : "linkplain";
12818
+ var name = link.name ? ts.entityNameToString(link.name) : "";
12819
+ var space = link.name && link.text.startsWith("://") ? "" : " ";
12820
+ return "{@" + kind + " " + name + space + link.text + "}";
12821
+ }
12818
12822
  /**
12819
12823
  * Gets the effective type parameters. If the node was parsed in a
12820
12824
  * JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
@@ -46863,8 +46867,8 @@ var ts;
46863
46867
  TypeFacts[TypeFacts["AllTypeofNE"] = 556800] = "AllTypeofNE";
46864
46868
  TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts";
46865
46869
  // Masks
46866
- TypeFacts[TypeFacts["OrFactsMask"] = 8288] = "OrFactsMask";
46867
- TypeFacts[TypeFacts["AndFactsMask"] = 16768927] = "AndFactsMask";
46870
+ TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
46871
+ TypeFacts[TypeFacts["AndFactsMask"] = 16768959] = "AndFactsMask";
46868
46872
  })(TypeFacts || (TypeFacts = {}));
46869
46873
  var typeofEQFacts = new ts.Map(ts.getEntries({
46870
46874
  string: 1 /* TypeofEQString */,
@@ -67972,7 +67976,10 @@ var ts;
67972
67976
  (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ :
67973
67977
  (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
67974
67978
  }
67975
- if (flags & 524288 /* Object */ && !ignoreObjects) {
67979
+ if (flags & 524288 /* Object */) {
67980
+ if (ignoreObjects) {
67981
+ return 16768959 /* AndFactsMask */; // This is the identity element for computing type facts of intersection.
67982
+ }
67976
67983
  return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ?
67977
67984
  strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ :
67978
67985
  isFunctionObjectType(type) ?
@@ -68020,7 +68027,7 @@ var ts;
68020
68027
  oredFacts |= f;
68021
68028
  andedFacts &= f;
68022
68029
  }
68023
- return oredFacts & 8288 /* OrFactsMask */ | andedFacts & 16768927 /* AndFactsMask */;
68030
+ return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 16768959 /* AndFactsMask */;
68024
68031
  }
68025
68032
  function getTypeWithFacts(type, include) {
68026
68033
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
@@ -69980,6 +69987,9 @@ var ts;
69980
69987
  return getTypeOfSymbol(symbol);
69981
69988
  }
69982
69989
  function checkIdentifier(node, checkMode) {
69990
+ if (ts.isThisInTypeQuery(node)) {
69991
+ return checkThisExpression(node);
69992
+ }
69983
69993
  var symbol = getResolvedSymbol(node);
69984
69994
  if (symbol === unknownSymbol) {
69985
69995
  return errorType;
@@ -71771,7 +71781,8 @@ var ts;
71771
71781
  var links = getNodeLinks(node.expression);
71772
71782
  if (!links.resolvedType) {
71773
71783
  if ((ts.isTypeLiteralNode(node.parent.parent) || ts.isClassLike(node.parent.parent) || ts.isInterfaceDeclaration(node.parent.parent))
71774
- && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */) {
71784
+ && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */
71785
+ && node.parent.kind !== 171 /* GetAccessor */ && node.parent.kind !== 172 /* SetAccessor */) {
71775
71786
  return links.resolvedType = errorType;
71776
71787
  }
71777
71788
  links.resolvedType = checkExpression(node.expression);
@@ -72940,23 +72951,6 @@ var ts;
72940
72951
  if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) {
72941
72952
  grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right));
72942
72953
  }
72943
- if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && !useDefineForClassFields)) {
72944
- var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration);
72945
- var parentStaticFieldInitializer = ts.findAncestor(node, function (n) {
72946
- if (n === lexicalClass_1)
72947
- return "quit";
72948
- if (ts.isPropertyDeclaration(n.parent) && ts.hasStaticModifier(n.parent) && n.parent.initializer === n && n.parent.parent === lexicalClass_1) {
72949
- return true;
72950
- }
72951
- return false;
72952
- });
72953
- if (parentStaticFieldInitializer) {
72954
- var parentStaticFieldInitializerSymbol = getSymbolOfNode(parentStaticFieldInitializer.parent);
72955
- ts.Debug.assert(parentStaticFieldInitializerSymbol, "Initializer without declaration symbol");
72956
- var diagnostic = error(node, ts.Diagnostics.Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false, ts.symbolName(lexicallyScopedSymbol));
72957
- ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(parentStaticFieldInitializer.parent, ts.Diagnostics.Initializer_for_property_0, ts.symbolName(parentStaticFieldInitializerSymbol)));
72958
- }
72959
- }
72960
72954
  if (isAnyLike) {
72961
72955
  if (lexicallyScopedSymbol) {
72962
72956
  return isErrorType(apparentType) ? errorType : apparentType;
@@ -75719,6 +75713,10 @@ var ts;
75719
75713
  return restParameter.escapedName;
75720
75714
  }
75721
75715
  function getParameterIdentifierNameAtPosition(signature, pos) {
75716
+ var _a;
75717
+ if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 315 /* JSDocFunctionType */) {
75718
+ return undefined;
75719
+ }
75722
75720
  var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
75723
75721
  if (pos < paramCount) {
75724
75722
  var param = signature.parameters[pos];
@@ -78588,9 +78586,6 @@ var ts;
78588
78586
  checkGrammarComputedPropertyName(node.name);
78589
78587
  checkVariableLikeDeclaration(node);
78590
78588
  setNodeLinksForPrivateIdentifierScope(node);
78591
- if (ts.isPrivateIdentifier(node.name) && ts.hasStaticModifier(node) && node.initializer && languageVersion === 99 /* ESNext */ && !compilerOptions.useDefineForClassFields) {
78592
- error(node.initializer, ts.Diagnostics.Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag);
78593
- }
78594
78589
  // property signatures already report "initializer not allowed in ambient context" elsewhere
78595
78590
  if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 166 /* PropertyDeclaration */ && node.initializer) {
78596
78591
  error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name));
@@ -84483,7 +84478,10 @@ var ts;
84483
84478
  case 80 /* PrivateIdentifier */:
84484
84479
  case 205 /* PropertyAccessExpression */:
84485
84480
  case 160 /* QualifiedName */:
84486
- return getSymbolOfNameOrPropertyAccessExpression(node);
84481
+ if (!ts.isThisInTypeQuery(node)) {
84482
+ return getSymbolOfNameOrPropertyAccessExpression(node);
84483
+ }
84484
+ // falls through
84487
84485
  case 108 /* ThisKeyword */:
84488
84486
  var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false);
84489
84487
  if (ts.isFunctionLike(container)) {
@@ -92277,10 +92275,12 @@ var ts;
92277
92275
  var languageVersion = ts.getEmitScriptTarget(compilerOptions);
92278
92276
  var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions);
92279
92277
  var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ES2022 */;
92278
+ // We need to transform `this` in a static initializer into a reference to the class
92279
+ // when targeting < ES2022 since the assignment will be moved outside of the class body.
92280
+ var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ES2022 */;
92280
92281
  // We don't need to transform `super` property access when targeting ES5, ES3 because
92281
92282
  // the es2015 transformation handles those.
92282
- var shouldTransformSuperInStaticInitializers = (languageVersion <= 8 /* ES2021 */ || !useDefineForClassFields) && languageVersion >= 2 /* ES2015 */;
92283
- var shouldTransformThisInStaticInitializers = languageVersion <= 8 /* ES2021 */ || !useDefineForClassFields;
92283
+ var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */;
92284
92284
  var previousOnSubstituteNode = context.onSubstituteNode;
92285
92285
  context.onSubstituteNode = onSubstituteNode;
92286
92286
  var previousOnEmitNode = context.onEmitNode;
@@ -92509,6 +92509,10 @@ var ts;
92509
92509
  ts.Debug.assert(!ts.some(node.decorators));
92510
92510
  if (ts.isPrivateIdentifier(node.name)) {
92511
92511
  if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
92512
+ if (ts.isStatic(node)) {
92513
+ // static fields are left as is
92514
+ return ts.visitEachChild(node, visitor, context);
92515
+ }
92512
92516
  // Initializer is elided as the field is initialized in transformConstructor.
92513
92517
  return factory.updatePropertyDeclaration(node,
92514
92518
  /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name,
@@ -92530,6 +92534,22 @@ var ts;
92530
92534
  if (expr && !ts.isSimpleInlineableExpression(expr)) {
92531
92535
  getPendingExpressions().push(expr);
92532
92536
  }
92537
+ if (ts.isStatic(node) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
92538
+ var initializerStatement = transformPropertyOrClassStaticBlock(node, factory.createThis());
92539
+ if (initializerStatement) {
92540
+ var staticBlock = factory.createClassStaticBlockDeclaration(
92541
+ /*decorators*/ undefined,
92542
+ /*modifiers*/ undefined, factory.createBlock([initializerStatement]));
92543
+ ts.setOriginalNode(staticBlock, node);
92544
+ ts.setCommentRange(staticBlock, node);
92545
+ // Set the comment range for the statement to an empty synthetic range
92546
+ // and drop synthetic comments from the statement to avoid printing them twice.
92547
+ ts.setCommentRange(initializerStatement, { pos: -1, end: -1 });
92548
+ ts.setSyntheticLeadingComments(initializerStatement, undefined);
92549
+ ts.setSyntheticTrailingComments(initializerStatement, undefined);
92550
+ return staticBlock;
92551
+ }
92552
+ }
92533
92553
  return undefined;
92534
92554
  }
92535
92555
  function createPrivateIdentifierAccess(info, receiver) {
@@ -92917,7 +92937,6 @@ var ts;
92917
92937
  if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) {
92918
92938
  enableSubstitutionForClassStaticThisOrSuperReference();
92919
92939
  }
92920
- var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
92921
92940
  // If a class has private static fields, or a static field has a `this` or `super` reference,
92922
92941
  // then we need to allocate a temp variable to hold on to that reference.
92923
92942
  var pendingClassReferenceAssignment;
@@ -92945,6 +92964,7 @@ var ts;
92945
92964
  // From ES6 specification:
92946
92965
  // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using
92947
92966
  // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration.
92967
+ var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
92948
92968
  if (ts.some(staticProperties)) {
92949
92969
  addPropertyOrClassStaticBlockStatements(statements, staticProperties, factory.getInternalName(node));
92950
92970
  }
@@ -92983,7 +93003,7 @@ var ts;
92983
93003
  }
92984
93004
  var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), node.modifiers, node.name,
92985
93005
  /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, heritageClauseVisitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass));
92986
- var hasTransformableStatics = ts.some(staticPropertiesOrClassStaticBlocks, function (p) { return ts.isClassStaticBlockDeclaration(p) || !!p.initializer || (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifier(p.name)); });
93006
+ var hasTransformableStatics = shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(staticPropertiesOrClassStaticBlocks, function (p) { return ts.isClassStaticBlockDeclaration(p) || !!p.initializer || ts.isPrivateIdentifier(p.name); });
92987
93007
  if (hasTransformableStatics || ts.some(pendingExpressions)) {
92988
93008
  if (isDecoratedClassDeclaration) {
92989
93009
  ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration.");
@@ -93030,6 +93050,7 @@ var ts;
93030
93050
  return undefined;
93031
93051
  }
93032
93052
  function transformClassMembers(node, isDerivedClass) {
93053
+ var members = [];
93033
93054
  if (shouldTransformPrivateElementsOrClassStaticBlocks) {
93034
93055
  // Declare private names.
93035
93056
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
@@ -93042,12 +93063,20 @@ var ts;
93042
93063
  createBrandCheckWeakSetForPrivateMethods();
93043
93064
  }
93044
93065
  }
93045
- var members = [];
93046
93066
  var constructor = transformConstructor(node, isDerivedClass);
93067
+ var visitedMembers = ts.visitNodes(node.members, classElementVisitor, ts.isClassElement);
93047
93068
  if (constructor) {
93048
93069
  members.push(constructor);
93049
93070
  }
93050
- ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
93071
+ if (!shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(pendingExpressions)) {
93072
+ members.push(factory.createClassStaticBlockDeclaration(
93073
+ /*decorators*/ undefined,
93074
+ /*modifiers*/ undefined, factory.createBlock([
93075
+ factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))
93076
+ ])));
93077
+ pendingExpressions = undefined;
93078
+ }
93079
+ ts.addRange(members, visitedMembers);
93051
93080
  return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members);
93052
93081
  }
93053
93082
  function createBrandCheckWeakSetForPrivateMethods() {
@@ -93190,24 +93219,34 @@ var ts;
93190
93219
  function addPropertyOrClassStaticBlockStatements(statements, properties, receiver) {
93191
93220
  for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
93192
93221
  var property = properties_7[_i];
93193
- var expression = ts.isClassStaticBlockDeclaration(property) ?
93194
- transformClassStaticBlockDeclaration(property) :
93195
- transformProperty(property, receiver);
93196
- if (!expression) {
93222
+ if (ts.isStatic(property) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
93223
+ continue;
93224
+ }
93225
+ var statement = transformPropertyOrClassStaticBlock(property, receiver);
93226
+ if (!statement) {
93197
93227
  continue;
93198
93228
  }
93199
- var statement = factory.createExpressionStatement(expression);
93200
- ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
93201
- ts.setCommentRange(statement, property);
93202
- ts.setOriginalNode(statement, property);
93203
- // `setOriginalNode` *copies* the `emitNode` from `property`, so now both
93204
- // `statement` and `expression` have a copy of the synthesized comments.
93205
- // Drop the comments from expression to avoid printing them twice.
93206
- ts.setSyntheticLeadingComments(expression, undefined);
93207
- ts.setSyntheticTrailingComments(expression, undefined);
93208
93229
  statements.push(statement);
93209
93230
  }
93210
93231
  }
93232
+ function transformPropertyOrClassStaticBlock(property, receiver) {
93233
+ var expression = ts.isClassStaticBlockDeclaration(property) ?
93234
+ transformClassStaticBlockDeclaration(property) :
93235
+ transformProperty(property, receiver);
93236
+ if (!expression) {
93237
+ return undefined;
93238
+ }
93239
+ var statement = factory.createExpressionStatement(expression);
93240
+ ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
93241
+ ts.setCommentRange(statement, property);
93242
+ ts.setOriginalNode(statement, property);
93243
+ // `setOriginalNode` *copies* the `emitNode` from `property`, so now both
93244
+ // `statement` and `expression` have a copy of the synthesized comments.
93245
+ // Drop the comments from expression to avoid printing them twice.
93246
+ ts.setSyntheticLeadingComments(expression, undefined);
93247
+ ts.setSyntheticTrailingComments(expression, undefined);
93248
+ return statement;
93249
+ }
93211
93250
  /**
93212
93251
  * Generates assignment expressions for property initializers.
93213
93252
  *
@@ -94457,6 +94496,7 @@ var ts;
94457
94496
  var exportedVariableStatement = false;
94458
94497
  var enabledSubstitutions;
94459
94498
  var enclosingFunctionFlags;
94499
+ var parametersWithPrecedingObjectRestOrSpread;
94460
94500
  var enclosingSuperContainerFlags = 0;
94461
94501
  var hierarchyFacts = 0;
94462
94502
  var currentSourceFile;
@@ -94913,6 +94953,7 @@ var ts;
94913
94953
  /*incrementor*/ undefined,
94914
94954
  /*statement*/ convertForOfStatementHead(node, getValue)),
94915
94955
  /*location*/ node), 256 /* NoTokenTrailingSourceMaps */);
94956
+ ts.setOriginalNode(forStatement, node);
94916
94957
  return factory.createTryStatement(factory.createBlock([
94917
94958
  factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement)
94918
94959
  ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([
@@ -94930,7 +94971,19 @@ var ts;
94930
94971
  ]), 1 /* SingleLine */))
94931
94972
  ]));
94932
94973
  }
94974
+ function parameterVisitor(node) {
94975
+ ts.Debug.assertNode(node, ts.isParameter);
94976
+ return visitParameter(node);
94977
+ }
94933
94978
  function visitParameter(node) {
94979
+ if (parametersWithPrecedingObjectRestOrSpread === null || parametersWithPrecedingObjectRestOrSpread === void 0 ? void 0 : parametersWithPrecedingObjectRestOrSpread.has(node)) {
94980
+ return factory.updateParameterDeclaration(node,
94981
+ /*decorators*/ undefined,
94982
+ /*modifiers*/ undefined, node.dotDotDotToken, ts.isBindingPattern(node.name) ? factory.getGeneratedNameForNode(node) : node.name,
94983
+ /*questionToken*/ undefined,
94984
+ /*type*/ undefined,
94985
+ /*initializer*/ undefined);
94986
+ }
94934
94987
  if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
94935
94988
  // Binding patterns are converted into a generated name and are
94936
94989
  // evaluated inside the function body.
@@ -94942,85 +94995,119 @@ var ts;
94942
94995
  }
94943
94996
  return ts.visitEachChild(node, visitor, context);
94944
94997
  }
94998
+ function collectParametersWithPrecedingObjectRestOrSpread(node) {
94999
+ var parameters;
95000
+ for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
95001
+ var parameter = _a[_i];
95002
+ if (parameters) {
95003
+ parameters.add(parameter);
95004
+ }
95005
+ else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
95006
+ parameters = new ts.Set();
95007
+ }
95008
+ }
95009
+ return parameters;
95010
+ }
94945
95011
  function visitConstructorDeclaration(node) {
94946
95012
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
94947
- enclosingFunctionFlags = 0 /* Normal */;
95013
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95014
+ enclosingFunctionFlags = ts.getFunctionFlags(node);
95015
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94948
95016
  var updated = factory.updateConstructorDeclaration(node,
94949
- /*decorators*/ undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
95017
+ /*decorators*/ undefined, node.modifiers, ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node));
94950
95018
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95019
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
94951
95020
  return updated;
94952
95021
  }
94953
95022
  function visitGetAccessorDeclaration(node) {
94954
95023
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
94955
- enclosingFunctionFlags = 0 /* Normal */;
95024
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95025
+ enclosingFunctionFlags = ts.getFunctionFlags(node);
95026
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94956
95027
  var updated = factory.updateGetAccessorDeclaration(node,
94957
- /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context),
95028
+ /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context),
94958
95029
  /*type*/ undefined, transformFunctionBody(node));
94959
95030
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95031
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
94960
95032
  return updated;
94961
95033
  }
94962
95034
  function visitSetAccessorDeclaration(node) {
94963
95035
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
94964
- enclosingFunctionFlags = 0 /* Normal */;
95036
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95037
+ enclosingFunctionFlags = ts.getFunctionFlags(node);
95038
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94965
95039
  var updated = factory.updateSetAccessorDeclaration(node,
94966
- /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
95040
+ /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node));
94967
95041
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95042
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
94968
95043
  return updated;
94969
95044
  }
94970
95045
  function visitMethodDeclaration(node) {
94971
95046
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95047
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
94972
95048
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95049
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94973
95050
  var updated = factory.updateMethodDeclaration(node,
94974
95051
  /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */
94975
95052
  ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
94976
95053
  : node.modifiers, enclosingFunctionFlags & 2 /* Async */
94977
95054
  ? undefined
94978
95055
  : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(/*questionToken*/ undefined, visitor, ts.isToken),
94979
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95056
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
94980
95057
  /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
94981
95058
  ? transformAsyncGeneratorFunctionBody(node)
94982
95059
  : transformFunctionBody(node));
94983
95060
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95061
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
94984
95062
  return updated;
94985
95063
  }
94986
95064
  function visitFunctionDeclaration(node) {
94987
95065
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95066
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
94988
95067
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95068
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94989
95069
  var updated = factory.updateFunctionDeclaration(node,
94990
95070
  /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */
94991
95071
  ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
94992
95072
  : node.modifiers, enclosingFunctionFlags & 2 /* Async */
94993
95073
  ? undefined
94994
95074
  : node.asteriskToken, node.name,
94995
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95075
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
94996
95076
  /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
94997
95077
  ? transformAsyncGeneratorFunctionBody(node)
94998
95078
  : transformFunctionBody(node));
94999
95079
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95080
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95000
95081
  return updated;
95001
95082
  }
95002
95083
  function visitArrowFunction(node) {
95003
95084
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95085
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95004
95086
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95087
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95005
95088
  var updated = factory.updateArrowFunction(node, node.modifiers,
95006
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95089
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
95007
95090
  /*type*/ undefined, node.equalsGreaterThanToken, transformFunctionBody(node));
95008
95091
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95092
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95009
95093
  return updated;
95010
95094
  }
95011
95095
  function visitFunctionExpression(node) {
95012
95096
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95097
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95013
95098
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95099
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95014
95100
  var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */
95015
95101
  ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
95016
95102
  : node.modifiers, enclosingFunctionFlags & 2 /* Async */
95017
95103
  ? undefined
95018
95104
  : node.asteriskToken, node.name,
95019
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95105
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
95020
95106
  /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
95021
95107
  ? transformAsyncGeneratorFunctionBody(node)
95022
95108
  : transformFunctionBody(node));
95023
95109
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95110
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95024
95111
  return updated;
95025
95112
  }
95026
95113
  function transformAsyncGeneratorFunctionBody(node) {
@@ -95081,16 +95168,71 @@ var ts;
95081
95168
  return body;
95082
95169
  }
95083
95170
  function appendObjectRestAssignmentsIfNeeded(statements, node) {
95171
+ var containsPrecedingObjectRestOrSpread = false;
95084
95172
  for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
95085
95173
  var parameter = _a[_i];
95086
- if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
95087
- var temp = factory.getGeneratedNameForNode(parameter);
95088
- var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, temp,
95174
+ if (containsPrecedingObjectRestOrSpread) {
95175
+ if (ts.isBindingPattern(parameter.name)) {
95176
+ // In cases where a binding pattern is simply '[]' or '{}',
95177
+ // we usually don't want to emit a var declaration; however, in the presence
95178
+ // of an initializer, we must emit that expression to preserve side effects.
95179
+ //
95180
+ // NOTE: see `insertDefaultValueAssignmentForBindingPattern` in es2015.ts
95181
+ if (parameter.name.elements.length > 0) {
95182
+ var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter));
95183
+ if (ts.some(declarations)) {
95184
+ var declarationList = factory.createVariableDeclarationList(declarations);
95185
+ var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList);
95186
+ ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
95187
+ statements = ts.append(statements, statement);
95188
+ }
95189
+ }
95190
+ else if (parameter.initializer) {
95191
+ var name = factory.getGeneratedNameForNode(parameter);
95192
+ var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression);
95193
+ var assignment = factory.createAssignment(name, initializer);
95194
+ var statement = factory.createExpressionStatement(assignment);
95195
+ ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
95196
+ statements = ts.append(statements, statement);
95197
+ }
95198
+ }
95199
+ else if (parameter.initializer) {
95200
+ // Converts a parameter initializer into a function body statement, i.e.:
95201
+ //
95202
+ // function f(x = 1) { }
95203
+ //
95204
+ // becomes
95205
+ //
95206
+ // function f(x) {
95207
+ // if (typeof x === "undefined") { x = 1; }
95208
+ // }
95209
+ var name = factory.cloneNode(parameter.name);
95210
+ ts.setTextRange(name, parameter.name);
95211
+ ts.setEmitFlags(name, 48 /* NoSourceMap */);
95212
+ var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression);
95213
+ ts.addEmitFlags(initializer, 48 /* NoSourceMap */ | 1536 /* NoComments */);
95214
+ var assignment = factory.createAssignment(name, initializer);
95215
+ ts.setTextRange(assignment, parameter);
95216
+ ts.setEmitFlags(assignment, 1536 /* NoComments */);
95217
+ var block = factory.createBlock([factory.createExpressionStatement(assignment)]);
95218
+ ts.setTextRange(block, parameter);
95219
+ ts.setEmitFlags(block, 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */);
95220
+ var typeCheck = factory.createTypeCheck(factory.cloneNode(parameter.name), "undefined");
95221
+ var statement = factory.createIfStatement(typeCheck, block);
95222
+ ts.startOnNewLine(statement);
95223
+ ts.setTextRange(statement, parameter);
95224
+ ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */);
95225
+ statements = ts.append(statements, statement);
95226
+ }
95227
+ }
95228
+ else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
95229
+ containsPrecedingObjectRestOrSpread = true;
95230
+ var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter),
95089
95231
  /*doNotRecordTempVariablesInLine*/ false,
95090
95232
  /*skipInitializer*/ true);
95091
95233
  if (ts.some(declarations)) {
95092
- var statement = factory.createVariableStatement(
95093
- /*modifiers*/ undefined, factory.createVariableDeclarationList(declarations));
95234
+ var declarationList = factory.createVariableDeclarationList(declarations);
95235
+ var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList);
95094
95236
  ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
95095
95237
  statements = ts.append(statements, statement);
95096
95238
  }
@@ -98341,10 +98483,12 @@ var ts;
98341
98483
  // variables declared in the loop initializer that will be changed inside the loop
98342
98484
  var loopOutParameters = [];
98343
98485
  if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) {
98344
- var hasCapturedBindingsInForInitializer = shouldConvertInitializerOfForStatement(node);
98486
+ var hasCapturedBindingsInForHead = shouldConvertInitializerOfForStatement(node) ||
98487
+ shouldConvertConditionOfForStatement(node) ||
98488
+ shouldConvertIncrementorOfForStatement(node);
98345
98489
  for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) {
98346
98490
  var decl = _a[_i];
98347
- processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
98491
+ processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForHead);
98348
98492
  }
98349
98493
  }
98350
98494
  var currentState = { loopParameters: loopParameters, loopOutParameters: loopOutParameters };
@@ -98698,27 +98842,33 @@ var ts;
98698
98842
  caseClauses.push(factory.createCaseClause(factory.createStringLiteral(labelMarker), statements));
98699
98843
  });
98700
98844
  }
98701
- function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer) {
98845
+ function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForHead) {
98702
98846
  var name = decl.name;
98703
98847
  if (ts.isBindingPattern(name)) {
98704
98848
  for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
98705
98849
  var element = _a[_i];
98706
98850
  if (!ts.isOmittedExpression(element)) {
98707
- processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
98851
+ processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForHead);
98708
98852
  }
98709
98853
  }
98710
98854
  }
98711
98855
  else {
98712
98856
  loopParameters.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name));
98713
98857
  var checkFlags = resolver.getNodeCheckFlags(decl);
98714
- if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForInitializer) {
98858
+ if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) {
98715
98859
  var outParamName = factory.createUniqueName("out_" + ts.idText(name));
98716
98860
  var flags = 0;
98717
98861
  if (checkFlags & 4194304 /* NeedsLoopOutParameter */) {
98718
98862
  flags |= 1 /* Body */;
98719
98863
  }
98720
- if (ts.isForStatement(container) && container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
98721
- flags |= 2 /* Initializer */;
98864
+ if (ts.isForStatement(container)) {
98865
+ if (container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
98866
+ flags |= 2 /* Initializer */;
98867
+ }
98868
+ if (container.condition && resolver.isBindingCapturedByNode(container.condition, decl) ||
98869
+ container.incrementor && resolver.isBindingCapturedByNode(container.incrementor, decl)) {
98870
+ flags |= 1 /* Body */;
98871
+ }
98722
98872
  }
98723
98873
  loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName });
98724
98874
  }
@@ -125738,7 +125888,7 @@ var ts;
125738
125888
  parts.push(linkTextPart(text));
125739
125889
  }
125740
125890
  else {
125741
- parts.push(linkTextPart(name + (suffix ? "" : " ") + text));
125891
+ parts.push(linkTextPart(name + (suffix || text.indexOf("://") === 0 ? "" : " ") + text));
125742
125892
  }
125743
125893
  }
125744
125894
  parts.push(linkPart("}"));
@@ -126559,15 +126709,35 @@ var ts;
126559
126709
  return ts.isArray(valueOrArray) ? ts.first(valueOrArray) : valueOrArray;
126560
126710
  }
126561
126711
  ts.firstOrOnly = firstOrOnly;
126712
+ function getNamesForExportedSymbol(symbol, scriptTarget) {
126713
+ if (needsNameFromDeclaration(symbol)) {
126714
+ var fromDeclaration = getDefaultLikeExportNameFromDeclaration(symbol);
126715
+ if (fromDeclaration)
126716
+ return fromDeclaration;
126717
+ var fileNameCase = ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, /*preferCapitalized*/ false);
126718
+ var capitalized = ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, /*preferCapitalized*/ true);
126719
+ if (fileNameCase === capitalized)
126720
+ return fileNameCase;
126721
+ return [fileNameCase, capitalized];
126722
+ }
126723
+ return symbol.name;
126724
+ }
126725
+ ts.getNamesForExportedSymbol = getNamesForExportedSymbol;
126562
126726
  function getNameForExportedSymbol(symbol, scriptTarget, preferCapitalized) {
126563
- if (!(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */)) {
126727
+ if (needsNameFromDeclaration(symbol)) {
126564
126728
  // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase.
126565
- return ts.firstDefined(symbol.declarations, function (d) { var _a; return ts.isExportAssignment(d) ? (_a = ts.tryCast(ts.skipOuterExpressions(d.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text : undefined; })
126729
+ return getDefaultLikeExportNameFromDeclaration(symbol)
126566
126730
  || ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, !!preferCapitalized);
126567
126731
  }
126568
126732
  return symbol.name;
126569
126733
  }
126570
126734
  ts.getNameForExportedSymbol = getNameForExportedSymbol;
126735
+ function needsNameFromDeclaration(symbol) {
126736
+ return !(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */);
126737
+ }
126738
+ function getDefaultLikeExportNameFromDeclaration(symbol) {
126739
+ return ts.firstDefined(symbol.declarations, function (d) { var _a; return ts.isExportAssignment(d) ? (_a = ts.tryCast(ts.skipOuterExpressions(d.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text : undefined; });
126740
+ }
126571
126741
  function getSymbolParentOrFail(symbol) {
126572
126742
  var _a;
126573
126743
  return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: " + ts.Debug.formatSymbolFlags(symbol.flags) + ". " +
@@ -126737,9 +126907,11 @@ var ts;
126737
126907
  // 3. Otherwise, we have a default/namespace import that can be imported by any name, and
126738
126908
  // `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to
126739
126909
  // get a better name.
126740
- var importedName = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
126910
+ var names = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
126741
126911
  ? ts.unescapeLeadingUnderscores(symbolTableKey)
126742
- : ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
126912
+ : ts.getNamesForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
126913
+ var symbolName = typeof names === "string" ? names : names[0];
126914
+ var capitalizedSymbolName = typeof names === "string" ? undefined : names[1];
126743
126915
  var moduleName = ts.stripQuotes(moduleSymbol.name);
126744
126916
  var id = exportInfoId++;
126745
126917
  var target = ts.skipAlias(symbol, checker);
@@ -126747,10 +126919,11 @@ var ts;
126747
126919
  var storedModuleSymbol = moduleSymbol.flags & 33554432 /* Transient */ ? undefined : moduleSymbol;
126748
126920
  if (!storedSymbol || !storedModuleSymbol)
126749
126921
  symbols.set(id, [symbol, moduleSymbol]);
126750
- exportInfo.add(key(importedName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), {
126922
+ exportInfo.add(key(symbolName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), {
126751
126923
  id: id,
126752
126924
  symbolTableKey: symbolTableKey,
126753
- symbolName: importedName,
126925
+ symbolName: symbolName,
126926
+ capitalizedSymbolName: capitalizedSymbolName,
126754
126927
  moduleName: moduleName,
126755
126928
  moduleFile: moduleFile,
126756
126929
  moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName,
@@ -126768,21 +126941,18 @@ var ts;
126768
126941
  var result = exportInfo.get(key);
126769
126942
  return result === null || result === void 0 ? void 0 : result.map(rehydrateCachedInfo);
126770
126943
  },
126771
- forEach: function (importingFile, action) {
126944
+ search: function (importingFile, preferCapitalized, matches, action) {
126772
126945
  if (importingFile !== usableByFileName)
126773
126946
  return;
126774
126947
  exportInfo.forEach(function (info, key) {
126775
126948
  var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
126776
- var rehydrated = info.map(rehydrateCachedInfo);
126777
- var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
126778
- if (filtered.length) {
126779
- action(filtered, function (preferCapitalized) {
126780
- var _a = rehydrated[0], symbol = _a.symbol, exportKind = _a.exportKind;
126781
- var namedSymbol = exportKind === 1 /* Default */ && ts.getLocalSymbolForExportDefault(symbol) || symbol;
126782
- return preferCapitalized
126783
- ? ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined, /*preferCapitalized*/ true)
126784
- : symbolName;
126785
- }, !!ambientModuleName, key);
126949
+ var name = preferCapitalized && info[0].capitalizedSymbolName || symbolName;
126950
+ if (matches(name, info[0].targetFlags)) {
126951
+ var rehydrated = info.map(rehydrateCachedInfo);
126952
+ var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
126953
+ if (filtered.length) {
126954
+ action(filtered, name, !!ambientModuleName, key);
126955
+ }
126786
126956
  }
126787
126957
  });
126788
126958
  },
@@ -130898,44 +131068,47 @@ var ts;
130898
131068
  var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
130899
131069
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
130900
131070
  resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
130901
- exportInfo.forEach(sourceFile.path, function (info, getSymbolName, isFromAmbientModule, exportMapKey) {
130902
- var symbolName = getSymbolName(/*preferCapitalized*/ isRightOfOpenTag);
131071
+ exportInfo.search(sourceFile.path,
131072
+ /*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
130903
131073
  if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
130904
- return;
131074
+ return false;
130905
131075
  if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
130906
- return;
130907
- // `targetFlags` should be the same for each `info`
130908
- if (!isTypeOnlyLocation && !importCompletionNode && !(info[0].targetFlags & 111551 /* Value */))
130909
- return;
130910
- if (isTypeOnlyLocation && !(info[0].targetFlags & (1536 /* Module */ | 788968 /* Type */)))
130911
- return;
131076
+ return false;
131077
+ if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* Value */))
131078
+ return false;
131079
+ if (isTypeOnlyLocation && !(targetFlags & (1536 /* Module */ | 788968 /* Type */)))
131080
+ return false;
130912
131081
  // Do not try to auto-import something with a lowercase first letter for a JSX tag
130913
131082
  var firstChar = symbolName.charCodeAt(0);
130914
131083
  if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */))
131084
+ return false;
131085
+ if (detailsEntryId)
131086
+ return true;
131087
+ return charactersFuzzyMatchInString(symbolName, lowerCaseTokenText);
131088
+ }, function (info, symbolName, isFromAmbientModule, exportMapKey) {
131089
+ if (detailsEntryId && !ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); })) {
130915
131090
  return;
130916
- var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); });
130917
- if (isCompletionDetailsMatch || !detailsEntryId && charactersFuzzyMatchInString(symbolName, lowerCaseTokenText)) {
130918
- var defaultExportInfo = ts.find(info, isImportableExportInfo);
130919
- if (!defaultExportInfo) {
130920
- return;
130921
- }
130922
- // If we don't need to resolve module specifiers, we can use any re-export that is importable at all
130923
- // (We need to ensure that at least one is importable to show a completion.)
130924
- var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo_1 = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
130925
- var isDefaultExport = exportInfo_1.exportKind === 1 /* Default */;
130926
- var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo_1.symbol) || exportInfo_1.symbol;
130927
- pushAutoImportSymbol(symbol, {
130928
- kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
130929
- moduleSpecifier: moduleSpecifier,
130930
- symbolName: symbolName,
130931
- exportMapKey: exportMapKey,
130932
- exportName: exportInfo_1.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo_1.symbol.name,
130933
- fileName: exportInfo_1.moduleFileName,
130934
- isDefaultExport: isDefaultExport,
130935
- moduleSymbol: exportInfo_1.moduleSymbol,
130936
- isFromPackageJson: exportInfo_1.isFromPackageJson,
130937
- });
130938
131091
  }
131092
+ var defaultExportInfo = ts.find(info, isImportableExportInfo);
131093
+ if (!defaultExportInfo) {
131094
+ return;
131095
+ }
131096
+ // If we don't need to resolve module specifiers, we can use any re-export that is importable at all
131097
+ // (We need to ensure that at least one is importable to show a completion.)
131098
+ var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
131099
+ var isDefaultExport = exportInfo.exportKind === 1 /* Default */;
131100
+ var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol;
131101
+ pushAutoImportSymbol(symbol, {
131102
+ kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
131103
+ moduleSpecifier: moduleSpecifier,
131104
+ symbolName: symbolName,
131105
+ exportMapKey: exportMapKey,
131106
+ exportName: exportInfo.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo.symbol.name,
131107
+ fileName: exportInfo.moduleFileName,
131108
+ isDefaultExport: isDefaultExport,
131109
+ moduleSymbol: exportInfo.moduleSymbol,
131110
+ isFromPackageJson: exportInfo.isFromPackageJson,
131111
+ });
130939
131112
  });
130940
131113
  hasUnresolvedAutoImports = context.resolutionLimitExceeded();
130941
131114
  });
@@ -136874,7 +137047,27 @@ var ts;
136874
137047
  case 326 /* JSDocAugmentsTag */:
136875
137048
  return withNode(tag.class);
136876
137049
  case 342 /* JSDocTemplateTag */:
136877
- return addComment(tag.typeParameters.map(function (tp) { return tp.getText(); }).join(", "));
137050
+ var templateTag = tag;
137051
+ var displayParts_3 = [];
137052
+ if (templateTag.constraint) {
137053
+ displayParts_3.push(ts.textPart(templateTag.constraint.getText()));
137054
+ }
137055
+ if (ts.length(templateTag.typeParameters)) {
137056
+ if (ts.length(displayParts_3)) {
137057
+ displayParts_3.push(ts.spacePart());
137058
+ }
137059
+ var lastTypeParameter_1 = templateTag.typeParameters[templateTag.typeParameters.length - 1];
137060
+ ts.forEach(templateTag.typeParameters, function (tp) {
137061
+ displayParts_3.push(namePart(tp.getText()));
137062
+ if (lastTypeParameter_1 !== tp) {
137063
+ displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]);
137064
+ }
137065
+ });
137066
+ }
137067
+ if (comment) {
137068
+ displayParts_3.push.apply(displayParts_3, __spreadArray([ts.spacePart()], getDisplayPartsFromComment(comment, checker), true));
137069
+ }
137070
+ return displayParts_3;
136878
137071
  case 341 /* JSDocTypeTag */:
136879
137072
  return withNode(tag.typeExpression);
136880
137073
  case 343 /* JSDocTypedefTag */:
@@ -138362,7 +138555,7 @@ var ts;
138362
138555
  newImportSpecifiers.push(ts.factory.createImportSpecifier(/*isTypeOnly*/ false, ts.factory.createIdentifier("default"), defaultImport.importClause.name)); // TODO: GH#18217
138363
138556
  }
138364
138557
  }
138365
- newImportSpecifiers.push.apply(newImportSpecifiers, ts.flatMap(namedImports, function (i) { return i.importClause.namedBindings.elements; })); // TODO: GH#18217
138558
+ newImportSpecifiers.push.apply(newImportSpecifiers, getNewImportSpecifiers(namedImports));
138366
138559
  var sortedImportSpecifiers = sortSpecifiers(newImportSpecifiers);
138367
138560
  var importDecl = defaultImports.length > 0
138368
138561
  ? defaultImports[0]
@@ -138572,6 +138765,21 @@ var ts;
138572
138765
  return 6;
138573
138766
  }
138574
138767
  }
138768
+ function getNewImportSpecifiers(namedImports) {
138769
+ return ts.flatMap(namedImports, function (namedImport) {
138770
+ return ts.map(tryGetNamedBindingElements(namedImport), function (importSpecifier) {
138771
+ return importSpecifier.name && importSpecifier.propertyName && importSpecifier.name.escapedText === importSpecifier.propertyName.escapedText
138772
+ ? ts.factory.updateImportSpecifier(importSpecifier, importSpecifier.isTypeOnly, /*propertyName*/ undefined, importSpecifier.name)
138773
+ : importSpecifier;
138774
+ });
138775
+ });
138776
+ }
138777
+ function tryGetNamedBindingElements(namedImport) {
138778
+ var _a;
138779
+ return ((_a = namedImport.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings) && ts.isNamedImports(namedImport.importClause.namedBindings)
138780
+ ? namedImport.importClause.namedBindings.elements
138781
+ : undefined;
138782
+ }
138575
138783
  })(OrganizeImports = ts.OrganizeImports || (ts.OrganizeImports = {}));
138576
138784
  })(ts || (ts = {}));
138577
138785
  /* @internal */
@@ -140285,12 +140493,12 @@ var ts;
140285
140493
  : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex };
140286
140494
  }
140287
140495
  SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions;
140288
- function getArgumentOrParameterListInfo(node, sourceFile) {
140496
+ function getArgumentOrParameterListInfo(node, position, sourceFile) {
140289
140497
  var info = getArgumentOrParameterListAndIndex(node, sourceFile);
140290
140498
  if (!info)
140291
140499
  return undefined;
140292
140500
  var list = info.list, argumentIndex = info.argumentIndex;
140293
- var argumentCount = getArgumentCount(list);
140501
+ var argumentCount = getArgumentCount(list, /*ignoreTrailingComma*/ ts.isInString(sourceFile, position, node));
140294
140502
  if (argumentIndex !== 0) {
140295
140503
  ts.Debug.assertLessThan(argumentIndex, argumentCount);
140296
140504
  }
@@ -140336,7 +140544,7 @@ var ts;
140336
140544
  // Case 3:
140337
140545
  // foo<T#, U#>(a#, #b#) -> The token is buried inside a list, and should give signature help
140338
140546
  // Find out if 'node' is an argument, a type argument, or neither
140339
- var info = getArgumentOrParameterListInfo(node, sourceFile);
140547
+ var info = getArgumentOrParameterListInfo(node, position, sourceFile);
140340
140548
  if (!info)
140341
140549
  return undefined;
140342
140550
  var list = info.list, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
@@ -140405,8 +140613,8 @@ var ts;
140405
140613
  function countBinaryExpressionParameters(b) {
140406
140614
  return ts.isBinaryExpression(b.left) ? countBinaryExpressionParameters(b.left) + 1 : 2;
140407
140615
  }
140408
- function tryGetParameterInfo(startingToken, _position, sourceFile, checker) {
140409
- var info = getContextualSignatureLocationInfo(startingToken, sourceFile, checker);
140616
+ function tryGetParameterInfo(startingToken, position, sourceFile, checker) {
140617
+ var info = getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker);
140410
140618
  if (!info)
140411
140619
  return undefined;
140412
140620
  var contextualType = info.contextualType, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
@@ -140418,7 +140626,7 @@ var ts;
140418
140626
  var invocation = { kind: 2 /* Contextual */, signature: ts.first(signatures), node: startingToken, symbol: chooseBetterSymbol(nonNullableContextualType.symbol) };
140419
140627
  return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount };
140420
140628
  }
140421
- function getContextualSignatureLocationInfo(startingToken, sourceFile, checker) {
140629
+ function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) {
140422
140630
  if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */)
140423
140631
  return undefined;
140424
140632
  var parent = startingToken.parent;
@@ -140427,7 +140635,7 @@ var ts;
140427
140635
  case 168 /* MethodDeclaration */:
140428
140636
  case 212 /* FunctionExpression */:
140429
140637
  case 213 /* ArrowFunction */:
140430
- var info = getArgumentOrParameterListInfo(startingToken, sourceFile);
140638
+ var info = getArgumentOrParameterListInfo(startingToken, position, sourceFile);
140431
140639
  if (!info)
140432
140640
  return undefined;
140433
140641
  var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
@@ -140474,7 +140682,7 @@ var ts;
140474
140682
  }
140475
140683
  return argumentIndex;
140476
140684
  }
140477
- function getArgumentCount(argumentsList) {
140685
+ function getArgumentCount(argumentsList, ignoreTrailingComma) {
140478
140686
  // The argument count for a list is normally the number of non-comma children it has.
140479
140687
  // For example, if you have "Foo(a,b)" then there will be three children of the arg
140480
140688
  // list 'a' '<comma>' 'b'. So, in this case the arg count will be 2. However, there
@@ -140488,7 +140696,7 @@ var ts;
140488
140696
  // arg count of 3.
140489
140697
  var listChildren = argumentsList.getChildren();
140490
140698
  var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; });
140491
- if (listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) {
140699
+ if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) {
140492
140700
  argumentCount++;
140493
140701
  }
140494
140702
  return argumentCount;
@@ -141434,7 +141642,7 @@ var ts;
141434
141642
  if (typeChecker.isArgumentsSymbol(symbol)) {
141435
141643
  return "local var" /* localVariableElement */;
141436
141644
  }
141437
- if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location)) {
141645
+ if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) {
141438
141646
  return "parameter" /* parameterElement */;
141439
141647
  }
141440
141648
  var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol);
@@ -141529,7 +141737,7 @@ var ts;
141529
141737
  var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol);
141530
141738
  var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */;
141531
141739
  var hasAddedSymbolInfo = false;
141532
- var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location);
141740
+ var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location);
141533
141741
  var type;
141534
141742
  var printer;
141535
141743
  var documentationFromAlias;
@@ -141942,6 +142150,18 @@ var ts;
141942
142150
  }
141943
142151
  }
141944
142152
  }
142153
+ if (documentation.length === 0 && ts.isIdentifier(location) && symbol.valueDeclaration && ts.isBindingElement(symbol.valueDeclaration)) {
142154
+ var declaration = symbol.valueDeclaration;
142155
+ var parent = declaration.parent;
142156
+ if (ts.isIdentifier(declaration.name) && ts.isObjectBindingPattern(parent)) {
142157
+ var name_4 = ts.getTextOfIdentifierOrLiteral(declaration.name);
142158
+ var objectType = typeChecker.getTypeAtLocation(parent);
142159
+ documentation = ts.firstDefined(objectType.isUnion() ? objectType.types : [objectType], function (t) {
142160
+ var prop = t.getProperty(name_4);
142161
+ return prop ? prop.getDocumentationComment(typeChecker) : undefined;
142162
+ }) || ts.emptyArray;
142163
+ }
142164
+ }
141945
142165
  if (tags.length === 0 && !hasMultipleSignatures) {
141946
142166
  tags = symbol.getContextualJsDocTags(enclosingDeclaration, typeChecker);
141947
142167
  }
@@ -155475,51 +155695,53 @@ var ts;
155475
155695
  (function (ts) {
155476
155696
  var refactor;
155477
155697
  (function (refactor) {
155698
+ var _a;
155478
155699
  var refactorName = "Convert import";
155479
- var namespaceToNamedAction = {
155480
- name: "Convert namespace import to named imports",
155481
- description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message,
155482
- kind: "refactor.rewrite.import.named",
155483
- };
155484
- var namedToNamespaceAction = {
155485
- name: "Convert named imports to namespace import",
155486
- description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message,
155487
- kind: "refactor.rewrite.import.namespace",
155488
- };
155700
+ var actions = (_a = {},
155701
+ _a[0 /* Named */] = {
155702
+ name: "Convert namespace import to named imports",
155703
+ description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message,
155704
+ kind: "refactor.rewrite.import.named",
155705
+ },
155706
+ _a[2 /* Namespace */] = {
155707
+ name: "Convert named imports to namespace import",
155708
+ description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message,
155709
+ kind: "refactor.rewrite.import.namespace",
155710
+ },
155711
+ _a[1 /* Default */] = {
155712
+ name: "Convert named imports to default import",
155713
+ description: ts.Diagnostics.Convert_named_imports_to_default_import.message,
155714
+ kind: "refactor.rewrite.import.default",
155715
+ },
155716
+ _a);
155489
155717
  refactor.registerRefactor(refactorName, {
155490
- kinds: [
155491
- namespaceToNamedAction.kind,
155492
- namedToNamespaceAction.kind
155493
- ],
155718
+ kinds: ts.getOwnValues(actions).map(function (a) { return a.kind; }),
155494
155719
  getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndNamespacedImports(context) {
155495
- var info = getImportToConvert(context, context.triggerReason === "invoked");
155720
+ var info = getImportConversionInfo(context, context.triggerReason === "invoked");
155496
155721
  if (!info)
155497
155722
  return ts.emptyArray;
155498
155723
  if (!refactor.isRefactorErrorInfo(info)) {
155499
- var namespaceImport = info.kind === 267 /* NamespaceImport */;
155500
- var action = namespaceImport ? namespaceToNamedAction : namedToNamespaceAction;
155724
+ var action = actions[info.convertTo];
155501
155725
  return [{ name: refactorName, description: action.description, actions: [action] }];
155502
155726
  }
155503
155727
  if (context.preferences.provideRefactorNotApplicableReason) {
155504
- return [
155505
- { name: refactorName, description: namespaceToNamedAction.description,
155506
- actions: [__assign(__assign({}, namespaceToNamedAction), { notApplicableReason: info.error })] },
155507
- { name: refactorName, description: namedToNamespaceAction.description,
155508
- actions: [__assign(__assign({}, namedToNamespaceAction), { notApplicableReason: info.error })] }
155509
- ];
155728
+ return ts.getOwnValues(actions).map(function (action) { return ({
155729
+ name: refactorName,
155730
+ description: action.description,
155731
+ actions: [__assign(__assign({}, action), { notApplicableReason: info.error })]
155732
+ }); });
155510
155733
  }
155511
155734
  return ts.emptyArray;
155512
155735
  },
155513
155736
  getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndNamespacedImports(context, actionName) {
155514
- ts.Debug.assert(actionName === namespaceToNamedAction.name || actionName === namedToNamespaceAction.name, "Unexpected action name");
155515
- var info = getImportToConvert(context);
155737
+ ts.Debug.assert(ts.some(ts.getOwnValues(actions), function (action) { return action.name === actionName; }), "Unexpected action name");
155738
+ var info = getImportConversionInfo(context);
155516
155739
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
155517
155740
  var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, info); });
155518
155741
  return { edits: edits, renameFilename: undefined, renameLocation: undefined };
155519
155742
  }
155520
155743
  });
155521
- // Can convert imports of the form `import * as m from "m";` or `import d, { x, y } from "m";`.
155522
- function getImportToConvert(context, considerPartialSpans) {
155744
+ function getImportConversionInfo(context, considerPartialSpans) {
155523
155745
  if (considerPartialSpans === void 0) { considerPartialSpans = true; }
155524
155746
  var file = context.file;
155525
155747
  var span = ts.getRefactorContextSpan(context);
@@ -155538,15 +155760,23 @@ var ts;
155538
155760
  if (!importClause.namedBindings) {
155539
155761
  return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_namespace_import_or_named_imports) };
155540
155762
  }
155541
- return importClause.namedBindings;
155763
+ if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
155764
+ return { convertTo: 0 /* Named */, import: importClause.namedBindings };
155765
+ }
155766
+ var compilerOptions = context.program.getCompilerOptions();
155767
+ var shouldUseDefault = ts.getAllowSyntheticDefaultImports(compilerOptions)
155768
+ && isExportEqualsModule(importClause.parent.moduleSpecifier, context.program.getTypeChecker());
155769
+ return shouldUseDefault
155770
+ ? { convertTo: 1 /* Default */, import: importClause.namedBindings }
155771
+ : { convertTo: 2 /* Namespace */, import: importClause.namedBindings };
155542
155772
  }
155543
- function doChange(sourceFile, program, changes, toConvert) {
155773
+ function doChange(sourceFile, program, changes, info) {
155544
155774
  var checker = program.getTypeChecker();
155545
- if (toConvert.kind === 267 /* NamespaceImport */) {
155546
- doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
155775
+ if (info.convertTo === 0 /* Named */) {
155776
+ doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
155547
155777
  }
155548
155778
  else {
155549
- doChangeNamedToNamespace(sourceFile, checker, changes, toConvert);
155779
+ doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, info.import, info.convertTo === 1 /* Default */);
155550
155780
  }
155551
155781
  }
155552
155782
  function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) {
@@ -155596,7 +155826,7 @@ var ts;
155596
155826
  function getLeftOfPropertyAccessOrQualifiedName(propertyAccessOrQualifiedName) {
155597
155827
  return ts.isPropertyAccessExpression(propertyAccessOrQualifiedName) ? propertyAccessOrQualifiedName.expression : propertyAccessOrQualifiedName.left;
155598
155828
  }
155599
- function doChangeNamedToNamespace(sourceFile, checker, changes, toConvert) {
155829
+ function doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, toConvert, shouldUseDefault) {
155600
155830
  var importDecl = toConvert.parent.parent;
155601
155831
  var moduleSpecifier = importDecl.moduleSpecifier;
155602
155832
  var toConvertSymbols = new ts.Set();
@@ -155647,7 +155877,9 @@ var ts;
155647
155877
  var element = _a[_i];
155648
155878
  _loop_17(element);
155649
155879
  }
155650
- changes.replaceNode(sourceFile, toConvert, ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName)));
155880
+ changes.replaceNode(sourceFile, toConvert, shouldUseDefault
155881
+ ? ts.factory.createIdentifier(namespaceImportName)
155882
+ : ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName)));
155651
155883
  if (neededNamedImports.size) {
155652
155884
  var newNamedImports = ts.arrayFrom(neededNamedImports.values()).map(function (element) {
155653
155885
  return ts.factory.createImportSpecifier(element.isTypeOnly, element.propertyName && ts.factory.createIdentifier(element.propertyName.text), ts.factory.createIdentifier(element.name.text));
@@ -155655,6 +155887,13 @@ var ts;
155655
155887
  changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, newNamedImports));
155656
155888
  }
155657
155889
  }
155890
+ function isExportEqualsModule(moduleSpecifier, checker) {
155891
+ var externalModule = checker.resolveExternalModuleName(moduleSpecifier);
155892
+ if (!externalModule)
155893
+ return false;
155894
+ var exportEquals = checker.resolveExternalModuleSymbol(externalModule);
155895
+ return externalModule !== exportEquals;
155896
+ }
155658
155897
  function updateImport(old, defaultImportName, elements) {
155659
155898
  return ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImportName, elements && elements.length ? ts.factory.createNamedImports(elements) : undefined), old.moduleSpecifier, /*assertClause*/ undefined);
155660
155899
  }
@@ -158934,7 +159173,7 @@ var ts;
158934
159173
  var convertParamsToDestructuredObject;
158935
159174
  (function (convertParamsToDestructuredObject) {
158936
159175
  var refactorName = "Convert parameters to destructured object";
158937
- var minimumParameterLength = 2;
159176
+ var minimumParameterLength = 1;
158938
159177
  var refactorDescription = ts.getLocaleSpecificMessage(ts.Diagnostics.Convert_parameters_to_destructured_object);
158939
159178
  var toDestructuredAction = {
158940
159179
  name: refactorName,