typescript 4.6.0-dev.20220129 → 4.6.0-dev.20220202

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.20220129";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220202";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -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 */
@@ -46863,8 +46863,8 @@ var ts;
46863
46863
  TypeFacts[TypeFacts["AllTypeofNE"] = 556800] = "AllTypeofNE";
46864
46864
  TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts";
46865
46865
  // Masks
46866
- TypeFacts[TypeFacts["OrFactsMask"] = 8288] = "OrFactsMask";
46867
- TypeFacts[TypeFacts["AndFactsMask"] = 16768927] = "AndFactsMask";
46866
+ TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
46867
+ TypeFacts[TypeFacts["AndFactsMask"] = 16768959] = "AndFactsMask";
46868
46868
  })(TypeFacts || (TypeFacts = {}));
46869
46869
  var typeofEQFacts = new ts.Map(ts.getEntries({
46870
46870
  string: 1 /* TypeofEQString */,
@@ -67972,7 +67972,10 @@ var ts;
67972
67972
  (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ :
67973
67973
  (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
67974
67974
  }
67975
- if (flags & 524288 /* Object */ && !ignoreObjects) {
67975
+ if (flags & 524288 /* Object */) {
67976
+ if (ignoreObjects) {
67977
+ return 16768959 /* AndFactsMask */; // This is the identity element for computing type facts of intersection.
67978
+ }
67976
67979
  return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ?
67977
67980
  strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ :
67978
67981
  isFunctionObjectType(type) ?
@@ -68020,7 +68023,7 @@ var ts;
68020
68023
  oredFacts |= f;
68021
68024
  andedFacts &= f;
68022
68025
  }
68023
- return oredFacts & 8288 /* OrFactsMask */ | andedFacts & 16768927 /* AndFactsMask */;
68026
+ return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 16768959 /* AndFactsMask */;
68024
68027
  }
68025
68028
  function getTypeWithFacts(type, include) {
68026
68029
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
@@ -69980,6 +69983,9 @@ var ts;
69980
69983
  return getTypeOfSymbol(symbol);
69981
69984
  }
69982
69985
  function checkIdentifier(node, checkMode) {
69986
+ if (ts.isThisInTypeQuery(node)) {
69987
+ return checkThisExpression(node);
69988
+ }
69983
69989
  var symbol = getResolvedSymbol(node);
69984
69990
  if (symbol === unknownSymbol) {
69985
69991
  return errorType;
@@ -71771,7 +71777,8 @@ var ts;
71771
71777
  var links = getNodeLinks(node.expression);
71772
71778
  if (!links.resolvedType) {
71773
71779
  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 */) {
71780
+ && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */
71781
+ && node.parent.kind !== 171 /* GetAccessor */ && node.parent.kind !== 172 /* SetAccessor */) {
71775
71782
  return links.resolvedType = errorType;
71776
71783
  }
71777
71784
  links.resolvedType = checkExpression(node.expression);
@@ -75719,6 +75726,10 @@ var ts;
75719
75726
  return restParameter.escapedName;
75720
75727
  }
75721
75728
  function getParameterIdentifierNameAtPosition(signature, pos) {
75729
+ var _a;
75730
+ if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 315 /* JSDocFunctionType */) {
75731
+ return undefined;
75732
+ }
75722
75733
  var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
75723
75734
  if (pos < paramCount) {
75724
75735
  var param = signature.parameters[pos];
@@ -84483,7 +84494,10 @@ var ts;
84483
84494
  case 80 /* PrivateIdentifier */:
84484
84495
  case 205 /* PropertyAccessExpression */:
84485
84496
  case 160 /* QualifiedName */:
84486
- return getSymbolOfNameOrPropertyAccessExpression(node);
84497
+ if (!ts.isThisInTypeQuery(node)) {
84498
+ return getSymbolOfNameOrPropertyAccessExpression(node);
84499
+ }
84500
+ // falls through
84487
84501
  case 108 /* ThisKeyword */:
84488
84502
  var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false);
84489
84503
  if (ts.isFunctionLike(container)) {
@@ -94457,6 +94471,7 @@ var ts;
94457
94471
  var exportedVariableStatement = false;
94458
94472
  var enabledSubstitutions;
94459
94473
  var enclosingFunctionFlags;
94474
+ var parametersWithPrecedingObjectRestOrSpread;
94460
94475
  var enclosingSuperContainerFlags = 0;
94461
94476
  var hierarchyFacts = 0;
94462
94477
  var currentSourceFile;
@@ -94913,6 +94928,7 @@ var ts;
94913
94928
  /*incrementor*/ undefined,
94914
94929
  /*statement*/ convertForOfStatementHead(node, getValue)),
94915
94930
  /*location*/ node), 256 /* NoTokenTrailingSourceMaps */);
94931
+ ts.setOriginalNode(forStatement, node);
94916
94932
  return factory.createTryStatement(factory.createBlock([
94917
94933
  factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement)
94918
94934
  ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([
@@ -94930,7 +94946,19 @@ var ts;
94930
94946
  ]), 1 /* SingleLine */))
94931
94947
  ]));
94932
94948
  }
94949
+ function parameterVisitor(node) {
94950
+ ts.Debug.assertNode(node, ts.isParameter);
94951
+ return visitParameter(node);
94952
+ }
94933
94953
  function visitParameter(node) {
94954
+ if (parametersWithPrecedingObjectRestOrSpread === null || parametersWithPrecedingObjectRestOrSpread === void 0 ? void 0 : parametersWithPrecedingObjectRestOrSpread.has(node)) {
94955
+ return factory.updateParameterDeclaration(node,
94956
+ /*decorators*/ undefined,
94957
+ /*modifiers*/ undefined, node.dotDotDotToken, ts.isBindingPattern(node.name) ? factory.getGeneratedNameForNode(node) : node.name,
94958
+ /*questionToken*/ undefined,
94959
+ /*type*/ undefined,
94960
+ /*initializer*/ undefined);
94961
+ }
94934
94962
  if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
94935
94963
  // Binding patterns are converted into a generated name and are
94936
94964
  // evaluated inside the function body.
@@ -94942,85 +94970,119 @@ var ts;
94942
94970
  }
94943
94971
  return ts.visitEachChild(node, visitor, context);
94944
94972
  }
94973
+ function collectParametersWithPrecedingObjectRestOrSpread(node) {
94974
+ var parameters;
94975
+ for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
94976
+ var parameter = _a[_i];
94977
+ if (parameters) {
94978
+ parameters.add(parameter);
94979
+ }
94980
+ else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
94981
+ parameters = new ts.Set();
94982
+ }
94983
+ }
94984
+ return parameters;
94985
+ }
94945
94986
  function visitConstructorDeclaration(node) {
94946
94987
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
94947
- enclosingFunctionFlags = 0 /* Normal */;
94988
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
94989
+ enclosingFunctionFlags = ts.getFunctionFlags(node);
94990
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94948
94991
  var updated = factory.updateConstructorDeclaration(node,
94949
- /*decorators*/ undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
94992
+ /*decorators*/ undefined, node.modifiers, ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node));
94950
94993
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
94994
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
94951
94995
  return updated;
94952
94996
  }
94953
94997
  function visitGetAccessorDeclaration(node) {
94954
94998
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
94955
- enclosingFunctionFlags = 0 /* Normal */;
94999
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95000
+ enclosingFunctionFlags = ts.getFunctionFlags(node);
95001
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94956
95002
  var updated = factory.updateGetAccessorDeclaration(node,
94957
- /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context),
95003
+ /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context),
94958
95004
  /*type*/ undefined, transformFunctionBody(node));
94959
95005
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95006
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
94960
95007
  return updated;
94961
95008
  }
94962
95009
  function visitSetAccessorDeclaration(node) {
94963
95010
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
94964
- enclosingFunctionFlags = 0 /* Normal */;
95011
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95012
+ enclosingFunctionFlags = ts.getFunctionFlags(node);
95013
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94965
95014
  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));
95015
+ /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node));
94967
95016
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95017
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
94968
95018
  return updated;
94969
95019
  }
94970
95020
  function visitMethodDeclaration(node) {
94971
95021
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95022
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
94972
95023
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95024
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94973
95025
  var updated = factory.updateMethodDeclaration(node,
94974
95026
  /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */
94975
95027
  ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
94976
95028
  : node.modifiers, enclosingFunctionFlags & 2 /* Async */
94977
95029
  ? undefined
94978
95030
  : 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),
95031
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
94980
95032
  /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
94981
95033
  ? transformAsyncGeneratorFunctionBody(node)
94982
95034
  : transformFunctionBody(node));
94983
95035
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95036
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
94984
95037
  return updated;
94985
95038
  }
94986
95039
  function visitFunctionDeclaration(node) {
94987
95040
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95041
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
94988
95042
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95043
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94989
95044
  var updated = factory.updateFunctionDeclaration(node,
94990
95045
  /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */
94991
95046
  ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
94992
95047
  : node.modifiers, enclosingFunctionFlags & 2 /* Async */
94993
95048
  ? undefined
94994
95049
  : node.asteriskToken, node.name,
94995
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95050
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
94996
95051
  /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
94997
95052
  ? transformAsyncGeneratorFunctionBody(node)
94998
95053
  : transformFunctionBody(node));
94999
95054
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95055
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95000
95056
  return updated;
95001
95057
  }
95002
95058
  function visitArrowFunction(node) {
95003
95059
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95060
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95004
95061
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95062
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95005
95063
  var updated = factory.updateArrowFunction(node, node.modifiers,
95006
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95064
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
95007
95065
  /*type*/ undefined, node.equalsGreaterThanToken, transformFunctionBody(node));
95008
95066
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95067
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95009
95068
  return updated;
95010
95069
  }
95011
95070
  function visitFunctionExpression(node) {
95012
95071
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95072
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95013
95073
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95074
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95014
95075
  var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */
95015
95076
  ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
95016
95077
  : node.modifiers, enclosingFunctionFlags & 2 /* Async */
95017
95078
  ? undefined
95018
95079
  : node.asteriskToken, node.name,
95019
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95080
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
95020
95081
  /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
95021
95082
  ? transformAsyncGeneratorFunctionBody(node)
95022
95083
  : transformFunctionBody(node));
95023
95084
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95085
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95024
95086
  return updated;
95025
95087
  }
95026
95088
  function transformAsyncGeneratorFunctionBody(node) {
@@ -95081,16 +95143,71 @@ var ts;
95081
95143
  return body;
95082
95144
  }
95083
95145
  function appendObjectRestAssignmentsIfNeeded(statements, node) {
95146
+ var containsPrecedingObjectRestOrSpread = false;
95084
95147
  for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
95085
95148
  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,
95149
+ if (containsPrecedingObjectRestOrSpread) {
95150
+ if (ts.isBindingPattern(parameter.name)) {
95151
+ // In cases where a binding pattern is simply '[]' or '{}',
95152
+ // we usually don't want to emit a var declaration; however, in the presence
95153
+ // of an initializer, we must emit that expression to preserve side effects.
95154
+ //
95155
+ // NOTE: see `insertDefaultValueAssignmentForBindingPattern` in es2015.ts
95156
+ if (parameter.name.elements.length > 0) {
95157
+ var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter));
95158
+ if (ts.some(declarations)) {
95159
+ var declarationList = factory.createVariableDeclarationList(declarations);
95160
+ var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList);
95161
+ ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
95162
+ statements = ts.append(statements, statement);
95163
+ }
95164
+ }
95165
+ else if (parameter.initializer) {
95166
+ var name = factory.getGeneratedNameForNode(parameter);
95167
+ var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression);
95168
+ var assignment = factory.createAssignment(name, initializer);
95169
+ var statement = factory.createExpressionStatement(assignment);
95170
+ ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
95171
+ statements = ts.append(statements, statement);
95172
+ }
95173
+ }
95174
+ else if (parameter.initializer) {
95175
+ // Converts a parameter initializer into a function body statement, i.e.:
95176
+ //
95177
+ // function f(x = 1) { }
95178
+ //
95179
+ // becomes
95180
+ //
95181
+ // function f(x) {
95182
+ // if (typeof x === "undefined") { x = 1; }
95183
+ // }
95184
+ var name = factory.cloneNode(parameter.name);
95185
+ ts.setTextRange(name, parameter.name);
95186
+ ts.setEmitFlags(name, 48 /* NoSourceMap */);
95187
+ var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression);
95188
+ ts.addEmitFlags(initializer, 48 /* NoSourceMap */ | 1536 /* NoComments */);
95189
+ var assignment = factory.createAssignment(name, initializer);
95190
+ ts.setTextRange(assignment, parameter);
95191
+ ts.setEmitFlags(assignment, 1536 /* NoComments */);
95192
+ var block = factory.createBlock([factory.createExpressionStatement(assignment)]);
95193
+ ts.setTextRange(block, parameter);
95194
+ ts.setEmitFlags(block, 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */);
95195
+ var typeCheck = factory.createTypeCheck(factory.cloneNode(parameter.name), "undefined");
95196
+ var statement = factory.createIfStatement(typeCheck, block);
95197
+ ts.startOnNewLine(statement);
95198
+ ts.setTextRange(statement, parameter);
95199
+ ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */);
95200
+ statements = ts.append(statements, statement);
95201
+ }
95202
+ }
95203
+ else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
95204
+ containsPrecedingObjectRestOrSpread = true;
95205
+ var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter),
95089
95206
  /*doNotRecordTempVariablesInLine*/ false,
