@typescript-deploys/pr-build 4.6.0-pr-47607-13 → 4.6.0-pr-47607-31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cs/diagnosticMessages.generated.json +22 -8
- package/lib/de/diagnosticMessages.generated.json +23 -10
- package/lib/es/diagnosticMessages.generated.json +22 -8
- package/lib/fr/diagnosticMessages.generated.json +5 -4
- package/lib/it/diagnosticMessages.generated.json +22 -8
- package/lib/ja/diagnosticMessages.generated.json +5 -4
- package/lib/ko/diagnosticMessages.generated.json +5 -4
- package/lib/lib.dom.d.ts +1 -1
- package/lib/lib.webworker.d.ts +1 -1
- package/lib/pl/diagnosticMessages.generated.json +5 -4
- package/lib/pt-br/diagnosticMessages.generated.json +22 -8
- package/lib/ru/diagnosticMessages.generated.json +6 -6
- package/lib/tr/diagnosticMessages.generated.json +5 -4
- package/lib/tsc.js +807 -695
- package/lib/tsserver.js +1372 -1058
- package/lib/tsserverlibrary.d.ts +1 -1
- package/lib/tsserverlibrary.js +1372 -1058
- package/lib/typescript.d.ts +1 -1
- package/lib/typescript.js +1372 -1058
- package/lib/typescriptServices.d.ts +1 -1
- package/lib/typescriptServices.js +1372 -1058
- package/lib/typingsInstaller.js +1116 -980
- package/lib/zh-cn/diagnosticMessages.generated.json +22 -8
- package/lib/zh-tw/diagnosticMessages.generated.json +6 -6
- package/package.json +1 -1
package/lib/typingsInstaller.js
CHANGED
|
@@ -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-insiders.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-insiders.20220207";
|
|
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(
|
|
1266
|
+
function getOwnValues(collection) {
|
|
1267
1267
|
var values = [];
|
|
1268
|
-
for (var key in
|
|
1269
|
-
if (hasOwnProperty.call(
|
|
1270
|
-
values.push(
|
|
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;
|
|
@@ -5714,704 +5714,6 @@ var ts;
|
|
|
5714
5714
|
},
|
|
5715
5715
|
};
|
|
5716
5716
|
})(ts || (ts = {}));
|
|
5717
|
-
/* @internal */
|
|
5718
|
-
var ts;
|
|
5719
|
-
(function (ts) {
|
|
5720
|
-
/**
|
|
5721
|
-
* Internally, we represent paths as strings with '/' as the directory separator.
|
|
5722
|
-
* When we make system calls (eg: LanguageServiceHost.getDirectory()),
|
|
5723
|
-
* we expect the host to correctly handle paths in our specified format.
|
|
5724
|
-
*/
|
|
5725
|
-
ts.directorySeparator = "/";
|
|
5726
|
-
ts.altDirectorySeparator = "\\";
|
|
5727
|
-
var urlSchemeSeparator = "://";
|
|
5728
|
-
var backslashRegExp = /\\/g;
|
|
5729
|
-
//// Path Tests
|
|
5730
|
-
/**
|
|
5731
|
-
* Determines whether a charCode corresponds to `/` or `\`.
|
|
5732
|
-
*/
|
|
5733
|
-
function isAnyDirectorySeparator(charCode) {
|
|
5734
|
-
return charCode === 47 /* slash */ || charCode === 92 /* backslash */;
|
|
5735
|
-
}
|
|
5736
|
-
ts.isAnyDirectorySeparator = isAnyDirectorySeparator;
|
|
5737
|
-
/**
|
|
5738
|
-
* Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.).
|
|
5739
|
-
*/
|
|
5740
|
-
function isUrl(path) {
|
|
5741
|
-
return getEncodedRootLength(path) < 0;
|
|
5742
|
-
}
|
|
5743
|
-
ts.isUrl = isUrl;
|
|
5744
|
-
/**
|
|
5745
|
-
* Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path
|
|
5746
|
-
* like `c:`, `c:\` or `c:/`).
|
|
5747
|
-
*/
|
|
5748
|
-
function isRootedDiskPath(path) {
|
|
5749
|
-
return getEncodedRootLength(path) > 0;
|
|
5750
|
-
}
|
|
5751
|
-
ts.isRootedDiskPath = isRootedDiskPath;
|
|
5752
|
-
/**
|
|
5753
|
-
* Determines whether a path consists only of a path root.
|
|
5754
|
-
*/
|
|
5755
|
-
function isDiskPathRoot(path) {
|
|
5756
|
-
var rootLength = getEncodedRootLength(path);
|
|
5757
|
-
return rootLength > 0 && rootLength === path.length;
|
|
5758
|
-
}
|
|
5759
|
-
ts.isDiskPathRoot = isDiskPathRoot;
|
|
5760
|
-
/**
|
|
5761
|
-
* Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.).
|
|
5762
|
-
*
|
|
5763
|
-
* ```ts
|
|
5764
|
-
* // POSIX
|
|
5765
|
-
* pathIsAbsolute("/path/to/file.ext") === true
|
|
5766
|
-
* // DOS
|
|
5767
|
-
* pathIsAbsolute("c:/path/to/file.ext") === true
|
|
5768
|
-
* // URL
|
|
5769
|
-
* pathIsAbsolute("file:///path/to/file.ext") === true
|
|
5770
|
-
* // Non-absolute
|
|
5771
|
-
* pathIsAbsolute("path/to/file.ext") === false
|
|
5772
|
-
* pathIsAbsolute("./path/to/file.ext") === false
|
|
5773
|
-
* ```
|
|
5774
|
-
*/
|
|
5775
|
-
function pathIsAbsolute(path) {
|
|
5776
|
-
return getEncodedRootLength(path) !== 0;
|
|
5777
|
-
}
|
|
5778
|
-
ts.pathIsAbsolute = pathIsAbsolute;
|
|
5779
|
-
/**
|
|
5780
|
-
* Determines whether a path starts with a relative path component (i.e. `.` or `..`).
|
|
5781
|
-
*/
|
|
5782
|
-
function pathIsRelative(path) {
|
|
5783
|
-
return /^\.\.?($|[\\/])/.test(path);
|
|
5784
|
-
}
|
|
5785
|
-
ts.pathIsRelative = pathIsRelative;
|
|
5786
|
-
/**
|
|
5787
|
-
* Determines whether a path is neither relative nor absolute, e.g. "path/to/file".
|
|
5788
|
-
* Also known misleadingly as "non-relative".
|
|
5789
|
-
*/
|
|
5790
|
-
function pathIsBareSpecifier(path) {
|
|
5791
|
-
return !pathIsAbsolute(path) && !pathIsRelative(path);
|
|
5792
|
-
}
|
|
5793
|
-
ts.pathIsBareSpecifier = pathIsBareSpecifier;
|
|
5794
|
-
function hasExtension(fileName) {
|
|
5795
|
-
return ts.stringContains(getBaseFileName(fileName), ".");
|
|
5796
|
-
}
|
|
5797
|
-
ts.hasExtension = hasExtension;
|
|
5798
|
-
function fileExtensionIs(path, extension) {
|
|
5799
|
-
return path.length > extension.length && ts.endsWith(path, extension);
|
|
5800
|
-
}
|
|
5801
|
-
ts.fileExtensionIs = fileExtensionIs;
|
|
5802
|
-
function fileExtensionIsOneOf(path, extensions) {
|
|
5803
|
-
for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
|
|
5804
|
-
var extension = extensions_1[_i];
|
|
5805
|
-
if (fileExtensionIs(path, extension)) {
|
|
5806
|
-
return true;
|
|
5807
|
-
}
|
|
5808
|
-
}
|
|
5809
|
-
return false;
|
|
5810
|
-
}
|
|
5811
|
-
ts.fileExtensionIsOneOf = fileExtensionIsOneOf;
|
|
5812
|
-
/**
|
|
5813
|
-
* Determines whether a path has a trailing separator (`/` or `\\`).
|
|
5814
|
-
*/
|
|
5815
|
-
function hasTrailingDirectorySeparator(path) {
|
|
5816
|
-
return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1));
|
|
5817
|
-
}
|
|
5818
|
-
ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator;
|
|
5819
|
-
//// Path Parsing
|
|
5820
|
-
function isVolumeCharacter(charCode) {
|
|
5821
|
-
return (charCode >= 97 /* a */ && charCode <= 122 /* z */) ||
|
|
5822
|
-
(charCode >= 65 /* A */ && charCode <= 90 /* Z */);
|
|
5823
|
-
}
|
|
5824
|
-
function getFileUrlVolumeSeparatorEnd(url, start) {
|
|
5825
|
-
var ch0 = url.charCodeAt(start);
|
|
5826
|
-
if (ch0 === 58 /* colon */)
|
|
5827
|
-
return start + 1;
|
|
5828
|
-
if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) {
|
|
5829
|
-
var ch2 = url.charCodeAt(start + 2);
|
|
5830
|
-
if (ch2 === 97 /* a */ || ch2 === 65 /* A */)
|
|
5831
|
-
return start + 3;
|
|
5832
|
-
}
|
|
5833
|
-
return -1;
|
|
5834
|
-
}
|
|
5835
|
-
/**
|
|
5836
|
-
* Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
|
|
5837
|
-
* If the root is part of a URL, the twos-complement of the root length is returned.
|
|
5838
|
-
*/
|
|
5839
|
-
function getEncodedRootLength(path) {
|
|
5840
|
-
if (!path)
|
|
5841
|
-
return 0;
|
|
5842
|
-
var ch0 = path.charCodeAt(0);
|
|
5843
|
-
// POSIX or UNC
|
|
5844
|
-
if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) {
|
|
5845
|
-
if (path.charCodeAt(1) !== ch0)
|
|
5846
|
-
return 1; // POSIX: "/" (or non-normalized "\")
|
|
5847
|
-
var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2);
|
|
5848
|
-
if (p1 < 0)
|
|
5849
|
-
return path.length; // UNC: "//server" or "\\server"
|
|
5850
|
-
return p1 + 1; // UNC: "//server/" or "\\server\"
|
|
5851
|
-
}
|
|
5852
|
-
// DOS
|
|
5853
|
-
if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) {
|
|
5854
|
-
var ch2 = path.charCodeAt(2);
|
|
5855
|
-
if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */)
|
|
5856
|
-
return 3; // DOS: "c:/" or "c:\"
|
|
5857
|
-
if (path.length === 2)
|
|
5858
|
-
return 2; // DOS: "c:" (but not "c:d")
|
|
5859
|
-
}
|
|
5860
|
-
// URL
|
|
5861
|
-
var schemeEnd = path.indexOf(urlSchemeSeparator);
|
|
5862
|
-
if (schemeEnd !== -1) {
|
|
5863
|
-
var authorityStart = schemeEnd + urlSchemeSeparator.length;
|
|
5864
|
-
var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart);
|
|
5865
|
-
if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path"
|
|
5866
|
-
// For local "file" URLs, include the leading DOS volume (if present).
|
|
5867
|
-
// Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a
|
|
5868
|
-
// special case interpreted as "the machine from which the URL is being interpreted".
|
|
5869
|
-
var scheme = path.slice(0, schemeEnd);
|
|
5870
|
-
var authority = path.slice(authorityStart, authorityEnd);
|
|
5871
|
-
if (scheme === "file" && (authority === "" || authority === "localhost") &&
|
|
5872
|
-
isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
|
|
5873
|
-
var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
|
|
5874
|
-
if (volumeSeparatorEnd !== -1) {
|
|
5875
|
-
if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) {
|
|
5876
|
-
// URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/"
|
|
5877
|
-
return ~(volumeSeparatorEnd + 1);
|
|
5878
|
-
}
|
|
5879
|
-
if (volumeSeparatorEnd === path.length) {
|
|
5880
|
-
// URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a"
|
|
5881
|
-
// but not "file:///c:d" or "file:///c%3ad"
|
|
5882
|
-
return ~volumeSeparatorEnd;
|
|
5883
|
-
}
|
|
5884
|
-
}
|
|
5885
|
-
}
|
|
5886
|
-
return ~(authorityEnd + 1); // URL: "file://server/", "http://server/"
|
|
5887
|
-
}
|
|
5888
|
-
return ~path.length; // URL: "file://server", "http://server"
|
|
5889
|
-
}
|
|
5890
|
-
// relative
|
|
5891
|
-
return 0;
|
|
5892
|
-
}
|
|
5893
|
-
/**
|
|
5894
|
-
* Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
|
|
5895
|
-
*
|
|
5896
|
-
* For example:
|
|
5897
|
-
* ```ts
|
|
5898
|
-
* getRootLength("a") === 0 // ""
|
|
5899
|
-
* getRootLength("/") === 1 // "/"
|
|
5900
|
-
* getRootLength("c:") === 2 // "c:"
|
|
5901
|
-
* getRootLength("c:d") === 0 // ""
|
|
5902
|
-
* getRootLength("c:/") === 3 // "c:/"
|
|
5903
|
-
* getRootLength("c:\\") === 3 // "c:\\"
|
|
5904
|
-
* getRootLength("//server") === 7 // "//server"
|
|
5905
|
-
* getRootLength("//server/share") === 8 // "//server/"
|
|
5906
|
-
* getRootLength("\\\\server") === 7 // "\\\\server"
|
|
5907
|
-
* getRootLength("\\\\server\\share") === 8 // "\\\\server\\"
|
|
5908
|
-
* getRootLength("file:///path") === 8 // "file:///"
|
|
5909
|
-
* getRootLength("file:///c:") === 10 // "file:///c:"
|
|
5910
|
-
* getRootLength("file:///c:d") === 8 // "file:///"
|
|
5911
|
-
* getRootLength("file:///c:/path") === 11 // "file:///c:/"
|
|
5912
|
-
* getRootLength("file://server") === 13 // "file://server"
|
|
5913
|
-
* getRootLength("file://server/path") === 14 // "file://server/"
|
|
5914
|
-
* getRootLength("http://server") === 13 // "http://server"
|
|
5915
|
-
* getRootLength("http://server/path") === 14 // "http://server/"
|
|
5916
|
-
* ```
|
|
5917
|
-
*/
|
|
5918
|
-
function getRootLength(path) {
|
|
5919
|
-
var rootLength = getEncodedRootLength(path);
|
|
5920
|
-
return rootLength < 0 ? ~rootLength : rootLength;
|
|
5921
|
-
}
|
|
5922
|
-
ts.getRootLength = getRootLength;
|
|
5923
|
-
function getDirectoryPath(path) {
|
|
5924
|
-
path = normalizeSlashes(path);
|
|
5925
|
-
// If the path provided is itself the root, then return it.
|
|
5926
|
-
var rootLength = getRootLength(path);
|
|
5927
|
-
if (rootLength === path.length)
|
|
5928
|
-
return path;
|
|
5929
|
-
// return the leading portion of the path up to the last (non-terminal) directory separator
|
|
5930
|
-
// but not including any trailing directory separator.
|
|
5931
|
-
path = removeTrailingDirectorySeparator(path);
|
|
5932
|
-
return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator)));
|
|
5933
|
-
}
|
|
5934
|
-
ts.getDirectoryPath = getDirectoryPath;
|
|
5935
|
-
function getBaseFileName(path, extensions, ignoreCase) {
|
|
5936
|
-
path = normalizeSlashes(path);
|
|
5937
|
-
// if the path provided is itself the root, then it has not file name.
|
|
5938
|
-
var rootLength = getRootLength(path);
|
|
5939
|
-
if (rootLength === path.length)
|
|
5940
|
-
return "";
|
|
5941
|
-
// return the trailing portion of the path starting after the last (non-terminal) directory
|
|
5942
|
-
// separator but not including any trailing directory separator.
|
|
5943
|
-
path = removeTrailingDirectorySeparator(path);
|
|
5944
|
-
var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1));
|
|
5945
|
-
var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined;
|
|
5946
|
-
return extension ? name.slice(0, name.length - extension.length) : name;
|
|
5947
|
-
}
|
|
5948
|
-
ts.getBaseFileName = getBaseFileName;
|
|
5949
|
-
function tryGetExtensionFromPath(path, extension, stringEqualityComparer) {
|
|
5950
|
-
if (!ts.startsWith(extension, "."))
|
|
5951
|
-
extension = "." + extension;
|
|
5952
|
-
if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) {
|
|
5953
|
-
var pathExtension = path.slice(path.length - extension.length);
|
|
5954
|
-
if (stringEqualityComparer(pathExtension, extension)) {
|
|
5955
|
-
return pathExtension;
|
|
5956
|
-
}
|
|
5957
|
-
}
|
|
5958
|
-
}
|
|
5959
|
-
function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) {
|
|
5960
|
-
if (typeof extensions === "string") {
|
|
5961
|
-
return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || "";
|
|
5962
|
-
}
|
|
5963
|
-
for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) {
|
|
5964
|
-
var extension = extensions_2[_i];
|
|
5965
|
-
var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer);
|
|
5966
|
-
if (result)
|
|
5967
|
-
return result;
|
|
5968
|
-
}
|
|
5969
|
-
return "";
|
|
5970
|
-
}
|
|
5971
|
-
function getAnyExtensionFromPath(path, extensions, ignoreCase) {
|
|
5972
|
-
// Retrieves any string from the final "." onwards from a base file name.
|
|
5973
|
-
// Unlike extensionFromPath, which throws an exception on unrecognized extensions.
|
|
5974
|
-
if (extensions) {
|
|
5975
|
-
return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive);
|
|
5976
|
-
}
|
|
5977
|
-
var baseFileName = getBaseFileName(path);
|
|
5978
|
-
var extensionIndex = baseFileName.lastIndexOf(".");
|
|
5979
|
-
if (extensionIndex >= 0) {
|
|
5980
|
-
return baseFileName.substring(extensionIndex);
|
|
5981
|
-
}
|
|
5982
|
-
return "";
|
|
5983
|
-
}
|
|
5984
|
-
ts.getAnyExtensionFromPath = getAnyExtensionFromPath;
|
|
5985
|
-
function pathComponents(path, rootLength) {
|
|
5986
|
-
var root = path.substring(0, rootLength);
|
|
5987
|
-
var rest = path.substring(rootLength).split(ts.directorySeparator);
|
|
5988
|
-
if (rest.length && !ts.lastOrUndefined(rest))
|
|
5989
|
-
rest.pop();
|
|
5990
|
-
return __spreadArray([root], rest, true);
|
|
5991
|
-
}
|
|
5992
|
-
/**
|
|
5993
|
-
* Parse a path into an array containing a root component (at index 0) and zero or more path
|
|
5994
|
-
* components (at indices > 0). The result is not normalized.
|
|
5995
|
-
* If the path is relative, the root component is `""`.
|
|
5996
|
-
* If the path is absolute, the root component includes the first path separator (`/`).
|
|
5997
|
-
*
|
|
5998
|
-
* ```ts
|
|
5999
|
-
* // POSIX
|
|
6000
|
-
* getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"]
|
|
6001
|
-
* getPathComponents("/path/to/") === ["/", "path", "to"]
|
|
6002
|
-
* getPathComponents("/") === ["/"]
|
|
6003
|
-
* // DOS
|
|
6004
|
-
* getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"]
|
|
6005
|
-
* getPathComponents("c:/path/to/") === ["c:/", "path", "to"]
|
|
6006
|
-
* getPathComponents("c:/") === ["c:/"]
|
|
6007
|
-
* getPathComponents("c:") === ["c:"]
|
|
6008
|
-
* // URL
|
|
6009
|
-
* getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"]
|
|
6010
|
-
* getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"]
|
|
6011
|
-
* getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"]
|
|
6012
|
-
* getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"]
|
|
6013
|
-
* getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"]
|
|
6014
|
-
* getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"]
|
|
6015
|
-
* getPathComponents("file://server/") === ["file://server/"]
|
|
6016
|
-
* getPathComponents("file://server") === ["file://server"]
|
|
6017
|
-
* getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"]
|
|
6018
|
-
* getPathComponents("file:///path/to/") === ["file:///", "path", "to"]
|
|
6019
|
-
* getPathComponents("file:///") === ["file:///"]
|
|
6020
|
-
* getPathComponents("file://") === ["file://"]
|
|
6021
|
-
*/
|
|
6022
|
-
function getPathComponents(path, currentDirectory) {
|
|
6023
|
-
if (currentDirectory === void 0) { currentDirectory = ""; }
|
|
6024
|
-
path = combinePaths(currentDirectory, path);
|
|
6025
|
-
return pathComponents(path, getRootLength(path));
|
|
6026
|
-
}
|
|
6027
|
-
ts.getPathComponents = getPathComponents;
|
|
6028
|
-
//// Path Formatting
|
|
6029
|
-
/**
|
|
6030
|
-
* Formats a parsed path consisting of a root component (at index 0) and zero or more path
|
|
6031
|
-
* segments (at indices > 0).
|
|
6032
|
-
*
|
|
6033
|
-
* ```ts
|
|
6034
|
-
* getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext"
|
|
6035
|
-
* ```
|
|
6036
|
-
*/
|
|
6037
|
-
function getPathFromPathComponents(pathComponents) {
|
|
6038
|
-
if (pathComponents.length === 0)
|
|
6039
|
-
return "";
|
|
6040
|
-
var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
|
|
6041
|
-
return root + pathComponents.slice(1).join(ts.directorySeparator);
|
|
6042
|
-
}
|
|
6043
|
-
ts.getPathFromPathComponents = getPathFromPathComponents;
|
|
6044
|
-
//// Path Normalization
|
|
6045
|
-
/**
|
|
6046
|
-
* Normalize path separators, converting `\` into `/`.
|
|
6047
|
-
*/
|
|
6048
|
-
function normalizeSlashes(path) {
|
|
6049
|
-
var index = path.indexOf("\\");
|
|
6050
|
-
if (index === -1) {
|
|
6051
|
-
return path;
|
|
6052
|
-
}
|
|
6053
|
-
backslashRegExp.lastIndex = index; // prime regex with known position
|
|
6054
|
-
return path.replace(backslashRegExp, ts.directorySeparator);
|
|
6055
|
-
}
|
|
6056
|
-
ts.normalizeSlashes = normalizeSlashes;
|
|
6057
|
-
/**
|
|
6058
|
-
* Reduce an array of path components to a more simplified path by navigating any
|
|
6059
|
-
* `"."` or `".."` entries in the path.
|
|
6060
|
-
*/
|
|
6061
|
-
function reducePathComponents(components) {
|
|
6062
|
-
if (!ts.some(components))
|
|
6063
|
-
return [];
|
|
6064
|
-
var reduced = [components[0]];
|
|
6065
|
-
for (var i = 1; i < components.length; i++) {
|
|
6066
|
-
var component = components[i];
|
|
6067
|
-
if (!component)
|
|
6068
|
-
continue;
|
|
6069
|
-
if (component === ".")
|
|
6070
|
-
continue;
|
|
6071
|
-
if (component === "..") {
|
|
6072
|
-
if (reduced.length > 1) {
|
|
6073
|
-
if (reduced[reduced.length - 1] !== "..") {
|
|
6074
|
-
reduced.pop();
|
|
6075
|
-
continue;
|
|
6076
|
-
}
|
|
6077
|
-
}
|
|
6078
|
-
else if (reduced[0])
|
|
6079
|
-
continue;
|
|
6080
|
-
}
|
|
6081
|
-
reduced.push(component);
|
|
6082
|
-
}
|
|
6083
|
-
return reduced;
|
|
6084
|
-
}
|
|
6085
|
-
ts.reducePathComponents = reducePathComponents;
|
|
6086
|
-
/**
|
|
6087
|
-
* Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified.
|
|
6088
|
-
*
|
|
6089
|
-
* ```ts
|
|
6090
|
-
* // Non-rooted
|
|
6091
|
-
* combinePaths("path", "to", "file.ext") === "path/to/file.ext"
|
|
6092
|
-
* combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext"
|
|
6093
|
-
* // POSIX
|
|
6094
|
-
* combinePaths("/path", "to", "file.ext") === "/path/to/file.ext"
|
|
6095
|
-
* combinePaths("/path", "/to", "file.ext") === "/to/file.ext"
|
|
6096
|
-
* // DOS
|
|
6097
|
-
* combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext"
|
|
6098
|
-
* combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext"
|
|
6099
|
-
* // URL
|
|
6100
|
-
* combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext"
|
|
6101
|
-
* combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext"
|
|
6102
|
-
* ```
|
|
6103
|
-
*/
|
|
6104
|
-
function combinePaths(path) {
|
|
6105
|
-
var paths = [];
|
|
6106
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
6107
|
-
paths[_i - 1] = arguments[_i];
|
|
6108
|
-
}
|
|
6109
|
-
if (path)
|
|
6110
|
-
path = normalizeSlashes(path);
|
|
6111
|
-
for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
|
|
6112
|
-
var relativePath = paths_1[_a];
|
|
6113
|
-
if (!relativePath)
|
|
6114
|
-
continue;
|
|
6115
|
-
relativePath = normalizeSlashes(relativePath);
|
|
6116
|
-
if (!path || getRootLength(relativePath) !== 0) {
|
|
6117
|
-
path = relativePath;
|
|
6118
|
-
}
|
|
6119
|
-
else {
|
|
6120
|
-
path = ensureTrailingDirectorySeparator(path) + relativePath;
|
|
6121
|
-
}
|
|
6122
|
-
}
|
|
6123
|
-
return path;
|
|
6124
|
-
}
|
|
6125
|
-
ts.combinePaths = combinePaths;
|
|
6126
|
-
/**
|
|
6127
|
-
* Combines and resolves paths. If a path is absolute, it replaces any previous path. Any
|
|
6128
|
-
* `.` and `..` path components are resolved. Trailing directory separators are preserved.
|
|
6129
|
-
*
|
|
6130
|
-
* ```ts
|
|
6131
|
-
* resolvePath("/path", "to", "file.ext") === "path/to/file.ext"
|
|
6132
|
-
* resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/"
|
|
6133
|
-
* resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext"
|
|
6134
|
-
* ```
|
|
6135
|
-
*/
|
|
6136
|
-
function resolvePath(path) {
|
|
6137
|
-
var paths = [];
|
|
6138
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
6139
|
-
paths[_i - 1] = arguments[_i];
|
|
6140
|
-
}
|
|
6141
|
-
return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArray([path], paths, false)) : normalizeSlashes(path));
|
|
6142
|
-
}
|
|
6143
|
-
ts.resolvePath = resolvePath;
|
|
6144
|
-
/**
|
|
6145
|
-
* Parse a path into an array containing a root component (at index 0) and zero or more path
|
|
6146
|
-
* components (at indices > 0). The result is normalized.
|
|
6147
|
-
* If the path is relative, the root component is `""`.
|
|
6148
|
-
* If the path is absolute, the root component includes the first path separator (`/`).
|
|
6149
|
-
*
|
|
6150
|
-
* ```ts
|
|
6151
|
-
* getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"]
|
|
6152
|
-
* ```
|
|
6153
|
-
*/
|
|
6154
|
-
function getNormalizedPathComponents(path, currentDirectory) {
|
|
6155
|
-
return reducePathComponents(getPathComponents(path, currentDirectory));
|
|
6156
|
-
}
|
|
6157
|
-
ts.getNormalizedPathComponents = getNormalizedPathComponents;
|
|
6158
|
-
function getNormalizedAbsolutePath(fileName, currentDirectory) {
|
|
6159
|
-
return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
|
|
6160
|
-
}
|
|
6161
|
-
ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
|
|
6162
|
-
function normalizePath(path) {
|
|
6163
|
-
path = normalizeSlashes(path);
|
|
6164
|
-
// Most paths don't require normalization
|
|
6165
|
-
if (!relativePathSegmentRegExp.test(path)) {
|
|
6166
|
-
return path;
|
|
6167
|
-
}
|
|
6168
|
-
// Some paths only require cleanup of `/./` or leading `./`
|
|
6169
|
-
var simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, "");
|
|
6170
|
-
if (simplified !== path) {
|
|
6171
|
-
path = simplified;
|
|
6172
|
-
if (!relativePathSegmentRegExp.test(path)) {
|
|
6173
|
-
return path;
|
|
6174
|
-
}
|
|
6175
|
-
}
|
|
6176
|
-
// Other paths require full normalization
|
|
6177
|
-
var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
|
|
6178
|
-
return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
|
|
6179
|
-
}
|
|
6180
|
-
ts.normalizePath = normalizePath;
|
|
6181
|
-
function getPathWithoutRoot(pathComponents) {
|
|
6182
|
-
if (pathComponents.length === 0)
|
|
6183
|
-
return "";
|
|
6184
|
-
return pathComponents.slice(1).join(ts.directorySeparator);
|
|
6185
|
-
}
|
|
6186
|
-
function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
|
|
6187
|
-
return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
|
|
6188
|
-
}
|
|
6189
|
-
ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
|
|
6190
|
-
function toPath(fileName, basePath, getCanonicalFileName) {
|
|
6191
|
-
var nonCanonicalizedPath = isRootedDiskPath(fileName)
|
|
6192
|
-
? normalizePath(fileName)
|
|
6193
|
-
: getNormalizedAbsolutePath(fileName, basePath);
|
|
6194
|
-
return getCanonicalFileName(nonCanonicalizedPath);
|
|
6195
|
-
}
|
|
6196
|
-
ts.toPath = toPath;
|
|
6197
|
-
function normalizePathAndParts(path) {
|
|
6198
|
-
path = normalizeSlashes(path);
|
|
6199
|
-
var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
|
|
6200
|
-
if (parts.length) {
|
|
6201
|
-
var joinedParts = root + parts.join(ts.directorySeparator);
|
|
6202
|
-
return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
|
|
6203
|
-
}
|
|
6204
|
-
else {
|
|
6205
|
-
return { path: root, parts: parts };
|
|
6206
|
-
}
|
|
6207
|
-
}
|
|
6208
|
-
ts.normalizePathAndParts = normalizePathAndParts;
|
|
6209
|
-
function removeTrailingDirectorySeparator(path) {
|
|
6210
|
-
if (hasTrailingDirectorySeparator(path)) {
|
|
6211
|
-
return path.substr(0, path.length - 1);
|
|
6212
|
-
}
|
|
6213
|
-
return path;
|
|
6214
|
-
}
|
|
6215
|
-
ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
|
|
6216
|
-
function ensureTrailingDirectorySeparator(path) {
|
|
6217
|
-
if (!hasTrailingDirectorySeparator(path)) {
|
|
6218
|
-
return path + ts.directorySeparator;
|
|
6219
|
-
}
|
|
6220
|
-
return path;
|
|
6221
|
-
}
|
|
6222
|
-
ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator;
|
|
6223
|
-
/**
|
|
6224
|
-
* Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed
|
|
6225
|
-
* with `./` or `../`) so as not to be confused with an unprefixed module name.
|
|
6226
|
-
*
|
|
6227
|
-
* ```ts
|
|
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
|
-
* ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext"
|
|
6232
|
-
* ```
|
|
6233
|
-
*/
|
|
6234
|
-
function ensurePathIsNonModuleName(path) {
|
|
6235
|
-
return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path;
|
|
6236
|
-
}
|
|
6237
|
-
ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName;
|
|
6238
|
-
function changeAnyExtension(path, ext, extensions, ignoreCase) {
|
|
6239
|
-
var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path);
|
|
6240
|
-
return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
|
|
6241
|
-
}
|
|
6242
|
-
ts.changeAnyExtension = changeAnyExtension;
|
|
6243
|
-
//// Path Comparisons
|
|
6244
|
-
// check path for these segments: '', '.'. '..'
|
|
6245
|
-
var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/;
|
|
6246
|
-
function comparePathsWorker(a, b, componentComparer) {
|
|
6247
|
-
if (a === b)
|
|
6248
|
-
return 0 /* EqualTo */;
|
|
6249
|
-
if (a === undefined)
|
|
6250
|
-
return -1 /* LessThan */;
|
|
6251
|
-
if (b === undefined)
|
|
6252
|
-
return 1 /* GreaterThan */;
|
|
6253
|
-
// NOTE: Performance optimization - shortcut if the root segments differ as there would be no
|
|
6254
|
-
// need to perform path reduction.
|
|
6255
|
-
var aRoot = a.substring(0, getRootLength(a));
|
|
6256
|
-
var bRoot = b.substring(0, getRootLength(b));
|
|
6257
|
-
var result = ts.compareStringsCaseInsensitive(aRoot, bRoot);
|
|
6258
|
-
if (result !== 0 /* EqualTo */) {
|
|
6259
|
-
return result;
|
|
6260
|
-
}
|
|
6261
|
-
// NOTE: Performance optimization - shortcut if there are no relative path segments in
|
|
6262
|
-
// the non-root portion of the path
|
|
6263
|
-
var aRest = a.substring(aRoot.length);
|
|
6264
|
-
var bRest = b.substring(bRoot.length);
|
|
6265
|
-
if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) {
|
|
6266
|
-
return componentComparer(aRest, bRest);
|
|
6267
|
-
}
|
|
6268
|
-
// The path contains a relative path segment. Normalize the paths and perform a slower component
|
|
6269
|
-
// by component comparison.
|
|
6270
|
-
var aComponents = reducePathComponents(getPathComponents(a));
|
|
6271
|
-
var bComponents = reducePathComponents(getPathComponents(b));
|
|
6272
|
-
var sharedLength = Math.min(aComponents.length, bComponents.length);
|
|
6273
|
-
for (var i = 1; i < sharedLength; i++) {
|
|
6274
|
-
var result_2 = componentComparer(aComponents[i], bComponents[i]);
|
|
6275
|
-
if (result_2 !== 0 /* EqualTo */) {
|
|
6276
|
-
return result_2;
|
|
6277
|
-
}
|
|
6278
|
-
}
|
|
6279
|
-
return ts.compareValues(aComponents.length, bComponents.length);
|
|
6280
|
-
}
|
|
6281
|
-
/**
|
|
6282
|
-
* Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively.
|
|
6283
|
-
*/
|
|
6284
|
-
function comparePathsCaseSensitive(a, b) {
|
|
6285
|
-
return comparePathsWorker(a, b, ts.compareStringsCaseSensitive);
|
|
6286
|
-
}
|
|
6287
|
-
ts.comparePathsCaseSensitive = comparePathsCaseSensitive;
|
|
6288
|
-
/**
|
|
6289
|
-
* Performs a case-insensitive comparison of two paths.
|
|
6290
|
-
*/
|
|
6291
|
-
function comparePathsCaseInsensitive(a, b) {
|
|
6292
|
-
return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive);
|
|
6293
|
-
}
|
|
6294
|
-
ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive;
|
|
6295
|
-
function comparePaths(a, b, currentDirectory, ignoreCase) {
|
|
6296
|
-
if (typeof currentDirectory === "string") {
|
|
6297
|
-
a = combinePaths(currentDirectory, a);
|
|
6298
|
-
b = combinePaths(currentDirectory, b);
|
|
6299
|
-
}
|
|
6300
|
-
else if (typeof currentDirectory === "boolean") {
|
|
6301
|
-
ignoreCase = currentDirectory;
|
|
6302
|
-
}
|
|
6303
|
-
return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase));
|
|
6304
|
-
}
|
|
6305
|
-
ts.comparePaths = comparePaths;
|
|
6306
|
-
function containsPath(parent, child, currentDirectory, ignoreCase) {
|
|
6307
|
-
if (typeof currentDirectory === "string") {
|
|
6308
|
-
parent = combinePaths(currentDirectory, parent);
|
|
6309
|
-
child = combinePaths(currentDirectory, child);
|
|
6310
|
-
}
|
|
6311
|
-
else if (typeof currentDirectory === "boolean") {
|
|
6312
|
-
ignoreCase = currentDirectory;
|
|
6313
|
-
}
|
|
6314
|
-
if (parent === undefined || child === undefined)
|
|
6315
|
-
return false;
|
|
6316
|
-
if (parent === child)
|
|
6317
|
-
return true;
|
|
6318
|
-
var parentComponents = reducePathComponents(getPathComponents(parent));
|
|
6319
|
-
var childComponents = reducePathComponents(getPathComponents(child));
|
|
6320
|
-
if (childComponents.length < parentComponents.length) {
|
|
6321
|
-
return false;
|
|
6322
|
-
}
|
|
6323
|
-
var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive;
|
|
6324
|
-
for (var i = 0; i < parentComponents.length; i++) {
|
|
6325
|
-
var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer;
|
|
6326
|
-
if (!equalityComparer(parentComponents[i], childComponents[i])) {
|
|
6327
|
-
return false;
|
|
6328
|
-
}
|
|
6329
|
-
}
|
|
6330
|
-
return true;
|
|
6331
|
-
}
|
|
6332
|
-
ts.containsPath = containsPath;
|
|
6333
|
-
/**
|
|
6334
|
-
* Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback.
|
|
6335
|
-
* Comparison is case-sensitive between the canonical paths.
|
|
6336
|
-
*
|
|
6337
|
-
* Use `containsPath` if file names are not already reduced and absolute.
|
|
6338
|
-
*/
|
|
6339
|
-
function startsWithDirectory(fileName, directoryName, getCanonicalFileName) {
|
|
6340
|
-
var canonicalFileName = getCanonicalFileName(fileName);
|
|
6341
|
-
var canonicalDirectoryName = getCanonicalFileName(directoryName);
|
|
6342
|
-
return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\");
|
|
6343
|
-
}
|
|
6344
|
-
ts.startsWithDirectory = startsWithDirectory;
|
|
6345
|
-
//// Relative Paths
|
|
6346
|
-
function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) {
|
|
6347
|
-
var fromComponents = reducePathComponents(getPathComponents(from));
|
|
6348
|
-
var toComponents = reducePathComponents(getPathComponents(to));
|
|
6349
|
-
var start;
|
|
6350
|
-
for (start = 0; start < fromComponents.length && start < toComponents.length; start++) {
|
|
6351
|
-
var fromComponent = getCanonicalFileName(fromComponents[start]);
|
|
6352
|
-
var toComponent = getCanonicalFileName(toComponents[start]);
|
|
6353
|
-
var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer;
|
|
6354
|
-
if (!comparer(fromComponent, toComponent))
|
|
6355
|
-
break;
|
|
6356
|
-
}
|
|
6357
|
-
if (start === 0) {
|
|
6358
|
-
return toComponents;
|
|
6359
|
-
}
|
|
6360
|
-
var components = toComponents.slice(start);
|
|
6361
|
-
var relative = [];
|
|
6362
|
-
for (; start < fromComponents.length; start++) {
|
|
6363
|
-
relative.push("..");
|
|
6364
|
-
}
|
|
6365
|
-
return __spreadArray(__spreadArray([""], relative, true), components, true);
|
|
6366
|
-
}
|
|
6367
|
-
ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo;
|
|
6368
|
-
function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
|
|
6369
|
-
ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
|
|
6370
|
-
var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
|
|
6371
|
-
var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
|
|
6372
|
-
var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
|
|
6373
|
-
return getPathFromPathComponents(pathComponents);
|
|
6374
|
-
}
|
|
6375
|
-
ts.getRelativePathFromDirectory = getRelativePathFromDirectory;
|
|
6376
|
-
function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
|
|
6377
|
-
return !isRootedDiskPath(absoluteOrRelativePath)
|
|
6378
|
-
? absoluteOrRelativePath
|
|
6379
|
-
: getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
|
|
6380
|
-
}
|
|
6381
|
-
ts.convertToRelativePath = convertToRelativePath;
|
|
6382
|
-
function getRelativePathFromFile(from, to, getCanonicalFileName) {
|
|
6383
|
-
return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName));
|
|
6384
|
-
}
|
|
6385
|
-
ts.getRelativePathFromFile = getRelativePathFromFile;
|
|
6386
|
-
function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
|
|
6387
|
-
var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName);
|
|
6388
|
-
var firstComponent = pathComponents[0];
|
|
6389
|
-
if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) {
|
|
6390
|
-
var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///";
|
|
6391
|
-
pathComponents[0] = prefix + firstComponent;
|
|
6392
|
-
}
|
|
6393
|
-
return getPathFromPathComponents(pathComponents);
|
|
6394
|
-
}
|
|
6395
|
-
ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl;
|
|
6396
|
-
function forEachAncestorDirectory(directory, callback) {
|
|
6397
|
-
while (true) {
|
|
6398
|
-
var result = callback(directory);
|
|
6399
|
-
if (result !== undefined) {
|
|
6400
|
-
return result;
|
|
6401
|
-
}
|
|
6402
|
-
var parentPath = getDirectoryPath(directory);
|
|
6403
|
-
if (parentPath === directory) {
|
|
6404
|
-
return undefined;
|
|
6405
|
-
}
|
|
6406
|
-
directory = parentPath;
|
|
6407
|
-
}
|
|
6408
|
-
}
|
|
6409
|
-
ts.forEachAncestorDirectory = forEachAncestorDirectory;
|
|
6410
|
-
function isNodeModulesDirectory(dirPath) {
|
|
6411
|
-
return ts.endsWith(dirPath, "/node_modules");
|
|
6412
|
-
}
|
|
6413
|
-
ts.isNodeModulesDirectory = isNodeModulesDirectory;
|
|
6414
|
-
})(ts || (ts = {}));
|
|
6415
5717
|
var ts;
|
|
6416
5718
|
(function (ts) {
|
|
6417
5719
|
/**
|
|
@@ -7786,66 +7088,764 @@ var ts;
|
|
|
7786
7088
|
return path;
|
|
7787
7089
|
}
|
|
7788
7090
|
}
|
|
7789
|
-
function getModifiedTime(path) {
|
|
7790
|
-
var _a;
|
|
7791
|
-
try {
|
|
7792
|
-
return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime;
|
|
7793
|
-
}
|
|
7794
|
-
catch (e) {
|
|
7795
|
-
return undefined;
|
|
7796
|
-
}
|
|
7091
|
+
function getModifiedTime(path) {
|
|
7092
|
+
var _a;
|
|
7093
|
+
try {
|
|
7094
|
+
return (_a = statSync(path)) === null || _a === void 0 ? void 0 : _a.mtime;
|
|
7095
|
+
}
|
|
7096
|
+
catch (e) {
|
|
7097
|
+
return undefined;
|
|
7098
|
+
}
|
|
7099
|
+
}
|
|
7100
|
+
function setModifiedTime(path, time) {
|
|
7101
|
+
try {
|
|
7102
|
+
_fs.utimesSync(path, time, time);
|
|
7103
|
+
}
|
|
7104
|
+
catch (e) {
|
|
7105
|
+
return;
|
|
7106
|
+
}
|
|
7107
|
+
}
|
|
7108
|
+
function deleteFile(path) {
|
|
7109
|
+
try {
|
|
7110
|
+
return _fs.unlinkSync(path);
|
|
7111
|
+
}
|
|
7112
|
+
catch (e) {
|
|
7113
|
+
return;
|
|
7114
|
+
}
|
|
7115
|
+
}
|
|
7116
|
+
function createSHA256Hash(data) {
|
|
7117
|
+
var hash = _crypto.createHash("sha256");
|
|
7118
|
+
hash.update(data);
|
|
7119
|
+
return hash.digest("hex");
|
|
7120
|
+
}
|
|
7121
|
+
}
|
|
7122
|
+
var sys;
|
|
7123
|
+
if (typeof process !== "undefined" && process.nextTick && !process.browser && typeof require !== "undefined") {
|
|
7124
|
+
// process and process.nextTick checks if current environment is node-like
|
|
7125
|
+
// process.browser check excludes webpack and browserify
|
|
7126
|
+
sys = getNodeSystem();
|
|
7127
|
+
}
|
|
7128
|
+
if (sys) {
|
|
7129
|
+
// patch writefile to create folder before writing the file
|
|
7130
|
+
patchWriteFileEnsuringDirectory(sys);
|
|
7131
|
+
}
|
|
7132
|
+
return sys;
|
|
7133
|
+
})();
|
|
7134
|
+
/*@internal*/
|
|
7135
|
+
function setSys(s) {
|
|
7136
|
+
ts.sys = s;
|
|
7137
|
+
}
|
|
7138
|
+
ts.setSys = setSys;
|
|
7139
|
+
if (ts.sys && ts.sys.getEnvironmentVariable) {
|
|
7140
|
+
setCustomPollingValues(ts.sys);
|
|
7141
|
+
ts.Debug.setAssertionLevel(/^development$/i.test(ts.sys.getEnvironmentVariable("NODE_ENV"))
|
|
7142
|
+
? 1 /* Normal */
|
|
7143
|
+
: 0 /* None */);
|
|
7144
|
+
}
|
|
7145
|
+
if (ts.sys && ts.sys.debugMode) {
|
|
7146
|
+
ts.Debug.isDebugging = true;
|
|
7147
|
+
}
|
|
7148
|
+
})(ts || (ts = {}));
|
|
7149
|
+
/* @internal */
|
|
7150
|
+
var ts;
|
|
7151
|
+
(function (ts) {
|
|
7152
|
+
/**
|
|
7153
|
+
* Internally, we represent paths as strings with '/' as the directory separator.
|
|
7154
|
+
* When we make system calls (eg: LanguageServiceHost.getDirectory()),
|
|
7155
|
+
* we expect the host to correctly handle paths in our specified format.
|
|
7156
|
+
*/
|
|
7157
|
+
ts.directorySeparator = "/";
|
|
7158
|
+
ts.altDirectorySeparator = "\\";
|
|
7159
|
+
var urlSchemeSeparator = "://";
|
|
7160
|
+
var backslashRegExp = /\\/g;
|
|
7161
|
+
//// Path Tests
|
|
7162
|
+
/**
|
|
7163
|
+
* Determines whether a charCode corresponds to `/` or `\`.
|
|
7164
|
+
*/
|
|
7165
|
+
function isAnyDirectorySeparator(charCode) {
|
|
7166
|
+
return charCode === 47 /* slash */ || charCode === 92 /* backslash */;
|
|
7167
|
+
}
|
|
7168
|
+
ts.isAnyDirectorySeparator = isAnyDirectorySeparator;
|
|
7169
|
+
/**
|
|
7170
|
+
* Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.).
|
|
7171
|
+
*/
|
|
7172
|
+
function isUrl(path) {
|
|
7173
|
+
return getEncodedRootLength(path) < 0;
|
|
7174
|
+
}
|
|
7175
|
+
ts.isUrl = isUrl;
|
|
7176
|
+
/**
|
|
7177
|
+
* Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path
|
|
7178
|
+
* like `c:`, `c:\` or `c:/`).
|
|
7179
|
+
*/
|
|
7180
|
+
function isRootedDiskPath(path) {
|
|
7181
|
+
return getEncodedRootLength(path) > 0;
|
|
7182
|
+
}
|
|
7183
|
+
ts.isRootedDiskPath = isRootedDiskPath;
|
|
7184
|
+
/**
|
|
7185
|
+
* Determines whether a path consists only of a path root.
|
|
7186
|
+
*/
|
|
7187
|
+
function isDiskPathRoot(path) {
|
|
7188
|
+
var rootLength = getEncodedRootLength(path);
|
|
7189
|
+
return rootLength > 0 && rootLength === path.length;
|
|
7190
|
+
}
|
|
7191
|
+
ts.isDiskPathRoot = isDiskPathRoot;
|
|
7192
|
+
/**
|
|
7193
|
+
* Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.).
|
|
7194
|
+
*
|
|
7195
|
+
* ```ts
|
|
7196
|
+
* // POSIX
|
|
7197
|
+
* pathIsAbsolute("/path/to/file.ext") === true
|
|
7198
|
+
* // DOS
|
|
7199
|
+
* pathIsAbsolute("c:/path/to/file.ext") === true
|
|
7200
|
+
* // URL
|
|
7201
|
+
* pathIsAbsolute("file:///path/to/file.ext") === true
|
|
7202
|
+
* // Non-absolute
|
|
7203
|
+
* pathIsAbsolute("path/to/file.ext") === false
|
|
7204
|
+
* pathIsAbsolute("./path/to/file.ext") === false
|
|
7205
|
+
* ```
|
|
7206
|
+
*/
|
|
7207
|
+
function pathIsAbsolute(path) {
|
|
7208
|
+
return getEncodedRootLength(path) !== 0;
|
|
7209
|
+
}
|
|
7210
|
+
ts.pathIsAbsolute = pathIsAbsolute;
|
|
7211
|
+
/**
|
|
7212
|
+
* Determines whether a path starts with a relative path component (i.e. `.` or `..`).
|
|
7213
|
+
*/
|
|
7214
|
+
function pathIsRelative(path) {
|
|
7215
|
+
return /^\.\.?($|[\\/])/.test(path);
|
|
7216
|
+
}
|
|
7217
|
+
ts.pathIsRelative = pathIsRelative;
|
|
7218
|
+
/**
|
|
7219
|
+
* Determines whether a path is neither relative nor absolute, e.g. "path/to/file".
|
|
7220
|
+
* Also known misleadingly as "non-relative".
|
|
7221
|
+
*/
|
|
7222
|
+
function pathIsBareSpecifier(path) {
|
|
7223
|
+
return !pathIsAbsolute(path) && !pathIsRelative(path);
|
|
7224
|
+
}
|
|
7225
|
+
ts.pathIsBareSpecifier = pathIsBareSpecifier;
|
|
7226
|
+
function hasExtension(fileName) {
|
|
7227
|
+
return ts.stringContains(getBaseFileName(fileName), ".");
|
|
7228
|
+
}
|
|
7229
|
+
ts.hasExtension = hasExtension;
|
|
7230
|
+
function fileExtensionIs(path, extension) {
|
|
7231
|
+
return path.length > extension.length && ts.endsWith(path, extension);
|
|
7232
|
+
}
|
|
7233
|
+
ts.fileExtensionIs = fileExtensionIs;
|
|
7234
|
+
function fileExtensionIsOneOf(path, extensions) {
|
|
7235
|
+
for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
|
|
7236
|
+
var extension = extensions_1[_i];
|
|
7237
|
+
if (fileExtensionIs(path, extension)) {
|
|
7238
|
+
return true;
|
|
7239
|
+
}
|
|
7240
|
+
}
|
|
7241
|
+
return false;
|
|
7242
|
+
}
|
|
7243
|
+
ts.fileExtensionIsOneOf = fileExtensionIsOneOf;
|
|
7244
|
+
/**
|
|
7245
|
+
* Determines whether a path has a trailing separator (`/` or `\\`).
|
|
7246
|
+
*/
|
|
7247
|
+
function hasTrailingDirectorySeparator(path) {
|
|
7248
|
+
return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1));
|
|
7249
|
+
}
|
|
7250
|
+
ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator;
|
|
7251
|
+
//// Path Parsing
|
|
7252
|
+
function isVolumeCharacter(charCode) {
|
|
7253
|
+
return (charCode >= 97 /* a */ && charCode <= 122 /* z */) ||
|
|
7254
|
+
(charCode >= 65 /* A */ && charCode <= 90 /* Z */);
|
|
7255
|
+
}
|
|
7256
|
+
function getFileUrlVolumeSeparatorEnd(url, start) {
|
|
7257
|
+
var ch0 = url.charCodeAt(start);
|
|
7258
|
+
if (ch0 === 58 /* colon */)
|
|
7259
|
+
return start + 1;
|
|
7260
|
+
if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) {
|
|
7261
|
+
var ch2 = url.charCodeAt(start + 2);
|
|
7262
|
+
if (ch2 === 97 /* a */ || ch2 === 65 /* A */)
|
|
7263
|
+
return start + 3;
|
|
7264
|
+
}
|
|
7265
|
+
return -1;
|
|
7266
|
+
}
|
|
7267
|
+
/**
|
|
7268
|
+
* Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
|
|
7269
|
+
* If the root is part of a URL, the twos-complement of the root length is returned.
|
|
7270
|
+
*/
|
|
7271
|
+
function getEncodedRootLength(path) {
|
|
7272
|
+
if (!path)
|
|
7273
|
+
return 0;
|
|
7274
|
+
var ch0 = path.charCodeAt(0);
|
|
7275
|
+
// POSIX or UNC
|
|
7276
|
+
if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) {
|
|
7277
|
+
if (path.charCodeAt(1) !== ch0)
|
|
7278
|
+
return 1; // POSIX: "/" (or non-normalized "\")
|
|
7279
|
+
var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2);
|
|
7280
|
+
if (p1 < 0)
|
|
7281
|
+
return path.length; // UNC: "//server" or "\\server"
|
|
7282
|
+
return p1 + 1; // UNC: "//server/" or "\\server\"
|
|
7283
|
+
}
|
|
7284
|
+
// DOS
|
|
7285
|
+
if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) {
|
|
7286
|
+
var ch2 = path.charCodeAt(2);
|
|
7287
|
+
if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */)
|
|
7288
|
+
return 3; // DOS: "c:/" or "c:\"
|
|
7289
|
+
if (path.length === 2)
|
|
7290
|
+
return 2; // DOS: "c:" (but not "c:d")
|
|
7291
|
+
}
|
|
7292
|
+
// URL
|
|
7293
|
+
var schemeEnd = path.indexOf(urlSchemeSeparator);
|
|
7294
|
+
if (schemeEnd !== -1) {
|
|
7295
|
+
var authorityStart = schemeEnd + urlSchemeSeparator.length;
|
|
7296
|
+
var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart);
|
|
7297
|
+
if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path"
|
|
7298
|
+
// For local "file" URLs, include the leading DOS volume (if present).
|
|
7299
|
+
// Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a
|
|
7300
|
+
// special case interpreted as "the machine from which the URL is being interpreted".
|
|
7301
|
+
var scheme = path.slice(0, schemeEnd);
|
|
7302
|
+
var authority = path.slice(authorityStart, authorityEnd);
|
|
7303
|
+
if (scheme === "file" && (authority === "" || authority === "localhost") &&
|
|
7304
|
+
isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
|
|
7305
|
+
var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
|
|
7306
|
+
if (volumeSeparatorEnd !== -1) {
|
|
7307
|
+
if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) {
|
|
7308
|
+
// URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/"
|
|
7309
|
+
return ~(volumeSeparatorEnd + 1);
|
|
7310
|
+
}
|
|
7311
|
+
if (volumeSeparatorEnd === path.length) {
|
|
7312
|
+
// URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a"
|
|
7313
|
+
// but not "file:///c:d" or "file:///c%3ad"
|
|
7314
|
+
return ~volumeSeparatorEnd;
|
|
7315
|
+
}
|
|
7316
|
+
}
|
|
7317
|
+
}
|
|
7318
|
+
return ~(authorityEnd + 1); // URL: "file://server/", "http://server/"
|
|
7319
|
+
}
|
|
7320
|
+
return ~path.length; // URL: "file://server", "http://server"
|
|
7321
|
+
}
|
|
7322
|
+
// relative
|
|
7323
|
+
return 0;
|
|
7324
|
+
}
|
|
7325
|
+
/**
|
|
7326
|
+
* Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
|
|
7327
|
+
*
|
|
7328
|
+
* For example:
|
|
7329
|
+
* ```ts
|
|
7330
|
+
* getRootLength("a") === 0 // ""
|
|
7331
|
+
* getRootLength("/") === 1 // "/"
|
|
7332
|
+
* getRootLength("c:") === 2 // "c:"
|
|
7333
|
+
* getRootLength("c:d") === 0 // ""
|
|
7334
|
+
* getRootLength("c:/") === 3 // "c:/"
|
|
7335
|
+
* getRootLength("c:\\") === 3 // "c:\\"
|
|
7336
|
+
* getRootLength("//server") === 7 // "//server"
|
|
7337
|
+
* getRootLength("//server/share") === 8 // "//server/"
|
|
7338
|
+
* getRootLength("\\\\server") === 7 // "\\\\server"
|
|
7339
|
+
* getRootLength("\\\\server\\share") === 8 // "\\\\server\\"
|
|
7340
|
+
* getRootLength("file:///path") === 8 // "file:///"
|
|
7341
|
+
* getRootLength("file:///c:") === 10 // "file:///c:"
|
|
7342
|
+
* getRootLength("file:///c:d") === 8 // "file:///"
|
|
7343
|
+
* getRootLength("file:///c:/path") === 11 // "file:///c:/"
|
|
7344
|
+
* getRootLength("file://server") === 13 // "file://server"
|
|
7345
|
+
* getRootLength("file://server/path") === 14 // "file://server/"
|
|
7346
|
+
* getRootLength("http://server") === 13 // "http://server"
|
|
7347
|
+
* getRootLength("http://server/path") === 14 // "http://server/"
|
|
7348
|
+
* ```
|
|
7349
|
+
*/
|
|
7350
|
+
function getRootLength(path) {
|
|
7351
|
+
var rootLength = getEncodedRootLength(path);
|
|
7352
|
+
return rootLength < 0 ? ~rootLength : rootLength;
|
|
7353
|
+
}
|
|
7354
|
+
ts.getRootLength = getRootLength;
|
|
7355
|
+
function getDirectoryPath(path) {
|
|
7356
|
+
path = normalizeSlashes(path);
|
|
7357
|
+
// If the path provided is itself the root, then return it.
|
|
7358
|
+
var rootLength = getRootLength(path);
|
|
7359
|
+
if (rootLength === path.length)
|
|
7360
|
+
return path;
|
|
7361
|
+
// return the leading portion of the path up to the last (non-terminal) directory separator
|
|
7362
|
+
// but not including any trailing directory separator.
|
|
7363
|
+
path = removeTrailingDirectorySeparator(path);
|
|
7364
|
+
return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator)));
|
|
7365
|
+
}
|
|
7366
|
+
ts.getDirectoryPath = getDirectoryPath;
|
|
7367
|
+
function getBaseFileName(path, extensions, ignoreCase) {
|
|
7368
|
+
path = normalizeSlashes(path);
|
|
7369
|
+
// if the path provided is itself the root, then it has not file name.
|
|
7370
|
+
var rootLength = getRootLength(path);
|
|
7371
|
+
if (rootLength === path.length)
|
|
7372
|
+
return "";
|
|
7373
|
+
// return the trailing portion of the path starting after the last (non-terminal) directory
|
|
7374
|
+
// separator but not including any trailing directory separator.
|
|
7375
|
+
path = removeTrailingDirectorySeparator(path);
|
|
7376
|
+
var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1));
|
|
7377
|
+
var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined;
|
|
7378
|
+
return extension ? name.slice(0, name.length - extension.length) : name;
|
|
7379
|
+
}
|
|
7380
|
+
ts.getBaseFileName = getBaseFileName;
|
|
7381
|
+
function tryGetExtensionFromPath(path, extension, stringEqualityComparer) {
|
|
7382
|
+
if (!ts.startsWith(extension, "."))
|
|
7383
|
+
extension = "." + extension;
|
|
7384
|
+
if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) {
|
|
7385
|
+
var pathExtension = path.slice(path.length - extension.length);
|
|
7386
|
+
if (stringEqualityComparer(pathExtension, extension)) {
|
|
7387
|
+
return pathExtension;
|
|
7388
|
+
}
|
|
7389
|
+
}
|
|
7390
|
+
}
|
|
7391
|
+
function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) {
|
|
7392
|
+
if (typeof extensions === "string") {
|
|
7393
|
+
return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || "";
|
|
7394
|
+
}
|
|
7395
|
+
for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) {
|
|
7396
|
+
var extension = extensions_2[_i];
|
|
7397
|
+
var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer);
|
|
7398
|
+
if (result)
|
|
7399
|
+
return result;
|
|
7400
|
+
}
|
|
7401
|
+
return "";
|
|
7402
|
+
}
|
|
7403
|
+
function getAnyExtensionFromPath(path, extensions, ignoreCase) {
|
|
7404
|
+
// Retrieves any string from the final "." onwards from a base file name.
|
|
7405
|
+
// Unlike extensionFromPath, which throws an exception on unrecognized extensions.
|
|
7406
|
+
if (extensions) {
|
|
7407
|
+
return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive);
|
|
7408
|
+
}
|
|
7409
|
+
var baseFileName = getBaseFileName(path);
|
|
7410
|
+
var extensionIndex = baseFileName.lastIndexOf(".");
|
|
7411
|
+
if (extensionIndex >= 0) {
|
|
7412
|
+
return baseFileName.substring(extensionIndex);
|
|
7413
|
+
}
|
|
7414
|
+
return "";
|
|
7415
|
+
}
|
|
7416
|
+
ts.getAnyExtensionFromPath = getAnyExtensionFromPath;
|
|
7417
|
+
function pathComponents(path, rootLength) {
|
|
7418
|
+
var root = path.substring(0, rootLength);
|
|
7419
|
+
var rest = path.substring(rootLength).split(ts.directorySeparator);
|
|
7420
|
+
if (rest.length && !ts.lastOrUndefined(rest))
|
|
7421
|
+
rest.pop();
|
|
7422
|
+
return __spreadArray([root], rest, true);
|
|
7423
|
+
}
|
|
7424
|
+
/**
|
|
7425
|
+
* Parse a path into an array containing a root component (at index 0) and zero or more path
|
|
7426
|
+
* components (at indices > 0). The result is not normalized.
|
|
7427
|
+
* If the path is relative, the root component is `""`.
|
|
7428
|
+
* If the path is absolute, the root component includes the first path separator (`/`).
|
|
7429
|
+
*
|
|
7430
|
+
* ```ts
|
|
7431
|
+
* // POSIX
|
|
7432
|
+
* getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"]
|
|
7433
|
+
* getPathComponents("/path/to/") === ["/", "path", "to"]
|
|
7434
|
+
* getPathComponents("/") === ["/"]
|
|
7435
|
+
* // DOS
|
|
7436
|
+
* getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"]
|
|
7437
|
+
* getPathComponents("c:/path/to/") === ["c:/", "path", "to"]
|
|
7438
|
+
* getPathComponents("c:/") === ["c:/"]
|
|
7439
|
+
* getPathComponents("c:") === ["c:"]
|
|
7440
|
+
* // URL
|
|
7441
|
+
* getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"]
|
|
7442
|
+
* getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"]
|
|
7443
|
+
* getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"]
|
|
7444
|
+
* getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"]
|
|
7445
|
+
* getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"]
|
|
7446
|
+
* getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"]
|
|
7447
|
+
* getPathComponents("file://server/") === ["file://server/"]
|
|
7448
|
+
* getPathComponents("file://server") === ["file://server"]
|
|
7449
|
+
* getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"]
|
|
7450
|
+
* getPathComponents("file:///path/to/") === ["file:///", "path", "to"]
|
|
7451
|
+
* getPathComponents("file:///") === ["file:///"]
|
|
7452
|
+
* getPathComponents("file://") === ["file://"]
|
|
7453
|
+
*/
|
|
7454
|
+
function getPathComponents(path, currentDirectory) {
|
|
7455
|
+
if (currentDirectory === void 0) { currentDirectory = ""; }
|
|
7456
|
+
path = combinePaths(currentDirectory, path);
|
|
7457
|
+
return pathComponents(path, getRootLength(path));
|
|
7458
|
+
}
|
|
7459
|
+
ts.getPathComponents = getPathComponents;
|
|
7460
|
+
//// Path Formatting
|
|
7461
|
+
/**
|
|
7462
|
+
* Formats a parsed path consisting of a root component (at index 0) and zero or more path
|
|
7463
|
+
* segments (at indices > 0).
|
|
7464
|
+
*
|
|
7465
|
+
* ```ts
|
|
7466
|
+
* getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext"
|
|
7467
|
+
* ```
|
|
7468
|
+
*/
|
|
7469
|
+
function getPathFromPathComponents(pathComponents) {
|
|
7470
|
+
if (pathComponents.length === 0)
|
|
7471
|
+
return "";
|
|
7472
|
+
var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
|
|
7473
|
+
return root + pathComponents.slice(1).join(ts.directorySeparator);
|
|
7474
|
+
}
|
|
7475
|
+
ts.getPathFromPathComponents = getPathFromPathComponents;
|
|
7476
|
+
//// Path Normalization
|
|
7477
|
+
/**
|
|
7478
|
+
* Normalize path separators, converting `\` into `/`.
|
|
7479
|
+
*/
|
|
7480
|
+
function normalizeSlashes(path) {
|
|
7481
|
+
var index = path.indexOf("\\");
|
|
7482
|
+
if (index === -1) {
|
|
7483
|
+
return path;
|
|
7484
|
+
}
|
|
7485
|
+
backslashRegExp.lastIndex = index; // prime regex with known position
|
|
7486
|
+
return path.replace(backslashRegExp, ts.directorySeparator);
|
|
7487
|
+
}
|
|
7488
|
+
ts.normalizeSlashes = normalizeSlashes;
|
|
7489
|
+
/**
|
|
7490
|
+
* Reduce an array of path components to a more simplified path by navigating any
|
|
7491
|
+
* `"."` or `".."` entries in the path.
|
|
7492
|
+
*/
|
|
7493
|
+
function reducePathComponents(components) {
|
|
7494
|
+
if (!ts.some(components))
|
|
7495
|
+
return [];
|
|
7496
|
+
var reduced = [components[0]];
|
|
7497
|
+
for (var i = 1; i < components.length; i++) {
|
|
7498
|
+
var component = components[i];
|
|
7499
|
+
if (!component)
|
|
7500
|
+
continue;
|
|
7501
|
+
if (component === ".")
|
|
7502
|
+
continue;
|
|
7503
|
+
if (component === "..") {
|
|
7504
|
+
if (reduced.length > 1) {
|
|
7505
|
+
if (reduced[reduced.length - 1] !== "..") {
|
|
7506
|
+
reduced.pop();
|
|
7507
|
+
continue;
|
|
7508
|
+
}
|
|
7509
|
+
}
|
|
7510
|
+
else if (reduced[0])
|
|
7511
|
+
continue;
|
|
7512
|
+
}
|
|
7513
|
+
reduced.push(component);
|
|
7514
|
+
}
|
|
7515
|
+
return reduced;
|
|
7516
|
+
}
|
|
7517
|
+
ts.reducePathComponents = reducePathComponents;
|
|
7518
|
+
/**
|
|
7519
|
+
* Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified.
|
|
7520
|
+
*
|
|
7521
|
+
* ```ts
|
|
7522
|
+
* // Non-rooted
|
|
7523
|
+
* combinePaths("path", "to", "file.ext") === "path/to/file.ext"
|
|
7524
|
+
* combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext"
|
|
7525
|
+
* // POSIX
|
|
7526
|
+
* combinePaths("/path", "to", "file.ext") === "/path/to/file.ext"
|
|
7527
|
+
* combinePaths("/path", "/to", "file.ext") === "/to/file.ext"
|
|
7528
|
+
* // DOS
|
|
7529
|
+
* combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext"
|
|
7530
|
+
* combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext"
|
|
7531
|
+
* // URL
|
|
7532
|
+
* combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext"
|
|
7533
|
+
* combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext"
|
|
7534
|
+
* ```
|
|
7535
|
+
*/
|
|
7536
|
+
function combinePaths(path) {
|
|
7537
|
+
var paths = [];
|
|
7538
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
7539
|
+
paths[_i - 1] = arguments[_i];
|
|
7540
|
+
}
|
|
7541
|
+
if (path)
|
|
7542
|
+
path = normalizeSlashes(path);
|
|
7543
|
+
for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
|
|
7544
|
+
var relativePath = paths_1[_a];
|
|
7545
|
+
if (!relativePath)
|
|
7546
|
+
continue;
|
|
7547
|
+
relativePath = normalizeSlashes(relativePath);
|
|
7548
|
+
if (!path || getRootLength(relativePath) !== 0) {
|
|
7549
|
+
path = relativePath;
|
|
7550
|
+
}
|
|
7551
|
+
else {
|
|
7552
|
+
path = ensureTrailingDirectorySeparator(path) + relativePath;
|
|
7797
7553
|
}
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
|
|
7554
|
+
}
|
|
7555
|
+
return path;
|
|
7556
|
+
}
|
|
7557
|
+
ts.combinePaths = combinePaths;
|
|
7558
|
+
/**
|
|
7559
|
+
* Combines and resolves paths. If a path is absolute, it replaces any previous path. Any
|
|
7560
|
+
* `.` and `..` path components are resolved. Trailing directory separators are preserved.
|
|
7561
|
+
*
|
|
7562
|
+
* ```ts
|
|
7563
|
+
* resolvePath("/path", "to", "file.ext") === "path/to/file.ext"
|
|
7564
|
+
* resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/"
|
|
7565
|
+
* resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext"
|
|
7566
|
+
* ```
|
|
7567
|
+
*/
|
|
7568
|
+
function resolvePath(path) {
|
|
7569
|
+
var paths = [];
|
|
7570
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
7571
|
+
paths[_i - 1] = arguments[_i];
|
|
7572
|
+
}
|
|
7573
|
+
return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArray([path], paths, false)) : normalizeSlashes(path));
|
|
7574
|
+
}
|
|
7575
|
+
ts.resolvePath = resolvePath;
|
|
7576
|
+
/**
|
|
7577
|
+
* Parse a path into an array containing a root component (at index 0) and zero or more path
|
|
7578
|
+
* components (at indices > 0). The result is normalized.
|
|
7579
|
+
* If the path is relative, the root component is `""`.
|
|
7580
|
+
* If the path is absolute, the root component includes the first path separator (`/`).
|
|
7581
|
+
*
|
|
7582
|
+
* ```ts
|
|
7583
|
+
* getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"]
|
|
7584
|
+
* ```
|
|
7585
|
+
*/
|
|
7586
|
+
function getNormalizedPathComponents(path, currentDirectory) {
|
|
7587
|
+
return reducePathComponents(getPathComponents(path, currentDirectory));
|
|
7588
|
+
}
|
|
7589
|
+
ts.getNormalizedPathComponents = getNormalizedPathComponents;
|
|
7590
|
+
function getNormalizedAbsolutePath(fileName, currentDirectory) {
|
|
7591
|
+
return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
|
|
7592
|
+
}
|
|
7593
|
+
ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
|
|
7594
|
+
function normalizePath(path) {
|
|
7595
|
+
path = normalizeSlashes(path);
|
|
7596
|
+
// Most paths don't require normalization
|
|
7597
|
+
if (!relativePathSegmentRegExp.test(path)) {
|
|
7598
|
+
return path;
|
|
7599
|
+
}
|
|
7600
|
+
// Some paths only require cleanup of `/./` or leading `./`
|
|
7601
|
+
var simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, "");
|
|
7602
|
+
if (simplified !== path) {
|
|
7603
|
+
path = simplified;
|
|
7604
|
+
if (!relativePathSegmentRegExp.test(path)) {
|
|
7605
|
+
return path;
|
|
7805
7606
|
}
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
|
|
7809
|
-
|
|
7810
|
-
|
|
7811
|
-
|
|
7812
|
-
|
|
7607
|
+
}
|
|
7608
|
+
// Other paths require full normalization
|
|
7609
|
+
var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
|
|
7610
|
+
return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
|
|
7611
|
+
}
|
|
7612
|
+
ts.normalizePath = normalizePath;
|
|
7613
|
+
function getPathWithoutRoot(pathComponents) {
|
|
7614
|
+
if (pathComponents.length === 0)
|
|
7615
|
+
return "";
|
|
7616
|
+
return pathComponents.slice(1).join(ts.directorySeparator);
|
|
7617
|
+
}
|
|
7618
|
+
function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
|
|
7619
|
+
return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
|
|
7620
|
+
}
|
|
7621
|
+
ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
|
|
7622
|
+
function toPath(fileName, basePath, getCanonicalFileName) {
|
|
7623
|
+
var nonCanonicalizedPath = isRootedDiskPath(fileName)
|
|
7624
|
+
? normalizePath(fileName)
|
|
7625
|
+
: getNormalizedAbsolutePath(fileName, basePath);
|
|
7626
|
+
return getCanonicalFileName(nonCanonicalizedPath);
|
|
7627
|
+
}
|
|
7628
|
+
ts.toPath = toPath;
|
|
7629
|
+
function normalizePathAndParts(path) {
|
|
7630
|
+
path = normalizeSlashes(path);
|
|
7631
|
+
var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
|
|
7632
|
+
if (parts.length) {
|
|
7633
|
+
var joinedParts = root + parts.join(ts.directorySeparator);
|
|
7634
|
+
return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
|
|
7635
|
+
}
|
|
7636
|
+
else {
|
|
7637
|
+
return { path: root, parts: parts };
|
|
7638
|
+
}
|
|
7639
|
+
}
|
|
7640
|
+
ts.normalizePathAndParts = normalizePathAndParts;
|
|
7641
|
+
function removeTrailingDirectorySeparator(path) {
|
|
7642
|
+
if (hasTrailingDirectorySeparator(path)) {
|
|
7643
|
+
return path.substr(0, path.length - 1);
|
|
7644
|
+
}
|
|
7645
|
+
return path;
|
|
7646
|
+
}
|
|
7647
|
+
ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
|
|
7648
|
+
function ensureTrailingDirectorySeparator(path) {
|
|
7649
|
+
if (!hasTrailingDirectorySeparator(path)) {
|
|
7650
|
+
return path + ts.directorySeparator;
|
|
7651
|
+
}
|
|
7652
|
+
return path;
|
|
7653
|
+
}
|
|
7654
|
+
ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator;
|
|
7655
|
+
/**
|
|
7656
|
+
* Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed
|
|
7657
|
+
* with `./` or `../`) so as not to be confused with an unprefixed module name.
|
|
7658
|
+
*
|
|
7659
|
+
* ```ts
|
|
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
|
+
* ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext"
|
|
7664
|
+
* ```
|
|
7665
|
+
*/
|
|
7666
|
+
function ensurePathIsNonModuleName(path) {
|
|
7667
|
+
return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path;
|
|
7668
|
+
}
|
|
7669
|
+
ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName;
|
|
7670
|
+
function changeAnyExtension(path, ext, extensions, ignoreCase) {
|
|
7671
|
+
var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path);
|
|
7672
|
+
return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
|
|
7673
|
+
}
|
|
7674
|
+
ts.changeAnyExtension = changeAnyExtension;
|
|
7675
|
+
//// Path Comparisons
|
|
7676
|
+
// check path for these segments: '', '.'. '..'
|
|
7677
|
+
var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/;
|
|
7678
|
+
function comparePathsWorker(a, b, componentComparer) {
|
|
7679
|
+
if (a === b)
|
|
7680
|
+
return 0 /* EqualTo */;
|
|
7681
|
+
if (a === undefined)
|
|
7682
|
+
return -1 /* LessThan */;
|
|
7683
|
+
if (b === undefined)
|
|
7684
|
+
return 1 /* GreaterThan */;
|
|
7685
|
+
// NOTE: Performance optimization - shortcut if the root segments differ as there would be no
|
|
7686
|
+
// need to perform path reduction.
|
|
7687
|
+
var aRoot = a.substring(0, getRootLength(a));
|
|
7688
|
+
var bRoot = b.substring(0, getRootLength(b));
|
|
7689
|
+
var result = ts.compareStringsCaseInsensitive(aRoot, bRoot);
|
|
7690
|
+
if (result !== 0 /* EqualTo */) {
|
|
7691
|
+
return result;
|
|
7692
|
+
}
|
|
7693
|
+
// NOTE: Performance optimization - shortcut if there are no relative path segments in
|
|
7694
|
+
// the non-root portion of the path
|
|
7695
|
+
var aRest = a.substring(aRoot.length);
|
|
7696
|
+
var bRest = b.substring(bRoot.length);
|
|
7697
|
+
if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) {
|
|
7698
|
+
return componentComparer(aRest, bRest);
|
|
7699
|
+
}
|
|
7700
|
+
// The path contains a relative path segment. Normalize the paths and perform a slower component
|
|
7701
|
+
// by component comparison.
|
|
7702
|
+
var aComponents = reducePathComponents(getPathComponents(a));
|
|
7703
|
+
var bComponents = reducePathComponents(getPathComponents(b));
|
|
7704
|
+
var sharedLength = Math.min(aComponents.length, bComponents.length);
|
|
7705
|
+
for (var i = 1; i < sharedLength; i++) {
|
|
7706
|
+
var result_2 = componentComparer(aComponents[i], bComponents[i]);
|
|
7707
|
+
if (result_2 !== 0 /* EqualTo */) {
|
|
7708
|
+
return result_2;
|
|
7813
7709
|
}
|
|
7814
|
-
|
|
7815
|
-
|
|
7816
|
-
|
|
7817
|
-
|
|
7710
|
+
}
|
|
7711
|
+
return ts.compareValues(aComponents.length, bComponents.length);
|
|
7712
|
+
}
|
|
7713
|
+
/**
|
|
7714
|
+
* Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively.
|
|
7715
|
+
*/
|
|
7716
|
+
function comparePathsCaseSensitive(a, b) {
|
|
7717
|
+
return comparePathsWorker(a, b, ts.compareStringsCaseSensitive);
|
|
7718
|
+
}
|
|
7719
|
+
ts.comparePathsCaseSensitive = comparePathsCaseSensitive;
|
|
7720
|
+
/**
|
|
7721
|
+
* Performs a case-insensitive comparison of two paths.
|
|
7722
|
+
*/
|
|
7723
|
+
function comparePathsCaseInsensitive(a, b) {
|
|
7724
|
+
return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive);
|
|
7725
|
+
}
|
|
7726
|
+
ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive;
|
|
7727
|
+
function comparePaths(a, b, currentDirectory, ignoreCase) {
|
|
7728
|
+
if (typeof currentDirectory === "string") {
|
|
7729
|
+
a = combinePaths(currentDirectory, a);
|
|
7730
|
+
b = combinePaths(currentDirectory, b);
|
|
7731
|
+
}
|
|
7732
|
+
else if (typeof currentDirectory === "boolean") {
|
|
7733
|
+
ignoreCase = currentDirectory;
|
|
7734
|
+
}
|
|
7735
|
+
return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase));
|
|
7736
|
+
}
|
|
7737
|
+
ts.comparePaths = comparePaths;
|
|
7738
|
+
function containsPath(parent, child, currentDirectory, ignoreCase) {
|
|
7739
|
+
if (typeof currentDirectory === "string") {
|
|
7740
|
+
parent = combinePaths(currentDirectory, parent);
|
|
7741
|
+
child = combinePaths(currentDirectory, child);
|
|
7742
|
+
}
|
|
7743
|
+
else if (typeof currentDirectory === "boolean") {
|
|
7744
|
+
ignoreCase = currentDirectory;
|
|
7745
|
+
}
|
|
7746
|
+
if (parent === undefined || child === undefined)
|
|
7747
|
+
return false;
|
|
7748
|
+
if (parent === child)
|
|
7749
|
+
return true;
|
|
7750
|
+
var parentComponents = reducePathComponents(getPathComponents(parent));
|
|
7751
|
+
var childComponents = reducePathComponents(getPathComponents(child));
|
|
7752
|
+
if (childComponents.length < parentComponents.length) {
|
|
7753
|
+
return false;
|
|
7754
|
+
}
|
|
7755
|
+
var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive;
|
|
7756
|
+
for (var i = 0; i < parentComponents.length; i++) {
|
|
7757
|
+
var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer;
|
|
7758
|
+
if (!equalityComparer(parentComponents[i], childComponents[i])) {
|
|
7759
|
+
return false;
|
|
7818
7760
|
}
|
|
7819
7761
|
}
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7762
|
+
return true;
|
|
7763
|
+
}
|
|
7764
|
+
ts.containsPath = containsPath;
|
|
7765
|
+
/**
|
|
7766
|
+
* Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback.
|
|
7767
|
+
* Comparison is case-sensitive between the canonical paths.
|
|
7768
|
+
*
|
|
7769
|
+
* Use `containsPath` if file names are not already reduced and absolute.
|
|
7770
|
+
*/
|
|
7771
|
+
function startsWithDirectory(fileName, directoryName, getCanonicalFileName) {
|
|
7772
|
+
var canonicalFileName = getCanonicalFileName(fileName);
|
|
7773
|
+
var canonicalDirectoryName = getCanonicalFileName(directoryName);
|
|
7774
|
+
return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\");
|
|
7775
|
+
}
|
|
7776
|
+
ts.startsWithDirectory = startsWithDirectory;
|
|
7777
|
+
//// Relative Paths
|
|
7778
|
+
function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) {
|
|
7779
|
+
var fromComponents = reducePathComponents(getPathComponents(from));
|
|
7780
|
+
var toComponents = reducePathComponents(getPathComponents(to));
|
|
7781
|
+
var start;
|
|
7782
|
+
for (start = 0; start < fromComponents.length && start < toComponents.length; start++) {
|
|
7783
|
+
var fromComponent = getCanonicalFileName(fromComponents[start]);
|
|
7784
|
+
var toComponent = getCanonicalFileName(toComponents[start]);
|
|
7785
|
+
var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer;
|
|
7786
|
+
if (!comparer(fromComponent, toComponent))
|
|
7787
|
+
break;
|
|
7825
7788
|
}
|
|
7826
|
-
if (
|
|
7827
|
-
|
|
7828
|
-
patchWriteFileEnsuringDirectory(sys);
|
|
7789
|
+
if (start === 0) {
|
|
7790
|
+
return toComponents;
|
|
7829
7791
|
}
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7792
|
+
var components = toComponents.slice(start);
|
|
7793
|
+
var relative = [];
|
|
7794
|
+
for (; start < fromComponents.length; start++) {
|
|
7795
|
+
relative.push("..");
|
|
7796
|
+
}
|
|
7797
|
+
return __spreadArray(__spreadArray([""], relative, true), components, true);
|
|
7835
7798
|
}
|
|
7836
|
-
ts.
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
ts.
|
|
7840
|
-
|
|
7841
|
-
|
|
7799
|
+
ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo;
|
|
7800
|
+
function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
|
|
7801
|
+
ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
|
|
7802
|
+
var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
|
|
7803
|
+
var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
|
|
7804
|
+
var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
|
|
7805
|
+
return getPathFromPathComponents(pathComponents);
|
|
7842
7806
|
}
|
|
7843
|
-
|
|
7844
|
-
|
|
7807
|
+
ts.getRelativePathFromDirectory = getRelativePathFromDirectory;
|
|
7808
|
+
function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
|
|
7809
|
+
return !isRootedDiskPath(absoluteOrRelativePath)
|
|
7810
|
+
? absoluteOrRelativePath
|
|
7811
|
+
: getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
|
|
7812
|
+
}
|
|
7813
|
+
ts.convertToRelativePath = convertToRelativePath;
|
|
7814
|
+
function getRelativePathFromFile(from, to, getCanonicalFileName) {
|
|
7815
|
+
return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName));
|
|
7816
|
+
}
|
|
7817
|
+
ts.getRelativePathFromFile = getRelativePathFromFile;
|
|
7818
|
+
function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
|
|
7819
|
+
var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName);
|
|
7820
|
+
var firstComponent = pathComponents[0];
|
|
7821
|
+
if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) {
|
|
7822
|
+
var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///";
|
|
7823
|
+
pathComponents[0] = prefix + firstComponent;
|
|
7824
|
+
}
|
|
7825
|
+
return getPathFromPathComponents(pathComponents);
|
|
7826
|
+
}
|
|
7827
|
+
ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl;
|
|
7828
|
+
function forEachAncestorDirectory(directory, callback) {
|
|
7829
|
+
while (true) {
|
|
7830
|
+
var result = callback(directory);
|
|
7831
|
+
if (result !== undefined) {
|
|
7832
|
+
return result;
|
|
7833
|
+
}
|
|
7834
|
+
var parentPath = getDirectoryPath(directory);
|
|
7835
|
+
if (parentPath === directory) {
|
|
7836
|
+
return undefined;
|
|
7837
|
+
}
|
|
7838
|
+
directory = parentPath;
|
|
7839
|
+
}
|
|
7840
|
+
}
|
|
7841
|
+
ts.forEachAncestorDirectory = forEachAncestorDirectory;
|
|
7842
|
+
function isNodeModulesDirectory(dirPath) {
|
|
7843
|
+
return ts.endsWith(dirPath, "/node_modules");
|
|
7845
7844
|
}
|
|
7845
|
+
ts.isNodeModulesDirectory = isNodeModulesDirectory;
|
|
7846
7846
|
})(ts || (ts = {}));
|
|
7847
7847
|
// <auto-generated />
|
|
7848
|
-
// generated from './
|
|
7848
|
+
// generated from './diagnosticMessages.json' in 'src/compiler'
|
|
7849
7849
|
/* @internal */
|
|
7850
7850
|
var ts;
|
|
7851
7851
|
(function (ts) {
|
|
@@ -8138,7 +8138,6 @@ var ts;
|
|
|
8138
8138
|
Unexpected_token_Did_you_mean_or_rbrace: diag(1381, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_rbrace_1381", "Unexpected token. Did you mean `{'}'}` or `}`?"),
|
|
8139
8139
|
Unexpected_token_Did_you_mean_or_gt: diag(1382, ts.DiagnosticCategory.Error, "Unexpected_token_Did_you_mean_or_gt_1382", "Unexpected token. Did you mean `{'>'}` or `>`?"),
|
|
8140
8140
|
Only_named_exports_may_use_export_type: diag(1383, ts.DiagnosticCategory.Error, "Only_named_exports_may_use_export_type_1383", "Only named exports may use 'export type'."),
|
|
8141
|
-
A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list: diag(1384, ts.DiagnosticCategory.Error, "A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list_1384", "A 'new' expression with type arguments must always be followed by a parenthesized argument list."),
|
|
8142
8141
|
Function_type_notation_must_be_parenthesized_when_used_in_a_union_type: diag(1385, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_a_union_type_1385", "Function type notation must be parenthesized when used in a union type."),
|
|
8143
8142
|
Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type: diag(1386, ts.DiagnosticCategory.Error, "Constructor_type_notation_must_be_parenthesized_when_used_in_a_union_type_1386", "Constructor type notation must be parenthesized when used in a union type."),
|
|
8144
8143
|
Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type: diag(1387, ts.DiagnosticCategory.Error, "Function_type_notation_must_be_parenthesized_when_used_in_an_intersection_type_1387", "Function type notation must be parenthesized when used in an intersection type."),
|
|
@@ -8672,12 +8671,10 @@ var ts;
|
|
|
8672
8671
|
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."),
|
|
8673
8672
|
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."),
|
|
8674
8673
|
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."),
|
|
8675
|
-
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."),
|
|
8676
8674
|
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."),
|
|
8677
8675
|
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}'."),
|
|
8678
8676
|
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"),
|
|
8679
8677
|
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."),
|
|
8680
|
-
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'."),
|
|
8681
8678
|
Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"),
|
|
8682
8679
|
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'."),
|
|
8683
8680
|
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}'."),
|
|
@@ -9434,9 +9431,8 @@ var ts;
|
|
|
9434
9431
|
Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"),
|
|
9435
9432
|
Remove_template_tag: diag(90011, ts.DiagnosticCategory.Message, "Remove_template_tag_90011", "Remove template tag"),
|
|
9436
9433
|
Remove_type_parameters: diag(90012, ts.DiagnosticCategory.Message, "Remove_type_parameters_90012", "Remove type parameters"),
|
|
9437
|
-
|
|
9434
|
+
Import_0_from_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_1_90013", "Import '{0}' from \"{1}\""),
|
|
9438
9435
|
Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"),
|
|
9439
|
-
Add_0_to_existing_import_declaration_from_1: diag(90015, ts.DiagnosticCategory.Message, "Add_0_to_existing_import_declaration_from_1_90015", "Add '{0}' to existing import declaration from \"{1}\""),
|
|
9440
9436
|
Declare_property_0: diag(90016, ts.DiagnosticCategory.Message, "Declare_property_0_90016", "Declare property '{0}'"),
|
|
9441
9437
|
Add_index_signature_for_property_0: diag(90017, ts.DiagnosticCategory.Message, "Add_index_signature_for_property_0_90017", "Add index signature for property '{0}'"),
|
|
9442
9438
|
Disable_checking_for_this_file: diag(90018, ts.DiagnosticCategory.Message, "Disable_checking_for_this_file_90018", "Disable checking for this file"),
|
|
@@ -9453,8 +9449,6 @@ var ts;
|
|
|
9453
9449
|
Add_async_modifier_to_containing_function: diag(90029, ts.DiagnosticCategory.Message, "Add_async_modifier_to_containing_function_90029", "Add async modifier to containing function"),
|
|
9454
9450
|
Replace_infer_0_with_unknown: diag(90030, ts.DiagnosticCategory.Message, "Replace_infer_0_with_unknown_90030", "Replace 'infer {0}' with 'unknown'"),
|
|
9455
9451
|
Replace_all_unused_infer_with_unknown: diag(90031, ts.DiagnosticCategory.Message, "Replace_all_unused_infer_with_unknown_90031", "Replace all unused 'infer' with 'unknown'"),
|
|
9456
|
-
Import_default_0_from_module_1: diag(90032, ts.DiagnosticCategory.Message, "Import_default_0_from_module_1_90032", "Import default '{0}' from module \"{1}\""),
|
|
9457
|
-
Add_default_import_0_to_existing_import_declaration_from_1: diag(90033, ts.DiagnosticCategory.Message, "Add_default_import_0_to_existing_import_declaration_from_1_90033", "Add default import '{0}' to existing import declaration from \"{1}\""),
|
|
9458
9452
|
Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"),
|
|
9459
9453
|
Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"),
|
|
9460
9454
|
Replace_0_with_Promise_1: diag(90036, ts.DiagnosticCategory.Message, "Replace_0_with_Promise_1_90036", "Replace '{0}' with 'Promise<{1}>'"),
|
|
@@ -9466,6 +9460,8 @@ var ts;
|
|
|
9466
9460
|
Includes_imports_of_types_referenced_by_0: diag(90054, ts.DiagnosticCategory.Message, "Includes_imports_of_types_referenced_by_0_90054", "Includes imports of types referenced by '{0}'"),
|
|
9467
9461
|
Remove_type_from_import_declaration_from_0: diag(90055, ts.DiagnosticCategory.Message, "Remove_type_from_import_declaration_from_0_90055", "Remove 'type' from import declaration from \"{0}\""),
|
|
9468
9462
|
Remove_type_from_import_of_0_from_1: diag(90056, ts.DiagnosticCategory.Message, "Remove_type_from_import_of_0_from_1_90056", "Remove 'type' from import of '{0}' from \"{1}\""),
|
|
9463
|
+
Add_import_from_0: diag(90057, ts.DiagnosticCategory.Message, "Add_import_from_0_90057", "Add import from \"{0}\""),
|
|
9464
|
+
Update_import_from_0: diag(90058, ts.DiagnosticCategory.Message, "Update_import_from_0_90058", "Update import from \"{0}\""),
|
|
9469
9465
|
Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
|
|
9470
9466
|
Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
|
|
9471
9467
|
Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
|
|
@@ -9629,6 +9625,7 @@ var ts;
|
|
|
9629
9625
|
Add_missing_attributes: diag(95167, ts.DiagnosticCategory.Message, "Add_missing_attributes_95167", "Add missing attributes"),
|
|
9630
9626
|
Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"),
|
|
9631
9627
|
Add_undefined_to_optional_property_type: diag(95169, ts.DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"),
|
|
9628
|
+
Convert_named_imports_to_default_import: diag(95170, ts.DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"),
|
|
9632
9629
|
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."),
|
|
9633
9630
|
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'."),
|
|
9634
9631
|
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?"),
|
|
@@ -12801,12 +12798,17 @@ var ts;
|
|
|
12801
12798
|
/** Gets the text of a jsdoc comment, flattening links to their text. */
|
|
12802
12799
|
function getTextOfJSDocComment(comment) {
|
|
12803
12800
|
return typeof comment === "string" ? comment
|
|
12804
|
-
: comment === null || comment === void 0 ? void 0 : comment.map(function (c) {
|
|
12805
|
-
// TODO: Other kinds here
|
|
12806
|
-
return c.kind === 319 /* JSDocText */ ? c.text : "{@link " + (c.name ? ts.entityNameToString(c.name) + " " : "") + c.text + "}";
|
|
12807
|
-
}).join("");
|
|
12801
|
+
: comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 319 /* JSDocText */ ? c.text : formatJSDocLink(c); }).join("");
|
|
12808
12802
|
}
|
|
12809
12803
|
ts.getTextOfJSDocComment = getTextOfJSDocComment;
|
|
12804
|
+
function formatJSDocLink(link) {
|
|
12805
|
+
var kind = link.kind === 322 /* JSDocLink */ ? "link"
|
|
12806
|
+
: link.kind === 323 /* JSDocLinkCode */ ? "linkcode"
|
|
12807
|
+
: "linkplain";
|
|
12808
|
+
var name = link.name ? ts.entityNameToString(link.name) : "";
|
|
12809
|
+
var space = link.name && link.text.startsWith("://") ? "" : " ";
|
|
12810
|
+
return "{@" + kind + " " + name + space + link.text + "}";
|
|
12811
|
+
}
|
|
12810
12812
|
/**
|
|
12811
12813
|
* Gets the effective type parameters. If the node was parsed in a
|
|
12812
12814
|
* JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
|
|
@@ -20865,6 +20867,59 @@ var ts;
|
|
|
20865
20867
|
return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
|
|
20866
20868
|
}
|
|
20867
20869
|
ts.isThisTypeParameter = isThisTypeParameter;
|
|
20870
|
+
function getNodeModulePathParts(fullPath) {
|
|
20871
|
+
// If fullPath can't be valid module file within node_modules, returns undefined.
|
|
20872
|
+
// Example of expected pattern: /base/path/node_modules/[@scope/otherpackage/@otherscope/node_modules/]package/[subdirectory/]file.js
|
|
20873
|
+
// Returns indices: ^ ^ ^ ^
|
|
20874
|
+
var topLevelNodeModulesIndex = 0;
|
|
20875
|
+
var topLevelPackageNameIndex = 0;
|
|
20876
|
+
var packageRootIndex = 0;
|
|
20877
|
+
var fileNameIndex = 0;
|
|
20878
|
+
var States;
|
|
20879
|
+
(function (States) {
|
|
20880
|
+
States[States["BeforeNodeModules"] = 0] = "BeforeNodeModules";
|
|
20881
|
+
States[States["NodeModules"] = 1] = "NodeModules";
|
|
20882
|
+
States[States["Scope"] = 2] = "Scope";
|
|
20883
|
+
States[States["PackageContent"] = 3] = "PackageContent";
|
|
20884
|
+
})(States || (States = {}));
|
|
20885
|
+
var partStart = 0;
|
|
20886
|
+
var partEnd = 0;
|
|
20887
|
+
var state = 0 /* BeforeNodeModules */;
|
|
20888
|
+
while (partEnd >= 0) {
|
|
20889
|
+
partStart = partEnd;
|
|
20890
|
+
partEnd = fullPath.indexOf("/", partStart + 1);
|
|
20891
|
+
switch (state) {
|
|
20892
|
+
case 0 /* BeforeNodeModules */:
|
|
20893
|
+
if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
|
|
20894
|
+
topLevelNodeModulesIndex = partStart;
|
|
20895
|
+
topLevelPackageNameIndex = partEnd;
|
|
20896
|
+
state = 1 /* NodeModules */;
|
|
20897
|
+
}
|
|
20898
|
+
break;
|
|
20899
|
+
case 1 /* NodeModules */:
|
|
20900
|
+
case 2 /* Scope */:
|
|
20901
|
+
if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") {
|
|
20902
|
+
state = 2 /* Scope */;
|
|
20903
|
+
}
|
|
20904
|
+
else {
|
|
20905
|
+
packageRootIndex = partEnd;
|
|
20906
|
+
state = 3 /* PackageContent */;
|
|
20907
|
+
}
|
|
20908
|
+
break;
|
|
20909
|
+
case 3 /* PackageContent */:
|
|
20910
|
+
if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
|
|
20911
|
+
state = 1 /* NodeModules */;
|
|
20912
|
+
}
|
|
20913
|
+
else {
|
|
20914
|
+
state = 3 /* PackageContent */;
|
|
20915
|
+
}
|
|
20916
|
+
break;
|
|
20917
|
+
}
|
|
20918
|
+
}
|
|
20919
|
+
fileNameIndex = partStart;
|
|
20920
|
+
return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
|
|
20921
|
+
}
|
|
20922
|
+
ts.getNodeModulePathParts = getNodeModulePathParts;
|
|
20868
20923
|
})(ts || (ts = {}));
|
|
20869
20924
|
/* @internal */
|
|
20870
20925
|
var ts;
|
|
@@ -34515,20 +34570,30 @@ var ts;
|
|
|
34515
34570
|
expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken);
|
|
34516
34571
|
continue;
|
|
34517
34572
|
}
|
|
34518
|
-
if (!questionDotToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) {
|
|
34519
|
-
nextToken();
|
|
34520
|
-
expression = finishNode(factory.createNonNullExpression(expression), pos);
|
|
34521
|
-
continue;
|
|
34522
|
-
}
|
|
34523
34573
|
// when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName
|
|
34524
34574
|
if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) {
|
|
34525
34575
|
expression = parseElementAccessExpressionRest(pos, expression, questionDotToken);
|
|
34526
34576
|
continue;
|
|
34527
34577
|
}
|
|
34528
34578
|
if (isTemplateStartOfTaggedTemplate()) {
|
|
34529
|
-
|
|
34579
|
+
// Absorb type arguments into TemplateExpression when preceding expression is ExpressionWithTypeArguments
|
|
34580
|
+
expression = !questionDotToken && expression.kind === 227 /* ExpressionWithTypeArguments */ ?
|
|
34581
|
+
parseTaggedTemplateRest(pos, expression.expression, questionDotToken, expression.typeArguments) :
|
|
34582
|
+
parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined);
|
|
34530
34583
|
continue;
|
|
34531
34584
|
}
|
|
34585
|
+
if (!questionDotToken) {
|
|
34586
|
+
if (token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) {
|
|
34587
|
+
nextToken();
|
|
34588
|
+
expression = finishNode(factory.createNonNullExpression(expression), pos);
|
|
34589
|
+
continue;
|
|
34590
|
+
}
|
|
34591
|
+
var typeArguments = tryParse(parseTypeArgumentsInExpression);
|
|
34592
|
+
if (typeArguments) {
|
|
34593
|
+
expression = finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
|
|
34594
|
+
continue;
|
|
34595
|
+
}
|
|
34596
|
+
}
|
|
34532
34597
|
return expression;
|
|
34533
34598
|
}
|
|
34534
34599
|
}
|
|
@@ -34548,42 +34613,30 @@ var ts;
|
|
|
34548
34613
|
function parseCallExpressionRest(pos, expression) {
|
|
34549
34614
|
while (true) {
|
|
34550
34615
|
expression = parseMemberExpressionRest(pos, expression, /*allowOptionalChain*/ true);
|
|
34616
|
+
var typeArguments = void 0;
|
|
34551
34617
|
var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */);
|
|
34552
|
-
|
|
34553
|
-
|
|
34554
|
-
|
|
34555
|
-
|
|
34556
|
-
|
|
34557
|
-
// part of an arithmetic expression. Break out so we consume it higher in the
|
|
34558
|
-
// stack.
|
|
34559
|
-
var typeArguments = tryParse(parseTypeArgumentsInExpression);
|
|
34560
|
-
if (typeArguments) {
|
|
34561
|
-
if (isTemplateStartOfTaggedTemplate()) {
|
|
34562
|
-
expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
|
|
34563
|
-
continue;
|
|
34564
|
-
}
|
|
34565
|
-
if (questionDotToken || token() === 20 /* OpenParenToken */) {
|
|
34566
|
-
var argumentList = parseArgumentList();
|
|
34567
|
-
var callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
|
|
34568
|
-
factory.createCallChain(expression, questionDotToken, typeArguments, argumentList) :
|
|
34569
|
-
factory.createCallExpression(expression, typeArguments, argumentList);
|
|
34570
|
-
expression = finishNode(callExpr, pos);
|
|
34571
|
-
continue;
|
|
34572
|
-
}
|
|
34573
|
-
expression = finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
|
|
34574
|
-
break;
|
|
34618
|
+
if (questionDotToken) {
|
|
34619
|
+
typeArguments = tryParse(parseTypeArgumentsInExpression);
|
|
34620
|
+
if (isTemplateStartOfTaggedTemplate()) {
|
|
34621
|
+
expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
|
|
34622
|
+
continue;
|
|
34575
34623
|
}
|
|
34576
34624
|
}
|
|
34577
|
-
|
|
34625
|
+
if (typeArguments || token() === 20 /* OpenParenToken */) {
|
|
34626
|
+
// Absorb type arguments into CallExpression when preceding expression is ExpressionWithTypeArguments
|
|
34627
|
+
if (!questionDotToken && expression.kind === 227 /* ExpressionWithTypeArguments */) {
|
|
34628
|
+
typeArguments = expression.typeArguments;
|
|
34629
|
+
expression = expression.expression;
|
|
34630
|
+
}
|
|
34578
34631
|
var argumentList = parseArgumentList();
|
|
34579
34632
|
var callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
|
|
34580
|
-
factory.createCallChain(expression, questionDotToken,
|
|
34581
|
-
factory.createCallExpression(expression,
|
|
34633
|
+
factory.createCallChain(expression, questionDotToken, typeArguments, argumentList) :
|
|
34634
|
+
factory.createCallExpression(expression, typeArguments, argumentList);
|
|
34582
34635
|
expression = finishNode(callExpr, pos);
|
|
34583
34636
|
continue;
|
|
34584
34637
|
}
|
|
34585
34638
|
if (questionDotToken) {
|
|
34586
|
-
// We failed to parse anything, so report a missing identifier here.
|
|
34639
|
+
// We parsed `?.` but then failed to parse anything, so report a missing identifier here.
|
|
34587
34640
|
var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected);
|
|
34588
34641
|
expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos);
|
|
34589
34642
|
}
|
|
@@ -34629,6 +34682,7 @@ var ts;
|
|
|
34629
34682
|
// falls through
|
|
34630
34683
|
case 27 /* CommaToken */: // foo<x>,
|
|
34631
34684
|
case 24 /* DotToken */: // foo<x>.
|
|
34685
|
+
case 28 /* QuestionDotToken */: // foo<x>?.
|
|
34632
34686
|
case 21 /* CloseParenToken */: // foo<x>)
|
|
34633
34687
|
case 23 /* CloseBracketToken */: // foo<x>]
|
|
34634
34688
|
case 58 /* ColonToken */: // foo<x>:
|
|
@@ -34831,20 +34885,14 @@ var ts;
|
|
|
34831
34885
|
}
|
|
34832
34886
|
var expressionPos = getNodePos();
|
|
34833
34887
|
var expression = parseMemberExpressionRest(expressionPos, parsePrimaryExpression(), /*allowOptionalChain*/ false);
|
|
34834
|
-
var typeArguments
|
|
34835
|
-
|
|
34836
|
-
|
|
34837
|
-
|
|
34838
|
-
|
|
34839
|
-
}
|
|
34840
|
-
var argumentsArray;
|
|
34841
|
-
if (token() === 20 /* OpenParenToken */) {
|
|
34842
|
-
argumentsArray = parseArgumentList();
|
|
34843
|
-
}
|
|
34844
|
-
else if (typeArguments) {
|
|
34845
|
-
parseErrorAt(pos, scanner.getStartPos(), ts.Diagnostics.A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list);
|
|
34888
|
+
var typeArguments;
|
|
34889
|
+
// Absorb type arguments into NewExpression when preceding expression is ExpressionWithTypeArguments
|
|
34890
|
+
if (expression.kind === 227 /* ExpressionWithTypeArguments */) {
|
|
34891
|
+
typeArguments = expression.typeArguments;
|
|
34892
|
+
expression = expression.expression;
|
|
34846
34893
|
}
|
|
34847
|
-
|
|
34894
|
+
var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined;
|
|
34895
|
+
return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos);
|
|
34848
34896
|
}
|
|
34849
34897
|
// STATEMENTS
|
|
34850
34898
|
function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) {
|
|
@@ -46803,8 +46851,8 @@ var ts;
|
|
|
46803
46851
|
TypeFacts[TypeFacts["AllTypeofNE"] = 556800] = "AllTypeofNE";
|
|
46804
46852
|
TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts";
|
|
46805
46853
|
// Masks
|
|
46806
|
-
TypeFacts[TypeFacts["OrFactsMask"] =
|
|
46807
|
-
TypeFacts[TypeFacts["AndFactsMask"] =
|
|
46854
|
+
TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
|
|
46855
|
+
TypeFacts[TypeFacts["AndFactsMask"] = 16768959] = "AndFactsMask";
|
|
46808
46856
|
})(TypeFacts || (TypeFacts = {}));
|
|
46809
46857
|
var typeofEQFacts = new ts.Map(ts.getEntries({
|
|
46810
46858
|
string: 1 /* TypeofEQString */,
|
|
@@ -48759,24 +48807,19 @@ var ts;
|
|
|
48759
48807
|
error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
|
|
48760
48808
|
}
|
|
48761
48809
|
}
|
|
48762
|
-
if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */) {
|
|
48763
|
-
|
|
48810
|
+
if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
|
|
48811
|
+
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
|
|
48812
|
+
if (typeOnlyDeclaration) {
|
|
48813
|
+
var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
|
|
48814
|
+
? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
|
|
48815
|
+
: ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
|
|
48816
|
+
var unescapedName = ts.unescapeLeadingUnderscores(name);
|
|
48817
|
+
addTypeOnlyDeclarationRelatedInfo(error(errorLocation, message, unescapedName), typeOnlyDeclaration, unescapedName);
|
|
48818
|
+
}
|
|
48764
48819
|
}
|
|
48765
48820
|
}
|
|
48766
48821
|
return result;
|
|
48767
48822
|
}
|
|
48768
|
-
function checkSymbolUsageInExpressionContext(symbol, name, useSite) {
|
|
48769
|
-
if (!ts.isValidTypeOnlyAliasUseSite(useSite)) {
|
|
48770
|
-
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
|
|
48771
|
-
if (typeOnlyDeclaration) {
|
|
48772
|
-
var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
|
|
48773
|
-
? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
|
|
48774
|
-
: ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
|
|
48775
|
-
var unescapedName = ts.unescapeLeadingUnderscores(name);
|
|
48776
|
-
addTypeOnlyDeclarationRelatedInfo(error(useSite, message, unescapedName), typeOnlyDeclaration, unescapedName);
|
|
48777
|
-
}
|
|
48778
|
-
}
|
|
48779
|
-
}
|
|
48780
48823
|
function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) {
|
|
48781
48824
|
if (!typeOnlyDeclaration)
|
|
48782
48825
|
return diagnostic;
|
|
@@ -67922,7 +67965,10 @@ var ts;
|
|
|
67922
67965
|
(type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ :
|
|
67923
67966
|
(type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
|
|
67924
67967
|
}
|
|
67925
|
-
if (flags & 524288 /* Object */
|
|
67968
|
+
if (flags & 524288 /* Object */) {
|
|
67969
|
+
if (ignoreObjects) {
|
|
67970
|
+
return 16768959 /* AndFactsMask */; // This is the identity element for computing type facts of intersection.
|
|
67971
|
+
}
|
|
67926
67972
|
return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ?
|
|
67927
67973
|
strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ :
|
|
67928
67974
|
isFunctionObjectType(type) ?
|
|
@@ -67970,7 +68016,7 @@ var ts;
|
|
|
67970
68016
|
oredFacts |= f;
|
|
67971
68017
|
andedFacts &= f;
|
|
67972
68018
|
}
|
|
67973
|
-
return oredFacts &
|
|
68019
|
+
return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 16768959 /* AndFactsMask */;
|
|
67974
68020
|
}
|
|
67975
68021
|
function getTypeWithFacts(type, include) {
|
|
67976
68022
|
return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
|
|
@@ -69930,6 +69976,9 @@ var ts;
|
|
|
69930
69976
|
return getTypeOfSymbol(symbol);
|
|
69931
69977
|
}
|
|
69932
69978
|
function checkIdentifier(node, checkMode) {
|
|
69979
|
+
if (ts.isThisInTypeQuery(node)) {
|
|
69980
|
+
return checkThisExpression(node);
|
|
69981
|
+
}
|
|
69933
69982
|
var symbol = getResolvedSymbol(node);
|
|
69934
69983
|
if (symbol === unknownSymbol) {
|
|
69935
69984
|
return errorType;
|
|
@@ -71721,7 +71770,8 @@ var ts;
|
|
|
71721
71770
|
var links = getNodeLinks(node.expression);
|
|
71722
71771
|
if (!links.resolvedType) {
|
|
71723
71772
|
if ((ts.isTypeLiteralNode(node.parent.parent) || ts.isClassLike(node.parent.parent) || ts.isInterfaceDeclaration(node.parent.parent))
|
|
71724
|
-
&& 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 */) {
|
|
71725
71775
|
return links.resolvedType = errorType;
|
|
71726
71776
|
}
|
|
71727
71777
|
links.resolvedType = checkExpression(node.expression);
|
|
@@ -72890,23 +72940,6 @@ var ts;
|
|
|
72890
72940
|
if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) {
|
|
72891
72941
|
grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right));
|
|
72892
72942
|
}
|
|
72893
|
-
if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && !useDefineForClassFields)) {
|
|
72894
|
-
var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration);
|
|
72895
|
-
var parentStaticFieldInitializer = ts.findAncestor(node, function (n) {
|
|
72896
|
-
if (n === lexicalClass_1)
|
|
72897
|
-
return "quit";
|
|
72898
|
-
if (ts.isPropertyDeclaration(n.parent) && ts.hasStaticModifier(n.parent) && n.parent.initializer === n && n.parent.parent === lexicalClass_1) {
|
|
72899
|
-
return true;
|
|
72900
|
-
}
|
|
72901
|
-
return false;
|
|
72902
|
-
});
|
|
72903
|
-
if (parentStaticFieldInitializer) {
|
|
72904
|
-
var parentStaticFieldInitializerSymbol = getSymbolOfNode(parentStaticFieldInitializer.parent);
|
|
72905
|
-
ts.Debug.assert(parentStaticFieldInitializerSymbol, "Initializer without declaration symbol");
|
|
72906
|
-
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));
|
|
72907
|
-
ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(parentStaticFieldInitializer.parent, ts.Diagnostics.Initializer_for_property_0, ts.symbolName(parentStaticFieldInitializerSymbol)));
|
|
72908
|
-
}
|
|
72909
|
-
}
|
|
72910
72943
|
if (isAnyLike) {
|
|
72911
72944
|
if (lexicallyScopedSymbol) {
|
|
72912
72945
|
return isErrorType(apparentType) ? errorType : apparentType;
|
|
@@ -75597,51 +75630,57 @@ var ts;
|
|
|
75597
75630
|
ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) :
|
|
75598
75631
|
checkExpression(node.exprName);
|
|
75599
75632
|
var typeArguments = node.typeArguments;
|
|
75600
|
-
if (!ts.some(typeArguments)) {
|
|
75633
|
+
if (exprType === silentNeverType || isErrorType(exprType) || !ts.some(typeArguments)) {
|
|
75601
75634
|
return exprType;
|
|
75602
75635
|
}
|
|
75603
|
-
var funcType = getApparentType(exprType);
|
|
75604
|
-
if (funcType === silentNeverType || isErrorType(funcType)) {
|
|
75605
|
-
return funcType;
|
|
75606
|
-
}
|
|
75607
75636
|
var hasSomeApplicableSignature = false;
|
|
75608
75637
|
var nonApplicableType;
|
|
75609
|
-
var
|
|
75610
|
-
var
|
|
75611
|
-
var result = mapType(funcType, getInstantiatedType);
|
|
75612
|
-
var errorType = hasSomeApplicableSignature ? nonApplicableType : funcType;
|
|
75638
|
+
var result = getInstantiatedType(exprType);
|
|
75639
|
+
var errorType = hasSomeApplicableSignature ? nonApplicableType : exprType;
|
|
75613
75640
|
if (errorType) {
|
|
75614
75641
|
diagnostics.add(ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable, typeToString(errorType)));
|
|
75615
75642
|
}
|
|
75616
75643
|
return result;
|
|
75617
75644
|
function getInstantiatedType(type) {
|
|
75618
|
-
hasSignatures = false;
|
|
75619
|
-
hasApplicableSignature = false;
|
|
75620
|
-
var result =
|
|
75645
|
+
var hasSignatures = false;
|
|
75646
|
+
var hasApplicableSignature = false;
|
|
75647
|
+
var result = getInstantiatedTypePart(type);
|
|
75621
75648
|
hasSomeApplicableSignature || (hasSomeApplicableSignature = hasApplicableSignature);
|
|
75622
75649
|
if (hasSignatures && !hasApplicableSignature) {
|
|
75623
75650
|
nonApplicableType !== null && nonApplicableType !== void 0 ? nonApplicableType : (nonApplicableType = type);
|
|
75624
75651
|
}
|
|
75625
75652
|
return result;
|
|
75626
|
-
|
|
75627
|
-
|
|
75628
|
-
|
|
75629
|
-
|
|
75630
|
-
|
|
75631
|
-
|
|
75632
|
-
|
|
75633
|
-
|
|
75634
|
-
|
|
75635
|
-
|
|
75636
|
-
|
|
75637
|
-
|
|
75638
|
-
|
|
75653
|
+
function getInstantiatedTypePart(type) {
|
|
75654
|
+
if (type.flags & 524288 /* Object */) {
|
|
75655
|
+
var resolved = resolveStructuredTypeMembers(type);
|
|
75656
|
+
var callSignatures = getInstantiatedSignatures(resolved.callSignatures);
|
|
75657
|
+
var constructSignatures = getInstantiatedSignatures(resolved.constructSignatures);
|
|
75658
|
+
hasSignatures || (hasSignatures = resolved.callSignatures.length !== 0 || resolved.constructSignatures.length !== 0);
|
|
75659
|
+
hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0);
|
|
75660
|
+
if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) {
|
|
75661
|
+
var result_11 = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos);
|
|
75662
|
+
result_11.objectFlags |= 16777216 /* InstantiationExpressionType */;
|
|
75663
|
+
result_11.node = node;
|
|
75664
|
+
return result_11;
|
|
75665
|
+
}
|
|
75666
|
+
}
|
|
75667
|
+
else if (type.flags & 58982400 /* InstantiableNonPrimitive */) {
|
|
75668
|
+
var constraint = getBaseConstraintOfType(type);
|
|
75669
|
+
if (constraint) {
|
|
75670
|
+
var instantiated = getInstantiatedTypePart(constraint);
|
|
75671
|
+
if (instantiated !== constraint) {
|
|
75672
|
+
return instantiated;
|
|
75673
|
+
}
|
|
75674
|
+
}
|
|
75639
75675
|
}
|
|
75676
|
+
else if (type.flags & 1048576 /* Union */) {
|
|
75677
|
+
return mapType(type, getInstantiatedType);
|
|
75678
|
+
}
|
|
75679
|
+
else if (type.flags & 2097152 /* Intersection */) {
|
|
75680
|
+
return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypePart));
|
|
75681
|
+
}
|
|
75682
|
+
return type;
|
|
75640
75683
|
}
|
|
75641
|
-
else if (type.flags & 2097152 /* Intersection */) {
|
|
75642
|
-
return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypeWorker));
|
|
75643
|
-
}
|
|
75644
|
-
return type;
|
|
75645
75684
|
}
|
|
75646
75685
|
function getInstantiatedSignatures(signatures) {
|
|
75647
75686
|
var applicableSignatures = ts.filter(signatures, function (sig) { return !!sig.typeParameters && hasCorrectTypeArgumentArity(sig, typeArguments); });
|
|
@@ -75729,6 +75768,10 @@ var ts;
|
|
|
75729
75768
|
return restParameter.escapedName;
|
|
75730
75769
|
}
|
|
75731
75770
|
function getParameterIdentifierNameAtPosition(signature, pos) {
|
|
75771
|
+
var _a;
|
|
75772
|
+
if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 315 /* JSDocFunctionType */) {
|
|
75773
|
+
return undefined;
|
|
75774
|
+
}
|
|
75732
75775
|
var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
|
|
75733
75776
|
if (pos < paramCount) {
|
|
75734
75777
|
var param = signature.parameters[pos];
|
|
@@ -78600,9 +78643,6 @@ var ts;
|
|
|
78600
78643
|
checkGrammarComputedPropertyName(node.name);
|
|
78601
78644
|
checkVariableLikeDeclaration(node);
|
|
78602
78645
|
setNodeLinksForPrivateIdentifierScope(node);
|
|
78603
|
-
if (ts.isPrivateIdentifier(node.name) && ts.hasStaticModifier(node) && node.initializer && languageVersion === 99 /* ESNext */ && !compilerOptions.useDefineForClassFields) {
|
|
78604
|
-
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);
|
|
78605
|
-
}
|
|
78606
78646
|
// property signatures already report "initializer not allowed in ambient context" elsewhere
|
|
78607
78647
|
if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 166 /* PropertyDeclaration */ && node.initializer) {
|
|
78608
78648
|
error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name));
|
|
@@ -84495,7 +84535,10 @@ var ts;
|
|
|
84495
84535
|
case 80 /* PrivateIdentifier */:
|
|
84496
84536
|
case 205 /* PropertyAccessExpression */:
|
|
84497
84537
|
case 160 /* QualifiedName */:
|
|
84498
|
-
|
|
84538
|
+
if (!ts.isThisInTypeQuery(node)) {
|
|
84539
|
+
return getSymbolOfNameOrPropertyAccessExpression(node);
|
|
84540
|
+
}
|
|
84541
|
+
// falls through
|
|
84499
84542
|
case 108 /* ThisKeyword */:
|
|
84500
84543
|
var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false);
|
|
84501
84544
|
if (ts.isFunctionLike(container)) {
|
|
@@ -85740,7 +85783,7 @@ var ts;
|
|
|
85740
85783
|
if (quickResult !== undefined) {
|
|
85741
85784
|
return quickResult;
|
|
85742
85785
|
}
|
|
85743
|
-
var lastStatic, lastDeclare, lastAsync,
|
|
85786
|
+
var lastStatic, lastDeclare, lastAsync, lastOverride;
|
|
85744
85787
|
var flags = 0 /* None */;
|
|
85745
85788
|
for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
|
|
85746
85789
|
var modifier = _a[_i];
|
|
@@ -85844,7 +85887,6 @@ var ts;
|
|
|
85844
85887
|
return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature);
|
|
85845
85888
|
}
|
|
85846
85889
|
flags |= 64 /* Readonly */;
|
|
85847
|
-
lastReadonly = modifier;
|
|
85848
85890
|
break;
|
|
85849
85891
|
case 93 /* ExportKeyword */:
|
|
85850
85892
|
if (flags & 1 /* Export */) {
|
|
@@ -85957,18 +85999,12 @@ var ts;
|
|
|
85957
85999
|
if (flags & 32 /* Static */) {
|
|
85958
86000
|
return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static");
|
|
85959
86001
|
}
|
|
85960
|
-
if (flags & 128 /* Abstract */) {
|
|
85961
|
-
return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); // TODO: GH#18217
|
|
85962
|
-
}
|
|
85963
86002
|
if (flags & 16384 /* Override */) {
|
|
85964
86003
|
return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217
|
|
85965
86004
|
}
|
|
85966
|
-
|
|
86005
|
+
if (flags & 256 /* Async */) {
|
|
85967
86006
|
return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async");
|
|
85968
86007
|
}
|
|
85969
|
-
else if (flags & 64 /* Readonly */) {
|
|
85970
|
-
return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly");
|
|
85971
|
-
}
|
|
85972
86008
|
return false;
|
|
85973
86009
|
}
|
|
85974
86010
|
else if ((node.kind === 265 /* ImportDeclaration */ || node.kind === 264 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) {
|
|
@@ -92296,10 +92332,12 @@ var ts;
|
|
|
92296
92332
|
var languageVersion = ts.getEmitScriptTarget(compilerOptions);
|
|
92297
92333
|
var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions);
|
|
92298
92334
|
var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ES2022 */;
|
|
92335
|
+
// We need to transform `this` in a static initializer into a reference to the class
|
|
92336
|
+
// when targeting < ES2022 since the assignment will be moved outside of the class body.
|
|
92337
|
+
var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ES2022 */;
|
|
92299
92338
|
// We don't need to transform `super` property access when targeting ES5, ES3 because
|
|
92300
92339
|
// the es2015 transformation handles those.
|
|
92301
|
-
var shouldTransformSuperInStaticInitializers =
|
|
92302
|
-
var shouldTransformThisInStaticInitializers = languageVersion <= 8 /* ES2021 */ || !useDefineForClassFields;
|
|
92340
|
+
var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */;
|
|
92303
92341
|
var previousOnSubstituteNode = context.onSubstituteNode;
|
|
92304
92342
|
context.onSubstituteNode = onSubstituteNode;
|
|
92305
92343
|
var previousOnEmitNode = context.onEmitNode;
|
|
@@ -92528,6 +92566,10 @@ var ts;
|
|
|
92528
92566
|
ts.Debug.assert(!ts.some(node.decorators));
|
|
92529
92567
|
if (ts.isPrivateIdentifier(node.name)) {
|
|
92530
92568
|
if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
|
|
92569
|
+
if (ts.isStatic(node)) {
|
|
92570
|
+
// static fields are left as is
|
|
92571
|
+
return ts.visitEachChild(node, visitor, context);
|
|
92572
|
+
}
|
|
92531
92573
|
// Initializer is elided as the field is initialized in transformConstructor.
|
|
92532
92574
|
return factory.updatePropertyDeclaration(node,
|
|
92533
92575
|
/*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name,
|
|
@@ -92549,6 +92591,22 @@ var ts;
|
|
|
92549
92591
|
if (expr && !ts.isSimpleInlineableExpression(expr)) {
|
|
92550
92592
|
getPendingExpressions().push(expr);
|
|
92551
92593
|
}
|
|
92594
|
+
if (ts.isStatic(node) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
|
|
92595
|
+
var initializerStatement = transformPropertyOrClassStaticBlock(node, factory.createThis());
|
|
92596
|
+
if (initializerStatement) {
|
|
92597
|
+
var staticBlock = factory.createClassStaticBlockDeclaration(
|
|
92598
|
+
/*decorators*/ undefined,
|
|
92599
|
+
/*modifiers*/ undefined, factory.createBlock([initializerStatement]));
|
|
92600
|
+
ts.setOriginalNode(staticBlock, node);
|
|
92601
|
+
ts.setCommentRange(staticBlock, node);
|
|
92602
|
+
// Set the comment range for the statement to an empty synthetic range
|
|
92603
|
+
// and drop synthetic comments from the statement to avoid printing them twice.
|
|
92604
|
+
ts.setCommentRange(initializerStatement, { pos: -1, end: -1 });
|
|
92605
|
+
ts.setSyntheticLeadingComments(initializerStatement, undefined);
|
|
92606
|
+
ts.setSyntheticTrailingComments(initializerStatement, undefined);
|
|
92607
|
+
return staticBlock;
|
|
92608
|
+
}
|
|
92609
|
+
}
|
|
92552
92610
|
return undefined;
|
|
92553
92611
|
}
|
|
92554
92612
|
function createPrivateIdentifierAccess(info, receiver) {
|
|
@@ -92936,7 +92994,6 @@ var ts;
|
|
|
92936
92994
|
if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) {
|
|
92937
92995
|
enableSubstitutionForClassStaticThisOrSuperReference();
|
|
92938
92996
|
}
|
|
92939
|
-
var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
|
|
92940
92997
|
// If a class has private static fields, or a static field has a `this` or `super` reference,
|
|
92941
92998
|
// then we need to allocate a temp variable to hold on to that reference.
|
|
92942
92999
|
var pendingClassReferenceAssignment;
|
|
@@ -92964,6 +93021,7 @@ var ts;
|
|
|
92964
93021
|
// From ES6 specification:
|
|
92965
93022
|
// HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using
|
|
92966
93023
|
// a lexical declaration such as a LexicalDeclaration or a ClassDeclaration.
|
|
93024
|
+
var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
|
|
92967
93025
|
if (ts.some(staticProperties)) {
|
|
92968
93026
|
addPropertyOrClassStaticBlockStatements(statements, staticProperties, factory.getInternalName(node));
|
|
92969
93027
|
}
|
|
@@ -93002,7 +93060,7 @@ var ts;
|
|
|
93002
93060
|
}
|
|
93003
93061
|
var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), node.modifiers, node.name,
|
|
93004
93062
|
/*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, heritageClauseVisitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass));
|
|
93005
|
-
var hasTransformableStatics = ts.some(staticPropertiesOrClassStaticBlocks, function (p) { return ts.isClassStaticBlockDeclaration(p) || !!p.initializer ||
|
|
93063
|
+
var hasTransformableStatics = shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(staticPropertiesOrClassStaticBlocks, function (p) { return ts.isClassStaticBlockDeclaration(p) || !!p.initializer || ts.isPrivateIdentifier(p.name); });
|
|
93006
93064
|
if (hasTransformableStatics || ts.some(pendingExpressions)) {
|
|
93007
93065
|
if (isDecoratedClassDeclaration) {
|
|
93008
93066
|
ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration.");
|
|
@@ -93049,6 +93107,7 @@ var ts;
|
|
|
93049
93107
|
return undefined;
|
|
93050
93108
|
}
|
|
93051
93109
|
function transformClassMembers(node, isDerivedClass) {
|
|
93110
|
+
var members = [];
|
|
93052
93111
|
if (shouldTransformPrivateElementsOrClassStaticBlocks) {
|
|
93053
93112
|
// Declare private names.
|
|
93054
93113
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
@@ -93061,12 +93120,20 @@ var ts;
|
|
|
93061
93120
|
createBrandCheckWeakSetForPrivateMethods();
|
|
93062
93121
|
}
|
|
93063
93122
|
}
|
|
93064
|
-
var members = [];
|
|
93065
93123
|
var constructor = transformConstructor(node, isDerivedClass);
|
|
93124
|
+
var visitedMembers = ts.visitNodes(node.members, classElementVisitor, ts.isClassElement);
|
|
93066
93125
|
if (constructor) {
|
|
93067
93126
|
members.push(constructor);
|
|
93068
93127
|
}
|
|
93069
|
-
|
|
93128
|
+
if (!shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(pendingExpressions)) {
|
|
93129
|
+
members.push(factory.createClassStaticBlockDeclaration(
|
|
93130
|
+
/*decorators*/ undefined,
|
|
93131
|
+
/*modifiers*/ undefined, factory.createBlock([
|
|
93132
|
+
factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))
|
|
93133
|
+
])));
|
|
93134
|
+
pendingExpressions = undefined;
|
|
93135
|
+
}
|
|
93136
|
+
ts.addRange(members, visitedMembers);
|
|
93070
93137
|
return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members);
|
|
93071
93138
|
}
|
|
93072
93139
|
function createBrandCheckWeakSetForPrivateMethods() {
|
|
@@ -93209,24 +93276,34 @@ var ts;
|
|
|
93209
93276
|
function addPropertyOrClassStaticBlockStatements(statements, properties, receiver) {
|
|
93210
93277
|
for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
|
|
93211
93278
|
var property = properties_7[_i];
|
|
93212
|
-
|
|
93213
|
-
|
|
93214
|
-
|
|
93215
|
-
|
|
93279
|
+
if (ts.isStatic(property) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
|
|
93280
|
+
continue;
|
|
93281
|
+
}
|
|
93282
|
+
var statement = transformPropertyOrClassStaticBlock(property, receiver);
|
|
93283
|
+
if (!statement) {
|
|
93216
93284
|
continue;
|
|
93217
93285
|
}
|
|
93218
|
-
var statement = factory.createExpressionStatement(expression);
|
|
93219
|
-
ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
|
|
93220
|
-
ts.setCommentRange(statement, property);
|
|
93221
|
-
ts.setOriginalNode(statement, property);
|
|
93222
|
-
// `setOriginalNode` *copies* the `emitNode` from `property`, so now both
|
|
93223
|
-
// `statement` and `expression` have a copy of the synthesized comments.
|
|
93224
|
-
// Drop the comments from expression to avoid printing them twice.
|
|
93225
|
-
ts.setSyntheticLeadingComments(expression, undefined);
|
|
93226
|
-
ts.setSyntheticTrailingComments(expression, undefined);
|
|
93227
93286
|
statements.push(statement);
|
|
93228
93287
|
}
|
|
93229
93288
|
}
|
|
93289
|
+
function transformPropertyOrClassStaticBlock(property, receiver) {
|
|
93290
|
+
var expression = ts.isClassStaticBlockDeclaration(property) ?
|
|
93291
|
+
transformClassStaticBlockDeclaration(property) :
|
|
93292
|
+
transformProperty(property, receiver);
|
|
93293
|
+
if (!expression) {
|
|
93294
|
+
return undefined;
|
|
93295
|
+
}
|
|
93296
|
+
var statement = factory.createExpressionStatement(expression);
|
|
93297
|
+
ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
|
|
93298
|
+
ts.setCommentRange(statement, property);
|
|
93299
|
+
ts.setOriginalNode(statement, property);
|
|
93300
|
+
// `setOriginalNode` *copies* the `emitNode` from `property`, so now both
|
|
93301
|
+
// `statement` and `expression` have a copy of the synthesized comments.
|
|
93302
|
+
// Drop the comments from expression to avoid printing them twice.
|
|
93303
|
+
ts.setSyntheticLeadingComments(expression, undefined);
|
|
93304
|
+
ts.setSyntheticTrailingComments(expression, undefined);
|
|
93305
|
+
return statement;
|
|
93306
|
+
}
|
|
93230
93307
|
/**
|
|
93231
93308
|
* Generates assignment expressions for property initializers.
|
|
93232
93309
|
*
|
|
@@ -94476,6 +94553,7 @@ var ts;
|
|
|
94476
94553
|
var exportedVariableStatement = false;
|
|
94477
94554
|
var enabledSubstitutions;
|
|
94478
94555
|
var enclosingFunctionFlags;
|
|
94556
|
+
var parametersWithPrecedingObjectRestOrSpread;
|
|
94479
94557
|
var enclosingSuperContainerFlags = 0;
|
|
94480
94558
|
var hierarchyFacts = 0;
|
|
94481
94559
|
var currentSourceFile;
|
|
@@ -94932,6 +95010,7 @@ var ts;
|
|
|
94932
95010
|
/*incrementor*/ undefined,
|
|
94933
95011
|
/*statement*/ convertForOfStatementHead(node, getValue)),
|
|
94934
95012
|
/*location*/ node), 256 /* NoTokenTrailingSourceMaps */);
|
|
95013
|
+
ts.setOriginalNode(forStatement, node);
|
|
94935
95014
|
return factory.createTryStatement(factory.createBlock([
|
|
94936
95015
|
factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement)
|
|
94937
95016
|
]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([
|
|
@@ -94949,7 +95028,19 @@ var ts;
|
|
|
94949
95028
|
]), 1 /* SingleLine */))
|
|
94950
95029
|
]));
|
|
94951
95030
|
}
|
|
95031
|
+
function parameterVisitor(node) {
|
|
95032
|
+
ts.Debug.assertNode(node, ts.isParameter);
|
|
95033
|
+
return visitParameter(node);
|
|
95034
|
+
}
|
|
94952
95035
|
function visitParameter(node) {
|
|
95036
|
+
if (parametersWithPrecedingObjectRestOrSpread === null || parametersWithPrecedingObjectRestOrSpread === void 0 ? void 0 : parametersWithPrecedingObjectRestOrSpread.has(node)) {
|
|
95037
|
+
return factory.updateParameterDeclaration(node,
|
|
95038
|
+
/*decorators*/ undefined,
|
|
95039
|
+
/*modifiers*/ undefined, node.dotDotDotToken, ts.isBindingPattern(node.name) ? factory.getGeneratedNameForNode(node) : node.name,
|
|
95040
|
+
/*questionToken*/ undefined,
|
|
95041
|
+
/*type*/ undefined,
|
|
95042
|
+
/*initializer*/ undefined);
|
|
95043
|
+
}
|
|
94953
95044
|
if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
|
|
94954
95045
|
// Binding patterns are converted into a generated name and are
|
|
94955
95046
|
// evaluated inside the function body.
|
|
@@ -94961,85 +95052,119 @@ var ts;
|
|
|
94961
95052
|
}
|
|
94962
95053
|
return ts.visitEachChild(node, visitor, context);
|
|
94963
95054
|
}
|
|
95055
|
+
function collectParametersWithPrecedingObjectRestOrSpread(node) {
|
|
95056
|
+
var parameters;
|
|
95057
|
+
for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
|
|
95058
|
+
var parameter = _a[_i];
|
|
95059
|
+
if (parameters) {
|
|
95060
|
+
parameters.add(parameter);
|
|
95061
|
+
}
|
|
95062
|
+
else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
|
|
95063
|
+
parameters = new ts.Set();
|
|
95064
|
+
}
|
|
95065
|
+
}
|
|
95066
|
+
return parameters;
|
|
95067
|
+
}
|
|
94964
95068
|
function visitConstructorDeclaration(node) {
|
|
94965
95069
|
var savedEnclosingFunctionFlags = enclosingFunctionFlags;
|
|
94966
|
-
|
|
95070
|
+
var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
|
|
95071
|
+
enclosingFunctionFlags = ts.getFunctionFlags(node);
|
|
95072
|
+
parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
|
|
94967
95073
|
var updated = factory.updateConstructorDeclaration(node,
|
|
94968
|
-
/*decorators*/ undefined, node.modifiers, ts.visitParameterList(node.parameters,
|
|
95074
|
+
/*decorators*/ undefined, node.modifiers, ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node));
|
|
94969
95075
|
enclosingFunctionFlags = savedEnclosingFunctionFlags;
|
|
95076
|
+
parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
|
|
94970
95077
|
return updated;
|
|
94971
95078
|
}
|
|
94972
95079
|
function visitGetAccessorDeclaration(node) {
|
|
94973
95080
|
var savedEnclosingFunctionFlags = enclosingFunctionFlags;
|
|
94974
|
-
|
|
95081
|
+
var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
|
|
95082
|
+
enclosingFunctionFlags = ts.getFunctionFlags(node);
|
|
95083
|
+
parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
|
|
94975
95084
|
var updated = factory.updateGetAccessorDeclaration(node,
|
|
94976
|
-
/*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters,
|
|
95085
|
+
/*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context),
|
|
94977
95086
|
/*type*/ undefined, transformFunctionBody(node));
|
|
94978
95087
|
enclosingFunctionFlags = savedEnclosingFunctionFlags;
|
|
95088
|
+
parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
|
|
94979
95089
|
return updated;
|
|
94980
95090
|
}
|
|
94981
95091
|
function visitSetAccessorDeclaration(node) {
|
|
94982
95092
|
var savedEnclosingFunctionFlags = enclosingFunctionFlags;
|
|
94983
|
-
|
|
95093
|
+
var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
|
|
95094
|
+
enclosingFunctionFlags = ts.getFunctionFlags(node);
|
|
95095
|
+
parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
|
|
94984
95096
|
var updated = factory.updateSetAccessorDeclaration(node,
|
|
94985
|
-
/*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters,
|
|
95097
|
+
/*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node));
|
|
94986
95098
|
enclosingFunctionFlags = savedEnclosingFunctionFlags;
|
|
95099
|
+
parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
|
|
94987
95100
|
return updated;
|
|
94988
95101
|
}
|
|
94989
95102
|
function visitMethodDeclaration(node) {
|
|
94990
95103
|
var savedEnclosingFunctionFlags = enclosingFunctionFlags;
|
|
95104
|
+
var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
|
|
94991
95105
|
enclosingFunctionFlags = ts.getFunctionFlags(node);
|
|
95106
|
+
parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
|
|
94992
95107
|
var updated = factory.updateMethodDeclaration(node,
|
|
94993
95108
|
/*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */
|
|
94994
95109
|
? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
|
|
94995
95110
|
: node.modifiers, enclosingFunctionFlags & 2 /* Async */
|
|
94996
95111
|
? undefined
|
|
94997
95112
|
: node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(/*questionToken*/ undefined, visitor, ts.isToken),
|
|
94998
|
-
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters,
|
|
95113
|
+
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
|
|
94999
95114
|
/*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
|
|
95000
95115
|
? transformAsyncGeneratorFunctionBody(node)
|
|
95001
95116
|
: transformFunctionBody(node));
|
|
95002
95117
|
enclosingFunctionFlags = savedEnclosingFunctionFlags;
|
|
95118
|
+
parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
|
|
95003
95119
|
return updated;
|
|
95004
95120
|
}
|
|
95005
95121
|
function visitFunctionDeclaration(node) {
|
|
95006
95122
|
var savedEnclosingFunctionFlags = enclosingFunctionFlags;
|
|
95123
|
+
var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
|
|
95007
95124
|
enclosingFunctionFlags = ts.getFunctionFlags(node);
|
|
95125
|
+
parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
|
|
95008
95126
|
var updated = factory.updateFunctionDeclaration(node,
|
|
95009
95127
|
/*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */
|
|
95010
95128
|
? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
|
|
95011
95129
|
: node.modifiers, enclosingFunctionFlags & 2 /* Async */
|
|
95012
95130
|
? undefined
|
|
95013
95131
|
: node.asteriskToken, node.name,
|
|
95014
|
-
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters,
|
|
95132
|
+
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
|
|
95015
95133
|
/*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
|
|
95016
95134
|
? transformAsyncGeneratorFunctionBody(node)
|
|
95017
95135
|
: transformFunctionBody(node));
|
|
95018
95136
|
enclosingFunctionFlags = savedEnclosingFunctionFlags;
|
|
95137
|
+
parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
|
|
95019
95138
|
return updated;
|
|
95020
95139
|
}
|
|
95021
95140
|
function visitArrowFunction(node) {
|
|
95022
95141
|
var savedEnclosingFunctionFlags = enclosingFunctionFlags;
|
|
95142
|
+
var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
|
|
95023
95143
|
enclosingFunctionFlags = ts.getFunctionFlags(node);
|
|
95144
|
+
parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
|
|
95024
95145
|
var updated = factory.updateArrowFunction(node, node.modifiers,
|
|
95025
|
-
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters,
|
|
95146
|
+
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
|
|
95026
95147
|
/*type*/ undefined, node.equalsGreaterThanToken, transformFunctionBody(node));
|
|
95027
95148
|
enclosingFunctionFlags = savedEnclosingFunctionFlags;
|
|
95149
|
+
parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
|
|
95028
95150
|
return updated;
|
|
95029
95151
|
}
|
|
95030
95152
|
function visitFunctionExpression(node) {
|
|
95031
95153
|
var savedEnclosingFunctionFlags = enclosingFunctionFlags;
|
|
95154
|
+
var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
|
|
95032
95155
|
enclosingFunctionFlags = ts.getFunctionFlags(node);
|
|
95156
|
+
parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
|
|
95033
95157
|
var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */
|
|
95034
95158
|
? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
|
|
95035
95159
|
: node.modifiers, enclosingFunctionFlags & 2 /* Async */
|
|
95036
95160
|
? undefined
|
|
95037
95161
|
: node.asteriskToken, node.name,
|
|
95038
|
-
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters,
|
|
95162
|
+
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
|
|
95039
95163
|
/*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
|
|
95040
95164
|
? transformAsyncGeneratorFunctionBody(node)
|
|
95041
95165
|
: transformFunctionBody(node));
|
|
95042
95166
|
enclosingFunctionFlags = savedEnclosingFunctionFlags;
|
|
95167
|
+
parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
|
|
95043
95168
|
return updated;
|
|
95044
95169
|
}
|
|
95045
95170
|
function transformAsyncGeneratorFunctionBody(node) {
|
|
@@ -95100,16 +95225,71 @@ var ts;
|
|
|
95100
95225
|
return body;
|
|
95101
95226
|
}
|
|
95102
95227
|
function appendObjectRestAssignmentsIfNeeded(statements, node) {
|
|
95228
|
+
var containsPrecedingObjectRestOrSpread = false;
|
|
95103
95229
|
for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
|
|
95104
95230
|
var parameter = _a[_i];
|
|
95105
|
-
if (
|
|
95106
|
-
|
|
95107
|
-
|
|
95231
|
+
if (containsPrecedingObjectRestOrSpread) {
|
|
95232
|
+
if (ts.isBindingPattern(parameter.name)) {
|
|
95233
|
+
// In cases where a binding pattern is simply '[]' or '{}',
|
|
95234
|
+
// we usually don't want to emit a var declaration; however, in the presence
|
|
95235
|
+
// of an initializer, we must emit that expression to preserve side effects.
|
|
95236
|
+
//
|
|
95237
|
+
// NOTE: see `insertDefaultValueAssignmentForBindingPattern` in es2015.ts
|
|
95238
|
+
if (parameter.name.elements.length > 0) {
|
|
95239
|
+
var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter));
|
|
95240
|
+
if (ts.some(declarations)) {
|
|
95241
|
+
var declarationList = factory.createVariableDeclarationList(declarations);
|
|
95242
|
+
var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList);
|
|
95243
|
+
ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
|
|
95244
|
+
statements = ts.append(statements, statement);
|
|
95245
|
+
}
|
|
95246
|
+
}
|
|
95247
|
+
else if (parameter.initializer) {
|
|
95248
|
+
var name = factory.getGeneratedNameForNode(parameter);
|
|
95249
|
+
var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression);
|
|
95250
|
+
var assignment = factory.createAssignment(name, initializer);
|
|
95251
|
+
var statement = factory.createExpressionStatement(assignment);
|
|
95252
|
+
ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
|
|
95253
|
+
statements = ts.append(statements, statement);
|
|
95254
|
+
}
|
|
95255
|
+
}
|
|
95256
|
+
else if (parameter.initializer) {
|
|
95257
|
+
// Converts a parameter initializer into a function body statement, i.e.:
|
|
95258
|
+
//
|
|
95259
|
+
// function f(x = 1) { }
|
|
95260
|
+
//
|
|
95261
|
+
// becomes
|
|
95262
|
+
//
|
|
95263
|
+
// function f(x) {
|
|
95264
|
+
// if (typeof x === "undefined") { x = 1; }
|
|
95265
|
+
// }
|
|
95266
|
+
var name = factory.cloneNode(parameter.name);
|
|
95267
|
+
ts.setTextRange(name, parameter.name);
|
|
95268
|
+
ts.setEmitFlags(name, 48 /* NoSourceMap */);
|
|
95269
|
+
var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression);
|
|
95270
|
+
ts.addEmitFlags(initializer, 48 /* NoSourceMap */ | 1536 /* NoComments */);
|
|
95271
|
+
var assignment = factory.createAssignment(name, initializer);
|
|
95272
|
+
ts.setTextRange(assignment, parameter);
|
|
95273
|
+
ts.setEmitFlags(assignment, 1536 /* NoComments */);
|
|
95274
|
+
var block = factory.createBlock([factory.createExpressionStatement(assignment)]);
|
|
95275
|
+
ts.setTextRange(block, parameter);
|
|
95276
|
+
ts.setEmitFlags(block, 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */);
|
|
95277
|
+
var typeCheck = factory.createTypeCheck(factory.cloneNode(parameter.name), "undefined");
|
|
95278
|
+
var statement = factory.createIfStatement(typeCheck, block);
|
|
95279
|
+
ts.startOnNewLine(statement);
|
|
95280
|
+
ts.setTextRange(statement, parameter);
|
|
95281
|
+
ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */);
|
|
95282
|
+
statements = ts.append(statements, statement);
|
|
95283
|
+
}
|
|
95284
|
+
}
|
|
95285
|
+
else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
|
|
95286
|
+
containsPrecedingObjectRestOrSpread = true;
|
|
95287
|
+
var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter),
|
|
95108
95288
|
/*doNotRecordTempVariablesInLine*/ false,
|
|
95109
95289
|
/*skipInitializer*/ true);
|
|
95110
95290
|
if (ts.some(declarations)) {
|
|
95111
|
-
var
|
|
95112
|
-
/*modifiers*/ undefined,
|
|
95291
|
+
var declarationList = factory.createVariableDeclarationList(declarations);
|
|
95292
|
+
var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList);
|
|
95113
95293
|
ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
|
|
95114
95294
|
statements = ts.append(statements, statement);
|
|
95115
95295
|
}
|
|
@@ -98360,10 +98540,12 @@ var ts;
|
|
|
98360
98540
|
// variables declared in the loop initializer that will be changed inside the loop
|
|
98361
98541
|
var loopOutParameters = [];
|
|
98362
98542
|
if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) {
|
|
98363
|
-
var
|
|
98543
|
+
var hasCapturedBindingsInForHead = shouldConvertInitializerOfForStatement(node) ||
|
|
98544
|
+
shouldConvertConditionOfForStatement(node) ||
|
|
98545
|
+
shouldConvertIncrementorOfForStatement(node);
|
|
98364
98546
|
for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) {
|
|
98365
98547
|
var decl = _a[_i];
|
|
98366
|
-
processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters,
|
|
98548
|
+
processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForHead);
|
|
98367
98549
|
}
|
|
98368
98550
|
}
|
|
98369
98551
|
var currentState = { loopParameters: loopParameters, loopOutParameters: loopOutParameters };
|
|
@@ -98717,27 +98899,33 @@ var ts;
|
|
|
98717
98899
|
caseClauses.push(factory.createCaseClause(factory.createStringLiteral(labelMarker), statements));
|
|
98718
98900
|
});
|
|
98719
98901
|
}
|
|
98720
|
-
function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters,
|
|
98902
|
+
function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForHead) {
|
|
98721
98903
|
var name = decl.name;
|
|
98722
98904
|
if (ts.isBindingPattern(name)) {
|
|
98723
98905
|
for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
|
|
98724
98906
|
var element = _a[_i];
|
|
98725
98907
|
if (!ts.isOmittedExpression(element)) {
|
|
98726
|
-
processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters,
|
|
98908
|
+
processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForHead);
|
|
98727
98909
|
}
|
|
98728
98910
|
}
|
|
98729
98911
|
}
|
|
98730
98912
|
else {
|
|
98731
98913
|
loopParameters.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name));
|
|
98732
98914
|
var checkFlags = resolver.getNodeCheckFlags(decl);
|
|
98733
|
-
if (checkFlags & 4194304 /* NeedsLoopOutParameter */ ||
|
|
98915
|
+
if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) {
|
|
98734
98916
|
var outParamName = factory.createUniqueName("out_" + ts.idText(name));
|
|
98735
98917
|
var flags = 0;
|
|
98736
98918
|
if (checkFlags & 4194304 /* NeedsLoopOutParameter */) {
|
|
98737
98919
|
flags |= 1 /* Body */;
|
|
98738
98920
|
}
|
|
98739
|
-
if (ts.isForStatement(container)
|
|
98740
|
-
|
|
98921
|
+
if (ts.isForStatement(container)) {
|
|
98922
|
+
if (container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
|
|
98923
|
+
flags |= 2 /* Initializer */;
|
|
98924
|
+
}
|
|
98925
|
+
if (container.condition && resolver.isBindingCapturedByNode(container.condition, decl) ||
|
|
98926
|
+
container.incrementor && resolver.isBindingCapturedByNode(container.incrementor, decl)) {
|
|
98927
|
+
flags |= 1 /* Body */;
|
|
98928
|
+
}
|
|
98741
98929
|
}
|
|
98742
98930
|
loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName });
|
|
98743
98931
|
}
|
|
@@ -120112,7 +120300,7 @@ var ts;
|
|
|
120112
120300
|
if (!host.fileExists || !host.readFile) {
|
|
120113
120301
|
return undefined;
|
|
120114
120302
|
}
|
|
120115
|
-
var parts = getNodeModulePathParts(path);
|
|
120303
|
+
var parts = ts.getNodeModulePathParts(path);
|
|
120116
120304
|
if (!parts) {
|
|
120117
120305
|
return undefined;
|
|
120118
120306
|
}
|
|
@@ -120235,58 +120423,6 @@ var ts;
|
|
|
120235
120423
|
}
|
|
120236
120424
|
}
|
|
120237
120425
|
}
|
|
120238
|
-
function getNodeModulePathParts(fullPath) {
|
|
120239
|
-
// If fullPath can't be valid module file within node_modules, returns undefined.
|
|
120240
|
-
// Example of expected pattern: /base/path/node_modules/[@scope/otherpackage/@otherscope/node_modules/]package/[subdirectory/]file.js
|
|
120241
|
-
// Returns indices: ^ ^ ^ ^
|
|
120242
|
-
var topLevelNodeModulesIndex = 0;
|
|
120243
|
-
var topLevelPackageNameIndex = 0;
|
|
120244
|
-
var packageRootIndex = 0;
|
|
120245
|
-
var fileNameIndex = 0;
|
|
120246
|
-
var States;
|
|
120247
|
-
(function (States) {
|
|
120248
|
-
States[States["BeforeNodeModules"] = 0] = "BeforeNodeModules";
|
|
120249
|
-
States[States["NodeModules"] = 1] = "NodeModules";
|
|
120250
|
-
States[States["Scope"] = 2] = "Scope";
|
|
120251
|
-
States[States["PackageContent"] = 3] = "PackageContent";
|
|
120252
|
-
})(States || (States = {}));
|
|
120253
|
-
var partStart = 0;
|
|
120254
|
-
var partEnd = 0;
|
|
120255
|
-
var state = 0 /* BeforeNodeModules */;
|
|
120256
|
-
while (partEnd >= 0) {
|
|
120257
|
-
partStart = partEnd;
|
|
120258
|
-
partEnd = fullPath.indexOf("/", partStart + 1);
|
|
120259
|
-
switch (state) {
|
|
120260
|
-
case 0 /* BeforeNodeModules */:
|
|
120261
|
-
if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
|
|
120262
|
-
topLevelNodeModulesIndex = partStart;
|
|
120263
|
-
topLevelPackageNameIndex = partEnd;
|
|
120264
|
-
state = 1 /* NodeModules */;
|
|
120265
|
-
}
|
|
120266
|
-
break;
|
|
120267
|
-
case 1 /* NodeModules */:
|
|
120268
|
-
case 2 /* Scope */:
|
|
120269
|
-
if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") {
|
|
120270
|
-
state = 2 /* Scope */;
|
|
120271
|
-
}
|
|
120272
|
-
else {
|
|
120273
|
-
packageRootIndex = partEnd;
|
|
120274
|
-
state = 3 /* PackageContent */;
|
|
120275
|
-
}
|
|
120276
|
-
break;
|
|
120277
|
-
case 3 /* PackageContent */:
|
|
120278
|
-
if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
|
|
120279
|
-
state = 1 /* NodeModules */;
|
|
120280
|
-
}
|
|
120281
|
-
else {
|
|
120282
|
-
state = 3 /* PackageContent */;
|
|
120283
|
-
}
|
|
120284
|
-
break;
|
|
120285
|
-
}
|
|
120286
|
-
}
|
|
120287
|
-
fileNameIndex = partStart;
|
|
120288
|
-
return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
|
|
120289
|
-
}
|
|
120290
120426
|
function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
|
|
120291
120427
|
return ts.firstDefined(rootDirs, function (rootDir) {
|
|
120292
120428
|
var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
|