typescript 4.5.4 → 4.5.5
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/tsc.js +19 -10
- package/lib/tsserver.js +48 -46
- package/lib/tsserverlibrary.js +48 -46
- package/lib/typescript.js +48 -46
- package/lib/typescriptServices.js +48 -46
- package/lib/typingsInstaller.js +22 -10
- package/package.json +1 -1
package/lib/tsc.js
CHANGED
|
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
69
69
|
var ts;
|
|
70
70
|
(function (ts) {
|
|
71
71
|
ts.versionMajorMinor = "4.5";
|
|
72
|
-
ts.version = "4.5.
|
|
72
|
+
ts.version = "4.5.5";
|
|
73
73
|
var NativeCollections;
|
|
74
74
|
(function (NativeCollections) {
|
|
75
75
|
function tryGetNativeMap() {
|
|
@@ -12247,7 +12247,7 @@ var ts;
|
|
|
12247
12247
|
}
|
|
12248
12248
|
ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression;
|
|
12249
12249
|
function getExternalModuleRequireArgument(node) {
|
|
12250
|
-
return
|
|
12250
|
+
return isVariableDeclarationInitializedToBareOrAccessedRequire(node) && getLeftmostAccessExpression(node.initializer).arguments[0];
|
|
12251
12251
|
}
|
|
12252
12252
|
ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument;
|
|
12253
12253
|
function isInternalModuleImportEqualsDeclaration(node) {
|
|
@@ -12301,17 +12301,26 @@ var ts;
|
|
|
12301
12301
|
return !requireStringLiteralLikeArgument || ts.isStringLiteralLike(arg);
|
|
12302
12302
|
}
|
|
12303
12303
|
ts.isRequireCall = isRequireCall;
|
|
12304
|
-
function
|
|
12304
|
+
function isVariableDeclarationInitializedToRequire(node) {
|
|
12305
|
+
return isVariableDeclarationInitializedWithRequireHelper(node, false);
|
|
12306
|
+
}
|
|
12307
|
+
ts.isVariableDeclarationInitializedToRequire = isVariableDeclarationInitializedToRequire;
|
|
12308
|
+
function isVariableDeclarationInitializedToBareOrAccessedRequire(node) {
|
|
12309
|
+
return isVariableDeclarationInitializedWithRequireHelper(node, true);
|
|
12310
|
+
}
|
|
12311
|
+
ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
|
|
12312
|
+
function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
|
|
12305
12313
|
if (node.kind === 202) {
|
|
12306
12314
|
node = node.parent.parent;
|
|
12307
12315
|
}
|
|
12308
|
-
return ts.isVariableDeclaration(node) &&
|
|
12316
|
+
return ts.isVariableDeclaration(node) &&
|
|
12317
|
+
!!node.initializer &&
|
|
12318
|
+
isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, true);
|
|
12309
12319
|
}
|
|
12310
|
-
ts.isRequireVariableDeclaration = isRequireVariableDeclaration;
|
|
12311
12320
|
function isRequireVariableStatement(node) {
|
|
12312
12321
|
return ts.isVariableStatement(node)
|
|
12313
12322
|
&& node.declarationList.declarations.length > 0
|
|
12314
|
-
&& ts.every(node.declarationList.declarations, function (decl) { return
|
|
12323
|
+
&& ts.every(node.declarationList.declarations, function (decl) { return isVariableDeclarationInitializedToRequire(decl); });
|
|
12315
12324
|
}
|
|
12316
12325
|
ts.isRequireVariableStatement = isRequireVariableStatement;
|
|
12317
12326
|
function isSingleOrDoubleQuote(charCode) {
|
|
@@ -37770,7 +37779,7 @@ var ts;
|
|
|
37770
37779
|
checkStrictModeEvalOrArguments(node, node.name);
|
|
37771
37780
|
}
|
|
37772
37781
|
if (!ts.isBindingPattern(node.name)) {
|
|
37773
|
-
if (ts.isInJSFile(node) && ts.
|
|
37782
|
+
if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node)) {
|
|
37774
37783
|
declareSymbolAndAddToSymbolTable(node, 2097152, 2097152);
|
|
37775
37784
|
}
|
|
37776
37785
|
else if (ts.isBlockOrCatchScoped(node)) {
|
|
@@ -40045,7 +40054,7 @@ var ts;
|
|
|
40045
40054
|
&& isAliasableOrJsExpression(node.parent.right)
|
|
40046
40055
|
|| node.kind === 295
|
|
40047
40056
|
|| node.kind === 294 && isAliasableOrJsExpression(node.initializer)
|
|
40048
|
-
|| ts.
|
|
40057
|
+
|| ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
|
|
40049
40058
|
}
|
|
40050
40059
|
function isAliasableOrJsExpression(e) {
|
|
40051
40060
|
return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
|
|
@@ -40901,7 +40910,7 @@ var ts;
|
|
|
40901
40910
|
if (!sigs || !sigs.length) {
|
|
40902
40911
|
sigs = getSignaturesOfStructuredType(type, 1);
|
|
40903
40912
|
}
|
|
40904
|
-
if ((sigs && sigs.length) || getPropertyOfType(type, "default")) {
|
|
40913
|
+
if ((sigs && sigs.length) || getPropertyOfType(type, "default", true)) {
|
|
40905
40914
|
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference);
|
|
40906
40915
|
return cloneTypeAsModuleType(symbol, moduleType, referenceParent);
|
|
40907
40916
|
}
|
|
@@ -67235,7 +67244,7 @@ var ts;
|
|
|
67235
67244
|
return;
|
|
67236
67245
|
}
|
|
67237
67246
|
var symbol = getSymbolOfNode(node);
|
|
67238
|
-
if (symbol.flags & 2097152 && ts.
|
|
67247
|
+
if (symbol.flags & 2097152 && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
|
|
67239
67248
|
checkAliasSymbol(node);
|
|
67240
67249
|
return;
|
|
67241
67250
|
}
|
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 = "4.5.
|
|
103
|
+
ts.version = "4.5.5";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -15839,7 +15839,7 @@ var ts;
|
|
|
15839
15839
|
}
|
|
15840
15840
|
ts.getExternalModuleImportEqualsDeclarationExpression = getExternalModuleImportEqualsDeclarationExpression;
|
|
15841
15841
|
function getExternalModuleRequireArgument(node) {
|
|
15842
|
-
return
|
|
15842
|
+
return isVariableDeclarationInitializedToBareOrAccessedRequire(node) && getLeftmostAccessExpression(node.initializer).arguments[0];
|
|
15843
15843
|
}
|
|
15844
15844
|
ts.getExternalModuleRequireArgument = getExternalModuleRequireArgument;
|
|
15845
15845
|
function isInternalModuleImportEqualsDeclaration(node) {
|
|
@@ -15897,17 +15897,29 @@ var ts;
|
|
|
15897
15897
|
* Returns true if the node is a VariableDeclaration initialized to a require call (see `isRequireCall`).
|
|
15898
15898
|
* This function does not test if the node is in a JavaScript file or not.
|
|
15899
15899
|
*/
|
|
15900
|
-
function
|
|
15900
|
+
function isVariableDeclarationInitializedToRequire(node) {
|
|
15901
|
+
return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ false);
|
|
15902
|
+
}
|
|
15903
|
+
ts.isVariableDeclarationInitializedToRequire = isVariableDeclarationInitializedToRequire;
|
|
15904
|
+
/**
|
|
15905
|
+
* Like {@link isVariableDeclarationInitializedToRequire} but allows things like `require("...").foo.bar` or `require("...")["baz"]`.
|
|
15906
|
+
*/
|
|
15907
|
+
function isVariableDeclarationInitializedToBareOrAccessedRequire(node) {
|
|
15908
|
+
return isVariableDeclarationInitializedWithRequireHelper(node, /*allowAccessedRequire*/ true);
|
|
15909
|
+
}
|
|
15910
|
+
ts.isVariableDeclarationInitializedToBareOrAccessedRequire = isVariableDeclarationInitializedToBareOrAccessedRequire;
|
|
15911
|
+
function isVariableDeclarationInitializedWithRequireHelper(node, allowAccessedRequire) {
|
|
15901
15912
|
if (node.kind === 202 /* BindingElement */) {
|
|
15902
15913
|
node = node.parent.parent;
|
|
15903
15914
|
}
|
|
15904
|
-
return ts.isVariableDeclaration(node) &&
|
|
15915
|
+
return ts.isVariableDeclaration(node) &&
|
|
15916
|
+
!!node.initializer &&
|
|
15917
|
+
isRequireCall(allowAccessedRequire ? getLeftmostAccessExpression(node.initializer) : node.initializer, /*requireStringLiteralLikeArgument*/ true);
|
|
15905
15918
|
}
|
|
15906
|
-
ts.isRequireVariableDeclaration = isRequireVariableDeclaration;
|
|
15907
15919
|
function isRequireVariableStatement(node) {
|
|
15908
15920
|
return ts.isVariableStatement(node)
|
|
15909
15921
|
&& node.declarationList.declarations.length > 0
|
|
15910
|
-
&& ts.every(node.declarationList.declarations, function (decl) { return
|
|
15922
|
+
&& ts.every(node.declarationList.declarations, function (decl) { return isVariableDeclarationInitializedToRequire(decl); });
|
|
15911
15923
|
}
|
|
15912
15924
|
ts.isRequireVariableStatement = isRequireVariableStatement;
|
|
15913
15925
|
function isSingleOrDoubleQuote(charCode) {
|
|
@@ -46064,7 +46076,7 @@ var ts;
|
|
|
46064
46076
|
checkStrictModeEvalOrArguments(node, node.name);
|
|
46065
46077
|
}
|
|
46066
46078
|
if (!ts.isBindingPattern(node.name)) {
|
|
46067
|
-
if (ts.isInJSFile(node) && ts.
|
|
46079
|
+
if (ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node) && !ts.getJSDocTypeTag(node)) {
|
|
46068
46080
|
declareSymbolAndAddToSymbolTable(node, 2097152 /* Alias */, 2097152 /* AliasExcludes */);
|
|
46069
46081
|
}
|
|
46070
46082
|
else if (ts.isBlockOrCatchScoped(node)) {
|
|
@@ -48843,7 +48855,7 @@ var ts;
|
|
|
48843
48855
|
&& isAliasableOrJsExpression(node.parent.right)
|
|
48844
48856
|
|| node.kind === 295 /* ShorthandPropertyAssignment */
|
|
48845
48857
|
|| node.kind === 294 /* PropertyAssignment */ && isAliasableOrJsExpression(node.initializer)
|
|
48846
|
-
|| ts.
|
|
48858
|
+
|| ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node);
|
|
48847
48859
|
}
|
|
48848
48860
|
function isAliasableOrJsExpression(e) {
|
|
48849
48861
|
return ts.isAliasableExpression(e) || ts.isFunctionExpression(e) && isJSConstructor(e);
|
|
@@ -49814,7 +49826,7 @@ var ts;
|
|
|
49814
49826
|
if (!sigs || !sigs.length) {
|
|
49815
49827
|
sigs = getSignaturesOfStructuredType(type, 1 /* Construct */);
|
|
49816
49828
|
}
|
|
49817
|
-
if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */)) {
|
|
49829
|
+
if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */, /*skipObjectFunctionPropertyAugment*/ true)) {
|
|
49818
49830
|
var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference);
|
|
49819
49831
|
return cloneTypeAsModuleType(symbol, moduleType, referenceParent);
|
|
49820
49832
|
}
|
|
@@ -80246,7 +80258,7 @@ var ts;
|
|
|
80246
80258
|
}
|
|
80247
80259
|
// For a commonjs `const x = require`, validate the alias and exit
|
|
80248
80260
|
var symbol = getSymbolOfNode(node);
|
|
80249
|
-
if (symbol.flags & 2097152 /* Alias */ && ts.
|
|
80261
|
+
if (symbol.flags & 2097152 /* Alias */ && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(node)) {
|
|
80250
80262
|
checkAliasSymbol(node);
|
|
80251
80263
|
return;
|
|
80252
80264
|
}
|
|
@@ -123955,7 +123967,7 @@ var ts;
|
|
|
123955
123967
|
isWhiteSpaceOnlyJsxText(child);
|
|
123956
123968
|
if (lookInPreviousChild) {
|
|
123957
123969
|
// actual start of the node is past the position - previous token should be at the end of previous child
|
|
123958
|
-
var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile);
|
|
123970
|
+
var candidate_1 = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile, n.kind);
|
|
123959
123971
|
return candidate_1 && findRightmostToken(candidate_1, sourceFile);
|
|
123960
123972
|
}
|
|
123961
123973
|
else {
|
|
@@ -123969,7 +123981,7 @@ var ts;
|
|
|
123969
123981
|
// the only known case is when position is at the end of the file.
|
|
123970
123982
|
// Try to find the rightmost token in the file without filtering.
|
|
123971
123983
|
// Namely we are skipping the check: 'position < node.end'
|
|
123972
|
-
var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile);
|
|
123984
|
+
var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind);
|
|
123973
123985
|
return candidate && findRightmostToken(candidate, sourceFile);
|
|
123974
123986
|
}
|
|
123975
123987
|
}
|
|
@@ -123985,17 +123997,19 @@ var ts;
|
|
|
123985
123997
|
if (children.length === 0) {
|
|
123986
123998
|
return n;
|
|
123987
123999
|
}
|
|
123988
|
-
var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile);
|
|
124000
|
+
var candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ children.length, sourceFile, n.kind);
|
|
123989
124001
|
return candidate && findRightmostToken(candidate, sourceFile);
|
|
123990
124002
|
}
|
|
123991
124003
|
/**
|
|
123992
124004
|
* Finds the rightmost child to the left of `children[exclusiveStartPosition]` which is a non-all-whitespace token or has constituent tokens.
|
|
123993
124005
|
*/
|
|
123994
|
-
function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile) {
|
|
124006
|
+
function findRightmostChildNodeWithTokens(children, exclusiveStartPosition, sourceFile, parentKind) {
|
|
123995
124007
|
for (var i = exclusiveStartPosition - 1; i >= 0; i--) {
|
|
123996
124008
|
var child = children[i];
|
|
123997
124009
|
if (isWhiteSpaceOnlyJsxText(child)) {
|
|
123998
|
-
|
|
124010
|
+
if (i === 0 && (parentKind === 11 /* JsxText */ || parentKind === 278 /* JsxSelfClosingElement */)) {
|
|
124011
|
+
ts.Debug.fail("`JsxText` tokens should not be the first child of `JsxElement | JsxSelfClosingElement`");
|
|
124012
|
+
}
|
|
123999
124013
|
}
|
|
124000
124014
|
else if (nodeHasTokens(children[i], sourceFile)) {
|
|
124001
124015
|
return children[i];
|
|
@@ -128412,7 +128426,7 @@ var ts;
|
|
|
128412
128426
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
128413
128427
|
}
|
|
128414
128428
|
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences) {
|
|
128415
|
-
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, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
|
|
128429
|
+
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;
|
|
128416
128430
|
// Verify if the file is JSX language variant
|
|
128417
128431
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
|
|
128418
128432
|
var completionInfo = getJsxClosingTagCompletion(location, sourceFile);
|
|
@@ -128423,7 +128437,7 @@ var ts;
|
|
|
128423
128437
|
var entries = [];
|
|
128424
128438
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
128425
128439
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
128426
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
128440
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
128427
128441
|
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
|
|
128428
128442
|
}
|
|
128429
128443
|
else {
|
|
@@ -128431,7 +128445,7 @@ var ts;
|
|
|
128431
128445
|
return undefined;
|
|
128432
128446
|
}
|
|
128433
128447
|
getCompletionEntriesFromSymbols(symbols, entries,
|
|
128434
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
128448
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
128435
128449
|
}
|
|
128436
128450
|
if (keywordFilters !== 0 /* None */) {
|
|
128437
128451
|
var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
@@ -128537,7 +128551,7 @@ var ts;
|
|
|
128537
128551
|
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
|
|
128538
128552
|
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
|
|
128539
128553
|
}
|
|
128540
|
-
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind) {
|
|
128554
|
+
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, isJsxIdentifierExpected, isRightOfOpenTag) {
|
|
128541
128555
|
var _a, _b;
|
|
128542
128556
|
var insertText;
|
|
128543
128557
|
var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
|
|
@@ -128608,24 +128622,7 @@ var ts;
|
|
|
128608
128622
|
source = CompletionSource.ClassMemberSnippet;
|
|
128609
128623
|
}
|
|
128610
128624
|
}
|
|
128611
|
-
|
|
128612
|
-
// a tag name; this may appear as an attribute after the "<" when the tag has not yet been
|
|
128613
|
-
// closed, as in:
|
|
128614
|
-
//
|
|
128615
|
-
// return <>
|
|
128616
|
-
// foo <butto|
|
|
128617
|
-
// </>
|
|
128618
|
-
//
|
|
128619
|
-
// We can detect this case by checking if both:
|
|
128620
|
-
//
|
|
128621
|
-
// 1. The location is "<", so we are completing immediately after it.
|
|
128622
|
-
// 2. The "<" has the same position as its parent, so is not a binary expression.
|
|
128623
|
-
var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location);
|
|
128624
|
-
if (kind === "JSX attribute" /* jsxAttribute */
|
|
128625
|
-
&& (location.kind !== 29 /* LessThanToken */ || location.pos !== location.parent.pos)
|
|
128626
|
-
&& preferences.includeCompletionsWithSnippetText
|
|
128627
|
-
&& preferences.jsxAttributeCompletionStyle
|
|
128628
|
-
&& preferences.jsxAttributeCompletionStyle !== "none") {
|
|
128625
|
+
if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
128629
128626
|
var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
|
|
128630
128627
|
var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
128631
128628
|
// If is boolean like or undefined, don't return a snippet we want just to return the completion.
|
|
@@ -128663,7 +128660,7 @@ var ts;
|
|
|
128663
128660
|
// entries (like JavaScript identifier entries).
|
|
128664
128661
|
return {
|
|
128665
128662
|
name: name,
|
|
128666
|
-
kind:
|
|
128663
|
+
kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location),
|
|
128667
128664
|
kindModifiers: ts.SymbolDisplay.getSymbolModifiers(typeChecker, symbol),
|
|
128668
128665
|
sortText: sortText,
|
|
128669
128666
|
source: source,
|
|
@@ -128938,7 +128935,7 @@ var ts;
|
|
|
128938
128935
|
return CompletionSource.ThisProperty;
|
|
128939
128936
|
}
|
|
128940
128937
|
}
|
|
128941
|
-
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) {
|
|
128938
|
+
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag) {
|
|
128942
128939
|
var _a;
|
|
128943
128940
|
var start = ts.timestamp();
|
|
128944
128941
|
var variableDeclaration = getVariableDeclaration(location);
|
|
@@ -128959,7 +128956,7 @@ var ts;
|
|
|
128959
128956
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
128960
128957
|
var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
|
|
128961
128958
|
var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
|
|
128962
|
-
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind);
|
|
128959
|
+
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
128963
128960
|
if (!entry) {
|
|
128964
128961
|
continue;
|
|
128965
128962
|
}
|
|
@@ -129553,6 +129550,7 @@ var ts;
|
|
|
129553
129550
|
symbolToSortTextIdMap: symbolToSortTextIdMap,
|
|
129554
129551
|
isTypeOnlyLocation: isTypeOnlyLocation,
|
|
129555
129552
|
isJsxIdentifierExpected: isJsxIdentifierExpected,
|
|
129553
|
+
isRightOfOpenTag: isRightOfOpenTag,
|
|
129556
129554
|
importCompletionNode: importCompletionNode,
|
|
129557
129555
|
hasUnresolvedAutoImports: hasUnresolvedAutoImports,
|
|
129558
129556
|
};
|
|
@@ -132484,7 +132482,7 @@ var ts;
|
|
|
132484
132482
|
ts.Debug.assert(parent.name === node);
|
|
132485
132483
|
return true;
|
|
132486
132484
|
case 202 /* BindingElement */:
|
|
132487
|
-
return ts.isInJSFile(node) && ts.
|
|
132485
|
+
return ts.isInJSFile(node) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(parent);
|
|
132488
132486
|
default:
|
|
132489
132487
|
return false;
|
|
132490
132488
|
}
|
|
@@ -133884,7 +133882,7 @@ var ts;
|
|
|
133884
133882
|
// Use the parent symbol if the location is commonjs require syntax on javascript files only.
|
|
133885
133883
|
if (ts.isInJSFile(referenceLocation)
|
|
133886
133884
|
&& referenceLocation.parent.kind === 202 /* BindingElement */
|
|
133887
|
-
&& ts.
|
|
133885
|
+
&& ts.isVariableDeclarationInitializedToBareOrAccessedRequire(referenceLocation.parent)) {
|
|
133888
133886
|
referenceSymbol = referenceLocation.parent.symbol;
|
|
133889
133887
|
// The parent will not have a symbol if it's an ObjectBindingPattern (when destructuring is used). In
|
|
133890
133888
|
// this case, just skip it, since the bound identifiers are not an alias of the import.
|
|
@@ -135591,7 +135589,7 @@ var ts;
|
|
|
135591
135589
|
return declaration.parent.kind === 268 /* NamedImports */;
|
|
135592
135590
|
case 202 /* BindingElement */:
|
|
135593
135591
|
case 253 /* VariableDeclaration */:
|
|
135594
|
-
return ts.isInJSFile(declaration) && ts.
|
|
135592
|
+
return ts.isInJSFile(declaration) && ts.isVariableDeclarationInitializedToBareOrAccessedRequire(declaration);
|
|
135595
135593
|
default:
|
|
135596
135594
|
return false;
|
|
135597
135595
|
}
|
|
@@ -136874,6 +136872,9 @@ var ts;
|
|
|
136874
136872
|
// We use 1 NavNode to represent 'A.B.C', but there are multiple source nodes.
|
|
136875
136873
|
// Only merge module nodes that have the same chain. Don't merge 'A.B.C' with 'A'!
|
|
136876
136874
|
function areSameModule(a, b) {
|
|
136875
|
+
if (!a.body || !b.body) {
|
|
136876
|
+
return a.body === b.body;
|
|
136877
|
+
}
|
|
136877
136878
|
return a.body.kind === b.body.kind && (a.body.kind !== 260 /* ModuleDeclaration */ || areSameModule(a.body, b.body));
|
|
136878
136879
|
}
|
|
136879
136880
|
/** Merge source into target. Source should be thrown away after this is called. */
|
|
@@ -148623,7 +148624,7 @@ var ts;
|
|
|
148623
148624
|
var importKind = getImportKind(importingFile, exportKind, compilerOptions);
|
|
148624
148625
|
return ts.mapDefined(importingFile.imports, function (moduleSpecifier) {
|
|
148625
148626
|
var i = ts.importFromModuleSpecifier(moduleSpecifier);
|
|
148626
|
-
if (ts.
|
|
148627
|
+
if (ts.isVariableDeclarationInitializedToRequire(i.parent)) {
|
|
148627
148628
|
return checker.resolveExternalModuleName(moduleSpecifier) === moduleSymbol ? { declaration: i.parent, importKind: importKind, symbol: symbol, targetFlags: targetFlags } : undefined;
|
|
148628
148629
|
}
|
|
148629
148630
|
if (i.kind === 265 /* ImportDeclaration */ || i.kind === 264 /* ImportEqualsDeclaration */) {
|
|
@@ -156683,11 +156684,12 @@ var ts;
|
|
|
156683
156684
|
var result = [];
|
|
156684
156685
|
return visitor(selection) ? undefined : result;
|
|
156685
156686
|
function visitor(node) {
|
|
156687
|
+
var _a;
|
|
156686
156688
|
if (ts.isTypeReferenceNode(node)) {
|
|
156687
156689
|
if (ts.isIdentifier(node.typeName)) {
|
|
156688
156690
|
var symbol = checker.resolveName(node.typeName.text, node.typeName, 262144 /* TypeParameter */, /* excludeGlobals */ true);
|
|
156689
|
-
|
|
156690
|
-
|
|
156691
|
+
var declaration = ts.tryCast((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0], ts.isTypeParameterDeclaration);
|
|
156692
|
+
if (declaration) {
|
|
156691
156693
|
if (rangeContainsSkipTrivia(statement, declaration, file) && !rangeContainsSkipTrivia(selection, declaration, file)) {
|
|
156692
156694
|
ts.pushIfUnique(result, declaration);
|
|
156693
156695
|
}
|