typescript 4.8.0-dev.20220722 → 4.8.0-dev.20220725
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 +2 -0
- package/lib/de/diagnosticMessages.generated.json +2 -0
- package/lib/es/diagnosticMessages.generated.json +2 -0
- package/lib/fr/diagnosticMessages.generated.json +2 -0
- package/lib/it/diagnosticMessages.generated.json +2 -0
- package/lib/ja/diagnosticMessages.generated.json +2 -0
- package/lib/ko/diagnosticMessages.generated.json +2 -0
- package/lib/pl/diagnosticMessages.generated.json +2 -0
- package/lib/pt-br/diagnosticMessages.generated.json +2 -0
- package/lib/ru/diagnosticMessages.generated.json +2 -0
- package/lib/tr/diagnosticMessages.generated.json +2 -0
- package/lib/tsc.js +28 -28
- package/lib/tsserver.js +101 -60
- package/lib/tsserverlibrary.js +101 -60
- package/lib/typescript.js +101 -60
- package/lib/typescriptServices.js +101 -60
- package/lib/typingsInstaller.js +33 -31
- package/lib/zh-cn/diagnosticMessages.generated.json +2 -0
- package/lib/zh-tw/diagnosticMessages.generated.json +2 -0
- package/package.json +1 -1
|
@@ -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.20220725";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -7042,8 +7042,10 @@ var ts;
|
|
|
7042
7042
|
return {
|
|
7043
7043
|
close: function () {
|
|
7044
7044
|
// Close the watcher (either existing file system entry watcher or missing file system entry watcher)
|
|
7045
|
-
watcher
|
|
7046
|
-
|
|
7045
|
+
if (watcher) {
|
|
7046
|
+
watcher.close();
|
|
7047
|
+
watcher = undefined;
|
|
7048
|
+
}
|
|
7047
7049
|
}
|
|
7048
7050
|
};
|
|
7049
7051
|
function updateWatcher(createWatcher) {
|
|
@@ -68131,37 +68133,33 @@ var ts;
|
|
|
68131
68133
|
var commonBaseType;
|
|
68132
68134
|
for (var _i = 0, types_13 = types; _i < types_13.length; _i++) {
|
|
68133
68135
|
var t = types_13[_i];
|
|
68134
|
-
|
|
68135
|
-
|
|
68136
|
-
commonBaseType = baseType;
|
|
68137
|
-
|
|
68138
|
-
|
|
68139
|
-
|
|
68136
|
+
if (!(t.flags & 131072 /* Never */)) {
|
|
68137
|
+
var baseType = getBaseTypeOfLiteralType(t);
|
|
68138
|
+
commonBaseType !== null && commonBaseType !== void 0 ? commonBaseType : (commonBaseType = baseType);
|
|
68139
|
+
if (baseType === t || baseType !== commonBaseType) {
|
|
68140
|
+
return false;
|
|
68141
|
+
}
|
|
68140
68142
|
}
|
|
68141
68143
|
}
|
|
68142
68144
|
return true;
|
|
68143
68145
|
}
|
|
68144
|
-
|
|
68145
|
-
|
|
68146
|
-
// right is a supertype.
|
|
68147
|
-
function getSupertypeOrUnion(types) {
|
|
68148
|
-
if (types.length === 1) {
|
|
68149
|
-
return types[0];
|
|
68150
|
-
}
|
|
68151
|
-
return literalTypesWithSameBaseType(types) ?
|
|
68152
|
-
getUnionType(types) :
|
|
68153
|
-
ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; });
|
|
68146
|
+
function getCombinedTypeFlags(types) {
|
|
68147
|
+
return ts.reduceLeft(types, function (flags, t) { return flags | (t.flags & 1048576 /* Union */ ? getCombinedTypeFlags(t.types) : t.flags); }, 0);
|
|
68154
68148
|
}
|
|
68155
68149
|
function getCommonSupertype(types) {
|
|
68156
|
-
if (
|
|
68157
|
-
return
|
|
68158
|
-
}
|
|
68159
|
-
var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); });
|
|
68160
|
-
if (primaryTypes.length) {
|
|
68161
|
-
var supertypeOrUnion = getSupertypeOrUnion(primaryTypes);
|
|
68162
|
-
return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true));
|
|
68150
|
+
if (types.length === 1) {
|
|
68151
|
+
return types[0];
|
|
68163
68152
|
}
|
|
68164
|
-
|
|
68153
|
+
// Remove nullable types from each of the candidates.
|
|
68154
|
+
var primaryTypes = strictNullChecks ? ts.sameMap(types, function (t) { return filterType(t, function (u) { return !(u.flags & 98304 /* Nullable */); }); }) : types;
|
|
68155
|
+
// When the candidate types are all literal types with the same base type, return a union
|
|
68156
|
+
// of those literal types. Otherwise, return the leftmost type for which no type to the
|
|
68157
|
+
// right is a supertype.
|
|
68158
|
+
var superTypeOrUnion = literalTypesWithSameBaseType(primaryTypes) ?
|
|
68159
|
+
getUnionType(primaryTypes) :
|
|
68160
|
+
ts.reduceLeft(primaryTypes, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; });
|
|
68161
|
+
// Add any nullable types that occurred in the candidates back to the result.
|
|
68162
|
+
return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) & 98304 /* Nullable */);
|
|
68165
68163
|
}
|
|
68166
68164
|
// Return the leftmost type for which no type to the right is a subtype.
|
|
68167
68165
|
function getCommonSubtype(types) {
|
|
@@ -79823,7 +79821,11 @@ var ts;
|
|
|
79823
79821
|
var operator = operatorToken.kind;
|
|
79824
79822
|
if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) {
|
|
79825
79823
|
if (operator === 55 /* AmpersandAmpersandToken */) {
|
|
79826
|
-
var parent =
|
|
79824
|
+
var parent = node.parent;
|
|
79825
|
+
while (parent.kind === 212 /* ParenthesizedExpression */
|
|
79826
|
+
|| ts.isBinaryExpression(parent) && (parent.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || parent.operatorToken.kind === 56 /* BarBarToken */)) {
|
|
79827
|
+
parent = parent.parent;
|
|
79828
|
+
}
|
|
79827
79829
|
checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
|
|
79828
79830
|
}
|
|
79829
79831
|
checkTruthinessOfType(leftType, node.left);
|
|
@@ -90745,13 +90747,13 @@ var ts;
|
|
|
90745
90747
|
return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration));
|
|
90746
90748
|
case 200 /* ImportType */:
|
|
90747
90749
|
ts.Debug.type(node);
|
|
90748
|
-
return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName),
|
|
90750
|
+
return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf);
|
|
90749
90751
|
case 295 /* ImportTypeAssertionContainer */:
|
|
90750
90752
|
ts.Debug.type(node);
|
|
90751
90753
|
return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine);
|
|
90752
90754
|
case 197 /* NamedTupleMember */:
|
|
90753
90755
|
ts.Debug.type(node);
|
|
90754
|
-
return factory.updateNamedTupleMember(node,
|
|
90756
|
+
return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken, visitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.questionToken, visitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
90755
90757
|
case 191 /* ParenthesizedType */:
|
|
90756
90758
|
ts.Debug.type(node);
|
|
90757
90759
|
return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
@@ -90816,7 +90818,7 @@ var ts;
|
|
|
90816
90818
|
return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
|
|
90817
90819
|
case 210 /* TaggedTemplateExpression */:
|
|
90818
90820
|
ts.Debug.type(node);
|
|
90819
|
-
return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression),
|
|
90821
|
+
return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral));
|
|
90820
90822
|
case 211 /* TypeAssertionExpression */:
|
|
90821
90823
|
ts.Debug.type(node);
|
|
90822
90824
|
return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression));
|
|
@@ -149449,6 +149451,7 @@ var ts;
|
|
|
149449
149451
|
consumeTokenAndAdvanceScanner(tokenInfo, node, nodeDynamicIndentation, node);
|
|
149450
149452
|
}
|
|
149451
149453
|
function processChildNode(child, inheritedIndentation, parent, parentDynamicIndentation, parentStartLine, undecoratedParentStartLine, isListItem, isFirstListItem) {
|
|
149454
|
+
ts.Debug.assert(!ts.nodeIsSynthesized(child));
|
|
149452
149455
|
if (ts.nodeIsMissing(child)) {
|
|
149453
149456
|
return inheritedIndentation;
|
|
149454
149457
|
}
|
|
@@ -149515,6 +149518,7 @@ var ts;
|
|
|
149515
149518
|
}
|
|
149516
149519
|
function processChildNodes(nodes, parent, parentStartLine, parentDynamicIndentation) {
|
|
149517
149520
|
ts.Debug.assert(ts.isNodeArray(nodes));
|
|
149521
|
+
ts.Debug.assert(!ts.nodeIsSynthesized(nodes));
|
|
149518
149522
|
var listStartToken = getOpenTokenForList(parent, nodes);
|
|
149519
149523
|
var listDynamicIndentation = parentDynamicIndentation;
|
|
149520
149524
|
var startLine = parentStartLine;
|
|
@@ -155974,54 +155978,91 @@ var ts;
|
|
|
155974
155978
|
codefix.registerCodeFix({
|
|
155975
155979
|
errorCodes: errorCodes,
|
|
155976
155980
|
getCodeActions: function (context) {
|
|
155977
|
-
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
155978
|
-
var
|
|
155979
|
-
if (
|
|
155981
|
+
var sourceFile = context.sourceFile, span = context.span, program = context.program, preferences = context.preferences, host = context.host;
|
|
155982
|
+
var info = getInfo(program, sourceFile, span);
|
|
155983
|
+
if (info === undefined)
|
|
155980
155984
|
return;
|
|
155981
|
-
}
|
|
155982
|
-
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, related); });
|
|
155985
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, program, preferences, host, sourceFile, info); });
|
|
155983
155986
|
return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
155984
155987
|
},
|
|
155985
155988
|
fixIds: [fixId],
|
|
155986
|
-
getAllCodeActions: function (context) {
|
|
155987
|
-
var
|
|
155988
|
-
|
|
155989
|
-
|
|
155990
|
-
|
|
155991
|
-
|
|
155989
|
+
getAllCodeActions: function (context) {
|
|
155990
|
+
var program = context.program, preferences = context.preferences, host = context.host;
|
|
155991
|
+
var seen = new ts.Map();
|
|
155992
|
+
return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, function (changes) {
|
|
155993
|
+
codefix.eachDiagnostic(context, errorCodes, function (diag) {
|
|
155994
|
+
var info = getInfo(program, diag.file, ts.createTextSpan(diag.start, diag.length));
|
|
155995
|
+
if (info) {
|
|
155996
|
+
var id = ts.getNodeId(info.declaration) + "#" + info.token.getText();
|
|
155997
|
+
if (ts.addToSeen(seen, id)) {
|
|
155998
|
+
return addMissingConstraint(changes, program, preferences, host, diag.file, info);
|
|
155999
|
+
}
|
|
156000
|
+
}
|
|
156001
|
+
return undefined;
|
|
156002
|
+
});
|
|
156003
|
+
}));
|
|
156004
|
+
}
|
|
155992
156005
|
});
|
|
155993
|
-
function
|
|
156006
|
+
function getInfo(program, sourceFile, span) {
|
|
155994
156007
|
var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
|
|
155995
|
-
if (
|
|
156008
|
+
if (diag === undefined || diag.relatedInformation === undefined)
|
|
155996
156009
|
return;
|
|
155997
156010
|
var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
|
|
155998
|
-
if (
|
|
156011
|
+
if (related === undefined || related.file === undefined || related.start === undefined || related.length === undefined)
|
|
155999
156012
|
return;
|
|
156000
|
-
|
|
156001
|
-
|
|
156002
|
-
function addMissingConstraint(changes, related) {
|
|
156003
|
-
var decl = findAncestorMatchingSpan(related.file, related);
|
|
156004
|
-
if (!decl)
|
|
156013
|
+
var declaration = findAncestorMatchingSpan(related.file, ts.createTextSpan(related.start, related.length));
|
|
156014
|
+
if (declaration === undefined)
|
|
156005
156015
|
return;
|
|
156006
|
-
if (ts.isIdentifier(
|
|
156007
|
-
|
|
156016
|
+
if (ts.isIdentifier(declaration) && ts.isTypeParameterDeclaration(declaration.parent)) {
|
|
156017
|
+
declaration = declaration.parent;
|
|
156018
|
+
}
|
|
156019
|
+
if (ts.isTypeParameterDeclaration(declaration)) {
|
|
156020
|
+
// should only issue fix on type parameters written using `extends`
|
|
156021
|
+
if (ts.isMappedTypeNode(declaration.parent))
|
|
156022
|
+
return;
|
|
156023
|
+
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
156024
|
+
var checker = program.getTypeChecker();
|
|
156025
|
+
var constraint = tryGetConstraintType(checker, token) || tryGetConstraintFromDiagnosticMessage(related.messageText);
|
|
156026
|
+
return { constraint: constraint, declaration: declaration, token: token };
|
|
156027
|
+
}
|
|
156028
|
+
return undefined;
|
|
156029
|
+
}
|
|
156030
|
+
function addMissingConstraint(changes, program, preferences, host, sourceFile, info) {
|
|
156031
|
+
var declaration = info.declaration, constraint = info.constraint;
|
|
156032
|
+
var checker = program.getTypeChecker();
|
|
156033
|
+
if (ts.isString(constraint)) {
|
|
156034
|
+
changes.insertText(sourceFile, declaration.name.end, " extends " + constraint);
|
|
156035
|
+
}
|
|
156036
|
+
else {
|
|
156037
|
+
var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
|
|
156038
|
+
var tracker = codefix.getNoopSymbolTrackerWithResolver({ program: program, host: host });
|
|
156039
|
+
var importAdder = codefix.createImportAdder(sourceFile, program, preferences, host);
|
|
156040
|
+
var typeNode = codefix.typeToAutoImportableTypeNode(checker, importAdder, constraint, /*contextNode*/ undefined, scriptTarget, /*flags*/ undefined, tracker);
|
|
156041
|
+
if (typeNode) {
|
|
156042
|
+
changes.replaceNode(sourceFile, declaration, ts.factory.updateTypeParameterDeclaration(declaration, /*modifiers*/ undefined, declaration.name, typeNode, declaration.default));
|
|
156043
|
+
importAdder.writeFixes(changes);
|
|
156044
|
+
}
|
|
156008
156045
|
}
|
|
156009
|
-
if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent))
|
|
156010
|
-
return; // should only issue fix on type parameters written using `extends`
|
|
156011
|
-
var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/);
|
|
156012
|
-
if (!newConstraint)
|
|
156013
|
-
return;
|
|
156014
|
-
var newConstraintText = newConstraint[1];
|
|
156015
|
-
changes.insertText(related.file, decl.name.end, " extends " + newConstraintText);
|
|
156016
156046
|
}
|
|
156017
156047
|
function findAncestorMatchingSpan(sourceFile, span) {
|
|
156018
|
-
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
156019
156048
|
var end = ts.textSpanEnd(span);
|
|
156049
|
+
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
156020
156050
|
while (token.end < end) {
|
|
156021
156051
|
token = token.parent;
|
|
156022
156052
|
}
|
|
156023
156053
|
return token;
|
|
156024
156054
|
}
|
|
156055
|
+
function tryGetConstraintFromDiagnosticMessage(messageText) {
|
|
156056
|
+
var _a = ts.flattenDiagnosticMessageText(messageText, "\n", 0).match(/`extends (.*)`/) || [], _ = _a[0], constraint = _a[1];
|
|
156057
|
+
return constraint;
|
|
156058
|
+
}
|
|
156059
|
+
function tryGetConstraintType(checker, node) {
|
|
156060
|
+
if (ts.isTypeNode(node.parent)) {
|
|
156061
|
+
return checker.getTypeArgumentConstraint(node.parent);
|
|
156062
|
+
}
|
|
156063
|
+
var contextualType = ts.isExpression(node) ? checker.getContextualType(node) : undefined;
|
|
156064
|
+
return contextualType || checker.getTypeAtLocation(node);
|
|
156065
|
+
}
|
|
156025
156066
|
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
156026
156067
|
})(ts || (ts = {}));
|
|
156027
156068
|
/* @internal */
|
package/lib/typingsInstaller.js
CHANGED
|
@@ -89,7 +89,7 @@ var ts;
|
|
|
89
89
|
// The following is baselined as a literal template type without intervention
|
|
90
90
|
/** The version of the TypeScript compiler release */
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
92
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
92
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220725";
|
|
93
93
|
/* @internal */
|
|
94
94
|
var Comparison;
|
|
95
95
|
(function (Comparison) {
|
|
@@ -6837,8 +6837,10 @@ var ts;
|
|
|
6837
6837
|
return {
|
|
6838
6838
|
close: function () {
|
|
6839
6839
|
// Close the watcher (either existing file system entry watcher or missing file system entry watcher)
|
|
6840
|
-
watcher
|
|
6841
|
-
|
|
6840
|
+
if (watcher) {
|
|
6841
|
+
watcher.close();
|
|
6842
|
+
watcher = undefined;
|
|
6843
|
+
}
|
|
6842
6844
|
}
|
|
6843
6845
|
};
|
|
6844
6846
|
function updateWatcher(createWatcher) {
|
|
@@ -67926,37 +67928,33 @@ var ts;
|
|
|
67926
67928
|
var commonBaseType;
|
|
67927
67929
|
for (var _i = 0, types_13 = types; _i < types_13.length; _i++) {
|
|
67928
67930
|
var t = types_13[_i];
|
|
67929
|
-
|
|
67930
|
-
|
|
67931
|
-
commonBaseType = baseType;
|
|
67932
|
-
|
|
67933
|
-
|
|
67934
|
-
|
|
67931
|
+
if (!(t.flags & 131072 /* Never */)) {
|
|
67932
|
+
var baseType = getBaseTypeOfLiteralType(t);
|
|
67933
|
+
commonBaseType !== null && commonBaseType !== void 0 ? commonBaseType : (commonBaseType = baseType);
|
|
67934
|
+
if (baseType === t || baseType !== commonBaseType) {
|
|
67935
|
+
return false;
|
|
67936
|
+
}
|
|
67935
67937
|
}
|
|
67936
67938
|
}
|
|
67937
67939
|
return true;
|
|
67938
67940
|
}
|
|
67939
|
-
|
|
67940
|
-
|
|
67941
|
-
// right is a supertype.
|
|
67942
|
-
function getSupertypeOrUnion(types) {
|
|
67943
|
-
if (types.length === 1) {
|
|
67944
|
-
return types[0];
|
|
67945
|
-
}
|
|
67946
|
-
return literalTypesWithSameBaseType(types) ?
|
|
67947
|
-
getUnionType(types) :
|
|
67948
|
-
ts.reduceLeft(types, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; });
|
|
67941
|
+
function getCombinedTypeFlags(types) {
|
|
67942
|
+
return ts.reduceLeft(types, function (flags, t) { return flags | (t.flags & 1048576 /* Union */ ? getCombinedTypeFlags(t.types) : t.flags); }, 0);
|
|
67949
67943
|
}
|
|
67950
67944
|
function getCommonSupertype(types) {
|
|
67951
|
-
if (
|
|
67952
|
-
return
|
|
67953
|
-
}
|
|
67954
|
-
var primaryTypes = ts.filter(types, function (t) { return !(t.flags & 98304 /* Nullable */); });
|
|
67955
|
-
if (primaryTypes.length) {
|
|
67956
|
-
var supertypeOrUnion = getSupertypeOrUnion(primaryTypes);
|
|
67957
|
-
return primaryTypes === types ? supertypeOrUnion : getUnionType(__spreadArray([supertypeOrUnion], ts.filter(types, function (t) { return !!(t.flags & 98304 /* Nullable */); }), true));
|
|
67945
|
+
if (types.length === 1) {
|
|
67946
|
+
return types[0];
|
|
67958
67947
|
}
|
|
67959
|
-
|
|
67948
|
+
// Remove nullable types from each of the candidates.
|
|
67949
|
+
var primaryTypes = strictNullChecks ? ts.sameMap(types, function (t) { return filterType(t, function (u) { return !(u.flags & 98304 /* Nullable */); }); }) : types;
|
|
67950
|
+
// When the candidate types are all literal types with the same base type, return a union
|
|
67951
|
+
// of those literal types. Otherwise, return the leftmost type for which no type to the
|
|
67952
|
+
// right is a supertype.
|
|
67953
|
+
var superTypeOrUnion = literalTypesWithSameBaseType(primaryTypes) ?
|
|
67954
|
+
getUnionType(primaryTypes) :
|
|
67955
|
+
ts.reduceLeft(primaryTypes, function (s, t) { return isTypeSubtypeOf(s, t) ? t : s; });
|
|
67956
|
+
// Add any nullable types that occurred in the candidates back to the result.
|
|
67957
|
+
return primaryTypes === types ? superTypeOrUnion : getNullableType(superTypeOrUnion, getCombinedTypeFlags(types) & 98304 /* Nullable */);
|
|
67960
67958
|
}
|
|
67961
67959
|
// Return the leftmost type for which no type to the right is a subtype.
|
|
67962
67960
|
function getCommonSubtype(types) {
|
|
@@ -79618,7 +79616,11 @@ var ts;
|
|
|
79618
79616
|
var operator = operatorToken.kind;
|
|
79619
79617
|
if (operator === 55 /* AmpersandAmpersandToken */ || operator === 56 /* BarBarToken */ || operator === 60 /* QuestionQuestionToken */) {
|
|
79620
79618
|
if (operator === 55 /* AmpersandAmpersandToken */) {
|
|
79621
|
-
var parent =
|
|
79619
|
+
var parent = node.parent;
|
|
79620
|
+
while (parent.kind === 212 /* ParenthesizedExpression */
|
|
79621
|
+
|| ts.isBinaryExpression(parent) && (parent.operatorToken.kind === 55 /* AmpersandAmpersandToken */ || parent.operatorToken.kind === 56 /* BarBarToken */)) {
|
|
79622
|
+
parent = parent.parent;
|
|
79623
|
+
}
|
|
79622
79624
|
checkTestingKnownTruthyCallableOrAwaitableType(node.left, ts.isIfStatement(parent) ? parent.thenStatement : undefined);
|
|
79623
79625
|
}
|
|
79624
79626
|
checkTruthinessOfType(leftType, node.left);
|
|
@@ -90540,13 +90542,13 @@ var ts;
|
|
|
90540
90542
|
return factory.updateInferTypeNode(node, nodeVisitor(node.typeParameter, visitor, ts.isTypeParameterDeclaration));
|
|
90541
90543
|
case 200 /* ImportType */:
|
|
90542
90544
|
ts.Debug.type(node);
|
|
90543
|
-
return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName),
|
|
90545
|
+
return factory.updateImportTypeNode(node, nodeVisitor(node.argument, visitor, ts.isTypeNode), nodeVisitor(node.assertions, visitor, ts.isNode), nodeVisitor(node.qualifier, visitor, ts.isEntityName), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), node.isTypeOf);
|
|
90544
90546
|
case 295 /* ImportTypeAssertionContainer */:
|
|
90545
90547
|
ts.Debug.type(node);
|
|
90546
90548
|
return factory.updateImportTypeAssertionContainer(node, nodeVisitor(node.assertClause, visitor, ts.isNode), node.multiLine);
|
|
90547
90549
|
case 197 /* NamedTupleMember */:
|
|
90548
90550
|
ts.Debug.type(node);
|
|
90549
|
-
return factory.updateNamedTupleMember(node,
|
|
90551
|
+
return factory.updateNamedTupleMember(node, nodeVisitor(node.dotDotDotToken, visitor, ts.isDotDotDotToken), nodeVisitor(node.name, visitor, ts.isIdentifier), nodeVisitor(node.questionToken, visitor, ts.isQuestionToken), nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
90550
90552
|
case 191 /* ParenthesizedType */:
|
|
90551
90553
|
ts.Debug.type(node);
|
|
90552
90554
|
return factory.updateParenthesizedType(node, nodeVisitor(node.type, visitor, ts.isTypeNode));
|
|
@@ -90611,7 +90613,7 @@ var ts;
|
|
|
90611
90613
|
return factory.updateNewExpression(node, nodeVisitor(node.expression, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodesVisitor(node.arguments, visitor, ts.isExpression));
|
|
90612
90614
|
case 210 /* TaggedTemplateExpression */:
|
|
90613
90615
|
ts.Debug.type(node);
|
|
90614
|
-
return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression),
|
|
90616
|
+
return factory.updateTaggedTemplateExpression(node, nodeVisitor(node.tag, visitor, ts.isExpression), nodesVisitor(node.typeArguments, visitor, ts.isTypeNode), nodeVisitor(node.template, visitor, ts.isTemplateLiteral));
|
|
90615
90617
|
case 211 /* TypeAssertionExpression */:
|
|
90616
90618
|
ts.Debug.type(node);
|
|
90617
90619
|
return factory.updateTypeAssertion(node, nodeVisitor(node.type, visitor, ts.isTypeNode), nodeVisitor(node.expression, visitor, ts.isExpression));
|
|
@@ -226,6 +226,7 @@
|
|
|
226
226
|
"An_index_signature_parameter_must_have_a_type_annotation_1022": "索引签名参数必须具有类型批注。",
|
|
227
227
|
"An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_o_1337": "索引签名参数类型不能为文本类型或泛型类型。请考虑改用映射的对象类型。",
|
|
228
228
|
"An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268": "索引签名参数类型必须是 “string”、“number”、“symbol”或模板文本类型。",
|
|
229
|
+
"An_instantiation_expression_cannot_be_followed_by_a_property_access_1477": "实例化表达式不能后跟属性访问。",
|
|
229
230
|
"An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499": "接口只能扩展具有可选类型参数的标识符/限定名称。",
|
|
230
231
|
"An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312": "接口只能扩展使用静态已知成员的对象类型或对象类型的交集。",
|
|
231
232
|
"An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840": "接口无法扩展基元类型,如“{0}”;接口只能扩展命名类型和类",
|
|
@@ -1561,6 +1562,7 @@
|
|
|
1561
1562
|
"Type_library_referenced_via_0_from_file_1_with_packageId_2_1403": "通过 \"{0}\" 从具有 packageId \"{2}\" 的文件 \"{1}\" 引用了库类型",
|
|
1562
1563
|
"Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320": "\"await\" 操作数的类型必须是有效承诺,或不得包含可调用的 \"then\" 成员。",
|
|
1563
1564
|
"Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418": "计算属性类型的值为 \"{0}\",该值不能赋给 \"{1}\" 类型。",
|
|
1565
|
+
"Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844": "实例成员变量“{0}”的类型不能引用构造函数中声明的标识符“{1}”。",
|
|
1564
1566
|
"Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322": "\"yield*\" 操作数的迭代元素的类型必须是有效承诺,或不得包含可调用的 \"then\" 成员。",
|
|
1565
1567
|
"Type_of_property_0_circularly_references_itself_in_mapped_type_1_2615": "属性“{0}”的类型在已映射的类型“{1}”中循环引用其自身。",
|
|
1566
1568
|
"Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321": "异步生成器中 \"yield\" 操作数的类型必须是有效承诺,或不得包含可调用的 \"then\" 成员。",
|
|
@@ -226,6 +226,7 @@
|
|
|
226
226
|
"An_index_signature_parameter_must_have_a_type_annotation_1022": "索引簽章參數必須有類型註釋。",
|
|
227
227
|
"An_index_signature_parameter_type_cannot_be_a_literal_type_or_generic_type_Consider_using_a_mapped_o_1337": "索引簽章參數類型不能是常值型別或泛型型別。請考慮改用對應的物件類型。",
|
|
228
228
|
"An_index_signature_parameter_type_must_be_string_number_symbol_or_a_template_literal_type_1268": "索引簽章參數類型必須是 'string'、'number'、'symbol' 或範本文字類型。",
|
|
229
|
+
"An_instantiation_expression_cannot_be_followed_by_a_property_access_1477": "具現化運算式後面不能接著屬性存取。",
|
|
229
230
|
"An_interface_can_only_extend_an_identifier_Slashqualified_name_with_optional_type_arguments_2499": "介面只能擴充具有選擇性型別引數的識別碼/限定名稱。",
|
|
230
231
|
"An_interface_can_only_extend_an_object_type_or_intersection_of_object_types_with_statically_known_me_2312": "介面只能延伸物件類型或具有靜態已知成員的物件類型交集。",
|
|
231
232
|
"An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840": "介面無法延伸基本類型,例如 '{0}';介面只能延伸命名類型和類別",
|
|
@@ -1561,6 +1562,7 @@
|
|
|
1561
1562
|
"Type_library_referenced_via_0_from_file_1_with_packageId_2_1403": "透過 '{0}' 從檔案 '{1}' (packageId 為 '{2}') 參考的型別程式庫",
|
|
1562
1563
|
"Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member_1320": "'await' 運算元類型必須是有效的 Promise,或不得包含可呼叫的 'then' 成員。",
|
|
1563
1564
|
"Type_of_computed_property_s_value_is_0_which_is_not_assignable_to_type_1_2418": "已計算屬性值的類型為 '{0}',其無法指派給類型 '{1}'。",
|
|
1565
|
+
"Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2844": "執行個體成員變數 '{0}' 的類型不得參考建構函式中所宣告的識別碼 '{1}'。",
|
|
1564
1566
|
"Type_of_iterated_elements_of_a_yield_Asterisk_operand_must_either_be_a_valid_promise_or_must_not_con_1322": "'yield*' 運算元的反覆項目類型必須是有效的 Promise,或不得包含可呼叫的 'then' 成員。",
|
|
1565
1567
|
"Type_of_property_0_circularly_references_itself_in_mapped_type_1_2615": "屬性 '{0}' 的類型在對應的類型 '{1}' 中會循環參考自己。",
|
|
1566
1568
|
"Type_of_yield_operand_in_an_async_generator_must_either_be_a_valid_promise_or_must_not_contain_a_cal_1321": "非同步產生器中的 'yield' 運算元類型必須是有效的 Promise,或不得包含可呼叫的 'then' 成員。",
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "typescript",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "4.8.0-dev.
|
|
5
|
+
"version": "4.8.0-dev.20220725",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|