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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.20220201";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220205";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -1263,11 +1263,11 @@ var ts;
1263
1263
  return result;
1264
1264
  }
1265
1265
  ts.getAllKeys = getAllKeys;
1266
- function getOwnValues(sparseArray) {
1266
+ function getOwnValues(collection) {
1267
1267
  var values = [];
1268
- for (var key in sparseArray) {
1269
- if (hasOwnProperty.call(sparseArray, key)) {
1270
- values.push(sparseArray[key]);
1268
+ for (var key in collection) {
1269
+ if (hasOwnProperty.call(collection, key)) {
1270
+ values.push(collection[key]);
1271
1271
  }
1272
1272
  }
1273
1273
  return values;
@@ -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'
@@ -8670,12 +8670,10 @@ var ts;
8670
8670
  Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher: diag(2802, ts.DiagnosticCategory.Error, "Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es201_2802", "Type '{0}' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher."),
8671
8671
  Cannot_assign_to_private_method_0_Private_methods_are_not_writable: diag(2803, ts.DiagnosticCategory.Error, "Cannot_assign_to_private_method_0_Private_methods_are_not_writable_2803", "Cannot assign to private method '{0}'. Private methods are not writable."),
8672
8672
  Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name: diag(2804, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name_2804", "Duplicate identifier '{0}'. Static and instance elements cannot share the same private name."),
8673
- Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag: diag(2805, ts.DiagnosticCategory.Error, "Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_no_2805", "Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag."),
8674
8673
  Private_accessor_was_defined_without_a_getter: diag(2806, ts.DiagnosticCategory.Error, "Private_accessor_was_defined_without_a_getter_2806", "Private accessor was defined without a getter."),
8675
8674
  This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."),
8676
8675
  A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"),
8677
8676
  Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."),
8678
- Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false: diag(2810, ts.DiagnosticCategory.Error, "Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnex_2810", "Property '{0}' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'."),
8679
8677
  Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"),
8680
8678
  Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."),
8681
8679
  Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."),
@@ -9626,6 +9624,7 @@ var ts;
9626
9624
  Add_missing_attributes: diag(95167, ts.DiagnosticCategory.Message, "Add_missing_attributes_95167", "Add missing attributes"),
9627
9625
  Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"),
9628
9626
  Add_undefined_to_optional_property_type: diag(95169, ts.DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"),
9627
+ Convert_named_imports_to_default_import: diag(95170, ts.DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"),
9629
9628
  No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
9630
9629
  Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
9631
9630
  JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
@@ -12798,12 +12797,17 @@ var ts;
12798
12797
  /** Gets the text of a jsdoc comment, flattening links to their text. */
12799
12798
  function getTextOfJSDocComment(comment) {
12800
12799
  return typeof comment === "string" ? comment
12801
- : comment === null || comment === void 0 ? void 0 : comment.map(function (c) {
12802
- // TODO: Other kinds here
12803
- return c.kind === 319 /* JSDocText */ ? c.text : "{@link " + (c.name ? ts.entityNameToString(c.name) + " " : "") + c.text + "}";
12804
- }).join("");
12800
+ : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 319 /* JSDocText */ ? c.text : formatJSDocLink(c); }).join("");
12805
12801
  }
12806
12802
  ts.getTextOfJSDocComment = getTextOfJSDocComment;
12803
+ function formatJSDocLink(link) {
12804
+ var kind = link.kind === 322 /* JSDocLink */ ? "link"
12805
+ : link.kind === 323 /* JSDocLinkCode */ ? "linkcode"
12806
+ : "linkplain";
12807
+ var name = link.name ? ts.entityNameToString(link.name) : "";
12808
+ var space = link.name && link.text.startsWith("://") ? "" : " ";
12809
+ return "{@" + kind + " " + name + space + link.text + "}";
12810
+ }
12807
12811
  /**
12808
12812
  * Gets the effective type parameters. If the node was parsed in a
12809
12813
  * JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
@@ -46852,8 +46856,8 @@ var ts;
46852
46856
  TypeFacts[TypeFacts["AllTypeofNE"] = 556800] = "AllTypeofNE";
46853
46857
  TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts";
46854
46858
  // Masks
46855
- TypeFacts[TypeFacts["OrFactsMask"] = 8288] = "OrFactsMask";
46856
- TypeFacts[TypeFacts["AndFactsMask"] = 16768927] = "AndFactsMask";
46859
+ TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
46860
+ TypeFacts[TypeFacts["AndFactsMask"] = 16768959] = "AndFactsMask";
46857
46861
  })(TypeFacts || (TypeFacts = {}));
46858
46862
  var typeofEQFacts = new ts.Map(ts.getEntries({
46859
46863
  string: 1 /* TypeofEQString */,
@@ -67961,7 +67965,10 @@ var ts;
67961
67965
  (type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ :
67962
67966
  (type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
67963
67967
  }
67964
- if (flags & 524288 /* Object */ && !ignoreObjects) {
67968
+ if (flags & 524288 /* Object */) {
67969
+ if (ignoreObjects) {
67970
+ return 16768959 /* AndFactsMask */; // This is the identity element for computing type facts of intersection.
67971
+ }
67965
67972
  return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ?
67966
67973
  strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ :
67967
67974
  isFunctionObjectType(type) ?
@@ -68009,7 +68016,7 @@ var ts;
68009
68016
  oredFacts |= f;
68010
68017
  andedFacts &= f;
68011
68018
  }
68012
- return oredFacts & 8288 /* OrFactsMask */ | andedFacts & 16768927 /* AndFactsMask */;
68019
+ return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 16768959 /* AndFactsMask */;
68013
68020
  }
68014
68021
  function getTypeWithFacts(type, include) {
68015
68022
  return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
@@ -69969,6 +69976,9 @@ var ts;
69969
69976
  return getTypeOfSymbol(symbol);
69970
69977
  }
69971
69978
  function checkIdentifier(node, checkMode) {
69979
+ if (ts.isThisInTypeQuery(node)) {
69980
+ return checkThisExpression(node);
69981
+ }
69972
69982
  var symbol = getResolvedSymbol(node);
69973
69983
  if (symbol === unknownSymbol) {
69974
69984
  return errorType;
@@ -71760,7 +71770,8 @@ var ts;
71760
71770
  var links = getNodeLinks(node.expression);
71761
71771
  if (!links.resolvedType) {
71762
71772
  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 */) {
71773
+ && ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */
71774
+ && node.parent.kind !== 171 /* GetAccessor */ && node.parent.kind !== 172 /* SetAccessor */) {
71764
71775
  return links.resolvedType = errorType;
71765
71776
  }
71766
71777
  links.resolvedType = checkExpression(node.expression);
@@ -72929,23 +72940,6 @@ var ts;
72929
72940
  if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) {
72930
72941
  grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right));
72931
72942
  }
72932
- if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && !useDefineForClassFields)) {
72933
- var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration);
72934
- var parentStaticFieldInitializer = ts.findAncestor(node, function (n) {
72935
- if (n === lexicalClass_1)
72936
- return "quit";
72937
- if (ts.isPropertyDeclaration(n.parent) && ts.hasStaticModifier(n.parent) && n.parent.initializer === n && n.parent.parent === lexicalClass_1) {
72938
- return true;
72939
- }
72940
- return false;
72941
- });
72942
- if (parentStaticFieldInitializer) {
72943
- var parentStaticFieldInitializerSymbol = getSymbolOfNode(parentStaticFieldInitializer.parent);
72944
- ts.Debug.assert(parentStaticFieldInitializerSymbol, "Initializer without declaration symbol");
72945
- var diagnostic = error(node, ts.Diagnostics.Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false, ts.symbolName(lexicallyScopedSymbol));
72946
- ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(parentStaticFieldInitializer.parent, ts.Diagnostics.Initializer_for_property_0, ts.symbolName(parentStaticFieldInitializerSymbol)));
72947
- }
72948
- }
72949
72943
  if (isAnyLike) {
72950
72944
  if (lexicallyScopedSymbol) {
72951
72945
  return isErrorType(apparentType) ? errorType : apparentType;
@@ -75708,6 +75702,10 @@ var ts;
75708
75702
  return restParameter.escapedName;
75709
75703
  }
75710
75704
  function getParameterIdentifierNameAtPosition(signature, pos) {
75705
+ var _a;
75706
+ if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 315 /* JSDocFunctionType */) {
75707
+ return undefined;
75708
+ }
75711
75709
  var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
75712
75710
  if (pos < paramCount) {
75713
75711
  var param = signature.parameters[pos];
@@ -78577,9 +78575,6 @@ var ts;
78577
78575
  checkGrammarComputedPropertyName(node.name);
78578
78576
  checkVariableLikeDeclaration(node);
78579
78577
  setNodeLinksForPrivateIdentifierScope(node);
78580
- if (ts.isPrivateIdentifier(node.name) && ts.hasStaticModifier(node) && node.initializer && languageVersion === 99 /* ESNext */ && !compilerOptions.useDefineForClassFields) {
78581
- error(node.initializer, ts.Diagnostics.Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag);
78582
- }
78583
78578
  // property signatures already report "initializer not allowed in ambient context" elsewhere
78584
78579
  if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 166 /* PropertyDeclaration */ && node.initializer) {
78585
78580
  error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name));
@@ -84472,7 +84467,10 @@ var ts;
84472
84467
  case 80 /* PrivateIdentifier */:
84473
84468
  case 205 /* PropertyAccessExpression */:
84474
84469
  case 160 /* QualifiedName */:
84475
- return getSymbolOfNameOrPropertyAccessExpression(node);
84470
+ if (!ts.isThisInTypeQuery(node)) {
84471
+ return getSymbolOfNameOrPropertyAccessExpression(node);
84472
+ }
84473
+ // falls through
84476
84474
  case 108 /* ThisKeyword */:
84477
84475
  var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false);
84478
84476
  if (ts.isFunctionLike(container)) {
@@ -92266,10 +92264,12 @@ var ts;
92266
92264
  var languageVersion = ts.getEmitScriptTarget(compilerOptions);
92267
92265
  var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions);
92268
92266
  var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ES2022 */;
92267
+ // We need to transform `this` in a static initializer into a reference to the class
92268
+ // when targeting < ES2022 since the assignment will be moved outside of the class body.
92269
+ var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ES2022 */;
92269
92270
  // We don't need to transform `super` property access when targeting ES5, ES3 because
92270
92271
  // the es2015 transformation handles those.
92271
- var shouldTransformSuperInStaticInitializers = (languageVersion <= 8 /* ES2021 */ || !useDefineForClassFields) && languageVersion >= 2 /* ES2015 */;
92272
- var shouldTransformThisInStaticInitializers = languageVersion <= 8 /* ES2021 */ || !useDefineForClassFields;
92272
+ var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */;
92273
92273
  var previousOnSubstituteNode = context.onSubstituteNode;
92274
92274
  context.onSubstituteNode = onSubstituteNode;
92275
92275
  var previousOnEmitNode = context.onEmitNode;
@@ -92498,6 +92498,10 @@ var ts;
92498
92498
  ts.Debug.assert(!ts.some(node.decorators));
