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.
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20220129";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220202";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -5713,704 +5713,6 @@ var ts;
5713
5713
  },
5714
5714
  };
5715
5715
  })(ts || (ts = {}));
5716
- /* @internal */
5717
- var ts;
5718
- (function (ts) {
5719
- /**
5720
- * Internally, we represent paths as strings with '/' as the directory separator.
5721
- * When we make system calls (eg: LanguageServiceHost.getDirectory()),
5722
- * we expect the host to correctly handle paths in our specified format.
5723
- */
5724
- ts.directorySeparator = "/";
5725
- ts.altDirectorySeparator = "\\";
5726
- var urlSchemeSeparator = "://";
5727
- var backslashRegExp = /\\/g;
5728
- //// Path Tests
5729
- /**
5730
- * Determines whether a charCode corresponds to `/` or `\`.
5731
- */
5732
- function isAnyDirectorySeparator(charCode) {
5733
- return charCode === 47 /* slash */ || charCode === 92 /* backslash */;
5734
- }
5735
- ts.isAnyDirectorySeparator = isAnyDirectorySeparator;
5736
- /**
5737
- * Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.).
5738
- */
5739
- function isUrl(path) {
5740
- return getEncodedRootLength(path) < 0;
5741
- }
5742
- ts.isUrl = isUrl;
5743
- /**
5744
- * Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path
5745
- * like `c:`, `c:\` or `c:/`).
5746
- */
5747
- function isRootedDiskPath(path) {
5748
- return getEncodedRootLength(path) > 0;
5749
- }
5750
- ts.isRootedDiskPath = isRootedDiskPath;
5751
- /**
5752
- * Determines whether a path consists only of a path root.
5753
- */
5754
- function isDiskPathRoot(path) {
5755
- var rootLength = getEncodedRootLength(path);
5756
- return rootLength > 0 && rootLength === path.length;
5757
- }
5758
- ts.isDiskPathRoot = isDiskPathRoot;
5759
- /**
5760
- * Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.).
5761
- *
5762
- * ```ts
5763
- * // POSIX
5764
- * pathIsAbsolute("/path/to/file.ext") === true
5765
- * // DOS
5766
- * pathIsAbsolute("c:/path/to/file.ext") === true
5767
- * // URL
5768
- * pathIsAbsolute("file:///path/to/file.ext") === true
5769
- * // Non-absolute
5770
- * pathIsAbsolute("path/to/file.ext") === false
5771
- * pathIsAbsolute("./path/to/file.ext") === false
5772
- * ```
5773
- */
5774
- function pathIsAbsolute(path) {
5775
- return getEncodedRootLength(path) !== 0;
5776
- }
5777
- ts.pathIsAbsolute = pathIsAbsolute;
5778
- /**
5779
- * Determines whether a path starts with a relative path component (i.e. `.` or `..`).
5780
- */
5781
- function pathIsRelative(path) {
5782
- return /^\.\.?($|[\\/])/.test(path);
5783
- }
5784
- ts.pathIsRelative = pathIsRelative;
5785
- /**
5786
- * Determines whether a path is neither relative nor absolute, e.g. "path/to/file".
5787
- * Also known misleadingly as "non-relative".
5788
- */
5789
- function pathIsBareSpecifier(path) {
5790
- return !pathIsAbsolute(path) && !pathIsRelative(path);
5791
- }
5792
- ts.pathIsBareSpecifier = pathIsBareSpecifier;
5793
- function hasExtension(fileName) {
5794
- return ts.stringContains(getBaseFileName(fileName), ".");
5795
- }
5796
- ts.hasExtension = hasExtension;
5797
- function fileExtensionIs(path, extension) {
5798
- return path.length > extension.length && ts.endsWith(path, extension);
5799
- }
5800
- ts.fileExtensionIs = fileExtensionIs;
5801
- function fileExtensionIsOneOf(path, extensions) {
5802
- for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
5803
- var extension = extensions_1[_i];
5804
- if (fileExtensionIs(path, extension)) {
5805
- return true;
5806
- }
5807
- }
5808
- return false;
5809
- }
5810
- ts.fileExtensionIsOneOf = fileExtensionIsOneOf;
5811
- /**
5812
- * Determines whether a path has a trailing separator (`/` or `\\`).
5813
- */
5814
- function hasTrailingDirectorySeparator(path) {
5815
- return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1));
5816
- }
5817
- ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator;
5818
- //// Path Parsing
5819
- function isVolumeCharacter(charCode) {
5820
- return (charCode >= 97 /* a */ && charCode <= 122 /* z */) ||
5821
- (charCode >= 65 /* A */ && charCode <= 90 /* Z */);
5822
- }
5823
- function getFileUrlVolumeSeparatorEnd(url, start) {
5824
- var ch0 = url.charCodeAt(start);
5825
- if (ch0 === 58 /* colon */)
5826
- return start + 1;
5827
- if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) {
5828
- var ch2 = url.charCodeAt(start + 2);
5829
- if (ch2 === 97 /* a */ || ch2 === 65 /* A */)
5830
- return start + 3;
5831
- }
5832
- return -1;
5833
- }
5834
- /**
5835
- * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
5836
- * If the root is part of a URL, the twos-complement of the root length is returned.
5837
- */
5838
- function getEncodedRootLength(path) {
5839
- if (!path)
5840
- return 0;
5841
- var ch0 = path.charCodeAt(0);
5842
- // POSIX or UNC
5843
- if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) {
5844
- if (path.charCodeAt(1) !== ch0)
5845
- return 1; // POSIX: "/" (or non-normalized "\")
5846
- var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2);
5847
- if (p1 < 0)
5848
- return path.length; // UNC: "//server" or "\\server"
5849
- return p1 + 1; // UNC: "//server/" or "\\server\"
5850
- }
5851
- // DOS
5852
- if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) {
5853
- var ch2 = path.charCodeAt(2);
5854
- if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */)
5855
- return 3; // DOS: "c:/" or "c:\"
5856
- if (path.length === 2)
5857
- return 2; // DOS: "c:" (but not "c:d")
5858
- }
5859
- // URL
5860
- var schemeEnd = path.indexOf(urlSchemeSeparator);
5861
- if (schemeEnd !== -1) {
5862
- var authorityStart = schemeEnd + urlSchemeSeparator.length;
5863
- var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart);
5864
- if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path"
5865
- // For local "file" URLs, include the leading DOS volume (if present).
5866
- // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a
5867
- // special case interpreted as "the machine from which the URL is being interpreted".
5868
- var scheme = path.slice(0, schemeEnd);
5869
- var authority = path.slice(authorityStart, authorityEnd);
5870
- if (scheme === "file" && (authority === "" || authority === "localhost") &&
5871
- isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
5872
- var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
5873
- if (volumeSeparatorEnd !== -1) {
5874
- if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) {
5875
- // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/"
5876
- return ~(volumeSeparatorEnd + 1);
5877
- }
5878
- if (volumeSeparatorEnd === path.length) {
5879
- // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a"
5880
- // but not "file:///c:d" or "file:///c%3ad"
5881
- return ~volumeSeparatorEnd;
5882
- }
5883
- }
5884
- }
5885
- return ~(authorityEnd + 1); // URL: "file://server/", "http://server/"
5886
- }
5887
- return ~path.length; // URL: "file://server", "http://server"
5888
- }
5889
- // relative
5890
- return 0;
5891
- }
5892
- /**
5893
- * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
5894
- *
5895
- * For example:
5896
- * ```ts
5897
- * getRootLength("a") === 0 // ""
5898
- * getRootLength("/") === 1 // "/"
5899
- * getRootLength("c:") === 2 // "c:"
5900
- * getRootLength("c:d") === 0 // ""
5901
- * getRootLength("c:/") === 3 // "c:/"
5902
- * getRootLength("c:\\") === 3 // "c:\\"
5903
- * getRootLength("//server") === 7 // "//server"
5904
- * getRootLength("//server/share") === 8 // "//server/"
5905
- * getRootLength("\\\\server") === 7 // "\\\\server"
5906
- * getRootLength("\\\\server\\share") === 8 // "\\\\server\\"
5907
- * getRootLength("file:///path") === 8 // "file:///"
5908
- * getRootLength("file:///c:") === 10 // "file:///c:"
5909
- * getRootLength("file:///c:d") === 8 // "file:///"
5910
- * getRootLength("file:///c:/path") === 11 // "file:///c:/"
5911
- * getRootLength("file://server") === 13 // "file://server"
5912
- * getRootLength("file://server/path") === 14 // "file://server/"
5913
- * getRootLength("http://server") === 13 // "http://server"
5914
- * getRootLength("http://server/path") === 14 // "http://server/"
5915
- * ```
5916
- */
5917
- function getRootLength(path) {
5918
- var rootLength = getEncodedRootLength(path);
5919
- return rootLength < 0 ? ~rootLength : rootLength;
5920
- }
5921
- ts.getRootLength = getRootLength;
5922
- function getDirectoryPath(path) {
5923
- path = normalizeSlashes(path);
5924
- // If the path provided is itself the root, then return it.
5925
- var rootLength = getRootLength(path);
5926
- if (rootLength === path.length)
5927
- return path;
5928
- // return the leading portion of the path up to the last (non-terminal) directory separator
5929
- // but not including any trailing directory separator.
5930
- path = removeTrailingDirectorySeparator(path);
5931
- return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator)));
5932
- }
5933
- ts.getDirectoryPath = getDirectoryPath;
5934
- function getBaseFileName(path, extensions, ignoreCase) {
5935
- path = normalizeSlashes(path);
5936
- // if the path provided is itself the root, then it has not file name.
5937
- var rootLength = getRootLength(path);
5938
- if (rootLength === path.length)
5939
- return "";
5940
- // return the trailing portion of the path starting after the last (non-terminal) directory
5941
- // separator but not including any trailing directory separator.
5942
- path = removeTrailingDirectorySeparator(path);
5943
- var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1));
5944
- var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined;
5945
- return extension ? name.slice(0, name.length - extension.length) : name;
5946
- }
5947
- ts.getBaseFileName = getBaseFileName;
5948
- function tryGetExtensionFromPath(path, extension, stringEqualityComparer) {
5949
- if (!ts.startsWith(extension, "."))
5950
- extension = "." + extension;
5951
- if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) {
5952
- var pathExtension = path.slice(path.length - extension.length);
5953
- if (stringEqualityComparer(pathExtension, extension)) {
5954
- return pathExtension;
5955
- }
5956
- }
5957
- }
5958
- function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) {
5959
- if (typeof extensions === "string") {
5960
- return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || "";
5961
- }
5962
- for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) {
5963
- var extension = extensions_2[_i];
5964
- var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer);
5965
- if (result)
5966
- return result;
5967
- }
5968
- return "";
5969
- }
5970
- function getAnyExtensionFromPath(path, extensions, ignoreCase) {
5971
- // Retrieves any string from the final "." onwards from a base file name.
5972
- // Unlike extensionFromPath, which throws an exception on unrecognized extensions.
5973
- if (extensions) {
5974
- return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive);
5975
- }
5976
- var baseFileName = getBaseFileName(path);
5977
- var extensionIndex = baseFileName.lastIndexOf(".");
5978
- if (extensionIndex >= 0) {
5979
- return baseFileName.substring(extensionIndex);
5980
- }
5981
- return "";
5982
- }
5983
- ts.getAnyExtensionFromPath = getAnyExtensionFromPath;
5984
- function pathComponents(path, rootLength) {
5985
- var root = path.substring(0, rootLength);
5986
- var rest = path.substring(rootLength).split(ts.directorySeparator);
5987
- if (rest.length && !ts.lastOrUndefined(rest))
5988
- rest.pop();
5989
- return __spreadArray([root], rest, true);
5990
- }
5991
- /**
5992
- * Parse a path into an array containing a root component (at index 0) and zero or more path
5993
- * components (at indices > 0). The result is not normalized.
5994
- * If the path is relative, the root component is `""`.
5995
- * If the path is absolute, the root component includes the first path separator (`/`).
5996
- *
5997
- * ```ts
5998
- * // POSIX
5999
- * getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"]
6000
- * getPathComponents("/path/to/") === ["/", "path", "to"]
6001
- * getPathComponents("/") === ["/"]
6002
- * // DOS
6003
- * getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"]
6004
- * getPathComponents("c:/path/to/") === ["c:/", "path", "to"]
6005
- * getPathComponents("c:/") === ["c:/"]
6006
- * getPathComponents("c:") === ["c:"]
6007
- * // URL
6008
- * getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"]
6009
- * getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"]
6010
- * getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"]
6011
- * getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"]
6012
- * getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"]
6013
- * getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"]
6014
- * getPathComponents("file://server/") === ["file://server/"]
6015
- * getPathComponents("file://server") === ["file://server"]
6016
- * getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"]
6017
- * getPathComponents("file:///path/to/") === ["file:///", "path", "to"]
6018
- * getPathComponents("file:///") === ["file:///"]
6019
- * getPathComponents("file://") === ["file://"]
6020
- */
6021
- function getPathComponents(path, currentDirectory) {
6022
- if (currentDirectory === void 0) { currentDirectory = ""; }
6023
- path = combinePaths(currentDirectory, path);
6024
- return pathComponents(path, getRootLength(path));
6025
- }
6026
- ts.getPathComponents = getPathComponents;
6027
- //// Path Formatting
6028
- /**
6029
- * Formats a parsed path consisting of a root component (at index 0) and zero or more path
6030
- * segments (at indices > 0).
6031
- *
6032
- * ```ts
6033
- * getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext"
6034
- * ```
6035
- */
6036
- function getPathFromPathComponents(pathComponents) {
6037
- if (pathComponents.length === 0)
6038
- return "";
6039
- var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
6040
- return root + pathComponents.slice(1).join(ts.directorySeparator);
6041
- }
6042
- ts.getPathFromPathComponents = getPathFromPathComponents;
6043
- //// Path Normalization
6044
- /**
6045
- * Normalize path separators, converting `\` into `/`.
6046
- */
6047
- function normalizeSlashes(path) {
6048
- var index = path.indexOf("\\");
6049
- if (index === -1) {
6050
- return path;
6051
- }
6052
- backslashRegExp.lastIndex = index; // prime regex with known position
6053
- return path.replace(backslashRegExp, ts.directorySeparator);
6054
- }
6055
- ts.normalizeSlashes = normalizeSlashes;
6056
- /**
6057
- * Reduce an array of path components to a more simplified path by navigating any
6058
- * `"."` or `".."` entries in the path.
6059
- */
6060
- function reducePathComponents(components) {
6061
- if (!ts.some(components))
6062
- return [];
6063
- var reduced = [components[0]];
6064
- for (var i = 1; i < components.length; i++) {
6065
- var component = components[i];
6066
- if (!component)
6067
- continue;
6068
- if (component === ".")
6069
- continue;
6070
- if (component === "..") {
6071
- if (reduced.length > 1) {
6072
- if (reduced[reduced.length - 1] !== "..") {
6073
- reduced.pop();
6074
- continue;
6075
- }
6076
- }
6077
- else if (reduced[0])
6078
- continue;
6079
- }
6080
- reduced.push(component);
6081
- }
6082
- return reduced;
6083
- }
6084
- ts.reducePathComponents = reducePathComponents;
6085
- /**
6086
- * Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified.
6087
- *
6088
- * ```ts
6089
- * // Non-rooted
6090
- * combinePaths("path", "to", "file.ext") === "path/to/file.ext"
6091
- * combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext"
6092
- * // POSIX
6093
- * combinePaths("/path", "to", "file.ext") === "/path/to/file.ext"
6094
- * combinePaths("/path", "/to", "file.ext") === "/to/file.ext"
6095
- * // DOS
6096
- * combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext"
6097
- * combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext"
6098
- * // URL
6099
- * combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext"
6100
- * combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext"
6101
- * ```
6102
- */
6103
- function combinePaths(path) {
6104
- var paths = [];
6105
- for (var _i = 1; _i < arguments.length; _i++) {
6106
- paths[_i - 1] = arguments[_i];
6107
- }
6108
- if (path)
6109
- path = normalizeSlashes(path);
6110
- for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
6111
- var relativePath = paths_1[_a];
6112
- if (!relativePath)
6113
- continue;
6114
- relativePath = normalizeSlashes(relativePath);
6115
- if (!path || getRootLength(relativePath) !== 0) {
6116
- path = relativePath;
6117
- }
6118
- else {
6119
- path = ensureTrailingDirectorySeparator(path) + relativePath;
6120
- }
6121
- }
6122
- return path;
6123
- }
6124
- ts.combinePaths = combinePaths;
6125
- /**
6126
- * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any
6127
- * `.` and `..` path components are resolved. Trailing directory separators are preserved.
6128
- *
6129
- * ```ts
6130
- * resolvePath("/path", "to", "file.ext") === "path/to/file.ext"
6131
- * resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/"
6132
- * resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext"
6133
- * ```
6134
- */
6135
- function resolvePath(path) {
6136
- var paths = [];
6137
- for (var _i = 1; _i < arguments.length; _i++) {
6138
- paths[_i - 1] = arguments[_i];
6139
- }
6140
- return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArray([path], paths, false)) : normalizeSlashes(path));
6141
- }
6142
- ts.resolvePath = resolvePath;
6143
- /**
6144
- * Parse a path into an array containing a root component (at index 0) and zero or more path
6145
- * components (at indices > 0). The result is normalized.
6146
- * If the path is relative, the root component is `""`.
6147
- * If the path is absolute, the root component includes the first path separator (`/`).
6148
- *
6149
- * ```ts
6150
- * getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"]
6151
- * ```
6152
- */
6153
- function getNormalizedPathComponents(path, currentDirectory) {
6154
- return reducePathComponents(getPathComponents(path, currentDirectory));
6155
- }
6156
- ts.getNormalizedPathComponents = getNormalizedPathComponents;
6157
- function getNormalizedAbsolutePath(fileName, currentDirectory) {
6158
- return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
6159
- }
6160
- ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
6161
- function normalizePath(path) {
6162
- path = normalizeSlashes(path);
6163
- // Most paths don't require normalization
6164
- if (!relativePathSegmentRegExp.test(path)) {
6165
- return path;
6166
- }
6167
- // Some paths only require cleanup of `/./` or leading `./`
6168
- var simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, "");
6169
- if (simplified !== path) {
6170
- path = simplified;
6171
- if (!relativePathSegmentRegExp.test(path)) {
6172
- return path;
6173
- }
6174
- }
6175
- // Other paths require full normalization
6176
- var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
6177
- return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
6178
- }
6179
- ts.normalizePath = normalizePath;
6180
- function getPathWithoutRoot(pathComponents) {
6181
- if (pathComponents.length === 0)
6182
- return "";
6183
- return pathComponents.slice(1).join(ts.directorySeparator);
6184
- }
6185
- function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
6186
- return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
6187
- }
6188
- ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
6189
- function toPath(fileName, basePath, getCanonicalFileName) {
6190
- var nonCanonicalizedPath = isRootedDiskPath(fileName)
6191
- ? normalizePath(fileName)
6192
- : getNormalizedAbsolutePath(fileName, basePath);
6193
- return getCanonicalFileName(nonCanonicalizedPath);
6194
- }
6195
- ts.toPath = toPath;
6196
- function normalizePathAndParts(path) {
6197
- path = normalizeSlashes(path);
6198
- var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
6199
- if (parts.length) {
6200
- var joinedParts = root + parts.join(ts.directorySeparator);
6201
- return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
6202
- }
6203
- else {
6204
- return { path: root, parts: parts };
6205
- }
6206
- }
6207
- ts.normalizePathAndParts = normalizePathAndParts;
6208
- function removeTrailingDirectorySeparator(path) {
6209
- if (hasTrailingDirectorySeparator(path)) {
6210
- return path.substr(0, path.length - 1);
6211
- }
6212
- return path;
6213
- }
6214
- ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
6215
- function ensureTrailingDirectorySeparator(path) {
6216
- if (!hasTrailingDirectorySeparator(path)) {
6217
- return path + ts.directorySeparator;
6218
- }
6219
- return path;
6220
- }
6221
- ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator;
6222
- /**
6223
- * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed
6224
- * with `./` or `../`) so as not to be confused with an unprefixed module name.
6225
- *
6226
- * ```ts
6227
- * ensurePathIsNonModuleName("/path/to/file.ext") === "/path/to/file.ext"
6228
- * ensurePathIsNonModuleName("./path/to/file.ext") === "./path/to/file.ext"
6229
- * ensurePathIsNonModuleName("../path/to/file.ext") === "../path/to/file.ext"
6230
- * ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext"
6231
- * ```
6232
- */
6233
- function ensurePathIsNonModuleName(path) {
6234
- return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path;
6235
- }
6236
- ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName;
6237
- function changeAnyExtension(path, ext, extensions, ignoreCase) {
6238
- var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path);
6239
- return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
6240
- }
6241
- ts.changeAnyExtension = changeAnyExtension;
6242
- //// Path Comparisons
6243
- // check path for these segments: '', '.'. '..'
6244
- var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/;
6245
- function comparePathsWorker(a, b, componentComparer) {
6246
- if (a === b)
6247
- return 0 /* EqualTo */;
6248
- if (a === undefined)
6249
- return -1 /* LessThan */;
6250
- if (b === undefined)
6251
- return 1 /* GreaterThan */;
6252
- // NOTE: Performance optimization - shortcut if the root segments differ as there would be no
6253
- // need to perform path reduction.
6254
- var aRoot = a.substring(0, getRootLength(a));
6255
- var bRoot = b.substring(0, getRootLength(b));
6256
- var result = ts.compareStringsCaseInsensitive(aRoot, bRoot);
6257
- if (result !== 0 /* EqualTo */) {
6258
- return result;
6259
- }
6260
- // NOTE: Performance optimization - shortcut if there are no relative path segments in
6261
- // the non-root portion of the path
6262
- var aRest = a.substring(aRoot.length);
6263
- var bRest = b.substring(bRoot.length);
6264
- if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) {
6265
- return componentComparer(aRest, bRest);
6266
- }
6267
- // The path contains a relative path segment. Normalize the paths and perform a slower component
6268
- // by component comparison.
6269
- var aComponents = reducePathComponents(getPathComponents(a));
6270
- var bComponents = reducePathComponents(getPathComponents(b));
6271
- var sharedLength = Math.min(aComponents.length, bComponents.length);
6272
- for (var i = 1; i < sharedLength; i++) {
6273
- var result_2 = componentComparer(aComponents[i], bComponents[i]);
6274
- if (result_2 !== 0 /* EqualTo */) {
6275
- return result_2;
6276
- }
6277
- }
6278
- return ts.compareValues(aComponents.length, bComponents.length);
6279
- }
6280
- /**
6281
- * Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively.
6282
- */
6283
- function comparePathsCaseSensitive(a, b) {
6284
- return comparePathsWorker(a, b, ts.compareStringsCaseSensitive);
6285
- }
6286
- ts.comparePathsCaseSensitive = comparePathsCaseSensitive;
6287
- /**
6288
- * Performs a case-insensitive comparison of two paths.
6289
- */
6290
- function comparePathsCaseInsensitive(a, b) {
6291
- return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive);
6292
- }
6293
- ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive;
6294
- function comparePaths(a, b, currentDirectory, ignoreCase) {
6295
- if (typeof currentDirectory === "string") {
6296
- a = combinePaths(currentDirectory, a);
6297
- b = combinePaths(currentDirectory, b);
6298
- }
6299
- else if (typeof currentDirectory === "boolean") {
6300
- ignoreCase = currentDirectory;
6301
- }
6302
- return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase));
6303
- }
6304
- ts.comparePaths = comparePaths;
6305
- function containsPath(parent, child, currentDirectory, ignoreCase) {
6306
- if (typeof currentDirectory === "string") {
6307
- parent = combinePaths(currentDirectory, parent);
6308
- child = combinePaths(currentDirectory, child);
6309
- }
6310
- else if (typeof currentDirectory === "boolean") {
6311
- ignoreCase = currentDirectory;
6312
- }
6313
- if (parent === undefined || child === undefined)
6314
- return false;
6315
- if (parent === child)
6316
- return true;
6317
- var parentComponents = reducePathComponents(getPathComponents(parent));
6318
- var childComponents = reducePathComponents(getPathComponents(child));
6319
- if (childComponents.length < parentComponents.length) {
6320
- return false;
6321
- }
6322
- var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive;
6323
- for (var i = 0; i < parentComponents.length; i++) {
6324
- var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer;
6325
- if (!equalityComparer(parentComponents[i], childComponents[i])) {
6326
- return false;
6327
- }
6328
- }
6329
- return true;
6330
- }
6331
- ts.containsPath = containsPath;
6332
- /**
6333
- * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback.
6334
- * Comparison is case-sensitive between the canonical paths.
6335
- *
6336
- * Use `containsPath` if file names are not already reduced and absolute.
6337
- */
6338
- function startsWithDirectory(fileName, directoryName, getCanonicalFileName) {
6339
- var canonicalFileName = getCanonicalFileName(fileName);
6340
- var canonicalDirectoryName = getCanonicalFileName(directoryName);
6341
- return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\");
6342
- }
6343
- ts.startsWithDirectory = startsWithDirectory;
6344
- //// Relative Paths
6345
- function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) {
6346
- var fromComponents = reducePathComponents(getPathComponents(from));
6347
- var toComponents = reducePathComponents(getPathComponents(to));
6348
- var start;
6349
- for (start = 0; start < fromComponents.length && start < toComponents.length; start++) {
6350
- var fromComponent = getCanonicalFileName(fromComponents[start]);
6351
- var toComponent = getCanonicalFileName(toComponents[start]);
6352
- var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer;
6353
- if (!comparer(fromComponent, toComponent))
6354
- break;
6355
- }
6356
- if (start === 0) {
6357
- return toComponents;
6358
- }
6359
- var components = toComponents.slice(start);
6360
- var relative = [];
6361
- for (; start < fromComponents.length; start++) {
6362
- relative.push("..");
6363
- }
6364
- return __spreadArray(__spreadArray([""], relative, true), components, true);
6365
- }
6366
- ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo;
6367
- function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
6368
- ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
6369
- var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
6370
- var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
6371
- var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
6372
- return getPathFromPathComponents(pathComponents);
6373
- }
6374
- ts.getRelativePathFromDirectory = getRelativePathFromDirectory;
6375
- function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
6376
- return !isRootedDiskPath(absoluteOrRelativePath)
6377
- ? absoluteOrRelativePath
6378
- : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
6379
- }
6380
- ts.convertToRelativePath = convertToRelativePath;
6381
- function getRelativePathFromFile(from, to, getCanonicalFileName) {
6382
- return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName));
6383
- }
6384
- ts.getRelativePathFromFile = getRelativePathFromFile;
6385
- function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
6386
- var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName);
6387
- var firstComponent = pathComponents[0];
6388
- if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) {
6389
- var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///";
6390
- pathComponents[0] = prefix + firstComponent;
6391
- }
6392
- return getPathFromPathComponents(pathComponents);
6393
- }
6394
- ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl;
6395
- function forEachAncestorDirectory(directory, callback) {
6396
- while (true) {
6397
- var result = callback(directory);
6398
- if (result !== undefined) {
6399
- return result;
6400
- }
6401
- var parentPath = getDirectoryPath(directory);
6402
- if (parentPath === directory) {
6403
- return undefined;
6404
- }
6405
- directory = parentPath;
6406
- }
6407
- }
6408
- ts.forEachAncestorDirectory = forEachAncestorDirectory;
6409
- function isNodeModulesDirectory(dirPath) {
6410
- return ts.endsWith(dirPath, "/node_modules");
6411
- }
6412
- ts.isNodeModulesDirectory = isNodeModulesDirectory;
6413
- })(ts || (ts = {}));
6414
5716
  var ts;
6415
5717
  (function (ts) {
6416
5718
  /**
@@ -7761,87 +7063,785 @@ var ts;
7761
7063
  default: return false;
7762
7064
  }
7763
7065
  }
7764
- catch (e) {
7765
- return false;
7766
- }
7767
- finally {
7768
- Error.stackTraceLimit = originalStackTraceLimit;
7769
- }
7770
- }
7771
- function fileExists(path) {
7772
- return fileSystemEntryExists(path, 0 /* File */);
7773
- }
7774
- function directoryExists(path) {
7775
- return fileSystemEntryExists(path, 1 /* Directory */);
7776
- }
7777
- function getDirectories(path) {
7778
- return getAccessibleFileSystemEntries(path).directories.slice();
7066
+ catch (e) {
7067
+ return false;
7068
+ }
7069
+ finally {
7070
+ Error.stackTraceLimit = originalStackTraceLimit;
7071
+ }
7072
+ }
7073
+ function fileExists(path) {
7074
+ return fileSystemEntryExists(path, 0 /* File */);
7075
+ }
7076
+ function directoryExists(path) {
7077
+ return fileSystemEntryExists(path, 1 /* Directory */);
7078
+ }
7079
+ function getDirectories(path) {
7080
+ return getAccessibleFileSystemEntries(path).directories.slice();
7081
+ }
7082
+ function realpath(path) {
7083
+ try {
7084
+ return realpathSync(path);
7085
+ }
7086
+ catch (_a) {
7087
+ return path;
7088
+ }
7089
+ }
7090
+ function getModifiedTime(path) {
7091
+ var _a;
7092
+ try {
7093
+ return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime;
7094
+ }
7095
+ catch (e) {
7096
+ return undefined;
7097
+ }
7098
+ }
7099
+ function setModifiedTime(path, time) {
7100
+ try {
7101
+ _fs.utimesSync(path, time, time);
7102
+ }
7103
+ catch (e) {
7104
+ return;
7105
+ }
7106
+ }
7107
+ function deleteFile(path) {
7108
+ try {
7109
+ return _fs.unlinkSync(path);
7110
+ }
7111
+ catch (e) {
7112
+ return;
7113
+ }
7114
+ }
7115
+ function createSHA256Hash(data) {
7116
+ var hash = _crypto.createHash("sha256");
7117
+ hash.update(data);
7118
+ return hash.digest("hex");
7119
+ }
7120
+ }
7121
+ var sys;
7122
+ if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") {
7123
+ // process and process.nextTick checks if current environment is node-like
7124
+ // process.browser check excludes webpack and browserify
7125
+ sys = getNodeSystem();
7126
+ }
7127
+ if (sys) {
7128
+ // patch writefile to create folder before writing the file
7129
+ patchWriteFileEnsuringDirectory(sys);
7130
+ }
7131
+ return sys;
7132
+ })();
7133
+ /*@internal*/
7134
+ function setSys(s) {
7135
+ ts.sys = s;
7136
+ }
7137
+ ts.setSys = setSys;
7138
+ if (ts.sys && ts.sys.getEnvironmentVariable) {
7139
+ setCustomPollingValues(ts.sys);
7140
+ ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))
7141
+ ? 1 /* Normal */
7142
+ : 0 /* None */);
7143
+ }
7144
+ if (ts.sys && ts.sys.debugMode) {
7145
+ ts.Debug.isDebugging = true;
7146
+ }
7147
+ })(ts || (ts = {}));
7148
+ /* @internal */
7149
+ var ts;
7150
+ (function (ts) {
7151
+ /**
7152
+ * Internally, we represent paths as strings with '/' as the directory separator.
7153
+ * When we make system calls (eg: LanguageServiceHost.getDirectory()),
7154
+ * we expect the host to correctly handle paths in our specified format.
7155
+ */
7156
+ ts.directorySeparator = "/";
7157
+ ts.altDirectorySeparator = "\\";
7158
+ var urlSchemeSeparator = "://";
7159
+ var backslashRegExp = /\\/g;
7160
+ //// Path Tests
7161
+ /**
7162
+ * Determines whether a charCode corresponds to `/` or `\`.
7163
+ */
7164
+ function isAnyDirectorySeparator(charCode) {
7165
+ return charCode === 47 /* slash */ || charCode === 92 /* backslash */;
7166
+ }
7167
+ ts.isAnyDirectorySeparator = isAnyDirectorySeparator;
7168
+ /**
7169
+ * Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.).
7170
+ */
7171
+ function isUrl(path) {
7172
+ return getEncodedRootLength(path) < 0;
7173
+ }
7174
+ ts.isUrl = isUrl;
7175
+ /**
7176
+ * Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path
7177
+ * like `c:`, `c:\` or `c:/`).
7178
+ */
7179
+ function isRootedDiskPath(path) {
7180
+ return getEncodedRootLength(path) > 0;
7181
+ }
7182
+ ts.isRootedDiskPath = isRootedDiskPath;
7183
+ /**
7184
+ * Determines whether a path consists only of a path root.
7185
+ */
7186
+ function isDiskPathRoot(path) {
7187
+ var rootLength = getEncodedRootLength(path);
7188
+ return rootLength > 0 && rootLength === path.length;
7189
+ }
7190
+ ts.isDiskPathRoot = isDiskPathRoot;
7191
+ /**
7192
+ * Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.).
7193
+ *
7194
+ * ```ts
7195
+ * // POSIX
7196
+ * pathIsAbsolute("/path/to/file.ext") === true
7197
+ * // DOS
7198
+ * pathIsAbsolute("c:/path/to/file.ext") === true
7199
+ * // URL
7200
+ * pathIsAbsolute("file:///path/to/file.ext") === true
7201
+ * // Non-absolute
7202
+ * pathIsAbsolute("path/to/file.ext") === false
7203
+ * pathIsAbsolute("./path/to/file.ext") === false
7204
+ * ```
7205
+ */
7206
+ function pathIsAbsolute(path) {
7207
+ return getEncodedRootLength(path) !== 0;
7208
+ }
7209
+ ts.pathIsAbsolute = pathIsAbsolute;
7210
+ /**
7211
+ * Determines whether a path starts with a relative path component (i.e. `.` or `..`).
7212
+ */
7213
+ function pathIsRelative(path) {
7214
+ return /^\.\.?($|[\\/])/.test(path);
7215
+ }
7216
+ ts.pathIsRelative = pathIsRelative;
7217
+ /**
7218
+ * Determines whether a path is neither relative nor absolute, e.g. "path/to/file".
7219
+ * Also known misleadingly as "non-relative".
7220
+ */
7221
+ function pathIsBareSpecifier(path) {
7222
+ return !pathIsAbsolute(path) && !pathIsRelative(path);
7223
+ }
7224
+ ts.pathIsBareSpecifier = pathIsBareSpecifier;
7225
+ function hasExtension(fileName) {
7226
+ return ts.stringContains(getBaseFileName(fileName), ".");
7227
+ }
7228
+ ts.hasExtension = hasExtension;
7229
+ function fileExtensionIs(path, extension) {
7230
+ return path.length > extension.length && ts.endsWith(path, extension);
7231
+ }
7232
+ ts.fileExtensionIs = fileExtensionIs;
7233
+ function fileExtensionIsOneOf(path, extensions) {
7234
+ for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
7235
+ var extension = extensions_1[_i];
7236
+ if (fileExtensionIs(path, extension)) {
7237
+ return true;
7238
+ }
7239
+ }
7240
+ return false;
7241
+ }
7242
+ ts.fileExtensionIsOneOf = fileExtensionIsOneOf;
7243
+ /**
7244
+ * Determines whether a path has a trailing separator (`/` or `\\`).
7245
+ */
7246
+ function hasTrailingDirectorySeparator(path) {
7247
+ return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1));
7248
+ }
7249
+ ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator;
7250
+ //// Path Parsing
7251
+ function isVolumeCharacter(charCode) {
7252
+ return (charCode >= 97 /* a */ && charCode <= 122 /* z */) ||
7253
+ (charCode >= 65 /* A */ && charCode <= 90 /* Z */);
7254
+ }
7255
+ function getFileUrlVolumeSeparatorEnd(url, start) {
7256
+ var ch0 = url.charCodeAt(start);
7257
+ if (ch0 === 58 /* colon */)
7258
+ return start + 1;
7259
+ if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) {
7260
+ var ch2 = url.charCodeAt(start + 2);
7261
+ if (ch2 === 97 /* a */ || ch2 === 65 /* A */)
7262
+ return start + 3;
7263
+ }
7264
+ return -1;
7265
+ }
7266
+ /**
7267
+ * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
7268
+ * If the root is part of a URL, the twos-complement of the root length is returned.
7269
+ */
7270
+ function getEncodedRootLength(path) {
7271
+ if (!path)
7272
+ return 0;
7273
+ var ch0 = path.charCodeAt(0);
7274
+ // POSIX or UNC
7275
+ if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) {
7276
+ if (path.charCodeAt(1) !== ch0)
7277
+ return 1; // POSIX: "/" (or non-normalized "\")
7278
+ var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2);
7279
+ if (p1 < 0)
7280
+ return path.length; // UNC: "//server" or "\\server"
7281
+ return p1 + 1; // UNC: "//server/" or "\\server\"
7282
+ }
7283
+ // DOS
7284
+ if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) {
7285
+ var ch2 = path.charCodeAt(2);
7286
+ if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */)
7287
+ return 3; // DOS: "c:/" or "c:\"
7288
+ if (path.length === 2)
7289
+ return 2; // DOS: "c:" (but not "c:d")
7290
+ }
7291
+ // URL
7292
+ var schemeEnd = path.indexOf(urlSchemeSeparator);
7293
+ if (schemeEnd !== -1) {
7294
+ var authorityStart = schemeEnd + urlSchemeSeparator.length;
7295
+ var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart);
7296
+ if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path"
7297
+ // For local "file" URLs, include the leading DOS volume (if present).
7298
+ // Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a
7299
+ // special case interpreted as "the machine from which the URL is being interpreted".
7300
+ var scheme = path.slice(0, schemeEnd);
7301
+ var authority = path.slice(authorityStart, authorityEnd);
7302
+ if (scheme === "file" && (authority === "" || authority === "localhost") &&
7303
+ isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
7304
+ var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
7305
+ if (volumeSeparatorEnd !== -1) {
7306
+ if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) {
7307
+ // URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/"
7308
+ return ~(volumeSeparatorEnd + 1);
7309
+ }
7310
+ if (volumeSeparatorEnd === path.length) {
7311
+ // URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a"
7312
+ // but not "file:///c:d" or "file:///c%3ad"
7313
+ return ~volumeSeparatorEnd;
7314
+ }
7315
+ }
7316
+ }
7317
+ return ~(authorityEnd + 1); // URL: "file://server/", "http://server/"
7318
+ }
7319
+ return ~path.length; // URL: "file://server", "http://server"
7320
+ }
7321
+ // relative
7322
+ return 0;
7323
+ }
7324
+ /**
7325
+ * Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
7326
+ *
7327
+ * For example:
7328
+ * ```ts
7329
+ * getRootLength("a") === 0 // ""
7330
+ * getRootLength("/") === 1 // "/"
7331
+ * getRootLength("c:") === 2 // "c:"
7332
+ * getRootLength("c:d") === 0 // ""
7333
+ * getRootLength("c:/") === 3 // "c:/"
7334
+ * getRootLength("c:\\") === 3 // "c:\\"
7335
+ * getRootLength("//server") === 7 // "//server"
7336
+ * getRootLength("//server/share") === 8 // "//server/"
7337
+ * getRootLength("\\\\server") === 7 // "\\\\server"
7338
+ * getRootLength("\\\\server\\share") === 8 // "\\\\server\\"
7339
+ * getRootLength("file:///path") === 8 // "file:///"
7340
+ * getRootLength("file:///c:") === 10 // "file:///c:"
7341
+ * getRootLength("file:///c:d") === 8 // "file:///"
7342
+ * getRootLength("file:///c:/path") === 11 // "file:///c:/"
7343
+ * getRootLength("file://server") === 13 // "file://server"
7344
+ * getRootLength("file://server/path") === 14 // "file://server/"
7345
+ * getRootLength("http://server") === 13 // "http://server"
7346
+ * getRootLength("http://server/path") === 14 // "http://server/"
7347
+ * ```
7348
+ */
7349
+ function getRootLength(path) {
7350
+ var rootLength = getEncodedRootLength(path);
7351
+ return rootLength < 0 ? ~rootLength : rootLength;
7352
+ }
7353
+ ts.getRootLength = getRootLength;
7354
+ function getDirectoryPath(path) {
7355
+ path = normalizeSlashes(path);
7356
+ // If the path provided is itself the root, then return it.
7357
+ var rootLength = getRootLength(path);
7358
+ if (rootLength === path.length)
7359
+ return path;
7360
+ // return the leading portion of the path up to the last (non-terminal) directory separator
7361
+ // but not including any trailing directory separator.
7362
+ path = removeTrailingDirectorySeparator(path);
7363
+ return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator)));
7364
+ }
7365
+ ts.getDirectoryPath = getDirectoryPath;
7366
+ function getBaseFileName(path, extensions, ignoreCase) {
7367
+ path = normalizeSlashes(path);
7368
+ // if the path provided is itself the root, then it has not file name.
7369
+ var rootLength = getRootLength(path);
7370
+ if (rootLength === path.length)
7371
+ return "";
7372
+ // return the trailing portion of the path starting after the last (non-terminal) directory
7373
+ // separator but not including any trailing directory separator.
7374
+ path = removeTrailingDirectorySeparator(path);
7375
+ var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1));
7376
+ var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined;
7377
+ return extension ? name.slice(0, name.length - extension.length) : name;
7378
+ }
7379
+ ts.getBaseFileName = getBaseFileName;
7380
+ function tryGetExtensionFromPath(path, extension, stringEqualityComparer) {
7381
+ if (!ts.startsWith(extension, "."))
7382
+ extension = "." + extension;
7383
+ if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) {
7384
+ var pathExtension = path.slice(path.length - extension.length);
7385
+ if (stringEqualityComparer(pathExtension, extension)) {
7386
+ return pathExtension;
7387
+ }
7388
+ }
7389
+ }
7390
+ function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) {
7391
+ if (typeof extensions === "string") {
7392
+ return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || "";
7393
+ }
7394
+ for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) {
7395
+ var extension = extensions_2[_i];
7396
+ var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer);
7397
+ if (result)
7398
+ return result;
7399
+ }
7400
+ return "";
7401
+ }
7402
+ function getAnyExtensionFromPath(path, extensions, ignoreCase) {
7403
+ // Retrieves any string from the final "." onwards from a base file name.
7404
+ // Unlike extensionFromPath, which throws an exception on unrecognized extensions.
7405
+ if (extensions) {
7406
+ return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive);
7407
+ }
7408
+ var baseFileName = getBaseFileName(path);
7409
+ var extensionIndex = baseFileName.lastIndexOf(".");
7410
+ if (extensionIndex >= 0) {
7411
+ return baseFileName.substring(extensionIndex);
7412
+ }
7413
+ return "";
7414
+ }
7415
+ ts.getAnyExtensionFromPath = getAnyExtensionFromPath;
7416
+ function pathComponents(path, rootLength) {
7417
+ var root = path.substring(0, rootLength);
7418
+ var rest = path.substring(rootLength).split(ts.directorySeparator);
7419
+ if (rest.length && !ts.lastOrUndefined(rest))
7420
+ rest.pop();
7421
+ return __spreadArray([root], rest, true);
7422
+ }
7423
+ /**
7424
+ * Parse a path into an array containing a root component (at index 0) and zero or more path
7425
+ * components (at indices > 0). The result is not normalized.
7426
+ * If the path is relative, the root component is `""`.
7427
+ * If the path is absolute, the root component includes the first path separator (`/`).
7428
+ *
7429
+ * ```ts
7430
+ * // POSIX
7431
+ * getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"]
7432
+ * getPathComponents("/path/to/") === ["/", "path", "to"]
7433
+ * getPathComponents("/") === ["/"]
7434
+ * // DOS
7435
+ * getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"]
7436
+ * getPathComponents("c:/path/to/") === ["c:/", "path", "to"]
7437
+ * getPathComponents("c:/") === ["c:/"]
7438
+ * getPathComponents("c:") === ["c:"]
7439
+ * // URL
7440
+ * getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"]
7441
+ * getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"]
7442
+ * getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"]
7443
+ * getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"]
7444
+ * getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"]
7445
+ * getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"]
7446
+ * getPathComponents("file://server/") === ["file://server/"]
7447
+ * getPathComponents("file://server") === ["file://server"]
7448
+ * getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"]
7449
+ * getPathComponents("file:///path/to/") === ["file:///", "path", "to"]
7450
+ * getPathComponents("file:///") === ["file:///"]
7451
+ * getPathComponents("file://") === ["file://"]
7452
+ */
7453
+ function getPathComponents(path, currentDirectory) {
7454
+ if (currentDirectory === void 0) { currentDirectory = ""; }
7455
+ path = combinePaths(currentDirectory, path);
7456
+ return pathComponents(path, getRootLength(path));
7457
+ }
7458
+ ts.getPathComponents = getPathComponents;
7459
+ //// Path Formatting
7460
+ /**
7461
+ * Formats a parsed path consisting of a root component (at index 0) and zero or more path
7462
+ * segments (at indices > 0).
7463
+ *
7464
+ * ```ts
7465
+ * getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext"
7466
+ * ```
7467
+ */
7468
+ function getPathFromPathComponents(pathComponents) {
7469
+ if (pathComponents.length === 0)
7470
+ return "";
7471
+ var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
7472
+ return root + pathComponents.slice(1).join(ts.directorySeparator);
7473
+ }
7474
+ ts.getPathFromPathComponents = getPathFromPathComponents;
7475
+ //// Path Normalization
7476
+ /**
7477
+ * Normalize path separators, converting `\` into `/`.
7478
+ */
7479
+ function normalizeSlashes(path) {
7480
+ var index = path.indexOf("\\");
7481
+ if (index === -1) {
7482
+ return path;
7483
+ }
7484
+ backslashRegExp.lastIndex = index; // prime regex with known position
7485
+ return path.replace(backslashRegExp, ts.directorySeparator);
7486
+ }
7487
+ ts.normalizeSlashes = normalizeSlashes;
7488
+ /**
7489
+ * Reduce an array of path components to a more simplified path by navigating any
7490
+ * `"."` or `".."` entries in the path.
7491
+ */
7492
+ function reducePathComponents(components) {
7493
+ if (!ts.some(components))
7494
+ return [];
7495
+ var reduced = [components[0]];
7496
+ for (var i = 1; i < components.length; i++) {
7497
+ var component = components[i];
7498
+ if (!component)
7499
+ continue;
7500
+ if (component === ".")
7501
+ continue;
7502
+ if (component === "..") {
7503
+ if (reduced.length > 1) {
7504
+ if (reduced[reduced.length - 1] !== "..") {
7505
+ reduced.pop();
7506
+ continue;
7507
+ }
7508
+ }
7509
+ else if (reduced[0])
7510
+ continue;
7779
7511
  }
7780
- function realpath(path) {
7781
- try {
7782
- return realpathSync(path);
7783
- }
7784
- catch (_a) {
7785
- return path;
7786
- }
7512
+ reduced.push(component);
7513
+ }
7514
+ return reduced;
7515
+ }
7516
+ ts.reducePathComponents = reducePathComponents;
7517
+ /**
7518
+ * Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified.
7519
+ *
7520
+ * ```ts
7521
+ * // Non-rooted
7522
+ * combinePaths("path", "to", "file.ext") === "path/to/file.ext"
7523
+ * combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext"
7524
+ * // POSIX
7525
+ * combinePaths("/path", "to", "file.ext") === "/path/to/file.ext"
7526
+ * combinePaths("/path", "/to", "file.ext") === "/to/file.ext"
7527
+ * // DOS
7528
+ * combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext"
7529
+ * combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext"
7530
+ * // URL
7531
+ * combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext"
7532
+ * combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext"
7533
+ * ```
7534
+ */
7535
+ function combinePaths(path) {
7536
+ var paths = [];
7537
+ for (var _i = 1; _i < arguments.length; _i++) {
7538
+ paths[_i - 1] = arguments[_i];
7539
+ }
7540
+ if (path)
7541
+ path = normalizeSlashes(path);
7542
+ for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
7543
+ var relativePath = paths_1[_a];
7544
+ if (!relativePath)
7545
+ continue;
7546
+ relativePath = normalizeSlashes(relativePath);
7547
+ if (!path || getRootLength(relativePath) !== 0) {
7548
+ path = relativePath;
7787
7549
  }
7788
- function getModifiedTime(path) {
7789
- var _a;
7790
- try {
7791
- return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime;
7792
- }
7793
- catch (e) {
7794
- return undefined;
7795
- }
7550
+ else {
7551
+ path = ensureTrailingDirectorySeparator(path) + relativePath;
7796
7552
  }
7797
- function setModifiedTime(path, time) {
7798
- try {
7799
- _fs.utimesSync(path, time, time);
7800
- }
7801
- catch (e) {
7802
- return;
7803
- }
7553
+ }
7554
+ return path;
7555
+ }
7556
+ ts.combinePaths = combinePaths;
7557
+ /**
7558
+ * Combines and resolves paths. If a path is absolute, it replaces any previous path. Any
7559
+ * `.` and `..` path components are resolved. Trailing directory separators are preserved.
7560
+ *
7561
+ * ```ts
7562
+ * resolvePath("/path", "to", "file.ext") === "path/to/file.ext"
7563
+ * resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/"
7564
+ * resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext"
7565
+ * ```
7566
+ */
7567
+ function resolvePath(path) {
7568
+ var paths = [];
7569
+ for (var _i = 1; _i < arguments.length; _i++) {
7570
+ paths[_i - 1] = arguments[_i];
7571
+ }
7572
+ return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArray([path], paths, false)) : normalizeSlashes(path));
7573
+ }
7574
+ ts.resolvePath = resolvePath;
7575
+ /**
7576
+ * Parse a path into an array containing a root component (at index 0) and zero or more path
7577
+ * components (at indices > 0). The result is normalized.
7578
+ * If the path is relative, the root component is `""`.
7579
+ * If the path is absolute, the root component includes the first path separator (`/`).
7580
+ *
7581
+ * ```ts
7582
+ * getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"]
7583
+ * ```
7584
+ */
7585
+ function getNormalizedPathComponents(path, currentDirectory) {
7586
+ return reducePathComponents(getPathComponents(path, currentDirectory));
7587
+ }
7588
+ ts.getNormalizedPathComponents = getNormalizedPathComponents;
7589
+ function getNormalizedAbsolutePath(fileName, currentDirectory) {
7590
+ return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
7591
+ }
7592
+ ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
7593
+ function normalizePath(path) {
7594
+ path = normalizeSlashes(path);
7595
+ // Most paths don't require normalization
7596
+ if (!relativePathSegmentRegExp.test(path)) {
7597
+ return path;
7598
+ }
7599
+ // Some paths only require cleanup of `/./` or leading `./`
7600
+ var simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, "");
7601
+ if (simplified !== path) {
7602
+ path = simplified;
7603
+ if (!relativePathSegmentRegExp.test(path)) {
7604
+ return path;
7804
7605
  }
7805
- function deleteFile(path) {
7806
- try {
7807
- return _fs.unlinkSync(path);
7808
- }
7809
- catch (e) {
7810
- return;
7811
- }
7606
+ }
7607
+ // Other paths require full normalization
7608
+ var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
7609
+ return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
7610
+ }
7611
+ ts.normalizePath = normalizePath;
7612
+ function getPathWithoutRoot(pathComponents) {
7613
+ if (pathComponents.length === 0)
7614
+ return "";
7615
+ return pathComponents.slice(1).join(ts.directorySeparator);
7616
+ }
7617
+ function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
7618
+ return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
7619
+ }
7620
+ ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
7621
+ function toPath(fileName, basePath, getCanonicalFileName) {
7622
+ var nonCanonicalizedPath = isRootedDiskPath(fileName)
7623
+ ? normalizePath(fileName)
7624
+ : getNormalizedAbsolutePath(fileName, basePath);
7625
+ return getCanonicalFileName(nonCanonicalizedPath);
7626
+ }
7627
+ ts.toPath = toPath;
7628
+ function normalizePathAndParts(path) {
7629
+ path = normalizeSlashes(path);
7630
+ var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
7631
+ if (parts.length) {
7632
+ var joinedParts = root + parts.join(ts.directorySeparator);
7633
+ return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
7634
+ }
7635
+ else {
7636
+ return { path: root, parts: parts };
7637
+ }
7638
+ }
7639
+ ts.normalizePathAndParts = normalizePathAndParts;
7640
+ function removeTrailingDirectorySeparator(path) {
7641
+ if (hasTrailingDirectorySeparator(path)) {
7642
+ return path.substr(0, path.length - 1);
7643
+ }
7644
+ return path;
7645
+ }
7646
+ ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
7647
+ function ensureTrailingDirectorySeparator(path) {
7648
+ if (!hasTrailingDirectorySeparator(path)) {
7649
+ return path + ts.directorySeparator;
7650
+ }
7651
+ return path;
7652
+ }
7653
+ ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator;
7654
+ /**
7655
+ * Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed
7656
+ * with `./` or `../`) so as not to be confused with an unprefixed module name.
7657
+ *
7658
+ * ```ts
7659
+ * ensurePathIsNonModuleName("/path/to/file.ext") === "/path/to/file.ext"
7660
+ * ensurePathIsNonModuleName("./path/to/file.ext") === "./path/to/file.ext"
7661
+ * ensurePathIsNonModuleName("../path/to/file.ext") === "../path/to/file.ext"
7662
+ * ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext"
7663
+ * ```
7664
+ */
7665
+ function ensurePathIsNonModuleName(path) {
7666
+ return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path;
7667
+ }
7668
+ ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName;
7669
+ function changeAnyExtension(path, ext, extensions, ignoreCase) {
7670
+ var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path);
7671
+ return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
7672
+ }
7673
+ ts.changeAnyExtension = changeAnyExtension;
7674
+ //// Path Comparisons
7675
+ // check path for these segments: '', '.'. '..'
7676
+ var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/;
7677
+ function comparePathsWorker(a, b, componentComparer) {
7678
+ if (a === b)
7679
+ return 0 /* EqualTo */;
7680
+ if (a === undefined)
7681
+ return -1 /* LessThan */;
7682
+ if (b === undefined)
7683
+ return 1 /* GreaterThan */;
7684
+ // NOTE: Performance optimization - shortcut if the root segments differ as there would be no
7685
+ // need to perform path reduction.
7686
+ var aRoot = a.substring(0, getRootLength(a));
7687
+ var bRoot = b.substring(0, getRootLength(b));
7688
+ var result = ts.compareStringsCaseInsensitive(aRoot, bRoot);
7689
+ if (result !== 0 /* EqualTo */) {
7690
+ return result;
7691
+ }
7692
+ // NOTE: Performance optimization - shortcut if there are no relative path segments in
7693
+ // the non-root portion of the path
7694
+ var aRest = a.substring(aRoot.length);
7695
+ var bRest = b.substring(bRoot.length);
7696
+ if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) {
7697
+ return componentComparer(aRest, bRest);
7698
+ }
7699
+ // The path contains a relative path segment. Normalize the paths and perform a slower component
7700
+ // by component comparison.
7701
+ var aComponents = reducePathComponents(getPathComponents(a));
7702
+ var bComponents = reducePathComponents(getPathComponents(b));
7703
+ var sharedLength = Math.min(aComponents.length, bComponents.length);
7704
+ for (var i = 1; i < sharedLength; i++) {
7705
+ var result_2 = componentComparer(aComponents[i], bComponents[i]);
7706
+ if (result_2 !== 0 /* EqualTo */) {
7707
+ return result_2;
7812
7708
  }
7813
- function createSHA256Hash(data) {
7814
- var hash = _crypto.createHash("sha256");
7815
- hash.update(data);
7816
- return hash.digest("hex");
7709
+ }
7710
+ return ts.compareValues(aComponents.length, bComponents.length);
7711
+ }
7712
+ /**
7713
+ * Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively.
7714
+ */
7715
+ function comparePathsCaseSensitive(a, b) {
7716
+ return comparePathsWorker(a, b, ts.compareStringsCaseSensitive);
7717
+ }
7718
+ ts.comparePathsCaseSensitive = comparePathsCaseSensitive;
7719
+ /**
7720
+ * Performs a case-insensitive comparison of two paths.
7721
+ */
7722
+ function comparePathsCaseInsensitive(a, b) {
7723
+ return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive);
7724
+ }
7725
+ ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive;
7726
+ function comparePaths(a, b, currentDirectory, ignoreCase) {
7727
+ if (typeof currentDirectory === "string") {
7728
+ a = combinePaths(currentDirectory, a);
7729
+ b = combinePaths(currentDirectory, b);
7730
+ }
7731
+ else if (typeof currentDirectory === "boolean") {
7732
+ ignoreCase = currentDirectory;
7733
+ }
7734
+ return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase));
7735
+ }
7736
+ ts.comparePaths = comparePaths;
7737
+ function containsPath(parent, child, currentDirectory, ignoreCase) {
7738
+ if (typeof currentDirectory === "string") {
7739
+ parent = combinePaths(currentDirectory, parent);
7740
+ child = combinePaths(currentDirectory, child);
7741
+ }
7742
+ else if (typeof currentDirectory === "boolean") {
7743
+ ignoreCase = currentDirectory;
7744
+ }
7745
+ if (parent === undefined || child === undefined)
7746
+ return false;
7747
+ if (parent === child)
7748
+ return true;
7749
+ var parentComponents = reducePathComponents(getPathComponents(parent));
7750
+ var childComponents = reducePathComponents(getPathComponents(child));
7751
+ if (childComponents.length < parentComponents.length) {
7752
+ return false;
7753
+ }
7754
+ var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive;
7755
+ for (var i = 0; i < parentComponents.length; i++) {
7756
+ var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer;
7757
+ if (!equalityComparer(parentComponents[i], childComponents[i])) {
7758
+ return false;
7817
7759
  }
7818
7760
  }
7819
- var sys;
7820
- if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") {
7821
- // process and process.nextTick checks if current environment is node-like
7822
- // process.browser check excludes webpack and browserify
7823
- sys = getNodeSystem();
7761
+ return true;
7762
+ }
7763
+ ts.containsPath = containsPath;
7764
+ /**
7765
+ * Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback.
7766
+ * Comparison is case-sensitive between the canonical paths.
7767
+ *
7768
+ * Use `containsPath` if file names are not already reduced and absolute.
7769
+ */
7770
+ function startsWithDirectory(fileName, directoryName, getCanonicalFileName) {
7771
+ var canonicalFileName = getCanonicalFileName(fileName);
7772
+ var canonicalDirectoryName = getCanonicalFileName(directoryName);
7773
+ return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\");
7774
+ }
7775
+ ts.startsWithDirectory = startsWithDirectory;
7776
+ //// Relative Paths
7777
+ function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) {
7778
+ var fromComponents = reducePathComponents(getPathComponents(from));
7779
+ var toComponents = reducePathComponents(getPathComponents(to));
7780
+ var start;
7781
+ for (start = 0; start < fromComponents.length && start < toComponents.length; start++) {
7782
+ var fromComponent = getCanonicalFileName(fromComponents[start]);
7783
+ var toComponent = getCanonicalFileName(toComponents[start]);
7784
+ var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer;
7785
+ if (!comparer(fromComponent, toComponent))
7786
+ break;
7824
7787
  }
7825
- if (sys) {
7826
- // patch writefile to create folder before writing the file
7827
- patchWriteFileEnsuringDirectory(sys);
7788
+ if (start === 0) {
7789
+ return toComponents;
7828
7790
  }
7829
- return sys;
7830
- })();
7831
- /*@internal*/
7832
- function setSys(s) {
7833
- ts.sys = s;
7791
+ var components = toComponents.slice(start);
7792
+ var relative = [];
7793
+ for (; start < fromComponents.length; start++) {
7794
+ relative.push("..");
7795
+ }
7796
+ return __spreadArray(__spreadArray([""], relative, true), components, true);
7834
7797
  }
7835
- ts.setSys = setSys;
7836
- if (ts.sys && ts.sys.getEnvironmentVariable) {
7837
- setCustomPollingValues(ts.sys);
7838
- ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))
7839
- ? 1 /* Normal */
7840
- : 0 /* None */);
7798
+ ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo;
7799
+ function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
7800
+ ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
7801
+ var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
7802
+ var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
7803
+ var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
7804
+ return getPathFromPathComponents(pathComponents);
7841
7805
  }
7842
- if (ts.sys && ts.sys.debugMode) {
7843
- ts.Debug.isDebugging = true;
7806
+ ts.getRelativePathFromDirectory = getRelativePathFromDirectory;
7807
+ function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
7808
+ return !isRootedDiskPath(absoluteOrRelativePath)
7809
+ ? absoluteOrRelativePath
7810
+ : getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
7811
+ }
7812
+ ts.convertToRelativePath = convertToRelativePath;
7813
+ function getRelativePathFromFile(from, to, getCanonicalFileName) {
7814
+ return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName));
7815
+ }
7816
+ ts.getRelativePathFromFile = getRelativePathFromFile;
7817
+ function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
7818
+ var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName);
7819
+ var firstComponent = pathComponents[0];
7820
+ if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) {
7821
+ var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///";
7822
+ pathComponents[0] = prefix + firstComponent;
7823
+ }
7824
+ return getPathFromPathComponents(pathComponents);
7825
+ }
7826
+ ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl;
7827
+ function forEachAncestorDirectory(directory, callback) {
7828
+ while (true) {
7829
+ var result = callback(directory);
7830
+ if (result !== undefined) {
7831
+ return result;
7832
+ }
7833
+ var parentPath = getDirectoryPath(directory);
7834
+ if (parentPath === directory) {
7835
+ return undefined;
7836
+ }
7837
+ directory = parentPath;
7838
+ }
7839
+ }
7840
+ ts.forEachAncestorDirectory = forEachAncestorDirectory;
7841
+ function isNodeModulesDirectory(dirPath) {
7842
+ return ts.endsWith(dirPath, "/node_modules");
7844
7843
  }
