MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/ou3ihc/i_dontt_know_what_i_was_thinking/
r/badcode • u/CreamyCheese384 evil • Jul 29 '21
13 comments sorted by
2
Please explain what's going on here, i know js, but not ts
2 u/CreamyCheese384 evil Jul 30 '21 ts is like an extension for js, as in all js is valid ts, but ts allows strong typing which sometimes can cause peculiar situations like these
ts is like an extension for js, as in all js is valid ts, but ts allows strong typing which sometimes can cause peculiar situations like these
34
You ok do u need help?
11
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 u/megamaz_ Jul 30 '21 :0 it's not the usual man. they're recruiting!
6
:0 it's not the usual man. they're recruiting!
7
You stared into the void and it stared back
4
I know what were uou thinking, about the crime of eslint police evasion!
Why would you ever do any of this?
To cast you have to first cast to unknown
classic TS with their unknown first casts
1
you were thinking this will get me some karma
No way 🤦♂️
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
34
u/[deleted] Jul 29 '21
You ok do u need help?
11
u/CoderCharmander Jul 29 '21
Image Transcription: Code
[The first and last lines are partially cropped off.]
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!
7
u/BirdLawyerCorvo Jul 29 '21
You stared into the void and it stared back
4
u/[deleted] Jul 30 '21
I know what were uou thinking, about the crime of eslint police evasion!
2
u/ZedTT Jul 29 '21
Why would you ever do any of this?
2
u/yshuttle Jul 30 '21
To cast you have to first cast to unknown
2
u/WheWhe10 Jul 30 '21
classic TS with their unknown first casts
1
u/[deleted] Jul 30 '21
you were thinking this will get me some karma
1
u/sixtyfifth_snow Jul 30 '21
No way 🤦♂️
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.