95090
95207
  /*skipInitializer*/ true);
95091
95208
  if (ts.some(declarations)) {
95092
- var statement = factory.createVariableStatement(
95093
- /*modifiers*/ undefined, factory.createVariableDeclarationList(declarations));
95209
+ var declarationList = factory.createVariableDeclarationList(declarations);
95210
+ var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList);
95094
95211
  ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
95095
95212
  statements = ts.append(statements, statement);
95096
95213
  }
@@ -98341,10 +98458,12 @@ var ts;
98341
98458
  // variables declared in the loop initializer that will be changed inside the loop
98342
98459
  var loopOutParameters = [];
98343
98460
  if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) {
98344
- var hasCapturedBindingsInForInitializer = shouldConvertInitializerOfForStatement(node);
98461
+ var hasCapturedBindingsInForHead = shouldConvertInitializerOfForStatement(node) ||
98462
+ shouldConvertConditionOfForStatement(node) ||
98463
+ shouldConvertIncrementorOfForStatement(node);
98345
98464
  for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) {
98346
98465
  var decl = _a[_i];
98347
- processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
98466
+ processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForHead);
98348
98467
  }
98349
98468
  }
98350
98469
  var currentState = { loopParameters: loopParameters, loopOutParameters: loopOutParameters };
@@ -98698,27 +98817,33 @@ var ts;
98698
98817
  caseClauses.push(factory.createCaseClause(factory.createStringLiteral(labelMarker), statements));
98699
98818
  });
98700
98819
  }
98701
- function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer) {
98820
+ function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForHead) {
98702
98821
  var name = decl.name;
98703
98822
  if (ts.isBindingPattern(name)) {
98704
98823
  for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
98705
98824
  var element = _a[_i];
98706
98825
  if (!ts.isOmittedExpression(element)) {
98707
- processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
98826
+ processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForHead);
98708
98827
  }
98709
98828
  }
98710
98829
  }
98711
98830
  else {
98712
98831
  loopParameters.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name));
98713
98832
  var checkFlags = resolver.getNodeCheckFlags(decl);
98714
- if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForInitializer) {
98833
+ if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) {
98715
98834
  var outParamName = factory.createUniqueName("out_" + ts.idText(name));
98716
98835
  var flags = 0;
98717
98836
  if (checkFlags & 4194304 /* NeedsLoopOutParameter */) {
98718
98837
  flags |= 1 /* Body */;
98719
98838
  }
98720
- if (ts.isForStatement(container) && container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
98721
- flags |= 2 /* Initializer */;
98839
+ if (ts.isForStatement(container)) {
98840
+ if (container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
98841
+ flags |= 2 /* Initializer */;
98842
+ }
98843
+ if (container.condition && resolver.isBindingCapturedByNode(container.condition, decl) ||
98844
+ container.incrementor && resolver.isBindingCapturedByNode(container.incrementor, decl)) {
98845
+ flags |= 1 /* Body */;
98846
+ }
98722
98847
  }
98723
98848
  loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName });
98724
98849
  }
@@ -141434,7 +141559,7 @@ var ts;
141434
141559
  if (typeChecker.isArgumentsSymbol(symbol)) {
141435
141560
  return "local var" /* localVariableElement */;
141436
141561
  }
141437
- if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location)) {
141562
+ if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) {
141438
141563
  return "parameter" /* parameterElement */;
141439
141564
  }
141440
141565
  var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol);
@@ -141529,7 +141654,7 @@ var ts;
141529
141654
  var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol);
141530
141655
  var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */;
141531
141656
  var hasAddedSymbolInfo = false;
141532
- var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location);
141657
+ var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location);
141533
141658
  var type;
141534
141659
  var printer;
141535
141660
  var documentationFromAlias;