Skip to content

Give a helpful error when trying to relate primitives to the boxed/apparent backing types. #10351

Closed
@DanielRosenwasser

Description

@DanielRosenwasser
var x = new Number();
var y = 100;
y = x;

Current error: Type 'Number' is not assignable to type 'number'.
Suggestion:

Type 'Number' is not assignable to type 'number'.
  'number' is a primitive type while 'Number' is a boxed object. Prefer using 'number' when possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: Error MessagesThe issue relates to error messagingFixedA PR has been merged for this issueGood First IssueWell scoped, documented and has the green lightSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions