Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

One of the solutions of Exercise 12 of the TypeScript beginner's course gives me this error on Typescript playground #62

Open
techemmy opened this issue Nov 1, 2022 · 4 comments

Comments

@techemmy
Copy link

techemmy commented Nov 1, 2022

The 3rd solution gives me the error on the TypeScript playground as well.

Screenshot 2022-10-31 at 22 19 13

@seblondono
Copy link

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 throws. 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?

@techemmy
Copy link
Author

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 throws. 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?

I don't remember if I had the rule enabled, but it was the only solution giving me this error.

@thierrymarianne
Copy link

thierrymarianne commented Apr 4, 2024

Hi!

Would it make sense to encourage

  • unknown type introduction
  • first guarding against cases when e variable
    does not inherit from Error class ?
  • so that we could narrow down the happier path when e has a message 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?

@techemmy
Copy link
Author

techemmy commented Apr 7, 2024

Hi!

Would it make sense to encourage

  • unknown type introduction
  • first guarding against cases when e variable
    does not inherit from Error class ?
  • so that we could narrow down the happier path when e has a message 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants