Merge pull request #29420 from Microsoft/fix29108

Remove overzealous simple relationship check for unique symbols
This commit is contained in:
Ron Buckton
2019-01-15 09:47:13 -08:00
committed by GitHub
5 changed files with 419 additions and 397 deletions

View File

@@ -11667,7 +11667,6 @@ namespace ts {
if (s & TypeFlags.Undefined && (!strictNullChecks || t & (TypeFlags.Undefined | TypeFlags.Void))) return true;
if (s & TypeFlags.Null && (!strictNullChecks || t & TypeFlags.Null)) return true;
if (s & TypeFlags.Object && t & TypeFlags.NonPrimitive) return true;
if (s & TypeFlags.UniqueESSymbol || t & TypeFlags.UniqueESSymbol) return false;
if (relation === assignableRelation || relation === comparableRelation) {
if (s & TypeFlags.Any) return true;
// Type number or any numeric literal type is assignable to any numeric enum type or any

View File

@@ -28,6 +28,10 @@ var varInitToConstDeclAmbient = constType;
const constInitToConstCallWithTypeQuery: typeof constCall = constCall;
const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType;
// assignment from any
// https://github.com/Microsoft/TypeScript/issues/29108
const fromAny: unique symbol = {} as any;
// function return inference
function funcReturnConstCall() { return constCall; }
function funcReturnLetCall() { return letCall; }
@@ -286,6 +290,9 @@ var varInitToConstDeclAmbient = constType;
// declaration from initializer with type query
const constInitToConstCallWithTypeQuery = constCall;
const constInitToConstDeclAmbientWithTypeQuery = constType;
// assignment from any
// https://github.com/Microsoft/TypeScript/issues/29108
const fromAny = {};
// function return inference
function funcReturnConstCall() { return constCall; }
function funcReturnLetCall() { return letCall; }

File diff suppressed because it is too large Load Diff

View File

@@ -85,6 +85,13 @@ const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType;
>constType : unique symbol
>constType : unique symbol
// assignment from any
// https://github.com/Microsoft/TypeScript/issues/29108
const fromAny: unique symbol = {} as any;
>fromAny : unique symbol
>{} as any : any
>{} : {}
// function return inference
function funcReturnConstCall() { return constCall; }
>funcReturnConstCall : () => symbol

View File

@@ -31,6 +31,10 @@ var varInitToConstDeclAmbient = constType;
const constInitToConstCallWithTypeQuery: typeof constCall = constCall;
const constInitToConstDeclAmbientWithTypeQuery: typeof constType = constType;
// assignment from any
// https://github.com/Microsoft/TypeScript/issues/29108
const fromAny: unique symbol = {} as any;
// function return inference
function funcReturnConstCall() { return constCall; }
function funcReturnLetCall() { return letCall; }