TypeScript Version: Version 2.3.0-dev.20170217
Code
// A *self-contained* demonstration of the problem follows...
// "noImplicitAny": true,
const myFunc = ( _ , index: number) => { //[ts] Parameter '_' implicitly has an 'any' type.
return `${index}`;
}
Expected behavior:
skip errors "noImplicitAny": when using _
Actual behavior:
[ts] Parameter '_' implicitly has an 'any' type.
I don't think that it should be ignored. You can use {} to ignore argument
@Strate I meant to say to not give errors. Same behavior as
https://github.com/Microsoft/TypeScript/issues/9458
I don't think I'd want to skip implicit any checks using the underscore. It's currently used for ignoring the unused parameter. Is this a bug report, regression or feature request?
@blakeembrey Feature Request since I don't think this was working before.
I need the parameter there so I can pass it to .map() or similar.
It is weird that I need to specify _: any for something I already tagged to skip errors.
Underscore has no special meaning in pure javascript. It is valid identifier for variable. To skip unused argument you can write like this:
function myMap({}, index: number) {
return `${index}`
}
Thanks @Strate ! This was your first suggestion too :)
Most helpful comment
Underscore has no special meaning in pure javascript. It is valid identifier for variable. To skip unused argument you can write like this: