Revised some awkward expression#136
Revised some awkward expression#136MilkClouds wants to merge 1 commit intomicrosoft:mainfrom MilkClouds:patch-1
Conversation
Revised some awkward expression.
Translation of TS for OOPers.mdtitle: TypeScript for Java/C# Programmers oneline: Learn TypeScript if you have a background in object-oriented languagesTypeScript is a popular choice for programmers who are familiar with languages that use static typing, such as C#, Java, and so on. TypeScript's type system offers many benefits of static typing, such as better code completion, early detection of errors, and clearer communication between parts of the program. Learn JavaScript Together (Co-learning JavaScript)If you're already familiar with JavaScript but are primarily programmers using Java or C#, this introductory page can help explain common misconceptions and pitfalls. If you're a Java or C# programmer new to JavaScript, you can first understand the runtime behavior of JavaScript. Except It's a good idea to learn part of JavaScript. TypeScript is the same as JavaScript _Runtime_It is very important to remember that resources that want to implement specific runtime behaviors (such as converting strings to numbers, displaying warnings, writing files to disk, etc.) always apply equally well to TypeScript programs. Rethinking the ClassC# and Java Mandatory OOP It's called language. Free functions and dataIn JavaScript, functions can be anywhere and can freely pass data without belonging to a predefined 'class' or 'struct'. Static ClassesIn addition, certain structures, such as singletons and static classes in C# and Java, are not required by TypeScript. OOP in TypeScript (OOP in TypeScript) in TypeScriptIn other words, you can continue using the class if you want! We will cover the class later in this guide. Rethinking TypesTypeScript's _type_The understanding of is actually quite different from C# or Java. Type system embodied by name (Terminal Reified Type Systems)The values and objects given in C# and Java have exactly one type: 'null', the raw type, or the defined class type. This is what reified, nominal Describes the type system. Type as a set (Types as Sets)In C# or Java, the one-to-one correspondence between the runtime type and its compile-time declaration is important. In TypeScript, the type shares something common _Set of values_It's a good idea to think of it as . Once you start thinking about types as a set, certain operations become very natural. In TypeScript, this becomes very natural when you realize that every type is simply a set. TypeScript provides several ways to use types based on collective theory, and it is more intuitive to think of types as a set. Deleted Structural TypesIn TypeScript, an object has exactly a single type. No. TypeScript's type system is not _Structured_Is: TypeScript's type system also Not materialized: At runtime Type as a set In a concept, Results of structural typeization (Concequencys of Structural Typing)Object-oriented programmers are often surprised by two aspects of structural typeization. Empty Type (Empty Types)First _Empty type_seems to defy expectations: TypeScript allows a given argument to be This may seem surprising, but it has a very similar relationship to what is finally implemented in a nominal object-oriented programming language. Same Type (Identical Types)The causes of another frequent surprise are caused by the same type: class Car {
drive() {
// hit the gas
}
}
class Golfer {
drive() {
// hit the ball far
}
}
// No error?
let w: Car = new Golfer();Again, the reason why it's not an error is _rescue_because it is the same. You'll learn more about how classes relate to each other in class chapters in the future. ReflectionObject-oriented programmers are accustomed to being able to query any type of value, including generics. // C#
static void PrintType<T>() {
Console.WriteLine(typeof(T).Name);
}Because TypeScript's type system is completely wiped out, information such as instantiation of generic type factors is not available at runtime. JavaScript It's been an overview so far, and here we are. handbookRead or Playground exampleExplore . |
yeonjuan
left a comment
There was a problem hiding this comment.
@MilkClouds 감사합니다! 몇 가지 제안남겼습니다.
Revised some awkward expression.