Typescript (Revature)
What is Typescript?
TypeScript is an open-source programming language developed and maintained by Microsoft. It is a strict syntactical superset of JavaScript, and adds optional static typing to the language. Anything you can do in javascript you can also do in typescript. And since browsers cannot read typescript the typescript code is transpiled into javascript before it is used by the browsers. The syntax is closer to higher level languages like java. It's strong typed and gives compiler errors while in the ide, making it easier to debug.
What happens when you put an access modifier on a constructor parameter in typescript?
Typescript automatically creates a member variable identical to the parameter's name and sets the member variable's value to the value of the constructor parameter.
What are the datatypes in typescript?
string, number, boolean, array, any, void, null, tuple, enum "any" acts like var/let in js, tuple is a fixed sized and datatype array
How do we transpile ts into js using the terminal?
tsc file.ts tsc -t es2015 file.ts ////to specifically make it es6 javascript
What is a decorator?
A Decorator is a special kind of declaration that can be attached to a class declaration, method, accessor, property, or parameter. They are functions that called at declaration. Decorators look a lot like annotations and are used to hold meta data in angular 2+.
What is bundling?
Bundling is the process of rolling up a number of distinct resources together into a single downloadable resource. For example, a bundle may consist of multiple JavaScript or CSS files you bring down to the local machine by making a single HTTP request.
What is linting?
Linting is the process of checking the source code for programmatic and stylistic errors. It is useful in keeping code consistent as well as pointing out common mistakes that could potentially be problematic.
What is a module?
In JavaScript/Typescript, the word "modules" refers to small units of independent, reusable code. Essentially, when you use the keyword "export" on a class it becomes a module for another file to import later.
What does using the "get" and "set" keywords in front of a function do?
It allows the method to be used like a variable (without using parentheses)
What does putting a question mark after a parameter name do?
It makes the parameter optional. When you do this all other parameters to the right of this optional parameter must also be optional.
What is Node.js?
Node.js is a free and open source server environment written in c++. It allows us to run javascript outside of a browser. It's platform independant.
What is webpack?
Webpack is a module bundler, this is useful because our client side application has many files and many dependencies, webpack can be used to bundle these files together so that our server has to send less files. This is even more important in Angular 2, since we are working with TypeScript webpack can also transpile the files into es5 standard of JavaScript. Angular Cli uses Webpack under the hood for bundling functionality, but it also gives us additional functionality. The cli can be used to start projects, create new components, services, pipes, etc.
Does typescript have inheritance?
Yes, you can inherit interfaces using "implements". Multiple interfaces if you'd like. You can inherit another class by using "extends" but only a single class.
Does typescript have access modifiers?
Yes. Public, protected, and private. By default members are set to public.
How would I check the version of Node on my computer? How about NPM?
node -v, npm -v.
How do we install typescript from npm?
npm install -g typescript
What is NPM?
npm is node package manager. It allows developers to create and use open source packages. Similar to Maven, we can use it to manage what dependencies we have and the versions we want to use. This is done through the package.json file It's both a platform and a command line interface. https://nodejs.org/en/
