One of the solutions of Exercise 12 of the TypeScript beginner's course gives me this error on Typescript playground
techemmy opened this issue · 4 comments
Hi, @techemmy! I see that is currently solution 2 to problem 12-catch-blocks.
Is that the only solution that gives you that error? I believe the error is happening because the function should be returning a value from inside the try
block, which currently only throw
s. However, you should not be getting that error since the noImplicitReturns
rule in the tsconfig.json
file is commented out.
Do you have that rule enabled by chance?
Hi, @techemmy! I see that is currently solution 2 to problem 12-catch-blocks.
Is that the only solution that gives you that error? I believe the error is happening because the function should be returning a value from inside the
try
block, which currently onlythrow
s. However, you should not be getting that error since thenoImplicitReturns
rule in thetsconfig.json
file is commented out.Do you have that rule enabled by chance?
I don't remember if I had the rule enabled, but it was the only solution giving me this error.
Hi!
Would it make sense to encourage
unknown
type introduction- first guarding against cases when
e
variable
does not inherit fromError
class ? - so that we could narrow down the
happier path
when e has amessage
member variable?
P.S. The underlying exercice could have been renamed in between (since this issue has been opened in late 2022),
- from
12-catch-blocks.problem.ts
- to
13-catch-blocks.problem.ts
perhaps?
Hi!
Would it make sense to encourage
unknown
type introduction- first guarding against cases when
e
variable
does not inherit fromError
class ?- so that we could narrow down the
happier path
when e has amessage
member variable?P.S. The underlying exercice could have been renamed in between (since this issue has been opened in late 2022),
- from
12-catch-blocks.problem.ts
- to
13-catch-blocks.problem.ts
perhaps?
I completely agree!
I had just started getting familiar with Typescript when I created this issue. So I didn't understand as much.
The introduction of unknown
would make total sense.