(type, context)
| 67837 | return getWidenedTypeWithContext(type, /*context*/ undefined); |
| 67838 | } |
| 67839 | function getWidenedTypeWithContext(type, context) { |
| 67840 | if (ts.getObjectFlags(type) & 196608 /* ObjectFlags.RequiresWidening */) { |
| 67841 | if (context === undefined && type.widened) { |
| 67842 | return type.widened; |
| 67843 | } |
| 67844 | var result = void 0; |
| 67845 | if (type.flags & (1 /* TypeFlags.Any */ | 98304 /* TypeFlags.Nullable */)) { |
| 67846 | result = anyType; |
| 67847 | } |
| 67848 | else if (isObjectLiteralType(type)) { |
| 67849 | result = getWidenedTypeOfObjectLiteral(type, context); |
| 67850 | } |
| 67851 | else if (type.flags & 1048576 /* TypeFlags.Union */) { |
| 67852 | var unionContext_1 = context || createWideningContext(/*parent*/ undefined, /*propertyName*/ undefined, type.types); |
| 67853 | var widenedTypes = ts.sameMap(type.types, function (t) { return t.flags & 98304 /* TypeFlags.Nullable */ ? t : getWidenedTypeWithContext(t, unionContext_1); }); |
| 67854 | // Widening an empty object literal transitions from a highly restrictive type to |
| 67855 | // a highly inclusive one. For that reason we perform subtype reduction here if the |
| 67856 | // union includes empty object types (e.g. reducing {} | string to just {}). |
| 67857 | result = getUnionType(widenedTypes, ts.some(widenedTypes, isEmptyObjectType) ? 2 /* UnionReduction.Subtype */ : 1 /* UnionReduction.Literal */); |
| 67858 | } |
| 67859 | else if (type.flags & 2097152 /* TypeFlags.Intersection */) { |
| 67860 | result = getIntersectionType(ts.sameMap(type.types, getWidenedType)); |
| 67861 | } |
| 67862 | else if (isArrayOrTupleType(type)) { |
| 67863 | result = createTypeReference(type.target, ts.sameMap(getTypeArguments(type), getWidenedType)); |
| 67864 | } |
| 67865 | if (result && context === undefined) { |
| 67866 | type.widened = result; |
| 67867 | } |
| 67868 | return result || type; |
| 67869 | } |
| 67870 | return type; |
| 67871 | } |
| 67872 | /** |
| 67873 | * Reports implicit any errors that occur as a result of widening 'null' and 'undefined' |
| 67874 | * to 'any'. A call to reportWideningErrorsInType is normally accompanied by a call to |
no test coverage detected