typescript 4.7.0-dev.20220217 → 4.7.0-dev.20220218
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/de/diagnosticMessages.generated.json +4 -0
- package/lib/fr/diagnosticMessages.generated.json +4 -0
- package/lib/it/diagnosticMessages.generated.json +4 -0
- package/lib/ko/diagnosticMessages.generated.json +4 -0
- package/lib/lib.es2021.intl.d.ts +6 -6
- package/lib/lib.es5.d.ts +3 -1
- package/lib/lib.esnext.intl.d.ts +4 -4
- package/lib/pl/diagnosticMessages.generated.json +4 -0
- package/lib/pt-br/diagnosticMessages.generated.json +4 -0
- package/lib/ru/diagnosticMessages.generated.json +4 -0
- package/lib/tr/diagnosticMessages.generated.json +4 -0
- package/lib/tsc.js +45 -39
- package/lib/tsserver.js +82 -60
- package/lib/tsserverlibrary.js +76 -55
- package/lib/typescript.js +76 -55
- package/lib/typescriptServices.js +76 -55
- package/lib/typingsInstaller.js +51 -46
- package/lib/zh-cn/diagnosticMessages.generated.json +4 -0
- package/lib/zh-tw/diagnosticMessages.generated.json +4 -0
- 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-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220218";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -2423,7 +2423,7 @@ var ts;
|
|
|
2423
2423
|
Debug.checkEachDefined = checkEachDefined;
|
|
2424
2424
|
function assertNever(member, message, stackCrawlMark) {
|
|
2425
2425
|
if (message === void 0) { message = "Illegal value:"; }
|
|
2426
|
-
var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos")
|
|
2426
|
+
var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
|
|
2427
2427
|
return fail(message + " " + detail, stackCrawlMark || assertNever);
|
|
2428
2428
|
}
|
|
2429
2429
|
Debug.assertNever = assertNever;
|
|
@@ -62995,10 +62995,6 @@ var ts;
|
|
|
62995
62995
|
if (sourceRestType || targetRestType) {
|
|
62996
62996
|
void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers);
|
|
62997
62997
|
}
|
|
62998
|
-
if (sourceRestType && targetRestType && sourceCount !== targetCount) {
|
|
62999
|
-
// We're not able to relate misaligned complex rest parameters
|
|
63000
|
-
return 0 /* False */;
|
|
63001
|
-
}
|
|
63002
62998
|
var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */;
|
|
63003
62999
|
var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 168 /* MethodDeclaration */ &&
|
|
63004
63000
|
kind !== 167 /* MethodSignature */ && kind !== 170 /* Constructor */;
|
|
@@ -77377,7 +77373,7 @@ var ts;
|
|
|
77377
77373
|
if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) {
|
|
77378
77374
|
if (operator === 55 /* AmpersandAmpersandToken */) {
|
|
77379
77375
|
var parent = ts.walkUpParenthesizedExpressions(node.parent);
|
|
77380
|
-
checkTestingKnownTruthyCallableOrAwaitableType(node.left,
|
|
77376
|
+
checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
|
|
77381
77377
|
}
|
|
77382
77378
|
checkTruthinessOfType(leftType, node.left);
|
|
77383
77379
|
}
|
|
@@ -77884,8 +77880,8 @@ var ts;
|
|
|
77884
77880
|
return type;
|
|
77885
77881
|
}
|
|
77886
77882
|
function checkConditionalExpression(node, checkMode) {
|
|
77887
|
-
|
|
77888
|
-
checkTestingKnownTruthyCallableOrAwaitableType(node.condition,
|
|
77883
|
+
checkTruthinessExpression(node.condition);
|
|
77884
|
+
checkTestingKnownTruthyCallableOrAwaitableType(node.condition, node.whenTrue);
|
|
77889
77885
|
var type1 = checkExpression(node.whenTrue, checkMode);
|
|
77890
77886
|
var type2 = checkExpression(node.whenFalse, checkMode);
|
|
77891
77887
|
return getUnionType([type1, type2], 2 /* Subtype */);
|
|
@@ -81041,50 +81037,59 @@ var ts;
|
|
|
81041
81037
|
function checkIfStatement(node) {
|
|
81042
81038
|
// Grammar checking
|
|
81043
81039
|
checkGrammarStatementInAmbientContext(node);
|
|
81044
|
-
|
|
81045
|
-
checkTestingKnownTruthyCallableOrAwaitableType(node.expression,
|
|
81040
|
+
checkTruthinessExpression(node.expression);
|
|
81041
|
+
checkTestingKnownTruthyCallableOrAwaitableType(node.expression, node.thenStatement);
|
|
81046
81042
|
checkSourceElement(node.thenStatement);
|
|
81047
81043
|
if (node.thenStatement.kind === 235 /* EmptyStatement */) {
|
|
81048
81044
|
error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement);
|
|
81049
81045
|
}
|
|
81050
81046
|
checkSourceElement(node.elseStatement);
|
|
81051
81047
|
}
|
|
81052
|
-
function checkTestingKnownTruthyCallableOrAwaitableType(condExpr,
|
|
81048
|
+
function checkTestingKnownTruthyCallableOrAwaitableType(condExpr, body) {
|
|
81053
81049
|
if (!strictNullChecks)
|
|
81054
81050
|
return;
|
|
81055
|
-
|
|
81056
|
-
|
|
81057
|
-
|
|
81058
|
-
|
|
81059
|
-
|
|
81060
|
-
|
|
81061
|
-
|
|
81062
|
-
|
|
81063
|
-
|
|
81064
|
-
|
|
81065
|
-
|
|
81066
|
-
|
|
81067
|
-
|
|
81068
|
-
|
|
81069
|
-
|
|
81070
|
-
|
|
81071
|
-
|
|
81072
|
-
|
|
81073
|
-
|
|
81074
|
-
|
|
81075
|
-
|
|
81076
|
-
|
|
81077
|
-
|
|
81078
|
-
}
|
|
81079
|
-
var isUsed = testedSymbol && ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol)
|
|
81080
|
-
|| testedSymbol && body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol);
|
|
81081
|
-
if (!isUsed) {
|
|
81082
|
-
if (isPromise) {
|
|
81083
|
-
errorAndMaybeSuggestAwait(location,
|
|
81084
|
-
/*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type));
|
|
81051
|
+
helper(condExpr, body);
|
|
81052
|
+
while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* BarBarToken */) {
|
|
81053
|
+
condExpr = condExpr.left;
|
|
81054
|
+
helper(condExpr, body);
|
|
81055
|
+
}
|
|
81056
|
+
function helper(condExpr, body) {
|
|
81057
|
+
var location = ts.isBinaryExpression(condExpr) &&
|
|
81058
|
+
(condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */)
|
|
81059
|
+
? condExpr.right
|
|
81060
|
+
: condExpr;
|
|
81061
|
+
var type = checkTruthinessExpression(location);
|
|
81062
|
+
var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
81063
|
+
if (getFalsyFlags(type) || isPropertyExpressionCast)
|
|
81064
|
+
return;
|
|
81065
|
+
// While it technically should be invalid for any known-truthy value
|
|
81066
|
+
// to be tested, we de-scope to functions and Promises unreferenced in
|
|
81067
|
+
// the block as a heuristic to identify the most common bugs. There
|
|
81068
|
+
// are too many false positives for values sourced from type
|
|
81069
|
+
// definitions without strictNullChecks otherwise.
|
|
81070
|
+
var callSignatures = getSignaturesOfType(type, 0 /* Call */);
|
|
81071
|
+
var isPromise = !!getAwaitedTypeOfPromise(type);
|
|
81072
|
+
if (callSignatures.length === 0 && !isPromise) {
|
|
81073
|
+
return;
|
|
81085
81074
|
}
|
|
81086
|
-
|
|
81087
|
-
|
|
81075
|
+
var testedNode = ts.isIdentifier(location) ? location
|
|
81076
|
+
: ts.isPropertyAccessExpression(location) ? location.name
|
|
81077
|
+
: ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right
|
|
81078
|
+
: undefined;
|
|
81079
|
+
var testedSymbol = testedNode && getSymbolAtLocation(testedNode);
|
|
81080
|
+
if (!testedSymbol && !isPromise) {
|
|
81081
|
+
return;
|
|
81082
|
+
}
|
|
81083
|
+
var isUsed = testedSymbol && ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol)
|
|
81084
|
+
|| testedSymbol && body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol);
|
|
81085
|
+
if (!isUsed) {
|
|
81086
|
+
if (isPromise) {
|
|
81087
|
+
errorAndMaybeSuggestAwait(location,
|
|
81088
|
+
/*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type));
|
|
81089
|
+
}
|
|
81090
|
+
else {
|
|
81091
|
+
error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead);
|
|
81092
|
+
}
|
|
81088
81093
|
}
|
|
81089
81094
|
}
|
|
81090
81095
|
}
|
|
@@ -83878,10 +83883,10 @@ var ts;
|
|
|
83878
83883
|
}
|
|
83879
83884
|
// ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries.
|
|
83880
83885
|
// (TS Exceptions: namespaces, function overloads, enums, and interfaces)
|
|
83881
|
-
if (flags & (1920 /* Namespace */ |
|
|
83886
|
+
if (flags & (1920 /* Namespace */ | 384 /* Enum */)) {
|
|
83882
83887
|
return;
|
|
83883
83888
|
}
|
|
83884
|
-
var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor);
|
|
83889
|
+
var exportedDeclarationsCount = ts.countWhere(declarations, ts.and(isNotOverloadAndNotAccessor, ts.not(ts.isInterfaceDeclaration)));
|
|
83885
83890
|
if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) {
|
|
83886
83891
|
// it is legal to merge type alias with other values
|
|
83887
83892
|
// so count should be either 1 (just type alias) or 2 (type alias + merged value)
|
|
@@ -126173,14 +126178,15 @@ var ts;
|
|
|
126173
126178
|
: "linkplain";
|
|
126174
126179
|
var parts = [linkPart("{@" + prefix + " ")];
|
|
126175
126180
|
if (!link.name) {
|
|
126176
|
-
if (link.text)
|
|
126181
|
+
if (link.text) {
|
|
126177
126182
|
parts.push(linkTextPart(link.text));
|
|
126183
|
+
}
|
|
126178
126184
|
}
|
|
126179
126185
|
else {
|
|
126180
126186
|
var symbol = checker === null || checker === void 0 ? void 0 : checker.getSymbolAtLocation(link.name);
|
|
126181
126187
|
var suffix = findLinkNameEnd(link.text);
|
|
126182
126188
|
var name = ts.getTextOfNode(link.name) + link.text.slice(0, suffix);
|
|
126183
|
-
var text = link.text.slice(suffix);
|
|
126189
|
+
var text = skipSeparatorFromLinkText(link.text.slice(suffix));
|
|
126184
126190
|
var decl = (symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) || ((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]);
|
|
126185
126191
|
if (decl) {
|
|
126186
126192
|
parts.push(linkNamePart(name, decl));
|
|
@@ -126195,6 +126201,15 @@ var ts;
|
|
|
126195
126201
|
return parts;
|
|
126196
126202
|
}
|
|
126197
126203
|
ts.buildLinkParts = buildLinkParts;
|
|
126204
|
+
function skipSeparatorFromLinkText(text) {
|
|
126205
|
+
var pos = 0;
|
|
126206
|
+
if (text.charCodeAt(pos++) === 124 /* bar */) {
|
|
126207
|
+
while (pos < text.length && text.charCodeAt(pos) === 32 /* space */)
|
|
126208
|
+
pos++;
|
|
126209
|
+
return text.slice(pos);
|
|
126210
|
+
}
|
|
126211
|
+
return text;
|
|
126212
|
+
}
|
|
126198
126213
|
function findLinkNameEnd(text) {
|
|
126199
126214
|
if (text.indexOf("()") === 0)
|
|
126200
126215
|
return 2;
|
|
@@ -154811,7 +154826,7 @@ var ts;
|
|
|
154811
154826
|
/*dotDotDotToken*/ undefined,
|
|
154812
154827
|
/*name*/ names && names[i] || "arg" + i,
|
|
154813
154828
|
/*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined,
|
|
154814
|
-
/*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(
|
|
154829
|
+
/*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */),
|
|
154815
154830
|
/*initializer*/ undefined);
|
|
154816
154831
|
parameters.push(newParameter);
|
|
154817
154832
|
}
|
|
@@ -154839,11 +154854,10 @@ var ts;
|
|
|
154839
154854
|
var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; });
|
|
154840
154855
|
var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false);
|
|
154841
154856
|
if (someSigHasRestParameter) {
|
|
154842
|
-
var anyArrayType = ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */));
|
|
154843
154857
|
var restParameter = ts.factory.createParameterDeclaration(
|
|
154844
154858
|
/*decorators*/ undefined,
|
|
154845
154859
|
/*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest",
|
|
154846
|
-
/*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined,
|
|
154860
|
+
/*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */)),
|
|
154847
154861
|
/*initializer*/ undefined);
|
|
154848
154862
|
parameters.push(restParameter);
|
|
154849
154863
|
}
|
|
@@ -157212,7 +157226,7 @@ var ts;
|
|
|
157212
157226
|
ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (1)");
|
|
157213
157227
|
// For understanding how skipTrivia functioned:
|
|
157214
157228
|
ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (2)");
|
|
157215
|
-
if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck))) {
|
|
157229
|
+
if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) {
|
|
157216
157230
|
return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)];
|
|
157217
157231
|
}
|
|
157218
157232
|
if (nodeToCheck.flags & 8388608 /* Ambient */) {
|
|
@@ -157392,13 +157406,16 @@ var ts;
|
|
|
157392
157406
|
if (ts.isStatement(node)) {
|
|
157393
157407
|
return [node];
|
|
157394
157408
|
}
|
|
157395
|
-
|
|
157409
|
+
if (ts.isExpressionNode(node)) {
|
|
157396
157410
|
// If our selection is the expression in an ExpressionStatement, expand
|
|
157397
157411
|
// the selection to include the enclosing Statement (this stops us
|
|
157398
157412
|
// from trying to care about the return value of the extracted function
|
|
157399
157413
|
// and eliminates double semicolon insertion in certain scenarios)
|
|
157400
157414
|
return ts.isExpressionStatement(node.parent) ? [node.parent] : node;
|
|
157401
157415
|
}
|
|
157416
|
+
if (isStringLiteralJsxAttribute(node)) {
|
|
157417
|
+
return node;
|
|
157418
|
+
}
|
|
157402
157419
|
return undefined;
|
|
157403
157420
|
}
|
|
157404
157421
|
function isScope(node) {
|
|
@@ -158208,7 +158225,7 @@ var ts;
|
|
|
158208
158225
|
// Unfortunately, this code takes advantage of the knowledge that the generated method
|
|
158209
158226
|
// will use the contextual type of an expression as the return type of the extracted
|
|
158210
158227
|
// method (and will therefore "use" all the types involved).
|
|
158211
|
-
if (inGenericContext && !isReadonlyArray(targetRange.range)) {
|
|
158228
|
+
if (inGenericContext && !isReadonlyArray(targetRange.range) && !ts.isJsxAttribute(targetRange.range)) {
|
|
158212
158229
|
var contextualType = checker.getContextualType(targetRange.range); // TODO: GH#18217
|
|
158213
158230
|
recordTypeParameterUsages(contextualType);
|
|
158214
158231
|
}
|
|
@@ -158533,7 +158550,11 @@ var ts;
|
|
|
158533
158550
|
}
|
|
158534
158551
|
}
|
|
158535
158552
|
function isInJSXContent(node) {
|
|
158536
|
-
return (
|
|
158553
|
+
return isStringLiteralJsxAttribute(node) ||
|
|
158554
|
+
(ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && (ts.isJsxElement(node.parent) || ts.isJsxFragment(node.parent));
|
|
158555
|
+
}
|
|
158556
|
+
function isStringLiteralJsxAttribute(node) {
|
|
158557
|
+
return ts.isStringLiteral(node) && node.parent && ts.isJsxAttribute(node.parent);
|
|
158537
158558
|
}
|
|
158538
158559
|
})(extractSymbol = refactor.extractSymbol || (refactor.extractSymbol = {}));
|
|
158539
158560
|
})(refactor = ts.refactor || (ts.refactor = {}));
|
|
@@ -177040,6 +177061,7 @@ var ts;
|
|
|
177040
177061
|
})(server = ts.server || (ts.server = {}));
|
|
177041
177062
|
})(ts || (ts = {}));
|
|
177042
177063
|
/*@internal*/
|
|
177064
|
+
/// <reference lib="webworker" />
|
|
177043
177065
|
var ts;
|
|
177044
177066
|
(function (ts) {
|
|
177045
177067
|
var server;
|
|
@@ -177121,7 +177143,7 @@ var ts;
|
|
|
177121
177143
|
}
|
|
177122
177144
|
}
|
|
177123
177145
|
function hrtime(previous) {
|
|
177124
|
-
var now = self.performance.now(
|
|
177146
|
+
var now = self.performance.now() * 1e-3;
|
|
177125
177147
|
var seconds = Math.floor(now);
|
|
177126
177148
|
var nanoseconds = Math.floor((now % 1) * 1e9);
|
|
177127
177149
|
if (previous) {
|
|
@@ -177143,7 +177165,7 @@ var ts;
|
|
|
177143
177165
|
WorkerSession.prototype.exit = function () {
|
|
177144
177166
|
this.logger.info("Exiting...");
|
|
177145
177167
|
this.projectService.closeLog();
|
|
177146
|
-
close(
|
|
177168
|
+
close();
|
|
177147
177169
|
};
|
|
177148
177170
|
WorkerSession.prototype.listen = function () {
|
|
177149
177171
|
var _this = this;
|
|
@@ -177174,9 +177196,9 @@ var ts;
|
|
|
177174
177196
|
function getLogLevel(level) {
|
|
177175
177197
|
if (level) {
|
|
177176
177198
|
var l = level.toLowerCase();
|
|
177177
|
-
for (var
|
|
177178
|
-
if (isNaN(+
|
|
177179
|
-
return server.LogLevel[
|
|
177199
|
+
for (var name_1 in server.LogLevel) {
|
|
177200
|
+
if (isNaN(+name_1) && l === name_1.toLowerCase()) {
|
|
177201
|
+
return server.LogLevel[name_1];
|
|
177180
177202
|
}
|
|
177181
177203
|
}
|
|
177182
177204
|
}
|
package/lib/tsserverlibrary.js
CHANGED
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220218";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -2617,7 +2617,7 @@ var ts;
|
|
|
2617
2617
|
Debug.checkEachDefined = checkEachDefined;
|
|
2618
2618
|
function assertNever(member, message, stackCrawlMark) {
|
|
2619
2619
|
if (message === void 0) { message = "Illegal value:"; }
|
|
2620
|
-
var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos")
|
|
2620
|
+
var detail = typeof member === "object" && ts.hasProperty(member, "kind") && ts.hasProperty(member, "pos") ? "SyntaxKind: " + formatSyntaxKind(member.kind) : JSON.stringify(member);
|
|
2621
2621
|
return fail(message + " " + detail, stackCrawlMark || assertNever);
|
|
2622
2622
|
}
|
|
2623
2623
|
Debug.assertNever = assertNever;
|
|
@@ -63189,10 +63189,6 @@ var ts;
|
|
|
63189
63189
|
if (sourceRestType || targetRestType) {
|
|
63190
63190
|
void instantiateType(sourceRestType || targetRestType, reportUnreliableMarkers);
|
|
63191
63191
|
}
|
|
63192
|
-
if (sourceRestType && targetRestType && sourceCount !== targetCount) {
|
|
63193
|
-
// We're not able to relate misaligned complex rest parameters
|
|
63194
|
-
return 0 /* False */;
|
|
63195
|
-
}
|
|
63196
63192
|
var kind = target.declaration ? target.declaration.kind : 0 /* Unknown */;
|
|
63197
63193
|
var strictVariance = !(checkMode & 3 /* Callback */) && strictFunctionTypes && kind !== 168 /* MethodDeclaration */ &&
|
|
63198
63194
|
kind !== 167 /* MethodSignature */ && kind !== 170 /* Constructor */;
|
|
@@ -77571,7 +77567,7 @@ var ts;
|
|
|
77571
77567
|
if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) {
|
|
77572
77568
|
if (operator === 55 /* AmpersandAmpersandToken */) {
|
|
77573
77569
|
var parent = ts.walkUpParenthesizedExpressions(node.parent);
|
|
77574
|
-
checkTestingKnownTruthyCallableOrAwaitableType(node.left,
|
|
77570
|
+
checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
|
|
77575
77571
|
}
|
|
77576
77572
|
checkTruthinessOfType(leftType, node.left);
|
|
77577
77573
|
}
|
|
@@ -78078,8 +78074,8 @@ var ts;
|
|
|
78078
78074
|
return type;
|
|
78079
78075
|
}
|
|
78080
78076
|
function checkConditionalExpression(node, checkMode) {
|
|
78081
|
-
|
|
78082
|
-
checkTestingKnownTruthyCallableOrAwaitableType(node.condition,
|
|
78077
|
+
checkTruthinessExpression(node.condition);
|
|
78078
|
+
checkTestingKnownTruthyCallableOrAwaitableType(node.condition, node.whenTrue);
|
|
78083
78079
|
var type1 = checkExpression(node.whenTrue, checkMode);
|
|
78084
78080
|
var type2 = checkExpression(node.whenFalse, checkMode);
|
|
78085
78081
|
return getUnionType([type1, type2], 2 /* Subtype */);
|
|
@@ -81235,50 +81231,59 @@ var ts;
|
|
|
81235
81231
|
function checkIfStatement(node) {
|
|
81236
81232
|
// Grammar checking
|
|
81237
81233
|
checkGrammarStatementInAmbientContext(node);
|
|
81238
|
-
|
|
81239
|
-
checkTestingKnownTruthyCallableOrAwaitableType(node.expression,
|
|
81234
|
+
checkTruthinessExpression(node.expression);
|
|
81235
|
+
checkTestingKnownTruthyCallableOrAwaitableType(node.expression, node.thenStatement);
|
|
81240
81236
|
checkSourceElement(node.thenStatement);
|
|
81241
81237
|
if (node.thenStatement.kind === 235 /* EmptyStatement */) {
|
|
81242
81238
|
error(node.thenStatement, ts.Diagnostics.The_body_of_an_if_statement_cannot_be_the_empty_statement);
|
|
81243
81239
|
}
|
|
81244
81240
|
checkSourceElement(node.elseStatement);
|
|
81245
81241
|
}
|
|
81246
|
-
function checkTestingKnownTruthyCallableOrAwaitableType(condExpr,
|
|
81242
|
+
function checkTestingKnownTruthyCallableOrAwaitableType(condExpr, body) {
|
|
81247
81243
|
if (!strictNullChecks)
|
|
81248
81244
|
return;
|
|
81249
|
-
|
|
81250
|
-
|
|
81251
|
-
|
|
81252
|
-
|
|
81253
|
-
|
|
81254
|
-
|
|
81255
|
-
|
|
81256
|
-
|
|
81257
|
-
|
|
81258
|
-
|
|
81259
|
-
|
|
81260
|
-
|
|
81261
|
-
|
|
81262
|
-
|
|
81263
|
-
|
|
81264
|
-
|
|
81265
|
-
|
|
81266
|
-
|
|
81267
|
-
|
|
81268
|
-
|
|
81269
|
-
|
|
81270
|
-
|
|
81271
|
-
|
|
81272
|
-
}
|
|
81273
|
-
var isUsed = testedSymbol && ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol)
|
|
81274
|
-
|| testedSymbol && body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol);
|
|
81275
|
-
if (!isUsed) {
|
|
81276
|
-
if (isPromise) {
|
|
81277
|
-
errorAndMaybeSuggestAwait(location,
|
|
81278
|
-
/*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type));
|
|
81245
|
+
helper(condExpr, body);
|
|
81246
|
+
while (ts.isBinaryExpression(condExpr) && condExpr.operatorToken.kind === 56 /* BarBarToken */) {
|
|
81247
|
+
condExpr = condExpr.left;
|
|
81248
|
+
helper(condExpr, body);
|
|
81249
|
+
}
|
|
81250
|
+
function helper(condExpr, body) {
|
|
81251
|
+
var location = ts.isBinaryExpression(condExpr) &&
|
|
81252
|
+
(condExpr.operatorToken.kind === 56 /* BarBarToken */ || condExpr.operatorToken.kind === 55 /* AmpersandAmpersandToken */)
|
|
81253
|
+
? condExpr.right
|
|
81254
|
+
: condExpr;
|
|
81255
|
+
var type = checkTruthinessExpression(location);
|
|
81256
|
+
var isPropertyExpressionCast = ts.isPropertyAccessExpression(location) && isTypeAssertion(location.expression);
|
|
81257
|
+
if (getFalsyFlags(type) || isPropertyExpressionCast)
|
|
81258
|
+
return;
|
|
81259
|
+
// While it technically should be invalid for any known-truthy value
|
|
81260
|
+
// to be tested, we de-scope to functions and Promises unreferenced in
|
|
81261
|
+
// the block as a heuristic to identify the most common bugs. There
|
|
81262
|
+
// are too many false positives for values sourced from type
|
|
81263
|
+
// definitions without strictNullChecks otherwise.
|
|
81264
|
+
var callSignatures = getSignaturesOfType(type, 0 /* Call */);
|
|
81265
|
+
var isPromise = !!getAwaitedTypeOfPromise(type);
|
|
81266
|
+
if (callSignatures.length === 0 && !isPromise) {
|
|
81267
|
+
return;
|
|
81279
81268
|
}
|
|
81280
|
-
|
|
81281
|
-
|
|
81269
|
+
var testedNode = ts.isIdentifier(location) ? location
|
|
81270
|
+
: ts.isPropertyAccessExpression(location) ? location.name
|
|
81271
|
+
: ts.isBinaryExpression(location) && ts.isIdentifier(location.right) ? location.right
|
|
81272
|
+
: undefined;
|
|
81273
|
+
var testedSymbol = testedNode && getSymbolAtLocation(testedNode);
|
|
81274
|
+
if (!testedSymbol && !isPromise) {
|
|
81275
|
+
return;
|
|
81276
|
+
}
|
|
81277
|
+
var isUsed = testedSymbol && ts.isBinaryExpression(condExpr.parent) && isSymbolUsedInBinaryExpressionChain(condExpr.parent, testedSymbol)
|
|
81278
|
+
|| testedSymbol && body && isSymbolUsedInConditionBody(condExpr, body, testedNode, testedSymbol);
|
|
81279
|
+
if (!isUsed) {
|
|
81280
|
+
if (isPromise) {
|
|
81281
|
+
errorAndMaybeSuggestAwait(location,
|
|
81282
|
+
/*maybeMissingAwait*/ true, ts.Diagnostics.This_condition_will_always_return_true_since_this_0_is_always_defined, getTypeNameForErrorDisplay(type));
|
|
81283
|
+
}
|
|
81284
|
+
else {
|
|
81285
|
+
error(location, ts.Diagnostics.This_condition_will_always_return_true_since_this_function_is_always_defined_Did_you_mean_to_call_it_instead);
|
|
81286
|
+
}
|
|
81282
81287
|
}
|
|
81283
81288
|
}
|
|
81284
81289
|
}
|
|
@@ -84072,10 +84077,10 @@ var ts;
|
|
|
84072
84077
|
}
|
|
84073
84078
|
// ECMA262: 15.2.1.1 It is a Syntax Error if the ExportedNames of ModuleItemList contains any duplicate entries.
|
|
84074
84079
|
// (TS Exceptions: namespaces, function overloads, enums, and interfaces)
|
|
84075
|
-
if (flags & (1920 /* Namespace */ |
|
|
84080
|
+
if (flags & (1920 /* Namespace */ | 384 /* Enum */)) {
|
|
84076
84081
|
return;
|
|
84077
84082
|
}
|
|
84078
|
-
var exportedDeclarationsCount = ts.countWhere(declarations, isNotOverloadAndNotAccessor);
|
|
84083
|
+
var exportedDeclarationsCount = ts.countWhere(declarations, ts.and(isNotOverloadAndNotAccessor, ts.not(ts.isInterfaceDeclaration)));
|
|
84079
84084
|
if (flags & 524288 /* TypeAlias */ && exportedDeclarationsCount <= 2) {
|
|
84080
84085
|
// it is legal to merge type alias with other values
|
|
84081
84086
|
// so count should be either 1 (just type alias) or 2 (type alias + merged value)
|
|
@@ -126784,14 +126789,15 @@ var ts;
|
|
|
126784
126789
|
: "linkplain";
|
|
126785
126790
|
var parts = [linkPart("{@" + prefix + " ")];
|
|
126786
126791
|
if (!link.name) {
|
|
126787
|
-
if (link.text)
|
|
126792
|
+
if (link.text) {
|
|
126788
126793
|
parts.push(linkTextPart(link.text));
|
|
126794
|
+
}
|
|
126789
126795
|
}
|
|
126790
126796
|
else {
|
|
126791
126797
|
var symbol = checker === null || checker === void 0 ? void 0 : checker.getSymbolAtLocation(link.name);
|
|
126792
126798
|
var suffix = findLinkNameEnd(link.text);
|
|
126793
126799
|
var name = ts.getTextOfNode(link.name) + link.text.slice(0, suffix);
|
|
126794
|
-
var text = link.text.slice(suffix);
|
|
126800
|
+
var text = skipSeparatorFromLinkText(link.text.slice(suffix));
|
|
126795
126801
|
var decl = (symbol === null || symbol === void 0 ? void 0 : symbol.valueDeclaration) || ((_a = symbol === null || symbol === void 0 ? void 0 : symbol.declarations) === null || _a === void 0 ? void 0 : _a[0]);
|
|
126796
126802
|
if (decl) {
|
|
126797
126803
|
parts.push(linkNamePart(name, decl));
|
|
@@ -126806,6 +126812,15 @@ var ts;
|
|
|
126806
126812
|
return parts;
|
|
126807
126813
|
}
|
|
126808
126814
|
ts.buildLinkParts = buildLinkParts;
|
|
126815
|
+
function skipSeparatorFromLinkText(text) {
|
|
126816
|
+
var pos = 0;
|
|
126817
|
+
if (text.charCodeAt(pos++) === 124 /* bar */) {
|
|
126818
|
+
while (pos < text.length && text.charCodeAt(pos) === 32 /* space */)
|
|
126819
|
+
pos++;
|
|
126820
|
+
return text.slice(pos);
|
|
126821
|
+
}
|
|
126822
|
+
return text;
|
|
126823
|
+
}
|
|
126809
126824
|
function findLinkNameEnd(text) {
|
|
126810
126825
|
if (text.indexOf("()") === 0)
|
|
126811
126826
|
return 2;
|
|
@@ -155422,7 +155437,7 @@ var ts;
|
|
|
155422
155437
|
/*dotDotDotToken*/ undefined,
|
|
155423
155438
|
/*name*/ names && names[i] || "arg" + i,
|
|
155424
155439
|
/*questionToken*/ minArgumentCount !== undefined && i >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined,
|
|
155425
|
-
/*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(
|
|
155440
|
+
/*type*/ inJs ? undefined : types && types[i] || ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */),
|
|
155426
155441
|
/*initializer*/ undefined);
|
|
155427
155442
|
parameters.push(newParameter);
|
|
155428
155443
|
}
|
|
@@ -155450,11 +155465,10 @@ var ts;
|
|
|
155450
155465
|
var maxArgsParameterSymbolNames = maxArgsSignature.parameters.map(function (symbol) { return symbol.name; });
|
|
155451
155466
|
var parameters = createDummyParameters(maxNonRestArgs, maxArgsParameterSymbolNames, /* types */ undefined, minArgumentCount, /*inJs*/ false);
|
|
155452
155467
|
if (someSigHasRestParameter) {
|
|
155453
|
-
var anyArrayType = ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(130 /* AnyKeyword */));
|
|
155454
155468
|
var restParameter = ts.factory.createParameterDeclaration(
|
|
155455
155469
|
/*decorators*/ undefined,
|
|
155456
155470
|
/*modifiers*/ undefined, ts.factory.createToken(25 /* DotDotDotToken */), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest",
|
|
155457
|
-
/*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined,
|
|
155471
|
+
/*questionToken*/ maxNonRestArgs >= minArgumentCount ? ts.factory.createToken(57 /* QuestionToken */) : undefined, ts.factory.createArrayTypeNode(ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */)),
|
|
155458
155472
|
/*initializer*/ undefined);
|
|
155459
155473
|
parameters.push(restParameter);
|
|
155460
155474
|
}
|
|
@@ -157823,7 +157837,7 @@ var ts;
|
|
|
157823
157837
|
ts.Debug.assert(nodeToCheck.pos <= nodeToCheck.end, "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (1)");
|
|
157824
157838
|
// For understanding how skipTrivia functioned:
|
|
157825
157839
|
ts.Debug.assert(!ts.positionIsSynthesized(nodeToCheck.pos), "This failure could trigger https://github.com/Microsoft/TypeScript/issues/20809 (2)");
|
|
157826
|
-
if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck))) {
|
|
157840
|
+
if (!ts.isStatement(nodeToCheck) && !(ts.isExpressionNode(nodeToCheck) && isExtractableExpression(nodeToCheck)) && !isStringLiteralJsxAttribute(nodeToCheck)) {
|
|
157827
157841
|
return [ts.createDiagnosticForNode(nodeToCheck, Messages.statementOrExpressionExpected)];
|
|
157828
157842
|
}
|
|
157829
157843
|
if (nodeToCheck.flags & 8388608 /* Ambient */) {
|
|
@@ -158003,13 +158017,16 @@ var ts;
|
|
|
158003
158017
|
if (ts.isStatement(node)) {
|
|
158004
158018
|
return [node];
|
|
158005
158019
|
}
|
|
158006
|
-
|
|
158020
|
+
if (ts.isExpressionNode(node)) {
|
|
158007
158021
|
// If our selection is the expression in an ExpressionStatement, expand
|
|
158008
158022
|
// the selection to include the enclosing Statement (this stops us
|
|
158009
158023
|
// from trying to care about the return value of the extracted function
|
|
158010
158024
|
// and eliminates double semicolon insertion in certain scenarios)
|
|
158011
158025
|
return ts.isExpressionStatement(node.parent) ? [node.parent] : node;
|
|
158012
158026
|
}
|
|
158027
|
+
if (isStringLiteralJsxAttribute(node)) {
|
|
158028
|
+
return node;
|
|
158029
|
+
}
|
|
158013
158030
|
return undefined;
|
|
158014
158031
|
}
|
|
158015
158032
|
function isScope(node) {
|
|
@@ -158819,7 +158836,7 @@ var ts;
|
|
|
158819
158836
|
// Unfortunately, this code takes advantage of the knowledge that the generated method
|
|
158820
158837
|
// will use the contextual type of an expression as the return type of the extracted
|
|
158821
158838
|
// method (and will therefore "use" all the types involved).
|
|
158822
|
-
if (inGenericContext && !isReadonlyArray(targetRange.range)) {
|
|
158839
|
+
if (inGenericContext && !isReadonlyArray(targetRange.range) && !ts.isJsxAttribute(targetRange.range)) {
|
|
158823
158840
|
var contextualType = checker.getContextualType(targetRange.range); // TODO: GH#18217
|
|
158824
158841
|
recordTypeParameterUsages(contextualType);
|
|
158825
158842
|
}
|
|
@@ -159144,7 +159161,11 @@ var ts;
|
|
|
159144
159161
|
}
|
|
159145
159162
|
}
|
|
159146
159163
|
function isInJSXContent(node) {
|
|
159147
|
-
return (
|
|
159164
|
+
return isStringLiteralJsxAttribute(node) ||
|
|
159165
|
+
(ts.isJsxElement(node) || ts.isJsxSelfClosingElement(node) || ts.isJsxFragment(node)) && (ts.isJsxElement(node.parent) || ts.isJsxFragment(node.parent));
|
|
159166
|
+
}
|
|
159167
|
+
function isStringLiteralJsxAttribute(node) {
|
|
159168
|
+
return ts.isStringLiteral(node) && node.parent && ts.isJsxAttribute(node.parent);
|
|
159148
159169
|
}
|
|
159149
159170
|
})(extractSymbol = refactor.extractSymbol || (refactor.extractSymbol = {}));
|
|
159150
159171
|
})(refactor = ts.refactor || (ts.refactor = {}));
|