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

Class Example in Page "Interface" #543

Open
Gfast2 opened this issue Dec 4, 2019 · 2 comments
Open

Class Example in Page "Interface" #543

Gfast2 opened this issue Dec 4, 2019 · 2 comments

Comments

@Gfast2
Copy link

Gfast2 commented Dec 4, 2019

Hey Basarat,

I'm reading the secsion Interface of the book. And decided to copy & past some snippet into typescript Playground. I've find that your code may not designed to be copyAndPastable. (See this result)
image

As a beginner for class in Javascript, I belive here I may initialize x and y in the constructure. So what's your purpose here? Prefer a concise expression as exist on the book or others?

BTW:
Awesome book really! I'm sure I will buy you something after I slowly finish my reading in the new future! 🌹
I'm pretty sure I've been your fans now 💘

Cheers

Su Gao

@Gfast2
Copy link
Author

Gfast2 commented Dec 5, 2019

Hi @basarat ,

Since I'm really new in typescript. So it's a little hard for me to dealing with code snippets that can't run out of the box. Besides this "Issue" above. I've figured out some others like in section Callable snippets about Newable.

Because I know this book's topic is something that let people "deep dive". So the audience may not persons like me. Feel free to close this issue, and I'll know what I found like this one is not treated as issue on your side. And I will stop going on report them. If you do think these can be treated as issues, I'll be more then happy to try to make PRs if I got answers.

Big thanks again for your effort put in this book! 🌹 🌹 🌹

@Gfast2
Copy link
Author

Gfast2 commented Dec 6, 2019

There are still some questions / possible small issues comes across these days. Since @basarat still not take response to my Issue ticket. So please allow me to point out another one here:

In Chapter Exception Handling there is a example in secsion "You don't have to throw an error" as follow:

function myFunction (callback: (e?: Error)) {
  doSomethingAsync(function () {
    if (somethingWrong) {
      callback(new Error('This is my error'))
    } else {
      callback();
    }
  });
}

I think variable somethingWrong should be the parameter of the nested anonym function. So it may looks clearer if put it this way:

function myFunction (callback: (e?: Error)) {
  doSomethingAsync(function (somethingWrong:any) {
    if (somethingWrong) {
      callback(new Error('This is my error'))
    } else {
      callback();
    }
  });
}

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

1 participant