Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typescript operator '+=' cannot be applied to types Number and Number #3447

Closed
Akxe opened this issue Jun 9, 2015 · 2 comments
Closed

typescript operator '+=' cannot be applied to types Number and Number #3447

Akxe opened this issue Jun 9, 2015 · 2 comments
Labels
By Design Deprecated - use "Working as Intended" or "Design Limitation" instead Canonical This issue contains a lengthy and complete description of a particular problem, solution, or design

Comments

@Akxe
Copy link

Akxe commented Jun 9, 2015

Why?

ref: [
  {
    value: Number
    date?: Date
  }
]
total() {
  var total = 0
  for (var ind = this.ref.length - 1; ind >= 0; ind--) {
    total += this.ref[ind].value
  }
  return total
}

This is totaly vaild in JS, should be in typescript too

@DanielRosenwasser
Copy link
Member

You want number (all lowercase) not Number. number is the primitive type, whereas Number is a description of the shape of instances of Number and number itself.

See a more detailed response here: #2624 (comment)

Or @danquirk's response here: #2031 (comment)

@DanielRosenwasser DanielRosenwasser added By Design Deprecated - use "Working as Intended" or "Design Limitation" instead Canonical This issue contains a lengthy and complete description of a particular problem, solution, or design labels Jun 9, 2015
@DanielRosenwasser
Copy link
Member

Note that #2361 aims to address this.

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
By Design Deprecated - use "Working as Intended" or "Design Limitation" instead Canonical This issue contains a lengthy and complete description of a particular problem, solution, or design
Projects
None yet
Development

No branches or pull requests

2 participants