@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/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-insiders.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-insiders.20220207";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -1274,11 +1274,11 @@ var ts;
|
|
|
1274
1274
|
return result;
|
|
1275
1275
|
}
|
|
1276
1276
|
ts.getAllKeys = getAllKeys;
|
|
1277
|
-
function getOwnValues(
|
|
1277
|
+
function getOwnValues(collection) {
|
|
1278
1278
|
var values = [];
|
|
1279
|
-
for (var key in
|
|
1280
|
-
if (hasOwnProperty.call(
|
|
1281
|
-
values.push(
|
|
1279
|
+
for (var key in collection) {
|
|
1280
|
+
if (hasOwnProperty.call(collection, key)) {
|
|
1281
|
+
values.push(collection[key]);
|
|
1282
1282
|
}
|
|
1283
1283
|
}
|
|
1284
1284
|
return values;
|
|
@@ -5725,704 +5725,6 @@ var ts;
|
|
|
5725
5725
|
},
|
|
5726
5726
|
};
|
|
5727
5727
|
})(ts || (ts = {}));
|
|
5728
|
-
/* @internal */
|
|
5729
|
-
var ts;
|
|
5730
|
-
(function (ts) {
|
|
5731
|
-
/**
|
|
5732
|
-
* Internally, we represent paths as strings with '/' as the directory separator.
|
|
5733
|
-
* When we make system calls (eg: LanguageServiceHost.getDirectory()),
|
|
5734
|
-
* we expect the host to correctly handle paths in our specified format.
|
|
5735
|
-
*/
|
|
5736
|
-
ts.directorySeparator = "/";
|
|
5737
|
-
ts.altDirectorySeparator = "\\";
|
|
5738
|
-
var urlSchemeSeparator = "://";
|
|
5739
|
-
var backslashRegExp = /\\/g;
|
|
5740
|
-
//// Path Tests
|
|
5741
|
-
/**
|
|
5742
|
-
* Determines whether a charCode corresponds to `/` or `\`.
|
|
5743
|
-
*/
|
|
5744
|
-
function isAnyDirectorySeparator(charCode) {
|
|
5745
|
-
return charCode === 47 /* slash */ || charCode === 92 /* backslash */;
|
|
5746
|
-
}
|
|
5747
|
-
ts.isAnyDirectorySeparator = isAnyDirectorySeparator;
|
|
5748
|
-
/**
|
|
5749
|
-
* Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.).
|
|
5750
|
-
*/
|
|
5751
|
-
function isUrl(path) {
|
|
5752
|
-
return getEncodedRootLength(path) < 0;
|
|
5753
|
-
}
|
|
5754
|
-
ts.isUrl = isUrl;
|
|
5755
|
-
/**
|
|
5756
|
-
* Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path
|
|
5757
|
-
* like `c:`, `c:\` or `c:/`).
|
|
5758
|
-
*/
|
|
5759
|
-
function isRootedDiskPath(path) {
|
|
5760
|
-
return getEncodedRootLength(path) > 0;
|
|
5761
|
-
}
|
|
5762
|
-
ts.isRootedDiskPath = isRootedDiskPath;
|
|
5763
|
-
/**
|
|
5764
|
-
* Determines whether a path consists only of a path root.
|
|
5765
|
-
*/
|
|
5766
|
-
function isDiskPathRoot(path) {
|
|
5767
|
-
var rootLength = getEncodedRootLength(path);
|
|
5768
|
-
return rootLength > 0 && rootLength === path.length;
|
|
5769
|
-
}
|
|
5770
|
-
ts.isDiskPathRoot = isDiskPathRoot;
|
|
5771
|
-
/**
|
|
5772
|
-
* Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.).
|
|
5773
|
-
*
|
|
5774
|
-
* ```ts
|
|
5775
|
-
* // POSIX
|
|
5776
|
-
* pathIsAbsolute("/path/to/file.ext") === true
|
|
5777
|
-
* // DOS
|
|
5778
|
-
* pathIsAbsolute("c:/path/to/file.ext") === true
|
|
5779
|
-
* // URL
|
|
5780
|
-
* pathIsAbsolute("file:///path/to/file.ext") === true
|
|
5781
|
-
* // Non-absolute
|
|
5782
|
-
* pathIsAbsolute("path/to/file.ext") === false
|
|
5783
|
-
* pathIsAbsolute("./path/to/file.ext") === false
|
|
5784
|
-
* ```
|
|
5785
|
-
*/
|
|
5786
|
-
function pathIsAbsolute(path) {
|
|
5787
|
-
return getEncodedRootLength(path) !== 0;
|
|
5788
|
-
}
|
|
5789
|
-
ts.pathIsAbsolute = pathIsAbsolute;
|
|
5790
|
-
/**
|
|
5791
|
-
* Determines whether a path starts with a relative path component (i.e. `.` or `..`).
|
|
5792
|
-
*/
|
|
5793
|
-
function pathIsRelative(path) {
|
|
5794
|
-
return /^\.\.?($|[\\/])/.test(path);
|
|
5795
|
-
}
|
|
5796
|
-
ts.pathIsRelative = pathIsRelative;
|
|
5797
|
-
/**
|
|
5798
|
-
* Determines whether a path is neither relative nor absolute, e.g. "path/to/file".
|
|
5799
|
-
* Also known misleadingly as "non-relative".
|
|
5800
|
-
*/
|
|
5801
|
-
function pathIsBareSpecifier(path) {
|
|
5802
|
-
return !pathIsAbsolute(path) && !pathIsRelative(path);
|
|
5803
|
-
}
|
|
5804
|
-
ts.pathIsBareSpecifier = pathIsBareSpecifier;
|
|
5805
|
-
function hasExtension(fileName) {
|
|
5806
|
-
return ts.stringContains(getBaseFileName(fileName), ".");
|
|
5807
|
-
}
|
|
5808
|
-
ts.hasExtension = hasExtension;
|
|
5809
|
-
function fileExtensionIs(path, extension) {
|
|
5810
|
-
return path.length > extension.length && ts.endsWith(path, extension);
|
|
5811
|
-
}
|
|
5812
|
-
ts.fileExtensionIs = fileExtensionIs;
|
|
5813
|
-
function fileExtensionIsOneOf(path, extensions) {
|
|
5814
|
-
for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
|
|
5815
|
-
var extension = extensions_1[_i];
|
|
5816
|
-
if (fileExtensionIs(path, extension)) {
|
|
5817
|
-
return true;
|
|
5818
|
-
}
|
|
5819
|
-
}
|
|
5820
|
-
return false;
|
|
5821
|
-
}
|
|
5822
|
-
ts.fileExtensionIsOneOf = fileExtensionIsOneOf;
|
|
5823
|
-
/**
|
|
5824
|
-
* Determines whether a path has a trailing separator (`/` or `\\`).
|
|
5825
|
-
*/
|
|
5826
|
-
function hasTrailingDirectorySeparator(path) {
|
|
5827
|
-
return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1));
|
|
5828
|
-
}
|
|
5829
|
-
ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator;
|
|
5830
|
-
//// Path Parsing
|
|
5831
|
-
function isVolumeCharacter(charCode) {
|
|
5832
|
-
return (charCode >= 97 /* a */ && charCode <= 122 /* z */) ||
|
|
5833
|
-
(charCode >= 65 /* A */ && charCode <= 90 /* Z */);
|
|
5834
|
-
}
|
|
5835
|
-
function getFileUrlVolumeSeparatorEnd(url, start) {
|
|
5836
|
-
var ch0 = url.charCodeAt(start);
|
|
5837
|
-
if (ch0 === 58 /* colon */)
|
|
5838
|
-
return start + 1;
|
|
5839
|
-
if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) {
|
|
5840
|
-
var ch2 = url.charCodeAt(start + 2);
|
|
5841
|
-
if (ch2 === 97 /* a */ || ch2 === 65 /* A */)
|
|
5842
|
-
return start + 3;
|
|
5843
|
-
}
|
|
5844
|
-
return -1;
|
|
5845
|
-
}
|
|
5846
|
-
/**
|
|
5847
|
-
* Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
|
|
5848
|
-
* If the root is part of a URL, the twos-complement of the root length is returned.
|
|
5849
|
-
*/
|
|
5850
|
-
function getEncodedRootLength(path) {
|
|
5851
|
-
if (!path)
|
|
5852
|
-
return 0;
|
|
5853
|
-
var ch0 = path.charCodeAt(0);
|
|
5854
|
-
// POSIX or UNC
|
|
5855
|
-
if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) {
|
|
5856
|
-
if (path.charCodeAt(1) !== ch0)
|
|
5857
|
-
return 1; // POSIX: "/" (or non-normalized "\")
|
|
5858
|
-
var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2);
|
|
5859
|
-
if (p1 < 0)
|
|
5860
|
-
return path.length; // UNC: "//server" or "\\server"
|
|
5861
|
-
return p1 + 1; // UNC: "//server/" or "\\server\"
|
|
5862
|
-
}
|
|
5863
|
-
// DOS
|
|
5864
|
-
if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) {
|
|
5865
|
-
var ch2 = path.charCodeAt(2);
|
|
5866
|
-
if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */)
|
|
5867
|
-
return 3; // DOS: "c:/" or "c:\"
|
|
5868
|
-
if (path.length === 2)
|
|
5869
|
-
return 2; // DOS: "c:" (but not "c:d")
|
|
5870
|
-
}
|
|
5871
|
-
// URL
|
|
5872
|
-
var schemeEnd = path.indexOf(urlSchemeSeparator);
|
|
5873
|
-
if (schemeEnd !== -1) {
|
|
5874
|
-
var authorityStart = schemeEnd + urlSchemeSeparator.length;
|
|
5875
|
-
var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart);
|
|
5876
|
-
if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path"
|
|
5877
|
-
// For local "file" URLs, include the leading DOS volume (if present).
|
|
5878
|
-
// Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a
|
|
5879
|
-
// special case interpreted as "the machine from which the URL is being interpreted".
|
|
5880
|
-
var scheme = path.slice(0, schemeEnd);
|
|
5881
|
-
var authority = path.slice(authorityStart, authorityEnd);
|
|
5882
|
-
if (scheme === "file" && (authority === "" || authority === "localhost") &&
|
|
5883
|
-
isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
|
|
5884
|
-
var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
|
|
5885
|
-
if (volumeSeparatorEnd !== -1) {
|
|
5886
|
-
if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) {
|
|
5887
|
-
// URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/"
|
|
5888
|
-
return ~(volumeSeparatorEnd + 1);
|
|
5889
|
-
}
|
|
5890
|
-
if (volumeSeparatorEnd === path.length) {
|
|
5891
|
-
// URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a"
|
|
5892
|
-
// but not "file:///c:d" or "file:///c%3ad"
|
|
5893
|
-
return ~volumeSeparatorEnd;
|
|
5894
|
-
}
|
|
5895
|
-
}
|
|
5896
|
-
}
|
|
5897
|
-
return ~(authorityEnd + 1); // URL: "file://server/", "http://server/"
|
|
5898
|
-
}
|
|
5899
|
-
return ~path.length; // URL: "file://server", "http://server"
|
|
5900
|
-
}
|
|
5901
|
-
// relative
|
|
5902
|
-
return 0;
|
|
5903
|
-
}
|
|
5904
|
-
/**
|
|
5905
|
-
* Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
|
|
5906
|
-
*
|
|
5907
|
-
* For example:
|
|
5908
|
-
* ```ts
|
|
5909
|
-
* getRootLength("a") === 0 // ""
|
|
5910
|
-
* getRootLength("/") === 1 // "/"
|
|
5911
|
-
* getRootLength("c:") === 2 // "c:"
|
|
5912
|
-
* getRootLength("c:d") === 0 // ""
|
|
5913
|
-
* getRootLength("c:/") === 3 // "c:/"
|
|
5914
|
-
* getRootLength("c:\\") === 3 // "c:\\"
|
|
5915
|
-
* getRootLength("//server") === 7 // "//server"
|
|
5916
|
-
* getRootLength("//server/share") === 8 // "//server/"
|
|
5917
|
-
* getRootLength("\\\\server") === 7 // "\\\\server"
|
|
5918
|
-
* getRootLength("\\\\server\\share") === 8 // "\\\\server\\"
|
|
5919
|
-
* getRootLength("file:///path") === 8 // "file:///"
|
|
5920
|
-
* getRootLength("file:///c:") === 10 // "file:///c:"
|
|
5921
|
-
* getRootLength("file:///c:d") === 8 // "file:///"
|
|
5922
|
-
* getRootLength("file:///c:/path") === 11 // "file:///c:/"
|
|
5923
|
-
* getRootLength("file://server") === 13 // "file://server"
|
|
5924
|
-
* getRootLength("file://server/path") === 14 // "file://server/"
|
|
5925
|
-
* getRootLength("http://server") === 13 // "http://server"
|
|
5926
|
-
* getRootLength("http://server/path") === 14 // "http://server/"
|
|
5927
|
-
* ```
|
|
5928
|
-
*/
|
|
5929
|
-
function getRootLength(path) {
|
|
5930
|
-
var rootLength = getEncodedRootLength(path);
|
|
5931
|
-
return rootLength < 0 ? ~rootLength : rootLength;
|
|
5932
|
-
}
|
|
5933
|
-
ts.getRootLength = getRootLength;
|
|
5934
|
-
function getDirectoryPath(path) {
|
|
5935
|
-
path = normalizeSlashes(path);
|
|
5936
|
-
// If the path provided is itself the root, then return it.
|
|
5937
|
-
var rootLength = getRootLength(path);
|
|
5938
|
-
if (rootLength === path.length)
|
|
5939
|
-
return path;
|
|
5940
|
-
// return the leading portion of the path up to the last (non-terminal) directory separator
|
|
5941
|
-
// but not including any trailing directory separator.
|
|
5942
|
-
path = removeTrailingDirectorySeparator(path);
|
|
5943
|
-
return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator)));
|
|
5944
|
-
}
|
|
5945
|
-
ts.getDirectoryPath = getDirectoryPath;
|
|
5946
|
-
function getBaseFileName(path, extensions, ignoreCase) {
|
|
5947
|
-
path = normalizeSlashes(path);
|
|
5948
|
-
// if the path provided is itself the root, then it has not file name.
|
|
5949
|
-
var rootLength = getRootLength(path);
|
|
5950
|
-
if (rootLength === path.length)
|
|
5951
|
-
return "";
|
|
5952
|
-
// return the trailing portion of the path starting after the last (non-terminal) directory
|
|
5953
|
-
// separator but not including any trailing directory separator.
|
|
5954
|
-
path = removeTrailingDirectorySeparator(path);
|
|
5955
|
-
var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1));
|
|
5956
|
-
var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined;
|
|
5957
|
-
return extension ? name.slice(0, name.length - extension.length) : name;
|
|
5958
|
-
}
|
|
5959
|
-
ts.getBaseFileName = getBaseFileName;
|
|
5960
|
-
function tryGetExtensionFromPath(path, extension, stringEqualityComparer) {
|
|
5961
|
-
if (!ts.startsWith(extension, "."))
|
|
5962
|
-
extension = "." + extension;
|
|
5963
|
-
if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) {
|
|
5964
|
-
var pathExtension = path.slice(path.length - extension.length);
|
|
5965
|
-
if (stringEqualityComparer(pathExtension, extension)) {
|
|
5966
|
-
return pathExtension;
|
|
5967
|
-
}
|
|
5968
|
-
}
|
|
5969
|
-
}
|
|
5970
|
-
function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) {
|
|
5971
|
-
if (typeof extensions === "string") {
|
|
5972
|
-
return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || "";
|
|
5973
|
-
}
|
|
5974
|
-
for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) {
|
|
5975
|
-
var extension = extensions_2[_i];
|
|
5976
|
-
var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer);
|
|
5977
|
-
if (result)
|
|
5978
|
-
return result;
|
|
5979
|
-
}
|
|
5980
|
-
return "";
|
|
5981
|
-
}
|
|
5982
|
-
function getAnyExtensionFromPath(path, extensions, ignoreCase) {
|
|
5983
|
-
// Retrieves any string from the final "." onwards from a base file name.
|
|
5984
|
-
// Unlike extensionFromPath, which throws an exception on unrecognized extensions.
|
|
5985
|
-
if (extensions) {
|
|
5986
|
-
return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive);
|
|
5987
|
-
}
|
|
5988
|
-
var baseFileName = getBaseFileName(path);
|
|
5989
|
-
var extensionIndex = baseFileName.lastIndexOf(".");
|
|
5990
|
-
if (extensionIndex >= 0) {
|
|
5991
|
-
return baseFileName.substring(extensionIndex);
|
|
5992
|
-
}
|
|
5993
|
-
return "";
|
|
5994
|
-
}
|
|
5995
|
-
ts.getAnyExtensionFromPath = getAnyExtensionFromPath;
|
|
5996
|
-
function pathComponents(path, rootLength) {
|
|
5997
|
-
var root = path.substring(0, rootLength);
|
|
5998
|
-
var rest = path.substring(rootLength).split(ts.directorySeparator);
|
|
5999
|
-
if (rest.length && !ts.lastOrUndefined(rest))
|
|
6000
|
-
rest.pop();
|
|
6001
|
-
return __spreadArray([root], rest, true);
|
|
6002
|
-
}
|
|
6003
|
-
/**
|
|
6004
|
-
* Parse a path into an array containing a root component (at index 0) and zero or more path
|
|
6005
|
-
* components (at indices > 0). The result is not normalized.
|
|
6006
|
-
* If the path is relative, the root component is `""`.
|
|
6007
|
-
* If the path is absolute, the root component includes the first path separator (`/`).
|
|
6008
|
-
*
|
|
6009
|
-
* ```ts
|
|
6010
|
-
* // POSIX
|
|
6011
|
-
* getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"]
|
|
6012
|
-
* getPathComponents("/path/to/") === ["/", "path", "to"]
|
|
6013
|
-
* getPathComponents("/") === ["/"]
|
|
6014
|
-
* // DOS
|
|
6015
|
-
* getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"]
|
|
6016
|
-
* getPathComponents("c:/path/to/") === ["c:/", "path", "to"]
|
|
6017
|
-
* getPathComponents("c:/") === ["c:/"]
|
|
6018
|
-
* getPathComponents("c:") === ["c:"]
|
|
6019
|
-
* // URL
|
|
6020
|
-
* getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"]
|
|
6021
|
-
* getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"]
|
|
6022
|
-
* getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"]
|
|
6023
|
-
* getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"]
|
|
6024
|
-
* getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"]
|
|
6025
|
-
* getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"]
|
|
6026
|
-
* getPathComponents("file://server/") === ["file://server/"]
|
|
6027
|
-
* getPathComponents("file://server") === ["file://server"]
|
|
6028
|
-
* getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"]
|
|
6029
|
-
* getPathComponents("file:///path/to/") === ["file:///", "path", "to"]
|
|
6030
|
-
* getPathComponents("file:///") === ["file:///"]
|
|
6031
|
-
* getPathComponents("file://") === ["file://"]
|
|
6032
|
-
*/
|
|
6033
|
-
function getPathComponents(path, currentDirectory) {
|
|
6034
|
-
if (currentDirectory === void 0) { currentDirectory = ""; }
|
|
6035
|
-
path = combinePaths(currentDirectory, path);
|
|
6036
|
-
return pathComponents(path, getRootLength(path));
|
|
6037
|
-
}
|
|
6038
|
-
ts.getPathComponents = getPathComponents;
|
|
6039
|
-
//// Path Formatting
|
|
6040
|
-
/**
|
|
6041
|
-
* Formats a parsed path consisting of a root component (at index 0) and zero or more path
|
|
6042
|
-
* segments (at indices > 0).
|
|
6043
|
-
*
|
|
6044
|
-
* ```ts
|
|
6045
|
-
* getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext"
|
|
6046
|
-
* ```
|
|
6047
|
-
*/
|
|
6048
|
-
function getPathFromPathComponents(pathComponents) {
|
|
6049
|
-
if (pathComponents.length === 0)
|
|
6050
|
-
return "";
|
|
6051
|
-
var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
|
|
6052
|
-
return root + pathComponents.slice(1).join(ts.directorySeparator);
|
|
6053
|
-
}
|
|
6054
|
-
ts.getPathFromPathComponents = getPathFromPathComponents;
|
|
6055
|
-
//// Path Normalization
|
|
6056
|
-
/**
|
|
6057
|
-
* Normalize path separators, converting `\` into `/`.
|
|
6058
|
-
*/
|
|
6059
|
-
function normalizeSlashes(path) {
|
|
6060
|
-
var index = path.indexOf("\\");
|
|
6061
|
-
if (index === -1) {
|
|
6062
|
-
return path;
|
|
6063
|
-
}
|
|
6064
|
-
backslashRegExp.lastIndex = index; // prime regex with known position
|
|
6065
|
-
return path.replace(backslashRegExp, ts.directorySeparator);
|
|
6066
|
-
}
|
|
6067
|
-
ts.normalizeSlashes = normalizeSlashes;
|
|
6068
|
-
/**
|
|
6069
|
-
* Reduce an array of path components to a more simplified path by navigating any
|
|
6070
|
-
* `"."` or `".."` entries in the path.
|
|
6071
|
-
*/
|
|
6072
|
-
function reducePathComponents(components) {
|
|
6073
|
-
if (!ts.some(components))
|
|
6074
|
-
return [];
|
|
6075
|
-
var reduced = [components[0]];
|
|
6076
|
-
for (var i = 1; i < components.length; i++) {
|
|
6077
|
-
var component = components[i];
|
|
6078
|
-
if (!component)
|
|
6079
|
-
continue;
|
|
6080
|
-
if (component === ".")
|
|
6081
|
-
continue;
|
|
6082
|
-
if (component === "..") {
|
|
6083
|
-
if (reduced.length > 1) {
|
|
6084
|
-
if (reduced[reduced.length - 1] !== "..") {
|
|
6085
|
-
reduced.pop();
|
|
6086
|
-
continue;
|
|
6087
|
-
}
|
|
6088
|
-
}
|
|
6089
|
-
else if (reduced[0])
|
|
6090
|
-
continue;
|
|
6091
|
-
}
|
|
6092
|
-
reduced.push(component);
|
|
6093
|
-
}
|
|
6094
|
-
return reduced;
|
|
6095
|
-
}
|
|
6096
|
-
ts.reducePathComponents = reducePathComponents;
|
|
6097
|
-
/**
|
|
6098
|
-
* Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified.
|
|
6099
|
-
*
|
|
6100
|
-
* ```ts
|
|
6101
|
-
* // Non-rooted
|
|
6102
|
-
* combinePaths("path", "to", "file.ext") === "path/to/file.ext"
|
|
6103
|
-
* combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext"
|
|
6104
|
-
* // POSIX
|
|
6105
|
-
* combinePaths("/path", "to", "file.ext") === "/path/to/file.ext"
|
|
6106
|
-
* combinePaths("/path", "/to", "file.ext") === "/to/file.ext"
|
|
6107
|
-
* // DOS
|
|
6108
|
-
* combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext"
|
|
6109
|
-
* combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext"
|
|
6110
|
-
* // URL
|
|
6111
|
-
* combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext"
|
|
6112
|
-
* combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext"
|
|
6113
|
-
* ```
|
|
6114
|
-
*/
|
|
6115
|
-
function combinePaths(path) {
|
|
6116
|
-
var paths = [];
|
|
6117
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
6118
|
-
paths[_i - 1] = arguments[_i];
|
|
6119
|
-
}
|
|
6120
|
-
if (path)
|
|
6121
|
-
path = normalizeSlashes(path);
|
|
6122
|
-
for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
|
|
6123
|
-
var relativePath = paths_1[_a];
|
|
6124
|
-
if (!relativePath)
|
|
6125
|
-
continue;
|
|
6126
|
-
relativePath = normalizeSlashes(relativePath);
|
|
6127
|
-
if (!path || getRootLength(relativePath) !== 0) {
|
|
6128
|
-
path = relativePath;
|
|
6129
|
-
}
|
|
6130
|
-
else {
|
|
6131
|
-
path = ensureTrailingDirectorySeparator(path) + relativePath;
|
|
6132
|
-
}
|
|
6133
|
-
}
|
|
6134
|
-
return path;
|
|
6135
|
-
}
|
|
6136
|
-
ts.combinePaths = combinePaths;
|
|
6137
|
-
/**
|
|
6138
|
-
* Combines and resolves paths. If a path is absolute, it replaces any previous path. Any
|
|
6139
|
-
* `.` and `..` path components are resolved. Trailing directory separators are preserved.
|
|
6140
|
-
*
|
|
6141
|
-
* ```ts
|
|
6142
|
-
* resolvePath("/path", "to", "file.ext") === "path/to/file.ext"
|
|
6143
|
-
* resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/"
|
|
6144
|
-
* resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext"
|
|
6145
|
-
* ```
|
|
6146
|
-
*/
|
|
6147
|
-
function resolvePath(path) {
|
|
6148
|
-
var paths = [];
|
|
6149
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
6150
|
-
paths[_i - 1] = arguments[_i];
|
|
6151
|
-
}
|
|
6152
|
-
return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArray([path], paths, false)) : normalizeSlashes(path));
|
|
6153
|
-
}
|
|
6154
|
-
ts.resolvePath = resolvePath;
|
|
6155
|
-
/**
|
|
6156
|
-
* Parse a path into an array containing a root component (at index 0) and zero or more path
|
|
6157
|
-
* components (at indices > 0). The result is normalized.
|
|
6158
|
-
* If the path is relative, the root component is `""`.
|
|
6159
|
-
* If the path is absolute, the root component includes the first path separator (`/`).
|
|
6160
|
-
*
|
|
6161
|
-
* ```ts
|
|
6162
|
-
* getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"]
|
|
6163
|
-
* ```
|
|
6164
|
-
*/
|
|
6165
|
-
function getNormalizedPathComponents(path, currentDirectory) {
|
|
6166
|
-
return reducePathComponents(getPathComponents(path, currentDirectory));
|
|
6167
|
-
}
|
|
6168
|
-
ts.getNormalizedPathComponents = getNormalizedPathComponents;
|
|
6169
|
-
function getNormalizedAbsolutePath(fileName, currentDirectory) {
|
|
6170
|
-
return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
|
|
6171
|
-
}
|
|
6172
|
-
ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
|
|
6173
|
-
function normalizePath(path) {
|
|
6174
|
-
path = normalizeSlashes(path);
|
|
6175
|
-
// Most paths don't require normalization
|
|
6176
|
-
if (!relativePathSegmentRegExp.test(path)) {
|
|
6177
|
-
return path;
|
|
6178
|
-
}
|
|
6179
|
-
// Some paths only require cleanup of `/./` or leading `./`
|
|
6180
|
-
var simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, "");
|
|
6181
|
-
if (simplified !== path) {
|
|
6182
|
-
path = simplified;
|
|
6183
|
-
if (!relativePathSegmentRegExp.test(path)) {
|
|
6184
|
-
return path;
|
|
6185
|
-
}
|
|
6186
|
-
}
|
|
6187
|
-
// Other paths require full normalization
|
|
6188
|
-
var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
|
|
6189
|
-
return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
|
|
6190
|
-
}
|
|
6191
|
-
ts.normalizePath = normalizePath;
|
|
6192
|
-
function getPathWithoutRoot(pathComponents) {
|
|
6193
|
-
if (pathComponents.length === 0)
|
|
6194
|
-
return "";
|
|
6195
|
-
return pathComponents.slice(1).join(ts.directorySeparator);
|
|
6196
|
-
}
|
|
6197
|
-
function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
|
|
6198
|
-
return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
|
|
6199
|
-
}
|
|
6200
|
-
ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
|
|
6201
|
-
function toPath(fileName, basePath, getCanonicalFileName) {
|
|
6202
|
-
var nonCanonicalizedPath = isRootedDiskPath(fileName)
|
|
6203
|
-
? normalizePath(fileName)
|
|
6204
|
-
: getNormalizedAbsolutePath(fileName, basePath);
|
|
6205
|
-
return getCanonicalFileName(nonCanonicalizedPath);
|
|
6206
|
-
}
|
|
6207
|
-
ts.toPath = toPath;
|
|
6208
|
-
function normalizePathAndParts(path) {
|
|
6209
|
-
path = normalizeSlashes(path);
|
|
6210
|
-
var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
|
|
6211
|
-
if (parts.length) {
|
|
6212
|
-
var joinedParts = root + parts.join(ts.directorySeparator);
|
|
6213
|
-
return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
|
|
6214
|
-
}
|
|
6215
|
-
else {
|
|
6216
|
-
return { path: root, parts: parts };
|
|
6217
|
-
}
|
|
6218
|
-
}
|
|
6219
|
-
ts.normalizePathAndParts = normalizePathAndParts;
|
|
6220
|
-
function removeTrailingDirectorySeparator(path) {
|
|
6221
|
-
if (hasTrailingDirectorySeparator(path)) {
|
|
6222
|
-
return path.substr(0, path.length - 1);
|
|
6223
|
-
}
|
|
6224
|
-
return path;
|
|
6225
|
-
}
|
|
6226
|
-
ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
|
|
6227
|
-
function ensureTrailingDirectorySeparator(path) {
|
|
6228
|
-
if (!hasTrailingDirectorySeparator(path)) {
|
|
6229
|
-
return path + ts.directorySeparator;
|
|
6230
|
-
}
|
|
6231
|
-
return path;
|
|
6232
|
-
}
|
|
6233
|
-
ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator;
|
|
6234
|
-
/**
|
|
6235
|
-
* Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed
|
|
6236
|
-
* with `./` or `../`) so as not to be confused with an unprefixed module name.
|
|
6237
|
-
*
|
|
6238
|
-
* ```ts
|
|
6239
|
-
* ensurePathIsNonModuleName("/path/to/file.ext") === "/path/to/file.ext"
|
|
6240
|
-
* ensurePathIsNonModuleName("./path/to/file.ext") === "./path/to/file.ext"
|
|
6241
|
-
* ensurePathIsNonModuleName("../path/to/file.ext") === "../path/to/file.ext"
|
|
6242
|
-
* ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext"
|
|
6243
|
-
* ```
|
|
6244
|
-
*/
|
|
6245
|
-
function ensurePathIsNonModuleName(path) {
|
|
6246
|
-
return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path;
|
|
6247
|
-
}
|
|
6248
|
-
ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName;
|
|
6249
|
-
function changeAnyExtension(path, ext, extensions, ignoreCase) {
|
|
6250
|
-
var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path);
|
|
6251
|
-
return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
|
|
6252
|
-
}
|
|
6253
|
-
ts.changeAnyExtension = changeAnyExtension;
|
|
6254
|
-
//// Path Comparisons
|
|
6255
|
-
// check path for these segments: '', '.'. '..'
|
|
6256
|
-
var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/;
|
|
6257
|
-
function comparePathsWorker(a, b, componentComparer) {
|
|
6258
|
-
if (a === b)
|
|
6259
|
-
return 0 /* EqualTo */;
|
|
6260
|
-
if (a === undefined)
|
|
6261
|
-
return -1 /* LessThan */;
|
|
6262
|
-
if (b === undefined)
|
|
6263
|
-
return 1 /* GreaterThan */;
|
|
6264
|
-
// NOTE: Performance optimization - shortcut if the root segments differ as there would be no
|
|
6265
|
-
// need to perform path reduction.
|
|
6266
|
-
var aRoot = a.substring(0, getRootLength(a));
|
|
6267
|
-
var bRoot = b.substring(0, getRootLength(b));
|
|
6268
|
-
var result = ts.compareStringsCaseInsensitive(aRoot, bRoot);
|
|
6269
|
-
if (result !== 0 /* EqualTo */) {
|
|
6270
|
-
return result;
|
|
6271
|
-
}
|
|
6272
|
-
// NOTE: Performance optimization - shortcut if there are no relative path segments in
|
|
6273
|
-
// the non-root portion of the path
|
|
6274
|
-
var aRest = a.substring(aRoot.length);
|
|
6275
|
-
var bRest = b.substring(bRoot.length);
|
|
6276
|
-
if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) {
|
|
6277
|
-
return componentComparer(aRest, bRest);
|
|
6278
|
-
}
|
|
6279
|
-
// The path contains a relative path segment. Normalize the paths and perform a slower component
|
|
6280
|
-
// by component comparison.
|
|
6281
|
-
var aComponents = reducePathComponents(getPathComponents(a));
|
|
6282
|
-
var bComponents = reducePathComponents(getPathComponents(b));
|
|
6283
|
-
var sharedLength = Math.min(aComponents.length, bComponents.length);
|
|
6284
|
-
for (var i = 1; i < sharedLength; i++) {
|
|
6285
|
-
var result_2 = componentComparer(aComponents[i], bComponents[i]);
|
|
6286
|
-
if (result_2 !== 0 /* EqualTo */) {
|
|
6287
|
-
return result_2;
|
|
6288
|
-
}
|
|
6289
|
-
}
|
|
6290
|
-
return ts.compareValues(aComponents.length, bComponents.length);
|
|
6291
|
-
}
|
|
6292
|
-
/**
|
|
6293
|
-
* Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively.
|
|
6294
|
-
*/
|
|
6295
|
-
function comparePathsCaseSensitive(a, b) {
|
|
6296
|
-
return comparePathsWorker(a, b, ts.compareStringsCaseSensitive);
|
|
6297
|
-
}
|
|
6298
|
-
ts.comparePathsCaseSensitive = comparePathsCaseSensitive;
|
|
6299
|
-
/**
|
|
6300
|
-
* Performs a case-insensitive comparison of two paths.
|
|
6301
|
-
*/
|
|
6302
|
-
function comparePathsCaseInsensitive(a, b) {
|
|
6303
|
-
return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive);
|
|
6304
|
-
}
|
|
6305
|
-
ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive;
|
|
6306
|
-
function comparePaths(a, b, currentDirectory, ignoreCase) {
|
|
6307
|
-
if (typeof currentDirectory === "string") {
|
|
6308
|
-
a = combinePaths(currentDirectory, a);
|
|
6309
|
-
b = combinePaths(currentDirectory, b);
|
|
6310
|
-
}
|
|
6311
|
-
else if (typeof currentDirectory === "boolean") {
|
|
6312
|
-
ignoreCase = currentDirectory;
|
|
6313
|
-
}
|
|
6314
|
-
return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase));
|
|
6315
|
-
}
|
|
6316
|
-
ts.comparePaths = comparePaths;
|
|
6317
|
-
function containsPath(parent, child, currentDirectory, ignoreCase) {
|
|
6318
|
-
if (typeof currentDirectory === "string") {
|
|
6319
|
-
parent = combinePaths(currentDirectory, parent);
|
|
6320
|
-
child = combinePaths(currentDirectory, child);
|
|
6321
|
-
}
|
|
6322
|
-
else if (typeof currentDirectory === "boolean") {
|
|
6323
|
-
ignoreCase = currentDirectory;
|
|
6324
|
-
}
|
|
6325
|
-
if (parent === undefined || child === undefined)
|
|
6326
|
-
return false;
|
|
6327
|
-
if (parent === child)
|
|
6328
|
-
return true;
|
|
6329
|
-
var parentComponents = reducePathComponents(getPathComponents(parent));
|
|
6330
|
-
var childComponents = reducePathComponents(getPathComponents(child));
|
|
6331
|
-
if (childComponents.length < parentComponents.length) {
|
|
6332
|
-
return false;
|
|
6333
|
-
}
|
|
6334
|
-
var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive;
|
|
6335
|
-
for (var i = 0; i < parentComponents.length; i++) {
|
|
6336
|
-
var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer;
|
|
6337
|
-
if (!equalityComparer(parentComponents[i], childComponents[i])) {
|
|
6338
|
-
return false;
|
|
6339
|
-
}
|
|
6340
|
-
}
|
|
6341
|
-
return true;
|
|
6342
|
-
}
|
|
6343
|
-
ts.containsPath = containsPath;
|
|
6344
|
-
/**
|
|
6345
|
-
* Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback.
|
|
6346
|
-
* Comparison is case-sensitive between the canonical paths.
|
|
6347
|
-
*
|
|
6348
|
-
* Use `containsPath` if file names are not already reduced and absolute.
|
|
6349
|
-
*/
|
|
6350
|
-
function startsWithDirectory(fileName, directoryName, getCanonicalFileName) {
|
|
6351
|
-
var canonicalFileName = getCanonicalFileName(fileName);
|
|
6352
|
-
var canonicalDirectoryName = getCanonicalFileName(directoryName);
|
|
6353
|
-
return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\");
|
|
6354
|
-
}
|
|
6355
|
-
ts.startsWithDirectory = startsWithDirectory;
|
|
6356
|
-
//// Relative Paths
|
|
6357
|
-
function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) {
|
|
6358
|
-
var fromComponents = reducePathComponents(getPathComponents(from));
|
|
6359
|
-
var toComponents = reducePathComponents(getPathComponents(to));
|
|
6360
|
-
var start;
|
|
6361
|
-
for (start = 0; start < fromComponents.length && start < toComponents.length; start++) {
|
|
6362
|
-
var fromComponent = getCanonicalFileName(fromComponents[start]);
|
|
6363
|
-
var toComponent = getCanonicalFileName(toComponents[start]);
|
|
6364
|
-
var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer;
|
|
6365
|
-
if (!comparer(fromComponent, toComponent))
|
|
6366
|
-
break;
|
|
6367
|
-
}
|
|
6368
|
-
if (start === 0) {
|
|
6369
|
-
return toComponents;
|
|
6370
|
-
}
|
|
6371
|
-
var components = toComponents.slice(start);
|
|
6372
|
-
var relative = [];
|
|
6373
|
-
for (; start < fromComponents.length; start++) {
|
|
6374
|
-
relative.push("..");
|
|
6375
|
-
}
|
|
6376
|
-
return __spreadArray(__spreadArray([""], relative, true), components, true);
|
|
6377
|
-
}
|
|
6378
|
-
ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo;
|
|
6379
|
-
function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
|
|
6380
|
-
ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
|
|
6381
|
-
var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
|
|
6382
|
-
var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
|
|
6383
|
-
var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
|
|
6384
|
-
return getPathFromPathComponents(pathComponents);
|
|
6385
|
-
}
|
|
6386
|
-
ts.getRelativePathFromDirectory = getRelativePathFromDirectory;
|
|
6387
|
-
function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
|
|
6388
|
-
return !isRootedDiskPath(absoluteOrRelativePath)
|
|
6389
|
-
? absoluteOrRelativePath
|
|
6390
|
-
: getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
|
|
6391
|
-
}
|
|
6392
|
-
ts.convertToRelativePath = convertToRelativePath;
|
|
6393
|
-
function getRelativePathFromFile(from, to, getCanonicalFileName) {
|
|
6394
|
-
return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName));
|
|
6395
|
-
}
|
|
6396
|
-
ts.getRelativePathFromFile = getRelativePathFromFile;
|
|
6397
|
-
function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
|
|
6398
|
-
var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName);
|
|
6399
|
-
var firstComponent = pathComponents[0];
|
|
6400
|
-
if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) {
|
|
6401
|
-
var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///";
|
|
6402
|
-
pathComponents[0] = prefix + firstComponent;
|
|
6403
|
-
}
|
|
6404
|
-
return getPathFromPathComponents(pathComponents);
|
|
6405
|
-
}
|
|
6406
|
-
ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl;
|
|
6407
|
-
function forEachAncestorDirectory(directory, callback) {
|
|
6408
|
-
while (true) {
|
|
6409
|
-
var result = callback(directory);
|
|
6410
|
-
if (result !== undefined) {
|
|
6411
|
-
return result;
|
|
6412
|
-
}
|
|
6413
|
-
var parentPath = getDirectoryPath(directory);
|
|
6414
|
-
if (parentPath === directory) {
|
|
6415
|
-
return undefined;
|
|
6416
|
-
}
|
|
6417
|
-
directory = parentPath;
|
|
6418
|
-
}
|
|
6419
|
-
}
|
|
6420
|
-
ts.forEachAncestorDirectory = forEachAncestorDirectory;
|
|
6421
|
-
function isNodeModulesDirectory(dirPath) {
|
|
6422
|
-
return ts.endsWith(dirPath, "/node_modules");
|
|
6423
|
-
}
|
|
6424
|
-
ts.isNodeModulesDirectory = isNodeModulesDirectory;
|
|
6425
|
-
})(ts || (ts = {}));
|
|
6426
5728
|
var ts;
|
|
6427
5729
|
(function (ts) {
|
|
6428
5730
|
/**
|
|
@@ -7855,8 +7157,706 @@ var ts;
|
|
|
7855
7157
|
ts.Debug.isDebugging = true;
|
|
7856
7158
|
}
|
|
7857
7159
|
})(ts || (ts = {}));
|
|
7160
|
+
/* @internal */
|
|
7161
|
+
var ts;
|
|
7162
|
+
(function (ts) {
|
|
7163
|
+
/**
|
|
7164
|
+
* Internally, we represent paths as strings with '/' as the directory separator.
|
|
7165
|
+
* When we make system calls (eg: LanguageServiceHost.getDirectory()),
|
|
7166
|
+
* we expect the host to correctly handle paths in our specified format.
|
|
7167
|
+
*/
|
|
7168
|
+
ts.directorySeparator = "/";
|
|
7169
|
+
ts.altDirectorySeparator = "\\";
|
|
7170
|
+
var urlSchemeSeparator = "://";
|
|
7171
|
+
var backslashRegExp = /\\/g;
|
|
7172
|
+
//// Path Tests
|
|
7173
|
+
/**
|
|
7174
|
+
* Determines whether a charCode corresponds to `/` or `\`.
|
|
7175
|
+
*/
|
|
7176
|
+
function isAnyDirectorySeparator(charCode) {
|
|
7177
|
+
return charCode === 47 /* slash */ || charCode === 92 /* backslash */;
|
|
7178
|
+
}
|
|
7179
|
+
ts.isAnyDirectorySeparator = isAnyDirectorySeparator;
|
|
7180
|
+
/**
|
|
7181
|
+
* Determines whether a path starts with a URL scheme (e.g. starts with `http://`, `ftp://`, `file://`, etc.).
|
|
7182
|
+
*/
|
|
7183
|
+
function isUrl(path) {
|
|
7184
|
+
return getEncodedRootLength(path) < 0;
|
|
7185
|
+
}
|
|
7186
|
+
ts.isUrl = isUrl;
|
|
7187
|
+
/**
|
|
7188
|
+
* Determines whether a path is an absolute disk path (e.g. starts with `/`, or a dos path
|
|
7189
|
+
* like `c:`, `c:\` or `c:/`).
|
|
7190
|
+
*/
|
|
7191
|
+
function isRootedDiskPath(path) {
|
|
7192
|
+
return getEncodedRootLength(path) > 0;
|
|
7193
|
+
}
|
|
7194
|
+
ts.isRootedDiskPath = isRootedDiskPath;
|
|
7195
|
+
/**
|
|
7196
|
+
* Determines whether a path consists only of a path root.
|
|
7197
|
+
*/
|
|
7198
|
+
function isDiskPathRoot(path) {
|
|
7199
|
+
var rootLength = getEncodedRootLength(path);
|
|
7200
|
+
return rootLength > 0 && rootLength === path.length;
|
|
7201
|
+
}
|
|
7202
|
+
ts.isDiskPathRoot = isDiskPathRoot;
|
|
7203
|
+
/**
|
|
7204
|
+
* Determines whether a path starts with an absolute path component (i.e. `/`, `c:/`, `file://`, etc.).
|
|
7205
|
+
*
|
|
7206
|
+
* ```ts
|
|
7207
|
+
* // POSIX
|
|
7208
|
+
* pathIsAbsolute("/path/to/file.ext") === true
|
|
7209
|
+
* // DOS
|
|
7210
|
+
* pathIsAbsolute("c:/path/to/file.ext") === true
|
|
7211
|
+
* // URL
|
|
7212
|
+
* pathIsAbsolute("file:///path/to/file.ext") === true
|
|
7213
|
+
* // Non-absolute
|
|
7214
|
+
* pathIsAbsolute("path/to/file.ext") === false
|
|
7215
|
+
* pathIsAbsolute("./path/to/file.ext") === false
|
|
7216
|
+
* ```
|
|
7217
|
+
*/
|
|
7218
|
+
function pathIsAbsolute(path) {
|
|
7219
|
+
return getEncodedRootLength(path) !== 0;
|
|
7220
|
+
}
|
|
7221
|
+
ts.pathIsAbsolute = pathIsAbsolute;
|
|
7222
|
+
/**
|
|
7223
|
+
* Determines whether a path starts with a relative path component (i.e. `.` or `..`).
|
|
7224
|
+
*/
|
|
7225
|
+
function pathIsRelative(path) {
|
|
7226
|
+
return /^\.\.?($|[\\/])/.test(path);
|
|
7227
|
+
}
|
|
7228
|
+
ts.pathIsRelative = pathIsRelative;
|
|
7229
|
+
/**
|
|
7230
|
+
* Determines whether a path is neither relative nor absolute, e.g. "path/to/file".
|
|
7231
|
+
* Also known misleadingly as "non-relative".
|
|
7232
|
+
*/
|
|
7233
|
+
function pathIsBareSpecifier(path) {
|
|
7234
|
+
return !pathIsAbsolute(path) && !pathIsRelative(path);
|
|
7235
|
+
}
|
|
7236
|
+
ts.pathIsBareSpecifier = pathIsBareSpecifier;
|
|
7237
|
+
function hasExtension(fileName) {
|
|
7238
|
+
return ts.stringContains(getBaseFileName(fileName), ".");
|
|
7239
|
+
}
|
|
7240
|
+
ts.hasExtension = hasExtension;
|
|
7241
|
+
function fileExtensionIs(path, extension) {
|
|
7242
|
+
return path.length > extension.length && ts.endsWith(path, extension);
|
|
7243
|
+
}
|
|
7244
|
+
ts.fileExtensionIs = fileExtensionIs;
|
|
7245
|
+
function fileExtensionIsOneOf(path, extensions) {
|
|
7246
|
+
for (var _i = 0, extensions_1 = extensions; _i < extensions_1.length; _i++) {
|
|
7247
|
+
var extension = extensions_1[_i];
|
|
7248
|
+
if (fileExtensionIs(path, extension)) {
|
|
7249
|
+
return true;
|
|
7250
|
+
}
|
|
7251
|
+
}
|
|
7252
|
+
return false;
|
|
7253
|
+
}
|
|
7254
|
+
ts.fileExtensionIsOneOf = fileExtensionIsOneOf;
|
|
7255
|
+
/**
|
|
7256
|
+
* Determines whether a path has a trailing separator (`/` or `\\`).
|
|
7257
|
+
*/
|
|
7258
|
+
function hasTrailingDirectorySeparator(path) {
|
|
7259
|
+
return path.length > 0 && isAnyDirectorySeparator(path.charCodeAt(path.length - 1));
|
|
7260
|
+
}
|
|
7261
|
+
ts.hasTrailingDirectorySeparator = hasTrailingDirectorySeparator;
|
|
7262
|
+
//// Path Parsing
|
|
7263
|
+
function isVolumeCharacter(charCode) {
|
|
7264
|
+
return (charCode >= 97 /* a */ && charCode <= 122 /* z */) ||
|
|
7265
|
+
(charCode >= 65 /* A */ && charCode <= 90 /* Z */);
|
|
7266
|
+
}
|
|
7267
|
+
function getFileUrlVolumeSeparatorEnd(url, start) {
|
|
7268
|
+
var ch0 = url.charCodeAt(start);
|
|
7269
|
+
if (ch0 === 58 /* colon */)
|
|
7270
|
+
return start + 1;
|
|
7271
|
+
if (ch0 === 37 /* percent */ && url.charCodeAt(start + 1) === 51 /* _3 */) {
|
|
7272
|
+
var ch2 = url.charCodeAt(start + 2);
|
|
7273
|
+
if (ch2 === 97 /* a */ || ch2 === 65 /* A */)
|
|
7274
|
+
return start + 3;
|
|
7275
|
+
}
|
|
7276
|
+
return -1;
|
|
7277
|
+
}
|
|
7278
|
+
/**
|
|
7279
|
+
* Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
|
|
7280
|
+
* If the root is part of a URL, the twos-complement of the root length is returned.
|
|
7281
|
+
*/
|
|
7282
|
+
function getEncodedRootLength(path) {
|
|
7283
|
+
if (!path)
|
|
7284
|
+
return 0;
|
|
7285
|
+
var ch0 = path.charCodeAt(0);
|
|
7286
|
+
// POSIX or UNC
|
|
7287
|
+
if (ch0 === 47 /* slash */ || ch0 === 92 /* backslash */) {
|
|
7288
|
+
if (path.charCodeAt(1) !== ch0)
|
|
7289
|
+
return 1; // POSIX: "/" (or non-normalized "\")
|
|
7290
|
+
var p1 = path.indexOf(ch0 === 47 /* slash */ ? ts.directorySeparator : ts.altDirectorySeparator, 2);
|
|
7291
|
+
if (p1 < 0)
|
|
7292
|
+
return path.length; // UNC: "//server" or "\\server"
|
|
7293
|
+
return p1 + 1; // UNC: "//server/" or "\\server\"
|
|
7294
|
+
}
|
|
7295
|
+
// DOS
|
|
7296
|
+
if (isVolumeCharacter(ch0) && path.charCodeAt(1) === 58 /* colon */) {
|
|
7297
|
+
var ch2 = path.charCodeAt(2);
|
|
7298
|
+
if (ch2 === 47 /* slash */ || ch2 === 92 /* backslash */)
|
|
7299
|
+
return 3; // DOS: "c:/" or "c:\"
|
|
7300
|
+
if (path.length === 2)
|
|
7301
|
+
return 2; // DOS: "c:" (but not "c:d")
|
|
7302
|
+
}
|
|
7303
|
+
// URL
|
|
7304
|
+
var schemeEnd = path.indexOf(urlSchemeSeparator);
|
|
7305
|
+
if (schemeEnd !== -1) {
|
|
7306
|
+
var authorityStart = schemeEnd + urlSchemeSeparator.length;
|
|
7307
|
+
var authorityEnd = path.indexOf(ts.directorySeparator, authorityStart);
|
|
7308
|
+
if (authorityEnd !== -1) { // URL: "file:///", "file://server/", "file://server/path"
|
|
7309
|
+
// For local "file" URLs, include the leading DOS volume (if present).
|
|
7310
|
+
// Per https://www.ietf.org/rfc/rfc1738.txt, a host of "" or "localhost" is a
|
|
7311
|
+
// special case interpreted as "the machine from which the URL is being interpreted".
|
|
7312
|
+
var scheme = path.slice(0, schemeEnd);
|
|
7313
|
+
var authority = path.slice(authorityStart, authorityEnd);
|
|
7314
|
+
if (scheme === "file" && (authority === "" || authority === "localhost") &&
|
|
7315
|
+
isVolumeCharacter(path.charCodeAt(authorityEnd + 1))) {
|
|
7316
|
+
var volumeSeparatorEnd = getFileUrlVolumeSeparatorEnd(path, authorityEnd + 2);
|
|
7317
|
+
if (volumeSeparatorEnd !== -1) {
|
|
7318
|
+
if (path.charCodeAt(volumeSeparatorEnd) === 47 /* slash */) {
|
|
7319
|
+
// URL: "file:///c:/", "file://localhost/c:/", "file:///c%3a/", "file://localhost/c%3a/"
|
|
7320
|
+
return ~(volumeSeparatorEnd + 1);
|
|
7321
|
+
}
|
|
7322
|
+
if (volumeSeparatorEnd === path.length) {
|
|
7323
|
+
// URL: "file:///c:", "file://localhost/c:", "file:///c$3a", "file://localhost/c%3a"
|
|
7324
|
+
// but not "file:///c:d" or "file:///c%3ad"
|
|
7325
|
+
return ~volumeSeparatorEnd;
|
|
7326
|
+
}
|
|
7327
|
+
}
|
|
7328
|
+
}
|
|
7329
|
+
return ~(authorityEnd + 1); // URL: "file://server/", "http://server/"
|
|
7330
|
+
}
|
|
7331
|
+
return ~path.length; // URL: "file://server", "http://server"
|
|
7332
|
+
}
|
|
7333
|
+
// relative
|
|
7334
|
+
return 0;
|
|
7335
|
+
}
|
|
7336
|
+
/**
|
|
7337
|
+
* Returns length of the root part of a path or URL (i.e. length of "/", "x:/", "//server/share/, file:///user/files").
|
|
7338
|
+
*
|
|
7339
|
+
* For example:
|
|
7340
|
+
* ```ts
|
|
7341
|
+
* getRootLength("a") === 0 // ""
|
|
7342
|
+
* getRootLength("/") === 1 // "/"
|
|
7343
|
+
* getRootLength("c:") === 2 // "c:"
|
|
7344
|
+
* getRootLength("c:d") === 0 // ""
|
|
7345
|
+
* getRootLength("c:/") === 3 // "c:/"
|
|
7346
|
+
* getRootLength("c:\\") === 3 // "c:\\"
|
|
7347
|
+
* getRootLength("//server") === 7 // "//server"
|
|
7348
|
+
* getRootLength("//server/share") === 8 // "//server/"
|
|
7349
|
+
* getRootLength("\\\\server") === 7 // "\\\\server"
|
|
7350
|
+
* getRootLength("\\\\server\\share") === 8 // "\\\\server\\"
|
|
7351
|
+
* getRootLength("file:///path") === 8 // "file:///"
|
|
7352
|
+
* getRootLength("file:///c:") === 10 // "file:///c:"
|
|
7353
|
+
* getRootLength("file:///c:d") === 8 // "file:///"
|
|
7354
|
+
* getRootLength("file:///c:/path") === 11 // "file:///c:/"
|
|
7355
|
+
* getRootLength("file://server") === 13 // "file://server"
|
|
7356
|
+
* getRootLength("file://server/path") === 14 // "file://server/"
|
|
7357
|
+
* getRootLength("http://server") === 13 // "http://server"
|
|
7358
|
+
* getRootLength("http://server/path") === 14 // "http://server/"
|
|
7359
|
+
* ```
|
|
7360
|
+
*/
|
|
7361
|
+
function getRootLength(path) {
|
|
7362
|
+
var rootLength = getEncodedRootLength(path);
|
|
7363
|
+
return rootLength < 0 ? ~rootLength : rootLength;
|
|
7364
|
+
}
|
|
7365
|
+
ts.getRootLength = getRootLength;
|
|
7366
|
+
function getDirectoryPath(path) {
|
|
7367
|
+
path = normalizeSlashes(path);
|
|
7368
|
+
// If the path provided is itself the root, then return it.
|
|
7369
|
+
var rootLength = getRootLength(path);
|
|
7370
|
+
if (rootLength === path.length)
|
|
7371
|
+
return path;
|
|
7372
|
+
// return the leading portion of the path up to the last (non-terminal) directory separator
|
|
7373
|
+
// but not including any trailing directory separator.
|
|
7374
|
+
path = removeTrailingDirectorySeparator(path);
|
|
7375
|
+
return path.slice(0, Math.max(rootLength, path.lastIndexOf(ts.directorySeparator)));
|
|
7376
|
+
}
|
|
7377
|
+
ts.getDirectoryPath = getDirectoryPath;
|
|
7378
|
+
function getBaseFileName(path, extensions, ignoreCase) {
|
|
7379
|
+
path = normalizeSlashes(path);
|
|
7380
|
+
// if the path provided is itself the root, then it has not file name.
|
|
7381
|
+
var rootLength = getRootLength(path);
|
|
7382
|
+
if (rootLength === path.length)
|
|
7383
|
+
return "";
|
|
7384
|
+
// return the trailing portion of the path starting after the last (non-terminal) directory
|
|
7385
|
+
// separator but not including any trailing directory separator.
|
|
7386
|
+
path = removeTrailingDirectorySeparator(path);
|
|
7387
|
+
var name = path.slice(Math.max(getRootLength(path), path.lastIndexOf(ts.directorySeparator) + 1));
|
|
7388
|
+
var extension = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(name, extensions, ignoreCase) : undefined;
|
|
7389
|
+
return extension ? name.slice(0, name.length - extension.length) : name;
|
|
7390
|
+
}
|
|
7391
|
+
ts.getBaseFileName = getBaseFileName;
|
|
7392
|
+
function tryGetExtensionFromPath(path, extension, stringEqualityComparer) {
|
|
7393
|
+
if (!ts.startsWith(extension, "."))
|
|
7394
|
+
extension = "." + extension;
|
|
7395
|
+
if (path.length >= extension.length && path.charCodeAt(path.length - extension.length) === 46 /* dot */) {
|
|
7396
|
+
var pathExtension = path.slice(path.length - extension.length);
|
|
7397
|
+
if (stringEqualityComparer(pathExtension, extension)) {
|
|
7398
|
+
return pathExtension;
|
|
7399
|
+
}
|
|
7400
|
+
}
|
|
7401
|
+
}
|
|
7402
|
+
function getAnyExtensionFromPathWorker(path, extensions, stringEqualityComparer) {
|
|
7403
|
+
if (typeof extensions === "string") {
|
|
7404
|
+
return tryGetExtensionFromPath(path, extensions, stringEqualityComparer) || "";
|
|
7405
|
+
}
|
|
7406
|
+
for (var _i = 0, extensions_2 = extensions; _i < extensions_2.length; _i++) {
|
|
7407
|
+
var extension = extensions_2[_i];
|
|
7408
|
+
var result = tryGetExtensionFromPath(path, extension, stringEqualityComparer);
|
|
7409
|
+
if (result)
|
|
7410
|
+
return result;
|
|
7411
|
+
}
|
|
7412
|
+
return "";
|
|
7413
|
+
}
|
|
7414
|
+
function getAnyExtensionFromPath(path, extensions, ignoreCase) {
|
|
7415
|
+
// Retrieves any string from the final "." onwards from a base file name.
|
|
7416
|
+
// Unlike extensionFromPath, which throws an exception on unrecognized extensions.
|
|
7417
|
+
if (extensions) {
|
|
7418
|
+
return getAnyExtensionFromPathWorker(removeTrailingDirectorySeparator(path), extensions, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive);
|
|
7419
|
+
}
|
|
7420
|
+
var baseFileName = getBaseFileName(path);
|
|
7421
|
+
var extensionIndex = baseFileName.lastIndexOf(".");
|
|
7422
|
+
if (extensionIndex >= 0) {
|
|
7423
|
+
return baseFileName.substring(extensionIndex);
|
|
7424
|
+
}
|
|
7425
|
+
return "";
|
|
7426
|
+
}
|
|
7427
|
+
ts.getAnyExtensionFromPath = getAnyExtensionFromPath;
|
|
7428
|
+
function pathComponents(path, rootLength) {
|
|
7429
|
+
var root = path.substring(0, rootLength);
|
|
7430
|
+
var rest = path.substring(rootLength).split(ts.directorySeparator);
|
|
7431
|
+
if (rest.length && !ts.lastOrUndefined(rest))
|
|
7432
|
+
rest.pop();
|
|
7433
|
+
return __spreadArray([root], rest, true);
|
|
7434
|
+
}
|
|
7435
|
+
/**
|
|
7436
|
+
* Parse a path into an array containing a root component (at index 0) and zero or more path
|
|
7437
|
+
* components (at indices > 0). The result is not normalized.
|
|
7438
|
+
* If the path is relative, the root component is `""`.
|
|
7439
|
+
* If the path is absolute, the root component includes the first path separator (`/`).
|
|
7440
|
+
*
|
|
7441
|
+
* ```ts
|
|
7442
|
+
* // POSIX
|
|
7443
|
+
* getPathComponents("/path/to/file.ext") === ["/", "path", "to", "file.ext"]
|
|
7444
|
+
* getPathComponents("/path/to/") === ["/", "path", "to"]
|
|
7445
|
+
* getPathComponents("/") === ["/"]
|
|
7446
|
+
* // DOS
|
|
7447
|
+
* getPathComponents("c:/path/to/file.ext") === ["c:/", "path", "to", "file.ext"]
|
|
7448
|
+
* getPathComponents("c:/path/to/") === ["c:/", "path", "to"]
|
|
7449
|
+
* getPathComponents("c:/") === ["c:/"]
|
|
7450
|
+
* getPathComponents("c:") === ["c:"]
|
|
7451
|
+
* // URL
|
|
7452
|
+
* getPathComponents("http://typescriptlang.org/path/to/file.ext") === ["http://typescriptlang.org/", "path", "to", "file.ext"]
|
|
7453
|
+
* getPathComponents("http://typescriptlang.org/path/to/") === ["http://typescriptlang.org/", "path", "to"]
|
|
7454
|
+
* getPathComponents("http://typescriptlang.org/") === ["http://typescriptlang.org/"]
|
|
7455
|
+
* getPathComponents("http://typescriptlang.org") === ["http://typescriptlang.org"]
|
|
7456
|
+
* getPathComponents("file://server/path/to/file.ext") === ["file://server/", "path", "to", "file.ext"]
|
|
7457
|
+
* getPathComponents("file://server/path/to/") === ["file://server/", "path", "to"]
|
|
7458
|
+
* getPathComponents("file://server/") === ["file://server/"]
|
|
7459
|
+
* getPathComponents("file://server") === ["file://server"]
|
|
7460
|
+
* getPathComponents("file:///path/to/file.ext") === ["file:///", "path", "to", "file.ext"]
|
|
7461
|
+
* getPathComponents("file:///path/to/") === ["file:///", "path", "to"]
|
|
7462
|
+
* getPathComponents("file:///") === ["file:///"]
|
|
7463
|
+
* getPathComponents("file://") === ["file://"]
|
|
7464
|
+
*/
|
|
7465
|
+
function getPathComponents(path, currentDirectory) {
|
|
7466
|
+
if (currentDirectory === void 0) { currentDirectory = ""; }
|
|
7467
|
+
path = combinePaths(currentDirectory, path);
|
|
7468
|
+
return pathComponents(path, getRootLength(path));
|
|
7469
|
+
}
|
|
7470
|
+
ts.getPathComponents = getPathComponents;
|
|
7471
|
+
//// Path Formatting
|
|
7472
|
+
/**
|
|
7473
|
+
* Formats a parsed path consisting of a root component (at index 0) and zero or more path
|
|
7474
|
+
* segments (at indices > 0).
|
|
7475
|
+
*
|
|
7476
|
+
* ```ts
|
|
7477
|
+
* getPathFromPathComponents(["/", "path", "to", "file.ext"]) === "/path/to/file.ext"
|
|
7478
|
+
* ```
|
|
7479
|
+
*/
|
|
7480
|
+
function getPathFromPathComponents(pathComponents) {
|
|
7481
|
+
if (pathComponents.length === 0)
|
|
7482
|
+
return "";
|
|
7483
|
+
var root = pathComponents[0] && ensureTrailingDirectorySeparator(pathComponents[0]);
|
|
7484
|
+
return root + pathComponents.slice(1).join(ts.directorySeparator);
|
|
7485
|
+
}
|
|
7486
|
+
ts.getPathFromPathComponents = getPathFromPathComponents;
|
|
7487
|
+
//// Path Normalization
|
|
7488
|
+
/**
|
|
7489
|
+
* Normalize path separators, converting `\` into `/`.
|
|
7490
|
+
*/
|
|
7491
|
+
function normalizeSlashes(path) {
|
|
7492
|
+
var index = path.indexOf("\\");
|
|
7493
|
+
if (index === -1) {
|
|
7494
|
+
return path;
|
|
7495
|
+
}
|
|
7496
|
+
backslashRegExp.lastIndex = index; // prime regex with known position
|
|
7497
|
+
return path.replace(backslashRegExp, ts.directorySeparator);
|
|
7498
|
+
}
|
|
7499
|
+
ts.normalizeSlashes = normalizeSlashes;
|
|
7500
|
+
/**
|
|
7501
|
+
* Reduce an array of path components to a more simplified path by navigating any
|
|
7502
|
+
* `"."` or `".."` entries in the path.
|
|
7503
|
+
*/
|
|
7504
|
+
function reducePathComponents(components) {
|
|
7505
|
+
if (!ts.some(components))
|
|
7506
|
+
return [];
|
|
7507
|
+
var reduced = [components[0]];
|
|
7508
|
+
for (var i = 1; i < components.length; i++) {
|
|
7509
|
+
var component = components[i];
|
|
7510
|
+
if (!component)
|
|
7511
|
+
continue;
|
|
7512
|
+
if (component === ".")
|
|
7513
|
+
continue;
|
|
7514
|
+
if (component === "..") {
|
|
7515
|
+
if (reduced.length > 1) {
|
|
7516
|
+
if (reduced[reduced.length - 1] !== "..") {
|
|
7517
|
+
reduced.pop();
|
|
7518
|
+
continue;
|
|
7519
|
+
}
|
|
7520
|
+
}
|
|
7521
|
+
else if (reduced[0])
|
|
7522
|
+
continue;
|
|
7523
|
+
}
|
|
7524
|
+
reduced.push(component);
|
|
7525
|
+
}
|
|
7526
|
+
return reduced;
|
|
7527
|
+
}
|
|
7528
|
+
ts.reducePathComponents = reducePathComponents;
|
|
7529
|
+
/**
|
|
7530
|
+
* Combines paths. If a path is absolute, it replaces any previous path. Relative paths are not simplified.
|
|
7531
|
+
*
|
|
7532
|
+
* ```ts
|
|
7533
|
+
* // Non-rooted
|
|
7534
|
+
* combinePaths("path", "to", "file.ext") === "path/to/file.ext"
|
|
7535
|
+
* combinePaths("path", "dir", "..", "to", "file.ext") === "path/dir/../to/file.ext"
|
|
7536
|
+
* // POSIX
|
|
7537
|
+
* combinePaths("/path", "to", "file.ext") === "/path/to/file.ext"
|
|
7538
|
+
* combinePaths("/path", "/to", "file.ext") === "/to/file.ext"
|
|
7539
|
+
* // DOS
|
|
7540
|
+
* combinePaths("c:/path", "to", "file.ext") === "c:/path/to/file.ext"
|
|
7541
|
+
* combinePaths("c:/path", "c:/to", "file.ext") === "c:/to/file.ext"
|
|
7542
|
+
* // URL
|
|
7543
|
+
* combinePaths("file:///path", "to", "file.ext") === "file:///path/to/file.ext"
|
|
7544
|
+
* combinePaths("file:///path", "file:///to", "file.ext") === "file:///to/file.ext"
|
|
7545
|
+
* ```
|
|
7546
|
+
*/
|
|
7547
|
+
function combinePaths(path) {
|
|
7548
|
+
var paths = [];
|
|
7549
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
7550
|
+
paths[_i - 1] = arguments[_i];
|
|
7551
|
+
}
|
|
7552
|
+
if (path)
|
|
7553
|
+
path = normalizeSlashes(path);
|
|
7554
|
+
for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
|
|
7555
|
+
var relativePath = paths_1[_a];
|
|
7556
|
+
if (!relativePath)
|
|
7557
|
+
continue;
|
|
7558
|
+
relativePath = normalizeSlashes(relativePath);
|
|
7559
|
+
if (!path || getRootLength(relativePath) !== 0) {
|
|
7560
|
+
path = relativePath;
|
|
7561
|
+
}
|
|
7562
|
+
else {
|
|
7563
|
+
path = ensureTrailingDirectorySeparator(path) + relativePath;
|
|
7564
|
+
}
|
|
7565
|
+
}
|
|
7566
|
+
return path;
|
|
7567
|
+
}
|
|
7568
|
+
ts.combinePaths = combinePaths;
|
|
7569
|
+
/**
|
|
7570
|
+
* Combines and resolves paths. If a path is absolute, it replaces any previous path. Any
|
|
7571
|
+
* `.` and `..` path components are resolved. Trailing directory separators are preserved.
|
|
7572
|
+
*
|
|
7573
|
+
* ```ts
|
|
7574
|
+
* resolvePath("/path", "to", "file.ext") === "path/to/file.ext"
|
|
7575
|
+
* resolvePath("/path", "to", "file.ext/") === "path/to/file.ext/"
|
|
7576
|
+
* resolvePath("/path", "dir", "..", "to", "file.ext") === "path/to/file.ext"
|
|
7577
|
+
* ```
|
|
7578
|
+
*/
|
|
7579
|
+
function resolvePath(path) {
|
|
7580
|
+
var paths = [];
|
|
7581
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
7582
|
+
paths[_i - 1] = arguments[_i];
|
|
7583
|
+
}
|
|
7584
|
+
return normalizePath(ts.some(paths) ? combinePaths.apply(void 0, __spreadArray([path], paths, false)) : normalizeSlashes(path));
|
|
7585
|
+
}
|
|
7586
|
+
ts.resolvePath = resolvePath;
|
|
7587
|
+
/**
|
|
7588
|
+
* Parse a path into an array containing a root component (at index 0) and zero or more path
|
|
7589
|
+
* components (at indices > 0). The result is normalized.
|
|
7590
|
+
* If the path is relative, the root component is `""`.
|
|
7591
|
+
* If the path is absolute, the root component includes the first path separator (`/`).
|
|
7592
|
+
*
|
|
7593
|
+
* ```ts
|
|
7594
|
+
* getNormalizedPathComponents("to/dir/../file.ext", "/path/") === ["/", "path", "to", "file.ext"]
|
|
7595
|
+
* ```
|
|
7596
|
+
*/
|
|
7597
|
+
function getNormalizedPathComponents(path, currentDirectory) {
|
|
7598
|
+
return reducePathComponents(getPathComponents(path, currentDirectory));
|
|
7599
|
+
}
|
|
7600
|
+
ts.getNormalizedPathComponents = getNormalizedPathComponents;
|
|
7601
|
+
function getNormalizedAbsolutePath(fileName, currentDirectory) {
|
|
7602
|
+
return getPathFromPathComponents(getNormalizedPathComponents(fileName, currentDirectory));
|
|
7603
|
+
}
|
|
7604
|
+
ts.getNormalizedAbsolutePath = getNormalizedAbsolutePath;
|
|
7605
|
+
function normalizePath(path) {
|
|
7606
|
+
path = normalizeSlashes(path);
|
|
7607
|
+
// Most paths don't require normalization
|
|
7608
|
+
if (!relativePathSegmentRegExp.test(path)) {
|
|
7609
|
+
return path;
|
|
7610
|
+
}
|
|
7611
|
+
// Some paths only require cleanup of `/./` or leading `./`
|
|
7612
|
+
var simplified = path.replace(/\/\.\//g, "/").replace(/^\.\//, "");
|
|
7613
|
+
if (simplified !== path) {
|
|
7614
|
+
path = simplified;
|
|
7615
|
+
if (!relativePathSegmentRegExp.test(path)) {
|
|
7616
|
+
return path;
|
|
7617
|
+
}
|
|
7618
|
+
}
|
|
7619
|
+
// Other paths require full normalization
|
|
7620
|
+
var normalized = getPathFromPathComponents(reducePathComponents(getPathComponents(path)));
|
|
7621
|
+
return normalized && hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(normalized) : normalized;
|
|
7622
|
+
}
|
|
7623
|
+
ts.normalizePath = normalizePath;
|
|
7624
|
+
function getPathWithoutRoot(pathComponents) {
|
|
7625
|
+
if (pathComponents.length === 0)
|
|
7626
|
+
return "";
|
|
7627
|
+
return pathComponents.slice(1).join(ts.directorySeparator);
|
|
7628
|
+
}
|
|
7629
|
+
function getNormalizedAbsolutePathWithoutRoot(fileName, currentDirectory) {
|
|
7630
|
+
return getPathWithoutRoot(getNormalizedPathComponents(fileName, currentDirectory));
|
|
7631
|
+
}
|
|
7632
|
+
ts.getNormalizedAbsolutePathWithoutRoot = getNormalizedAbsolutePathWithoutRoot;
|
|
7633
|
+
function toPath(fileName, basePath, getCanonicalFileName) {
|
|
7634
|
+
var nonCanonicalizedPath = isRootedDiskPath(fileName)
|
|
7635
|
+
? normalizePath(fileName)
|
|
7636
|
+
: getNormalizedAbsolutePath(fileName, basePath);
|
|
7637
|
+
return getCanonicalFileName(nonCanonicalizedPath);
|
|
7638
|
+
}
|
|
7639
|
+
ts.toPath = toPath;
|
|
7640
|
+
function normalizePathAndParts(path) {
|
|
7641
|
+
path = normalizeSlashes(path);
|
|
7642
|
+
var _a = reducePathComponents(getPathComponents(path)), root = _a[0], parts = _a.slice(1);
|
|
7643
|
+
if (parts.length) {
|
|
7644
|
+
var joinedParts = root + parts.join(ts.directorySeparator);
|
|
7645
|
+
return { path: hasTrailingDirectorySeparator(path) ? ensureTrailingDirectorySeparator(joinedParts) : joinedParts, parts: parts };
|
|
7646
|
+
}
|
|
7647
|
+
else {
|
|
7648
|
+
return { path: root, parts: parts };
|
|
7649
|
+
}
|
|
7650
|
+
}
|
|
7651
|
+
ts.normalizePathAndParts = normalizePathAndParts;
|
|
7652
|
+
function removeTrailingDirectorySeparator(path) {
|
|
7653
|
+
if (hasTrailingDirectorySeparator(path)) {
|
|
7654
|
+
return path.substr(0, path.length - 1);
|
|
7655
|
+
}
|
|
7656
|
+
return path;
|
|
7657
|
+
}
|
|
7658
|
+
ts.removeTrailingDirectorySeparator = removeTrailingDirectorySeparator;
|
|
7659
|
+
function ensureTrailingDirectorySeparator(path) {
|
|
7660
|
+
if (!hasTrailingDirectorySeparator(path)) {
|
|
7661
|
+
return path + ts.directorySeparator;
|
|
7662
|
+
}
|
|
7663
|
+
return path;
|
|
7664
|
+
}
|
|
7665
|
+
ts.ensureTrailingDirectorySeparator = ensureTrailingDirectorySeparator;
|
|
7666
|
+
/**
|
|
7667
|
+
* Ensures a path is either absolute (prefixed with `/` or `c:`) or dot-relative (prefixed
|
|
7668
|
+
* with `./` or `../`) so as not to be confused with an unprefixed module name.
|
|
7669
|
+
*
|
|
7670
|
+
* ```ts
|
|
7671
|
+
* ensurePathIsNonModuleName("/path/to/file.ext") === "/path/to/file.ext"
|
|
7672
|
+
* ensurePathIsNonModuleName("./path/to/file.ext") === "./path/to/file.ext"
|
|
7673
|
+
* ensurePathIsNonModuleName("../path/to/file.ext") === "../path/to/file.ext"
|
|
7674
|
+
* ensurePathIsNonModuleName("path/to/file.ext") === "./path/to/file.ext"
|
|
7675
|
+
* ```
|
|
7676
|
+
*/
|
|
7677
|
+
function ensurePathIsNonModuleName(path) {
|
|
7678
|
+
return !pathIsAbsolute(path) && !pathIsRelative(path) ? "./" + path : path;
|
|
7679
|
+
}
|
|
7680
|
+
ts.ensurePathIsNonModuleName = ensurePathIsNonModuleName;
|
|
7681
|
+
function changeAnyExtension(path, ext, extensions, ignoreCase) {
|
|
7682
|
+
var pathext = extensions !== undefined && ignoreCase !== undefined ? getAnyExtensionFromPath(path, extensions, ignoreCase) : getAnyExtensionFromPath(path);
|
|
7683
|
+
return pathext ? path.slice(0, path.length - pathext.length) + (ts.startsWith(ext, ".") ? ext : "." + ext) : path;
|
|
7684
|
+
}
|
|
7685
|
+
ts.changeAnyExtension = changeAnyExtension;
|
|
7686
|
+
//// Path Comparisons
|
|
7687
|
+
// check path for these segments: '', '.'. '..'
|
|
7688
|
+
var relativePathSegmentRegExp = /(?:\/\/)|(?:^|\/)\.\.?(?:$|\/)/;
|
|
7689
|
+
function comparePathsWorker(a, b, componentComparer) {
|
|
7690
|
+
if (a === b)
|
|
7691
|
+
return 0 /* EqualTo */;
|
|
7692
|
+
if (a === undefined)
|
|
7693
|
+
return -1 /* LessThan */;
|
|
7694
|
+
if (b === undefined)
|
|
7695
|
+
return 1 /* GreaterThan */;
|
|
7696
|
+
// NOTE: Performance optimization - shortcut if the root segments differ as there would be no
|
|
7697
|
+
// need to perform path reduction.
|
|
7698
|
+
var aRoot = a.substring(0, getRootLength(a));
|
|
7699
|
+
var bRoot = b.substring(0, getRootLength(b));
|
|
7700
|
+
var result = ts.compareStringsCaseInsensitive(aRoot, bRoot);
|
|
7701
|
+
if (result !== 0 /* EqualTo */) {
|
|
7702
|
+
return result;
|
|
7703
|
+
}
|
|
7704
|
+
// NOTE: Performance optimization - shortcut if there are no relative path segments in
|
|
7705
|
+
// the non-root portion of the path
|
|
7706
|
+
var aRest = a.substring(aRoot.length);
|
|
7707
|
+
var bRest = b.substring(bRoot.length);
|
|
7708
|
+
if (!relativePathSegmentRegExp.test(aRest) && !relativePathSegmentRegExp.test(bRest)) {
|
|
7709
|
+
return componentComparer(aRest, bRest);
|
|
7710
|
+
}
|
|
7711
|
+
// The path contains a relative path segment. Normalize the paths and perform a slower component
|
|
7712
|
+
// by component comparison.
|
|
7713
|
+
var aComponents = reducePathComponents(getPathComponents(a));
|
|
7714
|
+
var bComponents = reducePathComponents(getPathComponents(b));
|
|
7715
|
+
var sharedLength = Math.min(aComponents.length, bComponents.length);
|
|
7716
|
+
for (var i = 1; i < sharedLength; i++) {
|
|
7717
|
+
var result_2 = componentComparer(aComponents[i], bComponents[i]);
|
|
7718
|
+
if (result_2 !== 0 /* EqualTo */) {
|
|
7719
|
+
return result_2;
|
|
7720
|
+
}
|
|
7721
|
+
}
|
|
7722
|
+
return ts.compareValues(aComponents.length, bComponents.length);
|
|
7723
|
+
}
|
|
7724
|
+
/**
|
|
7725
|
+
* Performs a case-sensitive comparison of two paths. Path roots are always compared case-insensitively.
|
|
7726
|
+
*/
|
|
7727
|
+
function comparePathsCaseSensitive(a, b) {
|
|
7728
|
+
return comparePathsWorker(a, b, ts.compareStringsCaseSensitive);
|
|
7729
|
+
}
|
|
7730
|
+
ts.comparePathsCaseSensitive = comparePathsCaseSensitive;
|
|
7731
|
+
/**
|
|
7732
|
+
* Performs a case-insensitive comparison of two paths.
|
|
7733
|
+
*/
|
|
7734
|
+
function comparePathsCaseInsensitive(a, b) {
|
|
7735
|
+
return comparePathsWorker(a, b, ts.compareStringsCaseInsensitive);
|
|
7736
|
+
}
|
|
7737
|
+
ts.comparePathsCaseInsensitive = comparePathsCaseInsensitive;
|
|
7738
|
+
function comparePaths(a, b, currentDirectory, ignoreCase) {
|
|
7739
|
+
if (typeof currentDirectory === "string") {
|
|
7740
|
+
a = combinePaths(currentDirectory, a);
|
|
7741
|
+
b = combinePaths(currentDirectory, b);
|
|
7742
|
+
}
|
|
7743
|
+
else if (typeof currentDirectory === "boolean") {
|
|
7744
|
+
ignoreCase = currentDirectory;
|
|
7745
|
+
}
|
|
7746
|
+
return comparePathsWorker(a, b, ts.getStringComparer(ignoreCase));
|
|
7747
|
+
}
|
|
7748
|
+
ts.comparePaths = comparePaths;
|
|
7749
|
+
function containsPath(parent, child, currentDirectory, ignoreCase) {
|
|
7750
|
+
if (typeof currentDirectory === "string") {
|
|
7751
|
+
parent = combinePaths(currentDirectory, parent);
|
|
7752
|
+
child = combinePaths(currentDirectory, child);
|
|
7753
|
+
}
|
|
7754
|
+
else if (typeof currentDirectory === "boolean") {
|
|
7755
|
+
ignoreCase = currentDirectory;
|
|
7756
|
+
}
|
|
7757
|
+
if (parent === undefined || child === undefined)
|
|
7758
|
+
return false;
|
|
7759
|
+
if (parent === child)
|
|
7760
|
+
return true;
|
|
7761
|
+
var parentComponents = reducePathComponents(getPathComponents(parent));
|
|
7762
|
+
var childComponents = reducePathComponents(getPathComponents(child));
|
|
7763
|
+
if (childComponents.length < parentComponents.length) {
|
|
7764
|
+
return false;
|
|
7765
|
+
}
|
|
7766
|
+
var componentEqualityComparer = ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive;
|
|
7767
|
+
for (var i = 0; i < parentComponents.length; i++) {
|
|
7768
|
+
var equalityComparer = i === 0 ? ts.equateStringsCaseInsensitive : componentEqualityComparer;
|
|
7769
|
+
if (!equalityComparer(parentComponents[i], childComponents[i])) {
|
|
7770
|
+
return false;
|
|
7771
|
+
}
|
|
7772
|
+
}
|
|
7773
|
+
return true;
|
|
7774
|
+
}
|
|
7775
|
+
ts.containsPath = containsPath;
|
|
7776
|
+
/**
|
|
7777
|
+
* Determines whether `fileName` starts with the specified `directoryName` using the provided path canonicalization callback.
|
|
7778
|
+
* Comparison is case-sensitive between the canonical paths.
|
|
7779
|
+
*
|
|
7780
|
+
* Use `containsPath` if file names are not already reduced and absolute.
|
|
7781
|
+
*/
|
|
7782
|
+
function startsWithDirectory(fileName, directoryName, getCanonicalFileName) {
|
|
7783
|
+
var canonicalFileName = getCanonicalFileName(fileName);
|
|
7784
|
+
var canonicalDirectoryName = getCanonicalFileName(directoryName);
|
|
7785
|
+
return ts.startsWith(canonicalFileName, canonicalDirectoryName + "/") || ts.startsWith(canonicalFileName, canonicalDirectoryName + "\\");
|
|
7786
|
+
}
|
|
7787
|
+
ts.startsWithDirectory = startsWithDirectory;
|
|
7788
|
+
//// Relative Paths
|
|
7789
|
+
function getPathComponentsRelativeTo(from, to, stringEqualityComparer, getCanonicalFileName) {
|
|
7790
|
+
var fromComponents = reducePathComponents(getPathComponents(from));
|
|
7791
|
+
var toComponents = reducePathComponents(getPathComponents(to));
|
|
7792
|
+
var start;
|
|
7793
|
+
for (start = 0; start < fromComponents.length && start < toComponents.length; start++) {
|
|
7794
|
+
var fromComponent = getCanonicalFileName(fromComponents[start]);
|
|
7795
|
+
var toComponent = getCanonicalFileName(toComponents[start]);
|
|
7796
|
+
var comparer = start === 0 ? ts.equateStringsCaseInsensitive : stringEqualityComparer;
|
|
7797
|
+
if (!comparer(fromComponent, toComponent))
|
|
7798
|
+
break;
|
|
7799
|
+
}
|
|
7800
|
+
if (start === 0) {
|
|
7801
|
+
return toComponents;
|
|
7802
|
+
}
|
|
7803
|
+
var components = toComponents.slice(start);
|
|
7804
|
+
var relative = [];
|
|
7805
|
+
for (; start < fromComponents.length; start++) {
|
|
7806
|
+
relative.push("..");
|
|
7807
|
+
}
|
|
7808
|
+
return __spreadArray(__spreadArray([""], relative, true), components, true);
|
|
7809
|
+
}
|
|
7810
|
+
ts.getPathComponentsRelativeTo = getPathComponentsRelativeTo;
|
|
7811
|
+
function getRelativePathFromDirectory(fromDirectory, to, getCanonicalFileNameOrIgnoreCase) {
|
|
7812
|
+
ts.Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative");
|
|
7813
|
+
var getCanonicalFileName = typeof getCanonicalFileNameOrIgnoreCase === "function" ? getCanonicalFileNameOrIgnoreCase : ts.identity;
|
|
7814
|
+
var ignoreCase = typeof getCanonicalFileNameOrIgnoreCase === "boolean" ? getCanonicalFileNameOrIgnoreCase : false;
|
|
7815
|
+
var pathComponents = getPathComponentsRelativeTo(fromDirectory, to, ignoreCase ? ts.equateStringsCaseInsensitive : ts.equateStringsCaseSensitive, getCanonicalFileName);
|
|
7816
|
+
return getPathFromPathComponents(pathComponents);
|
|
7817
|
+
}
|
|
7818
|
+
ts.getRelativePathFromDirectory = getRelativePathFromDirectory;
|
|
7819
|
+
function convertToRelativePath(absoluteOrRelativePath, basePath, getCanonicalFileName) {
|
|
7820
|
+
return !isRootedDiskPath(absoluteOrRelativePath)
|
|
7821
|
+
? absoluteOrRelativePath
|
|
7822
|
+
: getRelativePathToDirectoryOrUrl(basePath, absoluteOrRelativePath, basePath, getCanonicalFileName, /*isAbsolutePathAnUrl*/ false);
|
|
7823
|
+
}
|
|
7824
|
+
ts.convertToRelativePath = convertToRelativePath;
|
|
7825
|
+
function getRelativePathFromFile(from, to, getCanonicalFileName) {
|
|
7826
|
+
return ensurePathIsNonModuleName(getRelativePathFromDirectory(getDirectoryPath(from), to, getCanonicalFileName));
|
|
7827
|
+
}
|
|
7828
|
+
ts.getRelativePathFromFile = getRelativePathFromFile;
|
|
7829
|
+
function getRelativePathToDirectoryOrUrl(directoryPathOrUrl, relativeOrAbsolutePath, currentDirectory, getCanonicalFileName, isAbsolutePathAnUrl) {
|
|
7830
|
+
var pathComponents = getPathComponentsRelativeTo(resolvePath(currentDirectory, directoryPathOrUrl), resolvePath(currentDirectory, relativeOrAbsolutePath), ts.equateStringsCaseSensitive, getCanonicalFileName);
|
|
7831
|
+
var firstComponent = pathComponents[0];
|
|
7832
|
+
if (isAbsolutePathAnUrl && isRootedDiskPath(firstComponent)) {
|
|
7833
|
+
var prefix = firstComponent.charAt(0) === ts.directorySeparator ? "file://" : "file:///";
|
|
7834
|
+
pathComponents[0] = prefix + firstComponent;
|
|
7835
|
+
}
|
|
7836
|
+
return getPathFromPathComponents(pathComponents);
|
|
7837
|
+
}
|
|
7838
|
+
ts.getRelativePathToDirectoryOrUrl = getRelativePathToDirectoryOrUrl;
|
|
7839
|
+
function forEachAncestorDirectory(directory, callback) {
|
|
7840
|
+
while (true) {
|
|
7841
|
+
var result = callback(directory);
|
|
7842
|
+
if (result !== undefined) {
|
|
7843
|
+
return result;
|
|
7844
|
+
}
|
|
7845
|
+
var parentPath = getDirectoryPath(directory);
|
|
7846
|
+
if (parentPath === directory) {
|
|
7847
|
+
return undefined;
|
|
7848
|
+
}
|
|
7849
|
+
directory = parentPath;
|
|
7850
|
+
}
|
|
7851
|
+
}
|
|
7852
|
+
ts.forEachAncestorDirectory = forEachAncestorDirectory;
|
|
7853
|
+
function isNodeModulesDirectory(dirPath) {
|
|
7854
|
+
return ts.endsWith(dirPath, "/node_modules");
|
|
7855
|
+
}
|
|
7856
|
+
ts.isNodeModulesDirectory = isNodeModulesDirectory;
|
|
7857
|
+
})(ts || (ts = {}));
|
|
7858
7858
|
// <auto-generated />
|
|
7859
|
-
// generated from './
|
|
7859
|
+
// generated from './diagnosticMessages.json' in 'src/compiler'
|
|
7860
7860
|
/* @internal */
|
|
7861
7861
|
var ts;
|
|
7862
7862
|
(function (ts) {
|
|
@@ -8149,7 +8149,6 @@ var ts;
|
|
|
8149
8149
|
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 `}`?"),
|
|
8150
8150
|
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 `>`?"),
|
|
8151
8151
|
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'."),
|
|
8152
|
-
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."),
|
|
8153
8152
|
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."),
|
|
8154
8153
|
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."),
|
|
8155
8154
|
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."),
|
|
@@ -8683,12 +8682,10 @@ var ts;
|
|
|
8683
8682
|
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."),
|
|
8684
8683
|
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."),
|
|
8685
8684
|
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."),
|
|
8686
|
-
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."),
|
|
8687
8685
|
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."),
|
|
8688
8686
|
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}'."),
|
|
8689
8687
|
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"),
|
|
8690
8688
|
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."),
|
|
8691
|
-
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'."),
|
|
8692
8689
|
Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"),
|
|
8693
8690
|
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'."),
|
|
8694
8691
|
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}'."),
|
|
@@ -9445,9 +9442,8 @@ var ts;
|
|
|
9445
9442
|
Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"),
|
|
9446
9443
|
Remove_template_tag: diag(90011, ts.DiagnosticCategory.Message, "Remove_template_tag_90011", "Remove template tag"),
|
|
9447
9444
|
Remove_type_parameters: diag(90012, ts.DiagnosticCategory.Message, "Remove_type_parameters_90012", "Remove type parameters"),
|
|
9448
|
-
|
|
9445
|
+
Import_0_from_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_1_90013", "Import '{0}' from \"{1}\""),
|
|
9449
9446
|
Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"),
|
|
9450
|
-
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}\""),
|
|
9451
9447
|
Declare_property_0: diag(90016, ts.DiagnosticCategory.Message, "Declare_property_0_90016", "Declare property '{0}'"),
|
|
9452
9448
|
Add_index_signature_for_property_0: diag(90017, ts.DiagnosticCategory.Message, "Add_index_signature_for_property_0_90017", "Add index signature for property '{0}'"),
|
|
9453
9449
|
Disable_checking_for_this_file: diag(90018, ts.DiagnosticCategory.Message, "Disable_checking_for_this_file_90018", "Disable checking for this file"),
|
|
@@ -9464,8 +9460,6 @@ var ts;
|
|
|
9464
9460
|
Add_async_modifier_to_containing_function: diag(90029, ts.DiagnosticCategory.Message, "Add_async_modifier_to_containing_function_90029", "Add async modifier to containing function"),
|
|
9465
9461
|
Replace_infer_0_with_unknown: diag(90030, ts.DiagnosticCategory.Message, "Replace_infer_0_with_unknown_90030", "Replace 'infer {0}' with 'unknown'"),
|
|
9466
9462
|
Replace_all_unused_infer_with_unknown: diag(90031, ts.DiagnosticCategory.Message, "Replace_all_unused_infer_with_unknown_90031", "Replace all unused 'infer' with 'unknown'"),
|
|
9467
|
-
Import_default_0_from_module_1: diag(90032, ts.DiagnosticCategory.Message, "Import_default_0_from_module_1_90032", "Import default '{0}' from module \"{1}\""),
|
|
9468
|
-
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}\""),
|
|
9469
9463
|
Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"),
|
|
9470
9464
|
Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"),
|
|
9471
9465
|
Replace_0_with_Promise_1: diag(90036, ts.DiagnosticCategory.Message, "Replace_0_with_Promise_1_90036", "Replace '{0}' with 'Promise<{1}>'"),
|
|
@@ -9477,6 +9471,8 @@ var ts;
|
|
|
9477
9471
|
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}'"),
|
|
9478
9472
|
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}\""),
|
|
9479
9473
|
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}\""),
|
|
9474
|
+
Add_import_from_0: diag(90057, ts.DiagnosticCategory.Message, "Add_import_from_0_90057", "Add import from \"{0}\""),
|
|
9475
|
+
Update_import_from_0: diag(90058, ts.DiagnosticCategory.Message, "Update_import_from_0_90058", "Update import from \"{0}\""),
|
|
9480
9476
|
Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
|
|
9481
9477
|
Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
|
|
9482
9478
|
Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
|
|
@@ -9640,6 +9636,7 @@ var ts;
|
|
|
9640
9636
|
Add_missing_attributes: diag(95167, ts.DiagnosticCategory.Message, "Add_missing_attributes_95167", "Add missing attributes"),
|
|
9641
9637
|
Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"),
|
|
9642
9638
|
Add_undefined_to_optional_property_type: diag(95169, ts.DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"),
|
|
9639
|
+
Convert_named_imports_to_default_import: diag(95170, ts.DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"),
|
|
9643
9640
|
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."),
|
|
9644
9641
|
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'."),
|
|
9645
9642
|
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?"),
|
|
@@ -12812,12 +12809,17 @@ var ts;
|
|
|
12812
12809
|
/** Gets the text of a jsdoc comment, flattening links to their text. */
|
|
12813
12810
|
function getTextOfJSDocComment(comment) {
|
|
12814
12811
|
return typeof comment === "string" ? comment
|
|
12815
|
-
: comment === null || comment === void 0 ? void 0 : comment.map(function (c) {
|
|
12816
|
-
// TODO: Other kinds here
|
|
12817
|
-
return c.kind === 319 /* JSDocText */ ? c.text : "{@link " + (c.name ? ts.entityNameToString(c.name) + " " : "") + c.text + "}";
|
|
12818
|
-
}).join("");
|
|
12812
|
+
: comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 319 /* JSDocText */ ? c.text : formatJSDocLink(c); }).join("");
|
|
12819
12813
|
}
|
|
12820
12814
|
ts.getTextOfJSDocComment = getTextOfJSDocComment;
|
|
12815
|
+
function formatJSDocLink(link) {
|
|
12816
|
+
var kind = link.kind === 322 /* JSDocLink */ ? "link"
|
|
12817
|
+
: link.kind === 323 /* JSDocLinkCode */ ? "linkcode"
|
|
12818
|
+
: "linkplain";
|
|
12819
|
+
var name = link.name ? ts.entityNameToString(link.name) : "";
|
|
12820
|
+
var space = link.name && link.text.startsWith("://") ? "" : " ";
|
|
12821
|
+
return "{@" + kind + " " + name + space + link.text + "}";
|
|
12822
|
+
}
|
|
12821
12823
|
/**
|
|
12822
12824
|
* Gets the effective type parameters. If the node was parsed in a
|
|
12823
12825
|
* JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
|
|
@@ -20876,6 +20878,59 @@ var ts;
|
|
|
20876
20878
|
return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
|
|
20877
20879
|
}
|
|
20878
20880
|
ts.isThisTypeParameter = isThisTypeParameter;
|
|
20881
|
+
function getNodeModulePathParts(fullPath) {
|
|
20882
|
+
// If fullPath can't be valid module file within node_modules, returns undefined.
|
|
20883
|
+
// Example of expected pattern: /base/path/node_modules/[@scope/otherpackage/@otherscope/node_modules/]package/[subdirectory/]file.js
|
|
20884
|
+
// Returns indices: ^ ^ ^ ^
|
|
20885
|
+
var topLevelNodeModulesIndex = 0;
|
|
20886
|
+
var topLevelPackageNameIndex = 0;
|
|
20887
|
+
var packageRootIndex = 0;
|
|
20888
|
+
var fileNameIndex = 0;
|
|
20889
|
+
var States;
|
|
20890
|
+
(function (States) {
|
|
20891
|
+
States[States["BeforeNodeModules"] = 0] = "BeforeNodeModules";
|
|
20892
|
+
States[States["NodeModules"] = 1] = "NodeModules";
|
|
20893
|
+
States[States["Scope"] = 2] = "Scope";
|
|
20894
|
+
States[States["PackageContent"] = 3] = "PackageContent";
|
|
20895
|
+
})(States || (States = {}));
|
|
20896
|
+
var partStart = 0;
|
|
20897
|
+
var partEnd = 0;
|
|
20898
|
+
var state = 0 /* BeforeNodeModules */;
|
|
20899
|
+
while (partEnd >= 0) {
|
|
20900
|
+
partStart = partEnd;
|
|
20901
|
+
partEnd = fullPath.indexOf("/", partStart + 1);
|
|
20902
|
+
switch (state) {
|
|
20903
|
+
case 0 /* BeforeNodeModules */:
|
|
20904
|
+
if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
|
|
20905
|
+
topLevelNodeModulesIndex = partStart;
|
|
20906
|
+
topLevelPackageNameIndex = partEnd;
|
|
20907
|
+
state = 1 /* NodeModules */;
|
|
20908
|
+
}
|
|
20909
|
+
break;
|
|
20910
|
+
case 1 /* NodeModules */:
|
|
20911
|
+
case 2 /* Scope */:
|
|
20912
|
+
if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") {
|
|
20913
|
+
state = 2 /* Scope */;
|
|
20914
|
+
}
|
|
20915
|
+
else {
|
|
20916
|
+
packageRootIndex = partEnd;
|
|
20917
|
+
state = 3 /* PackageContent */;
|
|
20918
|
+
}
|
|
20919
|
+
break;
|
|
20920
|
+
case 3 /* PackageContent */:
|
|
20921
|
+
if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
|
|
20922
|
+
state = 1 /* NodeModules */;
|
|
20923
|
+
}
|
|
20924
|
+
else {
|
|
20925
|
+
state = 3 /* PackageContent */;
|
|
20926
|
+
}
|
|
20927
|
+
break;
|
|
20928
|
+
}
|
|
20929
|
+
}
|
|
20930
|
+
fileNameIndex = partStart;
|
|
20931
|
+
return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
|
|
20932
|
+
}
|
|
20933
|
+
ts.getNodeModulePathParts = getNodeModulePathParts;
|
|
20879
20934
|
})(ts || (ts = {}));
|
|
20880
20935
|
/* @internal */
|
|
20881
20936
|
var ts;
|
|
@@ -34526,20 +34581,30 @@ var ts;
|
|
|
34526
34581
|
expression = parsePropertyAccessExpressionRest(pos, expression, questionDotToken);
|
|
34527
34582
|
continue;
|
|
34528
34583
|
}
|
|
34529
|
-
if (!questionDotToken && token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) {
|
|
34530
|
-
nextToken();
|
|
34531
|
-
expression = finishNode(factory.createNonNullExpression(expression), pos);
|
|
34532
|
-
continue;
|
|
34533
|
-
}
|
|
34534
34584
|
// when in the [Decorator] context, we do not parse ElementAccess as it could be part of a ComputedPropertyName
|
|
34535
34585
|
if ((questionDotToken || !inDecoratorContext()) && parseOptional(22 /* OpenBracketToken */)) {
|
|
34536
34586
|
expression = parseElementAccessExpressionRest(pos, expression, questionDotToken);
|
|
34537
34587
|
continue;
|
|
34538
34588
|
}
|
|
34539
34589
|
if (isTemplateStartOfTaggedTemplate()) {
|
|
34540
|
-
|
|
34590
|
+
// Absorb type arguments into TemplateExpression when preceding expression is ExpressionWithTypeArguments
|
|
34591
|
+
expression = !questionDotToken && expression.kind === 227 /* ExpressionWithTypeArguments */ ?
|
|
34592
|
+
parseTaggedTemplateRest(pos, expression.expression, questionDotToken, expression.typeArguments) :
|
|
34593
|
+
parseTaggedTemplateRest(pos, expression, questionDotToken, /*typeArguments*/ undefined);
|
|
34541
34594
|
continue;
|
|
34542
34595
|
}
|
|
34596
|
+
if (!questionDotToken) {
|
|
34597
|
+
if (token() === 53 /* ExclamationToken */ && !scanner.hasPrecedingLineBreak()) {
|
|
34598
|
+
nextToken();
|
|
34599
|
+
expression = finishNode(factory.createNonNullExpression(expression), pos);
|
|
34600
|
+
continue;
|
|
34601
|
+
}
|
|
34602
|
+
var typeArguments = tryParse(parseTypeArgumentsInExpression);
|
|
34603
|
+
if (typeArguments) {
|
|
34604
|
+
expression = finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
|
|
34605
|
+
continue;
|
|
34606
|
+
}
|
|
34607
|
+
}
|
|
34543
34608
|
return expression;
|
|
34544
34609
|
}
|
|
34545
34610
|
}
|
|
@@ -34559,42 +34624,30 @@ var ts;
|
|
|
34559
34624
|
function parseCallExpressionRest(pos, expression) {
|
|
34560
34625
|
while (true) {
|
|
34561
34626
|
expression = parseMemberExpressionRest(pos, expression, /*allowOptionalChain*/ true);
|
|
34627
|
+
var typeArguments = void 0;
|
|
34562
34628
|
var questionDotToken = parseOptionalToken(28 /* QuestionDotToken */);
|
|
34563
|
-
|
|
34564
|
-
|
|
34565
|
-
|
|
34566
|
-
|
|
34567
|
-
|
|
34568
|
-
// part of an arithmetic expression. Break out so we consume it higher in the
|
|
34569
|
-
// stack.
|
|
34570
|
-
var typeArguments = tryParse(parseTypeArgumentsInExpression);
|
|
34571
|
-
if (typeArguments) {
|
|
34572
|
-
if (isTemplateStartOfTaggedTemplate()) {
|
|
34573
|
-
expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
|
|
34574
|
-
continue;
|
|
34575
|
-
}
|
|
34576
|
-
if (questionDotToken || token() === 20 /* OpenParenToken */) {
|
|
34577
|
-
var argumentList = parseArgumentList();
|
|
34578
|
-
var callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
|
|
34579
|
-
factory.createCallChain(expression, questionDotToken, typeArguments, argumentList) :
|
|
34580
|
-
factory.createCallExpression(expression, typeArguments, argumentList);
|
|
34581
|
-
expression = finishNode(callExpr, pos);
|
|
34582
|
-
continue;
|
|
34583
|
-
}
|
|
34584
|
-
expression = finishNode(factory.createExpressionWithTypeArguments(expression, typeArguments), pos);
|
|
34585
|
-
break;
|
|
34629
|
+
if (questionDotToken) {
|
|
34630
|
+
typeArguments = tryParse(parseTypeArgumentsInExpression);
|
|
34631
|
+
if (isTemplateStartOfTaggedTemplate()) {
|
|
34632
|
+
expression = parseTaggedTemplateRest(pos, expression, questionDotToken, typeArguments);
|
|
34633
|
+
continue;
|
|
34586
34634
|
}
|
|
34587
34635
|
}
|
|
34588
|
-
|
|
34636
|
+
if (typeArguments || token() === 20 /* OpenParenToken */) {
|
|
34637
|
+
// Absorb type arguments into CallExpression when preceding expression is ExpressionWithTypeArguments
|
|
34638
|
+
if (!questionDotToken && expression.kind === 227 /* ExpressionWithTypeArguments */) {
|
|
34639
|
+
typeArguments = expression.typeArguments;
|
|
34640
|
+
expression = expression.expression;
|
|
34641
|
+
}
|
|
34589
34642
|
var argumentList = parseArgumentList();
|
|
34590
34643
|
var callExpr = questionDotToken || tryReparseOptionalChain(expression) ?
|
|
34591
|
-
factory.createCallChain(expression, questionDotToken,
|
|
34592
|
-
factory.createCallExpression(expression,
|
|
34644
|
+
factory.createCallChain(expression, questionDotToken, typeArguments, argumentList) :
|
|
34645
|
+
factory.createCallExpression(expression, typeArguments, argumentList);
|
|
34593
34646
|
expression = finishNode(callExpr, pos);
|
|
34594
34647
|
continue;
|
|
34595
34648
|
}
|
|
34596
34649
|
if (questionDotToken) {
|
|
34597
|
-
// We failed to parse anything, so report a missing identifier here.
|
|
34650
|
+
// We parsed `?.` but then failed to parse anything, so report a missing identifier here.
|
|
34598
34651
|
var name = createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics.Identifier_expected);
|
|
34599
34652
|
expression = finishNode(factory.createPropertyAccessChain(expression, questionDotToken, name), pos);
|
|
34600
34653
|
}
|
|
@@ -34640,6 +34693,7 @@ var ts;
|
|
|
34640
34693
|
// falls through
|
|
34641
34694
|
case 27 /* CommaToken */: // foo<x>,
|
|
34642
34695
|
case 24 /* DotToken */: // foo<x>.
|
|
34696
|
+
case 28 /* QuestionDotToken */: // foo<x>?.
|
|
34643
34697
|
case 21 /* CloseParenToken */: // foo<x>)
|
|
34644
34698
|
case 23 /* CloseBracketToken */: // foo<x>]
|
|
34645
34699
|
case 58 /* ColonToken */: // foo<x>:
|
|
@@ -34842,20 +34896,14 @@ var ts;
|
|
|
34842
34896
|
}
|
|
34843
34897
|
var expressionPos = getNodePos();
|
|
34844
34898
|
var expression = parseMemberExpressionRest(expressionPos, parsePrimaryExpression(), /*allowOptionalChain*/ false);
|
|
34845
|
-
var typeArguments
|
|
34846
|
-
|
|
34847
|
-
|
|
34848
|
-
|
|
34849
|
-
|
|
34850
|
-
}
|
|
34851
|
-
var argumentsArray;
|
|
34852
|
-
if (token() === 20 /* OpenParenToken */) {
|
|
34853
|
-
argumentsArray = parseArgumentList();
|
|
34854
|
-
}
|
|
34855
|
-
else if (typeArguments) {
|
|
34856
|
-
parseErrorAt(pos, scanner.getStartPos(), ts.Diagnostics.A_new_expression_with_type_arguments_must_always_be_followed_by_a_parenthesized_argument_list);
|
|
34899
|
+
var typeArguments;
|
|
34900
|
+
// Absorb type arguments into NewExpression when preceding expression is ExpressionWithTypeArguments
|
|
34901
|
+
if (expression.kind === 227 /* ExpressionWithTypeArguments */) {
|
|
34902
|
+
typeArguments = expression.typeArguments;
|
|
34903
|
+
expression = expression.expression;
|
|
34857
34904
|
}
|
|
34858
|
-
|
|
34905
|
+
var argumentList = token() === 20 /* OpenParenToken */ ? parseArgumentList() : undefined;
|
|
34906
|
+
return finishNode(factory.createNewExpression(expression, typeArguments, argumentList), pos);
|
|
34859
34907
|
}
|
|
34860
34908
|
// STATEMENTS
|
|
34861
34909
|
function parseBlock(ignoreMissingOpenBrace, diagnosticMessage) {
|
|
@@ -46814,8 +46862,8 @@ var ts;
|
|
|
46814
46862
|
TypeFacts[TypeFacts["AllTypeofNE"] = 556800] = "AllTypeofNE";
|
|
46815
46863
|
TypeFacts[TypeFacts["EmptyObjectFacts"] = 16777215] = "EmptyObjectFacts";
|
|
46816
46864
|
// Masks
|
|
46817
|
-
TypeFacts[TypeFacts["OrFactsMask"] =
|
|
46818
|
-
TypeFacts[TypeFacts["AndFactsMask"] =
|
|
46865
|
+
TypeFacts[TypeFacts["OrFactsMask"] = 8256] = "OrFactsMask";
|
|
46866
|
+
TypeFacts[TypeFacts["AndFactsMask"] = 16768959] = "AndFactsMask";
|
|
46819
46867
|
})(TypeFacts || (TypeFacts = {}));
|
|
46820
46868
|
var typeofEQFacts = new ts.Map(ts.getEntries({
|
|
46821
46869
|
string: 1 /* TypeofEQString */,
|
|
@@ -48770,24 +48818,19 @@ var ts;
|
|
|
48770
48818
|
error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
|
|
48771
48819
|
}
|
|
48772
48820
|
}
|
|
48773
|
-
if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */) {
|
|
48774
|
-
|
|
48821
|
+
if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
|
|
48822
|
+
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
|
|
48823
|
+
if (typeOnlyDeclaration) {
|
|
48824
|
+
var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
|
|
48825
|
+
? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
|
|
48826
|
+
: ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
|
|
48827
|
+
var unescapedName = ts.unescapeLeadingUnderscores(name);
|
|
48828
|
+
addTypeOnlyDeclarationRelatedInfo(error(errorLocation, message, unescapedName), typeOnlyDeclaration, unescapedName);
|
|
48829
|
+
}
|
|
48775
48830
|
}
|
|
48776
48831
|
}
|
|
48777
48832
|
return result;
|
|
48778
48833
|
}
|
|
48779
|
-
function checkSymbolUsageInExpressionContext(symbol, name, useSite) {
|
|
48780
|
-
if (!ts.isValidTypeOnlyAliasUseSite(useSite)) {
|
|
48781
|
-
var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
|
|
48782
|
-
if (typeOnlyDeclaration) {
|
|
48783
|
-
var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
|
|
48784
|
-
? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
|
|
48785
|
-
: ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
|
|
48786
|
-
var unescapedName = ts.unescapeLeadingUnderscores(name);
|
|
48787
|
-
addTypeOnlyDeclarationRelatedInfo(error(useSite, message, unescapedName), typeOnlyDeclaration, unescapedName);
|
|
48788
|
-
}
|
|
48789
|
-
}
|
|
48790
|
-
}
|
|
48791
48834
|
function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) {
|
|
48792
48835
|
if (!typeOnlyDeclaration)
|
|
48793
48836
|
return diagnostic;
|
|
@@ -67933,7 +67976,10 @@ var ts;
|
|
|
67933
67976
|
(type === falseType || type === regularFalseType) ? 12121864 /* FalseStrictFacts */ : 7927560 /* TrueStrictFacts */ :
|
|
67934
67977
|
(type === falseType || type === regularFalseType) ? 12580616 /* FalseFacts */ : 16774920 /* TrueFacts */;
|
|
67935
67978
|
}
|
|
67936
|
-
if (flags & 524288 /* Object */
|
|
67979
|
+
if (flags & 524288 /* Object */) {
|
|
67980
|
+
if (ignoreObjects) {
|
|
67981
|
+
return 16768959 /* AndFactsMask */; // This is the identity element for computing type facts of intersection.
|
|
67982
|
+
}
|
|
67937
67983
|
return ts.getObjectFlags(type) & 16 /* Anonymous */ && isEmptyObjectType(type) ?
|
|
67938
67984
|
strictNullChecks ? 16318463 /* EmptyObjectStrictFacts */ : 16777215 /* EmptyObjectFacts */ :
|
|
67939
67985
|
isFunctionObjectType(type) ?
|
|
@@ -67981,7 +68027,7 @@ var ts;
|
|
|
67981
68027
|
oredFacts |= f;
|
|
67982
68028
|
andedFacts &= f;
|
|
67983
68029
|
}
|
|
67984
|
-
return oredFacts &
|
|
68030
|
+
return oredFacts & 8256 /* OrFactsMask */ | andedFacts & 16768959 /* AndFactsMask */;
|
|
67985
68031
|
}
|
|
67986
68032
|
function getTypeWithFacts(type, include) {
|
|
67987
68033
|
return filterType(type, function (t) { return (getTypeFacts(t) & include) !== 0; });
|
|
@@ -69941,6 +69987,9 @@ var ts;
|
|
|
69941
69987
|
return getTypeOfSymbol(symbol);
|
|
69942
69988
|
}
|
|
69943
69989
|
function checkIdentifier(node, checkMode) {
|
|
69990
|
+
if (ts.isThisInTypeQuery(node)) {
|
|
69991
|
+
return checkThisExpression(node);
|
|
69992
|
+
}
|
|
69944
69993
|
var symbol = getResolvedSymbol(node);
|
|
69945
69994
|
if (symbol === unknownSymbol) {
|
|
69946
69995
|
return errorType;
|
|
@@ -71732,7 +71781,8 @@ var ts;
|
|
|
71732
71781
|
var links = getNodeLinks(node.expression);
|
|
71733
71782
|
if (!links.resolvedType) {
|
|
71734
71783
|
if ((ts.isTypeLiteralNode(node.parent.parent) || ts.isClassLike(node.parent.parent) || ts.isInterfaceDeclaration(node.parent.parent))
|
|
71735
|
-
&& ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */
|
|
71784
|
+
&& ts.isBinaryExpression(node.expression) && node.expression.operatorToken.kind === 101 /* InKeyword */
|
|
71785
|
+
&& node.parent.kind !== 171 /* GetAccessor */ && node.parent.kind !== 172 /* SetAccessor */) {
|
|
71736
71786
|
return links.resolvedType = errorType;
|
|
71737
71787
|
}
|
|
71738
71788
|
links.resolvedType = checkExpression(node.expression);
|
|
@@ -72901,23 +72951,6 @@ var ts;
|
|
|
72901
72951
|
if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) {
|
|
72902
72952
|
grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right));
|
|
72903
72953
|
}
|
|
72904
|
-
if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && !useDefineForClassFields)) {
|
|
72905
|
-
var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration);
|
|
72906
|
-
var parentStaticFieldInitializer = ts.findAncestor(node, function (n) {
|
|
72907
|
-
if (n === lexicalClass_1)
|
|
72908
|
-
return "quit";
|
|
72909
|
-
if (ts.isPropertyDeclaration(n.parent) && ts.hasStaticModifier(n.parent) && n.parent.initializer === n && n.parent.parent === lexicalClass_1) {
|
|
72910
|
-
return true;
|
|
72911
|
-
}
|
|
72912
|
-
return false;
|
|
72913
|
-
});
|
|
72914
|
-
if (parentStaticFieldInitializer) {
|
|
72915
|
-
var parentStaticFieldInitializerSymbol = getSymbolOfNode(parentStaticFieldInitializer.parent);
|
|
72916
|
-
ts.Debug.assert(parentStaticFieldInitializerSymbol, "Initializer without declaration symbol");
|
|
72917
|
-
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));
|
|
72918
|
-
ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(parentStaticFieldInitializer.parent, ts.Diagnostics.Initializer_for_property_0, ts.symbolName(parentStaticFieldInitializerSymbol)));
|
|
72919
|
-
}
|
|
72920
|
-
}
|
|
72921
72954
|
if (isAnyLike) {
|
|
72922
72955
|
if (lexicallyScopedSymbol) {
|
|
72923
72956
|
return isErrorType(apparentType) ? errorType : apparentType;
|
|
@@ -75608,51 +75641,57 @@ var ts;
|
|
|
75608
75641
|
ts.isThisIdentifier(node.exprName) ? checkThisExpression(node.exprName) :
|
|
75609
75642
|
checkExpression(node.exprName);
|
|
75610
75643
|
var typeArguments = node.typeArguments;
|
|
75611
|
-
if (!ts.some(typeArguments)) {
|
|
75644
|
+
if (exprType === silentNeverType || isErrorType(exprType) || !ts.some(typeArguments)) {
|
|
75612
75645
|
return exprType;
|
|
75613
75646
|
}
|
|
75614
|
-
var funcType = getApparentType(exprType);
|
|
75615
|
-
if (funcType === silentNeverType || isErrorType(funcType)) {
|
|
75616
|
-
return funcType;
|
|
75617
|
-
}
|
|
75618
75647
|
var hasSomeApplicableSignature = false;
|
|
75619
75648
|
var nonApplicableType;
|
|
75620
|
-
var
|
|
75621
|
-
var
|
|
75622
|
-
var result = mapType(funcType, getInstantiatedType);
|
|
75623
|
-
var errorType = hasSomeApplicableSignature ? nonApplicableType : funcType;
|
|
75649
|
+
var result = getInstantiatedType(exprType);
|
|
75650
|
+
var errorType = hasSomeApplicableSignature ? nonApplicableType : exprType;
|
|
75624
75651
|
if (errorType) {
|
|
75625
75652
|
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)));
|
|
75626
75653
|
}
|
|
75627
75654
|
return result;
|
|
75628
75655
|
function getInstantiatedType(type) {
|
|
75629
|
-
hasSignatures = false;
|
|
75630
|
-
hasApplicableSignature = false;
|
|
75631
|
-
var result =
|
|
75656
|
+
var hasSignatures = false;
|
|
75657
|
+
var hasApplicableSignature = false;
|
|
75658
|
+
var result = getInstantiatedTypePart(type);
|
|
75632
75659
|
hasSomeApplicableSignature || (hasSomeApplicableSignature = hasApplicableSignature);
|
|
75633
75660
|
if (hasSignatures && !hasApplicableSignature) {
|
|
75634
75661
|
nonApplicableType !== null && nonApplicableType !== void 0 ? nonApplicableType : (nonApplicableType = type);
|
|
75635
75662
|
}
|
|
75636
75663
|
return result;
|
|
75637
|
-
|
|
75638
|
-
|
|
75639
|
-
|
|
75640
|
-
|
|
75641
|
-
|
|
75642
|
-
|
|
75643
|
-
|
|
75644
|
-
|
|
75645
|
-
|
|
75646
|
-
|
|
75647
|
-
|
|
75648
|
-
|
|
75649
|
-
|
|
75664
|
+
function getInstantiatedTypePart(type) {
|
|
75665
|
+
if (type.flags & 524288 /* Object */) {
|
|
75666
|
+
var resolved = resolveStructuredTypeMembers(type);
|
|
75667
|
+
var callSignatures = getInstantiatedSignatures(resolved.callSignatures);
|
|
75668
|
+
var constructSignatures = getInstantiatedSignatures(resolved.constructSignatures);
|
|
75669
|
+
hasSignatures || (hasSignatures = resolved.callSignatures.length !== 0 || resolved.constructSignatures.length !== 0);
|
|
75670
|
+
hasApplicableSignature || (hasApplicableSignature = callSignatures.length !== 0 || constructSignatures.length !== 0);
|
|
75671
|
+
if (callSignatures !== resolved.callSignatures || constructSignatures !== resolved.constructSignatures) {
|
|
75672
|
+
var result_11 = createAnonymousType(undefined, resolved.members, callSignatures, constructSignatures, resolved.indexInfos);
|
|
75673
|
+
result_11.objectFlags |= 16777216 /* InstantiationExpressionType */;
|
|
75674
|
+
result_11.node = node;
|
|
75675
|
+
return result_11;
|
|
75676
|
+
}
|
|
75677
|
+
}
|
|
75678
|
+
else if (type.flags & 58982400 /* InstantiableNonPrimitive */) {
|
|
75679
|
+
var constraint = getBaseConstraintOfType(type);
|
|
75680
|
+
if (constraint) {
|
|
75681
|
+
var instantiated = getInstantiatedTypePart(constraint);
|
|
75682
|
+
if (instantiated !== constraint) {
|
|
75683
|
+
return instantiated;
|
|
75684
|
+
}
|
|
75685
|
+
}
|
|
75650
75686
|
}
|
|
75687
|
+
else if (type.flags & 1048576 /* Union */) {
|
|
75688
|
+
return mapType(type, getInstantiatedType);
|
|
75689
|
+
}
|
|
75690
|
+
else if (type.flags & 2097152 /* Intersection */) {
|
|
75691
|
+
return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypePart));
|
|
75692
|
+
}
|
|
75693
|
+
return type;
|
|
75651
75694
|
}
|
|
75652
|
-
else if (type.flags & 2097152 /* Intersection */) {
|
|
75653
|
-
return getIntersectionType(ts.sameMap(type.types, getInstantiatedTypeWorker));
|
|
75654
|
-
}
|
|
75655
|
-
return type;
|
|
75656
75695
|
}
|
|
75657
75696
|
function getInstantiatedSignatures(signatures) {
|
|
75658
75697
|
var applicableSignatures = ts.filter(signatures, function (sig) { return !!sig.typeParameters && hasCorrectTypeArgumentArity(sig, typeArguments); });
|
|
@@ -75740,6 +75779,10 @@ var ts;
|
|
|
75740
75779
|
return restParameter.escapedName;
|
|
75741
75780
|
}
|
|
75742
75781
|
function getParameterIdentifierNameAtPosition(signature, pos) {
|
|
75782
|
+
var _a;
|
|
75783
|
+
if (((_a = signature.declaration) === null || _a === void 0 ? void 0 : _a.kind) === 315 /* JSDocFunctionType */) {
|
|
75784
|
+
return undefined;
|
|
75785
|
+
}
|
|
75743
75786
|
var paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
|
|
75744
75787
|
if (pos < paramCount) {
|
|
75745
75788
|
var param = signature.parameters[pos];
|
|
@@ -78611,9 +78654,6 @@ var ts;
|
|
|
78611
78654
|
checkGrammarComputedPropertyName(node.name);
|
|
78612
78655
|
checkVariableLikeDeclaration(node);
|
|
78613
78656
|
setNodeLinksForPrivateIdentifierScope(node);
|
|
78614
|
-
if (ts.isPrivateIdentifier(node.name) && ts.hasStaticModifier(node) && node.initializer && languageVersion === 99 /* ESNext */ && !compilerOptions.useDefineForClassFields) {
|
|
78615
|
-
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);
|
|
78616
|
-
}
|
|
78617
78657
|
// property signatures already report "initializer not allowed in ambient context" elsewhere
|
|
78618
78658
|
if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 166 /* PropertyDeclaration */ && node.initializer) {
|
|
78619
78659
|
error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name));
|
|
@@ -84506,7 +84546,10 @@ var ts;
|
|
|
84506
84546
|
case 80 /* PrivateIdentifier */:
|
|
84507
84547
|
case 205 /* PropertyAccessExpression */:
|
|
84508
84548
|
case 160 /* QualifiedName */:
|
|
84509
|
-
|
|
84549
|
+
if (!ts.isThisInTypeQuery(node)) {
|
|
84550
|
+
return getSymbolOfNameOrPropertyAccessExpression(node);
|
|
84551
|
+
}
|
|
84552
|
+
// falls through
|
|
84510
84553
|
case 108 /* ThisKeyword */:
|
|
84511
84554
|
var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false);
|
|
84512
84555
|
if (ts.isFunctionLike(container)) {
|
|
@@ -85751,7 +85794,7 @@ var ts;
|
|
|
85751
85794
|
if (quickResult !== undefined) {
|
|
85752
85795
|
return quickResult;
|
|
85753
85796
|
}
|
|
85754
|
-
var lastStatic, lastDeclare, lastAsync,
|
|
85797
|
+
var lastStatic, lastDeclare, lastAsync, lastOverride;
|
|
85755
85798
|
var flags = 0 /* None */;
|
|
85756
85799
|
for (var _i = 0, _a = node.modifiers; _i < _a.length; _i++) {
|
|
85757
85800
|
var modifier = _a[_i];
|
|
@@ -85855,7 +85898,6 @@ var ts;
|
|
|
85855
85898
|
return grammarErrorOnNode(modifier, ts.Diagnostics.readonly_modifier_can_only_appear_on_a_property_declaration_or_index_signature);
|
|
85856
85899
|
}
|
|
85857
85900
|
flags |= 64 /* Readonly */;
|
|
85858
|
-
lastReadonly = modifier;
|
|
85859
85901
|
break;
|
|
85860
85902
|
case 93 /* ExportKeyword */:
|
|
85861
85903
|
if (flags & 1 /* Export */) {
|
|
@@ -85968,18 +86010,12 @@ var ts;
|
|
|
85968
86010
|
if (flags & 32 /* Static */) {
|
|
85969
86011
|
return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "static");
|
|
85970
86012
|
}
|
|
85971
|
-
if (flags & 128 /* Abstract */) {
|
|
85972
|
-
return grammarErrorOnNode(lastStatic, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "abstract"); // TODO: GH#18217
|
|
85973
|
-
}
|
|
85974
86013
|
if (flags & 16384 /* Override */) {
|
|
85975
86014
|
return grammarErrorOnNode(lastOverride, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "override"); // TODO: GH#18217
|
|
85976
86015
|
}
|
|
85977
|
-
|
|
86016
|
+
if (flags & 256 /* Async */) {
|
|
85978
86017
|
return grammarErrorOnNode(lastAsync, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "async");
|
|
85979
86018
|
}
|
|
85980
|
-
else if (flags & 64 /* Readonly */) {
|
|
85981
|
-
return grammarErrorOnNode(lastReadonly, ts.Diagnostics._0_modifier_cannot_appear_on_a_constructor_declaration, "readonly");
|
|
85982
|
-
}
|
|
85983
86019
|
return false;
|
|
85984
86020
|
}
|
|
85985
86021
|
else if ((node.kind === 265 /* ImportDeclaration */ || node.kind === 264 /* ImportEqualsDeclaration */) && flags & 2 /* Ambient */) {
|
|
@@ -92307,10 +92343,12 @@ var ts;
|
|
|
92307
92343
|
var languageVersion = ts.getEmitScriptTarget(compilerOptions);
|
|
92308
92344
|
var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions);
|
|
92309
92345
|
var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ES2022 */;
|
|
92346
|
+
// We need to transform `this` in a static initializer into a reference to the class
|
|
92347
|
+
// when targeting < ES2022 since the assignment will be moved outside of the class body.
|
|
92348
|
+
var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ES2022 */;
|
|
92310
92349
|
// We don't need to transform `super` property access when targeting ES5, ES3 because
|
|
92311
92350
|
// the es2015 transformation handles those.
|
|
92312
|
-
var shouldTransformSuperInStaticInitializers =
|
|
92313
|
-
var shouldTransformThisInStaticInitializers = languageVersion <= 8 /* ES2021 */ || !useDefineForClassFields;
|
|
92351
|
+
var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */;
|
|
92314
92352
|
var previousOnSubstituteNode = context.onSubstituteNode;
|
|
92315
92353
|
context.onSubstituteNode = onSubstituteNode;
|
|
92316
92354
|
var previousOnEmitNode = context.onEmitNode;
|
|
@@ -92539,6 +92577,10 @@ var ts;
|
|
|
92539
92577
|
ts.Debug.assert(!ts.some(node.decorators));
|
|
92540
92578
|
if (ts.isPrivateIdentifier(node.name)) {
|
|
92541
92579
|
if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
|
|
92580
|
+
if (ts.isStatic(node)) {
|
|
92581
|
+
// static fields are left as is
|
|
92582
|
+
return ts.visitEachChild(node, visitor, context);
|
|
92583
|
+
}
|
|
92542
92584
|
// Initializer is elided as the field is initialized in transformConstructor.
|
|
92543
92585
|
return factory.updatePropertyDeclaration(node,
|
|
92544
92586
|
/*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name,
|
|
@@ -92560,6 +92602,22 @@ var ts;
|
|
|
92560
92602
|
if (expr && !ts.isSimpleInlineableExpression(expr)) {
|
|
92561
92603
|
getPendingExpressions().push(expr);
|
|
92562
92604
|
}
|
|
92605
|
+
if (ts.isStatic(node) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
|
|
92606
|
+
var initializerStatement = transformPropertyOrClassStaticBlock(node, factory.createThis());
|
|
92607
|
+
if (initializerStatement) {
|
|
92608
|
+
var staticBlock = factory.createClassStaticBlockDeclaration(
|
|
92609
|
+
/*decorators*/ undefined,
|
|
92610
|
+
/*modifiers*/ undefined, factory.createBlock([initializerStatement]));
|
|
92611
|
+
ts.setOriginalNode(staticBlock, node);
|
|
92612
|
+
ts.setCommentRange(staticBlock, node);
|
|
92613
|
+
// Set the comment range for the statement to an empty synthetic range
|
|
92614
|
+
// and drop synthetic comments from the statement to avoid printing them twice.
|
|
92615
|
+
ts.setCommentRange(initializerStatement, { pos: -1, end: -1 });
|
|
92616
|
+
ts.setSyntheticLeadingComments(initializerStatement, undefined);
|
|
92617
|
+
ts.setSyntheticTrailingComments(initializerStatement, undefined);
|
|
92618
|
+
return staticBlock;
|
|
92619
|
+
}
|
|
92620
|
+
}
|
|
92563
92621
|
return undefined;
|
|
92564
92622
|
}
|
|
92565
92623
|
function createPrivateIdentifierAccess(info, receiver) {
|
|
@@ -92947,7 +93005,6 @@ var ts;
|
|
|
92947
93005
|
if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) {
|
|
92948
93006
|
enableSubstitutionForClassStaticThisOrSuperReference();
|
|
92949
93007
|
}
|
|
92950
|
-
var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
|
|
92951
93008
|
// If a class has private static fields, or a static field has a `this` or `super` reference,
|
|
92952
93009
|
// then we need to allocate a temp variable to hold on to that reference.
|
|
92953
93010
|
var pendingClassReferenceAssignment;
|
|
@@ -92975,6 +93032,7 @@ var ts;
|
|
|
92975
93032
|
// From ES6 specification:
|
|
92976
93033
|
// HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using
|
|
92977
93034
|
// a lexical declaration such as a LexicalDeclaration or a ClassDeclaration.
|
|
93035
|
+
var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
|
|
92978
93036
|
if (ts.some(staticProperties)) {
|
|
92979
93037
|
addPropertyOrClassStaticBlockStatements(statements, staticProperties, factory.getInternalName(node));
|
|
92980
93038
|
}
|
|
@@ -93013,7 +93071,7 @@ var ts;
|
|
|
93013
93071
|
}
|
|
93014
93072
|
var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), node.modifiers, node.name,
|
|
93015
93073
|
/*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, heritageClauseVisitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass));
|
|
93016
|
-
var hasTransformableStatics = ts.some(staticPropertiesOrClassStaticBlocks, function (p) { return ts.isClassStaticBlockDeclaration(p) || !!p.initializer ||
|
|
93074
|
+
var hasTransformableStatics = shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(staticPropertiesOrClassStaticBlocks, function (p) { return ts.isClassStaticBlockDeclaration(p) || !!p.initializer || ts.isPrivateIdentifier(p.name); });
|
|
93017
93075
|
if (hasTransformableStatics || ts.some(pendingExpressions)) {
|
|
93018
93076
|
if (isDecoratedClassDeclaration) {
|
|
93019
93077
|
ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration.");
|
|
@@ -93060,6 +93118,7 @@ var ts;
|
|
|
93060
93118
|
return undefined;
|
|
93061
93119
|
}
|
|
93062
93120
|
function transformClassMembers(node, isDerivedClass) {
|
|
93121
|
+
var members = [];
|
|
93063
93122
|
if (shouldTransformPrivateElementsOrClassStaticBlocks) {
|
|
93064
93123
|
// Declare private names.
|
|
93065
93124
|
for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
|
|
@@ -93072,12 +93131,20 @@ var ts;
|
|
|
93072
93131
|
createBrandCheckWeakSetForPrivateMethods();
|
|
93073
93132
|
}
|
|
93074
93133
|
}
|
|
93075
|
-
var members = [];
|
|
93076
93134
|
var constructor = transformConstructor(node, isDerivedClass);
|
|
93135
|
+
var visitedMembers = ts.visitNodes(node.members, classElementVisitor, ts.isClassElement);
|
|
93077
93136
|
if (constructor) {
|
|
93078
93137
|
members.push(constructor);
|
|
93079
93138
|
}
|
|
93080
|
-
|
|
93139
|
+
if (!shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(pendingExpressions)) {
|
|
93140
|
+
members.push(factory.createClassStaticBlockDeclaration(
|
|
93141
|
+
/*decorators*/ undefined,
|
|
93142
|
+
/*modifiers*/ undefined, factory.createBlock([
|
|
93143
|
+
factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))
|
|
93144
|
+
])));
|
|
93145
|
+
pendingExpressions = undefined;
|
|
93146
|
+
}
|
|
93147
|
+
ts.addRange(members, visitedMembers);
|
|
93081
93148
|
return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members);
|
|
93082
93149
|
}
|
|
93083
93150
|
function createBrandCheckWeakSetForPrivateMethods() {
|
|
@@ -93220,24 +93287,34 @@ var ts;
|
|
|
93220
93287
|
function addPropertyOrClassStaticBlockStatements(statements, properties, receiver) {
|
|
93221
93288
|
for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
|
|
93222
93289
|
var property = properties_7[_i];
|
|
93223
|
-
|
|
93224
|
-
|
|
93225
|
-
|
|
93226
|
-
|
|
93290
|
+
if (ts.isStatic(property) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
|
|
93291
|
+
continue;
|
|
93292
|
+
}
|
|
93293
|
+
var statement = transformPropertyOrClassStaticBlock(property, receiver);
|
|
93294
|
+
if (!statement) {
|
|
93227
93295
|
continue;
|
|
93228
93296
|
}
|
|
93229
|
-
var statement = factory.createExpressionStatement(expression);
|
|
93230
|
-
ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
|
|
93231
|
-
ts.setCommentRange(statement, property);
|
|
93232
|
-
ts.setOriginalNode(statement, property);
|
|
93233
|
-
// `setOriginalNode` *copies* the `emitNode` from `property`, so now both
|
|
93234
|
-
// `statement` and `expression` have a copy of the synthesized comments.
|
|
93235
|
-
// Drop the comments from expression to avoid printing them twice.
|
|
93236
|
-
ts.setSyntheticLeadingComments(expression, undefined);
|
|
93237
|
-
ts.setSyntheticTrailingComments(expression, undefined);
|
|
93238
93297
|
statements.push(statement);
|
|
93239
93298
|
}
|
|
93240
93299
|
}
|
|
93300
|
+
function transformPropertyOrClassStaticBlock(property, receiver) {
|
|
93301
|
+
var expression = ts.isClassStaticBlockDeclaration(property) ?
|
|
93302
|
+
transformClassStaticBlockDeclaration(property) :
|
|
93303
|
+
transformProperty(property, receiver);
|
|
93304
|
+
if (!expression) {
|
|
93305
|
+
return undefined;
|
|
93306
|
+
}
|
|
93307
|
+
var statement = factory.createExpressionStatement(expression);
|
|
93308
|
+
ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
|
|
93309
|
+
ts.setCommentRange(statement, property);
|
|
93310
|
+
ts.setOriginalNode(statement, property);
|
|
93311
|
+
// `setOriginalNode` *copies* the `emitNode` from `property`, so now both
|
|
93312
|
+
// `statement` and `expression` have a copy of the synthesized comments.
|
|
93313
|
+
// Drop the comments from expression to avoid printing them twice.
|
|
93314
|
+
ts.setSyntheticLeadingComments(expression, undefined);
|
|
93315
|
+
ts.setSyntheticTrailingComments(expression, undefined);
|
|
93316
|
+
return statement;
|
|
93317
|
+
}
|
|
93241
93318
|
/**
|
|
93242
93319
|
* Generates assignment expressions for property initializers.
|
|
93243
93320
|
*
|
|
@@ -94487,6 +94564,7 @@ var ts;
|
|
|
94487
94564
|
var exportedVariableStatement = false;
|
|
94488
94565
|
var enabledSubstitutions;
|
|
94489
94566
|
var enclosingFunctionFlags;
|
|
94567
|
+
var parametersWithPrecedingObjectRestOrSpread;
|
|
94490
94568
|
var enclosingSuperContainerFlags = 0;
|
|
94491
94569
|
var hierarchyFacts = 0;
|
|
94492
94570
|
var currentSourceFile;
|
|
@@ -94943,6 +95021,7 @@ var ts;
|
|
|
94943
95021
|
/*incrementor*/ undefined,
|
|
94944
95022
|
/*statement*/ convertForOfStatementHead(node, getValue)),
|
|
94945
95023
|
/*location*/ node), 256 /* NoTokenTrailingSourceMaps */);
|
|
95024
|
+
ts.setOriginalNode(forStatement, node);
|
|
94946
95025
|
return factory.createTryStatement(factory.createBlock([
|
|
94947
95026
|
factory.restoreEnclosingLabel(forStatement, outermostLabeledStatement)
|
|
94948
95027
|
]), factory.createCatchClause(factory.createVariableDeclaration(catchVariable), ts.setEmitFlags(factory.createBlock([
|
|
@@ -94960,7 +95039,19 @@ var ts;
|
|
|
94960
95039
|
]), 1 /* SingleLine */))
|
|
94961
95040
|
]));
|
|
94962
95041
|
}
|
|
95042
|
+
function parameterVisitor(node) {
|
|
95043
|
+
ts.Debug.assertNode(node, ts.isParameter);
|
|
95044
|
+
return visitParameter(node);
|
|
95045
|
+
}
|
|
94963
95046
|
function visitParameter(node) {
|
|
95047
|
+
if (parametersWithPrecedingObjectRestOrSpread === null || parametersWithPrecedingObjectRestOrSpread === void 0 ? void 0 : parametersWithPrecedingObjectRestOrSpread.has(node)) {
|
|
95048
|
+
return factory.updateParameterDeclaration(node,
|
|
95049
|
+
/*decorators*/ undefined,
|
|
95050
|
+
/*modifiers*/ undefined, node.dotDotDotToken, ts.isBindingPattern(node.name) ? factory.getGeneratedNameForNode(node) : node.name,
|
|
95051
|
+
/*questionToken*/ undefined,
|
|
95052
|
+
/*type*/ undefined,
|
|
95053
|
+
/*initializer*/ undefined);
|
|
95054
|
+
}
|
|
94964
95055
|
if (node.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
|
|
94965
95056
|
// Binding patterns are converted into a generated name and are
|
|
94966
95057
|
// evaluated inside the function body.
|
|
@@ -94972,85 +95063,119 @@ var ts;
|
|
|
94972
95063
|
}
|
|
94973
95064
|
return ts.visitEachChild(node, visitor, context);
|
|
94974
95065
|
}
|
|
95066
|
+
function collectParametersWithPrecedingObjectRestOrSpread(node) {
|
|
95067
|
+
var parameters;
|
|
95068
|
+
for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
|
|
95069
|
+
var parameter = _a[_i];
|
|
95070
|
+
if (parameters) {
|
|
95071
|
+
parameters.add(parameter);
|
|
95072
|
+
}
|
|
95073
|
+
else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
|
|
95074
|
+
parameters = new ts.Set();
|
|
95075
|
+
}
|
|
95076
|
+
}
|
|
95077
|
+
return parameters;
|
|
95078
|
+
}
|
|
94975
95079
|
function visitConstructorDeclaration(node) {
|
|
94976
95080
|
var savedEnclosingFunctionFlags = enclosingFunctionFlags;
|
|
94977
|
-
|
|
95081
|
+
var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
|
|
95082
|
+
enclosingFunctionFlags = ts.getFunctionFlags(node);
|
|
95083
|
+
parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
|
|
94978
95084
|
var updated = factory.updateConstructorDeclaration(node,
|
|
94979
|
-
/*decorators*/ undefined, node.modifiers, ts.visitParameterList(node.parameters,
|
|
95085
|
+
/*decorators*/ undefined, node.modifiers, ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node));
|
|
94980
95086
|
enclosingFunctionFlags = savedEnclosingFunctionFlags;
|
|
95087
|
+
parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
|
|
94981
95088
|
return updated;
|
|
94982
95089
|
}
|
|
94983
95090
|
function visitGetAccessorDeclaration(node) {
|
|
94984
95091
|
var savedEnclosingFunctionFlags = enclosingFunctionFlags;
|
|
94985
|
-
|
|
95092
|
+
var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
|
|
95093
|
+
enclosingFunctionFlags = ts.getFunctionFlags(node);
|
|
95094
|
+
parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
|
|
94986
95095
|
var updated = factory.updateGetAccessorDeclaration(node,
|
|
94987
|
-
/*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters,
|
|
95096
|
+
/*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context),
|
|
94988
95097
|
/*type*/ undefined, transformFunctionBody(node));
|
|
94989
95098
|
enclosingFunctionFlags = savedEnclosingFunctionFlags;
|
|
95099
|
+
parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
|
|
94990
95100
|
return updated;
|
|
94991
95101
|
}
|
|
94992
95102
|
function visitSetAccessorDeclaration(node) {
|
|
94993
95103
|
var savedEnclosingFunctionFlags = enclosingFunctionFlags;
|
|
94994
|
-
|
|
95104
|
+
var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
|
|
95105
|
+
enclosingFunctionFlags = ts.getFunctionFlags(node);
|
|
95106
|
+
parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
|
|
94995
95107
|
var updated = factory.updateSetAccessorDeclaration(node,
|
|
94996
|
-
/*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters,
|
|
95108
|
+
/*decorators*/ undefined, node.modifiers, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node));
|
|
94997
95109
|
enclosingFunctionFlags = savedEnclosingFunctionFlags;
|
|
95110
|
+
parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
|
|
94998
95111
|
return updated;
|
|
94999
95112
|
}
|
|
95000
95113
|
function visitMethodDeclaration(node) {
|
|
95001
95114
|
var savedEnclosingFunctionFlags = enclosingFunctionFlags;
|
|
95115
|
+
var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
|
|
95002
95116
|
enclosingFunctionFlags = ts.getFunctionFlags(node);
|
|
95117
|
+
parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
|
|
95003
95118
|
var updated = factory.updateMethodDeclaration(node,
|
|
95004
95119
|
/*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */
|
|
95005
95120
|
? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
|
|
95006
95121
|
: node.modifiers, enclosingFunctionFlags & 2 /* Async */
|
|
95007
95122
|
? undefined
|
|
95008
95123
|
: node.asteriskToken, ts.visitNode(node.name, visitor, ts.isPropertyName), ts.visitNode(/*questionToken*/ undefined, visitor, ts.isToken),
|
|
95009
|
-
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters,
|
|
95124
|
+
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
|
|
95010
95125
|
/*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
|
|
95011
95126
|
? transformAsyncGeneratorFunctionBody(node)
|
|
95012
95127
|
: transformFunctionBody(node));
|
|
95013
95128
|
enclosingFunctionFlags = savedEnclosingFunctionFlags;
|
|
95129
|
+
parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
|
|
95014
95130
|
return updated;
|
|
95015
95131
|
}
|
|
95016
95132
|
function visitFunctionDeclaration(node) {
|
|
95017
95133
|
var savedEnclosingFunctionFlags = enclosingFunctionFlags;
|
|
95134
|
+
var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
|
|
95018
95135
|
enclosingFunctionFlags = ts.getFunctionFlags(node);
|
|
95136
|
+
parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
|
|
95019
95137
|
var updated = factory.updateFunctionDeclaration(node,
|
|
95020
95138
|
/*decorators*/ undefined, enclosingFunctionFlags & 1 /* Generator */
|
|
95021
95139
|
? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
|
|
95022
95140
|
: node.modifiers, enclosingFunctionFlags & 2 /* Async */
|
|
95023
95141
|
? undefined
|
|
95024
95142
|
: node.asteriskToken, node.name,
|
|
95025
|
-
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters,
|
|
95143
|
+
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
|
|
95026
95144
|
/*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
|
|
95027
95145
|
? transformAsyncGeneratorFunctionBody(node)
|
|
95028
95146
|
: transformFunctionBody(node));
|
|
95029
95147
|
enclosingFunctionFlags = savedEnclosingFunctionFlags;
|
|
95148
|
+
parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
|
|
95030
95149
|
return updated;
|
|
95031
95150
|
}
|
|
95032
95151
|
function visitArrowFunction(node) {
|
|
95033
95152
|
var savedEnclosingFunctionFlags = enclosingFunctionFlags;
|
|
95153
|
+
var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
|
|
95034
95154
|
enclosingFunctionFlags = ts.getFunctionFlags(node);
|
|
95155
|
+
parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
|
|
95035
95156
|
var updated = factory.updateArrowFunction(node, node.modifiers,
|
|
95036
|
-
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters,
|
|
95157
|
+
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
|
|
95037
95158
|
/*type*/ undefined, node.equalsGreaterThanToken, transformFunctionBody(node));
|
|
95038
95159
|
enclosingFunctionFlags = savedEnclosingFunctionFlags;
|
|
95160
|
+
parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
|
|
95039
95161
|
return updated;
|
|
95040
95162
|
}
|
|
95041
95163
|
function visitFunctionExpression(node) {
|
|
95042
95164
|
var savedEnclosingFunctionFlags = enclosingFunctionFlags;
|
|
95165
|
+
var savedParametersWithPrecedingObjectRestOrSpread = parametersWithPrecedingObjectRestOrSpread;
|
|
95043
95166
|
enclosingFunctionFlags = ts.getFunctionFlags(node);
|
|
95167
|
+
parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node);
|
|
95044
95168
|
var updated = factory.updateFunctionExpression(node, enclosingFunctionFlags & 1 /* Generator */
|
|
95045
95169
|
? ts.visitNodes(node.modifiers, visitorNoAsyncModifier, ts.isModifier)
|
|
95046
95170
|
: node.modifiers, enclosingFunctionFlags & 2 /* Async */
|
|
95047
95171
|
? undefined
|
|
95048
95172
|
: node.asteriskToken, node.name,
|
|
95049
|
-
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters,
|
|
95173
|
+
/*typeParameters*/ undefined, ts.visitParameterList(node.parameters, parameterVisitor, context),
|
|
95050
95174
|
/*type*/ undefined, enclosingFunctionFlags & 2 /* Async */ && enclosingFunctionFlags & 1 /* Generator */
|
|
95051
95175
|
? transformAsyncGeneratorFunctionBody(node)
|
|
95052
95176
|
: transformFunctionBody(node));
|
|
95053
95177
|
enclosingFunctionFlags = savedEnclosingFunctionFlags;
|
|
95178
|
+
parametersWithPrecedingObjectRestOrSpread = savedParametersWithPrecedingObjectRestOrSpread;
|
|
95054
95179
|
return updated;
|
|
95055
95180
|
}
|
|
95056
95181
|
function transformAsyncGeneratorFunctionBody(node) {
|
|
@@ -95111,16 +95236,71 @@ var ts;
|
|
|
95111
95236
|
return body;
|
|
95112
95237
|
}
|
|
95113
95238
|
function appendObjectRestAssignmentsIfNeeded(statements, node) {
|
|
95239
|
+
var containsPrecedingObjectRestOrSpread = false;
|
|
95114
95240
|
for (var _i = 0, _a = node.parameters; _i < _a.length; _i++) {
|
|
95115
95241
|
var parameter = _a[_i];
|
|
95116
|
-
if (
|
|
95117
|
-
|
|
95118
|
-
|
|
95242
|
+
if (containsPrecedingObjectRestOrSpread) {
|
|
95243
|
+
if (ts.isBindingPattern(parameter.name)) {
|
|
95244
|
+
// In cases where a binding pattern is simply '[]' or '{}',
|
|
95245
|
+
// we usually don't want to emit a var declaration; however, in the presence
|
|
95246
|
+
// of an initializer, we must emit that expression to preserve side effects.
|
|
95247
|
+
//
|
|
95248
|
+
// NOTE: see `insertDefaultValueAssignmentForBindingPattern` in es2015.ts
|
|
95249
|
+
if (parameter.name.elements.length > 0) {
|
|
95250
|
+
var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 0 /* All */, factory.getGeneratedNameForNode(parameter));
|
|
95251
|
+
if (ts.some(declarations)) {
|
|
95252
|
+
var declarationList = factory.createVariableDeclarationList(declarations);
|
|
95253
|
+
var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList);
|
|
95254
|
+
ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
|
|
95255
|
+
statements = ts.append(statements, statement);
|
|
95256
|
+
}
|
|
95257
|
+
}
|
|
95258
|
+
else if (parameter.initializer) {
|
|
95259
|
+
var name = factory.getGeneratedNameForNode(parameter);
|
|
95260
|
+
var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression);
|
|
95261
|
+
var assignment = factory.createAssignment(name, initializer);
|
|
95262
|
+
var statement = factory.createExpressionStatement(assignment);
|
|
95263
|
+
ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
|
|
95264
|
+
statements = ts.append(statements, statement);
|
|
95265
|
+
}
|
|
95266
|
+
}
|
|
95267
|
+
else if (parameter.initializer) {
|
|
95268
|
+
// Converts a parameter initializer into a function body statement, i.e.:
|
|
95269
|
+
//
|
|
95270
|
+
// function f(x = 1) { }
|
|
95271
|
+
//
|
|
95272
|
+
// becomes
|
|
95273
|
+
//
|
|
95274
|
+
// function f(x) {
|
|
95275
|
+
// if (typeof x === "undefined") { x = 1; }
|
|
95276
|
+
// }
|
|
95277
|
+
var name = factory.cloneNode(parameter.name);
|
|
95278
|
+
ts.setTextRange(name, parameter.name);
|
|
95279
|
+
ts.setEmitFlags(name, 48 /* NoSourceMap */);
|
|
95280
|
+
var initializer = ts.visitNode(parameter.initializer, visitor, ts.isExpression);
|
|
95281
|
+
ts.addEmitFlags(initializer, 48 /* NoSourceMap */ | 1536 /* NoComments */);
|
|
95282
|
+
var assignment = factory.createAssignment(name, initializer);
|
|
95283
|
+
ts.setTextRange(assignment, parameter);
|
|
95284
|
+
ts.setEmitFlags(assignment, 1536 /* NoComments */);
|
|
95285
|
+
var block = factory.createBlock([factory.createExpressionStatement(assignment)]);
|
|
95286
|
+
ts.setTextRange(block, parameter);
|
|
95287
|
+
ts.setEmitFlags(block, 1 /* SingleLine */ | 32 /* NoTrailingSourceMap */ | 384 /* NoTokenSourceMaps */ | 1536 /* NoComments */);
|
|
95288
|
+
var typeCheck = factory.createTypeCheck(factory.cloneNode(parameter.name), "undefined");
|
|
95289
|
+
var statement = factory.createIfStatement(typeCheck, block);
|
|
95290
|
+
ts.startOnNewLine(statement);
|
|
95291
|
+
ts.setTextRange(statement, parameter);
|
|
95292
|
+
ts.setEmitFlags(statement, 384 /* NoTokenSourceMaps */ | 32 /* NoTrailingSourceMap */ | 1048576 /* CustomPrologue */ | 1536 /* NoComments */);
|
|
95293
|
+
statements = ts.append(statements, statement);
|
|
95294
|
+
}
|
|
95295
|
+
}
|
|
95296
|
+
else if (parameter.transformFlags & 32768 /* ContainsObjectRestOrSpread */) {
|
|
95297
|
+
containsPrecedingObjectRestOrSpread = true;
|
|
95298
|
+
var declarations = ts.flattenDestructuringBinding(parameter, visitor, context, 1 /* ObjectRest */, factory.getGeneratedNameForNode(parameter),
|
|
95119
95299
|
/*doNotRecordTempVariablesInLine*/ false,
|
|
95120
95300
|
/*skipInitializer*/ true);
|
|
95121
95301
|
if (ts.some(declarations)) {
|
|
95122
|
-
var
|
|
95123
|
-
/*modifiers*/ undefined,
|
|
95302
|
+
var declarationList = factory.createVariableDeclarationList(declarations);
|
|
95303
|
+
var statement = factory.createVariableStatement(/*modifiers*/ undefined, declarationList);
|
|
95124
95304
|
ts.setEmitFlags(statement, 1048576 /* CustomPrologue */);
|
|
95125
95305
|
statements = ts.append(statements, statement);
|
|
95126
95306
|
}
|
|
@@ -98371,10 +98551,12 @@ var ts;
|
|
|
98371
98551
|
// variables declared in the loop initializer that will be changed inside the loop
|
|
98372
98552
|
var loopOutParameters = [];
|
|
98373
98553
|
if (loopInitializer && (ts.getCombinedNodeFlags(loopInitializer) & 3 /* BlockScoped */)) {
|
|
98374
|
-
var
|
|
98554
|
+
var hasCapturedBindingsInForHead = shouldConvertInitializerOfForStatement(node) ||
|
|
98555
|
+
shouldConvertConditionOfForStatement(node) ||
|
|
98556
|
+
shouldConvertIncrementorOfForStatement(node);
|
|
98375
98557
|
for (var _i = 0, _a = loopInitializer.declarations; _i < _a.length; _i++) {
|
|
98376
98558
|
var decl = _a[_i];
|
|
98377
|
-
processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters,
|
|
98559
|
+
processLoopVariableDeclaration(node, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForHead);
|
|
98378
98560
|
}
|
|
98379
98561
|
}
|
|
98380
98562
|
var currentState = { loopParameters: loopParameters, loopOutParameters: loopOutParameters };
|
|
@@ -98728,27 +98910,33 @@ var ts;
|
|
|
98728
98910
|
caseClauses.push(factory.createCaseClause(factory.createStringLiteral(labelMarker), statements));
|
|
98729
98911
|
});
|
|
98730
98912
|
}
|
|
98731
|
-
function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters,
|
|
98913
|
+
function processLoopVariableDeclaration(container, decl, loopParameters, loopOutParameters, hasCapturedBindingsInForHead) {
|
|
98732
98914
|
var name = decl.name;
|
|
98733
98915
|
if (ts.isBindingPattern(name)) {
|
|
98734
98916
|
for (var _i = 0, _a = name.elements; _i < _a.length; _i++) {
|
|
98735
98917
|
var element = _a[_i];
|
|
98736
98918
|
if (!ts.isOmittedExpression(element)) {
|
|
98737
|
-
processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters,
|
|
98919
|
+
processLoopVariableDeclaration(container, element, loopParameters, loopOutParameters, hasCapturedBindingsInForHead);
|
|
98738
98920
|
}
|
|
98739
98921
|
}
|
|
98740
98922
|
}
|
|
98741
98923
|
else {
|
|
98742
98924
|
loopParameters.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name));
|
|
98743
98925
|
var checkFlags = resolver.getNodeCheckFlags(decl);
|
|
98744
|
-
if (checkFlags & 4194304 /* NeedsLoopOutParameter */ ||
|
|
98926
|
+
if (checkFlags & 4194304 /* NeedsLoopOutParameter */ || hasCapturedBindingsInForHead) {
|
|
98745
98927
|
var outParamName = factory.createUniqueName("out_" + ts.idText(name));
|
|
98746
98928
|
var flags = 0;
|
|
98747
98929
|
if (checkFlags & 4194304 /* NeedsLoopOutParameter */) {
|
|
98748
98930
|
flags |= 1 /* Body */;
|
|
98749
98931
|
}
|
|
98750
|
-
if (ts.isForStatement(container)
|
|
98751
|
-
|
|
98932
|
+
if (ts.isForStatement(container)) {
|
|
98933
|
+
if (container.initializer && resolver.isBindingCapturedByNode(container.initializer, decl)) {
|
|
98934
|
+
flags |= 2 /* Initializer */;
|
|
98935
|
+
}
|
|
98936
|
+
if (container.condition && resolver.isBindingCapturedByNode(container.condition, decl) ||
|
|
98937
|
+
container.incrementor && resolver.isBindingCapturedByNode(container.incrementor, decl)) {
|
|
98938
|
+
flags |= 1 /* Body */;
|
|
98939
|
+
}
|
|
98752
98940
|
}
|
|
98753
98941
|
loopOutParameters.push({ flags: flags, originalName: name, outParamName: outParamName });
|
|
98754
98942
|
}
|
|
@@ -120123,7 +120311,7 @@ var ts;
|
|
|
120123
120311
|
if (!host.fileExists || !host.readFile) {
|
|
120124
120312
|
return undefined;
|
|
120125
120313
|
}
|
|
120126
|
-
var parts = getNodeModulePathParts(path);
|
|
120314
|
+
var parts = ts.getNodeModulePathParts(path);
|
|
120127
120315
|
if (!parts) {
|
|
120128
120316
|
return undefined;
|
|
120129
120317
|
}
|
|
@@ -120246,58 +120434,6 @@ var ts;
|
|
|
120246
120434
|
}
|
|
120247
120435
|
}
|
|
120248
120436
|
}
|
|
120249
|
-
function getNodeModulePathParts(fullPath) {
|
|
120250
|
-
// If fullPath can't be valid module file within node_modules, returns undefined.
|
|
120251
|
-
// Example of expected pattern: /base/path/node_modules/[@scope/otherpackage/@otherscope/node_modules/]package/[subdirectory/]file.js
|
|
120252
|
-
// Returns indices: ^ ^ ^ ^
|
|
120253
|
-
var topLevelNodeModulesIndex = 0;
|
|
120254
|
-
var topLevelPackageNameIndex = 0;
|
|
120255
|
-
var packageRootIndex = 0;
|
|
120256
|
-
var fileNameIndex = 0;
|
|
120257
|
-
var States;
|
|
120258
|
-
(function (States) {
|
|
120259
|
-
States[States["BeforeNodeModules"] = 0] = "BeforeNodeModules";
|
|
120260
|
-
States[States["NodeModules"] = 1] = "NodeModules";
|
|
120261
|
-
States[States["Scope"] = 2] = "Scope";
|
|
120262
|
-
States[States["PackageContent"] = 3] = "PackageContent";
|
|
120263
|
-
})(States || (States = {}));
|
|
120264
|
-
var partStart = 0;
|
|
120265
|
-
var partEnd = 0;
|
|
120266
|
-
var state = 0 /* BeforeNodeModules */;
|
|
120267
|
-
while (partEnd >= 0) {
|
|
120268
|
-
partStart = partEnd;
|
|
120269
|
-
partEnd = fullPath.indexOf("/", partStart + 1);
|
|
120270
|
-
switch (state) {
|
|
120271
|
-
case 0 /* BeforeNodeModules */:
|
|
120272
|
-
if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
|
|
120273
|
-
topLevelNodeModulesIndex = partStart;
|
|
120274
|
-
topLevelPackageNameIndex = partEnd;
|
|
120275
|
-
state = 1 /* NodeModules */;
|
|
120276
|
-
}
|
|
120277
|
-
break;
|
|
120278
|
-
case 1 /* NodeModules */:
|
|
120279
|
-
case 2 /* Scope */:
|
|
120280
|
-
if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") {
|
|
120281
|
-
state = 2 /* Scope */;
|
|
120282
|
-
}
|
|
120283
|
-
else {
|
|
120284
|
-
packageRootIndex = partEnd;
|
|
120285
|
-
state = 3 /* PackageContent */;
|
|
120286
|
-
}
|
|
120287
|
-
break;
|
|
120288
|
-
case 3 /* PackageContent */:
|
|
120289
|
-
if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
|
|
120290
|
-
state = 1 /* NodeModules */;
|
|
120291
|
-
}
|
|
120292
|
-
else {
|
|
120293
|
-
state = 3 /* PackageContent */;
|
|
120294
|
-
}
|
|
120295
|
-
break;
|
|
120296
|
-
}
|
|
120297
|
-
}
|
|
120298
|
-
fileNameIndex = partStart;
|
|
120299
|
-
return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
|
|
120300
|
-
}
|
|
120301
120437
|
function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
|
|
120302
120438
|
return ts.firstDefined(rootDirs, function (rootDir) {
|
|
120303
120439
|
var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
|
|
@@ -125823,7 +125959,7 @@ var ts;
|
|
|
125823
125959
|
parts.push(linkTextPart(text));
|
|
125824
125960
|
}
|
|
125825
125961
|
else {
|
|
125826
|
-
parts.push(linkTextPart(name + (suffix ? "" : " ") + text));
|
|
125962
|
+
parts.push(linkTextPart(name + (suffix || text.indexOf("://") === 0 ? "" : " ") + text));
|
|
125827
125963
|
}
|
|
125828
125964
|
}
|
|
125829
125965
|
parts.push(linkPart("}"));
|
|
@@ -126644,15 +126780,35 @@ var ts;
|
|
|
126644
126780
|
return ts.isArray(valueOrArray) ? ts.first(valueOrArray) : valueOrArray;
|
|
126645
126781
|
}
|
|
126646
126782
|
ts.firstOrOnly = firstOrOnly;
|
|
126783
|
+
function getNamesForExportedSymbol(symbol, scriptTarget) {
|
|
126784
|
+
if (needsNameFromDeclaration(symbol)) {
|
|
126785
|
+
var fromDeclaration = getDefaultLikeExportNameFromDeclaration(symbol);
|
|
126786
|
+
if (fromDeclaration)
|
|
126787
|
+
return fromDeclaration;
|
|
126788
|
+
var fileNameCase = ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, /*preferCapitalized*/ false);
|
|
126789
|
+
var capitalized = ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, /*preferCapitalized*/ true);
|
|
126790
|
+
if (fileNameCase === capitalized)
|
|
126791
|
+
return fileNameCase;
|
|
126792
|
+
return [fileNameCase, capitalized];
|
|
126793
|
+
}
|
|
126794
|
+
return symbol.name;
|
|
126795
|
+
}
|
|
126796
|
+
ts.getNamesForExportedSymbol = getNamesForExportedSymbol;
|
|
126647
126797
|
function getNameForExportedSymbol(symbol, scriptTarget, preferCapitalized) {
|
|
126648
|
-
if (
|
|
126798
|
+
if (needsNameFromDeclaration(symbol)) {
|
|
126649
126799
|
// Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase.
|
|
126650
|
-
return
|
|
126800
|
+
return getDefaultLikeExportNameFromDeclaration(symbol)
|
|
126651
126801
|
|| ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, !!preferCapitalized);
|
|
126652
126802
|
}
|
|
126653
126803
|
return symbol.name;
|
|
126654
126804
|
}
|
|
126655
126805
|
ts.getNameForExportedSymbol = getNameForExportedSymbol;
|
|
126806
|
+
function needsNameFromDeclaration(symbol) {
|
|
126807
|
+
return !(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */);
|
|
126808
|
+
}
|
|
126809
|
+
function getDefaultLikeExportNameFromDeclaration(symbol) {
|
|
126810
|
+
return ts.firstDefined(symbol.declarations, function (d) { var _a; return ts.isExportAssignment(d) ? (_a = ts.tryCast(ts.skipOuterExpressions(d.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text : undefined; });
|
|
126811
|
+
}
|
|
126656
126812
|
function getSymbolParentOrFail(symbol) {
|
|
126657
126813
|
var _a;
|
|
126658
126814
|
return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: " + ts.Debug.formatSymbolFlags(symbol.flags) + ". " +
|
|
@@ -126767,6 +126923,17 @@ var ts;
|
|
|
126767
126923
|
var exportInfoId = 1;
|
|
126768
126924
|
var exportInfo = ts.createMultiMap();
|
|
126769
126925
|
var symbols = new ts.Map();
|
|
126926
|
+
/**
|
|
126927
|
+
* Key: node_modules package name (no @types).
|
|
126928
|
+
* Value: path to deepest node_modules folder seen that is
|
|
126929
|
+
* both visible to `usableByFileName` and contains the package.
|
|
126930
|
+
*
|
|
126931
|
+
* Later, we can see if a given SymbolExportInfo is shadowed by
|
|
126932
|
+
* a another installation of the same package in a deeper
|
|
126933
|
+
* node_modules folder by seeing if its path starts with the
|
|
126934
|
+
* value stored here.
|
|
126935
|
+
*/
|
|
126936
|
+
var packages = new ts.Map();
|
|
126770
126937
|
var usableByFileName;
|
|
126771
126938
|
var cache = {
|
|
126772
126939
|
isUsableByFile: function (importingFile) { return importingFile === usableByFileName; },
|
|
@@ -126781,6 +126948,27 @@ var ts;
|
|
|
126781
126948
|
cache.clear();
|
|
126782
126949
|
usableByFileName = importingFile;
|
|
126783
126950
|
}
|
|
126951
|
+
var packageName;
|
|
126952
|
+
if (moduleFile) {
|
|
126953
|
+
var nodeModulesPathParts = ts.getNodeModulePathParts(moduleFile.fileName);
|
|
126954
|
+
if (nodeModulesPathParts) {
|
|
126955
|
+
var topLevelNodeModulesIndex = nodeModulesPathParts.topLevelNodeModulesIndex, topLevelPackageNameIndex = nodeModulesPathParts.topLevelPackageNameIndex, packageRootIndex = nodeModulesPathParts.packageRootIndex;
|
|
126956
|
+
packageName = ts.unmangleScopedPackageName(ts.getPackageNameFromTypesPackageName(moduleFile.fileName.substring(topLevelPackageNameIndex + 1, packageRootIndex)));
|
|
126957
|
+
if (ts.startsWith(importingFile, moduleFile.path.substring(0, topLevelNodeModulesIndex))) {
|
|
126958
|
+
var prevDeepestNodeModulesPath = packages.get(packageName);
|
|
126959
|
+
var nodeModulesPath = moduleFile.fileName.substring(0, topLevelPackageNameIndex);
|
|
126960
|
+
if (prevDeepestNodeModulesPath) {
|
|
126961
|
+
var prevDeepestNodeModulesIndex = prevDeepestNodeModulesPath.indexOf(ts.nodeModulesPathPart);
|
|
126962
|
+
if (topLevelNodeModulesIndex > prevDeepestNodeModulesIndex) {
|
|
126963
|
+
packages.set(packageName, nodeModulesPath);
|
|
126964
|
+
}
|
|
126965
|
+
}
|
|
126966
|
+
else {
|
|
126967
|
+
packages.set(packageName, nodeModulesPath);
|
|
126968
|
+
}
|
|
126969
|
+
}
|
|
126970
|
+
}
|
|
126971
|
+
}
|
|
126784
126972
|
var isDefault = exportKind === 1 /* Default */;
|
|
126785
126973
|
var namedSymbol = isDefault && ts.getLocalSymbolForExportDefault(symbol) || symbol;
|
|
126786
126974
|
// 1. A named export must be imported by its key in `moduleSymbol.exports` or `moduleSymbol.members`.
|
|
@@ -126790,9 +126978,11 @@ var ts;
|
|
|
126790
126978
|
// 3. Otherwise, we have a default/namespace import that can be imported by any name, and
|
|
126791
126979
|
// `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to
|
|
126792
126980
|
// get a better name.
|
|
126793
|
-
var
|
|
126981
|
+
var names = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
|
|
126794
126982
|
? ts.unescapeLeadingUnderscores(symbolTableKey)
|
|
126795
|
-
: ts.
|
|
126983
|
+
: ts.getNamesForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
|
|
126984
|
+
var symbolName = typeof names === "string" ? names : names[0];
|
|
126985
|
+
var capitalizedSymbolName = typeof names === "string" ? undefined : names[1];
|
|
126796
126986
|
var moduleName = ts.stripQuotes(moduleSymbol.name);
|
|
126797
126987
|
var id = exportInfoId++;
|
|
126798
126988
|
var target = ts.skipAlias(symbol, checker);
|
|
@@ -126800,13 +126990,15 @@ var ts;
|
|
|
126800
126990
|
var storedModuleSymbol = moduleSymbol.flags & 33554432 /* Transient */ ? undefined : moduleSymbol;
|
|
126801
126991
|
if (!storedSymbol || !storedModuleSymbol)
|
|
126802
126992
|
symbols.set(id, [symbol, moduleSymbol]);
|
|
126803
|
-
exportInfo.add(key(
|
|
126993
|
+
exportInfo.add(key(symbolName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), {
|
|
126804
126994
|
id: id,
|
|
126805
126995
|
symbolTableKey: symbolTableKey,
|
|
126806
|
-
symbolName:
|
|
126996
|
+
symbolName: symbolName,
|
|
126997
|
+
capitalizedSymbolName: capitalizedSymbolName,
|
|
126807
126998
|
moduleName: moduleName,
|
|
126808
126999
|
moduleFile: moduleFile,
|
|
126809
127000
|
moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName,
|
|
127001
|
+
packageName: packageName,
|
|
126810
127002
|
exportKind: exportKind,
|
|
126811
127003
|
targetFlags: target.flags,
|
|
126812
127004
|
isFromPackageJson: isFromPackageJson,
|
|
@@ -126820,19 +127012,19 @@ var ts;
|
|
|
126820
127012
|
var result = exportInfo.get(key);
|
|
126821
127013
|
return result === null || result === void 0 ? void 0 : result.map(rehydrateCachedInfo);
|
|
126822
127014
|
},
|
|
126823
|
-
|
|
127015
|
+
search: function (importingFile, preferCapitalized, matches, action) {
|
|
126824
127016
|
if (importingFile !== usableByFileName)
|
|
126825
127017
|
return;
|
|
126826
127018
|
exportInfo.forEach(function (info, key) {
|
|
126827
127019
|
var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
|
|
126828
|
-
var
|
|
126829
|
-
|
|
126830
|
-
var
|
|
126831
|
-
var
|
|
126832
|
-
|
|
126833
|
-
|
|
126834
|
-
|
|
126835
|
-
}
|
|
127020
|
+
var name = preferCapitalized && info[0].capitalizedSymbolName || symbolName;
|
|
127021
|
+
if (matches(name, info[0].targetFlags)) {
|
|
127022
|
+
var rehydrated = info.map(rehydrateCachedInfo);
|
|
127023
|
+
var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
|
|
127024
|
+
if (filtered.length) {
|
|
127025
|
+
action(filtered, name, !!ambientModuleName, key);
|
|
127026
|
+
}
|
|
127027
|
+
}
|
|
126836
127028
|
});
|
|
126837
127029
|
},
|
|
126838
127030
|
releaseSymbols: function () {
|
|
@@ -126932,6 +127124,12 @@ var ts;
|
|
|
126932
127124
|
}
|
|
126933
127125
|
return true;
|
|
126934
127126
|
}
|
|
127127
|
+
function isNotShadowedByDeeperNodeModulesPackage(info, packageName) {
|
|
127128
|
+
if (!packageName || !info.moduleFileName)
|
|
127129
|
+
return true;
|
|
127130
|
+
var packageDeepestNodeModulesPath = packages.get(packageName);
|
|
127131
|
+
return !packageDeepestNodeModulesPath || ts.startsWith(info.moduleFileName, packageDeepestNodeModulesPath);
|
|
127132
|
+
}
|
|
126935
127133
|
}
|
|
126936
127134
|
ts.createCacheableExportInfoMap = createCacheableExportInfoMap;
|
|
126937
127135
|
function isImportableFile(program, from, to, preferences, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) {
|
|
@@ -129242,7 +129440,7 @@ var ts;
|
|
|
129242
129440
|
}
|
|
129243
129441
|
switch (completionData.kind) {
|
|
129244
129442
|
case 0 /* Data */:
|
|
129245
|
-
var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext);
|
|
129443
|
+
var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position);
|
|
129246
129444
|
if (response === null || response === void 0 ? void 0 : response.isIncomplete) {
|
|
129247
129445
|
incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response);
|
|
129248
129446
|
}
|
|
@@ -129362,7 +129560,7 @@ var ts;
|
|
|
129362
129560
|
// StringLiteralLike locations are handled separately in stringCompletions.ts
|
|
129363
129561
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
129364
129562
|
}
|
|
129365
|
-
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext) {
|
|
129563
|
+
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) {
|
|
129366
129564
|
var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
|
|
129367
129565
|
// Verify if the file is JSX language variant
|
|
129368
129566
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
|
|
@@ -129375,7 +129573,7 @@ var ts;
|
|
|
129375
129573
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
129376
129574
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
129377
129575
|
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
129378
|
-
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
|
|
129576
|
+
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
|
|
129379
129577
|
}
|
|
129380
129578
|
else {
|
|
129381
129579
|
if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
|
|
@@ -129385,16 +129583,23 @@ var ts;
|
|
|
129385
129583
|
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
129386
129584
|
}
|
|
129387
129585
|
if (keywordFilters !== 0 /* None */) {
|
|
129388
|
-
var
|
|
129586
|
+
var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
129389
129587
|
for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
|
|
129390
129588
|
var keywordEntry = _a[_i];
|
|
129391
|
-
if (!
|
|
129589
|
+
if (!entryNames_1.has(keywordEntry.name)) {
|
|
129392
129590
|
ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129393
129591
|
}
|
|
129394
129592
|
}
|
|
129395
129593
|
}
|
|
129396
|
-
|
|
129397
|
-
|
|
129594
|
+
var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
129595
|
+
for (var _b = 0, _c = getContextualKeywords(contextToken, position); _b < _c.length; _b++) {
|
|
129596
|
+
var keywordEntry = _c[_b];
|
|
129597
|
+
if (!entryNames.has(keywordEntry.name)) {
|
|
129598
|
+
ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129599
|
+
}
|
|
129600
|
+
}
|
|
129601
|
+
for (var _d = 0, literals_1 = literals; _d < literals_1.length; _d++) {
|
|
129602
|
+
var literal = literals_1[_d];
|
|
129398
129603
|
ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
|
|
129399
129604
|
}
|
|
129400
129605
|
return {
|
|
@@ -130934,44 +131139,47 @@ var ts;
|
|
|
130934
131139
|
var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
|
|
130935
131140
|
var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
|
|
130936
131141
|
resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
|
|
130937
|
-
exportInfo.
|
|
130938
|
-
|
|
131142
|
+
exportInfo.search(sourceFile.path,
|
|
131143
|
+
/*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
|
|
130939
131144
|
if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
|
|
130940
|
-
return;
|
|
131145
|
+
return false;
|
|
130941
131146
|
if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
|
|
130942
|
-
return;
|
|
130943
|
-
|
|
130944
|
-
|
|
130945
|
-
|
|
130946
|
-
|
|
130947
|
-
return;
|
|
131147
|
+
return false;
|
|
131148
|
+
if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* Value */))
|
|
131149
|
+
return false;
|
|
131150
|
+
if (isTypeOnlyLocation && !(targetFlags & (1536 /* Module */ | 788968 /* Type */)))
|
|
131151
|
+
return false;
|
|
130948
131152
|
// Do not try to auto-import something with a lowercase first letter for a JSX tag
|
|
130949
131153
|
var firstChar = symbolName.charCodeAt(0);
|
|
130950
131154
|
if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */))
|
|
131155
|
+
return false;
|
|
131156
|
+
if (detailsEntryId)
|
|
131157
|
+
return true;
|
|
131158
|
+
return charactersFuzzyMatchInString(symbolName, lowerCaseTokenText);
|
|
131159
|
+
}, function (info, symbolName, isFromAmbientModule, exportMapKey) {
|
|
131160
|
+
if (detailsEntryId && !ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); })) {
|
|
130951
131161
|
return;
|
|
130952
|
-
var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); });
|
|
130953
|
-
if (isCompletionDetailsMatch || !detailsEntryId && charactersFuzzyMatchInString(symbolName, lowerCaseTokenText)) {
|
|
130954
|
-
var defaultExportInfo = ts.find(info, isImportableExportInfo);
|
|
130955
|
-
if (!defaultExportInfo) {
|
|
130956
|
-
return;
|
|
130957
|
-
}
|
|
130958
|
-
// If we don't need to resolve module specifiers, we can use any re-export that is importable at all
|
|
130959
|
-
// (We need to ensure that at least one is importable to show a completion.)
|
|
130960
|
-
var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo_1 = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
|
|
130961
|
-
var isDefaultExport = exportInfo_1.exportKind === 1 /* Default */;
|
|
130962
|
-
var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo_1.symbol) || exportInfo_1.symbol;
|
|
130963
|
-
pushAutoImportSymbol(symbol, {
|
|
130964
|
-
kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
|
|
130965
|
-
moduleSpecifier: moduleSpecifier,
|
|
130966
|
-
symbolName: symbolName,
|
|
130967
|
-
exportMapKey: exportMapKey,
|
|
130968
|
-
exportName: exportInfo_1.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo_1.symbol.name,
|
|
130969
|
-
fileName: exportInfo_1.moduleFileName,
|
|
130970
|
-
isDefaultExport: isDefaultExport,
|
|
130971
|
-
moduleSymbol: exportInfo_1.moduleSymbol,
|
|
130972
|
-
isFromPackageJson: exportInfo_1.isFromPackageJson,
|
|
130973
|
-
});
|
|
130974
131162
|
}
|
|
131163
|
+
var defaultExportInfo = ts.find(info, isImportableExportInfo);
|
|
131164
|
+
if (!defaultExportInfo) {
|
|
131165
|
+
return;
|
|
131166
|
+
}
|
|
131167
|
+
// If we don't need to resolve module specifiers, we can use any re-export that is importable at all
|
|
131168
|
+
// (We need to ensure that at least one is importable to show a completion.)
|
|
131169
|
+
var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
|
|
131170
|
+
var isDefaultExport = exportInfo.exportKind === 1 /* Default */;
|
|
131171
|
+
var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol;
|
|
131172
|
+
pushAutoImportSymbol(symbol, {
|
|
131173
|
+
kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
|
|
131174
|
+
moduleSpecifier: moduleSpecifier,
|
|
131175
|
+
symbolName: symbolName,
|
|
131176
|
+
exportMapKey: exportMapKey,
|
|
131177
|
+
exportName: exportInfo.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo.symbol.name,
|
|
131178
|
+
fileName: exportInfo.moduleFileName,
|
|
131179
|
+
isDefaultExport: isDefaultExport,
|
|
131180
|
+
moduleSymbol: exportInfo.moduleSymbol,
|
|
131181
|
+
isFromPackageJson: exportInfo.isFromPackageJson,
|
|
131182
|
+
});
|
|
130975
131183
|
});
|
|
130976
131184
|
hasUnresolvedAutoImports = context.resolutionLimitExceeded();
|
|
130977
131185
|
});
|
|
@@ -131944,6 +132152,34 @@ var ts;
|
|
|
131944
132152
|
function keywordForNode(node) {
|
|
131945
132153
|
return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind;
|
|
131946
132154
|
}
|
|
132155
|
+
function getContextualKeywords(contextToken, position) {
|
|
132156
|
+
var entries = [];
|
|
132157
|
+
/**
|
|
132158
|
+
* An `AssertClause` can come after an import declaration:
|
|
132159
|
+
* import * from "foo" |
|
|
132160
|
+
* import "foo" |
|
|
132161
|
+
* or after a re-export declaration that has a module specifier:
|
|
132162
|
+
* export { foo } from "foo" |
|
|
132163
|
+
* Source: https://tc39.es/proposal-import-assertions/
|
|
132164
|
+
*/
|
|
132165
|
+
if (contextToken) {
|
|
132166
|
+
var file = contextToken.getSourceFile();
|
|
132167
|
+
var parent = contextToken.parent;
|
|
132168
|
+
var tokenLine = file.getLineAndCharacterOfPosition(contextToken.end).line;
|
|
132169
|
+
var currentLine = file.getLineAndCharacterOfPosition(position).line;
|
|
132170
|
+
if ((ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent) && parent.moduleSpecifier)
|
|
132171
|
+
&& contextToken === parent.moduleSpecifier
|
|
132172
|
+
&& tokenLine === currentLine) {
|
|
132173
|
+
entries.push({
|
|
132174
|
+
name: ts.tokenToString(129 /* AssertKeyword */),
|
|
132175
|
+
kind: "keyword" /* keyword */,
|
|
132176
|
+
kindModifiers: "" /* none */,
|
|
132177
|
+
sortText: SortText.GlobalsOrKeywords,
|
|
132178
|
+
});
|
|
132179
|
+
}
|
|
132180
|
+
}
|
|
132181
|
+
return entries;
|
|
132182
|
+
}
|
|
131947
132183
|
/** Get the corresponding JSDocTag node if the position is in a jsDoc comment */
|
|
131948
132184
|
function getJsDocTagAtPosition(node, position) {
|
|
131949
132185
|
return ts.findAncestor(node, function (n) {
|
|
@@ -136882,7 +137118,27 @@ var ts;
|
|
|
136882
137118
|
case 326 /* JSDocAugmentsTag */:
|
|
136883
137119
|
return withNode(tag.class);
|
|
136884
137120
|
case 342 /* JSDocTemplateTag */:
|
|
136885
|
-
|
|
137121
|
+
var templateTag = tag;
|
|
137122
|
+
var displayParts_3 = [];
|
|
137123
|
+
if (templateTag.constraint) {
|
|
137124
|
+
displayParts_3.push(ts.textPart(templateTag.constraint.getText()));
|
|
137125
|
+
}
|
|
137126
|
+
if (ts.length(templateTag.typeParameters)) {
|
|
137127
|
+
if (ts.length(displayParts_3)) {
|
|
137128
|
+
displayParts_3.push(ts.spacePart());
|
|
137129
|
+
}
|
|
137130
|
+
var lastTypeParameter_1 = templateTag.typeParameters[templateTag.typeParameters.length - 1];
|
|
137131
|
+
ts.forEach(templateTag.typeParameters, function (tp) {
|
|
137132
|
+
displayParts_3.push(namePart(tp.getText()));
|
|
137133
|
+
if (lastTypeParameter_1 !== tp) {
|
|
137134
|
+
displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]);
|
|
137135
|
+
}
|
|
137136
|
+
});
|
|
137137
|
+
}
|
|
137138
|
+
if (comment) {
|
|
137139
|
+
displayParts_3.push.apply(displayParts_3, __spreadArray([ts.spacePart()], getDisplayPartsFromComment(comment, checker), true));
|
|
137140
|
+
}
|
|
137141
|
+
return displayParts_3;
|
|
136886
137142
|
case 341 /* JSDocTypeTag */:
|
|
136887
137143
|
return withNode(tag.typeExpression);
|
|
136888
137144
|
case 343 /* JSDocTypedefTag */:
|
|
@@ -138370,7 +138626,7 @@ var ts;
|
|
|
138370
138626
|
newImportSpecifiers.push(ts.factory.createImportSpecifier(/*isTypeOnly*/ false, ts.factory.createIdentifier("default"), defaultImport.importClause.name)); // TODO: GH#18217
|
|
138371
138627
|
}
|
|
138372
138628
|
}
|
|
138373
|
-
newImportSpecifiers.push.apply(newImportSpecifiers,
|
|
138629
|
+
newImportSpecifiers.push.apply(newImportSpecifiers, getNewImportSpecifiers(namedImports));
|
|
138374
138630
|
var sortedImportSpecifiers = sortSpecifiers(newImportSpecifiers);
|
|
138375
138631
|
var importDecl = defaultImports.length > 0
|
|
138376
138632
|
? defaultImports[0]
|
|
@@ -138580,6 +138836,21 @@ var ts;
|
|
|
138580
138836
|
return 6;
|
|
138581
138837
|
}
|
|
138582
138838
|
}
|
|
138839
|
+
function getNewImportSpecifiers(namedImports) {
|
|
138840
|
+
return ts.flatMap(namedImports, function (namedImport) {
|
|
138841
|
+
return ts.map(tryGetNamedBindingElements(namedImport), function (importSpecifier) {
|
|
138842
|
+
return importSpecifier.name && importSpecifier.propertyName && importSpecifier.name.escapedText === importSpecifier.propertyName.escapedText
|
|
138843
|
+
? ts.factory.updateImportSpecifier(importSpecifier, importSpecifier.isTypeOnly, /*propertyName*/ undefined, importSpecifier.name)
|
|
138844
|
+
: importSpecifier;
|
|
138845
|
+
});
|
|
138846
|
+
});
|
|
138847
|
+
}
|
|
138848
|
+
function tryGetNamedBindingElements(namedImport) {
|
|
138849
|
+
var _a;
|
|
138850
|
+
return ((_a = namedImport.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings) && ts.isNamedImports(namedImport.importClause.namedBindings)
|
|
138851
|
+
? namedImport.importClause.namedBindings.elements
|
|
138852
|
+
: undefined;
|
|
138853
|
+
}
|
|
138583
138854
|
})(OrganizeImports = ts.OrganizeImports || (ts.OrganizeImports = {}));
|
|
138584
138855
|
})(ts || (ts = {}));
|
|
138585
138856
|
/* @internal */
|
|
@@ -140293,12 +140564,12 @@ var ts;
|
|
|
140293
140564
|
: { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex };
|
|
140294
140565
|
}
|
|
140295
140566
|
SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions;
|
|
140296
|
-
function getArgumentOrParameterListInfo(node, sourceFile) {
|
|
140567
|
+
function getArgumentOrParameterListInfo(node, position, sourceFile) {
|
|
140297
140568
|
var info = getArgumentOrParameterListAndIndex(node, sourceFile);
|
|
140298
140569
|
if (!info)
|
|
140299
140570
|
return undefined;
|
|
140300
140571
|
var list = info.list, argumentIndex = info.argumentIndex;
|
|
140301
|
-
var argumentCount = getArgumentCount(list);
|
|
140572
|
+
var argumentCount = getArgumentCount(list, /*ignoreTrailingComma*/ ts.isInString(sourceFile, position, node));
|
|
140302
140573
|
if (argumentIndex !== 0) {
|
|
140303
140574
|
ts.Debug.assertLessThan(argumentIndex, argumentCount);
|
|
140304
140575
|
}
|
|
@@ -140344,7 +140615,7 @@ var ts;
|
|
|
140344
140615
|
// Case 3:
|
|
140345
140616
|
// foo<T#, U#>(a#, #b#) -> The token is buried inside a list, and should give signature help
|
|
140346
140617
|
// Find out if 'node' is an argument, a type argument, or neither
|
|
140347
|
-
var info = getArgumentOrParameterListInfo(node, sourceFile);
|
|
140618
|
+
var info = getArgumentOrParameterListInfo(node, position, sourceFile);
|
|
140348
140619
|
if (!info)
|
|
140349
140620
|
return undefined;
|
|
140350
140621
|
var list = info.list, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
|
|
@@ -140413,8 +140684,8 @@ var ts;
|
|
|
140413
140684
|
function countBinaryExpressionParameters(b) {
|
|
140414
140685
|
return ts.isBinaryExpression(b.left) ? countBinaryExpressionParameters(b.left) + 1 : 2;
|
|
140415
140686
|
}
|
|
140416
|
-
function tryGetParameterInfo(startingToken,
|
|
140417
|
-
var info = getContextualSignatureLocationInfo(startingToken, sourceFile, checker);
|
|
140687
|
+
function tryGetParameterInfo(startingToken, position, sourceFile, checker) {
|
|
140688
|
+
var info = getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker);
|
|
140418
140689
|
if (!info)
|
|
140419
140690
|
return undefined;
|
|
140420
140691
|
var contextualType = info.contextualType, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
|
|
@@ -140426,7 +140697,7 @@ var ts;
|
|
|
140426
140697
|
var invocation = { kind: 2 /* Contextual */, signature: ts.first(signatures), node: startingToken, symbol: chooseBetterSymbol(nonNullableContextualType.symbol) };
|
|
140427
140698
|
return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount };
|
|
140428
140699
|
}
|
|
140429
|
-
function getContextualSignatureLocationInfo(startingToken, sourceFile, checker) {
|
|
140700
|
+
function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) {
|
|
140430
140701
|
if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */)
|
|
140431
140702
|
return undefined;
|
|
140432
140703
|
var parent = startingToken.parent;
|
|
@@ -140435,7 +140706,7 @@ var ts;
|
|
|
140435
140706
|
case 168 /* MethodDeclaration */:
|
|
140436
140707
|
case 212 /* FunctionExpression */:
|
|
140437
140708
|
case 213 /* ArrowFunction */:
|
|
140438
|
-
var info = getArgumentOrParameterListInfo(startingToken, sourceFile);
|
|
140709
|
+
var info = getArgumentOrParameterListInfo(startingToken, position, sourceFile);
|
|
140439
140710
|
if (!info)
|
|
140440
140711
|
return undefined;
|
|
140441
140712
|
var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
|
|
@@ -140482,7 +140753,7 @@ var ts;
|
|
|
140482
140753
|
}
|
|
140483
140754
|
return argumentIndex;
|
|
140484
140755
|
}
|
|
140485
|
-
function getArgumentCount(argumentsList) {
|
|
140756
|
+
function getArgumentCount(argumentsList, ignoreTrailingComma) {
|
|
140486
140757
|
// The argument count for a list is normally the number of non-comma children it has.
|
|
140487
140758
|
// For example, if you have "Foo(a,b)" then there will be three children of the arg
|
|
140488
140759
|
// list 'a' '<comma>' 'b'. So, in this case the arg count will be 2. However, there
|
|
@@ -140496,7 +140767,7 @@ var ts;
|
|
|
140496
140767
|
// arg count of 3.
|
|
140497
140768
|
var listChildren = argumentsList.getChildren();
|
|
140498
140769
|
var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; });
|
|
140499
|
-
if (listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) {
|
|
140770
|
+
if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) {
|
|
140500
140771
|
argumentCount++;
|
|
140501
140772
|
}
|
|
140502
140773
|
return argumentCount;
|
|
@@ -141442,7 +141713,7 @@ var ts;
|
|
|
141442
141713
|
if (typeChecker.isArgumentsSymbol(symbol)) {
|
|
141443
141714
|
return "local var" /* localVariableElement */;
|
|
141444
141715
|
}
|
|
141445
|
-
if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location)) {
|
|
141716
|
+
if (location.kind === 108 /* ThisKeyword */ && ts.isExpression(location) || ts.isThisInTypeQuery(location)) {
|
|
141446
141717
|
return "parameter" /* parameterElement */;
|
|
141447
141718
|
}
|
|
141448
141719
|
var flags = ts.getCombinedLocalAndExportSymbolFlags(symbol);
|
|
@@ -141537,7 +141808,7 @@ var ts;
|
|
|
141537
141808
|
var symbolFlags = ts.getCombinedLocalAndExportSymbolFlags(symbol);
|
|
141538
141809
|
var symbolKind = semanticMeaning & 1 /* Value */ ? getSymbolKindOfConstructorPropertyMethodAccessorFunctionOrVar(typeChecker, symbol, location) : "" /* unknown */;
|
|
141539
141810
|
var hasAddedSymbolInfo = false;
|
|
141540
|
-
var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location);
|
|
141811
|
+
var isThisExpression = location.kind === 108 /* ThisKeyword */ && ts.isInExpressionContext(location) || ts.isThisInTypeQuery(location);
|
|
141541
141812
|
var type;
|
|
141542
141813
|
var printer;
|
|
141543
141814
|
var documentationFromAlias;
|
|
@@ -141950,6 +142221,18 @@ var ts;
|
|
|
141950
142221
|
}
|
|
141951
142222
|
}
|
|
141952
142223
|
}
|
|
142224
|
+
if (documentation.length === 0 && ts.isIdentifier(location) && symbol.valueDeclaration && ts.isBindingElement(symbol.valueDeclaration)) {
|
|
142225
|
+
var declaration = symbol.valueDeclaration;
|
|
142226
|
+
var parent = declaration.parent;
|
|
142227
|
+
if (ts.isIdentifier(declaration.name) && ts.isObjectBindingPattern(parent)) {
|
|
142228
|
+
var name_4 = ts.getTextOfIdentifierOrLiteral(declaration.name);
|
|
142229
|
+
var objectType = typeChecker.getTypeAtLocation(parent);
|
|
142230
|
+
documentation = ts.firstDefined(objectType.isUnion() ? objectType.types : [objectType], function (t) {
|
|
142231
|
+
var prop = t.getProperty(name_4);
|
|
142232
|
+
return prop ? prop.getDocumentationComment(typeChecker) : undefined;
|
|
142233
|
+
}) || ts.emptyArray;
|
|
142234
|
+
}
|
|
142235
|
+
}
|
|
141953
142236
|
if (tags.length === 0 && !hasMultipleSignatures) {
|
|
141954
142237
|
tags = symbol.getContextualJsDocTags(enclosingDeclaration, typeChecker);
|
|
141955
142238
|
}
|
|
@@ -149296,9 +149579,10 @@ var ts;
|
|
|
149296
149579
|
var info = getFixesInfo(context, errorCode, span.start, /*useAutoImportProvider*/ true);
|
|
149297
149580
|
if (!info)
|
|
149298
149581
|
return undefined;
|
|
149299
|
-
var fixes = info.fixes, symbolName = info.symbolName;
|
|
149582
|
+
var fixes = info.fixes, symbolName = info.symbolName, errorIdentifierText = info.errorIdentifierText;
|
|
149300
149583
|
var quotePreference = ts.getQuotePreference(sourceFile, preferences);
|
|
149301
|
-
return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix,
|
|
149584
|
+
return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix,
|
|
149585
|
+
/*includeSymbolNameInDescription*/ symbolName !== errorIdentifierText, quotePreference, program.getCompilerOptions()); });
|
|
149302
149586
|
},
|
|
149303
149587
|
fixIds: [importFixId],
|
|
149304
149588
|
getAllCodeActions: function (context) {
|
|
@@ -149337,7 +149621,7 @@ var ts;
|
|
|
149337
149621
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
149338
149622
|
var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
|
|
149339
149623
|
if (fix) {
|
|
149340
|
-
addImport({ fixes: [fix], symbolName: symbolName });
|
|
149624
|
+
addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
|
|
149341
149625
|
}
|
|
149342
149626
|
}
|
|
149343
149627
|
function addImport(info) {
|
|
@@ -149508,7 +149792,8 @@ var ts;
|
|
|
149508
149792
|
var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences));
|
|
149509
149793
|
return {
|
|
149510
149794
|
moduleSpecifier: fix.moduleSpecifier,
|
|
149511
|
-
codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix,
|
|
149795
|
+
codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix,
|
|
149796
|
+
/*includeSymbolNameInDescription*/ false, ts.getQuotePreference(sourceFile, preferences), compilerOptions))
|
|
149512
149797
|
};
|
|
149513
149798
|
}
|
|
149514
149799
|
codefix.getImportCompletionAction = getImportCompletionAction;
|
|
@@ -149516,7 +149801,8 @@ var ts;
|
|
|
149516
149801
|
var compilerOptions = program.getCompilerOptions();
|
|
149517
149802
|
var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions);
|
|
149518
149803
|
var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program);
|
|
149519
|
-
|
|
149804
|
+
var includeSymbolNameInDescription = symbolName !== symbolToken.text;
|
|
149805
|
+
return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions));
|
|
149520
149806
|
}
|
|
149521
149807
|
codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction;
|
|
149522
149808
|
function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
|
|
@@ -149809,7 +150095,7 @@ var ts;
|
|
|
149809
150095
|
else if (errorCode === ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code) {
|
|
149810
150096
|
var symbolName_1 = getSymbolName(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions());
|
|
149811
150097
|
var fix = getTypeOnlyPromotionFix(context.sourceFile, symbolToken, symbolName_1, context.program);
|
|
149812
|
-
return fix && { fixes: [fix], symbolName: symbolName_1 };
|
|
150098
|
+
return fix && { fixes: [fix], symbolName: symbolName_1, errorIdentifierText: symbolToken.text };
|
|
149813
150099
|
}
|
|
149814
150100
|
else {
|
|
149815
150101
|
info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
|
|
@@ -149854,6 +150140,7 @@ var ts;
|
|
|
149854
150140
|
return 0 /* EqualTo */;
|
|
149855
150141
|
}
|
|
149856
150142
|
function getFixesInfoForUMDImport(_a, token) {
|
|
150143
|
+
var _b;
|
|
149857
150144
|
var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences;
|
|
149858
150145
|
var checker = program.getTypeChecker();
|
|
149859
150146
|
var umdSymbol = getUmdSymbol(token, checker);
|
|
@@ -149864,7 +150151,7 @@ var ts;
|
|
|
149864
150151
|
var exportInfos = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
|
|
149865
150152
|
var useRequire = shouldUseRequire(sourceFile, program);
|
|
149866
150153
|
var fixes = getImportFixes(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
|
|
149867
|
-
return { fixes: fixes, symbolName: symbolName };
|
|
150154
|
+
return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
|
|
149868
150155
|
}
|
|
149869
150156
|
function getUmdSymbol(token, checker) {
|
|
149870
150157
|
// try the identifier to see if it is the umd symbol
|
|
@@ -149935,7 +150222,7 @@ var ts;
|
|
|
149935
150222
|
var _ = _a[0], exportInfos = _a[1];
|
|
149936
150223
|
return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
|
|
149937
150224
|
}));
|
|
149938
|
-
return { fixes: fixes, symbolName: symbolName };
|
|
150225
|
+
return { fixes: fixes, symbolName: symbolName, errorIdentifierText: symbolToken.text };
|
|
149939
150226
|
}
|
|
149940
150227
|
function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) {
|
|
149941
150228
|
var checker = program.getTypeChecker();
|
|
@@ -150030,14 +150317,14 @@ var ts;
|
|
|
150030
150317
|
// allowSyntheticDefaultImports/esModuleInterop is enabled.
|
|
150031
150318
|
return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */;
|
|
150032
150319
|
}
|
|
150033
|
-
function codeActionForFix(context, sourceFile, symbolName, fix, quotePreference, compilerOptions) {
|
|
150320
|
+
function codeActionForFix(context, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) {
|
|
150034
150321
|
var diag;
|
|
150035
150322
|
var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) {
|
|
150036
|
-
diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, quotePreference, compilerOptions);
|
|
150323
|
+
diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions);
|
|
150037
150324
|
});
|
|
150038
150325
|
return codefix.createCodeFixAction(codefix.importFixName, changes, diag, importFixId, ts.Diagnostics.Add_all_missing_imports);
|
|
150039
150326
|
}
|
|
150040
|
-
function codeActionForFixWorker(changes, sourceFile, symbolName, fix, quotePreference, compilerOptions) {
|
|
150327
|
+
function codeActionForFixWorker(changes, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) {
|
|
150041
150328
|
switch (fix.kind) {
|
|
150042
150329
|
case 0 /* UseNamespace */:
|
|
150043
150330
|
addNamespaceQualifier(changes, sourceFile, fix);
|
|
@@ -150049,11 +150336,9 @@ var ts;
|
|
|
150049
150336
|
var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly, moduleSpecifier = fix.moduleSpecifier;
|
|
150050
150337
|
doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions);
|
|
150051
150338
|
var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier);
|
|
150052
|
-
return
|
|
150053
|
-
|
|
150054
|
-
|
|
150055
|
-
moduleSpecifierWithoutQuotes
|
|
150056
|
-
]; // you too!
|
|
150339
|
+
return includeSymbolNameInDescription
|
|
150340
|
+
? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifierWithoutQuotes]
|
|
150341
|
+
: [ts.Diagnostics.Update_import_from_0, moduleSpecifierWithoutQuotes];
|
|
150057
150342
|
}
|
|
150058
150343
|
case 3 /* AddNew */: {
|
|
150059
150344
|
var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, addAsTypeOnly = fix.addAsTypeOnly, useRequire = fix.useRequire;
|
|
@@ -150062,7 +150347,9 @@ var ts;
|
|
|
150062
150347
|
var namedImports = importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined;
|
|
150063
150348
|
var namespaceLikeImport = importKind === 2 /* Namespace */ || importKind === 3 /* CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined;
|
|
150064
150349
|
ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true);
|
|
150065
|
-
return
|
|
150350
|
+
return includeSymbolNameInDescription
|
|
150351
|
+
? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifier]
|
|
150352
|
+
: [ts.Diagnostics.Add_import_from_0, moduleSpecifier];
|
|
150066
150353
|
}
|
|
150067
150354
|
case 4 /* PromoteTypeOnly */: {
|
|
150068
150355
|
var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration;
|
|
@@ -155479,51 +155766,53 @@ var ts;
|
|
|
155479
155766
|
(function (ts) {
|
|
155480
155767
|
var refactor;
|
|
155481
155768
|
(function (refactor) {
|
|
155769
|
+
var _a;
|
|
155482
155770
|
var refactorName = "Convert import";
|
|
155483
|
-
var
|
|
155484
|
-
|
|
155485
|
-
|
|
155486
|
-
|
|
155487
|
-
|
|
155488
|
-
|
|
155489
|
-
|
|
155490
|
-
|
|
155491
|
-
|
|
155492
|
-
|
|
155771
|
+
var actions = (_a = {},
|
|
155772
|
+
_a[0 /* Named */] = {
|
|
155773
|
+
name: "Convert namespace import to named imports",
|
|
155774
|
+
description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message,
|
|
155775
|
+
kind: "refactor.rewrite.import.named",
|
|
155776
|
+
},
|
|
155777
|
+
_a[2 /* Namespace */] = {
|
|
155778
|
+
name: "Convert named imports to namespace import",
|
|
155779
|
+
description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message,
|
|
155780
|
+
kind: "refactor.rewrite.import.namespace",
|
|
155781
|
+
},
|
|
155782
|
+
_a[1 /* Default */] = {
|
|
155783
|
+
name: "Convert named imports to default import",
|
|
155784
|
+
description: ts.Diagnostics.Convert_named_imports_to_default_import.message,
|
|
155785
|
+
kind: "refactor.rewrite.import.default",
|
|
155786
|
+
},
|
|
155787
|
+
_a);
|
|
155493
155788
|
refactor.registerRefactor(refactorName, {
|
|
155494
|
-
kinds:
|
|
155495
|
-
namespaceToNamedAction.kind,
|
|
155496
|
-
namedToNamespaceAction.kind
|
|
155497
|
-
],
|
|
155789
|
+
kinds: ts.getOwnValues(actions).map(function (a) { return a.kind; }),
|
|
155498
155790
|
getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndNamespacedImports(context) {
|
|
155499
|
-
var info =
|
|
155791
|
+
var info = getImportConversionInfo(context, context.triggerReason === "invoked");
|
|
155500
155792
|
if (!info)
|
|
155501
155793
|
return ts.emptyArray;
|
|
155502
155794
|
if (!refactor.isRefactorErrorInfo(info)) {
|
|
155503
|
-
var
|
|
155504
|
-
var action = namespaceImport ? namespaceToNamedAction : namedToNamespaceAction;
|
|
155795
|
+
var action = actions[info.convertTo];
|
|
155505
155796
|
return [{ name: refactorName, description: action.description, actions: [action] }];
|
|
155506
155797
|
}
|
|
155507
155798
|
if (context.preferences.provideRefactorNotApplicableReason) {
|
|
155508
|
-
return
|
|
155509
|
-
|
|
155510
|
-
|
|
155511
|
-
|
|
155512
|
-
|
|
155513
|
-
];
|
|
155799
|
+
return ts.getOwnValues(actions).map(function (action) { return ({
|
|
155800
|
+
name: refactorName,
|
|
155801
|
+
description: action.description,
|
|
155802
|
+
actions: [__assign(__assign({}, action), { notApplicableReason: info.error })]
|
|
155803
|
+
}); });
|
|
155514
155804
|
}
|
|
155515
155805
|
return ts.emptyArray;
|
|
155516
155806
|
},
|
|
155517
155807
|
getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndNamespacedImports(context, actionName) {
|
|
155518
|
-
ts.Debug.assert(
|
|
155519
|
-
var info =
|
|
155808
|
+
ts.Debug.assert(ts.some(ts.getOwnValues(actions), function (action) { return action.name === actionName; }), "Unexpected action name");
|
|
155809
|
+
var info = getImportConversionInfo(context);
|
|
155520
155810
|
ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
|
|
155521
155811
|
var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, info); });
|
|
155522
155812
|
return { edits: edits, renameFilename: undefined, renameLocation: undefined };
|
|
155523
155813
|
}
|
|
155524
155814
|
});
|
|
155525
|
-
|
|
155526
|
-
function getImportToConvert(context, considerPartialSpans) {
|
|
155815
|
+
function getImportConversionInfo(context, considerPartialSpans) {
|
|
155527
155816
|
if (considerPartialSpans === void 0) { considerPartialSpans = true; }
|
|
155528
155817
|
var file = context.file;
|
|
155529
155818
|
var span = ts.getRefactorContextSpan(context);
|
|
@@ -155542,15 +155831,23 @@ var ts;
|
|
|
155542
155831
|
if (!importClause.namedBindings) {
|
|
155543
155832
|
return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_namespace_import_or_named_imports) };
|
|
155544
155833
|
}
|
|
155545
|
-
|
|
155834
|
+
if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
|
|
155835
|
+
return { convertTo: 0 /* Named */, import: importClause.namedBindings };
|
|
155836
|
+
}
|
|
155837
|
+
var compilerOptions = context.program.getCompilerOptions();
|
|
155838
|
+
var shouldUseDefault = ts.getAllowSyntheticDefaultImports(compilerOptions)
|
|
155839
|
+
&& isExportEqualsModule(importClause.parent.moduleSpecifier, context.program.getTypeChecker());
|
|
155840
|
+
return shouldUseDefault
|
|
155841
|
+
? { convertTo: 1 /* Default */, import: importClause.namedBindings }
|
|
155842
|
+
: { convertTo: 2 /* Namespace */, import: importClause.namedBindings };
|
|
155546
155843
|
}
|
|
155547
|
-
function doChange(sourceFile, program, changes,
|
|
155844
|
+
function doChange(sourceFile, program, changes, info) {
|
|
155548
155845
|
var checker = program.getTypeChecker();
|
|
155549
|
-
if (
|
|
155550
|
-
doChangeNamespaceToNamed(sourceFile, checker, changes,
|
|
155846
|
+
if (info.convertTo === 0 /* Named */) {
|
|
155847
|
+
doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
|
|
155551
155848
|
}
|
|
155552
155849
|
else {
|
|
155553
|
-
|
|
155850
|
+
doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, info.import, info.convertTo === 1 /* Default */);
|
|
155554
155851
|
}
|
|
155555
155852
|
}
|
|
155556
155853
|
function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) {
|
|
@@ -155600,7 +155897,7 @@ var ts;
|
|
|
155600
155897
|
function getLeftOfPropertyAccessOrQualifiedName(propertyAccessOrQualifiedName) {
|
|
155601
155898
|
return ts.isPropertyAccessExpression(propertyAccessOrQualifiedName) ? propertyAccessOrQualifiedName.expression : propertyAccessOrQualifiedName.left;
|
|
155602
155899
|
}
|
|
155603
|
-
function
|
|
155900
|
+
function doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, toConvert, shouldUseDefault) {
|
|
155604
155901
|
var importDecl = toConvert.parent.parent;
|
|
155605
155902
|
var moduleSpecifier = importDecl.moduleSpecifier;
|
|
155606
155903
|
var toConvertSymbols = new ts.Set();
|
|
@@ -155651,7 +155948,9 @@ var ts;
|
|
|
155651
155948
|
var element = _a[_i];
|
|
155652
155949
|
_loop_17(element);
|
|
155653
155950
|
}
|
|
155654
|
-
changes.replaceNode(sourceFile, toConvert,
|
|
155951
|
+
changes.replaceNode(sourceFile, toConvert, shouldUseDefault
|
|
155952
|
+
? ts.factory.createIdentifier(namespaceImportName)
|
|
155953
|
+
: ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName)));
|
|
155655
155954
|
if (neededNamedImports.size) {
|
|
155656
155955
|
var newNamedImports = ts.arrayFrom(neededNamedImports.values()).map(function (element) {
|
|
155657
155956
|
return ts.factory.createImportSpecifier(element.isTypeOnly, element.propertyName && ts.factory.createIdentifier(element.propertyName.text), ts.factory.createIdentifier(element.name.text));
|
|
@@ -155659,6 +155958,13 @@ var ts;
|
|
|
155659
155958
|
changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, newNamedImports));
|
|
155660
155959
|
}
|
|
155661
155960
|
}
|
|
155961
|
+
function isExportEqualsModule(moduleSpecifier, checker) {
|
|
155962
|
+
var externalModule = checker.resolveExternalModuleName(moduleSpecifier);
|
|
155963
|
+
if (!externalModule)
|
|
155964
|
+
return false;
|
|
155965
|
+
var exportEquals = checker.resolveExternalModuleSymbol(externalModule);
|
|
155966
|
+
return externalModule !== exportEquals;
|
|
155967
|
+
}
|
|
155662
155968
|
function updateImport(old, defaultImportName, elements) {
|
|
155663
155969
|
return ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImportName, elements && elements.length ? ts.factory.createNamedImports(elements) : undefined), old.moduleSpecifier, /*assertClause*/ undefined);
|
|
155664
155970
|
}
|
|
@@ -157922,14 +158228,22 @@ var ts;
|
|
|
157922
158228
|
var result = [];
|
|
157923
158229
|
return visitor(selection) ? undefined : result;
|
|
157924
158230
|
function visitor(node) {
|
|
157925
|
-
var _a;
|
|
157926
158231
|
if (ts.isTypeReferenceNode(node)) {
|
|
157927
158232
|
if (ts.isIdentifier(node.typeName)) {
|
|
157928
|
-
var
|
|
157929
|
-
var
|
|
157930
|
-
|
|
157931
|
-
|
|
157932
|
-
|
|
158233
|
+
var typeName = node.typeName;
|
|
158234
|
+
var symbol = checker.resolveName(typeName.text, typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true);
|
|
158235
|
+
for (var _i = 0, _a = (symbol === null || symbol === void 0 ? void 0 : symbol.declarations) || ts.emptyArray; _i < _a.length; _i++) {
|
|
158236
|
+
var decl = _a[_i];
|
|
158237
|
+
if (ts.isTypeParameterDeclaration(decl) && decl.getSourceFile() === file) {
|
|
158238
|
+
// skip extraction if the type node is in the range of the type parameter declaration.
|
|
158239
|
+
// function foo<T extends { a?: /**/T }>(): void;
|
|
158240
|
+
if (decl.name.escapedText === typeName.escapedText && rangeContainsSkipTrivia(decl, selection, file)) {
|
|
158241
|
+
return true;
|
|
158242
|
+
}
|
|
158243
|
+
if (rangeContainsSkipTrivia(statement, decl, file) && !rangeContainsSkipTrivia(selection, decl, file)) {
|
|
158244
|
+
ts.pushIfUnique(result, decl);
|
|
158245
|
+
break;
|
|
158246
|
+
}
|
|
157933
158247
|
}
|
|
157934
158248
|
}
|
|
157935
158249
|
}
|
|
@@ -158930,7 +159244,7 @@ var ts;
|
|
|
158930
159244
|
var convertParamsToDestructuredObject;
|
|
158931
159245
|
(function (convertParamsToDestructuredObject) {
|
|
158932
159246
|
var refactorName = "Convert parameters to destructured object";
|
|
158933
|
-
var minimumParameterLength =
|
|
159247
|
+
var minimumParameterLength = 1;
|
|
158934
159248
|
var refactorDescription = ts.getLocaleSpecificMessage(ts.Diagnostics.Convert_parameters_to_destructured_object);
|
|
158935
159249
|
var toDestructuredAction = {
|
|
158936
159250
|
name: refactorName,
|