92499
92499
  if (ts.isPrivateIdentifier(node.name)) {
92500
92500
  if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
92501
+ if (ts.isStatic(node)) {
92502
+ // static fields are left as is
92503
+ return ts.visitEachChild(node, visitor, context);
92504
+ }
92501
92505
  // Initializer is elided as the field is initialized in transformConstructor.
92502
92506
  return factory.updatePropertyDeclaration(node,
92503
92507
  /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name,
@@ -92519,6 +92523,22 @@ var ts;
92519
92523
  if (expr && !ts.isSimpleInlineableExpression(expr)) {
92520
92524
  getPendingExpressions().push(expr);
92521
92525
  }
92526
+ if (ts.isStatic(node) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
92527
+ var initializerStatement = transformPropertyOrClassStaticBlock(node, factory.createThis());
92528
+ if (initializerStatement) {
92529
+ var staticBlock = factory.createClassStaticBlockDeclaration(
92530
+ /*decorators*/ undefined,
92531
+ /*modifiers*/ undefined, factory.createBlock([initializerStatement]));
92532
+ ts.setOriginalNode(staticBlock, node);
92533
+ ts.setCommentRange(staticBlock, node);
92534
+ // Set the comment range for the statement to an empty synthetic range
92535
+ // and drop synthetic comments from the statement to avoid printing them twice.
92536
+ ts.setCommentRange(initializerStatement, { pos: -1, end: -1 });
92537
+ ts.setSyntheticLeadingComments(initializerStatement, undefined);
92538
+ ts.setSyntheticTrailingComments(initializerStatement, undefined);
92539
+ return staticBlock;
92540
+ }
92541
+ }
92522
92542
  return undefined;
92523
92543
  }
92524
92544
  function createPrivateIdentifierAccess(info, receiver) {
@@ -92906,7 +92926,6 @@ var ts;
92906
92926
  if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) {
92907
92927
  enableSubstitutionForClassStaticThisOrSuperReference();
92908
92928
  }
92909
- var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
92910
92929
  // If a class has private static fields, or a static field has a `this` or `super` reference,
92911
92930
  // then we need to allocate a temp variable to hold on to that reference.
92912
92931
  var pendingClassReferenceAssignment;
@@ -92934,6 +92953,7 @@ var ts;
92934
92953
  // From ES6 specification:
92935
92954
  // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using
92936
92955
  // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration.
92956
+ var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
92937
92957
  if (ts.some(staticProperties)) {
92938
92958
  addPropertyOrClassStaticBlockStatements(statements, staticProperties, factory.getInternalName(node));
92939
92959
  }
@@ -92972,7 +92992,7 @@ var ts;
92972
92992
  }
92973
92993
  var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), node.modifiers, node.name,
92974
92994
  /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, heritageClauseVisitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass));
92975
- var hasTransformableStatics = ts.some(staticPropertiesOrClassStaticBlocks, function (p) { return ts.isClassStaticBlockDeclaration(p) || !!p.initializer || (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifier(p.name)); });
92995
+ var hasTransformableStatics = shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(staticPropertiesOrClassStaticBlocks, function (p) { return ts.isClassStaticBlockDeclaration(p) || !!p.initializer || ts.isPrivateIdentifier(p.name); });
92976
92996
  if (hasTransformableStatics || ts.some(pendingExpressions)) {
92977
92997
  if (isDecoratedClassDeclaration) {
92978
92998
  ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration.");
@@ -93019,6 +93039,7 @@ var ts;
93019
93039
  return undefined;
93020
93040
  }
93021
93041
  function transformClassMembers(node, isDerivedClass) {
93042
+ var members = [];
93022
93043
  if (shouldTransformPrivateElementsOrClassStaticBlocks) {
93023
93044
  // Declare private names.
93024
93045
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
@@ -93031,12 +93052,20 @@ var ts;
93031
93052
  createBrandCheckWeakSetForPrivateMethods();
93032
93053
  }
93033
93054
  }
93034
- var members = [];
93035
93055
  var constructor = transformConstructor(node, isDerivedClass);
93056
+ var visitedMembers = ts.visitNodes(node.members, classElementVisitor, ts.isClassElement);
93036
93057
  if (constructor) {
93037
93058
  members.push(constructor);
93038
93059
  }
93039
- ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
93060
+ if (!shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(pendingExpressions)) {
93061
+ members.push(factory.createClassStaticBlockDeclaration(
93062
+ /*decorators*/ undefined,
93063
+ /*modifiers*/ undefined, factory.createBlock([
93064
+ factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))
93065
+ ])));
93066
+ pendingExpressions = undefined;
93067
+ }
93068
+ ts.addRange(members, visitedMembers);
93040
93069
  return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members);
93041
93070
  }
93042
93071
  function createBrandCheckWeakSetForPrivateMethods() {
@@ -93179,24 +93208,34 @@ var ts;
93179
93208
  function addPropertyOrClassStaticBlockStatements(statements, properties, receiver) {
93180
93209
  for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
93181
93210
  var property = properties_7[_i];
93182
- var expression = ts.isClassStaticBlockDeclaration(property) ?
93183
- transformClassStaticBlockDeclaration(property) :
93184
- transformProperty(property, receiver);
93185
- if (!expression) {
93211
+ if (ts.isStatic(property) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
93212
+ continue;
93213
+ }
93214
+ var statement = transformPropertyOrClassStaticBlock(property, receiver);
93215
+ if (!statement) {
93186
93216
  continue;
93187
93217
  }
93188
- var statement = factory.createExpressionStatement(expression);
93189
- ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
93190
- ts.setCommentRange(statement, property);
93191
- ts.setOriginalNode(statement, property);
93192
- // `setOriginalNode` *copies* the `emitNode` from `property`, so now both
93193
- // `statement` and `expression` have a copy of the synthesized comments.
93194
- // Drop the comments from expression to avoid printing them twice.
93195
- ts.setSyntheticLeadingComments(expression, undefined);
93196
- ts.setSyntheticTrailingComments(expression, undefined);
93197
93218
  statements.push(statement);
93198
93219
  }
93199
93220
  }
93221
+ function transformPropertyOrClassStaticBlock(property, receiver) {
93222
+ var expression = ts.isClassStaticBlockDeclaration(property) ?
93223
+ transformClassStaticBlockDeclaration(property) :
93224
+ transformProperty(property, receiver);
93225
+ if (!expression) {
93226
+ return undefined;
93227
+ }
93228
+ var statement = factory.createExpressionStatement(expression);
93229
+ ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
93230
+ ts.setCommentRange(statement, property);
93231
+ ts.setOriginalNode(statement, property);
93232
+ // `setOriginalNode` *copies* the `emitNode` from `property`, so now both
93233
+ // `statement` and `expression` have a copy of the synthesized comments.
93234
+ // Drop the comments from expression to avoid printing them twice.
93235
+ ts.setSyntheticLeadingComments(expression, undefined);
93236
+ ts.setSyntheticTrailingComments(expression, undefined);
93237
+ return statement;
93238
+ }
93200
93239
  /**
93201
93240
  * Generates assignment expressions for property initializers.
93202
93241
  *
@@ -94446,6 +94485,7 @@ var ts;
94446
94485
  var exportedVariableStatement = false;
94447
94486
  var enabledSubstitutions;
94448
94487
  var enclosingFunctionFlags;
94488
+ var parametersWithPrecedingObjectRestOrSpread;
94449
94489
  var enclosingSuperContainerFlags = 0;
94450
94490
  var hierarchyFacts = 0;
94451
94491
  var currentSourceFile;
@@ -94902,6 +94942,7 @@ var ts;
94902
94942
  /*incrementor*/ undefined,
94903
94943
  /*statement*/ convertForOfStatementHead(node, getValue)),
94904
94944
  /*location*/ node), 256 /* NoTokenTrailingSourceMaps */);
94945
+ ts.setOriginalNode(forStatement, node);
94905
94946
  return factory.createTryStatement(factory.createBlock([
94906
94947
  factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement)
94907
94948
  ]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([
@@ -94919,7 +94960,19 @@ var ts;
94919
94960
  ]), 1 /* SingleLine */))
94920
94961
  ]));
94921
94962
  }
