@@ -3959,7 +3959,7 @@ namespace ts {
39593959 }
39603960 if (type.flags & TypeFlags.TypeVariable) {
39613961 const constraint = getBaseConstraintOfType(<TypeVariable>type);
3962- return isValidBaseType(constraint) && isMixinConstructorType(constraint);
3962+ return constraint && isValidBaseType(constraint) && isMixinConstructorType(constraint);
39633963 }
39643964 return false;
39653965 }
@@ -5904,15 +5904,52 @@ namespace ts {
59045904 return getTypeFromNonGenericTypeReference(node, symbol);
59055905 }
59065906
5907+ function getPrimitiveTypeFromJSDocTypeReference(node: JSDocTypeReference): Type {
5908+ if (isIdentifier(node.name)) {
5909+ switch (node.name.text) {
5910+ case "String":
5911+ return stringType;
5912+ case "Number":
5913+ return numberType;
5914+ case "Boolean":
5915+ return booleanType;
5916+ case "Void":
5917+ return voidType;
5918+ case "Undefined":
5919+ return undefinedType;
5920+ case "Null":
5921+ return nullType;
5922+ case "Object":
5923+ return anyType;
5924+ case "Function":
5925+ return anyFunctionType;
5926+ case "Array":
5927+ case "array":
5928+ return !node.typeArguments || !node.typeArguments.length ? createArrayType(anyType) : undefined;
5929+ case "Promise":
5930+ case "promise":
5931+ return !node.typeArguments || !node.typeArguments.length ? createPromiseType(anyType) : undefined;
5932+ }
5933+ }
5934+ }
5935+
5936+ function getTypeFromJSDocNullableTypeNode(node: JSDocNullableType) {
5937+ const type = getTypeFromTypeNode(node.type);
5938+ return strictNullChecks ? getUnionType([type, nullType]) : type;
5939+ }
5940+
59075941 function getTypeFromTypeReference(node: TypeReferenceNode | ExpressionWithTypeArguments | JSDocTypeReference): Type {
59085942 const links = getNodeLinks(node);
59095943 if (!links.resolvedType) {
59105944 let symbol: Symbol;
59115945 let type: Type;
59125946 if (node.kind === SyntaxKind.JSDocTypeReference) {
5913- const typeReferenceName = getTypeReferenceName(node);
5914- symbol = resolveTypeReferenceName(typeReferenceName);
5915- type = getTypeReferenceType(node, symbol);
5947+ type = getPrimitiveTypeFromJSDocTypeReference(<JSDocTypeReference>node);
5948+ if (!type) {
5949+ const typeReferenceName = getTypeReferenceName(node);
5950+ symbol = resolveTypeReferenceName(typeReferenceName);
5951+ type = getTypeReferenceType(node, symbol);
5952+ }
59165953 }
59175954 else {
59185955 // We only support expressions that are simple qualified names. For other expressions this produces undefined.
@@ -6824,12 +6861,6 @@ namespace ts {
68246861 return neverType;
68256862 case SyntaxKind.ObjectKeyword:
68266863 return nonPrimitiveType;
6827- case SyntaxKind.JSDocNullKeyword:
6828- return nullType;
6829- case SyntaxKind.JSDocUndefinedKeyword:
6830- return undefinedType;
6831- case SyntaxKind.JSDocNeverKeyword:
6832- return neverType;
68336864 case SyntaxKind.ThisType:
68346865 case SyntaxKind.ThisKeyword:
68356866 return getTypeFromThisTypeNode(node);
@@ -6856,8 +6887,9 @@ namespace ts {
68566887 return getTypeFromUnionTypeNode(<UnionTypeNode>node);
68576888 case SyntaxKind.IntersectionType:
68586889 return getTypeFromIntersectionTypeNode(<IntersectionTypeNode>node);
6859- case SyntaxKind.ParenthesizedType:
68606890 case SyntaxKind.JSDocNullableType:
6891+ return getTypeFromJSDocNullableTypeNode(<JSDocNullableType>node);
6892+ case SyntaxKind.ParenthesizedType:
68616893 case SyntaxKind.JSDocNonNullableType:
68626894 case SyntaxKind.JSDocConstructorType:
68636895 case SyntaxKind.JSDocThisType:
@@ -12814,11 +12846,6 @@ namespace ts {
1281412846 // Props is of type 'any' or unknown
1281512847 return attributesType;
1281612848 }
12817- else if (attributesType.flags & TypeFlags.Union) {
12818- // Props cannot be a union type
12819- error(openingLikeElement.tagName, Diagnostics.JSX_element_attributes_type_0_may_not_be_a_union_type, typeToString(attributesType));
12820- return anyType;
12821- }
1282212849 else {
1282312850 // Normal case -- add in IntrinsicClassElements<T> and IntrinsicElements
1282412851 let apparentAttributesType = attributesType;
@@ -15962,12 +15989,16 @@ namespace ts {
1596215989 checkAssignmentOperator(rightType);
1596315990 return getRegularTypeOfObjectLiteral(rightType);
1596415991 case SyntaxKind.CommaToken:
15965- if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left)) {
15992+ if (!compilerOptions.allowUnreachableCode && isSideEffectFree(left) && !isEvalNode(right) ) {
1596615993 error(left, Diagnostics.Left_side_of_comma_operator_is_unused_and_has_no_side_effects);
1596715994 }
1596815995 return rightType;
1596915996 }
1597015997
15998+ function isEvalNode(node: Expression) {
15999+ return node.kind === SyntaxKind.Identifier && (node as Identifier).text === "eval";
16000+ }
16001+
1597116002 // Return true if there was no error, false if there was an error.
1597216003 function checkForDisallowedESSymbolOperand(operator: SyntaxKind): boolean {
1597316004 const offendingSymbolOperand =
@@ -20958,7 +20989,9 @@ namespace ts {
2095820989 return getSymbolOfNode(entityName.parent);
2095920990 }
2096020991
20961- if (isInJavaScriptFile(entityName) && entityName.parent.kind === SyntaxKind.PropertyAccessExpression) {
20992+ if (isInJavaScriptFile(entityName) &&
20993+ entityName.parent.kind === SyntaxKind.PropertyAccessExpression &&
20994+ entityName.parent === (entityName.parent.parent as BinaryExpression).left) {
2096220995 // Check if this is a special property assignment
2096320996 const specialPropertyAssignmentSymbol = getSpecialPropertyAssignmentSymbolFromEntityName(entityName);
2096420997 if (specialPropertyAssignmentSymbol) {
0 commit comments