Update LKG.

This commit is contained in:
Daniel Rosenwasser 2019-11-22 16:32:32 -08:00
parent c021b28597
commit a8b63ef981
6 changed files with 761 additions and 523 deletions

View File

@ -67,7 +67,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook
var ts;
(function (ts) {
ts.versionMajorMinor = "3.7";
ts.version = ts.versionMajorMinor + ".2";
ts.version = ts.versionMajorMinor + ".3";
})(ts || (ts = {}));
(function (ts) {
function tryGetNativeMap() {
@ -4683,7 +4683,7 @@ var ts;
Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: diag(5059, ts.DiagnosticCategory.Error, "Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier_5059", "Invalid value for '--reactNamespace'. '{0}' is not a valid identifier."),
Option_paths_cannot_be_used_without_specifying_baseUrl_option: diag(5060, ts.DiagnosticCategory.Error, "Option_paths_cannot_be_used_without_specifying_baseUrl_option_5060", "Option 'paths' cannot be used without specifying '--baseUrl' option."),
Pattern_0_can_have_at_most_one_Asterisk_character: diag(5061, ts.DiagnosticCategory.Error, "Pattern_0_can_have_at_most_one_Asterisk_character_5061", "Pattern '{0}' can have at most one '*' character."),
Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: diag(5062, ts.DiagnosticCategory.Error, "Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character_5062", "Substitution '{0}' in pattern '{1}' in can have at most one '*' character."),
Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character: diag(5062, ts.DiagnosticCategory.Error, "Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character_5062", "Substitution '{0}' in pattern '{1}' can have at most one '*' character."),
Substitutions_for_pattern_0_should_be_an_array: diag(5063, ts.DiagnosticCategory.Error, "Substitutions_for_pattern_0_should_be_an_array_5063", "Substitutions for pattern '{0}' should be an array."),
Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: diag(5064, ts.DiagnosticCategory.Error, "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'."),
File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5065, ts.DiagnosticCategory.Error, "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'."),
@ -11887,10 +11887,20 @@ var ts;
|| kind === 195);
}
ts.isOptionalChain = isOptionalChain;
function isOptionalChainRoot(node) {
return isOptionalChain(node) && !!node.questionDotToken;
}
ts.isOptionalChainRoot = isOptionalChainRoot;
function isExpressionOfOptionalChainRoot(node) {
return ts.isOptionalChainRoot(node.parent) && node.parent.expression === node;
return isOptionalChainRoot(node.parent) && node.parent.expression === node;
}
ts.isExpressionOfOptionalChainRoot = isExpressionOfOptionalChainRoot;
function isOutermostOptionalChain(node) {
return !isOptionalChain(node.parent)
|| isOptionalChainRoot(node.parent)
|| node !== node.parent.expression;
}
ts.isOutermostOptionalChain = isOutermostOptionalChain;
function isNullishCoalesce(node) {
return node.kind === 208 && node.operatorToken.kind === 60;
}
@ -13049,10 +13059,6 @@ var ts;
return node.kind === 162;
}
ts.isGetAccessor = isGetAccessor;
function isOptionalChainRoot(node) {
return ts.isOptionalChain(node) && !!node.questionDotToken;
}
ts.isOptionalChainRoot = isOptionalChainRoot;
function hasJSDocNodes(node) {
var jsDoc = node.jsDoc;
return !!jsDoc && jsDoc.length > 0;
@ -13844,6 +13850,8 @@ var ts;
var patterns = [];
for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) {
var patternString = patternStrings_1[_i];
if (!ts.hasZeroOrOneAsteriskCharacter(patternString))
continue;
var pattern = tryParsePattern(patternString);
if (pattern) {
patterns.push(pattern);
@ -24247,7 +24255,7 @@ var ts;
}
function bindCondition(node, trueTarget, falseTarget) {
doWithConditionalBranches(bind, node, trueTarget, falseTarget);
if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && isOutermostOptionalChain(node))) {
if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) {
addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
}
@ -24673,12 +24681,9 @@ var ts;
addDeclarationToSymbol(host.symbol, host, 32);
}
}
function isOutermostOptionalChain(node) {
return !ts.isOptionalChain(node.parent) || ts.isOptionalChainRoot(node.parent) || node !== node.parent.expression;
}
function bindOptionalExpression(node, trueTarget, falseTarget) {
doWithConditionalBranches(bind, node, trueTarget, falseTarget);
if (!ts.isOptionalChain(node) || isOutermostOptionalChain(node)) {
if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) {
addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
}
@ -24705,7 +24710,7 @@ var ts;
currentFlow = finishFlowLabel(preChainLabel);
}
doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget);
if (isOutermostOptionalChain(node)) {
if (ts.isOutermostOptionalChain(node)) {
addAntecedent(trueTarget, createFlowCondition(32, currentFlow, node));
addAntecedent(falseTarget, createFlowCondition(64, currentFlow, node));
}
@ -25634,7 +25639,7 @@ var ts;
}
function bindObjectDefinePrototypeProperty(node) {
var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression);
if (namespaceSymbol) {
if (namespaceSymbol && namespaceSymbol.valueDeclaration) {
addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32);
}
bindPotentiallyNewExpandoMemberToNamespace(node, namespaceSymbol, true);
@ -26245,7 +26250,8 @@ var ts;
|| ts.hasModifier(node, 2270)
|| node.typeParameters
|| node.type
|| !node.body) {
|| !node.body
|| node.questionToken) {
transformFlags |= 1;
}
if (subtreeFlags & 8192) {
@ -26276,7 +26282,7 @@ var ts;
}
function computePropertyDeclaration(node, subtreeFlags) {
var transformFlags = subtreeFlags | 1048576;
if (ts.some(node.decorators) || ts.hasModifier(node, 2270) || node.type) {
if (ts.some(node.decorators) || ts.hasModifier(node, 2270) || node.type || node.questionToken) {
transformFlags |= 1;
}
if (ts.isComputedPropertyName(node.name) || (ts.hasStaticModifier(node) && node.initializer)) {
@ -33534,13 +33540,21 @@ var ts;
result.mapper = undefined;
return result;
}
function getOptionalCallSignature(signature) {
return signatureIsOptionalCall(signature) ? signature :
(signature.optionalCallSignatureCache || (signature.optionalCallSignatureCache = createOptionalCallSignature(signature)));
function getOptionalCallSignature(signature, callChainFlags) {
if ((signature.flags & 12) === callChainFlags) {
return signature;
}
if (!signature.optionalCallSignatureCache) {
signature.optionalCallSignatureCache = {};
}
var key = callChainFlags === 4 ? "inner" : "outer";
return signature.optionalCallSignatureCache[key]
|| (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags));
}
function createOptionalCallSignature(signature) {
function createOptionalCallSignature(signature, callChainFlags) {
ts.Debug.assert(callChainFlags === 4 || callChainFlags === 8, "An optional call signature can either be for an inner call chain or an outer call chain, but not both.");
var result = cloneSignature(signature);
result.flags |= 4;
result.flags |= callChainFlags;
return result;
}
function getExpandedParameters(sig) {
@ -34881,9 +34895,12 @@ var ts;
signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2) :
getReturnTypeFromAnnotation(signature.declaration) ||
(ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration));
if (signatureIsOptionalCall(signature)) {
if (signature.flags & 4) {
type = addOptionalTypeMarker(type);
}
else if (signature.flags & 8) {
type = getOptionalType(type);
}
if (!popTypeResolution()) {
if (signature.declaration) {
var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration);
@ -35305,7 +35322,8 @@ var ts;
isRequireAlias = ts.isCallExpression(expr) && ts.isRequireCall(expr, true) && !!valueType.symbol;
}
var isDelayedMergeClass = symbol !== valueType.symbol && getMergedSymbol(symbol) === valueType.symbol;
if (isRequireAlias || node.kind === 187 || isDelayedMergeClass) {
var isImportTypeWithQualifier = node.kind === 187 && node.qualifier;
if (isRequireAlias || isImportTypeWithQualifier || isDelayedMergeClass) {
typeType = getTypeReferenceType(node, valueType.symbol);
}
}
@ -40184,8 +40202,8 @@ var ts;
function removeOptionalTypeMarker(type) {
return strictNullChecks ? filterType(type, isNotOptionalTypeMarker) : type;
}
function propagateOptionalTypeMarker(type, wasOptional) {
return wasOptional ? addOptionalTypeMarker(type) : type;
function propagateOptionalTypeMarker(type, node, wasOptional) {
return wasOptional ? ts.isOutermostOptionalChain(node) ? getOptionalType(type) : addOptionalTypeMarker(type) : type;
}
function getOptionalExpressionType(exprType, expression) {
return ts.isExpressionOfOptionalChainRoot(expression) ? getNonNullableType(exprType) :
@ -44939,7 +44957,7 @@ var ts;
function checkPropertyAccessChain(node) {
var leftType = checkExpression(node.expression);
var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), nonOptionalType !== leftType);
return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType);
}
function checkQualifiedName(node) {
return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right);
@ -45287,7 +45305,7 @@ var ts;
function checkElementAccessChain(node) {
var exprType = checkExpression(node.expression);
var nonOptionalType = getOptionalExpressionType(exprType, node.expression);
return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), nonOptionalType !== exprType);
return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType);
}
function checkElementAccessExpression(node, exprType) {
var objectType = ts.getAssignmentTargetKind(node) !== 0 || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
@ -45361,7 +45379,7 @@ var ts;
resolveUntypedCall(node);
return unknownSignature;
}
function reorderCandidates(signatures, result, isOptionalCall) {
function reorderCandidates(signatures, result, callChainFlags) {
var lastParent;
var lastSymbol;
var cutoffIndex = 0;
@ -45395,7 +45413,7 @@ var ts;
else {
spliceIndex = index;
}
result.splice(spliceIndex, 0, isOptionalCall ? getOptionalCallSignature(signature) : signature);
result.splice(spliceIndex, 0, callChainFlags ? getOptionalCallSignature(signature, callChainFlags) : signature);
}
}
function isSpreadArgument(arg) {
@ -45903,7 +45921,7 @@ var ts;
}
return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
}
function resolveCall(node, signatures, candidatesOutArray, checkMode, isOptionalCall, fallbackError) {
function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) {
var isTaggedTemplate = node.kind === 197;
var isDecorator = node.kind === 156;
var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
@ -45916,7 +45934,7 @@ var ts;
}
}
var candidates = candidatesOutArray || [];
reorderCandidates(signatures, candidates, isOptionalCall);
reorderCandidates(signatures, candidates, callChainFlags);
if (!candidates.length) {
if (reportErrors) {
diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures));
@ -46198,20 +46216,22 @@ var ts;
var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
if (baseTypeNode) {
var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode);
return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, false);
return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0);
}
}
return resolveUntypedCall(node);
}
var isOptional;
var callChainFlags;
var funcType = checkExpression(node.expression);
if (ts.isCallChain(node)) {
var nonOptionalType = getOptionalExpressionType(funcType, node.expression);
isOptional = nonOptionalType !== funcType;
callChainFlags = nonOptionalType === funcType ? 0 :
ts.isOutermostOptionalChain(node) ? 8 :
4;
funcType = nonOptionalType;
}
else {
isOptional = false;
callChainFlags = 0;
}
funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError);
if (funcType === silentNeverType) {
@ -46253,7 +46273,7 @@ var ts;
error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
return resolveErrorCall(node);
}
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, isOptional);
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
}
function isGenericFunctionReturningFunction(signature) {
return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
@ -46293,11 +46313,11 @@ var ts;
error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class);
return resolveErrorCall(node);
}
return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, false);
return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0);
}
var callSignatures = getSignaturesOfType(expressionType, 0);
if (callSignatures.length) {
var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, false);
var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0);
if (!noImplicitAny) {
if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
@ -46464,7 +46484,7 @@ var ts;
invocationError(node.tag, apparentType, 0);
return resolveErrorCall(node);
}
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, false);
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0);
}
function getDiagnosticHeadMessageForDecoratorResolution(node) {
switch (node.parent.kind) {
@ -46511,7 +46531,7 @@ var ts;
invocationErrorRecovery(apparentType, 0, diag);
return resolveErrorCall(node);
}
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, false, headMessage);
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0, headMessage);
}
function createSignatureForJSXIntrinsic(node, result) {
var namespace = getJsxNamespaceAt(node);
@ -46543,7 +46563,7 @@ var ts;
error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName));
return resolveErrorCall(node);
}
return resolveCall(node, signatures, candidatesOutArray, checkMode, false);
return resolveCall(node, signatures, candidatesOutArray, checkMode, 0);
}
function isPotentiallyUncalledDecorator(decorator, signatures) {
return signatures.length && ts.every(signatures, function (signature) {
@ -48535,24 +48555,25 @@ var ts;
}
}
}
function getReturnTypeOfSingleNonGenericCallSignature(funcType) {
var signature = getSingleCallSignature(funcType);
if (signature && !signature.typeParameters) {
return getReturnTypeOfSignature(signature);
}
}
function getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) {
var funcType = checkExpression(expr.expression);
var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
var returnType = getReturnTypeOfSingleNonGenericCallSignature(funcType);
return returnType && propagateOptionalTypeMarker(returnType, expr, nonOptionalType !== funcType);
}
function getTypeOfExpression(node, cache) {
var expr = ts.skipParentheses(node);
if (ts.isCallExpression(expr) && expr.expression.kind !== 101 && !ts.isRequireCall(expr, true) && !isSymbolOrSymbolForCall(expr)) {
var isOptional = void 0;
var funcType = void 0;
if (ts.isCallChain(expr)) {
funcType = checkExpression(expr.expression);
var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
isOptional = funcType !== nonOptionalType;
funcType = checkNonNullType(nonOptionalType, expr.expression);
}
else {
isOptional = false;
funcType = checkNonNullExpression(expr.expression);
}
var signature = getSingleCallSignature(funcType);
if (signature && !signature.typeParameters) {
return propagateOptionalTypeMarker(getReturnTypeOfSignature(signature), isOptional);
var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
if (type) {
return type;
}
}
else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) {
@ -55330,10 +55351,6 @@ var ts;
return !!(s.flags & 2);
}
ts.signatureHasLiteralTypes = signatureHasLiteralTypes;
function signatureIsOptionalCall(s) {
return !!(s.flags & 4);
}
ts.signatureIsOptionalCall = signatureIsOptionalCall;
})(ts || (ts = {}));
var ts;
(function (ts) {
@ -62099,7 +62116,7 @@ var ts;
for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) {
var parameter = parametersWithPropertyAssignments_1[_i];
if (ts.isIdentifier(parameter.name)) {
members.push(ts.aggregateTransformFlags(ts.createProperty(undefined, undefined, parameter.name, undefined, undefined, undefined)));
members.push(ts.setOriginalNode(ts.aggregateTransformFlags(ts.createProperty(undefined, undefined, parameter.name, undefined, undefined, undefined)), parameter));
}
}
}
@ -62623,6 +62640,9 @@ var ts;
return !ts.nodeIsMissing(node.body);
}
function visitPropertyDeclaration(node) {
if (node.flags & 8388608) {
return undefined;
}
var updated = ts.updateProperty(node, undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node), undefined, undefined, ts.visitNode(node.initializer, visitor));
if (updated !== node) {
ts.setCommentRange(updated, node);
@ -62863,7 +62883,11 @@ var ts;
}
}
}
function shouldEmitModuleDeclaration(node) {
function shouldEmitModuleDeclaration(nodeIn) {
var node = ts.getParseTreeNode(nodeIn, ts.isModuleDeclaration);
if (!node) {
return true;
}
return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules);
}
function hasNamespaceQualifiedExportName(node) {
@ -63495,7 +63519,9 @@ var ts;
return ts.startOnNewLine(ts.setOriginalNode(ts.setTextRange(ts.createConstructor(undefined, undefined, parameters, body), constructor || node), constructor));
}
function transformConstructorBody(node, constructor, isDerivedClass) {
var properties = ts.getProperties(node, !context.getCompilerOptions().useDefineForClassFields, false);
var _a;
var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields;
var properties = ts.getProperties(node, !useDefineForClassFields, false);
if (!constructor && !ts.some(properties)) {
return ts.visitFunctionBody(undefined, visitor, context);
}
@ -63508,19 +63534,16 @@ var ts;
if (constructor) {
indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(constructor, statements, visitor);
}
if (constructor && constructor.body) {
var parameterPropertyDeclarationCount = 0;
for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) {
if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) {
parameterPropertyDeclarationCount++;
}
else {
break;
}
if ((_a = constructor) === null || _a === void 0 ? void 0 : _a.body) {
var afterParameterProperties = ts.findIndex(constructor.body.statements, function (s) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(s), constructor); }, indexOfFirstStatement);
if (afterParameterProperties === -1) {
afterParameterProperties = constructor.body.statements.length;
}
if (parameterPropertyDeclarationCount > 0) {
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, parameterPropertyDeclarationCount));
indexOfFirstStatement += parameterPropertyDeclarationCount;
if (afterParameterProperties > indexOfFirstStatement) {
if (!useDefineForClassFields) {
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, afterParameterProperties - indexOfFirstStatement));
}
indexOfFirstStatement = afterParameterProperties;
}
}
addPropertyStatements(statements, properties, ts.createThis());
@ -63558,7 +63581,9 @@ var ts;
var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression)
? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name))
: property.name;
var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression) : ts.createVoidZero();
var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression)
: ts.hasModifier(ts.getOriginalNode(property), 92) && ts.isIdentifier(propertyName) ? propertyName
: ts.createVoidZero();
if (emitAssignment) {
var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, propertyName);
return ts.createAssignment(memberAccess, initializer);
@ -79531,7 +79556,7 @@ var ts;
var typeOfSubst = typeof subst;
if (typeOfSubst === "string") {
if (!ts.hasZeroOrOneAsteriskCharacter(subst)) {
createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key);
createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character, subst, key);
}
}
else {

View File

@ -94,7 +94,7 @@ var ts;
// If changing the text in this section, be sure to test `configureNightly` too.
ts.versionMajorMinor = "3.7";
/** The version of the TypeScript compiler release */
ts.version = ts.versionMajorMinor + ".2";
ts.version = ts.versionMajorMinor + ".3";
})(ts || (ts = {}));
(function (ts) {
/* @internal */
@ -3799,11 +3799,13 @@ var ts;
SignatureFlags[SignatureFlags["None"] = 0] = "None";
SignatureFlags[SignatureFlags["HasRestParameter"] = 1] = "HasRestParameter";
SignatureFlags[SignatureFlags["HasLiteralTypes"] = 2] = "HasLiteralTypes";
SignatureFlags[SignatureFlags["IsOptionalCall"] = 4] = "IsOptionalCall";
// We do not propagate `IsOptionalCall` to instantiated signatures, as that would result in us
SignatureFlags[SignatureFlags["IsInnerCallChain"] = 4] = "IsInnerCallChain";
SignatureFlags[SignatureFlags["IsOuterCallChain"] = 8] = "IsOuterCallChain";
// We do not propagate `IsInnerCallChain` to instantiated signatures, as that would result in us
// attempting to add `| undefined` on each recursive call to `getReturnTypeOfSignature` when
// instantiating the return type.
SignatureFlags[SignatureFlags["PropagatingFlags"] = 3] = "PropagatingFlags";
SignatureFlags[SignatureFlags["CallChainFlags"] = 12] = "CallChainFlags";
})(SignatureFlags = ts.SignatureFlags || (ts.SignatureFlags = {}));
var IndexKind;
(function (IndexKind) {
@ -7050,7 +7052,7 @@ var ts;
Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: diag(5059, ts.DiagnosticCategory.Error, "Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier_5059", "Invalid value for '--reactNamespace'. '{0}' is not a valid identifier."),
Option_paths_cannot_be_used_without_specifying_baseUrl_option: diag(5060, ts.DiagnosticCategory.Error, "Option_paths_cannot_be_used_without_specifying_baseUrl_option_5060", "Option 'paths' cannot be used without specifying '--baseUrl' option."),
Pattern_0_can_have_at_most_one_Asterisk_character: diag(5061, ts.DiagnosticCategory.Error, "Pattern_0_can_have_at_most_one_Asterisk_character_5061", "Pattern '{0}' can have at most one '*' character."),
Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: diag(5062, ts.DiagnosticCategory.Error, "Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character_5062", "Substitution '{0}' in pattern '{1}' in can have at most one '*' character."),
Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character: diag(5062, ts.DiagnosticCategory.Error, "Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character_5062", "Substitution '{0}' in pattern '{1}' can have at most one '*' character."),
Substitutions_for_pattern_0_should_be_an_array: diag(5063, ts.DiagnosticCategory.Error, "Substitutions_for_pattern_0_should_be_an_array_5063", "Substitutions for pattern '{0}' should be an array."),
Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: diag(5064, ts.DiagnosticCategory.Error, "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'."),
File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5065, ts.DiagnosticCategory.Error, "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'."),
@ -15164,14 +15166,36 @@ var ts;
|| kind === 195 /* CallExpression */);
}
ts.isOptionalChain = isOptionalChain;
/* @internal */
function isOptionalChainRoot(node) {
return isOptionalChain(node) && !!node.questionDotToken;
}
ts.isOptionalChainRoot = isOptionalChainRoot;
/**
* Determines whether a node is the expression preceding an optional chain (i.e. `a` in `a?.b`).
*/
/* @internal */
function isExpressionOfOptionalChainRoot(node) {
return ts.isOptionalChainRoot(node.parent) && node.parent.expression === node;
return isOptionalChainRoot(node.parent) && node.parent.expression === node;
}
ts.isExpressionOfOptionalChainRoot = isExpressionOfOptionalChainRoot;
/**
* Determines whether a node is the outermost `OptionalChain` in an ECMAScript `OptionalExpression`:
*
* 1. For `a?.b.c`, the outermost chain is `a?.b.c` (`c` is the end of the chain starting at `a?.`)
* 2. For `(a?.b.c).d`, the outermost chain is `a?.b.c` (`c` is the end of the chain starting at `a?.` since parens end the chain)
* 3. For `a?.b.c?.d`, both `a?.b.c` and `a?.b.c?.d` are outermost (`c` is the end of the chain starting at `a?.`, and `d` is
* the end of the chain starting at `c?.`)
* 4. For `a?.(b?.c).d`, both `b?.c` and `a?.(b?.c)d` are outermost (`c` is the end of the chain starting at `b`, and `d` is
* the end of the chain starting at `a?.`)
*/
/* @internal */
function isOutermostOptionalChain(node) {
return !isOptionalChain(node.parent) // cases 1 and 2
|| isOptionalChainRoot(node.parent) // case 3
|| node !== node.parent.expression; // case 4
}
ts.isOutermostOptionalChain = isOutermostOptionalChain;
function isNullishCoalesce(node) {
return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */;
}
@ -16446,11 +16470,6 @@ var ts;
return node.kind === 162 /* GetAccessor */;
}
ts.isGetAccessor = isGetAccessor;
/* @internal */
function isOptionalChainRoot(node) {
return ts.isOptionalChain(node) && !!node.questionDotToken;
}
ts.isOptionalChainRoot = isOptionalChainRoot;
/** True if has jsdoc nodes attached to it. */
/* @internal */
// TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times
@ -17351,6 +17370,8 @@ var ts;
var patterns = [];
for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) {
var patternString = patternStrings_1[_i];
if (!ts.hasZeroOrOneAsteriskCharacter(patternString))
continue;
var pattern = tryParsePattern(patternString);
if (pattern) {
patterns.push(pattern);
@ -29785,7 +29806,7 @@ var ts;
}
function bindCondition(node, trueTarget, falseTarget) {
doWithConditionalBranches(bind, node, trueTarget, falseTarget);
if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && isOutermostOptionalChain(node))) {
if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) {
addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
}
@ -30257,12 +30278,9 @@ var ts;
addDeclarationToSymbol(host.symbol, host, 32 /* Class */);
}
}
function isOutermostOptionalChain(node) {
return !ts.isOptionalChain(node.parent) || ts.isOptionalChainRoot(node.parent) || node !== node.parent.expression;
}
function bindOptionalExpression(node, trueTarget, falseTarget) {
doWithConditionalBranches(bind, node, trueTarget, falseTarget);
if (!ts.isOptionalChain(node) || isOutermostOptionalChain(node)) {
if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) {
addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
}
@ -30300,7 +30318,7 @@ var ts;
currentFlow = finishFlowLabel(preChainLabel);
}
doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget);
if (isOutermostOptionalChain(node)) {
if (ts.isOutermostOptionalChain(node)) {
addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
}
@ -31385,7 +31403,7 @@ var ts;
}
function bindObjectDefinePrototypeProperty(node) {
var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression);
if (namespaceSymbol) {
if (namespaceSymbol && namespaceSymbol.valueDeclaration) {
// Ensure the namespace symbol becomes class-like
addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */);
}
@ -32112,7 +32130,8 @@ var ts;
|| ts.hasModifier(node, 2270 /* TypeScriptModifier */)
|| node.typeParameters
|| node.type
|| !node.body) {
|| !node.body
|| node.questionToken) {
transformFlags |= 1 /* AssertTypeScript */;
}
// function declarations with object rest destructuring are ES2018 syntax
@ -32149,7 +32168,7 @@ var ts;
function computePropertyDeclaration(node, subtreeFlags) {
var transformFlags = subtreeFlags | 1048576 /* ContainsClassFields */;
// Decorators, TypeScript-specific modifiers, and type annotations are TypeScript syntax.
if (ts.some(node.decorators) || ts.hasModifier(node, 2270 /* TypeScriptModifier */) || node.type) {
if (ts.some(node.decorators) || ts.hasModifier(node, 2270 /* TypeScriptModifier */) || node.type || node.questionToken) {
transformFlags |= 1 /* AssertTypeScript */;
}
// Hoisted variables related to class properties should live within the TypeScript class wrapper.
@ -40679,13 +40698,21 @@ var ts;
result.mapper = undefined;
return result;
}
function getOptionalCallSignature(signature) {
return signatureIsOptionalCall(signature) ? signature :
(signature.optionalCallSignatureCache || (signature.optionalCallSignatureCache = createOptionalCallSignature(signature)));
function getOptionalCallSignature(signature, callChainFlags) {
if ((signature.flags & 12 /* CallChainFlags */) === callChainFlags) {
return signature;
}
if (!signature.optionalCallSignatureCache) {
signature.optionalCallSignatureCache = {};
}
var key = callChainFlags === 4 /* IsInnerCallChain */ ? "inner" : "outer";
return signature.optionalCallSignatureCache[key]
|| (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags));
}
function createOptionalCallSignature(signature) {
function createOptionalCallSignature(signature, callChainFlags) {
ts.Debug.assert(callChainFlags === 4 /* IsInnerCallChain */ || callChainFlags === 8 /* IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both.");
var result = cloneSignature(signature);
result.flags |= 4 /* IsOptionalCall */;
result.flags |= callChainFlags;
return result;
}
function getExpandedParameters(sig) {
@ -42197,9 +42224,12 @@ var ts;
signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) :
getReturnTypeFromAnnotation(signature.declaration) ||
(ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration));
if (signatureIsOptionalCall(signature)) {
if (signature.flags & 4 /* IsInnerCallChain */) {
type = addOptionalTypeMarker(type);
}
else if (signature.flags & 8 /* IsOuterCallChain */) {
type = getOptionalType(type);
}
if (!popTypeResolution()) {
if (signature.declaration) {
var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration);
@ -42672,7 +42702,8 @@ var ts;
isRequireAlias = ts.isCallExpression(expr) && ts.isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !!valueType.symbol;
}
var isDelayedMergeClass = symbol !== valueType.symbol && getMergedSymbol(symbol) === valueType.symbol;
if (isRequireAlias || node.kind === 187 /* ImportType */ || isDelayedMergeClass) {
var isImportTypeWithQualifier = node.kind === 187 /* ImportType */ && node.qualifier;
if (isRequireAlias || isImportTypeWithQualifier || isDelayedMergeClass) {
typeType = getTypeReferenceType(node, valueType.symbol);
}
}
@ -48212,8 +48243,8 @@ var ts;
function removeOptionalTypeMarker(type) {
return strictNullChecks ? filterType(type, isNotOptionalTypeMarker) : type;
}
function propagateOptionalTypeMarker(type, wasOptional) {
return wasOptional ? addOptionalTypeMarker(type) : type;
function propagateOptionalTypeMarker(type, node, wasOptional) {
return wasOptional ? ts.isOutermostOptionalChain(node) ? getOptionalType(type) : addOptionalTypeMarker(type) : type;
}
function getOptionalExpressionType(exprType, expression) {
return ts.isExpressionOfOptionalChainRoot(expression) ? getNonNullableType(exprType) :
@ -53840,7 +53871,7 @@ var ts;
function checkPropertyAccessChain(node) {
var leftType = checkExpression(node.expression);
var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), nonOptionalType !== leftType);
return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType);
}
function checkQualifiedName(node) {
return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right);
@ -54232,7 +54263,7 @@ var ts;
function checkElementAccessChain(node) {
var exprType = checkExpression(node.expression);
var nonOptionalType = getOptionalExpressionType(exprType, node.expression);
return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), nonOptionalType !== exprType);
return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType);
}
function checkElementAccessExpression(node, exprType) {
var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
@ -54321,7 +54352,7 @@ var ts;
// interface B extends A { (x: 'foo'): string }
// const b: B;
// b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void]
function reorderCandidates(signatures, result, isOptionalCall) {
function reorderCandidates(signatures, result, callChainFlags) {
var lastParent;
var lastSymbol;
var cutoffIndex = 0;
@ -54362,7 +54393,7 @@ var ts;
else {
spliceIndex = index;
}
result.splice(spliceIndex, 0, isOptionalCall ? getOptionalCallSignature(signature) : signature);
result.splice(spliceIndex, 0, callChainFlags ? getOptionalCallSignature(signature, callChainFlags) : signature);
}
}
function isSpreadArgument(arg) {
@ -54952,7 +54983,7 @@ var ts;
}
return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
}
function resolveCall(node, signatures, candidatesOutArray, checkMode, isOptionalCall, fallbackError) {
function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) {
var isTaggedTemplate = node.kind === 197 /* TaggedTemplateExpression */;
var isDecorator = node.kind === 156 /* Decorator */;
var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
@ -54967,7 +54998,7 @@ var ts;
}
var candidates = candidatesOutArray || [];
// reorderCandidates fills up the candidates array directly
reorderCandidates(signatures, candidates, isOptionalCall);
reorderCandidates(signatures, candidates, callChainFlags);
if (!candidates.length) {
if (reportErrors) {
diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures));
@ -55325,20 +55356,22 @@ var ts;
var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
if (baseTypeNode) {
var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode);
return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, /*isOptional*/ false);
return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* None */);
}
}
return resolveUntypedCall(node);
}
var isOptional;
var callChainFlags;
var funcType = checkExpression(node.expression);
if (ts.isCallChain(node)) {
var nonOptionalType = getOptionalExpressionType(funcType, node.expression);
isOptional = nonOptionalType !== funcType;
callChainFlags = nonOptionalType === funcType ? 0 /* None */ :
ts.isOutermostOptionalChain(node) ? 8 /* IsOuterCallChain */ :
4 /* IsInnerCallChain */;
funcType = nonOptionalType;
}
else {
isOptional = false;
callChainFlags = 0 /* None */;
}
funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError);
if (funcType === silentNeverType) {
@ -55406,7 +55439,7 @@ var ts;
error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
return resolveErrorCall(node);
}
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, isOptional);
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
}
function isGenericFunctionReturningFunction(signature) {
return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
@ -55469,7 +55502,7 @@ var ts;
error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class);
return resolveErrorCall(node);
}
return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, /*isOptional*/ false);
return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* None */);
}
// If expressionType's apparent type is an object type with no construct signatures but
// one or more call signatures, the expression is processed as a function call. A compile-time
@ -55477,7 +55510,7 @@ var ts;
// operation is Any. It is an error to have a Void this type.
var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */);
if (callSignatures.length) {
var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false);
var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */);
if (!noImplicitAny) {
if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
@ -55654,7 +55687,7 @@ var ts;
invocationError(node.tag, apparentType, 0 /* Call */);
return resolveErrorCall(node);
}
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false);
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */);
}
/**
* Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression.
@ -55707,7 +55740,7 @@ var ts;
invocationErrorRecovery(apparentType, 0 /* Call */, diag);
return resolveErrorCall(node);
}
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false, headMessage);
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage);
}
function createSignatureForJSXIntrinsic(node, result) {
var namespace = getJsxNamespaceAt(node);
@ -55745,7 +55778,7 @@ var ts;
error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName));
return resolveErrorCall(node);
}
return resolveCall(node, signatures, candidatesOutArray, checkMode, /*isOptional*/ false);
return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */);
}
/**
* Sometimes, we have a decorator that could accept zero arguments,
@ -58005,6 +58038,18 @@ var ts;
}
}
}
function getReturnTypeOfSingleNonGenericCallSignature(funcType) {
var signature = getSingleCallSignature(funcType);
if (signature && !signature.typeParameters) {
return getReturnTypeOfSignature(signature);
}
}
function getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) {
var funcType = checkExpression(expr.expression);
var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
var returnType = getReturnTypeOfSingleNonGenericCallSignature(funcType);
return returnType && propagateOptionalTypeMarker(returnType, expr, nonOptionalType !== funcType);
}
/**
* Returns the type of an expression. Unlike checkExpression, this function is simply concerned
* with computing the type and may not fully check all contained sub-expressions for errors.
@ -58016,21 +58061,10 @@ var ts;
// Optimize for the common case of a call to a function with a single non-generic call
// signature where we can just fetch the return type without checking the arguments.
if (ts.isCallExpression(expr) && expr.expression.kind !== 101 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) {
var isOptional = void 0;
var funcType = void 0;
if (ts.isCallChain(expr)) {
funcType = checkExpression(expr.expression);
var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
isOptional = funcType !== nonOptionalType;
funcType = checkNonNullType(nonOptionalType, expr.expression);
}
else {
isOptional = false;
funcType = checkNonNullExpression(expr.expression);
}
var signature = getSingleCallSignature(funcType);
if (signature && !signature.typeParameters) {
return propagateOptionalTypeMarker(getReturnTypeOfSignature(signature), isOptional);
var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
if (type) {
return type;
}
}
else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) {
@ -65885,10 +65919,6 @@ var ts;
return !!(s.flags & 2 /* HasLiteralTypes */);
}
ts.signatureHasLiteralTypes = signatureHasLiteralTypes;
function signatureIsOptionalCall(s) {
return !!(s.flags & 4 /* IsOptionalCall */);
}
ts.signatureIsOptionalCall = signatureIsOptionalCall;
})(ts || (ts = {}));
var ts;
(function (ts) {
@ -73880,12 +73910,12 @@ var ts;
for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) {
var parameter = parametersWithPropertyAssignments_1[_i];
if (ts.isIdentifier(parameter.name)) {
members.push(ts.aggregateTransformFlags(ts.createProperty(
members.push(ts.setOriginalNode(ts.aggregateTransformFlags(ts.createProperty(
/*decorators*/ undefined,
/*modifiers*/ undefined, parameter.name,
/*questionOrExclamationToken*/ undefined,
/*type*/ undefined,
/*initializer*/ undefined)));
/*initializer*/ undefined)), parameter));
}
}
}
@ -74700,6 +74730,9 @@ var ts;
return !ts.nodeIsMissing(node.body);
}
function visitPropertyDeclaration(node) {
if (node.flags & 8388608 /* Ambient */) {
return undefined;
}
var updated = ts.updateProperty(node,
/*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node),
/*questionOrExclamationToken*/ undefined,
@ -75084,7 +75117,12 @@ var ts;
*
* @param node The module declaration node.
*/
function shouldEmitModuleDeclaration(node) {
function shouldEmitModuleDeclaration(nodeIn) {
var node = ts.getParseTreeNode(nodeIn, ts.isModuleDeclaration);
if (!node) {
// If we can't find a parse tree node, assume the node is instantiated.
return true;
}
return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules);
}
/**
@ -75808,9 +75846,9 @@ var ts;
/**
* Transforms ECMAScript Class Syntax.
* TypeScript parameter property syntax is transformed in the TypeScript transformer.
* For now, this transforms public field declarations using TypeScript class semantics
* (where the declarations get elided and initializers are transformed as assignments in the constructor).
* Eventually, this transform will change to the ECMAScript semantics (with Object.defineProperty).
* For now, this transforms public field declarations using TypeScript class semantics,
* where declarations are elided and initializers are transformed as assignments in the constructor.
* When --useDefineForClassFields is on, this transforms to ECMAScript semantics, with Object.defineProperty.
*/
function transformClassFields(context) {
var hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment;
@ -76021,7 +76059,9 @@ var ts;
/*modifiers*/ undefined, parameters, body), constructor || node), constructor));
}
function transformConstructorBody(node, constructor, isDerivedClass) {
var properties = ts.getProperties(node, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields, /*isStatic*/ false);
var _a;
var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields;
var properties = ts.getProperties(node, /*requireInitializer*/ !useDefineForClassFields, /*isStatic*/ false);
// Only generate synthetic constructor when there are property initializers to move.
if (!constructor && !ts.some(properties)) {
return ts.visitFunctionBody(/*node*/ undefined, visitor, context);
@ -76050,19 +76090,16 @@ var ts;
// this.x = 1;
// }
//
if (constructor && constructor.body) {
var parameterPropertyDeclarationCount = 0;
for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) {
if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) {
parameterPropertyDeclarationCount++;
}
else {
break;
}
if ((_a = constructor) === null || _a === void 0 ? void 0 : _a.body) {
var afterParameterProperties = ts.findIndex(constructor.body.statements, function (s) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(s), constructor); }, indexOfFirstStatement);
if (afterParameterProperties === -1) {
afterParameterProperties = constructor.body.statements.length;
}
if (parameterPropertyDeclarationCount > 0) {
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, parameterPropertyDeclarationCount));
indexOfFirstStatement += parameterPropertyDeclarationCount;
if (afterParameterProperties > indexOfFirstStatement) {
if (!useDefineForClassFields) {
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, afterParameterProperties - indexOfFirstStatement));
}
indexOfFirstStatement = afterParameterProperties;
}
}
addPropertyStatements(statements, properties, ts.createThis());
@ -76123,7 +76160,9 @@ var ts;
var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression)
? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name))
: property.name;
var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression) : ts.createVoidZero();
var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression)
: ts.hasModifier(ts.getOriginalNode(property), 92 /* ParameterPropertyModifier */) && ts.isIdentifier(propertyName) ? propertyName
: ts.createVoidZero();
if (emitAssignment) {
var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName);
return ts.createAssignment(memberAccess, initializer);
@ -96751,7 +96790,7 @@ var ts;
var typeOfSubst = typeof subst;
if (typeOfSubst === "string") {
if (!ts.hasZeroOrOneAsteriskCharacter(subst)) {
createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key);
createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character, subst, key);
}
}
else {
@ -104385,10 +104424,11 @@ var ts;
}
var dependencyKeys = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"];
var stringContent = host.readFile(fileName);
var content = stringContent && tryParseJson(stringContent);
if (!content) {
if (!stringContent)
return undefined;
}
var content = tryParseJson(stringContent);
if (!content)
return false;
var info = {};
for (var _i = 0, dependencyKeys_1 = dependencyKeys; _i < dependencyKeys_1.length; _i++) {
var key = dependencyKeys_1[_i];
@ -135480,7 +135520,9 @@ var ts;
case -1 /* True */:
var packageJsonFileName = ts.combinePaths(directory, "package.json");
watchPackageJsonFile(packageJsonFileName);
result.push(ts.Debug.assertDefined(packageJsonCache.getInDirectory(directory)));
var info = packageJsonCache.getInDirectory(directory);
if (info)
result.push(info);
}
if (rootPath && rootPath === toPath(directory)) {
return true;
@ -136768,7 +136810,7 @@ var ts;
ts.Debug.assert(info.isOrphan());
var project = this.getOrCreateInferredProjectForProjectRootPathIfEnabled(info, projectRootPath) ||
this.getOrCreateSingleInferredProjectIfEnabled() ||
this.getOrCreateSingleInferredWithoutProjectRoot(info.isDynamic ? this.currentDirectory : ts.getDirectoryPath(info.path));
this.getOrCreateSingleInferredWithoutProjectRoot(info.isDynamic ? projectRootPath || this.currentDirectory : ts.getDirectoryPath(info.path));
project.addRoot(info);
if (info.containingProjects[0] !== project) {
// Ensure this is first project, we could be in this scenario because info could be part of orphan project
@ -137091,6 +137133,9 @@ var ts;
}
ts.Debug.assert(!isOpenScriptInfo(info) || this.openFiles.has(info.path));
var projectRootPath = this.openFiles.get(info.path);
var scriptInfo = ts.Debug.assertDefined(this.getScriptInfo(info.path));
if (scriptInfo.isDynamic)
return undefined;
var searchPath = server.asNormalizedPath(ts.getDirectoryPath(info.fileName));
var isSearchPathInProjectRoot = function () { return ts.containsPath(projectRootPath, searchPath, _this.currentDirectory, !_this.host.useCaseSensitiveFileNames); };
// If projectRootPath doesn't contain info.path, then do normal search for config file
@ -137462,7 +137507,9 @@ var ts;
});
};
ProjectService.prototype.getOrCreateInferredProjectForProjectRootPathIfEnabled = function (info, projectRootPath) {
if (info.isDynamic || !this.useInferredProjectPerProjectRoot) {
if (!this.useInferredProjectPerProjectRoot ||
// Its a dynamic info opened without project root
(info.isDynamic && projectRootPath === undefined)) {
return undefined;
}
if (projectRootPath) {
@ -137721,7 +137768,7 @@ var ts;
var isDynamic = server.isDynamicFileName(fileName);
ts.Debug.assert(ts.isRootedDiskPath(fileName) || isDynamic || openedByClient, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nScript info with non-dynamic relative file name can only be open script info or in context of host currentDirectory"; });
ts.Debug.assert(!ts.isRootedDiskPath(fileName) || this.currentDirectory === currentDirectory || !this.openFilesWithNonRootedDiskPath.has(this.toCanonicalFileName(fileName)), "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nOpen script files with non rooted disk path opened with current directory context cannot have same canonical names"; });
ts.Debug.assert(!isDynamic || this.currentDirectory === currentDirectory, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nDynamic files must always have current directory context since containing external project name will always match the script info name."; });
ts.Debug.assert(!isDynamic || this.currentDirectory === currentDirectory || this.useInferredProjectPerProjectRoot, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nDynamic files must always be opened with service's current directory or service should support inferred project per projectRootPath."; });
// If the file is not opened by client and the file doesnot exist on the disk, return
if (!openedByClient && !isDynamic && !(hostToQueryFileExistsOn || this.host).fileExists(fileName)) {
return;
@ -137732,7 +137779,7 @@ var ts;
if (!openedByClient) {
this.watchClosedScriptInfo(info);
}
else if (!ts.isRootedDiskPath(fileName) && !isDynamic) {
else if (!ts.isRootedDiskPath(fileName) && (!isDynamic || this.currentDirectory !== currentDirectory)) {
// File that is opened by user but isn't rooted disk path
this.openFilesWithNonRootedDiskPath.set(this.toCanonicalFileName(fileName), info);
}
@ -138723,7 +138770,7 @@ var ts;
directoriesWithoutPackageJson.set(ts.getDirectoryPath(fileName), true);
},
getInDirectory: function (directory) {
return packageJsons.get(ts.combinePaths(directory, "package.json"));
return packageJsons.get(ts.combinePaths(directory, "package.json")) || undefined;
},
directoryHasPackageJson: directoryHasPackageJson,
searchDirectoryAndAncestors: function (directory) {
@ -138743,7 +138790,7 @@ var ts;
};
function addOrUpdate(fileName) {
var packageJsonInfo = ts.createPackageJsonInfo(fileName, project);
if (packageJsonInfo) {
if (packageJsonInfo !== undefined) {
packageJsons.set(fileName, packageJsonInfo);
directoriesWithoutPackageJson.delete(ts.getDirectoryPath(fileName));
}

View File

@ -244,7 +244,7 @@ var ts;
// If changing the text in this section, be sure to test `configureNightly` too.
ts.versionMajorMinor = "3.7";
/** The version of the TypeScript compiler release */
ts.version = ts.versionMajorMinor + ".2";
ts.version = ts.versionMajorMinor + ".3";
})(ts || (ts = {}));
(function (ts) {
/* @internal */
@ -3949,11 +3949,13 @@ var ts;
SignatureFlags[SignatureFlags["None"] = 0] = "None";
SignatureFlags[SignatureFlags["HasRestParameter"] = 1] = "HasRestParameter";
SignatureFlags[SignatureFlags["HasLiteralTypes"] = 2] = "HasLiteralTypes";
SignatureFlags[SignatureFlags["IsOptionalCall"] = 4] = "IsOptionalCall";
// We do not propagate `IsOptionalCall` to instantiated signatures, as that would result in us
SignatureFlags[SignatureFlags["IsInnerCallChain"] = 4] = "IsInnerCallChain";
SignatureFlags[SignatureFlags["IsOuterCallChain"] = 8] = "IsOuterCallChain";
// We do not propagate `IsInnerCallChain` to instantiated signatures, as that would result in us
// attempting to add `| undefined` on each recursive call to `getReturnTypeOfSignature` when
// instantiating the return type.
SignatureFlags[SignatureFlags["PropagatingFlags"] = 3] = "PropagatingFlags";
SignatureFlags[SignatureFlags["CallChainFlags"] = 12] = "CallChainFlags";
})(SignatureFlags = ts.SignatureFlags || (ts.SignatureFlags = {}));
var IndexKind;
(function (IndexKind) {
@ -7200,7 +7202,7 @@ var ts;
Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: diag(5059, ts.DiagnosticCategory.Error, "Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier_5059", "Invalid value for '--reactNamespace'. '{0}' is not a valid identifier."),
Option_paths_cannot_be_used_without_specifying_baseUrl_option: diag(5060, ts.DiagnosticCategory.Error, "Option_paths_cannot_be_used_without_specifying_baseUrl_option_5060", "Option 'paths' cannot be used without specifying '--baseUrl' option."),
Pattern_0_can_have_at_most_one_Asterisk_character: diag(5061, ts.DiagnosticCategory.Error, "Pattern_0_can_have_at_most_one_Asterisk_character_5061", "Pattern '{0}' can have at most one '*' character."),
Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: diag(5062, ts.DiagnosticCategory.Error, "Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character_5062", "Substitution '{0}' in pattern '{1}' in can have at most one '*' character."),
Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character: diag(5062, ts.DiagnosticCategory.Error, "Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character_5062", "Substitution '{0}' in pattern '{1}' can have at most one '*' character."),
Substitutions_for_pattern_0_should_be_an_array: diag(5063, ts.DiagnosticCategory.Error, "Substitutions_for_pattern_0_should_be_an_array_5063", "Substitutions for pattern '{0}' should be an array."),
Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: diag(5064, ts.DiagnosticCategory.Error, "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'."),
File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5065, ts.DiagnosticCategory.Error, "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'."),
@ -15314,14 +15316,36 @@ var ts;
|| kind === 195 /* CallExpression */);
}
ts.isOptionalChain = isOptionalChain;
/* @internal */
function isOptionalChainRoot(node) {
return isOptionalChain(node) && !!node.questionDotToken;
}
ts.isOptionalChainRoot = isOptionalChainRoot;
/**
* Determines whether a node is the expression preceding an optional chain (i.e. `a` in `a?.b`).
*/
/* @internal */
function isExpressionOfOptionalChainRoot(node) {
return ts.isOptionalChainRoot(node.parent) && node.parent.expression === node;
return isOptionalChainRoot(node.parent) && node.parent.expression === node;
}
ts.isExpressionOfOptionalChainRoot = isExpressionOfOptionalChainRoot;
/**
* Determines whether a node is the outermost `OptionalChain` in an ECMAScript `OptionalExpression`:
*
* 1. For `a?.b.c`, the outermost chain is `a?.b.c` (`c` is the end of the chain starting at `a?.`)
* 2. For `(a?.b.c).d`, the outermost chain is `a?.b.c` (`c` is the end of the chain starting at `a?.` since parens end the chain)
* 3. For `a?.b.c?.d`, both `a?.b.c` and `a?.b.c?.d` are outermost (`c` is the end of the chain starting at `a?.`, and `d` is
* the end of the chain starting at `c?.`)
* 4. For `a?.(b?.c).d`, both `b?.c` and `a?.(b?.c)d` are outermost (`c` is the end of the chain starting at `b`, and `d` is
* the end of the chain starting at `a?.`)
*/
/* @internal */
function isOutermostOptionalChain(node) {
return !isOptionalChain(node.parent) // cases 1 and 2
|| isOptionalChainRoot(node.parent) // case 3
|| node !== node.parent.expression; // case 4
}
ts.isOutermostOptionalChain = isOutermostOptionalChain;
function isNullishCoalesce(node) {
return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */;
}
@ -16596,11 +16620,6 @@ var ts;
return node.kind === 162 /* GetAccessor */;
}
ts.isGetAccessor = isGetAccessor;
/* @internal */
function isOptionalChainRoot(node) {
return ts.isOptionalChain(node) && !!node.questionDotToken;
}
ts.isOptionalChainRoot = isOptionalChainRoot;
/** True if has jsdoc nodes attached to it. */
/* @internal */
// TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times
@ -17501,6 +17520,8 @@ var ts;
var patterns = [];
for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) {
var patternString = patternStrings_1[_i];
if (!ts.hasZeroOrOneAsteriskCharacter(patternString))
continue;
var pattern = tryParsePattern(patternString);
if (pattern) {
patterns.push(pattern);
@ -29935,7 +29956,7 @@ var ts;
}
function bindCondition(node, trueTarget, falseTarget) {
doWithConditionalBranches(bind, node, trueTarget, falseTarget);
if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && isOutermostOptionalChain(node))) {
if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) {
addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
}
@ -30407,12 +30428,9 @@ var ts;
addDeclarationToSymbol(host.symbol, host, 32 /* Class */);
}
}
function isOutermostOptionalChain(node) {
return !ts.isOptionalChain(node.parent) || ts.isOptionalChainRoot(node.parent) || node !== node.parent.expression;
}
function bindOptionalExpression(node, trueTarget, falseTarget) {
doWithConditionalBranches(bind, node, trueTarget, falseTarget);
if (!ts.isOptionalChain(node) || isOutermostOptionalChain(node)) {
if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) {
addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
}
@ -30450,7 +30468,7 @@ var ts;
currentFlow = finishFlowLabel(preChainLabel);
}
doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget);
if (isOutermostOptionalChain(node)) {
if (ts.isOutermostOptionalChain(node)) {
addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
}
@ -31535,7 +31553,7 @@ var ts;
}
function bindObjectDefinePrototypeProperty(node) {
var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression);
if (namespaceSymbol) {
if (namespaceSymbol && namespaceSymbol.valueDeclaration) {
// Ensure the namespace symbol becomes class-like
addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */);
}
@ -32262,7 +32280,8 @@ var ts;
|| ts.hasModifier(node, 2270 /* TypeScriptModifier */)
|| node.typeParameters
|| node.type
|| !node.body) {
|| !node.body
|| node.questionToken) {
transformFlags |= 1 /* AssertTypeScript */;
}
// function declarations with object rest destructuring are ES2018 syntax
@ -32299,7 +32318,7 @@ var ts;
function computePropertyDeclaration(node, subtreeFlags) {
var transformFlags = subtreeFlags | 1048576 /* ContainsClassFields */;
// Decorators, TypeScript-specific modifiers, and type annotations are TypeScript syntax.
if (ts.some(node.decorators) || ts.hasModifier(node, 2270 /* TypeScriptModifier */) || node.type) {
if (ts.some(node.decorators) || ts.hasModifier(node, 2270 /* TypeScriptModifier */) || node.type || node.questionToken) {
transformFlags |= 1 /* AssertTypeScript */;
}
// Hoisted variables related to class properties should live within the TypeScript class wrapper.
@ -40829,13 +40848,21 @@ var ts;
result.mapper = undefined;
return result;
}
function getOptionalCallSignature(signature) {
return signatureIsOptionalCall(signature) ? signature :
(signature.optionalCallSignatureCache || (signature.optionalCallSignatureCache = createOptionalCallSignature(signature)));
function getOptionalCallSignature(signature, callChainFlags) {
if ((signature.flags & 12 /* CallChainFlags */) === callChainFlags) {
return signature;
}
if (!signature.optionalCallSignatureCache) {
signature.optionalCallSignatureCache = {};
}
var key = callChainFlags === 4 /* IsInnerCallChain */ ? "inner" : "outer";
return signature.optionalCallSignatureCache[key]
|| (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags));
}
function createOptionalCallSignature(signature) {
function createOptionalCallSignature(signature, callChainFlags) {
ts.Debug.assert(callChainFlags === 4 /* IsInnerCallChain */ || callChainFlags === 8 /* IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both.");
var result = cloneSignature(signature);
result.flags |= 4 /* IsOptionalCall */;
result.flags |= callChainFlags;
return result;
}
function getExpandedParameters(sig) {
@ -42347,9 +42374,12 @@ var ts;
signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) :
getReturnTypeFromAnnotation(signature.declaration) ||
(ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration));
if (signatureIsOptionalCall(signature)) {
if (signature.flags & 4 /* IsInnerCallChain */) {
type = addOptionalTypeMarker(type);
}
else if (signature.flags & 8 /* IsOuterCallChain */) {
type = getOptionalType(type);
}
if (!popTypeResolution()) {
if (signature.declaration) {
var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration);
@ -42822,7 +42852,8 @@ var ts;
isRequireAlias = ts.isCallExpression(expr) && ts.isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !!valueType.symbol;
}
var isDelayedMergeClass = symbol !== valueType.symbol && getMergedSymbol(symbol) === valueType.symbol;
if (isRequireAlias || node.kind === 187 /* ImportType */ || isDelayedMergeClass) {
var isImportTypeWithQualifier = node.kind === 187 /* ImportType */ && node.qualifier;
if (isRequireAlias || isImportTypeWithQualifier || isDelayedMergeClass) {
typeType = getTypeReferenceType(node, valueType.symbol);
}
}
@ -48362,8 +48393,8 @@ var ts;
function removeOptionalTypeMarker(type) {
return strictNullChecks ? filterType(type, isNotOptionalTypeMarker) : type;
}
function propagateOptionalTypeMarker(type, wasOptional) {
return wasOptional ? addOptionalTypeMarker(type) : type;
function propagateOptionalTypeMarker(type, node, wasOptional) {
return wasOptional ? ts.isOutermostOptionalChain(node) ? getOptionalType(type) : addOptionalTypeMarker(type) : type;
}
function getOptionalExpressionType(exprType, expression) {
return ts.isExpressionOfOptionalChainRoot(expression) ? getNonNullableType(exprType) :
@ -53990,7 +54021,7 @@ var ts;
function checkPropertyAccessChain(node) {
var leftType = checkExpression(node.expression);
var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), nonOptionalType !== leftType);
return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType);
}
function checkQualifiedName(node) {
return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right);
@ -54382,7 +54413,7 @@ var ts;
function checkElementAccessChain(node) {
var exprType = checkExpression(node.expression);
var nonOptionalType = getOptionalExpressionType(exprType, node.expression);
return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), nonOptionalType !== exprType);
return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType);
}
function checkElementAccessExpression(node, exprType) {
var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
@ -54471,7 +54502,7 @@ var ts;
// interface B extends A { (x: 'foo'): string }
// const b: B;
// b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void]
function reorderCandidates(signatures, result, isOptionalCall) {
function reorderCandidates(signatures, result, callChainFlags) {
var lastParent;
var lastSymbol;
var cutoffIndex = 0;
@ -54512,7 +54543,7 @@ var ts;
else {
spliceIndex = index;
}
result.splice(spliceIndex, 0, isOptionalCall ? getOptionalCallSignature(signature) : signature);
result.splice(spliceIndex, 0, callChainFlags ? getOptionalCallSignature(signature, callChainFlags) : signature);
}
}
function isSpreadArgument(arg) {
@ -55102,7 +55133,7 @@ var ts;
}
return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
}
function resolveCall(node, signatures, candidatesOutArray, checkMode, isOptionalCall, fallbackError) {
function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) {
var isTaggedTemplate = node.kind === 197 /* TaggedTemplateExpression */;
var isDecorator = node.kind === 156 /* Decorator */;
var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
@ -55117,7 +55148,7 @@ var ts;
}
var candidates = candidatesOutArray || [];
// reorderCandidates fills up the candidates array directly
reorderCandidates(signatures, candidates, isOptionalCall);
reorderCandidates(signatures, candidates, callChainFlags);
if (!candidates.length) {
if (reportErrors) {
diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures));
@ -55475,20 +55506,22 @@ var ts;
var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
if (baseTypeNode) {
var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode);
return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, /*isOptional*/ false);
return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* None */);
}
}
return resolveUntypedCall(node);
}
var isOptional;
var callChainFlags;
var funcType = checkExpression(node.expression);
if (ts.isCallChain(node)) {
var nonOptionalType = getOptionalExpressionType(funcType, node.expression);
isOptional = nonOptionalType !== funcType;
callChainFlags = nonOptionalType === funcType ? 0 /* None */ :
ts.isOutermostOptionalChain(node) ? 8 /* IsOuterCallChain */ :
4 /* IsInnerCallChain */;
funcType = nonOptionalType;
}
else {
isOptional = false;
callChainFlags = 0 /* None */;
}
funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError);
if (funcType === silentNeverType) {
@ -55556,7 +55589,7 @@ var ts;
error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
return resolveErrorCall(node);
}
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, isOptional);
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
}
function isGenericFunctionReturningFunction(signature) {
return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
@ -55619,7 +55652,7 @@ var ts;
error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class);
return resolveErrorCall(node);
}
return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, /*isOptional*/ false);
return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* None */);
}
// If expressionType's apparent type is an object type with no construct signatures but
// one or more call signatures, the expression is processed as a function call. A compile-time
@ -55627,7 +55660,7 @@ var ts;
// operation is Any. It is an error to have a Void this type.
var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */);
if (callSignatures.length) {
var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false);
var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */);
if (!noImplicitAny) {
if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
@ -55804,7 +55837,7 @@ var ts;
invocationError(node.tag, apparentType, 0 /* Call */);
return resolveErrorCall(node);
}
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false);
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */);
}
/**
* Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression.
@ -55857,7 +55890,7 @@ var ts;
invocationErrorRecovery(apparentType, 0 /* Call */, diag);
return resolveErrorCall(node);
}
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false, headMessage);
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage);
}
function createSignatureForJSXIntrinsic(node, result) {
var namespace = getJsxNamespaceAt(node);
@ -55895,7 +55928,7 @@ var ts;
error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName));
return resolveErrorCall(node);
}
return resolveCall(node, signatures, candidatesOutArray, checkMode, /*isOptional*/ false);
return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */);
}
/**
* Sometimes, we have a decorator that could accept zero arguments,
@ -58155,6 +58188,18 @@ var ts;
}
}
}
function getReturnTypeOfSingleNonGenericCallSignature(funcType) {
var signature = getSingleCallSignature(funcType);
if (signature && !signature.typeParameters) {
return getReturnTypeOfSignature(signature);
}
}
function getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) {
var funcType = checkExpression(expr.expression);
var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
var returnType = getReturnTypeOfSingleNonGenericCallSignature(funcType);
return returnType && propagateOptionalTypeMarker(returnType, expr, nonOptionalType !== funcType);
}
/**
* Returns the type of an expression. Unlike checkExpression, this function is simply concerned
* with computing the type and may not fully check all contained sub-expressions for errors.
@ -58166,21 +58211,10 @@ var ts;
// Optimize for the common case of a call to a function with a single non-generic call
// signature where we can just fetch the return type without checking the arguments.
if (ts.isCallExpression(expr) && expr.expression.kind !== 101 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) {
var isOptional = void 0;
var funcType = void 0;
if (ts.isCallChain(expr)) {
funcType = checkExpression(expr.expression);
var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
isOptional = funcType !== nonOptionalType;
funcType = checkNonNullType(nonOptionalType, expr.expression);
}
else {
isOptional = false;
funcType = checkNonNullExpression(expr.expression);
}
var signature = getSingleCallSignature(funcType);
if (signature && !signature.typeParameters) {
return propagateOptionalTypeMarker(getReturnTypeOfSignature(signature), isOptional);
var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
if (type) {
return type;
}
}
else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) {
@ -66035,10 +66069,6 @@ var ts;
return !!(s.flags & 2 /* HasLiteralTypes */);
}
ts.signatureHasLiteralTypes = signatureHasLiteralTypes;
function signatureIsOptionalCall(s) {
return !!(s.flags & 4 /* IsOptionalCall */);
}
ts.signatureIsOptionalCall = signatureIsOptionalCall;
})(ts || (ts = {}));
var ts;
(function (ts) {
@ -74030,12 +74060,12 @@ var ts;
for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) {
var parameter = parametersWithPropertyAssignments_1[_i];
if (ts.isIdentifier(parameter.name)) {
members.push(ts.aggregateTransformFlags(ts.createProperty(
members.push(ts.setOriginalNode(ts.aggregateTransformFlags(ts.createProperty(
/*decorators*/ undefined,
/*modifiers*/ undefined, parameter.name,
/*questionOrExclamationToken*/ undefined,
/*type*/ undefined,
/*initializer*/ undefined)));
/*initializer*/ undefined)), parameter));
}
}
}
@ -74850,6 +74880,9 @@ var ts;
return !ts.nodeIsMissing(node.body);
}
function visitPropertyDeclaration(node) {
if (node.flags & 8388608 /* Ambient */) {
return undefined;
}
var updated = ts.updateProperty(node,
/*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node),
/*questionOrExclamationToken*/ undefined,
@ -75234,7 +75267,12 @@ var ts;
*
* @param node The module declaration node.
*/
function shouldEmitModuleDeclaration(node) {
function shouldEmitModuleDeclaration(nodeIn) {
var node = ts.getParseTreeNode(nodeIn, ts.isModuleDeclaration);
if (!node) {
// If we can't find a parse tree node, assume the node is instantiated.
return true;
}
return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules);
}
/**
@ -75958,9 +75996,9 @@ var ts;
/**
* Transforms ECMAScript Class Syntax.
* TypeScript parameter property syntax is transformed in the TypeScript transformer.
* For now, this transforms public field declarations using TypeScript class semantics
* (where the declarations get elided and initializers are transformed as assignments in the constructor).
* Eventually, this transform will change to the ECMAScript semantics (with Object.defineProperty).
* For now, this transforms public field declarations using TypeScript class semantics,
* where declarations are elided and initializers are transformed as assignments in the constructor.
* When --useDefineForClassFields is on, this transforms to ECMAScript semantics, with Object.defineProperty.
*/
function transformClassFields(context) {
var hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment;
@ -76171,7 +76209,9 @@ var ts;
/*modifiers*/ undefined, parameters, body), constructor || node), constructor));
}
function transformConstructorBody(node, constructor, isDerivedClass) {
var properties = ts.getProperties(node, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields, /*isStatic*/ false);
var _a;
var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields;
var properties = ts.getProperties(node, /*requireInitializer*/ !useDefineForClassFields, /*isStatic*/ false);
// Only generate synthetic constructor when there are property initializers to move.
if (!constructor && !ts.some(properties)) {
return ts.visitFunctionBody(/*node*/ undefined, visitor, context);
@ -76200,19 +76240,16 @@ var ts;
// this.x = 1;
// }
//
if (constructor && constructor.body) {
var parameterPropertyDeclarationCount = 0;
for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) {
if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) {
parameterPropertyDeclarationCount++;
}
else {
break;
}
if ((_a = constructor) === null || _a === void 0 ? void 0 : _a.body) {
var afterParameterProperties = ts.findIndex(constructor.body.statements, function (s) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(s), constructor); }, indexOfFirstStatement);
if (afterParameterProperties === -1) {
afterParameterProperties = constructor.body.statements.length;
}
if (parameterPropertyDeclarationCount > 0) {
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, parameterPropertyDeclarationCount));
indexOfFirstStatement += parameterPropertyDeclarationCount;
if (afterParameterProperties > indexOfFirstStatement) {
if (!useDefineForClassFields) {
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, afterParameterProperties - indexOfFirstStatement));
}
indexOfFirstStatement = afterParameterProperties;
}
}
addPropertyStatements(statements, properties, ts.createThis());
@ -76273,7 +76310,9 @@ var ts;
var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression)
? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name))
: property.name;
var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression) : ts.createVoidZero();
var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression)
: ts.hasModifier(ts.getOriginalNode(property), 92 /* ParameterPropertyModifier */) && ts.isIdentifier(propertyName) ? propertyName
: ts.createVoidZero();
if (emitAssignment) {
var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName);
return ts.createAssignment(memberAccess, initializer);
@ -96901,7 +96940,7 @@ var ts;
var typeOfSubst = typeof subst;
if (typeOfSubst === "string") {
if (!ts.hasZeroOrOneAsteriskCharacter(subst)) {
createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key);
createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character, subst, key);
}
}
else {
@ -104898,10 +104937,11 @@ var ts;
}
var dependencyKeys = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"];
var stringContent = host.readFile(fileName);
var content = stringContent && tryParseJson(stringContent);
if (!content) {
if (!stringContent)
return undefined;
}
var content = tryParseJson(stringContent);
if (!content)
return false;
var info = {};
for (var _i = 0, dependencyKeys_1 = dependencyKeys; _i < dependencyKeys_1.length; _i++) {
var key = dependencyKeys_1[_i];
@ -135630,7 +135670,9 @@ var ts;
case -1 /* True */:
var packageJsonFileName = ts.combinePaths(directory, "package.json");
watchPackageJsonFile(packageJsonFileName);
result.push(ts.Debug.assertDefined(packageJsonCache.getInDirectory(directory)));
var info = packageJsonCache.getInDirectory(directory);
if (info)
result.push(info);
}
if (rootPath && rootPath === toPath(directory)) {
return true;
@ -136918,7 +136960,7 @@ var ts;
ts.Debug.assert(info.isOrphan());
var project = this.getOrCreateInferredProjectForProjectRootPathIfEnabled(info, projectRootPath) ||
this.getOrCreateSingleInferredProjectIfEnabled() ||
this.getOrCreateSingleInferredWithoutProjectRoot(info.isDynamic ? this.currentDirectory : ts.getDirectoryPath(info.path));
this.getOrCreateSingleInferredWithoutProjectRoot(info.isDynamic ? projectRootPath || this.currentDirectory : ts.getDirectoryPath(info.path));
project.addRoot(info);
if (info.containingProjects[0] !== project) {
// Ensure this is first project, we could be in this scenario because info could be part of orphan project
@ -137241,6 +137283,9 @@ var ts;
}
ts.Debug.assert(!isOpenScriptInfo(info) || this.openFiles.has(info.path));
var projectRootPath = this.openFiles.get(info.path);
var scriptInfo = ts.Debug.assertDefined(this.getScriptInfo(info.path));
if (scriptInfo.isDynamic)
return undefined;
var searchPath = server.asNormalizedPath(ts.getDirectoryPath(info.fileName));
var isSearchPathInProjectRoot = function () { return ts.containsPath(projectRootPath, searchPath, _this.currentDirectory, !_this.host.useCaseSensitiveFileNames); };
// If projectRootPath doesn't contain info.path, then do normal search for config file
@ -137612,7 +137657,9 @@ var ts;
});
};
ProjectService.prototype.getOrCreateInferredProjectForProjectRootPathIfEnabled = function (info, projectRootPath) {
if (info.isDynamic || !this.useInferredProjectPerProjectRoot) {
if (!this.useInferredProjectPerProjectRoot ||
// Its a dynamic info opened without project root
(info.isDynamic && projectRootPath === undefined)) {
return undefined;
}
if (projectRootPath) {
@ -137871,7 +137918,7 @@ var ts;
var isDynamic = server.isDynamicFileName(fileName);
ts.Debug.assert(ts.isRootedDiskPath(fileName) || isDynamic || openedByClient, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nScript info with non-dynamic relative file name can only be open script info or in context of host currentDirectory"; });
ts.Debug.assert(!ts.isRootedDiskPath(fileName) || this.currentDirectory === currentDirectory || !this.openFilesWithNonRootedDiskPath.has(this.toCanonicalFileName(fileName)), "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nOpen script files with non rooted disk path opened with current directory context cannot have same canonical names"; });
ts.Debug.assert(!isDynamic || this.currentDirectory === currentDirectory, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nDynamic files must always have current directory context since containing external project name will always match the script info name."; });
ts.Debug.assert(!isDynamic || this.currentDirectory === currentDirectory || this.useInferredProjectPerProjectRoot, "", function () { return JSON.stringify({ fileName: fileName, currentDirectory: currentDirectory, hostCurrentDirectory: _this.currentDirectory, openKeys: ts.arrayFrom(_this.openFilesWithNonRootedDiskPath.keys()) }) + "\nDynamic files must always be opened with service's current directory or service should support inferred project per projectRootPath."; });
// If the file is not opened by client and the file doesnot exist on the disk, return
if (!openedByClient && !isDynamic && !(hostToQueryFileExistsOn || this.host).fileExists(fileName)) {
return;
@ -137882,7 +137929,7 @@ var ts;
if (!openedByClient) {
this.watchClosedScriptInfo(info);
}
else if (!ts.isRootedDiskPath(fileName) && !isDynamic) {
else if (!ts.isRootedDiskPath(fileName) && (!isDynamic || this.currentDirectory !== currentDirectory)) {
// File that is opened by user but isn't rooted disk path
this.openFilesWithNonRootedDiskPath.set(this.toCanonicalFileName(fileName), info);
}
@ -138873,7 +138920,7 @@ var ts;
directoriesWithoutPackageJson.set(ts.getDirectoryPath(fileName), true);
},
getInDirectory: function (directory) {
return packageJsons.get(ts.combinePaths(directory, "package.json"));
return packageJsons.get(ts.combinePaths(directory, "package.json")) || undefined;
},
directoryHasPackageJson: directoryHasPackageJson,
searchDirectoryAndAncestors: function (directory) {
@ -138893,7 +138940,7 @@ var ts;
};
function addOrUpdate(fileName) {
var packageJsonInfo = ts.createPackageJsonInfo(fileName, project);
if (packageJsonInfo) {
if (packageJsonInfo !== undefined) {
packageJsons.set(fileName, packageJsonInfo);
directoriesWithoutPackageJson.delete(ts.getDirectoryPath(fileName));
}

View File

@ -233,7 +233,7 @@ var ts;
// If changing the text in this section, be sure to test `configureNightly` too.
ts.versionMajorMinor = "3.7";
/** The version of the TypeScript compiler release */
ts.version = ts.versionMajorMinor + ".2";
ts.version = ts.versionMajorMinor + ".3";
})(ts || (ts = {}));
(function (ts) {
/* @internal */
@ -3938,11 +3938,13 @@ var ts;
SignatureFlags[SignatureFlags["None"] = 0] = "None";
SignatureFlags[SignatureFlags["HasRestParameter"] = 1] = "HasRestParameter";
SignatureFlags[SignatureFlags["HasLiteralTypes"] = 2] = "HasLiteralTypes";
SignatureFlags[SignatureFlags["IsOptionalCall"] = 4] = "IsOptionalCall";
// We do not propagate `IsOptionalCall` to instantiated signatures, as that would result in us
SignatureFlags[SignatureFlags["IsInnerCallChain"] = 4] = "IsInnerCallChain";
SignatureFlags[SignatureFlags["IsOuterCallChain"] = 8] = "IsOuterCallChain";
// We do not propagate `IsInnerCallChain` to instantiated signatures, as that would result in us
// attempting to add `| undefined` on each recursive call to `getReturnTypeOfSignature` when
// instantiating the return type.
SignatureFlags[SignatureFlags["PropagatingFlags"] = 3] = "PropagatingFlags";
SignatureFlags[SignatureFlags["CallChainFlags"] = 12] = "CallChainFlags";
})(SignatureFlags = ts.SignatureFlags || (ts.SignatureFlags = {}));
var IndexKind;
(function (IndexKind) {
@ -7189,7 +7191,7 @@ var ts;
Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: diag(5059, ts.DiagnosticCategory.Error, "Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier_5059", "Invalid value for '--reactNamespace'. '{0}' is not a valid identifier."),
Option_paths_cannot_be_used_without_specifying_baseUrl_option: diag(5060, ts.DiagnosticCategory.Error, "Option_paths_cannot_be_used_without_specifying_baseUrl_option_5060", "Option 'paths' cannot be used without specifying '--baseUrl' option."),
Pattern_0_can_have_at_most_one_Asterisk_character: diag(5061, ts.DiagnosticCategory.Error, "Pattern_0_can_have_at_most_one_Asterisk_character_5061", "Pattern '{0}' can have at most one '*' character."),
Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: diag(5062, ts.DiagnosticCategory.Error, "Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character_5062", "Substitution '{0}' in pattern '{1}' in can have at most one '*' character."),
Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character: diag(5062, ts.DiagnosticCategory.Error, "Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character_5062", "Substitution '{0}' in pattern '{1}' can have at most one '*' character."),
Substitutions_for_pattern_0_should_be_an_array: diag(5063, ts.DiagnosticCategory.Error, "Substitutions_for_pattern_0_should_be_an_array_5063", "Substitutions for pattern '{0}' should be an array."),
Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: diag(5064, ts.DiagnosticCategory.Error, "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'."),
File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5065, ts.DiagnosticCategory.Error, "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'."),
@ -15303,14 +15305,36 @@ var ts;
|| kind === 195 /* CallExpression */);
}
ts.isOptionalChain = isOptionalChain;
/* @internal */
function isOptionalChainRoot(node) {
return isOptionalChain(node) && !!node.questionDotToken;
}
ts.isOptionalChainRoot = isOptionalChainRoot;
/**
* Determines whether a node is the expression preceding an optional chain (i.e. `a` in `a?.b`).
*/
/* @internal */
function isExpressionOfOptionalChainRoot(node) {
return ts.isOptionalChainRoot(node.parent) && node.parent.expression === node;
return isOptionalChainRoot(node.parent) && node.parent.expression === node;
}
ts.isExpressionOfOptionalChainRoot = isExpressionOfOptionalChainRoot;
/**
* Determines whether a node is the outermost `OptionalChain` in an ECMAScript `OptionalExpression`:
*
* 1. For `a?.b.c`, the outermost chain is `a?.b.c` (`c` is the end of the chain starting at `a?.`)
* 2. For `(a?.b.c).d`, the outermost chain is `a?.b.c` (`c` is the end of the chain starting at `a?.` since parens end the chain)
* 3. For `a?.b.c?.d`, both `a?.b.c` and `a?.b.c?.d` are outermost (`c` is the end of the chain starting at `a?.`, and `d` is
* the end of the chain starting at `c?.`)
* 4. For `a?.(b?.c).d`, both `b?.c` and `a?.(b?.c)d` are outermost (`c` is the end of the chain starting at `b`, and `d` is
* the end of the chain starting at `a?.`)
*/
/* @internal */
function isOutermostOptionalChain(node) {
return !isOptionalChain(node.parent) // cases 1 and 2
|| isOptionalChainRoot(node.parent) // case 3
|| node !== node.parent.expression; // case 4
}
ts.isOutermostOptionalChain = isOutermostOptionalChain;
function isNullishCoalesce(node) {
return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */;
}
@ -16585,11 +16609,6 @@ var ts;
return node.kind === 162 /* GetAccessor */;
}
ts.isGetAccessor = isGetAccessor;
/* @internal */
function isOptionalChainRoot(node) {
return ts.isOptionalChain(node) && !!node.questionDotToken;
}
ts.isOptionalChainRoot = isOptionalChainRoot;
/** True if has jsdoc nodes attached to it. */
/* @internal */
// TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times
@ -17490,6 +17509,8 @@ var ts;
var patterns = [];
for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) {
var patternString = patternStrings_1[_i];
if (!ts.hasZeroOrOneAsteriskCharacter(patternString))
continue;
var pattern = tryParsePattern(patternString);
if (pattern) {
patterns.push(pattern);
@ -29924,7 +29945,7 @@ var ts;
}
function bindCondition(node, trueTarget, falseTarget) {
doWithConditionalBranches(bind, node, trueTarget, falseTarget);
if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && isOutermostOptionalChain(node))) {
if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) {
addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
}
@ -30396,12 +30417,9 @@ var ts;
addDeclarationToSymbol(host.symbol, host, 32 /* Class */);
}
}
function isOutermostOptionalChain(node) {
return !ts.isOptionalChain(node.parent) || ts.isOptionalChainRoot(node.parent) || node !== node.parent.expression;
}
function bindOptionalExpression(node, trueTarget, falseTarget) {
doWithConditionalBranches(bind, node, trueTarget, falseTarget);
if (!ts.isOptionalChain(node) || isOutermostOptionalChain(node)) {
if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) {
addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
}
@ -30439,7 +30457,7 @@ var ts;
currentFlow = finishFlowLabel(preChainLabel);
}
doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget);
if (isOutermostOptionalChain(node)) {
if (ts.isOutermostOptionalChain(node)) {
addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
}
@ -31524,7 +31542,7 @@ var ts;
}
function bindObjectDefinePrototypeProperty(node) {
var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression);
if (namespaceSymbol) {
if (namespaceSymbol && namespaceSymbol.valueDeclaration) {
// Ensure the namespace symbol becomes class-like
addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */);
}
@ -32251,7 +32269,8 @@ var ts;
|| ts.hasModifier(node, 2270 /* TypeScriptModifier */)
|| node.typeParameters
|| node.type
|| !node.body) {
|| !node.body
|| node.questionToken) {
transformFlags |= 1 /* AssertTypeScript */;
}
// function declarations with object rest destructuring are ES2018 syntax
@ -32288,7 +32307,7 @@ var ts;
function computePropertyDeclaration(node, subtreeFlags) {
var transformFlags = subtreeFlags | 1048576 /* ContainsClassFields */;
// Decorators, TypeScript-specific modifiers, and type annotations are TypeScript syntax.
if (ts.some(node.decorators) || ts.hasModifier(node, 2270 /* TypeScriptModifier */) || node.type) {
if (ts.some(node.decorators) || ts.hasModifier(node, 2270 /* TypeScriptModifier */) || node.type || node.questionToken) {
transformFlags |= 1 /* AssertTypeScript */;
}
// Hoisted variables related to class properties should live within the TypeScript class wrapper.
@ -40818,13 +40837,21 @@ var ts;
result.mapper = undefined;
return result;
}
function getOptionalCallSignature(signature) {
return signatureIsOptionalCall(signature) ? signature :
(signature.optionalCallSignatureCache || (signature.optionalCallSignatureCache = createOptionalCallSignature(signature)));
function getOptionalCallSignature(signature, callChainFlags) {
if ((signature.flags & 12 /* CallChainFlags */) === callChainFlags) {
return signature;
}
if (!signature.optionalCallSignatureCache) {
signature.optionalCallSignatureCache = {};
}
var key = callChainFlags === 4 /* IsInnerCallChain */ ? "inner" : "outer";
return signature.optionalCallSignatureCache[key]
|| (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags));
}
function createOptionalCallSignature(signature) {
function createOptionalCallSignature(signature, callChainFlags) {
ts.Debug.assert(callChainFlags === 4 /* IsInnerCallChain */ || callChainFlags === 8 /* IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both.");
var result = cloneSignature(signature);
result.flags |= 4 /* IsOptionalCall */;
result.flags |= callChainFlags;
return result;
}
function getExpandedParameters(sig) {
@ -42336,9 +42363,12 @@ var ts;
signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) :
getReturnTypeFromAnnotation(signature.declaration) ||
(ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration));
if (signatureIsOptionalCall(signature)) {
if (signature.flags & 4 /* IsInnerCallChain */) {
type = addOptionalTypeMarker(type);
}
else if (signature.flags & 8 /* IsOuterCallChain */) {
type = getOptionalType(type);
}
if (!popTypeResolution()) {
if (signature.declaration) {
var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration);
@ -42811,7 +42841,8 @@ var ts;
isRequireAlias = ts.isCallExpression(expr) && ts.isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !!valueType.symbol;
}
var isDelayedMergeClass = symbol !== valueType.symbol && getMergedSymbol(symbol) === valueType.symbol;
if (isRequireAlias || node.kind === 187 /* ImportType */ || isDelayedMergeClass) {
var isImportTypeWithQualifier = node.kind === 187 /* ImportType */ && node.qualifier;
if (isRequireAlias || isImportTypeWithQualifier || isDelayedMergeClass) {
typeType = getTypeReferenceType(node, valueType.symbol);
}
}
@ -48351,8 +48382,8 @@ var ts;
function removeOptionalTypeMarker(type) {
return strictNullChecks ? filterType(type, isNotOptionalTypeMarker) : type;
}
function propagateOptionalTypeMarker(type, wasOptional) {
return wasOptional ? addOptionalTypeMarker(type) : type;
function propagateOptionalTypeMarker(type, node, wasOptional) {
return wasOptional ? ts.isOutermostOptionalChain(node) ? getOptionalType(type) : addOptionalTypeMarker(type) : type;
}
function getOptionalExpressionType(exprType, expression) {
return ts.isExpressionOfOptionalChainRoot(expression) ? getNonNullableType(exprType) :
@ -53979,7 +54010,7 @@ var ts;
function checkPropertyAccessChain(node) {
var leftType = checkExpression(node.expression);
var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), nonOptionalType !== leftType);
return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType);
}
function checkQualifiedName(node) {
return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right);
@ -54371,7 +54402,7 @@ var ts;
function checkElementAccessChain(node) {
var exprType = checkExpression(node.expression);
var nonOptionalType = getOptionalExpressionType(exprType, node.expression);
return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), nonOptionalType !== exprType);
return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType);
}
function checkElementAccessExpression(node, exprType) {
var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
@ -54460,7 +54491,7 @@ var ts;
// interface B extends A { (x: 'foo'): string }
// const b: B;
// b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void]
function reorderCandidates(signatures, result, isOptionalCall) {
function reorderCandidates(signatures, result, callChainFlags) {
var lastParent;
var lastSymbol;
var cutoffIndex = 0;
@ -54501,7 +54532,7 @@ var ts;
else {
spliceIndex = index;
}
result.splice(spliceIndex, 0, isOptionalCall ? getOptionalCallSignature(signature) : signature);
result.splice(spliceIndex, 0, callChainFlags ? getOptionalCallSignature(signature, callChainFlags) : signature);
}
}
function isSpreadArgument(arg) {
@ -55091,7 +55122,7 @@ var ts;
}
return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
}
function resolveCall(node, signatures, candidatesOutArray, checkMode, isOptionalCall, fallbackError) {
function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) {
var isTaggedTemplate = node.kind === 197 /* TaggedTemplateExpression */;
var isDecorator = node.kind === 156 /* Decorator */;
var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
@ -55106,7 +55137,7 @@ var ts;
}
var candidates = candidatesOutArray || [];
// reorderCandidates fills up the candidates array directly
reorderCandidates(signatures, candidates, isOptionalCall);
reorderCandidates(signatures, candidates, callChainFlags);
if (!candidates.length) {
if (reportErrors) {
diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures));
@ -55464,20 +55495,22 @@ var ts;
var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
if (baseTypeNode) {
var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode);
return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, /*isOptional*/ false);
return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* None */);
}
}
return resolveUntypedCall(node);
}
var isOptional;
var callChainFlags;
var funcType = checkExpression(node.expression);
if (ts.isCallChain(node)) {
var nonOptionalType = getOptionalExpressionType(funcType, node.expression);
isOptional = nonOptionalType !== funcType;
callChainFlags = nonOptionalType === funcType ? 0 /* None */ :
ts.isOutermostOptionalChain(node) ? 8 /* IsOuterCallChain */ :
4 /* IsInnerCallChain */;
funcType = nonOptionalType;
}
else {
isOptional = false;
callChainFlags = 0 /* None */;
}
funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError);
if (funcType === silentNeverType) {
@ -55545,7 +55578,7 @@ var ts;
error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
return resolveErrorCall(node);
}
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, isOptional);
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
}
function isGenericFunctionReturningFunction(signature) {
return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
@ -55608,7 +55641,7 @@ var ts;
error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class);
return resolveErrorCall(node);
}
return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, /*isOptional*/ false);
return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* None */);
}
// If expressionType's apparent type is an object type with no construct signatures but
// one or more call signatures, the expression is processed as a function call. A compile-time
@ -55616,7 +55649,7 @@ var ts;
// operation is Any. It is an error to have a Void this type.
var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */);
if (callSignatures.length) {
var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false);
var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */);
if (!noImplicitAny) {
if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
@ -55793,7 +55826,7 @@ var ts;
invocationError(node.tag, apparentType, 0 /* Call */);
return resolveErrorCall(node);
}
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false);
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */);
}
/**
* Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression.
@ -55846,7 +55879,7 @@ var ts;
invocationErrorRecovery(apparentType, 0 /* Call */, diag);
return resolveErrorCall(node);
}
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false, headMessage);
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage);
}
function createSignatureForJSXIntrinsic(node, result) {
var namespace = getJsxNamespaceAt(node);
@ -55884,7 +55917,7 @@ var ts;
error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName));
return resolveErrorCall(node);
}
return resolveCall(node, signatures, candidatesOutArray, checkMode, /*isOptional*/ false);
return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */);
}
/**
* Sometimes, we have a decorator that could accept zero arguments,
@ -58144,6 +58177,18 @@ var ts;
}
}
}
function getReturnTypeOfSingleNonGenericCallSignature(funcType) {
var signature = getSingleCallSignature(funcType);
if (signature && !signature.typeParameters) {
return getReturnTypeOfSignature(signature);
}
}
function getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) {
var funcType = checkExpression(expr.expression);
var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
var returnType = getReturnTypeOfSingleNonGenericCallSignature(funcType);
return returnType && propagateOptionalTypeMarker(returnType, expr, nonOptionalType !== funcType);
}
/**
* Returns the type of an expression. Unlike checkExpression, this function is simply concerned
* with computing the type and may not fully check all contained sub-expressions for errors.
@ -58155,21 +58200,10 @@ var ts;
// Optimize for the common case of a call to a function with a single non-generic call
// signature where we can just fetch the return type without checking the arguments.
if (ts.isCallExpression(expr) && expr.expression.kind !== 101 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) {
var isOptional = void 0;
var funcType = void 0;
if (ts.isCallChain(expr)) {
funcType = checkExpression(expr.expression);
var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
isOptional = funcType !== nonOptionalType;
funcType = checkNonNullType(nonOptionalType, expr.expression);
}
else {
isOptional = false;
funcType = checkNonNullExpression(expr.expression);
}
var signature = getSingleCallSignature(funcType);
if (signature && !signature.typeParameters) {
return propagateOptionalTypeMarker(getReturnTypeOfSignature(signature), isOptional);
var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
if (type) {
return type;
}
}
else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) {
@ -66024,10 +66058,6 @@ var ts;
return !!(s.flags & 2 /* HasLiteralTypes */);
}
ts.signatureHasLiteralTypes = signatureHasLiteralTypes;
function signatureIsOptionalCall(s) {
return !!(s.flags & 4 /* IsOptionalCall */);
}
ts.signatureIsOptionalCall = signatureIsOptionalCall;
})(ts || (ts = {}));
var ts;
(function (ts) {
@ -74019,12 +74049,12 @@ var ts;
for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) {
var parameter = parametersWithPropertyAssignments_1[_i];
if (ts.isIdentifier(parameter.name)) {
members.push(ts.aggregateTransformFlags(ts.createProperty(
members.push(ts.setOriginalNode(ts.aggregateTransformFlags(ts.createProperty(
/*decorators*/ undefined,
/*modifiers*/ undefined, parameter.name,
/*questionOrExclamationToken*/ undefined,
/*type*/ undefined,
/*initializer*/ undefined)));
/*initializer*/ undefined)), parameter));
}
}
}
@ -74839,6 +74869,9 @@ var ts;
return !ts.nodeIsMissing(node.body);
}
function visitPropertyDeclaration(node) {
if (node.flags & 8388608 /* Ambient */) {
return undefined;
}
var updated = ts.updateProperty(node,
/*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node),
/*questionOrExclamationToken*/ undefined,
@ -75223,7 +75256,12 @@ var ts;
*
* @param node The module declaration node.
*/
function shouldEmitModuleDeclaration(node) {
function shouldEmitModuleDeclaration(nodeIn) {
var node = ts.getParseTreeNode(nodeIn, ts.isModuleDeclaration);
if (!node) {
// If we can't find a parse tree node, assume the node is instantiated.
return true;
}
return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules);
}
/**
@ -75947,9 +75985,9 @@ var ts;
/**
* Transforms ECMAScript Class Syntax.
* TypeScript parameter property syntax is transformed in the TypeScript transformer.
* For now, this transforms public field declarations using TypeScript class semantics
* (where the declarations get elided and initializers are transformed as assignments in the constructor).
* Eventually, this transform will change to the ECMAScript semantics (with Object.defineProperty).
* For now, this transforms public field declarations using TypeScript class semantics,
* where declarations are elided and initializers are transformed as assignments in the constructor.
* When --useDefineForClassFields is on, this transforms to ECMAScript semantics, with Object.defineProperty.
*/
function transformClassFields(context) {
var hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment;
@ -76160,7 +76198,9 @@ var ts;
/*modifiers*/ undefined, parameters, body), constructor || node), constructor));
}
function transformConstructorBody(node, constructor, isDerivedClass) {
var properties = ts.getProperties(node, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields, /*isStatic*/ false);
var _a;
var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields;
var properties = ts.getProperties(node, /*requireInitializer*/ !useDefineForClassFields, /*isStatic*/ false);
// Only generate synthetic constructor when there are property initializers to move.
if (!constructor && !ts.some(properties)) {
return ts.visitFunctionBody(/*node*/ undefined, visitor, context);
@ -76189,19 +76229,16 @@ var ts;
// this.x = 1;
// }
//
if (constructor && constructor.body) {
var parameterPropertyDeclarationCount = 0;
for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) {
if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) {
parameterPropertyDeclarationCount++;
}
else {
break;
}
if ((_a = constructor) === null || _a === void 0 ? void 0 : _a.body) {
var afterParameterProperties = ts.findIndex(constructor.body.statements, function (s) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(s), constructor); }, indexOfFirstStatement);
if (afterParameterProperties === -1) {
afterParameterProperties = constructor.body.statements.length;
}
if (parameterPropertyDeclarationCount > 0) {
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, parameterPropertyDeclarationCount));
indexOfFirstStatement += parameterPropertyDeclarationCount;
if (afterParameterProperties > indexOfFirstStatement) {
if (!useDefineForClassFields) {
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, afterParameterProperties - indexOfFirstStatement));
}
indexOfFirstStatement = afterParameterProperties;
}
}
addPropertyStatements(statements, properties, ts.createThis());
@ -76262,7 +76299,9 @@ var ts;
var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression)
? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name))
: property.name;
var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression) : ts.createVoidZero();
var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression)
: ts.hasModifier(ts.getOriginalNode(property), 92 /* ParameterPropertyModifier */) && ts.isIdentifier(propertyName) ? propertyName
: ts.createVoidZero();
if (emitAssignment) {
var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName);
return ts.createAssignment(memberAccess, initializer);
@ -96890,7 +96929,7 @@ var ts;
var typeOfSubst = typeof subst;
if (typeOfSubst === "string") {
if (!ts.hasZeroOrOneAsteriskCharacter(subst)) {
createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key);
createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character, subst, key);
}
}
else {
@ -104887,10 +104926,11 @@ var ts;
}
var dependencyKeys = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"];
var stringContent = host.readFile(fileName);
var content = stringContent && tryParseJson(stringContent);
if (!content) {
if (!stringContent)
return undefined;
}
var content = tryParseJson(stringContent);
if (!content)
return false;
var info = {};
for (var _i = 0, dependencyKeys_1 = dependencyKeys; _i < dependencyKeys_1.length; _i++) {
var key = dependencyKeys_1[_i];

View File

@ -233,7 +233,7 @@ var ts;
// If changing the text in this section, be sure to test `configureNightly` too.
ts.versionMajorMinor = "3.7";
/** The version of the TypeScript compiler release */
ts.version = ts.versionMajorMinor + ".2";
ts.version = ts.versionMajorMinor + ".3";
})(ts || (ts = {}));
(function (ts) {
/* @internal */
@ -3938,11 +3938,13 @@ var ts;
SignatureFlags[SignatureFlags["None"] = 0] = "None";
SignatureFlags[SignatureFlags["HasRestParameter"] = 1] = "HasRestParameter";
SignatureFlags[SignatureFlags["HasLiteralTypes"] = 2] = "HasLiteralTypes";
SignatureFlags[SignatureFlags["IsOptionalCall"] = 4] = "IsOptionalCall";
// We do not propagate `IsOptionalCall` to instantiated signatures, as that would result in us
SignatureFlags[SignatureFlags["IsInnerCallChain"] = 4] = "IsInnerCallChain";
SignatureFlags[SignatureFlags["IsOuterCallChain"] = 8] = "IsOuterCallChain";
// We do not propagate `IsInnerCallChain` to instantiated signatures, as that would result in us
// attempting to add `| undefined` on each recursive call to `getReturnTypeOfSignature` when
// instantiating the return type.
SignatureFlags[SignatureFlags["PropagatingFlags"] = 3] = "PropagatingFlags";
SignatureFlags[SignatureFlags["CallChainFlags"] = 12] = "CallChainFlags";
})(SignatureFlags = ts.SignatureFlags || (ts.SignatureFlags = {}));
var IndexKind;
(function (IndexKind) {
@ -7189,7 +7191,7 @@ var ts;
Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: diag(5059, ts.DiagnosticCategory.Error, "Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier_5059", "Invalid value for '--reactNamespace'. '{0}' is not a valid identifier."),
Option_paths_cannot_be_used_without_specifying_baseUrl_option: diag(5060, ts.DiagnosticCategory.Error, "Option_paths_cannot_be_used_without_specifying_baseUrl_option_5060", "Option 'paths' cannot be used without specifying '--baseUrl' option."),
Pattern_0_can_have_at_most_one_Asterisk_character: diag(5061, ts.DiagnosticCategory.Error, "Pattern_0_can_have_at_most_one_Asterisk_character_5061", "Pattern '{0}' can have at most one '*' character."),
Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: diag(5062, ts.DiagnosticCategory.Error, "Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character_5062", "Substitution '{0}' in pattern '{1}' in can have at most one '*' character."),
Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character: diag(5062, ts.DiagnosticCategory.Error, "Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character_5062", "Substitution '{0}' in pattern '{1}' can have at most one '*' character."),
Substitutions_for_pattern_0_should_be_an_array: diag(5063, ts.DiagnosticCategory.Error, "Substitutions_for_pattern_0_should_be_an_array_5063", "Substitutions for pattern '{0}' should be an array."),
Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: diag(5064, ts.DiagnosticCategory.Error, "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'."),
File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5065, ts.DiagnosticCategory.Error, "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'."),
@ -15303,14 +15305,36 @@ var ts;
|| kind === 195 /* CallExpression */);
}
ts.isOptionalChain = isOptionalChain;
/* @internal */
function isOptionalChainRoot(node) {
return isOptionalChain(node) && !!node.questionDotToken;
}
ts.isOptionalChainRoot = isOptionalChainRoot;
/**
* Determines whether a node is the expression preceding an optional chain (i.e. `a` in `a?.b`).
*/
/* @internal */
function isExpressionOfOptionalChainRoot(node) {
return ts.isOptionalChainRoot(node.parent) && node.parent.expression === node;
return isOptionalChainRoot(node.parent) && node.parent.expression === node;
}
ts.isExpressionOfOptionalChainRoot = isExpressionOfOptionalChainRoot;
/**
* Determines whether a node is the outermost `OptionalChain` in an ECMAScript `OptionalExpression`:
*
* 1. For `a?.b.c`, the outermost chain is `a?.b.c` (`c` is the end of the chain starting at `a?.`)
* 2. For `(a?.b.c).d`, the outermost chain is `a?.b.c` (`c` is the end of the chain starting at `a?.` since parens end the chain)
* 3. For `a?.b.c?.d`, both `a?.b.c` and `a?.b.c?.d` are outermost (`c` is the end of the chain starting at `a?.`, and `d` is
* the end of the chain starting at `c?.`)
* 4. For `a?.(b?.c).d`, both `b?.c` and `a?.(b?.c)d` are outermost (`c` is the end of the chain starting at `b`, and `d` is
* the end of the chain starting at `a?.`)
*/
/* @internal */
function isOutermostOptionalChain(node) {
return !isOptionalChain(node.parent) // cases 1 and 2
|| isOptionalChainRoot(node.parent) // case 3
|| node !== node.parent.expression; // case 4
}
ts.isOutermostOptionalChain = isOutermostOptionalChain;
function isNullishCoalesce(node) {
return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */;
}
@ -16585,11 +16609,6 @@ var ts;
return node.kind === 162 /* GetAccessor */;
}
ts.isGetAccessor = isGetAccessor;
/* @internal */
function isOptionalChainRoot(node) {
return ts.isOptionalChain(node) && !!node.questionDotToken;
}
ts.isOptionalChainRoot = isOptionalChainRoot;
/** True if has jsdoc nodes attached to it. */
/* @internal */
// TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times
@ -17490,6 +17509,8 @@ var ts;
var patterns = [];
for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) {
var patternString = patternStrings_1[_i];
if (!ts.hasZeroOrOneAsteriskCharacter(patternString))
continue;
var pattern = tryParsePattern(patternString);
if (pattern) {
patterns.push(pattern);
@ -29924,7 +29945,7 @@ var ts;
}
function bindCondition(node, trueTarget, falseTarget) {
doWithConditionalBranches(bind, node, trueTarget, falseTarget);
if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && isOutermostOptionalChain(node))) {
if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) {
addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
}
@ -30396,12 +30417,9 @@ var ts;
addDeclarationToSymbol(host.symbol, host, 32 /* Class */);
}
}
function isOutermostOptionalChain(node) {
return !ts.isOptionalChain(node.parent) || ts.isOptionalChainRoot(node.parent) || node !== node.parent.expression;
}
function bindOptionalExpression(node, trueTarget, falseTarget) {
doWithConditionalBranches(bind, node, trueTarget, falseTarget);
if (!ts.isOptionalChain(node) || isOutermostOptionalChain(node)) {
if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) {
addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
}
@ -30439,7 +30457,7 @@ var ts;
currentFlow = finishFlowLabel(preChainLabel);
}
doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget);
if (isOutermostOptionalChain(node)) {
if (ts.isOutermostOptionalChain(node)) {
addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
}
@ -31524,7 +31542,7 @@ var ts;
}
function bindObjectDefinePrototypeProperty(node) {
var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression);
if (namespaceSymbol) {
if (namespaceSymbol && namespaceSymbol.valueDeclaration) {
// Ensure the namespace symbol becomes class-like
addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */);
}
@ -32251,7 +32269,8 @@ var ts;
|| ts.hasModifier(node, 2270 /* TypeScriptModifier */)
|| node.typeParameters
|| node.type
|| !node.body) {
|| !node.body
|| node.questionToken) {
transformFlags |= 1 /* AssertTypeScript */;
}
// function declarations with object rest destructuring are ES2018 syntax
@ -32288,7 +32307,7 @@ var ts;
function computePropertyDeclaration(node, subtreeFlags) {
var transformFlags = subtreeFlags | 1048576 /* ContainsClassFields */;
// Decorators, TypeScript-specific modifiers, and type annotations are TypeScript syntax.
if (ts.some(node.decorators) || ts.hasModifier(node, 2270 /* TypeScriptModifier */) || node.type) {
if (ts.some(node.decorators) || ts.hasModifier(node, 2270 /* TypeScriptModifier */) || node.type || node.questionToken) {
transformFlags |= 1 /* AssertTypeScript */;
}
// Hoisted variables related to class properties should live within the TypeScript class wrapper.
@ -40818,13 +40837,21 @@ var ts;
result.mapper = undefined;
return result;
}
function getOptionalCallSignature(signature) {
return signatureIsOptionalCall(signature) ? signature :
(signature.optionalCallSignatureCache || (signature.optionalCallSignatureCache = createOptionalCallSignature(signature)));
function getOptionalCallSignature(signature, callChainFlags) {
if ((signature.flags & 12 /* CallChainFlags */) === callChainFlags) {
return signature;
}
if (!signature.optionalCallSignatureCache) {
signature.optionalCallSignatureCache = {};
}
var key = callChainFlags === 4 /* IsInnerCallChain */ ? "inner" : "outer";
return signature.optionalCallSignatureCache[key]
|| (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags));
}
function createOptionalCallSignature(signature) {
function createOptionalCallSignature(signature, callChainFlags) {
ts.Debug.assert(callChainFlags === 4 /* IsInnerCallChain */ || callChainFlags === 8 /* IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both.");
var result = cloneSignature(signature);
result.flags |= 4 /* IsOptionalCall */;
result.flags |= callChainFlags;
return result;
}
function getExpandedParameters(sig) {
@ -42336,9 +42363,12 @@ var ts;
signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) :
getReturnTypeFromAnnotation(signature.declaration) ||
(ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration));
if (signatureIsOptionalCall(signature)) {
if (signature.flags & 4 /* IsInnerCallChain */) {
type = addOptionalTypeMarker(type);
}
else if (signature.flags & 8 /* IsOuterCallChain */) {
type = getOptionalType(type);
}
if (!popTypeResolution()) {
if (signature.declaration) {
var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration);
@ -42811,7 +42841,8 @@ var ts;
isRequireAlias = ts.isCallExpression(expr) && ts.isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !!valueType.symbol;
}
var isDelayedMergeClass = symbol !== valueType.symbol && getMergedSymbol(symbol) === valueType.symbol;
if (isRequireAlias || node.kind === 187 /* ImportType */ || isDelayedMergeClass) {
var isImportTypeWithQualifier = node.kind === 187 /* ImportType */ && node.qualifier;
if (isRequireAlias || isImportTypeWithQualifier || isDelayedMergeClass) {
typeType = getTypeReferenceType(node, valueType.symbol);
}
}
@ -48351,8 +48382,8 @@ var ts;
function removeOptionalTypeMarker(type) {
return strictNullChecks ? filterType(type, isNotOptionalTypeMarker) : type;
}
function propagateOptionalTypeMarker(type, wasOptional) {
return wasOptional ? addOptionalTypeMarker(type) : type;
function propagateOptionalTypeMarker(type, node, wasOptional) {
return wasOptional ? ts.isOutermostOptionalChain(node) ? getOptionalType(type) : addOptionalTypeMarker(type) : type;
}
function getOptionalExpressionType(exprType, expression) {
return ts.isExpressionOfOptionalChainRoot(expression) ? getNonNullableType(exprType) :
@ -53979,7 +54010,7 @@ var ts;
function checkPropertyAccessChain(node) {
var leftType = checkExpression(node.expression);
var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), nonOptionalType !== leftType);
return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType);
}
function checkQualifiedName(node) {
return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right);
@ -54371,7 +54402,7 @@ var ts;
function checkElementAccessChain(node) {
var exprType = checkExpression(node.expression);
var nonOptionalType = getOptionalExpressionType(exprType, node.expression);
return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), nonOptionalType !== exprType);
return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType);
}
function checkElementAccessExpression(node, exprType) {
var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
@ -54460,7 +54491,7 @@ var ts;
// interface B extends A { (x: 'foo'): string }
// const b: B;
// b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void]
function reorderCandidates(signatures, result, isOptionalCall) {
function reorderCandidates(signatures, result, callChainFlags) {
var lastParent;
var lastSymbol;
var cutoffIndex = 0;
@ -54501,7 +54532,7 @@ var ts;
else {
spliceIndex = index;
}
result.splice(spliceIndex, 0, isOptionalCall ? getOptionalCallSignature(signature) : signature);
result.splice(spliceIndex, 0, callChainFlags ? getOptionalCallSignature(signature, callChainFlags) : signature);
}
}
function isSpreadArgument(arg) {
@ -55091,7 +55122,7 @@ var ts;
}
return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
}
function resolveCall(node, signatures, candidatesOutArray, checkMode, isOptionalCall, fallbackError) {
function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) {
var isTaggedTemplate = node.kind === 197 /* TaggedTemplateExpression */;
var isDecorator = node.kind === 156 /* Decorator */;
var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
@ -55106,7 +55137,7 @@ var ts;
}
var candidates = candidatesOutArray || [];
// reorderCandidates fills up the candidates array directly
reorderCandidates(signatures, candidates, isOptionalCall);
reorderCandidates(signatures, candidates, callChainFlags);
if (!candidates.length) {
if (reportErrors) {
diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures));
@ -55464,20 +55495,22 @@ var ts;
var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
if (baseTypeNode) {
var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode);
return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, /*isOptional*/ false);
return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* None */);
}
}
return resolveUntypedCall(node);
}
var isOptional;
var callChainFlags;
var funcType = checkExpression(node.expression);
if (ts.isCallChain(node)) {
var nonOptionalType = getOptionalExpressionType(funcType, node.expression);
isOptional = nonOptionalType !== funcType;
callChainFlags = nonOptionalType === funcType ? 0 /* None */ :
ts.isOutermostOptionalChain(node) ? 8 /* IsOuterCallChain */ :
4 /* IsInnerCallChain */;
funcType = nonOptionalType;
}
else {
isOptional = false;
callChainFlags = 0 /* None */;
}
funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError);
if (funcType === silentNeverType) {
@ -55545,7 +55578,7 @@ var ts;
error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
return resolveErrorCall(node);
}
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, isOptional);
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
}
function isGenericFunctionReturningFunction(signature) {
return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
@ -55608,7 +55641,7 @@ var ts;
error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class);
return resolveErrorCall(node);
}
return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, /*isOptional*/ false);
return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* None */);
}
// If expressionType's apparent type is an object type with no construct signatures but
// one or more call signatures, the expression is processed as a function call. A compile-time
@ -55616,7 +55649,7 @@ var ts;
// operation is Any. It is an error to have a Void this type.
var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */);
if (callSignatures.length) {
var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false);
var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */);
if (!noImplicitAny) {
if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
@ -55793,7 +55826,7 @@ var ts;
invocationError(node.tag, apparentType, 0 /* Call */);
return resolveErrorCall(node);
}
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false);
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */);
}
/**
* Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression.
@ -55846,7 +55879,7 @@ var ts;
invocationErrorRecovery(apparentType, 0 /* Call */, diag);
return resolveErrorCall(node);
}
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false, headMessage);
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage);
}
function createSignatureForJSXIntrinsic(node, result) {
var namespace = getJsxNamespaceAt(node);
@ -55884,7 +55917,7 @@ var ts;
error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName));
return resolveErrorCall(node);
}
return resolveCall(node, signatures, candidatesOutArray, checkMode, /*isOptional*/ false);
return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */);
}
/**
* Sometimes, we have a decorator that could accept zero arguments,
@ -58144,6 +58177,18 @@ var ts;
}
}
}
function getReturnTypeOfSingleNonGenericCallSignature(funcType) {
var signature = getSingleCallSignature(funcType);
if (signature && !signature.typeParameters) {
return getReturnTypeOfSignature(signature);
}
}
function getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) {
var funcType = checkExpression(expr.expression);
var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
var returnType = getReturnTypeOfSingleNonGenericCallSignature(funcType);
return returnType && propagateOptionalTypeMarker(returnType, expr, nonOptionalType !== funcType);
}
/**
* Returns the type of an expression. Unlike checkExpression, this function is simply concerned
* with computing the type and may not fully check all contained sub-expressions for errors.
@ -58155,21 +58200,10 @@ var ts;
// Optimize for the common case of a call to a function with a single non-generic call
// signature where we can just fetch the return type without checking the arguments.
if (ts.isCallExpression(expr) && expr.expression.kind !== 101 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) {
var isOptional = void 0;
var funcType = void 0;
if (ts.isCallChain(expr)) {
funcType = checkExpression(expr.expression);
var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
isOptional = funcType !== nonOptionalType;
funcType = checkNonNullType(nonOptionalType, expr.expression);
}
else {
isOptional = false;
funcType = checkNonNullExpression(expr.expression);
}
var signature = getSingleCallSignature(funcType);
if (signature && !signature.typeParameters) {
return propagateOptionalTypeMarker(getReturnTypeOfSignature(signature), isOptional);
var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
if (type) {
return type;
}
}
else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) {
@ -66024,10 +66058,6 @@ var ts;
return !!(s.flags & 2 /* HasLiteralTypes */);
}
ts.signatureHasLiteralTypes = signatureHasLiteralTypes;
function signatureIsOptionalCall(s) {
return !!(s.flags & 4 /* IsOptionalCall */);
}
ts.signatureIsOptionalCall = signatureIsOptionalCall;
})(ts || (ts = {}));
var ts;
(function (ts) {
@ -74019,12 +74049,12 @@ var ts;
for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) {
var parameter = parametersWithPropertyAssignments_1[_i];
if (ts.isIdentifier(parameter.name)) {
members.push(ts.aggregateTransformFlags(ts.createProperty(
members.push(ts.setOriginalNode(ts.aggregateTransformFlags(ts.createProperty(
/*decorators*/ undefined,
/*modifiers*/ undefined, parameter.name,
/*questionOrExclamationToken*/ undefined,
/*type*/ undefined,
/*initializer*/ undefined)));
/*initializer*/ undefined)), parameter));
}
}
}
@ -74839,6 +74869,9 @@ var ts;
return !ts.nodeIsMissing(node.body);
}
function visitPropertyDeclaration(node) {
if (node.flags & 8388608 /* Ambient */) {
return undefined;
}
var updated = ts.updateProperty(node,
/*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node),
/*questionOrExclamationToken*/ undefined,
@ -75223,7 +75256,12 @@ var ts;
*
* @param node The module declaration node.
*/
function shouldEmitModuleDeclaration(node) {
function shouldEmitModuleDeclaration(nodeIn) {
var node = ts.getParseTreeNode(nodeIn, ts.isModuleDeclaration);
if (!node) {
// If we can't find a parse tree node, assume the node is instantiated.
return true;
}
return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules);
}
/**
@ -75947,9 +75985,9 @@ var ts;
/**
* Transforms ECMAScript Class Syntax.
* TypeScript parameter property syntax is transformed in the TypeScript transformer.
* For now, this transforms public field declarations using TypeScript class semantics
* (where the declarations get elided and initializers are transformed as assignments in the constructor).
* Eventually, this transform will change to the ECMAScript semantics (with Object.defineProperty).
* For now, this transforms public field declarations using TypeScript class semantics,
* where declarations are elided and initializers are transformed as assignments in the constructor.
* When --useDefineForClassFields is on, this transforms to ECMAScript semantics, with Object.defineProperty.
*/
function transformClassFields(context) {
var hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment;
@ -76160,7 +76198,9 @@ var ts;
/*modifiers*/ undefined, parameters, body), constructor || node), constructor));
}
function transformConstructorBody(node, constructor, isDerivedClass) {
var properties = ts.getProperties(node, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields, /*isStatic*/ false);
var _a;
var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields;
var properties = ts.getProperties(node, /*requireInitializer*/ !useDefineForClassFields, /*isStatic*/ false);
// Only generate synthetic constructor when there are property initializers to move.
if (!constructor && !ts.some(properties)) {
return ts.visitFunctionBody(/*node*/ undefined, visitor, context);
@ -76189,19 +76229,16 @@ var ts;
// this.x = 1;
// }
//
if (constructor && constructor.body) {
var parameterPropertyDeclarationCount = 0;
for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) {
if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) {
parameterPropertyDeclarationCount++;
}
else {
break;
}
if ((_a = constructor) === null || _a === void 0 ? void 0 : _a.body) {
var afterParameterProperties = ts.findIndex(constructor.body.statements, function (s) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(s), constructor); }, indexOfFirstStatement);
if (afterParameterProperties === -1) {
afterParameterProperties = constructor.body.statements.length;
}
if (parameterPropertyDeclarationCount > 0) {
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, parameterPropertyDeclarationCount));
indexOfFirstStatement += parameterPropertyDeclarationCount;
if (afterParameterProperties > indexOfFirstStatement) {
if (!useDefineForClassFields) {
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, afterParameterProperties - indexOfFirstStatement));
}
indexOfFirstStatement = afterParameterProperties;
}
}
addPropertyStatements(statements, properties, ts.createThis());
@ -76262,7 +76299,9 @@ var ts;
var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression)
? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name))
: property.name;
var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression) : ts.createVoidZero();
var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression)
: ts.hasModifier(ts.getOriginalNode(property), 92 /* ParameterPropertyModifier */) && ts.isIdentifier(propertyName) ? propertyName
: ts.createVoidZero();
if (emitAssignment) {
var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName);
return ts.createAssignment(memberAccess, initializer);
@ -96890,7 +96929,7 @@ var ts;
var typeOfSubst = typeof subst;
if (typeOfSubst === "string") {
if (!ts.hasZeroOrOneAsteriskCharacter(subst)) {
createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key);
createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character, subst, key);
}
}
else {
@ -104887,10 +104926,11 @@ var ts;
}
var dependencyKeys = ["dependencies", "devDependencies", "optionalDependencies", "peerDependencies"];
var stringContent = host.readFile(fileName);
var content = stringContent && tryParseJson(stringContent);
if (!content) {
if (!stringContent)
return undefined;
}
var content = tryParseJson(stringContent);
if (!content)
return false;
var info = {};
for (var _i = 0, dependencyKeys_1 = dependencyKeys; _i < dependencyKeys_1.length; _i++) {
var key = dependencyKeys_1[_i];

View File

@ -83,7 +83,7 @@ var ts;
// If changing the text in this section, be sure to test `configureNightly` too.
ts.versionMajorMinor = "3.7";
/** The version of the TypeScript compiler release */
ts.version = ts.versionMajorMinor + ".2";
ts.version = ts.versionMajorMinor + ".3";
})(ts || (ts = {}));
(function (ts) {
/* @internal */
@ -3788,11 +3788,13 @@ var ts;
SignatureFlags[SignatureFlags["None"] = 0] = "None";
SignatureFlags[SignatureFlags["HasRestParameter"] = 1] = "HasRestParameter";
SignatureFlags[SignatureFlags["HasLiteralTypes"] = 2] = "HasLiteralTypes";
SignatureFlags[SignatureFlags["IsOptionalCall"] = 4] = "IsOptionalCall";
// We do not propagate `IsOptionalCall` to instantiated signatures, as that would result in us
SignatureFlags[SignatureFlags["IsInnerCallChain"] = 4] = "IsInnerCallChain";
SignatureFlags[SignatureFlags["IsOuterCallChain"] = 8] = "IsOuterCallChain";
// We do not propagate `IsInnerCallChain` to instantiated signatures, as that would result in us
// attempting to add `| undefined` on each recursive call to `getReturnTypeOfSignature` when
// instantiating the return type.
SignatureFlags[SignatureFlags["PropagatingFlags"] = 3] = "PropagatingFlags";
SignatureFlags[SignatureFlags["CallChainFlags"] = 12] = "CallChainFlags";
})(SignatureFlags = ts.SignatureFlags || (ts.SignatureFlags = {}));
var IndexKind;
(function (IndexKind) {
@ -7039,7 +7041,7 @@ var ts;
Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier: diag(5059, ts.DiagnosticCategory.Error, "Invalid_value_for_reactNamespace_0_is_not_a_valid_identifier_5059", "Invalid value for '--reactNamespace'. '{0}' is not a valid identifier."),
Option_paths_cannot_be_used_without_specifying_baseUrl_option: diag(5060, ts.DiagnosticCategory.Error, "Option_paths_cannot_be_used_without_specifying_baseUrl_option_5060", "Option 'paths' cannot be used without specifying '--baseUrl' option."),
Pattern_0_can_have_at_most_one_Asterisk_character: diag(5061, ts.DiagnosticCategory.Error, "Pattern_0_can_have_at_most_one_Asterisk_character_5061", "Pattern '{0}' can have at most one '*' character."),
Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character: diag(5062, ts.DiagnosticCategory.Error, "Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character_5062", "Substitution '{0}' in pattern '{1}' in can have at most one '*' character."),
Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character: diag(5062, ts.DiagnosticCategory.Error, "Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character_5062", "Substitution '{0}' in pattern '{1}' can have at most one '*' character."),
Substitutions_for_pattern_0_should_be_an_array: diag(5063, ts.DiagnosticCategory.Error, "Substitutions_for_pattern_0_should_be_an_array_5063", "Substitutions for pattern '{0}' should be an array."),
Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2: diag(5064, ts.DiagnosticCategory.Error, "Substitution_0_for_pattern_1_has_incorrect_type_expected_string_got_2_5064", "Substitution '{0}' for pattern '{1}' has incorrect type, expected 'string', got '{2}'."),
File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5065, ts.DiagnosticCategory.Error, "File_specification_cannot_contain_a_parent_directory_that_appears_after_a_recursive_directory_wildca_5065", "File specification cannot contain a parent directory ('..') that appears after a recursive directory wildcard ('**'): '{0}'."),
@ -15153,14 +15155,36 @@ var ts;
|| kind === 195 /* CallExpression */);
}
ts.isOptionalChain = isOptionalChain;
/* @internal */
function isOptionalChainRoot(node) {
return isOptionalChain(node) && !!node.questionDotToken;
}
ts.isOptionalChainRoot = isOptionalChainRoot;
/**
* Determines whether a node is the expression preceding an optional chain (i.e. `a` in `a?.b`).
*/
/* @internal */
function isExpressionOfOptionalChainRoot(node) {
return ts.isOptionalChainRoot(node.parent) && node.parent.expression === node;
return isOptionalChainRoot(node.parent) && node.parent.expression === node;
}
ts.isExpressionOfOptionalChainRoot = isExpressionOfOptionalChainRoot;
/**
* Determines whether a node is the outermost `OptionalChain` in an ECMAScript `OptionalExpression`:
*
* 1. For `a?.b.c`, the outermost chain is `a?.b.c` (`c` is the end of the chain starting at `a?.`)
* 2. For `(a?.b.c).d`, the outermost chain is `a?.b.c` (`c` is the end of the chain starting at `a?.` since parens end the chain)
* 3. For `a?.b.c?.d`, both `a?.b.c` and `a?.b.c?.d` are outermost (`c` is the end of the chain starting at `a?.`, and `d` is
* the end of the chain starting at `c?.`)
* 4. For `a?.(b?.c).d`, both `b?.c` and `a?.(b?.c)d` are outermost (`c` is the end of the chain starting at `b`, and `d` is
* the end of the chain starting at `a?.`)
*/
/* @internal */
function isOutermostOptionalChain(node) {
return !isOptionalChain(node.parent) // cases 1 and 2
|| isOptionalChainRoot(node.parent) // case 3
|| node !== node.parent.expression; // case 4
}
ts.isOutermostOptionalChain = isOutermostOptionalChain;
function isNullishCoalesce(node) {
return node.kind === 208 /* BinaryExpression */ && node.operatorToken.kind === 60 /* QuestionQuestionToken */;
}
@ -16435,11 +16459,6 @@ var ts;
return node.kind === 162 /* GetAccessor */;
}
ts.isGetAccessor = isGetAccessor;
/* @internal */
function isOptionalChainRoot(node) {
return ts.isOptionalChain(node) && !!node.questionDotToken;
}
ts.isOptionalChainRoot = isOptionalChainRoot;
/** True if has jsdoc nodes attached to it. */
/* @internal */
// TODO: GH#19856 Would like to return `node is Node & { jsDoc: JSDoc[] }` but it causes long compile times
@ -17340,6 +17359,8 @@ var ts;
var patterns = [];
for (var _i = 0, patternStrings_1 = patternStrings; _i < patternStrings_1.length; _i++) {
var patternString = patternStrings_1[_i];
if (!ts.hasZeroOrOneAsteriskCharacter(patternString))
continue;
var pattern = tryParsePattern(patternString);
if (pattern) {
patterns.push(pattern);
@ -29774,7 +29795,7 @@ var ts;
}
function bindCondition(node, trueTarget, falseTarget) {
doWithConditionalBranches(bind, node, trueTarget, falseTarget);
if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && isOutermostOptionalChain(node))) {
if (!node || !isLogicalExpression(node) && !(ts.isOptionalChain(node) && ts.isOutermostOptionalChain(node))) {
addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
}
@ -30246,12 +30267,9 @@ var ts;
addDeclarationToSymbol(host.symbol, host, 32 /* Class */);
}
}
function isOutermostOptionalChain(node) {
return !ts.isOptionalChain(node.parent) || ts.isOptionalChainRoot(node.parent) || node !== node.parent.expression;
}
function bindOptionalExpression(node, trueTarget, falseTarget) {
doWithConditionalBranches(bind, node, trueTarget, falseTarget);
if (!ts.isOptionalChain(node) || isOutermostOptionalChain(node)) {
if (!ts.isOptionalChain(node) || ts.isOutermostOptionalChain(node)) {
addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
}
@ -30289,7 +30307,7 @@ var ts;
currentFlow = finishFlowLabel(preChainLabel);
}
doWithConditionalBranches(bindOptionalChainRest, node, trueTarget, falseTarget);
if (isOutermostOptionalChain(node)) {
if (ts.isOutermostOptionalChain(node)) {
addAntecedent(trueTarget, createFlowCondition(32 /* TrueCondition */, currentFlow, node));
addAntecedent(falseTarget, createFlowCondition(64 /* FalseCondition */, currentFlow, node));
}
@ -31374,7 +31392,7 @@ var ts;
}
function bindObjectDefinePrototypeProperty(node) {
var namespaceSymbol = lookupSymbolForPropertyAccess(node.arguments[0].expression);
if (namespaceSymbol) {
if (namespaceSymbol && namespaceSymbol.valueDeclaration) {
// Ensure the namespace symbol becomes class-like
addDeclarationToSymbol(namespaceSymbol, namespaceSymbol.valueDeclaration, 32 /* Class */);
}
@ -32101,7 +32119,8 @@ var ts;
|| ts.hasModifier(node, 2270 /* TypeScriptModifier */)
|| node.typeParameters
|| node.type
|| !node.body) {
|| !node.body
|| node.questionToken) {
transformFlags |= 1 /* AssertTypeScript */;
}
// function declarations with object rest destructuring are ES2018 syntax
@ -32138,7 +32157,7 @@ var ts;
function computePropertyDeclaration(node, subtreeFlags) {
var transformFlags = subtreeFlags | 1048576 /* ContainsClassFields */;
// Decorators, TypeScript-specific modifiers, and type annotations are TypeScript syntax.
if (ts.some(node.decorators) || ts.hasModifier(node, 2270 /* TypeScriptModifier */) || node.type) {
if (ts.some(node.decorators) || ts.hasModifier(node, 2270 /* TypeScriptModifier */) || node.type || node.questionToken) {
transformFlags |= 1 /* AssertTypeScript */;
}
// Hoisted variables related to class properties should live within the TypeScript class wrapper.
@ -40668,13 +40687,21 @@ var ts;
result.mapper = undefined;
return result;
}
function getOptionalCallSignature(signature) {
return signatureIsOptionalCall(signature) ? signature :
(signature.optionalCallSignatureCache || (signature.optionalCallSignatureCache = createOptionalCallSignature(signature)));
function getOptionalCallSignature(signature, callChainFlags) {
if ((signature.flags & 12 /* CallChainFlags */) === callChainFlags) {
return signature;
}
if (!signature.optionalCallSignatureCache) {
signature.optionalCallSignatureCache = {};
}
var key = callChainFlags === 4 /* IsInnerCallChain */ ? "inner" : "outer";
return signature.optionalCallSignatureCache[key]
|| (signature.optionalCallSignatureCache[key] = createOptionalCallSignature(signature, callChainFlags));
}
function createOptionalCallSignature(signature) {
function createOptionalCallSignature(signature, callChainFlags) {
ts.Debug.assert(callChainFlags === 4 /* IsInnerCallChain */ || callChainFlags === 8 /* IsOuterCallChain */, "An optional call signature can either be for an inner call chain or an outer call chain, but not both.");
var result = cloneSignature(signature);
result.flags |= 4 /* IsOptionalCall */;
result.flags |= callChainFlags;
return result;
}
function getExpandedParameters(sig) {
@ -42186,9 +42213,12 @@ var ts;
signature.unionSignatures ? getUnionType(ts.map(signature.unionSignatures, getReturnTypeOfSignature), 2 /* Subtype */) :
getReturnTypeFromAnnotation(signature.declaration) ||
(ts.nodeIsMissing(signature.declaration.body) ? anyType : getReturnTypeFromBody(signature.declaration));
if (signatureIsOptionalCall(signature)) {
if (signature.flags & 4 /* IsInnerCallChain */) {
type = addOptionalTypeMarker(type);
}
else if (signature.flags & 8 /* IsOuterCallChain */) {
type = getOptionalType(type);
}
if (!popTypeResolution()) {
if (signature.declaration) {
var typeNode = ts.getEffectiveReturnTypeNode(signature.declaration);
@ -42661,7 +42691,8 @@ var ts;
isRequireAlias = ts.isCallExpression(expr) && ts.isRequireCall(expr, /*requireStringLiteralLikeArgument*/ true) && !!valueType.symbol;
}
var isDelayedMergeClass = symbol !== valueType.symbol && getMergedSymbol(symbol) === valueType.symbol;
if (isRequireAlias || node.kind === 187 /* ImportType */ || isDelayedMergeClass) {
var isImportTypeWithQualifier = node.kind === 187 /* ImportType */ && node.qualifier;
if (isRequireAlias || isImportTypeWithQualifier || isDelayedMergeClass) {
typeType = getTypeReferenceType(node, valueType.symbol);
}
}
@ -48201,8 +48232,8 @@ var ts;
function removeOptionalTypeMarker(type) {
return strictNullChecks ? filterType(type, isNotOptionalTypeMarker) : type;
}
function propagateOptionalTypeMarker(type, wasOptional) {
return wasOptional ? addOptionalTypeMarker(type) : type;
function propagateOptionalTypeMarker(type, node, wasOptional) {
return wasOptional ? ts.isOutermostOptionalChain(node) ? getOptionalType(type) : addOptionalTypeMarker(type) : type;
}
function getOptionalExpressionType(exprType, expression) {
return ts.isExpressionOfOptionalChainRoot(expression) ? getNonNullableType(exprType) :
@ -53829,7 +53860,7 @@ var ts;
function checkPropertyAccessChain(node) {
var leftType = checkExpression(node.expression);
var nonOptionalType = getOptionalExpressionType(leftType, node.expression);
return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), nonOptionalType !== leftType);
return propagateOptionalTypeMarker(checkPropertyAccessExpressionOrQualifiedName(node, node.expression, checkNonNullType(nonOptionalType, node.expression), node.name), node, nonOptionalType !== leftType);
}
function checkQualifiedName(node) {
return checkPropertyAccessExpressionOrQualifiedName(node, node.left, checkNonNullExpression(node.left), node.right);
@ -54221,7 +54252,7 @@ var ts;
function checkElementAccessChain(node) {
var exprType = checkExpression(node.expression);
var nonOptionalType = getOptionalExpressionType(exprType, node.expression);
return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), nonOptionalType !== exprType);
return propagateOptionalTypeMarker(checkElementAccessExpression(node, checkNonNullType(nonOptionalType, node.expression)), node, nonOptionalType !== exprType);
}
function checkElementAccessExpression(node, exprType) {
var objectType = ts.getAssignmentTargetKind(node) !== 0 /* None */ || isMethodAccessForCall(node) ? getWidenedType(exprType) : exprType;
@ -54310,7 +54341,7 @@ var ts;
// interface B extends A { (x: 'foo'): string }
// const b: B;
// b('foo') // <- here overloads should be processed as [(x:'foo'): string, (x: string): void]
function reorderCandidates(signatures, result, isOptionalCall) {
function reorderCandidates(signatures, result, callChainFlags) {
var lastParent;
var lastSymbol;
var cutoffIndex = 0;
@ -54351,7 +54382,7 @@ var ts;
else {
spliceIndex = index;
}
result.splice(spliceIndex, 0, isOptionalCall ? getOptionalCallSignature(signature) : signature);
result.splice(spliceIndex, 0, callChainFlags ? getOptionalCallSignature(signature, callChainFlags) : signature);
}
}
function isSpreadArgument(arg) {
@ -54941,7 +54972,7 @@ var ts;
}
return ts.createDiagnosticForNodeArray(ts.getSourceFileOfNode(node), typeArguments, ts.Diagnostics.Expected_0_type_arguments_but_got_1, belowArgCount === -Infinity ? aboveArgCount : belowArgCount, argCount);
}
function resolveCall(node, signatures, candidatesOutArray, checkMode, isOptionalCall, fallbackError) {
function resolveCall(node, signatures, candidatesOutArray, checkMode, callChainFlags, fallbackError) {
var isTaggedTemplate = node.kind === 197 /* TaggedTemplateExpression */;
var isDecorator = node.kind === 156 /* Decorator */;
var isJsxOpeningOrSelfClosingElement = ts.isJsxOpeningLikeElement(node);
@ -54956,7 +54987,7 @@ var ts;
}
var candidates = candidatesOutArray || [];
// reorderCandidates fills up the candidates array directly
reorderCandidates(signatures, candidates, isOptionalCall);
reorderCandidates(signatures, candidates, callChainFlags);
if (!candidates.length) {
if (reportErrors) {
diagnostics.add(getDiagnosticForCallNode(node, ts.Diagnostics.Call_target_does_not_contain_any_signatures));
@ -55314,20 +55345,22 @@ var ts;
var baseTypeNode = ts.getEffectiveBaseTypeNode(ts.getContainingClass(node));
if (baseTypeNode) {
var baseConstructors = getInstantiatedConstructorsForTypeArguments(superType, baseTypeNode.typeArguments, baseTypeNode);
return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, /*isOptional*/ false);
return resolveCall(node, baseConstructors, candidatesOutArray, checkMode, 0 /* None */);
}
}
return resolveUntypedCall(node);
}
var isOptional;
var callChainFlags;
var funcType = checkExpression(node.expression);
if (ts.isCallChain(node)) {
var nonOptionalType = getOptionalExpressionType(funcType, node.expression);
isOptional = nonOptionalType !== funcType;
callChainFlags = nonOptionalType === funcType ? 0 /* None */ :
ts.isOutermostOptionalChain(node) ? 8 /* IsOuterCallChain */ :
4 /* IsInnerCallChain */;
funcType = nonOptionalType;
}
else {
isOptional = false;
callChainFlags = 0 /* None */;
}
funcType = checkNonNullTypeWithReporter(funcType, node.expression, reportCannotInvokePossiblyNullOrUndefinedError);
if (funcType === silentNeverType) {
@ -55395,7 +55428,7 @@ var ts;
error(node, ts.Diagnostics.Value_of_type_0_is_not_callable_Did_you_mean_to_include_new, typeToString(funcType));
return resolveErrorCall(node);
}
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, isOptional);
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, callChainFlags);
}
function isGenericFunctionReturningFunction(signature) {
return !!(signature.typeParameters && isFunctionType(getReturnTypeOfSignature(signature)));
@ -55458,7 +55491,7 @@ var ts;
error(node, ts.Diagnostics.Cannot_create_an_instance_of_an_abstract_class);
return resolveErrorCall(node);
}
return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, /*isOptional*/ false);
return resolveCall(node, constructSignatures, candidatesOutArray, checkMode, 0 /* None */);
}
// If expressionType's apparent type is an object type with no construct signatures but
// one or more call signatures, the expression is processed as a function call. A compile-time
@ -55466,7 +55499,7 @@ var ts;
// operation is Any. It is an error to have a Void this type.
var callSignatures = getSignaturesOfType(expressionType, 0 /* Call */);
if (callSignatures.length) {
var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false);
var signature = resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */);
if (!noImplicitAny) {
if (signature.declaration && !isJSConstructor(signature.declaration) && getReturnTypeOfSignature(signature) !== voidType) {
error(node, ts.Diagnostics.Only_a_void_function_can_be_called_with_the_new_keyword);
@ -55643,7 +55676,7 @@ var ts;
invocationError(node.tag, apparentType, 0 /* Call */);
return resolveErrorCall(node);
}
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false);
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */);
}
/**
* Gets the localized diagnostic head message to use for errors when resolving a decorator as a call expression.
@ -55696,7 +55729,7 @@ var ts;
invocationErrorRecovery(apparentType, 0 /* Call */, diag);
return resolveErrorCall(node);
}
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, /*isOptional*/ false, headMessage);
return resolveCall(node, callSignatures, candidatesOutArray, checkMode, 0 /* None */, headMessage);
}
function createSignatureForJSXIntrinsic(node, result) {
var namespace = getJsxNamespaceAt(node);
@ -55734,7 +55767,7 @@ var ts;
error(node.tagName, ts.Diagnostics.JSX_element_type_0_does_not_have_any_construct_or_call_signatures, ts.getTextOfNode(node.tagName));
return resolveErrorCall(node);
}
return resolveCall(node, signatures, candidatesOutArray, checkMode, /*isOptional*/ false);
return resolveCall(node, signatures, candidatesOutArray, checkMode, 0 /* None */);
}
/**
* Sometimes, we have a decorator that could accept zero arguments,
@ -57994,6 +58027,18 @@ var ts;
}
}
}
function getReturnTypeOfSingleNonGenericCallSignature(funcType) {
var signature = getSingleCallSignature(funcType);
if (signature && !signature.typeParameters) {
return getReturnTypeOfSignature(signature);
}
}
function getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) {
var funcType = checkExpression(expr.expression);
var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
var returnType = getReturnTypeOfSingleNonGenericCallSignature(funcType);
return returnType && propagateOptionalTypeMarker(returnType, expr, nonOptionalType !== funcType);
}
/**
* Returns the type of an expression. Unlike checkExpression, this function is simply concerned
* with computing the type and may not fully check all contained sub-expressions for errors.
@ -58005,21 +58050,10 @@ var ts;
// Optimize for the common case of a call to a function with a single non-generic call
// signature where we can just fetch the return type without checking the arguments.
if (ts.isCallExpression(expr) && expr.expression.kind !== 101 /* SuperKeyword */ && !ts.isRequireCall(expr, /*checkArgumentIsStringLiteralLike*/ true) && !isSymbolOrSymbolForCall(expr)) {
var isOptional = void 0;
var funcType = void 0;
if (ts.isCallChain(expr)) {
funcType = checkExpression(expr.expression);
var nonOptionalType = getOptionalExpressionType(funcType, expr.expression);
isOptional = funcType !== nonOptionalType;
funcType = checkNonNullType(nonOptionalType, expr.expression);
}
else {
isOptional = false;
funcType = checkNonNullExpression(expr.expression);
}
var signature = getSingleCallSignature(funcType);
if (signature && !signature.typeParameters) {
return propagateOptionalTypeMarker(getReturnTypeOfSignature(signature), isOptional);
var type = ts.isCallChain(expr) ? getReturnTypeOfSingleNonGenericSignatureOfCallChain(expr) :
getReturnTypeOfSingleNonGenericCallSignature(checkNonNullExpression(expr.expression));
if (type) {
return type;
}
}
else if (ts.isAssertionExpression(expr) && !ts.isConstTypeReference(expr.type)) {
@ -65874,10 +65908,6 @@ var ts;
return !!(s.flags & 2 /* HasLiteralTypes */);
}
ts.signatureHasLiteralTypes = signatureHasLiteralTypes;
function signatureIsOptionalCall(s) {
return !!(s.flags & 4 /* IsOptionalCall */);
}
ts.signatureIsOptionalCall = signatureIsOptionalCall;
})(ts || (ts = {}));
var ts;
(function (ts) {
@ -73869,12 +73899,12 @@ var ts;
for (var _i = 0, parametersWithPropertyAssignments_1 = parametersWithPropertyAssignments; _i < parametersWithPropertyAssignments_1.length; _i++) {
var parameter = parametersWithPropertyAssignments_1[_i];
if (ts.isIdentifier(parameter.name)) {
members.push(ts.aggregateTransformFlags(ts.createProperty(
members.push(ts.setOriginalNode(ts.aggregateTransformFlags(ts.createProperty(
/*decorators*/ undefined,
/*modifiers*/ undefined, parameter.name,
/*questionOrExclamationToken*/ undefined,
/*type*/ undefined,
/*initializer*/ undefined)));
/*initializer*/ undefined)), parameter));
}
}
}
@ -74689,6 +74719,9 @@ var ts;
return !ts.nodeIsMissing(node.body);
}
function visitPropertyDeclaration(node) {
if (node.flags & 8388608 /* Ambient */) {
return undefined;
}
var updated = ts.updateProperty(node,
/*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), visitPropertyNameOfClassElement(node),
/*questionOrExclamationToken*/ undefined,
@ -75073,7 +75106,12 @@ var ts;
*
* @param node The module declaration node.
*/
function shouldEmitModuleDeclaration(node) {
function shouldEmitModuleDeclaration(nodeIn) {
var node = ts.getParseTreeNode(nodeIn, ts.isModuleDeclaration);
if (!node) {
// If we can't find a parse tree node, assume the node is instantiated.
return true;
}
return ts.isInstantiatedModule(node, !!compilerOptions.preserveConstEnums || !!compilerOptions.isolatedModules);
}
/**
@ -75797,9 +75835,9 @@ var ts;
/**
* Transforms ECMAScript Class Syntax.
* TypeScript parameter property syntax is transformed in the TypeScript transformer.
* For now, this transforms public field declarations using TypeScript class semantics
* (where the declarations get elided and initializers are transformed as assignments in the constructor).
* Eventually, this transform will change to the ECMAScript semantics (with Object.defineProperty).
* For now, this transforms public field declarations using TypeScript class semantics,
* where declarations are elided and initializers are transformed as assignments in the constructor.
* When --useDefineForClassFields is on, this transforms to ECMAScript semantics, with Object.defineProperty.
*/
function transformClassFields(context) {
var hoistVariableDeclaration = context.hoistVariableDeclaration, endLexicalEnvironment = context.endLexicalEnvironment, resumeLexicalEnvironment = context.resumeLexicalEnvironment;
@ -76010,7 +76048,9 @@ var ts;
/*modifiers*/ undefined, parameters, body), constructor || node), constructor));
}
function transformConstructorBody(node, constructor, isDerivedClass) {
var properties = ts.getProperties(node, /*requireInitializer*/ !context.getCompilerOptions().useDefineForClassFields, /*isStatic*/ false);
var _a;
var useDefineForClassFields = context.getCompilerOptions().useDefineForClassFields;
var properties = ts.getProperties(node, /*requireInitializer*/ !useDefineForClassFields, /*isStatic*/ false);
// Only generate synthetic constructor when there are property initializers to move.
if (!constructor && !ts.some(properties)) {
return ts.visitFunctionBody(/*node*/ undefined, visitor, context);
@ -76039,19 +76079,16 @@ var ts;
// this.x = 1;
// }
//
if (constructor && constructor.body) {
var parameterPropertyDeclarationCount = 0;
for (var i = indexOfFirstStatement; i < constructor.body.statements.length; i++) {
if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(constructor.body.statements[i]), constructor)) {
parameterPropertyDeclarationCount++;
}
else {
break;
}
if ((_a = constructor) === null || _a === void 0 ? void 0 : _a.body) {
var afterParameterProperties = ts.findIndex(constructor.body.statements, function (s) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(s), constructor); }, indexOfFirstStatement);
if (afterParameterProperties === -1) {
afterParameterProperties = constructor.body.statements.length;
}
if (parameterPropertyDeclarationCount > 0) {
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, parameterPropertyDeclarationCount));
indexOfFirstStatement += parameterPropertyDeclarationCount;
if (afterParameterProperties > indexOfFirstStatement) {
if (!useDefineForClassFields) {
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatement, afterParameterProperties - indexOfFirstStatement));
}
indexOfFirstStatement = afterParameterProperties;
}
}
addPropertyStatements(statements, properties, ts.createThis());
@ -76112,7 +76149,9 @@ var ts;
var propertyName = ts.isComputedPropertyName(property.name) && !ts.isSimpleInlineableExpression(property.name.expression)
? ts.updateComputedPropertyName(property.name, ts.getGeneratedNameForNode(property.name))
: property.name;
var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression) : ts.createVoidZero();
var initializer = property.initializer || emitAssignment ? ts.visitNode(property.initializer, visitor, ts.isExpression)
: ts.hasModifier(ts.getOriginalNode(property), 92 /* ParameterPropertyModifier */) && ts.isIdentifier(propertyName) ? propertyName
: ts.createVoidZero();
if (emitAssignment) {
var memberAccess = ts.createMemberAccessForPropertyName(receiver, propertyName, /*location*/ propertyName);
return ts.createAssignment(memberAccess, initializer);
@ -96740,7 +96779,7 @@ var ts;
var typeOfSubst = typeof subst;
if (typeOfSubst === "string") {
if (!ts.hasZeroOrOneAsteriskCharacter(subst)) {
createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_in_can_have_at_most_one_Asterisk_character, subst, key);
createDiagnosticForOptionPathKeyValue(key, i, ts.Diagnostics.Substitution_0_in_pattern_1_can_have_at_most_one_Asterisk_character, subst, key);
}
}
else {