-
Notifications
You must be signed in to change notification settings - Fork 130
Translate Handbookv2/Classes in Chinese #177
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
base: main
Are you sure you want to change the base?
Conversation
@YexuanXiao please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
Thanks for the PR! This section of the codebase is owned by @Kingwl - if they write a comment saying "LGTM" then it will be merged. |
Translation of Classes.mdtitle: class oneline: "How TypeScript's classes work"
TypeScript provides support for what was introduced in ES2015 Like other JavaScript features, TypeScript adds type annotations and other syntax to allow you to express relationships between classes and other types. Class membersHere is a basic class - an empty class: class Point {} This class isn't very useful yet, so let's start adding some members. fieldThe field declaration creates an exposed writable property in the class: // @strictPropertyInitialization: false
class Point {
x: number;
y: number;
}
const pt = new Point();
pt.x = 0;
pt.y = 0; As with the other sections, type annotations are optional, but if not specified, they are implicitly declared as Fields are also available Initializer; The initializer will execute automatically when the class is instantiated. class Point {
x = 0;
y = 0;
}
const pt = new Point();
// 打印 0, 0
console.log(`${pt.x}, ${pt.y}`); resemble // @errors: 2322
class Point {
x = 0;
y = 0;
}
// ---cut---
const pt = new Point();
pt.x = "0";
|
@microsoft-github-policy-service agree |
No description provided.