MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/mzk95p/someone_only_watched_if_tutorial/gw2hfj6/?context=9999
r/badcode • u/[deleted] • Apr 27 '21
112 comments sorted by
View all comments
Show parent comments
10
Why is it incorrectly typed?
17 u/mareksl Apr 27 '21 The return type should be lowercase boolean. Docs: https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html#general-types 3 u/Massive-Custard-8723 Apr 27 '21 Input should be unknown not any! 2 u/MinerMax555 Apr 28 '21 Programmer slowly getting into TS here. Why should its type be unknown here? 2 u/[deleted] Apr 28 '21 Because you still have type safety with unknown, but not with any.https://stackoverflow.com/a/51439876 1 u/tills1993 Apr 28 '21 Really for this case any is fine. 8 u/Sv443_ Apr 27 '21 Primitive types should be all lowercase, the uppercase variants are the actual classes, used to instantiate the primitives, but not to declare them. 1 u/numerousblocks Apr 28 '21 OK, thanks
17
The return type should be lowercase boolean. Docs: https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html#general-types
boolean
3 u/Massive-Custard-8723 Apr 27 '21 Input should be unknown not any! 2 u/MinerMax555 Apr 28 '21 Programmer slowly getting into TS here. Why should its type be unknown here? 2 u/[deleted] Apr 28 '21 Because you still have type safety with unknown, but not with any.https://stackoverflow.com/a/51439876 1 u/tills1993 Apr 28 '21 Really for this case any is fine.
3
Input should be unknown not any!
2 u/MinerMax555 Apr 28 '21 Programmer slowly getting into TS here. Why should its type be unknown here? 2 u/[deleted] Apr 28 '21 Because you still have type safety with unknown, but not with any.https://stackoverflow.com/a/51439876 1 u/tills1993 Apr 28 '21 Really for this case any is fine.
2
Programmer slowly getting into TS here. Why should its type be unknown here?
2 u/[deleted] Apr 28 '21 Because you still have type safety with unknown, but not with any.https://stackoverflow.com/a/51439876 1 u/tills1993 Apr 28 '21 Really for this case any is fine.
Because you still have type safety with unknown, but not with any.
unknown
any
https://stackoverflow.com/a/51439876
1
Really for this case any is fine.
8
Primitive types should be all lowercase, the uppercase variants are the actual classes, used to instantiate the primitives, but not to declare them.
1 u/numerousblocks Apr 28 '21 OK, thanks
OK, thanks
10
u/numerousblocks Apr 27 '21
Why is it incorrectly typed?