Revert "Merge pull request #7235 from weswigham/narrow-all-types"

This reverts commit ef0f6c8fe4, reversing
changes made to 9f087cb62a.
This commit is contained in:
Nathan Shively-Sanders
2016-06-02 12:57:24 -07:00
parent 7e00d7e595
commit fc3e040c51
14 changed files with 2 additions and 409 deletions

View File

@@ -7662,7 +7662,7 @@ namespace ts {
function getFlowTypeOfReference(reference: Node, declaredType: Type, assumeInitialized: boolean, includeOuterFunctions: boolean) {
let key: string;
if (!reference.flowNode || assumeInitialized && (declaredType.flags & TypeFlags.NotNarrowable)) {
if (!reference.flowNode || assumeInitialized && !(declaredType.flags & TypeFlags.Narrowable)) {
return declaredType;
}
const initialType = assumeInitialized ? declaredType : addNullableKind(declaredType, TypeFlags.Undefined);

View File

@@ -2218,13 +2218,7 @@ namespace ts {
ObjectType = Class | Interface | Reference | Tuple | Anonymous,
UnionOrIntersection = Union | Intersection,
StructuredType = ObjectType | Union | Intersection,
// 'NotNarrowable' types are types where narrowing reverts to the original type, rather than actually narrow.
// This is never really correct - you can _always_ narrow to an intersection with that type, _but_ we keep
// Void as the only non-narrowable type, since it's a non-value type construct (representing a lack of a value)
// and, generally speaking, narrowing `void` should fail in some way, as it is nonsensical. (`void` narrowing
// to `void & T`, in a structural sense, is just narrowing to T, which we wouldn't allow under normal rules)
NotNarrowable = Void,
Narrowable = Any | ObjectType | Union | TypeParameter,
/* @internal */
RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral,
/* @internal */