basarat / basarat/typescript-book

Class Example in Page "Interface"

Open
#543 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
21.6k
Forks
2.6k
PR merge metrics
No merged PRs in 30d

Description

Hey Basarat,

I'm reading the secsion [***Interface***](https://basarat.gitbooks.io/typescript/docs/types/interfaces.html) of the book. And decided to copy & past some snippet into [***typescript Playground***](https://www.typescriptlang.org/play/index.html). I've find that your code may not designed to be *copyAndPastable*. (See [this result](https://www.typescriptlang.org/play/index.html?ssl=7&ssc=1&pln=7&pc=2#code/JYOwLgpgTgZghgYwgAgAoHtRmQbwLABQyxyAHgFzIgCuAtgEbQDcyAnpTQ84QL6GEIANnADOI5AFlWGLMmC0ADoIi0I4cTPC5CJMhzqMoLdlQPNkAegvIAynFXJRaTOF5A))
![image](https://user-images.githubusercontent.com/2803903/70173465-27364500-16d3-11ea-9910-2e66c6d7a5d9.png)

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

Contributor guide

Open the contributing guide

Research direction

Read the Interface section of the book and reproduce the linked TypeScript Playground result. Compare the class example with the reported copy-and-paste failure, then clarify the example or its explanation so a beginner understands the intended initialization and can run the snippet successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.