Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Union of variant setters uses getter type for assignmentΒ #45376

Copy link
Copy link

Description

@thw0rted
Issue body actions

Bug Report

πŸ”Ž Search Terms

variant accessor setter union

πŸ•— Version & Regression Information

  • I was unable to test this on prior versions because: variant accessors only landed in 4.3

⏯ Playground Link

Example from below

πŸ’» Code

class One {
  get prop(): string { return ""; }
  set prop(s: string | number) { }
}

class Two {
  get prop(): string { return ""; }
  set prop(s: string | number) { }
}

declare const u1: One|Two;
u1.prop = 42; //Type 'number' is not assignable to type 'string'.(2322)

I didn't include it in the playground, but behavior is the same for class or interface.

πŸ™ Actual behavior

Assignment of number is flagged as an error, even though both sides of the union allow assignment of a number.

πŸ™‚ Expected behavior

Assignment should not be flagged.


Originally reported by @ws93

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestoneThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

Morty Proxy This is a proxified and sanitized view of the page, visit original site.