94963
+ function parameterVisitor(node) {
94964
+ ts.Debug.assertNode(node, ts.isParameter);
94965
+ return visitParameter(node);
94966
+ }
94922
94967
  function visitParameter(node) {
94968
+ if (parametersWithPrecedingObjectRestOrSpread === null || parametersWithPrecedingObjectRestOrSpread === void 0 ? void 0 : parametersWithPrecedingObjectRestOrSpread.has(node)) {
94969
+ return factory.updateParameterDeclaration(node,
94970
+ /*decorators*/ undefined,
94971
+ /*modifiers*/ undefined, node.dotDotDotToken, ts.isBindingPattern(node.name) ? factory.getGeneratedNameForNode(node) : node.name,
94972
+ /*questionToken*/ undefined,
94973
+ /*type*/ undefined,
94974
+ /*initializer*/ undefined);
94975
+ }
94923
94976
  if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
94924
94977
  // Binding patterns are converted into a generated name and are
94925
94978
  // evaluated inside the function body.
@@ -94931,85 +94984,119 @@ var ts;
94931
94984
  }
94932
94985
  return ts.visitEachChild(node, visitor, context);
94933
94986
  }
94987
+ function collectParametersWithPrecedingObjectRestOrSpread(node) {
94988
+ var parameters;
94989
+ for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
94990
+ var parameter = _a[_i];
94991
+ if (parameters) {
94992
+ parameters.add(parameter);
94993
+ }
94994
+ else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
94995
+ parameters = new ts.Set();
94996
+ }
94997
+ }
94998
+ return parameters;
94999
+ }
94934
95000
  function visitConstructorDeclaration(node) {
94935
95001
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
94936
- enclosingFunctionFlags = 0 /* Normal */;
95002
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95003
+ enclosingFunctionFlags = ts.getFunctionFlags(node);
95004
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94937
95005
  var updated = factory.updateConstructorDeclaration(node,
94938
- /*decorators*/ undefined, node.modifiers, ts.visitParameterList(node.parameters, visitor, context), transformFunctionBody(node));
95006
+ /*decorators*/ undefined, node.modifiers, ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node));
94939
95007
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95008
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
94940
95009
  return updated;
94941
95010
  }
94942
95011
  function visitGetAccessorDeclaration(node) {
94943
95012
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
94944
- enclosingFunctionFlags = 0 /* Normal */;
95013
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95014
+ enclosingFunctionFlags = ts.getFunctionFlags(node);
95015
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94945
95016
  var updated = factory.updateGetAccessorDeclaration(node,
94946
- /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, visitor, context),
95017
+ /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context),
94947
95018
  /*type*/ undefined, transformFunctionBody(node));
94948
95019
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95020
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
94949
95021
  return updated;
94950
95022
  }
94951
95023
  function visitSetAccessorDeclaration(node) {
94952
95024
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
94953
- enclosingFunctionFlags = 0 /* Normal */;
95025
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95026
+ enclosingFunctionFlags = ts.getFunctionFlags(node);
95027
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94954
95028
  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));
95029
+ /*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node));
94956
95030
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95031
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
94957
95032
  return updated;
94958
95033
  }
94959
95034
  function visitMethodDeclaration(node) {
94960
95035
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95036
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
94961
95037
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95038
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94962
95039
  var updated = factory.updateMethodDeclaration(node,
94963
95040
  /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */
94964
95041
  ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
94965
95042
  : node.modifiers, enclosingFunctionFlags & 2 /* Async */
94966
95043
  ? undefined
94967
95044
  : 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),
95045
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
94969
95046
  /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
94970
95047
  ? transformAsyncGeneratorFunctionBody(node)
94971
95048
  : transformFunctionBody(node));
94972
95049
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95050
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
94973
95051
  return updated;
94974
95052
  }
94975
95053
  function visitFunctionDeclaration(node) {
94976
95054
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95055
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
94977
95056
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95057
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94978
95058
  var updated = factory.updateFunctionDeclaration(node,
94979
95059
  /*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */
94980
95060
  ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
94981
95061
  : node.modifiers, enclosingFunctionFlags & 2 /* Async */
94982
95062
  ? undefined
94983
95063
  : node.asteriskToken, node.name,
94984
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95064
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
94985
95065
  /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
94986
95066
  ? transformAsyncGeneratorFunctionBody(node)
94987
95067
  : transformFunctionBody(node));
94988
95068
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95069
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
94989
95070
  return updated;
94990
95071
  }
