You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In this step we will review briefly files structure our Socially app has so far,
5
-
also we’ll look closely into TypeScript features since knowing better primary programming language of this package would be surely beneficial.
4
+
In this step we will briefly review the file structure our Socially app has so far,
5
+
also we’ll look closely into certain TypeScript features since having a better understanding of the primary programming language of this package would be surely beneficial.
6
6
7
7
# File Structure
8
8
9
-
As you probably have noticed, our tutorial app has a strict modular structure at this point:
10
-
there is no pure JavaScript files that are being bundled together and auto-executed, so Meteor's file loading conventions don't have effect.
9
+
As you have probably noticed, our tutorial app has a strict modular structure at this point:
10
+
there are no pure JavaScript files that are being bundled together and auto-executed, so Meteor's file loading conventions doesn't have an effect.
11
11
Even more, every .ts-file is being compiled into a separate System.j module, which we can then import whenever we need to.
12
12
13
-
There is another one thing worth sounding once more. As you know, Meteor has two special folders: **client** and **server**.
14
-
We can benefit from them (and already done it in this app) too by allowing access to the client side modules from the client side only and, accordingly, to server side modules from the server side.
15
-
Everything outside them will be available to the both parts.
16
-
It’s, no wonder, a recommended approach in Meteor, and this is how we’ve been doing it so far.
13
+
There is another thing worth mentioning once more. As you know, Meteor has two special folders: **client** and **server**.
14
+
We can benefit from them (and have already done so in this app) by allowing access to the client side modules from the client side only and, accordingly, to server side modules from the server side.
15
+
Everything outside of those folders will be available to the both client and server.
16
+
It’s no wonder why this is a recommended approach in Meteor, and this is why we’ve been doing it so far.
17
17
Let's stick to it further.
18
18
19
19
# TypeScript
20
20
21
21
TypeScript is a rather new language that has been around for 3 years only.
22
-
Since then it’s been gaining [popularity](https://www.google.com/trends/explore#q=%2Fm%2F0n50hxv) due to various reasons. Among them are one of the fullest implementation of the ES2015 standard's features
23
-
on the market including some of the experimental ones, pseudo type-checking and rich toolset developed by Microsoft and TypeScript community.
22
+
Since then it’s been gaining [popularity](https://www.google.com/trends/explore#q=%2Fm%2F0n50hxv) due to various reasons. Among them is one of the fullest implementations of ES2015 features
23
+
on the market: including some of the experimental ones, pseudo type-checking and a rich toolset developed by Microsoft and the TypeScript community.
24
24
It has support already in all major IDEs including Visual Studio, WebStorm, Sublime etc.
25
25
26
26
One of the hottest questions in JavaScript, that has been around since the Web 2.0 era started, was how to make JavaScript less bug-prone and
27
27
suitable for big projects. In the OOP world, well-known solutions include modularity and strict type-checking. While OOP is available in JavaScript in some way,
28
28
it turned out to be very hard to create a good type-checking due to, first of all, JavaScript's flexibility. One always needs to impose a certain number of rules to
29
29
follow to make a JavaScript compiler effective. For many years, we’ve seen around a number of solutions including Closure Compiler and GWT from Google, a bunch of C#-to-JavaScript compilers and others.
30
30
31
-
This was, for sure, one of the questions why TypeScript team were striving to solve: to create a language that would inherit flexibility of JavaScript while would have, at the same, effective type-checking with minimum amount of effort required from the user. There should have been some kind of the[middle way](https://en.wikipedia.org/wiki/Middle_Way).
32
-
And they found it, having introduced the type declaration files. These are files of special kind where you describe interfaces your classes expose along with signatures of the methods and types of the parameters they take, so that TypeScript will be able to refer to these files to verify correctness of your class's API.
33
-
Of course, flexibility is still there which means if you don’t want to declare types you can skip them right away.
31
+
This was, for sure, one of the problems the TypeScript team were striving to solve: to create a language that would inherit the flexibility of JavaScript while, at the same time, having effective type-checking with minimum effort required from the user. There should have been some kind of [middle way](https://en.wikipedia.org/wiki/Middle_Way).
32
+
And they found it, having introduced the type declaration files. These are files of a special kind where you describe interfaces your classes expose along with signatures of the methods and types of the parameters they take, so that TypeScript will be able to refer to these files to verify the correctness of your class's API.
33
+
Of course, the flexibility is still there which means if you don’t want to declare types you can skip them right away.
34
34
35
-
Usage of the declaration files was mentioned multiple time in this tutorial before with the `/// <reference path=".." />` syntax. By this way, we tell TypeScript what declaration files to check when it is compiling a particular .ts-file.
35
+
Usage of the declaration files was mentioned multiple times in this tutorial with the `/// <reference path=".." />` syntax. By this way, we tell TypeScript what declaration files to check when it is compiling a particular .ts-file.
36
36
37
37
As you may have noticed, Angular2-Meteor package itself installs a number of these files into the **typings** folder.
38
38
Some of them have names `angular2.d.ts` and `meteor.d.ts`, which, as you can guess, are used to verify that API of Meteor and Angular 2 are being used correctly in your code.
39
39
40
-
But let’s create own declaration file to learn this type-checking better.
40
+
But let’s create our own declaration file in order to learn this type-checking better.
41
41
Keep in mind, type-checking is not delivered in the outputted JavaScript. It is only extra sugar for your development environment, and adds no weight to the outputted .js file.
42
42
43
43
## Type Declaration Files
@@ -49,7 +49,7 @@ Let's create `party.d.ts` file and place it inside “typings” folder with the
0 commit comments