Skip to content

Unexpected intersection type constraint error related to union, generic type and private field #38236

Closed
@vilicvane

Description

@vilicvane

TypeScript Version: 3.9.1-rc/4.0.0-dev.20200428

3.9.0-beta seems to be fine.

Search Terms: intersection,private,generic,constraint,union

Code

type Type = {foo: string} | {bar: number};

class SyncableObject {
  private foo: unknown;
}

interface SyncableRef<T extends ISyncableObject> {
}

interface ISyncableObject<T = object> extends SyncableObject {
}

type __ValueDescriptorType<
  T extends Type | undefined
> = T extends ISyncableObject
  ? SyncableRef<T>
  : T;

Expected behavior: No error

Actual behavior:

Type 'ISyncableObject<object> & T' does not satisfy the constraint 'ISyncableObject<object>'.
  Property 'foo' is missing in type 'ISyncableObject<object> & T' but required in type 'ISyncableObject<object>'.(2344)

Playground Link: Playground

Related Issues:

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions