Typescript: [Feature Request] skip --noImplicitAny checks when using `_ `

Created on 17 Feb 2017  路  6Comments  路  Source: microsoft/TypeScript

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.

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:

function myMap({}, index: number) {
  return `${index}`
}

All 6 comments

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 :)

Was this page helpful?
0 / 5 - 0 ratings