From 73d4aaef46eea2323587edb650678c2fe70aa170 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Tue, 26 Apr 2016 04:17:40 -0400 Subject: [PATCH] Defaultable -> NotNarrowable to align with use --- src/compiler/checker.ts | 4 ++-- src/compiler/types.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ca0d61c8106..2e2f59f6c15 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -7555,7 +7555,7 @@ namespace ts { } function getNarrowedTypeOfReference(type: Type, reference: Node) { - if (type.flags & TypeFlags.Defaultable || !isNarrowableReference(reference)) { + if (type.flags & TypeFlags.NotNarrowable || !isNarrowableReference(reference)) { return type; } const leftmostNode = getLeftmostIdentifierOrThis(reference); @@ -7975,7 +7975,7 @@ namespace ts { const defaultsToDeclaredType = !strictNullChecks || type.flags & TypeFlags.Any || !declaration || declaration.kind === SyntaxKind.Parameter || isInAmbientContext(declaration) || getContainingFunctionOrModule(declaration) !== getContainingFunctionOrModule(node); - if (defaultsToDeclaredType && type.flags & TypeFlags.Defaultable) { + if (defaultsToDeclaredType && type.flags & TypeFlags.NotNarrowable) { return type; } const flowType = getFlowTypeOfReference(node, type, defaultsToDeclaredType ? type : undefinedType); diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 5f181bc982e..47f9d1b752e 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -2176,12 +2176,12 @@ namespace ts { UnionOrIntersection = Union | Intersection, StructuredType = ObjectType | Union | Intersection, - // 'Defaultable' types are types where narrowing reverts to the original type, rather than actually narrow. + // '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 defaultable 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) - Defaultable = Void, + NotNarrowable = Void, /* @internal */ RequiresWidening = ContainsUndefinedOrNull | ContainsObjectLiteral, /* @internal */