-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
Search Terms:
nounusedlocals never
nounusedlocals
never
never variable is not used error
Code
//NOTE: nounusedlocals is set to true in tsconfig.
enum Color {
A,
B,
}
function f(color: Color) {
switch(color) {
case Color.A:
console.log("White");
break;
case Color.B:
console.log("Black");
break;
default:
const _:never = color;
}
}Expected behavior:
Compiles fine, prints nothing
Actual behavior:
Given variable _ is unused. _ is of type never which means it is expected to be never used. It is being declared as a compile time safety to ensure that we have cases over all the Color enum values.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScriptAn idea for TypeScript