94991
95072
  function visitArrowFunction(node) {
94992
95073
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95074
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
94993
95075
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95076
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
94994
95077
  var updated = factory.updateArrowFunction(node, node.modifiers,
94995
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95078
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
94996
95079
  /*type*/ undefined, node.equalsGreaterThanToken, transformFunctionBody(node));
94997
95080
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95081
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
94998
95082
  return updated;
94999
95083
  }
95000
95084
  function visitFunctionExpression(node) {
95001
95085
  var savedEnclosingFunctionFlags = enclosingFunctionFlags;
95086
+ var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
95002
95087
  enclosingFunctionFlags = ts.getFunctionFlags(node);
95088
+ parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
95003
95089
  var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */
95004
95090
  ? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
95005
95091
  : node.modifiers, enclosingFunctionFlags & 2 /* Async */
95006
95092
  ? undefined
95007
95093
  : node.asteriskToken, node.name,
95008
- /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, visitor, context),
95094
+ /*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
95009
95095
  /*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
95010
95096
  ? transformAsyncGeneratorFunctionBody(node)
95011
95097
  : transformFunctionBody(node));
95012
95098
  enclosingFunctionFlags = savedEnclosingFunctionFlags;
95099
+ parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
95013
95100
  return updated;
95014
95101
  }
95015
95102
  function transformAsyncGeneratorFunctionBody(node) {
@@ -95070,16 +95157,71 @@ var ts;
95070
95157
  return body;
95071
95158
  }
95072
95159
  function appendObjectRestAssignmentsIfNeeded(statements, node) {
95160
+ var containsPrecedingObjectRestOrSpread = false;
95073
95161
  for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
95074
95162
  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,
95163
+ if (containsPrecedingObjectRestOrSpread) {
95164
+ if (ts.isBindingPattern(parameter.name)) {
95165
+ // In cases where a binding pattern is simply '[]' or '{}',
95166
+ // we usually don't want to emit a var declaration; however, in the presence
95167
+ // of an initializer, we must emit that expression to preserve side effects.
95168
+ //
95169
+ // NOTE: see `insertDefaultValueAssignmentForBindingPattern` in es2015.ts
95170
+ if (parameter.name.elements.length > 0) {
95171
+ var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter));
95172
+ if (ts.some(declarations)) {
95173
+ var declarationList = factory.createVariableDeclarationList(declarations);
95174
+ var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList);
95175
+ ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
95176
+ statements = ts.append(statements, statement);
95177
+ }
95178
+ }
95179
+ else if (parameter.initializer) {
95180
+ var name = factory.getGeneratedNameForNode(parameter);
95181
+ var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression);
95182
+ var assignment = factory.createAssignment(name, initializer);
95183
+ var statement = factory.createExpressionStatement(assignment);
95184
+ ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
95185
+ statements = ts.append(statements, statement);
95186
+ }
95187
+ }
95188
+ else if (parameter.initializer) {
95189
+ // Converts a parameter initializer into a function body statement, i.e.:
95190
+ //
95191
+ // function f(x = 1) { }
95192
+ //
95193
+ // becomes
95194
+ //
95195
+ // function f(x) {
95196
+ // if (typeof x === "undefined") { x = 1; }
95197
+ // }
95198
+ var name = factory.cloneNode(parameter.name);
95199
+ ts.setTextRange(name, parameter.name);
95200
+ ts.setEmitFlags(name, 48 /* NoSourceMap */);
95201
+ var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression);
95202
+ ts.addEmitFlags(initializer, 48 /* NoSourceMap */ | 1536 /* NoComments */);
95203
+ var assignment = factory.createAssignment(name, initializer);
95204
+ ts.setTextRange(assignment, parameter);
95205
+ ts.setEmitFlags(assignment, 1536 /* NoComments */);
95206
+ var block = factory.createBlock([factory.createExpressionStatement(assignment)]);
95207
+ ts.setTextRange(block, parameter);
95208
+ ts.setEmitFlags(block, 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */);
95209
+ var typeCheck = factory.createTypeCheck(factory.cloneNode(parameter.name), "undefined");
95210
+ var statement = factory.createIfStatement(typeCheck, block);
95211
+ ts.startOnNewLine(statement);
95212
+ ts.setTextRange(statement, parameter);
95213
+ ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */);
95214
+ statements = ts.append(statements, statement);
95215
+ }
95216
+ }
95217
+ else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
95218
+ containsPrecedingObjectRestOrSpread = true;
95219
+ var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter),
95078
95220
  /*doNotRecordTempVariablesInLine*/ false,
95079
95221
  /*skipInitializer*/ true);
95080
95222
  if (ts.some(declarations)) {
95081
- var statement = factory.createVariableStatement(
95082
- /*modifiers*/ undefined, factory.createVariableDeclarationList(declarations));
95223
+ var declarationList = factory.createVariableDeclarationList(declarations);
95224
+ var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList);
95083
95225
  ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
95084
95226
  statements = ts.append(statements, statement);
95085
95227
  }
@@ -98330,10 +98472,12 @@ var ts;
98330
98472
  // variables declared in the loop initializer that will be changed inside the loop
98331
98473
  var loopOutParameters = [];
98332
98474
  if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) {
98333
- var hasCapturedBindingsInForInitializer = shouldConvertInitializerOfForStatement(node);
98475
+ var hasCapturedBindingsInForHead = shouldConvertInitializerOfForStatement(node) ||
98476
+ shouldConvertConditionOfForStatement(node) ||
98477
+ shouldConvertIncrementorOfForStatement(node);
98334
98478
  for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) {
98335
98479
  var decl = _a[_i];
98336
- processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
98480
+ processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForHead);
98337
98481
  }
98338
98482
  }
98339
98483
  var currentState = { loopParameters: loopParameters, loopOutParameters: loopOutParameters };
@@ -98687,27 +98831,33 @@ var ts;
98687
98831
  caseClauses.push(factory.createCaseClause(factory.createStringLiteral(labelMarker), statements));
98688
98832
  });
98689
98833
  }
98690
- function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer) {
98834
+ function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForHead) {
98691
98835
  var name = decl.name;
98692
98836
  if (ts.isBindingPattern(name)) {
98693
98837
  for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
98694
98838
  var element = _a[_i];
98695
98839
  if (!ts.isOmittedExpression(element)) {
98696
- processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForInitializer);
98840
+ processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForHead);
98697
98841
  }
98698
98842
  }
98699
98843
  }
98700
98844
  else {
98701
98845
  loopParameters.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name));
98702
98846
  var checkFlags = resolver.getNodeCheckFlags(decl);
98703
- if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForInitializer) {
98847
+ if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) {
98704
98848
  var outParamName = factory.createUniqueName("out_" + ts.idText(name));
98705
98849
  var flags = 0;
98706
98850
  if (checkFlags & 4194304 /* NeedsLoopOutParameter */) {
98707
98851
  flags |= 1 /* Body */;
98708
98852
  }
98709
- if (ts.isForStatement(container) && container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
98710
- flags |= 2 /* Initializer */;
98853
+ if (ts.isForStatement(container)) {
98854
+ if (container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
98855
+ flags |= 2 /* Initializer */;
98856
+ }
98857
+ if (container.condition && resolver.isBindingCapturedByNode(container.condition, decl) ||
98858
+ container.incrementor && resolver.isBindingCapturedByNode(container.incrementor, decl)) {
98859
+ flags |= 1 /* Body */;
98860
+ }
98711
98861
  }
98712
98862
  loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName });
98713
98863
  }