We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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 Version: nightly (2.4.0-dev.20170501)
Code
interface I { x: number; } type IdentityMap<T> = { [P in keyof T]: T[P]; }; function f<T extends I>(i: IdentityMap<T>) { const n: number = i.x; // No error, good i.x * 2; // Error }
Expected behavior:
No error.
Actual behavior:
src/a.ts(9,5): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
May be related to #14360.
The text was updated successfully, but these errors were encountered:
This is not really special to mapped types. this is true for all generic variables:
function f2<T extends number>(x: T) { const n: number = x; // No error, good x * 2; // Error }
the check we perform for these operators is that it has to be the type number, and not just a number.
number
I am sure we have another issue for strings somewhere, but could not find it.
Sorry, something went wrong.
No branches or pull requests
TypeScript Version: nightly (2.4.0-dev.20170501)
Code
Expected behavior:
No error.
Actual behavior:
src/a.ts(9,5): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number' or an enum type.
May be related to #14360.
The text was updated successfully, but these errors were encountered: