Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Doesnt need to be undefineable at all
  • Loading branch information
weswigham committed Aug 27, 2018
commit 37e5f6de44e0b2f4e716a57847af5399c1606779
8 changes: 4 additions & 4 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15140,14 +15140,14 @@ namespace ts {
return type.flags & TypeFlags.InstantiableNonPrimitive && maybeTypeOfKind(getBaseConstraintOfType(type) || emptyObjectType, TypeFlags.Nullable);
}

function getConstraintForLocation(type: Type, node: Node | undefined): Type;
function getConstraintForLocation(type: Type | undefined, node: Node | undefined): Type | undefined;
function getConstraintForLocation(type: Type, node: Node | undefined): Type | undefined {
function getConstraintForLocation(type: Type, node: Node): Type;
function getConstraintForLocation(type: Type | undefined, node: Node): Type | undefined;
function getConstraintForLocation(type: Type, node: Node): Type | undefined {
// When a node is the left hand expression of a property access, element access, or call expression,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be node: Node | undefined, i.e. not an optional parameter? It seems pointless to make it optional since the function will never do anything if you don't pass an argument for it.

Also, when might node be undefined? Not clear to me what those changes are accomplishing.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't need to be undefine'd-able at all. I probably factored the place where it may have been undefinable so it wouldn't be while I was working on it - fix't.

// and the type of the node includes type variables with constraints that are nullable, we fetch the
// apparent type of the node *before* performing control flow analysis such that narrowings apply to
// the constraint type.
if (node && type && isConstraintPosition(node) && forEachType(type, typeHasNullableConstraint)) {
if (type && isConstraintPosition(node) && forEachType(type, typeHasNullableConstraint)) {
return mapType(getWidenedType(type), getBaseConstraintOrType);
}
return type;
Expand Down