diff --git a/lib/tsc.js b/lib/tsc.js index 880ed7d7d763e..361e447f84231 100644 --- a/lib/tsc.js +++ b/lib/tsc.js @@ -67,7 +67,7 @@ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cook var ts; (function (ts) { ts.versionMajorMinor = "3.9"; - ts.version = "3.9.1-rc"; + ts.version = "3.9.2"; function tryGetNativeMap() { return typeof Map !== "undefined" && "entries" in Map.prototype ? Map : undefined; } @@ -27221,18 +27221,17 @@ var ts; if (ts.isIdentifier(node.left.expression) && container === file && isExportsOrModuleExportsOrAlias(file, node.left.expression)) { bindExportsPropertyAssignment(node); } + else if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 | 67108864, "__computed"); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), false, false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } else { - if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 | 67108864, "__computed"); - var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), false, false); - addLateBoundAssignmentDeclarationToSymbol(node, sym); - } - else { - bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); - } + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticNameExpression)); } } function bindStaticPropertyAssignment(node) { + ts.Debug.assert(!ts.isIdentifier(node)); node.expression.parent = node; bindPropertyAssignment(node.expression, node, false, false); } @@ -29808,7 +29807,9 @@ var ts; lastLocation === location.name && ts.isBindingPattern(lastLocation))) { var root = ts.getRootDeclaration(location); if (root.kind === 156) { - associatedDeclarationForContainingInitializerOrBindingName = location; + if (!associatedDeclarationForContainingInitializerOrBindingName) { + associatedDeclarationForContainingInitializerOrBindingName = location; + } } } break; @@ -32762,12 +32763,15 @@ var ts; function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) { return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); }); } + function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) { + return !(ts.getObjectFlags(type) & 4) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); + } function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) { if (type !== errorType && enclosingDeclaration) { var declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration); if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); - if (getTypeFromTypeNode(existing) === type) { + if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { var result_4 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); if (result_4) { return result_4; @@ -32787,7 +32791,7 @@ var ts; function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (type !== errorType && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); - if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type) { + if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { return result; @@ -32826,6 +32830,14 @@ var ts; if (ts.isJSDocVariadicType(node)) { return ts.createArrayTypeNode(ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } + if (ts.isJSDocTypeLiteral(node)) { + return ts.createTypeLiteralNode(ts.map(node.jsDocPropertyTags, function (t) { + var name = ts.isIdentifier(t.name) ? t.name : t.name.right; + var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); + var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; + return ts.createPropertySignature(undefined, name, t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.createToken(57) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.createKeywordTypeNode(125), undefined); + })); + } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { return ts.setOriginalNode(ts.createKeywordTypeNode(125), node); } @@ -32841,6 +32853,9 @@ var ts; return ts.createFunctionTypeNode(ts.visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), ts.map(node.parameters, function (p, i) { return ts.createParameter(undefined, undefined, getEffectiveDotDotDotForParameter(p), p.name || getEffectiveDotDotDotForParameter(p) ? "args" : "arg" + i, p.questionToken, ts.visitNode(p.type, visitExistingNodeTreeSymbols), undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } } + if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968, true))) { + return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); + } if (ts.isLiteralImportTypeNode(node)) { return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); } @@ -40940,7 +40955,7 @@ var ts; } } if (result && !inPropertyCheck && (target.flags & 2097152 && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152); }))) { + isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 && getApparentType(source).flags & 3670016 && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152); }))) { inPropertyCheck = true; result &= recursiveTypeRelatedTo(source, target, reportErrors, 4); inPropertyCheck = false; @@ -44661,7 +44676,7 @@ var ts; var predicate = getTypePredicateOfSignature(signature); if (predicate && (predicate.kind === 2 || predicate.kind === 3)) { var flowType = getTypeAtFlowNode(flow.antecedent); - var type = getTypeFromFlowType(flowType); + var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType)); var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, true) : predicate.kind === 3 && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; diff --git a/lib/tsserver.js b/lib/tsserver.js index 4a2ca4e28e94a..2b6f035cc95ba 100644 --- a/lib/tsserver.js +++ b/lib/tsserver.js @@ -94,7 +94,7 @@ var ts; // If changing the text in this section, be sure to test `configurePrerelease` too. ts.versionMajorMinor = "3.9"; /** The version of the TypeScript compiler release */ - ts.version = "3.9.1-rc"; + ts.version = "3.9.2"; /** * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). */ @@ -16562,9 +16562,11 @@ var ts; secondAccessor = member; } if (member.kind === 163 /* GetAccessor */ && !getAccessor) { + // eslint-disable-next-line getAccessor = member; } if (member.kind === 164 /* SetAccessor */ && !setAccessor) { + // eslint-disable-next-line setAccessor = member; } } @@ -33219,15 +33221,13 @@ var ts; // util.property = function ... bindExportsPropertyAssignment(node); } + else if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } else { - if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); - var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); - addLateBoundAssignmentDeclarationToSymbol(node, sym); - } - else { - bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); - } + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticNameExpression)); } } /** @@ -33235,6 +33235,7 @@ var ts; * Also works for expression statements preceded by JSDoc, like / ** @type number * / x.y; */ function bindStaticPropertyAssignment(node) { + ts.Debug.assert(!ts.isIdentifier(node)); node.expression.parent = node; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } @@ -36386,7 +36387,9 @@ var ts; lastLocation === location.name && ts.isBindingPattern(lastLocation))) { var root = ts.getRootDeclaration(location); if (root.kind === 156 /* Parameter */) { - associatedDeclarationForContainingInitializerOrBindingName = location; + if (!associatedDeclarationForContainingInitializerOrBindingName) { + associatedDeclarationForContainingInitializerOrBindingName = location; + } } } break; @@ -39688,6 +39691,9 @@ var ts; function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) { return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); }); } + function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) { + return !(ts.getObjectFlags(type) & 4 /* Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); + } /** * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` @@ -39698,7 +39704,7 @@ var ts; if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); - if (getTypeFromTypeNode(existing) === type) { + if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { var result_4 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); if (result_4) { return result_4; @@ -39718,7 +39724,7 @@ var ts; function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (type !== errorType && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); - if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type) { + if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { return result; @@ -39758,6 +39764,16 @@ var ts; if (ts.isJSDocVariadicType(node)) { return ts.createArrayTypeNode(ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } + if (ts.isJSDocTypeLiteral(node)) { + return ts.createTypeLiteralNode(ts.map(node.jsDocPropertyTags, function (t) { + var name = ts.isIdentifier(t.name) ? t.name : t.name.right; + var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); + var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; + return ts.createPropertySignature( + /*modifiers*/ undefined, name, t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.createKeywordTypeNode(125 /* AnyKeyword */), + /*initializer*/ undefined); + })); + } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { return ts.setOriginalNode(ts.createKeywordTypeNode(125 /* AnyKeyword */), node); } @@ -39785,6 +39801,9 @@ var ts; /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } } + if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */, /*ignoreErrors*/ true))) { + return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); + } if (ts.isLiteralImportTypeNode(node)) { return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); } @@ -49124,7 +49143,7 @@ var ts; // We suppress recursive intersection property checks because they can generate lots of work when relating // recursive intersections that are structurally similar but not exactly identical. See #37854. if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { + isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { inPropertyCheck = true; result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */); inPropertyCheck = false; @@ -53366,7 +53385,7 @@ var ts; var predicate = getTypePredicateOfSignature(signature); if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { var flowType = getTypeAtFlowNode(flow.antecedent); - var type = getTypeFromFlowType(flowType); + var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType)); var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; @@ -60091,6 +60110,7 @@ var ts; error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } + // eslint-disable-next-line if (expr.kind === 194 /* PropertyAccessExpression */ && ts.isPrivateIdentifier(expr.name)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_private_identifier); } @@ -136694,6 +136714,7 @@ var ts; case 253 /* ImportEqualsDeclaration */: case 258 /* ImportSpecifier */: case 255 /* ImportClause */: + case 256 /* NamespaceImport */: return true; case 242 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); diff --git a/lib/tsserverlibrary.js b/lib/tsserverlibrary.js index c3162c1458bfd..60e8447a1cd8d 100644 --- a/lib/tsserverlibrary.js +++ b/lib/tsserverlibrary.js @@ -244,7 +244,7 @@ var ts; // If changing the text in this section, be sure to test `configurePrerelease` too. ts.versionMajorMinor = "3.9"; /** The version of the TypeScript compiler release */ - ts.version = "3.9.1-rc"; + ts.version = "3.9.2"; /** * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). */ @@ -16712,9 +16712,11 @@ var ts; secondAccessor = member; } if (member.kind === 163 /* GetAccessor */ && !getAccessor) { + // eslint-disable-next-line getAccessor = member; } if (member.kind === 164 /* SetAccessor */ && !setAccessor) { + // eslint-disable-next-line setAccessor = member; } } @@ -33369,15 +33371,13 @@ var ts; // util.property = function ... bindExportsPropertyAssignment(node); } + else if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } else { - if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); - var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); - addLateBoundAssignmentDeclarationToSymbol(node, sym); - } - else { - bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); - } + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticNameExpression)); } } /** @@ -33385,6 +33385,7 @@ var ts; * Also works for expression statements preceded by JSDoc, like / ** @type number * / x.y; */ function bindStaticPropertyAssignment(node) { + ts.Debug.assert(!ts.isIdentifier(node)); node.expression.parent = node; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } @@ -36536,7 +36537,9 @@ var ts; lastLocation === location.name && ts.isBindingPattern(lastLocation))) { var root = ts.getRootDeclaration(location); if (root.kind === 156 /* Parameter */) { - associatedDeclarationForContainingInitializerOrBindingName = location; + if (!associatedDeclarationForContainingInitializerOrBindingName) { + associatedDeclarationForContainingInitializerOrBindingName = location; + } } } break; @@ -39838,6 +39841,9 @@ var ts; function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) { return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); }); } + function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) { + return !(ts.getObjectFlags(type) & 4 /* Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); + } /** * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` @@ -39848,7 +39854,7 @@ var ts; if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); - if (getTypeFromTypeNode(existing) === type) { + if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { var result_4 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); if (result_4) { return result_4; @@ -39868,7 +39874,7 @@ var ts; function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (type !== errorType && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); - if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type) { + if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { return result; @@ -39908,6 +39914,16 @@ var ts; if (ts.isJSDocVariadicType(node)) { return ts.createArrayTypeNode(ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } + if (ts.isJSDocTypeLiteral(node)) { + return ts.createTypeLiteralNode(ts.map(node.jsDocPropertyTags, function (t) { + var name = ts.isIdentifier(t.name) ? t.name : t.name.right; + var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); + var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; + return ts.createPropertySignature( + /*modifiers*/ undefined, name, t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.createKeywordTypeNode(125 /* AnyKeyword */), + /*initializer*/ undefined); + })); + } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { return ts.setOriginalNode(ts.createKeywordTypeNode(125 /* AnyKeyword */), node); } @@ -39935,6 +39951,9 @@ var ts; /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } } + if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */, /*ignoreErrors*/ true))) { + return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); + } if (ts.isLiteralImportTypeNode(node)) { return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); } @@ -49274,7 +49293,7 @@ var ts; // We suppress recursive intersection property checks because they can generate lots of work when relating // recursive intersections that are structurally similar but not exactly identical. See #37854. if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { + isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { inPropertyCheck = true; result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */); inPropertyCheck = false; @@ -53516,7 +53535,7 @@ var ts; var predicate = getTypePredicateOfSignature(signature); if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { var flowType = getTypeAtFlowNode(flow.antecedent); - var type = getTypeFromFlowType(flowType); + var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType)); var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; @@ -60241,6 +60260,7 @@ var ts; error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } + // eslint-disable-next-line if (expr.kind === 194 /* PropertyAccessExpression */ && ts.isPrivateIdentifier(expr.name)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_private_identifier); } @@ -137217,6 +137237,7 @@ var ts; case 253 /* ImportEqualsDeclaration */: case 258 /* ImportSpecifier */: case 255 /* ImportClause */: + case 256 /* NamespaceImport */: return true; case 242 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); diff --git a/lib/typescript.js b/lib/typescript.js index b24e253d048c6..90202c1c5b1e7 100644 --- a/lib/typescript.js +++ b/lib/typescript.js @@ -244,7 +244,7 @@ var ts; // If changing the text in this section, be sure to test `configurePrerelease` too. ts.versionMajorMinor = "3.9"; /** The version of the TypeScript compiler release */ - ts.version = "3.9.1-rc"; + ts.version = "3.9.2"; /** * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). */ @@ -16712,9 +16712,11 @@ var ts; secondAccessor = member; } if (member.kind === 163 /* GetAccessor */ && !getAccessor) { + // eslint-disable-next-line getAccessor = member; } if (member.kind === 164 /* SetAccessor */ && !setAccessor) { + // eslint-disable-next-line setAccessor = member; } } @@ -33369,15 +33371,13 @@ var ts; // util.property = function ... bindExportsPropertyAssignment(node); } + else if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } else { - if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); - var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); - addLateBoundAssignmentDeclarationToSymbol(node, sym); - } - else { - bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); - } + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticNameExpression)); } } /** @@ -33385,6 +33385,7 @@ var ts; * Also works for expression statements preceded by JSDoc, like / ** @type number * / x.y; */ function bindStaticPropertyAssignment(node) { + ts.Debug.assert(!ts.isIdentifier(node)); node.expression.parent = node; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } @@ -36536,7 +36537,9 @@ var ts; lastLocation === location.name && ts.isBindingPattern(lastLocation))) { var root = ts.getRootDeclaration(location); if (root.kind === 156 /* Parameter */) { - associatedDeclarationForContainingInitializerOrBindingName = location; + if (!associatedDeclarationForContainingInitializerOrBindingName) { + associatedDeclarationForContainingInitializerOrBindingName = location; + } } } break; @@ -39838,6 +39841,9 @@ var ts; function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) { return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); }); } + function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) { + return !(ts.getObjectFlags(type) & 4 /* Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); + } /** * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` @@ -39848,7 +39854,7 @@ var ts; if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); - if (getTypeFromTypeNode(existing) === type) { + if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { var result_4 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); if (result_4) { return result_4; @@ -39868,7 +39874,7 @@ var ts; function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (type !== errorType && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); - if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type) { + if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { return result; @@ -39908,6 +39914,16 @@ var ts; if (ts.isJSDocVariadicType(node)) { return ts.createArrayTypeNode(ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } + if (ts.isJSDocTypeLiteral(node)) { + return ts.createTypeLiteralNode(ts.map(node.jsDocPropertyTags, function (t) { + var name = ts.isIdentifier(t.name) ? t.name : t.name.right; + var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); + var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; + return ts.createPropertySignature( + /*modifiers*/ undefined, name, t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.createKeywordTypeNode(125 /* AnyKeyword */), + /*initializer*/ undefined); + })); + } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { return ts.setOriginalNode(ts.createKeywordTypeNode(125 /* AnyKeyword */), node); } @@ -39935,6 +39951,9 @@ var ts; /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } } + if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */, /*ignoreErrors*/ true))) { + return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); + } if (ts.isLiteralImportTypeNode(node)) { return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); } @@ -49274,7 +49293,7 @@ var ts; // We suppress recursive intersection property checks because they can generate lots of work when relating // recursive intersections that are structurally similar but not exactly identical. See #37854. if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { + isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { inPropertyCheck = true; result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */); inPropertyCheck = false; @@ -53516,7 +53535,7 @@ var ts; var predicate = getTypePredicateOfSignature(signature); if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { var flowType = getTypeAtFlowNode(flow.antecedent); - var type = getTypeFromFlowType(flowType); + var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType)); var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; @@ -60241,6 +60260,7 @@ var ts; error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } + // eslint-disable-next-line if (expr.kind === 194 /* PropertyAccessExpression */ && ts.isPrivateIdentifier(expr.name)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_private_identifier); } @@ -137217,6 +137237,7 @@ var ts; case 253 /* ImportEqualsDeclaration */: case 258 /* ImportSpecifier */: case 255 /* ImportClause */: + case 256 /* NamespaceImport */: return true; case 242 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); diff --git a/lib/typescriptServices.js b/lib/typescriptServices.js index 7656a80b4f2c3..d78fb9eda99d6 100644 --- a/lib/typescriptServices.js +++ b/lib/typescriptServices.js @@ -244,7 +244,7 @@ var ts; // If changing the text in this section, be sure to test `configurePrerelease` too. ts.versionMajorMinor = "3.9"; /** The version of the TypeScript compiler release */ - ts.version = "3.9.1-rc"; + ts.version = "3.9.2"; /** * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). */ @@ -16712,9 +16712,11 @@ var ts; secondAccessor = member; } if (member.kind === 163 /* GetAccessor */ && !getAccessor) { + // eslint-disable-next-line getAccessor = member; } if (member.kind === 164 /* SetAccessor */ && !setAccessor) { + // eslint-disable-next-line setAccessor = member; } } @@ -33369,15 +33371,13 @@ var ts; // util.property = function ... bindExportsPropertyAssignment(node); } + else if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } else { - if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); - var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); - addLateBoundAssignmentDeclarationToSymbol(node, sym); - } - else { - bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); - } + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticNameExpression)); } } /** @@ -33385,6 +33385,7 @@ var ts; * Also works for expression statements preceded by JSDoc, like / ** @type number * / x.y; */ function bindStaticPropertyAssignment(node) { + ts.Debug.assert(!ts.isIdentifier(node)); node.expression.parent = node; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } @@ -36536,7 +36537,9 @@ var ts; lastLocation === location.name && ts.isBindingPattern(lastLocation))) { var root = ts.getRootDeclaration(location); if (root.kind === 156 /* Parameter */) { - associatedDeclarationForContainingInitializerOrBindingName = location; + if (!associatedDeclarationForContainingInitializerOrBindingName) { + associatedDeclarationForContainingInitializerOrBindingName = location; + } } } break; @@ -39838,6 +39841,9 @@ var ts; function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) { return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); }); } + function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) { + return !(ts.getObjectFlags(type) & 4 /* Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); + } /** * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` @@ -39848,7 +39854,7 @@ var ts; if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); - if (getTypeFromTypeNode(existing) === type) { + if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { var result_4 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); if (result_4) { return result_4; @@ -39868,7 +39874,7 @@ var ts; function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (type !== errorType && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); - if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type) { + if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { return result; @@ -39908,6 +39914,16 @@ var ts; if (ts.isJSDocVariadicType(node)) { return ts.createArrayTypeNode(ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } + if (ts.isJSDocTypeLiteral(node)) { + return ts.createTypeLiteralNode(ts.map(node.jsDocPropertyTags, function (t) { + var name = ts.isIdentifier(t.name) ? t.name : t.name.right; + var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); + var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; + return ts.createPropertySignature( + /*modifiers*/ undefined, name, t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.createKeywordTypeNode(125 /* AnyKeyword */), + /*initializer*/ undefined); + })); + } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { return ts.setOriginalNode(ts.createKeywordTypeNode(125 /* AnyKeyword */), node); } @@ -39935,6 +39951,9 @@ var ts; /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } } + if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */, /*ignoreErrors*/ true))) { + return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); + } if (ts.isLiteralImportTypeNode(node)) { return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); } @@ -49274,7 +49293,7 @@ var ts; // We suppress recursive intersection property checks because they can generate lots of work when relating // recursive intersections that are structurally similar but not exactly identical. See #37854. if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { + isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { inPropertyCheck = true; result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */); inPropertyCheck = false; @@ -53516,7 +53535,7 @@ var ts; var predicate = getTypePredicateOfSignature(signature); if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { var flowType = getTypeAtFlowNode(flow.antecedent); - var type = getTypeFromFlowType(flowType); + var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType)); var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; @@ -60241,6 +60260,7 @@ var ts; error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } + // eslint-disable-next-line if (expr.kind === 194 /* PropertyAccessExpression */ && ts.isPrivateIdentifier(expr.name)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_private_identifier); } @@ -137217,6 +137237,7 @@ var ts; case 253 /* ImportEqualsDeclaration */: case 258 /* ImportSpecifier */: case 255 /* ImportClause */: + case 256 /* NamespaceImport */: return true; case 242 /* VariableDeclaration */: return isVariableDeclarationInImport(decl); diff --git a/lib/typingsInstaller.js b/lib/typingsInstaller.js index 6c5a27d3bfb08..967aad4ef5b36 100644 --- a/lib/typingsInstaller.js +++ b/lib/typingsInstaller.js @@ -83,7 +83,7 @@ var ts; // If changing the text in this section, be sure to test `configurePrerelease` too. ts.versionMajorMinor = "3.9"; /** The version of the TypeScript compiler release */ - ts.version = "3.9.1-rc"; + ts.version = "3.9.2"; /** * Returns the native Map implementation if it is available and compatible (i.e. supports iteration). */ @@ -16551,9 +16551,11 @@ var ts; secondAccessor = member; } if (member.kind === 163 /* GetAccessor */ && !getAccessor) { + // eslint-disable-next-line getAccessor = member; } if (member.kind === 164 /* SetAccessor */ && !setAccessor) { + // eslint-disable-next-line setAccessor = member; } } @@ -33208,15 +33210,13 @@ var ts; // util.property = function ... bindExportsPropertyAssignment(node); } + else if (ts.hasDynamicName(node)) { + bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); + var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); + addLateBoundAssignmentDeclarationToSymbol(node, sym); + } else { - if (ts.hasDynamicName(node)) { - bindAnonymousDeclaration(node, 4 /* Property */ | 67108864 /* Assignment */, "__computed" /* Computed */); - var sym = bindPotentiallyMissingNamespaces(parentSymbol, node.left.expression, isTopLevelNamespaceAssignment(node.left), /*isPrototype*/ false, /*containerIsClass*/ false); - addLateBoundAssignmentDeclarationToSymbol(node, sym); - } - else { - bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticAccessExpression)); - } + bindStaticPropertyAssignment(ts.cast(node.left, ts.isBindableStaticNameExpression)); } } /** @@ -33224,6 +33224,7 @@ var ts; * Also works for expression statements preceded by JSDoc, like / ** @type number * / x.y; */ function bindStaticPropertyAssignment(node) { + ts.Debug.assert(!ts.isIdentifier(node)); node.expression.parent = node; bindPropertyAssignment(node.expression, node, /*isPrototypeProperty*/ false, /*containerIsClass*/ false); } @@ -36375,7 +36376,9 @@ var ts; lastLocation === location.name && ts.isBindingPattern(lastLocation))) { var root = ts.getRootDeclaration(location); if (root.kind === 156 /* Parameter */) { - associatedDeclarationForContainingInitializerOrBindingName = location; + if (!associatedDeclarationForContainingInitializerOrBindingName) { + associatedDeclarationForContainingInitializerOrBindingName = location; + } } } break; @@ -39677,6 +39680,9 @@ var ts; function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) { return symbol.declarations && ts.find(symbol.declarations, function (s) { return !!ts.getEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!ts.findAncestor(s, function (n) { return n === enclosingDeclaration; })); }); } + function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) { + return !(ts.getObjectFlags(type) & 4 /* Reference */) || !ts.isTypeReferenceNode(existing) || ts.length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters); + } /** * Unlike `typeToTypeNodeHelper`, this handles setting up the `AllowUniqueESSymbolType` flag * so a `unique symbol` is returned when appropriate for the input symbol, rather than `typeof sym` @@ -39687,7 +39693,7 @@ var ts; if (declWithExistingAnnotation && !ts.isFunctionLikeDeclaration(declWithExistingAnnotation)) { // try to reuse the existing annotation var existing = ts.getEffectiveTypeAnnotationNode(declWithExistingAnnotation); - if (getTypeFromTypeNode(existing) === type) { + if (getTypeFromTypeNode(existing) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) { var result_4 = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled); if (result_4) { return result_4; @@ -39707,7 +39713,7 @@ var ts; function serializeReturnTypeForSignature(context, type, signature, includePrivateSymbol, bundled) { if (type !== errorType && context.enclosingDeclaration) { var annotation = signature.declaration && ts.getEffectiveReturnTypeNode(signature.declaration); - if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type) { + if (!!ts.findAncestor(annotation, function (n) { return n === context.enclosingDeclaration; }) && annotation && instantiateType(getTypeFromTypeNode(annotation), signature.mapper) === type && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(annotation, type)) { var result = serializeExistingTypeNode(context, annotation, includePrivateSymbol, bundled); if (result) { return result; @@ -39747,6 +39753,16 @@ var ts; if (ts.isJSDocVariadicType(node)) { return ts.createArrayTypeNode(ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } + if (ts.isJSDocTypeLiteral(node)) { + return ts.createTypeLiteralNode(ts.map(node.jsDocPropertyTags, function (t) { + var name = ts.isIdentifier(t.name) ? t.name : t.name.right; + var typeViaParent = getTypeOfPropertyOfType(getTypeFromTypeNode(node), name.escapedText); + var overrideTypeNode = typeViaParent && t.typeExpression && getTypeFromTypeNode(t.typeExpression.type) !== typeViaParent ? typeToTypeNodeHelper(typeViaParent, context) : undefined; + return ts.createPropertySignature( + /*modifiers*/ undefined, name, t.typeExpression && ts.isJSDocOptionalType(t.typeExpression.type) ? ts.createToken(57 /* QuestionToken */) : undefined, overrideTypeNode || (t.typeExpression && ts.visitNode(t.typeExpression.type, visitExistingNodeTreeSymbols)) || ts.createKeywordTypeNode(125 /* AnyKeyword */), + /*initializer*/ undefined); + })); + } if (ts.isTypeReferenceNode(node) && ts.isIdentifier(node.typeName) && node.typeName.escapedText === "") { return ts.setOriginalNode(ts.createKeywordTypeNode(125 /* AnyKeyword */), node); } @@ -39774,6 +39790,9 @@ var ts; /*initializer*/ undefined); }), ts.visitNode(node.type, visitExistingNodeTreeSymbols)); } } + if (ts.isTypeReferenceNode(node) && ts.isInJSDoc(node) && (getIntendedTypeFromJSDocTypeReference(node) || unknownSymbol === resolveTypeReferenceName(getTypeReferenceName(node), 788968 /* Type */, /*ignoreErrors*/ true))) { + return ts.setOriginalNode(typeToTypeNodeHelper(getTypeFromTypeNode(node), context), node); + } if (ts.isLiteralImportTypeNode(node)) { return ts.updateImportTypeNode(node, ts.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), node.qualifier, ts.visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, ts.isTypeNode), node.isTypeOf); } @@ -49113,7 +49132,7 @@ var ts; // We suppress recursive intersection property checks because they can generate lots of work when relating // recursive intersections that are structurally similar but not exactly identical. See #37854. if (result && !inPropertyCheck && (target.flags & 2097152 /* Intersection */ && (isPerformingExcessPropertyChecks || isPerformingCommonPropertyChecks) || - isNonGenericObjectType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { + isNonGenericObjectType(target) && !isArrayType(target) && !isTupleType(target) && source.flags & 2097152 /* Intersection */ && getApparentType(source).flags & 3670016 /* StructuredType */ && !ts.some(source.types, function (t) { return !!(ts.getObjectFlags(t) & 2097152 /* NonInferrableType */); }))) { inPropertyCheck = true; result &= recursiveTypeRelatedTo(source, target, reportErrors, 4 /* PropertyCheck */); inPropertyCheck = false; @@ -53355,7 +53374,7 @@ var ts; var predicate = getTypePredicateOfSignature(signature); if (predicate && (predicate.kind === 2 /* AssertsThis */ || predicate.kind === 3 /* AssertsIdentifier */)) { var flowType = getTypeAtFlowNode(flow.antecedent); - var type = getTypeFromFlowType(flowType); + var type = finalizeEvolvingArrayType(getTypeFromFlowType(flowType)); var narrowedType = predicate.type ? narrowTypeByTypePredicate(type, predicate, flow.node, /*assumeTrue*/ true) : predicate.kind === 3 /* AssertsIdentifier */ && predicate.parameterIndex >= 0 && predicate.parameterIndex < flow.node.arguments.length ? narrowTypeByAssertion(type, flow.node.arguments[predicate.parameterIndex]) : type; @@ -60080,6 +60099,7 @@ var ts; error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_must_be_a_property_reference); return booleanType; } + // eslint-disable-next-line if (expr.kind === 194 /* PropertyAccessExpression */ && ts.isPrivateIdentifier(expr.name)) { error(expr, ts.Diagnostics.The_operand_of_a_delete_operator_cannot_be_a_private_identifier); } diff --git a/package.json b/package.json index 176bc3029a7d0..79cdcc92fab90 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "typescript", "author": "Microsoft Corp.", "homepage": "https://www.typescriptlang.org/", - "version": "3.9.1-rc", + "version": "3.9.2", "license": "Apache-2.0", "description": "TypeScript is a language for application scale JavaScript development", "keywords": [ diff --git a/src/compiler/corePublic.ts b/src/compiler/corePublic.ts index b1eb2adb2437e..4cce68313f542 100644 --- a/src/compiler/corePublic.ts +++ b/src/compiler/corePublic.ts @@ -3,7 +3,7 @@ namespace ts { // If changing the text in this section, be sure to test `configurePrerelease` too. export const versionMajorMinor = "3.9"; /** The version of the TypeScript compiler release */ - export const version = "3.9.1-rc" as string; + export const version = "3.9.2" as string; /** * Type of objects whose values are all of the same type.