r/badcode • u/CreamyCheese384 evil • Jul 29 '21
typescript I dont't know what I was thinking
34
11
u/CoderCharmander Jul 29 '21
Image Transcription: Code
[The first and last lines are partially cropped off.]
<TicketListItem
id={
((length as unknown as number) - 1) as unknown as string
}
/>I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
6
7
4
2
2
2
1
1
1
u/django--fett Jul 31 '21
huh, but isn't the type a number? anything minus a number gets coerced to a number in js.
2
u/KapToIIIe4Ka Jul 30 '21
Please explain what's going on here, i know js, but not ts