@@ -66,8 +66,8 @@ module ts {
6666 var numberType = createIntrinsicType(TypeFlags.Number, "number");
6767 var booleanType = createIntrinsicType(TypeFlags.Boolean, "boolean");
6868 var voidType = createIntrinsicType(TypeFlags.Void, "void");
69- var undefinedType = createIntrinsicType(TypeFlags.Undefined | TypeFlags.ContainsUndefined , "undefined");
70- var nullType = createIntrinsicType(TypeFlags.Null | TypeFlags.ContainsUndefined , "null");
69+ var undefinedType = createIntrinsicType(TypeFlags.Undefined | TypeFlags.ContainsUndefinedOrNull , "undefined");
70+ var nullType = createIntrinsicType(TypeFlags.Null | TypeFlags.ContainsUndefinedOrNull , "null");
7171 var unknownType = createIntrinsicType(TypeFlags.Any, "unknown");
7272 var resolvingType = createIntrinsicType(TypeFlags.Any, "__resolving__");
7373
@@ -2807,6 +2807,9 @@ module ts {
28072807 }
28082808 }
28092809
2810+ // This function is used to propagate widening flags when creating new object types references and union types.
2811+ // It is only necessary to do so if a constituent type might be the undefined type, the null type, or the type
2812+ // of an object literal (since those types have widening related information we need to track).
28102813 function getWideningFlagsOfTypes(types: Type[]): TypeFlags {
28112814 var result: TypeFlags = 0;
28122815 for (var i = 0; i < types.length; i++) {
@@ -4111,7 +4114,7 @@ module ts {
41114114 var symbol = <TransientSymbol>createSymbol(p.flags | SymbolFlags.Transient, p.name);
41124115 symbol.declarations = p.declarations;
41134116 symbol.parent = p.parent;
4114- symbol.type = getWidenedType(getTypeOfSymbol(p)) ;
4117+ symbol.type = widenedType ;
41154118 symbol.target = p;
41164119 if (p.valueDeclaration) symbol.valueDeclaration = p.valueDeclaration;
41174120 p = symbol;
@@ -4160,7 +4163,7 @@ module ts {
41604163 var errorReported = false;
41614164 forEach(getPropertiesOfObjectType(type), p => {
41624165 var t = getTypeOfSymbol(p);
4163- if (t.flags & TypeFlags.ContainsUndefined ) {
4166+ if (t.flags & TypeFlags.ContainsUndefinedOrNull ) {
41644167 if (!reportWideningErrorsInType(t)) {
41654168 error(p.valueDeclaration, Diagnostics.Object_literal_s_property_0_implicitly_has_an_1_type, p.name, typeToString(getWidenedType(t)));
41664169 }
@@ -4204,7 +4207,7 @@ module ts {
42044207 }
42054208
42064209 function reportErrorsFromWidening(declaration: Declaration, type: Type) {
4207- if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & TypeFlags.ContainsUndefined ) {
4210+ if (produceDiagnostics && compilerOptions.noImplicitAny && type.flags & TypeFlags.ContainsUndefinedOrNull ) {
42084211 // Report implicit any error within type if possible, otherwise report error on declaration
42094212 if (!reportWideningErrorsInType(type)) {
42104213 reportImplicitAnyError(declaration, type);
@@ -5464,7 +5467,7 @@ module ts {
54645467 var stringIndexType = getIndexType(IndexKind.String);
54655468 var numberIndexType = getIndexType(IndexKind.Number);
54665469 var result = createAnonymousType(node.symbol, properties, emptyArray, emptyArray, stringIndexType, numberIndexType);
5467- result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsLiteral | (typeFlags & TypeFlags.ContainsUndefined );
5470+ result.flags |= TypeFlags.ObjectLiteral | TypeFlags.ContainsObjectLiteral | (typeFlags & TypeFlags.ContainsUndefinedOrNull );
54685471 return result;
54695472
54705473 function getIndexType(kind: IndexKind) {
0 commit comments