💅 lint/suspicious/noRedeclare
false positive when using inline type signature on const with [key in MyMapPb[keyof MyMapPb]]
#953
Labels
A-Linter
Area: linter
L-JavaScript
Language: JavaScript and super languages
S-Bug-confirmed
Status: report has been confirmed as a valid bug
Environment information
We have a pattern of mapping enums to-from one system to another with the nice
in ... keyof
pattern. Biome considers these placeholderkey
syntax a variable redeclaration.Like this:
However when I have several of these enum to enum mappings, Biome complains.
Please see the code snippet in playground.
Biome shows error
Shouldn't redeclare 'key'. Consider to delete it or rename it.
But this is not correct. As far as I can tell whatever that 'key' signifies is not a reachable part of syntax.Rule name
lint/suspicious/noRedeclare
Playground link
https://biomejs.dev/playground/?code=ZQB4AHAAbwByAHQAIABjAG8AbgBzAHQAIABNAHkATQBhAHAAcABpAG4AZwBQAGIAVABvAEcAcQBsADoAIAB7AAoAIAAgAFsAawBlAHkAIABpAG4AIABNAHkAUwB0AGEAdAB1AHMATQBhAHAAUABiAFsAawBlAHkAbwBmACAATQB5AFMAdABhAHQAdQBzAE0AYQBwAFAAYgBdAF0AOgAgAFMAdABhAHQAdQBzAEcAcQBsADsACgB9ACAAPQAgAHsACgAgACAAWwBNAHkAUwB0AGEAdAB1AHMAUABiAC4AUwBUAEEAVABVAFMAXwBJAE4AVgBBAEwASQBEAF0AOgAgAFMAdABhAHQAdQBzAEcAcQBsAC4ASQBuAHYAYQBsAGkAZAAsAAoAIAAgAFsATQB5AFMAdABhAHQAdQBzAFAAYgAuAFMAVABBAFQAVQBTAF8AQQBdADoAIABTAHQAYQB0AHUAcwBHAHEAbAAuAEEALAAKACAAIABbAE0AeQBTAHQAYQB0AHUAcwBQAGIALgBTAFQAQQBUAFUAUwBfAEIAXQA6ACAAUwB0AGEAdAB1AHMARwBxAGwALgBCACwACgAgACAAWwBNAHkAUwB0AGEAdAB1AHMAUABiAC4AUwBUAEEAVABVAFMAXwBDAF0AOgAgAFMAdABhAHQAdQBzAEcAcQBsAC4AQwAsAAoAfQA7AAoACgBlAHgAcABvAHIAdAAgAGMAbwBuAHMAdAAgAE0AeQBPAHQAaABlAHIATQBhAHAAcABpAG4AZwBQAGIAVABvAEcAcQBsADoAIAB7AAoAIAAgAFsAawBlAHkAIABpAG4AIABNAHkATwB0AGgAZQByAFMAdABhAHQAdQBzAE0AYQBwAFAAYgBbAGsAZQB5AG8AZgAgAE0AeQBPAHQAaABlAHIAUwB0AGEAdAB1AHMATQBhAHAAUABiAF0AXQA6ACAATwB0AGgAZQByAFMAdABhAHQAdQBzAEcAcQBsADsACgB9ACAAPQAgAHsACgAgACAAWwBNAHkATwB0AGgAZQByAFMAdABhAHQAdQBzAFAAYgAuAFMAVABBAFQAVQBTAF8ASQBOAFYAQQBMAEkARABdADoAIABPAHQAaABlAHIAUwB0AGEAdAB1AHMARwBxAGwALgBJAG4AdgBhAGwAaQBkACwACgAgACAAWwBNAHkATwB0AGgAZQByAFMAdABhAHQAdQBzAFAAYgAuAFMAVABBAFQAVQBTAF8ARABdADoAIABPAHQAaABlAHIAUwB0AGEAdAB1AHMARwBxAGwALgBEACwACgAgACAAWwBNAHkATwB0AGgAZQByAFMAdABhAHQAdQBzAFAAYgAuAFMAVABBAFQAVQBTAF8ARQBdADoAIABPAHQAaABlAHIAUwB0AGEAdAB1AHMARwBxAGwALgBFACwACgAgACAAWwBNAHkATwB0AGgAZQByAFMAdABhAHQAdQBzAFAAYgAuAFMAVABBAFQAVQBTAF8ARgBdADoAIABPAHQAaABlAHIAUwB0AGEAdAB1AHMARwBxAGwALgBGACwACgB9ADsACgA%3D
Expected result
Linter should not complain about key being declared or redeclared.
something in Map[keyof Map]
in type signature is a special syntax and actually does not declare (or redeclare) anything.Code of Conduct
The text was updated successfully, but these errors were encountered: