-
Notifications
You must be signed in to change notification settings - Fork 130
feat: translate TS for the New Programmer to pt #124
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
Translation of TS for the New Programmer.mdtitle: TypeScript for new programmer oneline: Learn TypeScript from scratchCongratulations on choosing TypeScript as one of your first programming languages - you've already started making good decisions. You've probably heard that TypeScript is a "flavor" or "variant" of JavaScript. TypeScript (TS) and JavaScript (JS) maintain a unique relationship between modern programming languages, so learning more about this relationship will help you understand how TypeScript extends JavaScript. What is JavaScript? A brief historyJavaScript (also known as ECMAScript) began its life as a simple scripting language for browsers. Browser developers responded to this increased use of JS by optimizing their execution engines (dynamic build) and extending what could be done with them (adding APIs), which in turn caused web developers to use the language even more. More than that, JS has become popular enough to be used outside the context of browsers, such as to deploy servers in JS using node.js. To summarize, we have a language that was designed for quick uses, and that has become a complete tool for writing applications with millions of lines.
Many programming languages would trigger an error in the occurrence of some of these conditions, others would do so during compilation - before any code was executed. TypeScript: A static type checkerWe said earlier that some programming languages would not even allow the startup of bugprograms. TypeScript looks for errors in programs before they even run, and does so based on the kind of values that are being used, so it's a static type tester // @errors: 2551
const obj = { width: 10, height: 15 };
const area = obj.width * obj.heigth; A JavaScript-typed supersetSo how does TypeScript relate to JavaScript? SyntaxTypeScript is a language that is a superset JavaScript: Soon JS syntax is allowed within TS. // @errors: 1005
let a = (4 TypeScript does not consider any JavaScript code to be an error because of its syntax. TypesHowever, TypeScript is a superset Typed, which means that it has extra rules about how different types of values can be used. In this other example, we have javascript code that will run normally in your browser, printing a value on the console: console.log(4 / []); This program, which is syntactically correct, will print // @errors: 2363
console.log(4 / []); It's possible that you actually Wanted divide a number by an array, perhaps just to see what happens. But in most cases, however, this is a programming error. If you move some code from a JavaScript file to a TypeScript file, you will probably see type errors depending on how your code was written. Runtime Behavior (Runtime)TypeScript is also a programming language that preserves the runtime behavior javascript. This means that if you move some JavaScript code to TypeScript, it is secure that it will run the same way, even if TypeScript thinks it has some type errors. Maintaining the same Runtime feature as JavaScript is a key promise of TypeScript as this means you can easily migrate between the two languages without worrying about subtle differences that can cause your program to stop running. Deleted TypesRoughly speaking, once the TypeScript compiler finishes checking your code, it Erases the types to produce the "compiled" code. This also means that TypeScript never changes the behaviour programme based on inferred types. Finally, TypeScript does not provide any additional library at runtime. Learning JavaScript and TypeScriptWe often see the question "Should I learn JavaScript or TypeScript?". The answer is that you can't learn TypeScript without learning JavaScript! There are many resources available for programmers to learn JavaScript; you No you should ignore these features if you are writing TypeScript. If you find yourself looking for something like "how to sort a list in TypeScript," remember: TypeScript is the Runtime JavaScript with a build-time type analyzer. Next stepsThis was a brief summary of the syntax and tools used in the day-to-day life of TypeScript. From here, you can:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small changes
Co-authored-by: Lucas Santos <[email protected]>
Co-authored-by: Lucas Santos <[email protected]>
LGTM |
Sorry @khaosdoctor, you don't have access to these files: |
I've also translated this file at #133 |
lgtm |
Sorry @khaosdoctor, you don't have access to these files: |
@tomashugo can you please remove the package-lock that was altered? |
Thanks for the PR! This section of the codebase is owned by @khaosdoctor and @danilofuchs - if they write a comment saying "LGTM" then it will be merged. |
Done |
I dit it before |
LGTM |
Sorry @khaosdoctor, this PR has merge conflicts. They'll need to be fixed before this can be merged. |
@tomashugo probably you'll need to merge master into your branch to solve those conflicts and then we can try again |
No description provided.