Skip to content

Arithmetic operators don't work on type parameters #15523

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

Closed
vkurchatkin opened this issue May 2, 2017 · 1 comment
Closed

Arithmetic operators don't work on type parameters #15523

vkurchatkin opened this issue May 2, 2017 · 1 comment
Labels
Duplicate An existing issue was already created

Comments

@vkurchatkin
Copy link
Contributor

TypeScript Version: master

Code

function test<T extends number>(n: T) {
  var a = n * 1;
  var b = n - 1;
  var c = n + 1;
}

Expected behavior:

No errors

Actual behavior:

Following errors:

test.ts(4,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
test.ts(5,11): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
test.ts(6,11): error TS2365: Operator '+' cannot be applied to types 'T' and '1'.
@vkurchatkin
Copy link
Contributor Author

Oops, duplicate of #15501

@RyanCavanaugh RyanCavanaugh added the Duplicate An existing issue was already created label May 2, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

2 participants