Skip to content

Commit

Permalink
2016-08-10 [ci skip] Version: 1.201608100007.1+3f1ec7ad4bda8fb546beec…
Browse files Browse the repository at this point in the history
…e999f5f20ef6fe9f24
  • Loading branch information
basarat committed Aug 10, 2016
1 parent e436a86 commit b73cd1c
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 12 deletions.
12 changes: 9 additions & 3 deletions bin/ntypescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -21731,6 +21731,12 @@ var ts;
function isTypeAssignableTo(source, target) {
return isTypeRelatedTo(source, target, assignableRelation);
}
// A type S is considered to be an instance of a type T if S and T are the same type or if S is a
// subtype of T but not structurally identical to T. This specifically means that two distinct but
// structurally identical types (such as two classes) are not considered instances of each other.
function isTypeInstanceOf(source, target) {
return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target);
}
/**
* This is *not* a bi-directional relationship.
* If one needs to check both directions for comparability, use a second call to this function or 'checkTypeComparableTo'.
Expand Down Expand Up @@ -24194,12 +24200,12 @@ var ts;
}
function getNarrowedType(type, candidate, assumeTrue) {
if (!assumeTrue) {
return filterType(type, function (t) { return !isTypeSubtypeOf(t, candidate); });
return filterType(type, function (t) { return !isTypeInstanceOf(t, candidate); });
}
// If the current type is a union type, remove all constituents that aren't assignable to
// If the current type is a union type, remove all constituents that couldn't be instances of
// the candidate type. If one or more constituents remain, return a union of those.
if (type.flags & 524288 /* Union */) {
var assignableConstituents = ts.filter(type.types, function (t) { return isTypeAssignableTo(t, candidate); });
var assignableConstituents = ts.filter(type.types, function (t) { return isTypeInstanceOf(t, candidate); });
if (assignableConstituents.length) {
return getUnionType(assignableConstituents);
}
Expand Down
12 changes: 9 additions & 3 deletions bin/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -21731,6 +21731,12 @@ var ts;
function isTypeAssignableTo(source, target) {
return isTypeRelatedTo(source, target, assignableRelation);
}
// A type S is considered to be an instance of a type T if S and T are the same type or if S is a
// subtype of T but not structurally identical to T. This specifically means that two distinct but
// structurally identical types (such as two classes) are not considered instances of each other.
function isTypeInstanceOf(source, target) {
return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target);
}
/**
* This is *not* a bi-directional relationship.
* If one needs to check both directions for comparability, use a second call to this function or 'checkTypeComparableTo'.
Expand Down Expand Up @@ -24194,12 +24200,12 @@ var ts;
}
function getNarrowedType(type, candidate, assumeTrue) {
if (!assumeTrue) {
return filterType(type, function (t) { return !isTypeSubtypeOf(t, candidate); });
return filterType(type, function (t) { return !isTypeInstanceOf(t, candidate); });
}
// If the current type is a union type, remove all constituents that aren't assignable to
// If the current type is a union type, remove all constituents that couldn't be instances of
// the candidate type. If one or more constituents remain, return a union of those.
if (type.flags & 524288 /* Union */) {
var assignableConstituents = ts.filter(type.types, function (t) { return isTypeAssignableTo(t, candidate); });
var assignableConstituents = ts.filter(type.types, function (t) { return isTypeInstanceOf(t, candidate); });
if (assignableConstituents.length) {
return getUnionType(assignableConstituents);
}
Expand Down
2 changes: 1 addition & 1 deletion kicktravis
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2016-08-09 [ci skip] Version: 1.201608090009.1+3f6aa3f3f0705cfc6bfe59920d49e76c12023953
2016-08-10 [ci skip] Version: 1.201608100007.1+3f1ec7ad4bda8fb546beece999f5f20ef6fe9f24
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ntypescript",
"version": "1.201608090009.1+3f6aa3f3f0705cfc6bfe59920d49e76c12023953",
"version": "1.201608100007.1+3f1ec7ad4bda8fb546beece999f5f20ef6fe9f24",
"description": "A nicer version of microsoft/typescript packaged and released for API developers",
"main": "./bin/ntypescript.js",
"bin": {
Expand Down
13 changes: 10 additions & 3 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5924,6 +5924,13 @@ namespace ts {
return isTypeRelatedTo(source, target, assignableRelation);
}

// A type S is considered to be an instance of a type T if S and T are the same type or if S is a
// subtype of T but not structurally identical to T. This specifically means that two distinct but
// structurally identical types (such as two classes) are not considered instances of each other.
function isTypeInstanceOf(source: Type, target: Type): boolean {
return source === target || isTypeSubtypeOf(source, target) && !isTypeIdenticalTo(source, target);
}

/**
* This is *not* a bi-directional relationship.
* If one needs to check both directions for comparability, use a second call to this function or 'checkTypeComparableTo'.
Expand Down Expand Up @@ -8575,12 +8582,12 @@ namespace ts {

function getNarrowedType(type: Type, candidate: Type, assumeTrue: boolean) {
if (!assumeTrue) {
return filterType(type, t => !isTypeSubtypeOf(t, candidate));
return filterType(type, t => !isTypeInstanceOf(t, candidate));
}
// If the current type is a union type, remove all constituents that aren't assignable to
// If the current type is a union type, remove all constituents that couldn't be instances of
// the candidate type. If one or more constituents remain, return a union of those.
if (type.flags & TypeFlags.Union) {
const assignableConstituents = filter((<UnionType>type).types, t => isTypeAssignableTo(t, candidate));
const assignableConstituents = filter((<UnionType>type).types, t => isTypeInstanceOf(t, candidate));
if (assignableConstituents.length) {
return getUnionType(assignableConstituents);
}
Expand Down

0 comments on commit b73cd1c

Please sign in to comment.