7844
+ ts.isNodeModulesDirectory = isNodeModulesDirectory;
7845
7845
  })(ts || (ts = {}));
7846
7846
  // <auto-generated />
7847
7847
  // generated from './diagnosticMessages.json' in 'src/compiler'
@@ -46852,8 +46852,8 @@ var ts;
46852
46852
  TypeFacts[TypeFacts["AllTypeofNE"] = 556800] = "AllTypeofNE";
46853
46853
  TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts";
46854
46854
  // Masks
46855
- TypeFacts[TypeFacts["OrFactsMask"] = 8288] = "OrFactsMask";
46856
- TypeFacts[TypeFacts["AndFactsMask"] = 16768927] = "AndFactsMask";
46855
+ TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
46856
+ TypeFacts[TypeFacts["AndFactsMask"] = 16768959] = "AndFactsMask";
46857
46857
  })(TypeFacts || (TypeFacts = {}));
46858
46858
  var typeofEQFacts = new ts.Map(ts.getEntries({
46859
46859
  string: 1 /* TypeofEQString */,
@@ -67961,7 +67961,10 @@ var ts;
67961
67961
  (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ :
67962
67962
  (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
67963
67963
  }
67964
- if (flags & 524288 /* Object */ && !ignoreObjects) {
67964
+ if (flags & 524288 /* Object */) {
67965
+ if (ignoreObjects) {
67966
+ return 16768959 /* AndFactsMask */; // This is the identity element for computing type facts of intersection.
67967
+ }
67965
67968
  return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ?
67966
67969
  strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ :
67967
67970
  isFunctionObjectType(type) ?
@@ -68009,7 +68012,7 @@ var ts;
68009
68012
  oredFacts |= f;
68010
68013
  andedFacts &= f;
68011
68014
  }
68012
- return oredFacts & 8288 /* OrFactsMask */ | andedFacts & 16768927 /* AndFactsMask */;
68015
+ return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 16768959 /* AndFactsMask */;
68013
68016
  }
68014
68017
  function getTypeWithFacts(type, include) {
68015
68018
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
@@ -69969,6 +69972,9 @@ var ts;
69969
69972
  return getTypeOfSymbol(symbol);
69970
69973
  }
69971
69974
  function checkIdentifier(node, checkMode) {
69975
+ if (ts.isThisInTypeQuery(node)) {
69976
+ return checkThisExpression(node);
69977
+ }
69972
69978
  var symbol = getResolvedSymbol(node);
69973
69979
  if (symbol === unknownSymbol) {
69974
69980
  return errorType;
@@ -71760,7 +71766,8 @@ var ts;
71760
71766
  var links = getNodeLinks(node.expression);
71761
71767
  if (!links.resolvedType) {
71762
71768
  if ((ts.isTypeLiteralNode(node.parent.parent) || ts.isClassLike(node.parent.parent) || ts.isInterfaceDeclaration(node.parent.parent))
71763
- && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */) {
71769
+ && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */
71770
+ && node.parent.kind !== 171 /* GetAccessor */ && node.parent.kind !== 172 /* SetAccessor */) {
71764
71771
  return links.resolvedType = errorType;
71765
71772
  }
71766
71773
  links.resolvedType = checkExpression(node.expression);
@@ -75708,6 +75715,10 @@ var ts;
75708
75715
  return restParameter.escapedName;
75709
75716
  }
75710
75717
  function getParameterIdentifierNameAtPosition(signature, pos) {
75718
+ var _a;
75719
+ if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 315 /* JSDocFunctionType */) {
75720
+ return undefined;
75721
+ }
75711
75722
  var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
75712
75723
  if (pos < paramCount) {
75713
75724
  var param = signature.parameters[pos];
@@ -84472,7 +84483,10 @@ var ts;
84472
84483
  case 80 /* PrivateIdentifier */:
84473
84484
  case 205 /* PropertyAccessExpression */:
84474
84485
  case 160 /* QualifiedName */:
84475
- return getSymbolOfNameOrPropertyAccessExpression(node);
84486
+ if (!ts.isThisInTypeQuery(node)) {
84487
+ return getSymbolOfNameOrPropertyAccessExpression(node);
84488
+ }
84489
+ // falls through
84476
84490
  case 108 /* ThisKeyword */:
84477
84491
  var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false);
84478
84492
  if (ts.isFunctionLike(container)) {
@@ -94446,6 +94460,7 @@ var ts;
94446
94460
  var exportedVariableStatement = false;
94447
94461
  var enabledSubstitutions;
94448
94462
  var enclosingFunctionFlags;
94463
+ var parametersWithPrecedingObjectRestOrSpread;
94449
94464
  var enclosingSuperContainerFlags = 0;
94450
94465
  var hierarchyFacts = 0;
94451
94466
  var currentSourceFile;
@@ -94902,6 +94917,7 @@ var ts;
94902
94917
  /*incrementor*/ undefined,
94903
94918
  /*statement*/ convertForOfStatementHead(node, getValue)),
94904
94919
  /*location*/ node), 256 /* NoTokenTrailingSourceMaps */);
94920
+ ts.setOriginalNode(forStatement, node);
94905
94921
  return factory.createTryStatement(factory.createBlock([
94906
94922
  factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement)
94907
94923
  ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([
@@ -94919,7 +94935,19 @@ var ts;
94919
94935
  ]), 1 /* SingleLine */))
94920
94936
  ]));
94921
94937
  }
94938
+ function parameterVisitor(node) {
94939
+ ts.Debug.assertNode(node, ts.isParameter);
94940
+ return visitParameter(node);
94941
+ }
94922
94942
  function visitParameter(node) {
94943
+ if (parametersWithPrecedingObjectRestOrSpread === null || parametersWithPrecedingObjectRestOrSpread === void 0 ? void 0 : parametersWithPrecedingObjectRestOrSpread.has(node)) {
94944
+ return factory.updateParameterDeclaration(node,
94945
+ /*decorators*/ undefined,
94946
+ /*modifiers*/ undefined, node.dotDotDotToken, ts.isBindingPattern(node.name) ? factory.getGeneratedNameForNode(node) : node.name,
94947
+ /*questionToken*/ undefined,
94948
+ /*type*/ undefined,
94949
+ /*initializer*/ undefined);
94950
+ }
94923
94951
  if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
94924
94952
  // Binding patterns are converted into a generated name and are
94925
94953
  // evaluated inside the function body.
@@ -94931,85 +94959,119 @@ var ts;
94931
94959
  }
94932
94960
  return ts.visitEachChild(node, visitor, context);
94933
94961
  }
94962
+ function collectParametersWithPrecedingObjectRestOrSpread(node) {
94963
+ var parameters;
94964
+ for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
94965
+ var parameter = _a[_i];
94966
+ if (parameters) {
94967
+ parameters.add(parameter);
94968
+ }
94969
+ else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
94970
+ parameters = new ts.Set();
94971
+ }
94972
+ }
94973
+ return parameters;
94974
+ }
94934
94975
  function visitConstructorDeclaration(node) {
94935
94976
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
94936
- enclosingFunctionFlags = 0 /* Normal */;
94977
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
94978
+ enclosingFunctionFlags = ts.getFunctionFlags(node);
94979
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94937
94980
  var updated = factory.updateConstructorDeclaration(node,
94938
- /*decorators*/ undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
94981
+ /*decorators*/ undefined, node.modifiers, ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node));
94939
94982
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
94983
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
94940
94984
  return updated;
94941
94985
  }
94942
94986
  function visitGetAccessorDeclaration(node) {
94943
94987
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
94944
- enclosingFunctionFlags = 0 /* Normal */;
94988
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
94989
+ enclosingFunctionFlags = ts.getFunctionFlags(node);
94990
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94945
94991
  var updated = factory.updateGetAccessorDeclaration(node,
94946
- /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context),
94992
+ /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context),
94947
94993
  /*type*/ undefined, transformFunctionBody(node));
94948
94994
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
94995
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
94949
94996
  return updated;
94950
94997
  }
94951
94998
  function visitSetAccessorDeclaration(node) {
94952
94999
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
94953
- enclosingFunctionFlags = 0 /* Normal */;
95000
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95001
+ enclosingFunctionFlags = ts.getFunctionFlags(node);
95002
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94954
95003
  var updated = factory.updateSetAccessorDeclaration(node,
94955
- /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
95004
+ /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node));
94956
95005
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95006
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
94957
95007
  return updated;
94958
95008
  }
94959
95009
  function visitMethodDeclaration(node) {
94960
95010
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95011
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
94961
95012
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95013
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94962
95014
  var updated = factory.updateMethodDeclaration(node,
94963
95015
  /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */
94964
95016
  ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
94965
95017
  : node.modifiers, enclosingFunctionFlags & 2 /* Async */
94966
95018
  ? undefined
94967
95019
  : node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(/*questionToken*/ undefined, visitor, ts.isToken),
94968
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95020
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
94969
95021
  /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
94970
95022
  ? transformAsyncGeneratorFunctionBody(node)
94971
95023
  : transformFunctionBody(node));
94972
95024
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95025
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
94973
95026
  return updated;
94974
95027
  }
94975
95028
  function visitFunctionDeclaration(node) {
94976
95029
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95030
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
94977
95031
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95032
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94978
95033
  var updated = factory.updateFunctionDeclaration(node,
94979
95034
  /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */
94980
95035
  ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
94981
95036
  : node.modifiers, enclosingFunctionFlags & 2 /* Async */
94982
95037
  ? undefined
94983
95038
  : node.asteriskToken, node.name,
94984
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95039
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
94985
95040
  /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
94986
95041
  ? transformAsyncGeneratorFunctionBody(node)
94987
95042
  : transformFunctionBody(node));
94988
95043
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95044
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
94989
95045
  return updated;
94990
95046
  }
94991
95047
  function visitArrowFunction(node) {
94992
95048
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95049
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
94993
95050
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95051
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94994
95052
  var updated = factory.updateArrowFunction(node, node.modifiers,
94995
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95053
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
94996
95054
  /*type*/ undefined, node.equalsGreaterThanToken, transformFunctionBody(node));
94997
95055
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95056
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
94998
95057
  return updated;
94999
95058
  }
95000
95059
  function visitFunctionExpression(node) {
95001
95060
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95061
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95002
95062
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95063
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95003
95064
  var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */
95004
95065
  ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
95005
95066
  : node.modifiers, enclosingFunctionFlags & 2 /* Async */
95006
95067
  ? undefined
95007
95068
  : node.asteriskToken, node.name,
95008
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95069
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
95009
95070
  /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
95010
95071
  ? transformAsyncGeneratorFunctionBody(node)
95011
95072
  : transformFunctionBody(node));
95012
95073
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95074
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95013
95075
  return updated;
95014
95076
  }
95015
95077
  function transformAsyncGeneratorFunctionBody(node) {
@@ -95070,16 +95132,71 @@ var ts;
95070
95132
  return body;
95071
95133
  }
95072
95134
  function appendObjectRestAssignmentsIfNeeded(statements, node) {
95135
+ var containsPrecedingObjectRestOrSpread = false;
95073
95136
  for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
95074
95137
  var parameter = _a[_i];
95075
- if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
95076
- var temp = factory.getGeneratedNameForNode(parameter);
95077
- var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, temp,
95138
+ if (containsPrecedingObjectRestOrSpread) {
95139
+ if (ts.isBindingPattern(parameter.name)) {
95140
+ // In cases where a binding pattern is simply '[]' or '{}',
95141
+ // we usually don't want to emit a var declaration; however, in the presence
95142
+ // of an initializer, we must emit that expression to preserve side effects.
95143
+ //
95144
+ // NOTE: see `insertDefaultValueAssignmentForBindingPattern` in es2015.ts
95145
+ if (parameter.name.elements.length > 0) {
95146
+ var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter));
95147
+ if (ts.some(declarations)) {
95148
+ var declarationList = factory.createVariableDeclarationList(declarations);
95149
+ var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList);
95150
+ ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
95151
+ statements = ts.append(statements, statement);
95152
+ }
95153
+ }
95154
+ else if (parameter.initializer) {
95155
+ var name = factory.getGeneratedNameForNode(parameter);
95156
+ var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression);
95157
+ var assignment = factory.createAssignment(name, initializer);
95158
+ var statement = factory.createExpressionStatement(assignment);
95159
+ ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
95160
+ statements = ts.append(statements, statement);
95161
+ }
95162
+ }
95163
+ else if (parameter.initializer) {
95164
+ // Converts a parameter initializer into a function body statement, i.e.:
95165
+ //
95166
+ // function f(x = 1) { }
95167
+ //
95168
+ // becomes
95169
+ //
95170
+ // function f(x) {
95171
+ // if (typeof x === "undefined") { x = 1; }
95172
+ // }
95173
+ var name = factory.cloneNode(parameter.name);
95174
+ ts.setTextRange(name, parameter.name);
95175
+ ts.setEmitFlags(name, 48 /* NoSourceMap */);
95176
+ var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression);
95177
+ ts.addEmitFlags(initializer, 48 /* NoSourceMap */ | 1536 /* NoComments */);
95178
+ var assignment = factory.createAssignment(name, initializer);
95179
+ ts.setTextRange(assignment, parameter);
95180
+ ts.setEmitFlags(assignment, 1536 /* NoComments */);
95181
+ var block = factory.createBlock([factory.createExpressionStatement(assignment)]);
95182
+ ts.setTextRange(block, parameter);
95183
+ ts.setEmitFlags(block, 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */);
95184
+ var typeCheck = factory.createTypeCheck(factory.cloneNode(parameter.name), "undefined");
95185
+ var statement = factory.createIfStatement(typeCheck, block);
95186
+ ts.startOnNewLine(statement);
95187
+ ts.setTextRange(statement, parameter);
95188
+ ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */);
95189
+ statements = ts.append(statements, statement);
95190
+ }
95191
+ }
95192
+ else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
95193
+ containsPrecedingObjectRestOrSpread = true;
95194
+ var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter),
95078
95195
  /*doNotRecordTempVariablesInLine*/ false,
95079
95196
  /*skipInitializer*/ true);
95080
95197
  if (ts.some(declarations)) {
95081
- var statement = factory.createVariableStatement(
95082
- /*modifiers*/ undefined, factory.createVariableDeclarationList(declarations));
95198
+ var declarationList = factory.createVariableDeclarationList(declarations);
95199
+ var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList);
95083
95200
  ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
95084
95201
  statements = ts.append(statements, statement);
95085
95202
  }
@@ -98330,10 +98447,12 @@ var ts;
98330
98447
  // variables declared in the loop initializer that will be changed inside the loop
98331
98448
  var loopOutParameters = [];
98332
98449
  if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) {
98333
- var hasCapturedBindingsInForInitializer = shouldConvertInitializerOfForStatement(node);
98450
+ var hasCapturedBindingsInForHead = shouldConvertInitializerOfForStatement(node) ||
98451
+ shouldConvertConditionOfForStatement(node) ||
98452
+ shouldConvertIncrementorOfForStatement(node);
98334
98453
  for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) {
98335
98454
  var decl = _a[_i];
98336
- processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
98455
+ processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForHead);
98337
98456
  }
98338
98457
  }
98339
98458
  var currentState = { loopParameters: loopParameters, loopOutParameters: loopOutParameters };
@@ -98687,27 +98806,33 @@ var ts;
98687
98806
  caseClauses.push(factory.createCaseClause(factory.createStringLiteral(labelMarker), statements));
98688
98807
  });
98689
98808
  }
98690
- function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer) {
98809
+ function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForHead) {
98691
98810
  var name = decl.name;
98692
98811
  if (ts.isBindingPattern(name)) {
98693
98812
  for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
98694
98813
  var element = _a[_i];
98695
98814
  if (!ts.isOmittedExpression(element)) {
98696
- processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
98815
+ processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForHead);
98697
98816
  }
98698
98817
  }
98699
98818
  }
98700
98819
  else {
98701
98820
  loopParameters.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name));
98702
98821
  var checkFlags = resolver.getNodeCheckFlags(decl);
98703
- if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForInitializer) {
98822
+ if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) {
98704
98823
  var outParamName = factory.createUniqueName("out_" + ts.idText(name));
98705
98824
  var flags = 0;
98706
98825
  if (checkFlags & 4194304 /* NeedsLoopOutParameter */) {
98707
98826
  flags |= 1 /* Body */;
98708
98827
  }
98709
- if (ts.isForStatement(container) && container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
98710
- flags |= 2 /* Initializer */;
98828
+ if (ts.isForStatement(container)) {
98829
+ if (container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
98830
+ flags |= 2 /* Initializer */;
98831
+ }
98832
+ if (container.condition && resolver.isBindingCapturedByNode(container.condition, decl) ||
98833
+ container.incrementor && resolver.isBindingCapturedByNode(container.incrementor, decl)) {
98834
+ flags |= 1 /* Body */;
98835
+ }
98711
98836
  }
98712
98837
  loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName });
98713
98838
  }