Skip to content

Commit

Permalink
Use inclusive flag, as originally done, but include almost everything
Browse files Browse the repository at this point in the history
  • Loading branch information
weswigham committed Jun 6, 2016
1 parent 9761c3b commit 26b1ab4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7664,7 +7664,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);
Expand Down
9 changes: 3 additions & 6 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2219,12 +2219,9 @@ namespace ts {
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' types are types where narrowing actually narrows.
// This *should* be every type other than null, undefined, void, and never
Narrowable = Any | StructuredType | TypeParameter | StringLike | NumberLike | Boolean | ESSymbol,
/* @internal */
RequiresWidening = ContainsWideningType | ContainsObjectLiteral,
/* @internal */
Expand Down

0 comments on commit 26b1ab4

Please sign in to comment.