diff --git a/TypeScript b/TypeScript index 3f6aa3f..3f1ec7a 160000 --- a/TypeScript +++ b/TypeScript @@ -1 +1 @@ -Subproject commit 3f6aa3f3f0705cfc6bfe59920d49e76c12023953 +Subproject commit 3f1ec7ad4bda8fb546beece999f5f20ef6fe9f24 diff --git a/bin/ntypescript.js b/bin/ntypescript.js index 46d399b..3b213c0 100644 --- a/bin/ntypescript.js +++ b/bin/ntypescript.js @@ -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'. @@ -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); } diff --git a/bin/typescript.js b/bin/typescript.js index 912e6c7..3410e81 100644 --- a/bin/typescript.js +++ b/bin/typescript.js @@ -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'. @@ -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); } diff --git a/kicktravis b/kicktravis index e0160ef..067b1fa 100644 --- a/kicktravis +++ b/kicktravis @@ -1 +1 @@ -2016-08-09 [ci skip] Version: 1.201608090009.1+3f6aa3f3f0705cfc6bfe59920d49e76c12023953 +2016-08-10 [ci skip] Version: 1.201608100007.1+3f1ec7ad4bda8fb546beece999f5f20ef6fe9f24 diff --git a/package.json b/package.json index 9e28bce..58faf3f 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bec8686..1f2eaea 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -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'. @@ -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((type).types, t => isTypeAssignableTo(t, candidate)); + const assignableConstituents = filter((type).types, t => isTypeInstanceOf(t, candidate)); if (assignableConstituents.length) { return getUnionType(assignableConstituents); }