Pragma disabled for noUnusedLocals?

I have included noUnusedLocals , but I have a function that simply checks for the presence of the first element, but does not use it. Is there any pragma to disable this warning for a code block?

Example:

 export function has<T>(sequence: Iterable<T>): boolean { for (let element of sequence) { element; // Needed to quiet compiler setting `noUnusedLocals`. return true; } return false; } 

The docs say use _ :

Declaring parameters with names starting with _ is exempt from unused parameter checking.

(see this )

But this seems to apply only to parameters , not local variables.

+6
source share
1 answer

This is not really an answer in the strict sense of the word, but _ , since the prefix of the name or name suppresses --noUnusedLocals in the for..of loop for..of in TypeScript 2.2.2, which is the current version at the time of this writing.

+1
source

All Articles